Repository navigation
feat(lathe): add personal command snips - #243
Merged
Merged
Conversation
Add a built-in `snip` framework command (`set`, `list`, `delete`, `run`, and `<cli> snip <name>`) that persists personal command bookmarks in `snips.yml`. Support contiguous `$1` positional placeholders, `$$` escapes, and trailing flag overrides while keeping snips out of the machine catalog. Reserve `snip` as a root command name during code generation and include `snip` guidance in generated `SKILL.md` files. Signed-off-by: samzong <samzong.lu@gmail.com>
Place caller trailing flags before a saved `--` separator and check target command flag arity before treating `-h` or `--help` as help. Stop subcommand descent at `--` during target resolution and allocate table rows without size multiplication. Signed-off-by: samzong <samzong.lu@gmail.com>
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
Add a built-in
snipframework command (set,list,delete,run, and<cli> snip <name>) to every generated CLI.The CLI stores personal command bookmarks in
snips.ymlinside the existing CLI configuration directory ($<CLI>_CONFIG_DIR,$XDG_CONFIG_HOME/<cli-name>, or~/.config/<cli-name>).This mechanism avoids
cli.yamlchanges and keeps user bookmarks separate fromhosts.ymlcredentials and compiled overlay shortcuts.Support
$1,$2, and higher contiguous positional placeholders,$$literal escapes, and trailing scalar or--setflag overrides.Reject flag values in unescaped placeholder positions so omitted arguments cannot consume
--dry-runbefore write operations.Reserve
snipas a root command during code generation and includeSaved Snipsguidance in generatedSKILL.mdfiles.Verification
GOROOT="$(GOTOOLCHAIN=go1.26.0 go env GOROOT)" PATH="$(GOTOOLCHAIN=go1.26.0 go env GOROOT)/bin:$PATH" make checkpassed (fmt-check,go vet,golangci-lintwith 0 issues, andgo test ./...).go test -race ./...passed across all packages, includingpkg/config,pkg/lathe, andinternal/codegen/render.examples/petstorebuild passedpetstore __lathe verify --json(includingskill_install),snip set,snip list,snip get-pet 42 --dry-run,snip delete, user-scope Skill install--dry-run, and project-scope Skill install.MoveFileExatomic replacement forsnips.ymlwas not executed on macOS. It reuses the existingwriteFileAtomicpath inpkg/config.Compatibility
runtime.SchemaVersionandruntime.CatalogSchemaVersionare unchanged.commands --jsonorsearch.snipis now a reserved root command name in code generation. Single-module specs with aSnipgroup automatically use namespaced paths undercli.command_path: auto.snipcommand when rebuilt against the new runtime and pick upSKILL.mdguidance on the nextlathe codegenrun.Checklist
internal/generated/,.cache/, and ad-hocskills/<cli-name>/directories is not committed.