Repository navigation
Conversation
…ection - Add ScriptImporter: detect the language from content (shebang, then syntax sniffing, then extension fallback), normalize BOM and CRLF, and prepend a shebang when the source has none - Add an "Import Script" card to the new-task sheet using NSOpenPanel with no content-type restriction - Show the source file, detected language, and line count after import, and surface fallback warnings as amber notes - Add 14 unit tests covering detection, normalization, and the binary/oversized rejection paths - Document the feature in README.md and README.en.md
RuochenLyu
added a commit
that referenced
this pull request
Nov 25, 2026
The new-task sheet gains an eighth card, 导入文件, that copies a local file into the task's run.sh via the file picker or drag-and-drop. The interpreter comes only from reliable signals: a byte-0 shebang is kept verbatim, otherwise the file extension picks one, otherwise zsh. Content sniffing is deliberately absent; it misreads ordinary shell, Perl, Ruby and ESM files as Python and fails silently. Interpreter checks use launchd's fixed PATH, which both scheduled and manual runs inherit, so `#!/usr/bin/env node` that works in Terminal is flagged before the task exists. Chosen interpreters resolve Homebrew first and are written as absolute paths. Non-regular files, files over 128 KiB, UTF-16, binary, non-UTF-8 and empty files are rejected with one short message each. No schema, CLI, lock or on-disk format change. Supersedes #3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
感谢这个 PR,「从本地文件导入脚本」确实是我们缺的功能,方向完全认同。 我们没有直接合并,而是按项目的约束重新实现了一版,已随 Run Shelf 1.7.0 发布:https://github.com/RuochenLyu/run-shelf/releases/tag/v1.7.0 和这个 PR 的主要差别,供参考:
设计和评审记录在 |
Author
|
感谢你的评审意见,你的设计确实更好也更严谨 —— 内容嗅探的误判、缩进的 我的本意只是想为项目做一点贡献。方便的话,能否在 |
Owner
|
当然可以,已经加上了:
这个功能是你最先提出并动手实现的,署名理所应当。谢谢你的贡献,也谢谢你认真核对评审意见 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a way to import an existing script when creating a task, instead of pasting its contents by hand.
Features
.sh,.py,.rb,.txt, and extension-less files are all selectable.#!/usr/bin/env -S node --enable-source-mapsform;run.shis executed directly, so a file without one cannot run.Testing
Environment: macOS 26.5, Xcode 26.5, Intel host.
ScriptImporterTests: 14/14 pass. Covers direct andenv -Sshebang detection, content-over-extension, extension fallback with warning, unknown-text fallback, CRLF/BOM normalization, empty input, binary rejection, oversized rejection, and reading a real file from disk.testBackgroundPriorityRunsBelowStandard. It asserts a probe collects twops -o pri=samples and gets 0 here, becausepsis blocked for the process running the tests in this environment (operation not permitted). It is unrelated to this change and also fails on unmodifiedmainhere.scripts/check.shthat do not need Bundler all pass: JSON schemas parse,generate_cli_schemas.rb --checkin sync,sync_xcodeproj_files.rb --checkin sync,ruby -c/bash -non every script,plutil -linton the LaunchAgent plist,git diff --checkclean.scripts/check.shcould not run end to end here: its first step isbundle check, and the Gemfile pins Bundler 2.4.22 while this machine only has system Ruby 2.6. Its Tests and Universal Debug build phases were run directly instead; the Universal build produces anx86_64 arm64binary.The repo has no UI test target, so the new card is covered by unit tests at the model layer plus manual verification. I am not claiming automated UI coverage.
Motivation
Reusing an existing script currently means opening it in an editor and copying the whole file into the new-task sheet. That is fine for a five-line one-liner and painful for a 200-line script, and the copied task loses any link to the file it came from. Importing keeps the workflow file-native, which is how the rest of Run Shelf already treats tasks and run history.
Checklist
scripts/check.sh— every gate that does not require Bundler passes (see Testing for the two that cannot run here, and why)bundle exec ruby scripts/sync_xcodeproj_files.rbschemas/*.jsonuntouched, soGeneratedSchemas.swiftneeds no regeneration — nothing to tick here