Skip to content

feat(lathe): add personal command snips - #243

Merged
samzong merged 2 commits into
mainfrom
feat/snip-commands
Nov 24, 2026
Merged

samzong merged 2 commits into
mainfrom
feat/snip-commands

Conversation

@samzong

@samzong samzong commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add a built-in snip framework command (set, list, delete, run, and <cli> snip <name>) to every generated CLI.
The CLI stores personal command bookmarks in snips.yml inside the existing CLI configuration directory ($<CLI>_CONFIG_DIR, $XDG_CONFIG_HOME/<cli-name>, or ~/.config/<cli-name>).
This mechanism avoids cli.yaml changes and keeps user bookmarks separate from hosts.yml credentials and compiled overlay shortcuts.

Support $1, $2, and higher contiguous positional placeholders, $$ literal escapes, and trailing scalar or --set flag overrides.
Reject flag values in unescaped placeholder positions so omitted arguments cannot consume --dry-run before write operations.
Reserve snip as a root command during code generation and include Saved Snips guidance in generated SKILL.md files.

Verification

  • GOROOT="$(GOTOOLCHAIN=go1.26.0 go env GOROOT)" PATH="$(GOTOOLCHAIN=go1.26.0 go env GOROOT)/bin:$PATH" make check passed (fmt-check, go vet, golangci-lint with 0 issues, and go test ./...).
  • go test -race ./... passed across all packages, including pkg/config, pkg/lathe, and internal/codegen/render.
  • Scratch examples/petstore build passed petstore __lathe verify --json (including skill_install), snip set, snip list, snip get-pet 42 --dry-run, snip delete, user-scope Skill install --dry-run, and project-scope Skill install.
  • Unverified: Windows MoveFileEx atomic replacement for snips.yml was not executed on macOS. It reuses the existing writeFileAtomic path in pkg/config.

Compatibility

  • runtime.SchemaVersion and runtime.CatalogSchemaVersion are unchanged.
  • Saved snips are local operator state and do not appear in commands --json or search.
  • snip is now a reserved root command name in code generation. Single-module specs with a Snip group automatically use namespaced paths under cli.command_path: auto.
  • Existing CLIs pick up the snip command when rebuilt against the new runtime and pick up SKILL.md guidance on the next lathe codegen run.

Checklist

  • Tests or focused verification cover the changed surface.
  • User-facing behavior changes are documented.
  • Generated output under internal/generated/, .cache/, and ad-hoc skills/<cli-name>/ directories is not committed.
  • Commits are signed off when this is ready to merge.

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>
@ghfind-review ghfind-review Bot added the review: top ghfind author score; see https://ghfind.com label Nov 24, 2026
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>
@samzong
samzong marked this pull request as ready for review November 24, 2026 17:41
@samzong
samzong merged commit c4b144f into main Nov 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: top ghfind author score; see https://ghfind.com

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant