agentplane 0.1.9 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/assets/AGENTS.md +281 -70
- package/assets/agents/CODER.json +1 -0
- package/assets/agents/INTEGRATOR.json +1 -0
- package/assets/agents/ORCHESTRATOR.json +1 -0
- package/assets/agents/PLANNER.json +1 -0
- package/assets/agents/TESTER.json +1 -0
- package/dist/backends/task-backend/load.d.ts +13 -0
- package/dist/backends/task-backend/load.d.ts.map +1 -0
- package/dist/backends/task-backend/load.js +58 -0
- package/dist/backends/task-backend/local-backend.d.ts +28 -0
- package/dist/backends/task-backend/local-backend.d.ts.map +1 -0
- package/dist/backends/task-backend/local-backend.js +335 -0
- package/dist/backends/task-backend/redmine/client.d.ts +8 -0
- package/dist/backends/task-backend/redmine/client.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/client.js +60 -0
- package/dist/backends/task-backend/redmine/comments.d.ts +12 -0
- package/dist/backends/task-backend/redmine/comments.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/comments.js +54 -0
- package/dist/backends/task-backend/redmine/fields.d.ts +9 -0
- package/dist/backends/task-backend/redmine/fields.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/fields.js +38 -0
- package/dist/backends/task-backend/redmine/mapping.d.ts +20 -0
- package/dist/backends/task-backend/redmine/mapping.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/mapping.js +114 -0
- package/dist/backends/task-backend/redmine/parse.d.ts +3 -0
- package/dist/backends/task-backend/redmine/parse.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/parse.js +27 -0
- package/dist/backends/task-backend/redmine/remote.d.ts +19 -0
- package/dist/backends/task-backend/redmine/remote.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/remote.js +82 -0
- package/dist/backends/task-backend/redmine-backend.d.ts +80 -0
- package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine-backend.js +505 -0
- package/dist/backends/task-backend/shared/concurrency.d.ts +3 -0
- package/dist/backends/task-backend/shared/concurrency.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/concurrency.js +21 -0
- package/dist/backends/task-backend/shared/constants.d.ts +4 -0
- package/dist/backends/task-backend/shared/constants.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/constants.js +4 -0
- package/dist/backends/task-backend/shared/doc.d.ts +11 -0
- package/dist/backends/task-backend/shared/doc.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/doc.js +78 -0
- package/dist/backends/task-backend/shared/errors.d.ts +10 -0
- package/dist/backends/task-backend/shared/errors.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/errors.js +18 -0
- package/dist/backends/task-backend/shared/events.d.ts +3 -0
- package/dist/backends/task-backend/shared/events.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/events.js +29 -0
- package/dist/backends/task-backend/shared/export.d.ts +15 -0
- package/dist/backends/task-backend/shared/export.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/export.js +60 -0
- package/dist/backends/task-backend/shared/id.d.ts +13 -0
- package/dist/backends/task-backend/shared/id.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/id.js +17 -0
- package/dist/backends/task-backend/shared/normalize.d.ts +8 -0
- package/dist/backends/task-backend/shared/normalize.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/normalize.js +54 -0
- package/dist/backends/task-backend/shared/record.d.ts +4 -0
- package/dist/backends/task-backend/shared/record.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/record.js +53 -0
- package/dist/backends/task-backend/shared/strings.d.ts +4 -0
- package/dist/backends/task-backend/shared/strings.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/strings.js +21 -0
- package/dist/backends/task-backend/shared/types.d.ts +84 -0
- package/dist/backends/task-backend/shared/types.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/types.js +1 -0
- package/dist/backends/task-backend/shared.d.ts +11 -0
- package/dist/backends/task-backend/shared.d.ts.map +1 -0
- package/dist/backends/task-backend/shared.js +9 -0
- package/dist/backends/task-backend.d.ts +4 -204
- package/dist/backends/task-backend.d.ts.map +1 -1
- package/dist/backends/task-backend.js +4 -1366
- package/dist/backends/task-index.js +2 -2
- package/dist/cli/archive.d.ts +0 -2
- package/dist/cli/archive.d.ts.map +1 -1
- package/dist/cli/archive.js +1 -2
- package/dist/cli/command-guide.d.ts.map +1 -1
- package/dist/cli/command-guide.js +25 -8
- package/dist/cli/parse/lifecycle.d.ts +64 -0
- package/dist/cli/parse/lifecycle.d.ts.map +1 -0
- package/dist/cli/parse/lifecycle.js +280 -0
- package/dist/cli/run-cli/command-catalog.d.ts +16 -0
- package/dist/cli/run-cli/command-catalog.d.ts.map +1 -0
- package/dist/cli/run-cli/command-catalog.js +204 -0
- package/dist/cli/run-cli/commands/config.d.ts +20 -0
- package/dist/cli/run-cli/commands/config.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/config.js +130 -0
- package/dist/cli/run-cli/commands/core.d.ts +14 -0
- package/dist/cli/run-cli/commands/core.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/core.js +144 -0
- package/dist/cli/run-cli/commands/ide.d.ts +13 -0
- package/dist/cli/run-cli/commands/ide.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/ide.js +67 -0
- package/dist/cli/run-cli/commands/init/base-branch.d.ts +9 -0
- package/dist/cli/run-cli/commands/init/base-branch.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/base-branch.js +11 -0
- package/dist/cli/run-cli/commands/init/conflicts.d.ts +11 -0
- package/dist/cli/run-cli/commands/init/conflicts.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/conflicts.js +42 -0
- package/dist/cli/run-cli/commands/init/git.d.ts +8 -0
- package/dist/cli/run-cli/commands/init/git.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/git.js +12 -0
- package/dist/cli/run-cli/commands/init/ide-sync.d.ts +9 -0
- package/dist/cli/run-cli/commands/init/ide-sync.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/ide-sync.js +18 -0
- package/dist/cli/run-cli/commands/init/recipes.d.ts +2 -0
- package/dist/cli/run-cli/commands/init/recipes.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/recipes.js +11 -0
- package/dist/cli/run-cli/commands/init/write-agents.d.ts +11 -0
- package/dist/cli/run-cli/commands/init/write-agents.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/write-agents.js +30 -0
- package/dist/cli/run-cli/commands/init/write-config.d.ts +15 -0
- package/dist/cli/run-cli/commands/init/write-config.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/write-config.js +45 -0
- package/dist/cli/run-cli/commands/init.d.ts +21 -0
- package/dist/cli/run-cli/commands/init.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init.js +332 -0
- package/dist/cli/run-cli/registry.run.d.ts +4 -0
- package/dist/cli/run-cli/registry.run.d.ts.map +1 -0
- package/dist/cli/run-cli/registry.run.js +19 -0
- package/dist/cli/run-cli.d.ts.map +1 -1
- package/dist/cli/run-cli.js +182 -2463
- package/dist/cli/spec/docs-render.d.ts +3 -0
- package/dist/cli/spec/docs-render.d.ts.map +1 -0
- package/dist/cli/spec/docs-render.js +118 -0
- package/dist/cli/spec/errors.d.ts +9 -0
- package/dist/cli/spec/errors.d.ts.map +1 -0
- package/dist/cli/spec/errors.js +18 -0
- package/dist/cli/spec/help-render.d.ts +43 -0
- package/dist/cli/spec/help-render.d.ts.map +1 -0
- package/dist/cli/spec/help-render.js +185 -0
- package/dist/cli/spec/help.d.ts +10 -0
- package/dist/cli/spec/help.d.ts.map +1 -0
- package/dist/cli/spec/help.js +64 -0
- package/dist/cli/spec/parse.d.ts +8 -0
- package/dist/cli/spec/parse.d.ts.map +1 -0
- package/dist/cli/spec/parse.js +188 -0
- package/dist/cli/spec/registry.d.ts +12 -0
- package/dist/cli/spec/registry.d.ts.map +1 -0
- package/dist/cli/spec/registry.js +47 -0
- package/dist/cli/spec/spec.d.ts +76 -0
- package/dist/cli/spec/spec.d.ts.map +1 -0
- package/dist/cli/spec/spec.js +1 -0
- package/dist/cli/spec/suggest.d.ts +2 -0
- package/dist/cli/spec/suggest.d.ts.map +1 -0
- package/dist/cli/spec/suggest.js +45 -0
- package/dist/commands/backend/sync.command.d.ts +12 -0
- package/dist/commands/backend/sync.command.d.ts.map +1 -0
- package/dist/commands/backend/sync.command.js +79 -0
- package/dist/commands/backend.d.ts +21 -8
- package/dist/commands/backend.d.ts.map +1 -1
- package/dist/commands/backend.js +28 -165
- package/dist/commands/block.command.d.ts +19 -0
- package/dist/commands/block.command.d.ts.map +1 -0
- package/dist/commands/block.command.js +143 -0
- package/dist/commands/branch/base.command.d.ts +20 -0
- package/dist/commands/branch/base.command.d.ts.map +1 -0
- package/dist/commands/branch/base.command.js +110 -0
- package/dist/commands/branch/base.d.ts +19 -0
- package/dist/commands/branch/base.d.ts.map +1 -0
- package/dist/commands/branch/base.js +114 -0
- package/dist/commands/branch/cleanup-merged.d.ts +11 -0
- package/dist/commands/branch/cleanup-merged.d.ts.map +1 -0
- package/dist/commands/branch/cleanup-merged.js +141 -0
- package/dist/commands/branch/index.d.ts +6 -59
- package/dist/commands/branch/index.d.ts.map +1 -1
- package/dist/commands/branch/index.js +6 -513
- package/dist/commands/branch/internal/archive-pr.d.ts +2 -0
- package/dist/commands/branch/internal/archive-pr.d.ts.map +1 -0
- package/dist/commands/branch/internal/archive-pr.js +17 -0
- package/dist/commands/branch/internal/work-validate.d.ts +3 -0
- package/dist/commands/branch/internal/work-validate.d.ts.map +1 -0
- package/dist/commands/branch/internal/work-validate.js +27 -0
- package/dist/commands/branch/remove.command.d.ts +10 -0
- package/dist/commands/branch/remove.command.d.ts.map +1 -0
- package/dist/commands/branch/remove.command.js +63 -0
- package/dist/commands/branch/remove.d.ts +9 -0
- package/dist/commands/branch/remove.d.ts.map +1 -0
- package/dist/commands/branch/remove.js +65 -0
- package/dist/commands/branch/status.command.d.ts +8 -0
- package/dist/commands/branch/status.command.d.ts.map +1 -0
- package/dist/commands/branch/status.command.js +36 -0
- package/dist/commands/branch/status.d.ts +7 -0
- package/dist/commands/branch/status.d.ts.map +1 -0
- package/dist/commands/branch/status.js +60 -0
- package/dist/commands/branch/work-start.command.d.ts +11 -0
- package/dist/commands/branch/work-start.command.d.ts.map +1 -0
- package/dist/commands/branch/work-start.command.js +80 -0
- package/dist/commands/branch/work-start.d.ts +11 -0
- package/dist/commands/branch/work-start.d.ts.map +1 -0
- package/dist/commands/branch/work-start.js +120 -0
- package/dist/commands/cleanup/merged.command.d.ts +17 -0
- package/dist/commands/cleanup/merged.command.d.ts.map +1 -0
- package/dist/commands/cleanup/merged.command.js +75 -0
- package/dist/commands/commit.command.d.ts +6 -0
- package/dist/commands/commit.command.d.ts.map +1 -0
- package/dist/commands/commit.command.js +24 -0
- package/dist/commands/commit.spec.d.ts +18 -0
- package/dist/commands/commit.spec.d.ts.map +1 -0
- package/dist/commands/commit.spec.js +119 -0
- package/dist/commands/docs/cli.command.d.ts +9 -0
- package/dist/commands/docs/cli.command.d.ts.map +1 -0
- package/dist/commands/docs/cli.command.js +51 -0
- package/dist/commands/finish.command.d.ts +28 -0
- package/dist/commands/finish.command.d.ts.map +1 -0
- package/dist/commands/finish.command.js +237 -0
- package/dist/commands/guard/clean.command.d.ts +7 -0
- package/dist/commands/guard/clean.command.d.ts.map +1 -0
- package/dist/commands/guard/clean.command.js +14 -0
- package/dist/commands/guard/commit.command.d.ts +19 -0
- package/dist/commands/guard/commit.command.d.ts.map +1 -0
- package/dist/commands/guard/commit.command.js +132 -0
- package/dist/commands/guard/guard.command.d.ts +5 -0
- package/dist/commands/guard/guard.command.d.ts.map +1 -0
- package/dist/commands/guard/guard.command.js +21 -0
- package/dist/commands/guard/impl/allow.d.ts +18 -0
- package/dist/commands/guard/impl/allow.d.ts.map +1 -0
- package/dist/commands/guard/impl/allow.js +77 -0
- package/dist/commands/guard/impl/close-message.d.ts +16 -0
- package/dist/commands/guard/impl/close-message.d.ts.map +1 -0
- package/dist/commands/guard/impl/close-message.js +156 -0
- package/dist/commands/guard/impl/commands.d.ts +32 -0
- package/dist/commands/guard/impl/commands.d.ts.map +1 -0
- package/dist/commands/guard/impl/commands.js +191 -0
- package/dist/commands/guard/impl/comment-commit.d.ts +25 -0
- package/dist/commands/guard/impl/comment-commit.d.ts.map +1 -0
- package/dist/commands/guard/impl/comment-commit.js +137 -0
- package/dist/commands/guard/impl/env.d.ts +10 -0
- package/dist/commands/guard/impl/env.d.ts.map +1 -0
- package/dist/commands/guard/impl/env.js +12 -0
- package/dist/commands/guard/impl/policy.d.ts +19 -0
- package/dist/commands/guard/impl/policy.d.ts.map +1 -0
- package/dist/commands/guard/impl/policy.js +46 -0
- package/dist/commands/guard/index.d.ts +4 -87
- package/dist/commands/guard/index.d.ts.map +1 -1
- package/dist/commands/guard/index.js +4 -481
- package/dist/commands/guard/suggest-allow.command.d.ts +7 -0
- package/dist/commands/guard/suggest-allow.command.d.ts.map +1 -0
- package/dist/commands/guard/suggest-allow.command.js +28 -0
- package/dist/commands/hooks/hooks.command.d.ts +5 -0
- package/dist/commands/hooks/hooks.command.d.ts.map +1 -0
- package/dist/commands/hooks/hooks.command.js +18 -0
- package/dist/commands/hooks/index.d.ts.map +1 -1
- package/dist/commands/hooks/index.js +36 -81
- package/dist/commands/hooks/install.command.d.ts +7 -0
- package/dist/commands/hooks/install.command.d.ts.map +1 -0
- package/dist/commands/hooks/install.command.js +14 -0
- package/dist/commands/hooks/run.command.d.ts +9 -0
- package/dist/commands/hooks/run.command.d.ts.map +1 -0
- package/dist/commands/hooks/run.command.js +39 -0
- package/dist/commands/hooks/uninstall.command.d.ts +7 -0
- package/dist/commands/hooks/uninstall.command.d.ts.map +1 -0
- package/dist/commands/hooks/uninstall.command.js +16 -0
- package/dist/commands/integrate.command.d.ts +14 -0
- package/dist/commands/integrate.command.d.ts.map +1 -0
- package/dist/commands/integrate.command.js +61 -0
- package/dist/commands/pr/check.d.ts +8 -0
- package/dist/commands/pr/check.d.ts.map +1 -0
- package/dist/commands/pr/check.js +78 -0
- package/dist/commands/pr/index.d.ts +5 -45
- package/dist/commands/pr/index.d.ts.map +1 -1
- package/dist/commands/pr/index.js +5 -857
- package/dist/commands/pr/integrate/artifacts.d.ts +14 -0
- package/dist/commands/pr/integrate/artifacts.d.ts.map +1 -0
- package/dist/commands/pr/integrate/artifacts.js +45 -0
- package/dist/commands/pr/integrate/cmd.d.ts +14 -0
- package/dist/commands/pr/integrate/cmd.d.ts.map +1 -0
- package/dist/commands/pr/integrate/cmd.js +150 -0
- package/dist/commands/pr/integrate/internal/finalize.d.ts +25 -0
- package/dist/commands/pr/integrate/internal/finalize.d.ts.map +1 -0
- package/dist/commands/pr/integrate/internal/finalize.js +86 -0
- package/dist/commands/pr/integrate/internal/merge.d.ts +40 -0
- package/dist/commands/pr/integrate/internal/merge.d.ts.map +1 -0
- package/dist/commands/pr/integrate/internal/merge.js +138 -0
- package/dist/commands/pr/integrate/internal/prepare.d.ts +33 -0
- package/dist/commands/pr/integrate/internal/prepare.d.ts.map +1 -0
- package/dist/commands/pr/integrate/internal/prepare.js +142 -0
- package/dist/commands/pr/integrate/internal/worktree.d.ts +14 -0
- package/dist/commands/pr/integrate/internal/worktree.d.ts.map +1 -0
- package/dist/commands/pr/integrate/internal/worktree.js +51 -0
- package/dist/commands/pr/integrate/verify.d.ts +22 -0
- package/dist/commands/pr/integrate/verify.d.ts.map +1 -0
- package/dist/commands/pr/integrate/verify.js +60 -0
- package/dist/commands/pr/integrate.d.ts +2 -0
- package/dist/commands/pr/integrate.d.ts.map +1 -0
- package/dist/commands/pr/integrate.js +1 -0
- package/dist/commands/pr/internal/pr-paths.d.ts +29 -0
- package/dist/commands/pr/internal/pr-paths.d.ts.map +1 -0
- package/dist/commands/pr/internal/pr-paths.js +38 -0
- package/dist/commands/pr/internal/review-template.d.ts +9 -0
- package/dist/commands/pr/internal/review-template.d.ts.map +1 -0
- package/dist/commands/pr/internal/review-template.js +62 -0
- package/dist/commands/pr/note.d.ts +10 -0
- package/dist/commands/pr/note.d.ts.map +1 -0
- package/dist/commands/pr/note.js +50 -0
- package/dist/commands/pr/open.d.ts +10 -0
- package/dist/commands/pr/open.d.ts.map +1 -0
- package/dist/commands/pr/open.js +80 -0
- package/dist/commands/pr/pr.command.d.ts +33 -0
- package/dist/commands/pr/pr.command.d.ts.map +1 -0
- package/dist/commands/pr/pr.command.js +172 -0
- package/dist/commands/pr/update.d.ts +8 -0
- package/dist/commands/pr/update.d.ts.map +1 -0
- package/dist/commands/pr/update.js +103 -0
- package/dist/commands/ready.command.d.ts +8 -0
- package/dist/commands/ready.command.d.ts.map +1 -0
- package/dist/commands/ready.command.js +28 -0
- package/dist/commands/recipes/cache-prune.command.d.ts +6 -0
- package/dist/commands/recipes/cache-prune.command.d.ts.map +1 -0
- package/dist/commands/recipes/cache-prune.command.js +30 -0
- package/dist/commands/recipes/cache.command.d.ts +6 -0
- package/dist/commands/recipes/cache.command.d.ts.map +1 -0
- package/dist/commands/recipes/cache.command.js +37 -0
- package/dist/commands/recipes/explain.command.d.ts +7 -0
- package/dist/commands/recipes/explain.command.d.ts.map +1 -0
- package/dist/commands/recipes/explain.command.js +10 -0
- package/dist/commands/recipes/impl/apply.d.ts +16 -0
- package/dist/commands/recipes/impl/apply.d.ts.map +1 -0
- package/dist/commands/recipes/impl/apply.js +97 -0
- package/dist/commands/recipes/impl/archive.d.ts +2 -0
- package/dist/commands/recipes/impl/archive.d.ts.map +1 -0
- package/dist/commands/recipes/impl/archive.js +19 -0
- package/dist/commands/recipes/impl/commands/cache-prune.d.ts +7 -0
- package/dist/commands/recipes/impl/commands/cache-prune.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/cache-prune.js +94 -0
- package/dist/commands/recipes/impl/commands/explain.d.ts +6 -0
- package/dist/commands/recipes/impl/commands/explain.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/explain.js +88 -0
- package/dist/commands/recipes/impl/commands/info.d.ts +6 -0
- package/dist/commands/recipes/impl/commands/info.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/info.js +58 -0
- package/dist/commands/recipes/impl/commands/install.d.ts +11 -0
- package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/install.js +212 -0
- package/dist/commands/recipes/impl/commands/list-remote.d.ts +7 -0
- package/dist/commands/recipes/impl/commands/list-remote.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/list-remote.js +53 -0
- package/dist/commands/recipes/impl/commands/list.d.ts +7 -0
- package/dist/commands/recipes/impl/commands/list.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/list.js +38 -0
- package/dist/commands/recipes/impl/commands/remove.d.ts +6 -0
- package/dist/commands/recipes/impl/commands/remove.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/remove.js +35 -0
- package/dist/commands/recipes/impl/commands.d.ts +8 -0
- package/dist/commands/recipes/impl/commands.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands.js +7 -0
- package/dist/commands/recipes/impl/constants.d.ts +13 -0
- package/dist/commands/recipes/impl/constants.d.ts.map +1 -0
- package/dist/commands/recipes/impl/constants.js +16 -0
- package/dist/commands/recipes/impl/format.d.ts +2 -0
- package/dist/commands/recipes/impl/format.d.ts.map +1 -0
- package/dist/commands/recipes/impl/format.js +9 -0
- package/dist/commands/recipes/impl/index.d.ts +12 -0
- package/dist/commands/recipes/impl/index.d.ts.map +1 -0
- package/dist/commands/recipes/impl/index.js +150 -0
- package/dist/commands/recipes/impl/installed-recipes.d.ts +4 -0
- package/dist/commands/recipes/impl/installed-recipes.d.ts.map +1 -0
- package/dist/commands/recipes/impl/installed-recipes.js +58 -0
- package/dist/commands/recipes/impl/manifest.d.ts +4 -0
- package/dist/commands/recipes/impl/manifest.d.ts.map +1 -0
- package/dist/commands/recipes/impl/manifest.js +43 -0
- package/dist/commands/recipes/impl/normalize.d.ts +5 -0
- package/dist/commands/recipes/impl/normalize.d.ts.map +1 -0
- package/dist/commands/recipes/impl/normalize.js +50 -0
- package/dist/commands/recipes/impl/paths.d.ts +13 -0
- package/dist/commands/recipes/impl/paths.d.ts.map +1 -0
- package/dist/commands/recipes/impl/paths.js +27 -0
- package/dist/commands/recipes/impl/project.d.ts +8 -0
- package/dist/commands/recipes/impl/project.d.ts.map +1 -0
- package/dist/commands/recipes/impl/project.js +23 -0
- package/dist/commands/recipes/impl/scenario.d.ts +16 -0
- package/dist/commands/recipes/impl/scenario.d.ts.map +1 -0
- package/dist/commands/recipes/impl/scenario.js +128 -0
- package/dist/commands/recipes/impl/types.d.ts +107 -0
- package/dist/commands/recipes/impl/types.d.ts.map +1 -0
- package/dist/commands/recipes/impl/types.js +1 -0
- package/dist/commands/recipes/info.command.d.ts +7 -0
- package/dist/commands/recipes/info.command.d.ts.map +1 -0
- package/dist/commands/recipes/info.command.js +10 -0
- package/dist/commands/recipes/install.command.d.ts +12 -0
- package/dist/commands/recipes/install.command.d.ts.map +1 -0
- package/dist/commands/recipes/install.command.js +161 -0
- package/dist/commands/recipes/list-remote.command.d.ts +6 -0
- package/dist/commands/recipes/list-remote.command.d.ts.map +1 -0
- package/dist/commands/recipes/list-remote.command.js +46 -0
- package/dist/commands/recipes/list.command.d.ts +6 -0
- package/dist/commands/recipes/list.command.d.ts.map +1 -0
- package/dist/commands/recipes/list.command.js +39 -0
- package/dist/commands/recipes/recipes.command.d.ts +6 -0
- package/dist/commands/recipes/recipes.command.d.ts.map +1 -0
- package/dist/commands/recipes/recipes.command.js +45 -0
- package/dist/commands/recipes/remove.command.d.ts +7 -0
- package/dist/commands/recipes/remove.command.d.ts.map +1 -0
- package/dist/commands/recipes/remove.command.js +10 -0
- package/dist/commands/recipes.d.ts +7 -81
- package/dist/commands/recipes.d.ts.map +1 -1
- package/dist/commands/recipes.js +6 -1457
- package/dist/commands/scenario/impl/commands.d.ts +19 -0
- package/dist/commands/scenario/impl/commands.d.ts.map +1 -0
- package/dist/commands/scenario/impl/commands.js +336 -0
- package/dist/commands/scenario/impl/report.d.ts +30 -0
- package/dist/commands/scenario/impl/report.d.ts.map +1 -0
- package/dist/commands/scenario/impl/report.js +99 -0
- package/dist/commands/scenario/info.command.d.ts +8 -0
- package/dist/commands/scenario/info.command.d.ts.map +1 -0
- package/dist/commands/scenario/info.command.js +27 -0
- package/dist/commands/scenario/list.command.d.ts +5 -0
- package/dist/commands/scenario/list.command.d.ts.map +1 -0
- package/dist/commands/scenario/list.command.js +9 -0
- package/dist/commands/scenario/run.command.d.ts +8 -0
- package/dist/commands/scenario/run.command.d.ts.map +1 -0
- package/dist/commands/scenario/run.command.js +27 -0
- package/dist/commands/scenario/scenario.command.d.ts +6 -0
- package/dist/commands/scenario/scenario.command.d.ts.map +1 -0
- package/dist/commands/scenario/scenario.command.js +37 -0
- package/dist/commands/scenario.d.ts +1 -6
- package/dist/commands/scenario.d.ts.map +1 -1
- package/dist/commands/scenario.js +1 -501
- package/dist/commands/shared/git-context.d.ts +23 -0
- package/dist/commands/shared/git-context.d.ts.map +1 -0
- package/dist/commands/shared/git-context.js +140 -0
- package/dist/commands/shared/policy-deny.d.ts +3 -0
- package/dist/commands/shared/policy-deny.d.ts.map +1 -0
- package/dist/commands/shared/policy-deny.js +12 -0
- package/dist/commands/shared/task-backend.d.ts +17 -5
- package/dist/commands/shared/task-backend.d.ts.map +1 -1
- package/dist/commands/shared/task-backend.js +34 -5
- package/dist/commands/shared/task-store.d.ts +16 -0
- package/dist/commands/shared/task-store.d.ts.map +1 -0
- package/dist/commands/shared/task-store.js +142 -0
- package/dist/commands/start.command.d.ts +19 -0
- package/dist/commands/start.command.d.ts.map +1 -0
- package/dist/commands/start.command.js +143 -0
- package/dist/commands/sync.command.d.ts +6 -0
- package/dist/commands/sync.command.d.ts.map +1 -0
- package/dist/commands/sync.command.js +57 -0
- package/dist/commands/task/add.command.d.ts +18 -0
- package/dist/commands/task/add.command.d.ts.map +1 -0
- package/dist/commands/task/add.command.js +157 -0
- package/dist/commands/task/add.d.ts +13 -3
- package/dist/commands/task/add.d.ts.map +1 -1
- package/dist/commands/task/add.js +21 -126
- package/dist/commands/task/block.d.ts +2 -2
- package/dist/commands/task/block.d.ts.map +1 -1
- package/dist/commands/task/block.js +13 -9
- package/dist/commands/task/comment.command.d.ts +10 -0
- package/dist/commands/task/comment.command.d.ts.map +1 -0
- package/dist/commands/task/comment.command.js +57 -0
- package/dist/commands/task/comment.d.ts +2 -0
- package/dist/commands/task/comment.d.ts.map +1 -1
- package/dist/commands/task/comment.js +10 -7
- package/dist/commands/task/derive.command.d.ts +13 -0
- package/dist/commands/task/derive.command.d.ts.map +1 -0
- package/dist/commands/task/derive.command.js +94 -0
- package/dist/commands/task/derive.d.ts +13 -0
- package/dist/commands/task/derive.d.ts.map +1 -0
- package/dist/commands/task/derive.js +71 -0
- package/dist/commands/task/doc-set.command.d.ts +12 -0
- package/dist/commands/task/doc-set.command.d.ts.map +1 -0
- package/dist/commands/task/doc-set.command.js +82 -0
- package/dist/commands/task/doc-show.command.d.ts +10 -0
- package/dist/commands/task/doc-show.command.d.ts.map +1 -0
- package/dist/commands/task/doc-show.command.js +54 -0
- package/dist/commands/task/doc.command.d.ts +7 -0
- package/dist/commands/task/doc.command.d.ts.map +1 -0
- package/dist/commands/task/doc.command.js +22 -0
- package/dist/commands/task/doc.d.ts +9 -6
- package/dist/commands/task/doc.d.ts.map +1 -1
- package/dist/commands/task/doc.js +61 -113
- package/dist/commands/task/export.command.d.ts +6 -0
- package/dist/commands/task/export.command.d.ts.map +1 -0
- package/dist/commands/task/export.command.js +17 -0
- package/dist/commands/task/export.d.ts +2 -0
- package/dist/commands/task/export.d.ts.map +1 -1
- package/dist/commands/task/export.js +7 -9
- package/dist/commands/task/finish.d.ts +5 -4
- package/dist/commands/task/finish.d.ts.map +1 -1
- package/dist/commands/task/finish.js +50 -17
- package/dist/commands/task/index.d.ts +14 -13
- package/dist/commands/task/index.d.ts.map +1 -1
- package/dist/commands/task/index.js +13 -13
- package/dist/commands/task/lint.command.d.ts +5 -0
- package/dist/commands/task/lint.command.d.ts.map +1 -0
- package/dist/commands/task/lint.command.js +11 -0
- package/dist/commands/task/list.command.d.ts +9 -0
- package/dist/commands/task/list.command.d.ts.map +1 -0
- package/dist/commands/task/list.command.js +68 -0
- package/dist/commands/task/list.d.ts +6 -2
- package/dist/commands/task/list.d.ts.map +1 -1
- package/dist/commands/task/list.js +12 -15
- package/dist/commands/task/migrate-doc.command.d.ts +9 -0
- package/dist/commands/task/migrate-doc.command.d.ts.map +1 -0
- package/dist/commands/task/migrate-doc.command.js +65 -0
- package/dist/commands/task/migrate-doc.d.ts +3 -3
- package/dist/commands/task/migrate-doc.d.ts.map +1 -1
- package/dist/commands/task/migrate-doc.js +40 -47
- package/dist/commands/task/migrate.command.d.ts +10 -0
- package/dist/commands/task/migrate.command.d.ts.map +1 -0
- package/dist/commands/task/migrate.command.js +50 -0
- package/dist/commands/task/migrate.d.ts +5 -1
- package/dist/commands/task/migrate.d.ts.map +1 -1
- package/dist/commands/task/migrate.js +10 -44
- package/dist/commands/task/new.command.d.ts +6 -0
- package/dist/commands/task/new.command.d.ts.map +1 -0
- package/dist/commands/task/new.command.js +13 -0
- package/dist/commands/task/new.d.ts +13 -4
- package/dist/commands/task/new.d.ts.map +1 -1
- package/dist/commands/task/new.js +30 -92
- package/dist/commands/task/new.spec.d.ts +4 -0
- package/dist/commands/task/new.spec.d.ts.map +1 -0
- package/dist/commands/task/new.spec.js +79 -0
- package/dist/commands/task/next.command.d.ts +9 -0
- package/dist/commands/task/next.command.d.ts.map +1 -0
- package/dist/commands/task/next.command.js +89 -0
- package/dist/commands/task/next.d.ts +4 -1
- package/dist/commands/task/next.d.ts.map +1 -1
- package/dist/commands/task/next.js +15 -16
- package/dist/commands/task/normalize.command.d.ts +9 -0
- package/dist/commands/task/normalize.command.d.ts.map +1 -0
- package/dist/commands/task/normalize.command.js +39 -0
- package/dist/commands/task/normalize.d.ts +4 -1
- package/dist/commands/task/normalize.d.ts.map +1 -1
- package/dist/commands/task/normalize.js +18 -31
- package/dist/commands/task/plan-approve.command.d.ts +10 -0
- package/dist/commands/task/plan-approve.command.d.ts.map +1 -0
- package/dist/commands/task/plan-approve.command.js +54 -0
- package/dist/commands/task/plan-reject.command.d.ts +10 -0
- package/dist/commands/task/plan-reject.command.d.ts.map +1 -0
- package/dist/commands/task/plan-reject.command.js +59 -0
- package/dist/commands/task/plan-set.command.d.ts +11 -0
- package/dist/commands/task/plan-set.command.d.ts.map +1 -0
- package/dist/commands/task/plan-set.command.js +76 -0
- package/dist/commands/task/plan.d.ts +23 -10
- package/dist/commands/task/plan.d.ts.map +1 -1
- package/dist/commands/task/plan.js +182 -177
- package/dist/commands/task/ready.d.ts +2 -0
- package/dist/commands/task/ready.d.ts.map +1 -1
- package/dist/commands/task/ready.js +4 -6
- package/dist/commands/task/scaffold.command.d.ts +12 -0
- package/dist/commands/task/scaffold.command.d.ts.map +1 -0
- package/dist/commands/task/scaffold.command.js +73 -0
- package/dist/commands/task/scaffold.d.ts +7 -3
- package/dist/commands/task/scaffold.d.ts.map +1 -1
- package/dist/commands/task/scaffold.js +57 -67
- package/dist/commands/task/scrub.command.d.ts +11 -0
- package/dist/commands/task/scrub.command.d.ts.map +1 -0
- package/dist/commands/task/scrub.command.js +72 -0
- package/dist/commands/task/scrub.d.ts +6 -3
- package/dist/commands/task/scrub.d.ts.map +1 -1
- package/dist/commands/task/scrub.js +12 -68
- package/dist/commands/task/search.command.d.ts +11 -0
- package/dist/commands/task/search.command.d.ts.map +1 -0
- package/dist/commands/task/search.command.js +101 -0
- package/dist/commands/task/search.d.ts +5 -1
- package/dist/commands/task/search.d.ts.map +1 -1
- package/dist/commands/task/search.js +14 -23
- package/dist/commands/task/set-status.command.d.ts +21 -0
- package/dist/commands/task/set-status.command.d.ts.map +1 -0
- package/dist/commands/task/set-status.command.js +171 -0
- package/dist/commands/task/set-status.d.ts +2 -0
- package/dist/commands/task/set-status.d.ts.map +1 -1
- package/dist/commands/task/set-status.js +14 -8
- package/dist/commands/task/shared.d.ts +5 -0
- package/dist/commands/task/shared.d.ts.map +1 -1
- package/dist/commands/task/shared.js +50 -0
- package/dist/commands/task/show.command.d.ts +8 -0
- package/dist/commands/task/show.command.d.ts.map +1 -0
- package/dist/commands/task/show.command.js +19 -0
- package/dist/commands/task/show.d.ts +2 -0
- package/dist/commands/task/show.d.ts.map +1 -1
- package/dist/commands/task/show.js +5 -7
- package/dist/commands/task/start.d.ts +2 -2
- package/dist/commands/task/start.d.ts.map +1 -1
- package/dist/commands/task/start.js +48 -11
- package/dist/commands/task/update.command.d.ts +18 -0
- package/dist/commands/task/update.command.d.ts.map +1 -0
- package/dist/commands/task/update.command.js +141 -0
- package/dist/commands/task/update.d.ts +13 -3
- package/dist/commands/task/update.d.ts.map +1 -1
- package/dist/commands/task/update.js +31 -122
- package/dist/commands/task/verify-ok.command.d.ts +13 -0
- package/dist/commands/task/verify-ok.command.d.ts.map +1 -0
- package/dist/commands/task/verify-ok.command.js +83 -0
- package/dist/commands/task/verify-record.d.ts +30 -8
- package/dist/commands/task/verify-record.d.ts.map +1 -1
- package/dist/commands/task/verify-record.js +107 -117
- package/dist/commands/task/verify-rework.command.d.ts +13 -0
- package/dist/commands/task/verify-rework.command.d.ts.map +1 -0
- package/dist/commands/task/verify-rework.command.js +83 -0
- package/dist/commands/task/verify-show.command.d.ts +9 -0
- package/dist/commands/task/verify-show.command.d.ts.map +1 -0
- package/dist/commands/task/verify-show.command.js +38 -0
- package/dist/commands/task/verify.command.d.ts +7 -0
- package/dist/commands/task/verify.command.d.ts.map +1 -0
- package/dist/commands/task/verify.command.js +20 -0
- package/dist/commands/upgrade.command.d.ts +6 -0
- package/dist/commands/upgrade.command.d.ts.map +1 -0
- package/dist/commands/upgrade.command.js +104 -0
- package/dist/commands/upgrade.d.ts +19 -2
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +281 -85
- package/dist/commands/verify.command.d.ts +16 -0
- package/dist/commands/verify.command.d.ts.map +1 -0
- package/dist/commands/verify.command.js +113 -0
- package/dist/commands/workflow.d.ts +4 -6
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +4 -7
- package/dist/meta/release.d.ts +2 -0
- package/dist/meta/release.d.ts.map +1 -0
- package/dist/meta/release.js +50 -0
- package/dist/policy/evaluate.d.ts +3 -0
- package/dist/policy/evaluate.d.ts.map +1 -0
- package/dist/policy/evaluate.js +27 -0
- package/dist/policy/result.d.ts +7 -0
- package/dist/policy/result.d.ts.map +1 -0
- package/dist/policy/result.js +21 -0
- package/dist/policy/rules/allowlist.d.ts +3 -0
- package/dist/policy/rules/allowlist.d.ts.map +1 -0
- package/dist/policy/rules/allowlist.js +30 -0
- package/dist/policy/rules/branch-pr-base.d.ts +3 -0
- package/dist/policy/rules/branch-pr-base.d.ts.map +1 -0
- package/dist/policy/rules/branch-pr-base.js +43 -0
- package/dist/policy/rules/clean-tree.d.ts +3 -0
- package/dist/policy/rules/clean-tree.d.ts.map +1 -0
- package/dist/policy/rules/clean-tree.js +19 -0
- package/dist/policy/rules/commit-subject.d.ts +3 -0
- package/dist/policy/rules/commit-subject.d.ts.map +1 -0
- package/dist/policy/rules/commit-subject.js +33 -0
- package/dist/policy/rules/protected-paths.d.ts +3 -0
- package/dist/policy/rules/protected-paths.d.ts.map +1 -0
- package/dist/policy/rules/protected-paths.js +53 -0
- package/dist/policy/types.d.ts +38 -0
- package/dist/policy/types.d.ts.map +1 -0
- package/dist/policy/types.js +1 -0
- package/dist/shared/write-if-changed.d.ts +3 -0
- package/dist/shared/write-if-changed.d.ts.map +1 -0
- package/dist/shared/write-if-changed.js +25 -0
- package/package.json +3 -3
- package/dist/cli/help.d.ts +0 -2
- package/dist/cli/help.d.ts.map +0 -1
- package/dist/cli/help.js +0 -127
- package/dist/commands/task/verify.d.ts +0 -2
- package/dist/commands/task/verify.d.ts.map +0 -1
- package/dist/commands/task/verify.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-render.d.ts","sourceRoot":"","sources":["../../../src/cli/spec/docs-render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AA2BjD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,MAAM,CAsGnE"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
function escInline(text) {
|
|
2
|
+
return text.replaceAll("`", "\\`");
|
|
3
|
+
}
|
|
4
|
+
function toAnchor(text) {
|
|
5
|
+
return text
|
|
6
|
+
.toLowerCase()
|
|
7
|
+
.replaceAll(/[^a-z0-9]+/g, "-")
|
|
8
|
+
.replaceAll(/(^-|-$)/g, "");
|
|
9
|
+
}
|
|
10
|
+
function formatDefaultValue(value) {
|
|
11
|
+
if (value === undefined)
|
|
12
|
+
return "";
|
|
13
|
+
if (value === null)
|
|
14
|
+
return "null";
|
|
15
|
+
if (typeof value === "string")
|
|
16
|
+
return value;
|
|
17
|
+
if (typeof value === "number")
|
|
18
|
+
return String(value);
|
|
19
|
+
if (typeof value === "boolean")
|
|
20
|
+
return value ? "true" : "false";
|
|
21
|
+
if (typeof value === "bigint")
|
|
22
|
+
return value.toString();
|
|
23
|
+
try {
|
|
24
|
+
return JSON.stringify(value);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return "[unserializable]";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function renderCliDocsMdx(specs) {
|
|
31
|
+
const byGroup = new Map();
|
|
32
|
+
for (const s of specs) {
|
|
33
|
+
const g = s.group || "Other";
|
|
34
|
+
byGroup.set(g, [...(byGroup.get(g) ?? []), s]);
|
|
35
|
+
}
|
|
36
|
+
const groups = [...byGroup.keys()].toSorted((a, b) => a.localeCompare(b));
|
|
37
|
+
const groupEntries = groups.map((g) => ({
|
|
38
|
+
group: g,
|
|
39
|
+
specs: (byGroup.get(g) ?? []).toSorted((a, b) => a.id.join(" ").localeCompare(b.id.join(" "))),
|
|
40
|
+
}));
|
|
41
|
+
const indexLines = groupEntries.flatMap(({ group, specs }) => [
|
|
42
|
+
`- ${group}`,
|
|
43
|
+
...specs.map((s) => {
|
|
44
|
+
const title = s.id.join(" ");
|
|
45
|
+
return ` - [${title}](#${toAnchor(title)})`;
|
|
46
|
+
}),
|
|
47
|
+
]);
|
|
48
|
+
const bodyLines = groupEntries.flatMap(({ group, specs }) => {
|
|
49
|
+
const groupHeader = ["", `## ${group}`];
|
|
50
|
+
const commandBlocks = specs.flatMap((s) => {
|
|
51
|
+
const summaryLines = s.description
|
|
52
|
+
? ["", escInline(s.summary), "", escInline(s.description)]
|
|
53
|
+
: ["", escInline(s.summary)];
|
|
54
|
+
const usageLines = ["", "Usage:", "", "```text", ...(s.usage ?? []), "```"];
|
|
55
|
+
const visibleOpts = (s.options ?? []).filter((o) => !o.hidden);
|
|
56
|
+
const optionLines = visibleOpts.length === 0
|
|
57
|
+
? []
|
|
58
|
+
: [
|
|
59
|
+
"",
|
|
60
|
+
"Options:",
|
|
61
|
+
"",
|
|
62
|
+
...visibleOpts.map((o) => {
|
|
63
|
+
const short = o.short ? `-${o.short}, ` : "";
|
|
64
|
+
const head = o.kind === "string"
|
|
65
|
+
? `${short}--${o.name} ${o.valueHint ?? "<value>"}`
|
|
66
|
+
: `${short}--${o.name}`;
|
|
67
|
+
const meta = [
|
|
68
|
+
o.required ? "required" : null,
|
|
69
|
+
o.repeatable ? "repeatable" : null,
|
|
70
|
+
o.choices && o.choices.length > 0 ? `choices=${o.choices.join("|")}` : null,
|
|
71
|
+
o.patternHint ? `format=${o.patternHint}` : null,
|
|
72
|
+
o.default === undefined ? null : `default=${formatDefaultValue(o.default)}`,
|
|
73
|
+
o.deprecated ? `deprecated=${o.deprecated}` : null,
|
|
74
|
+
].filter((x) => x !== null);
|
|
75
|
+
const suffix = meta.length > 0 ? ` (${meta.join(", ")})` : "";
|
|
76
|
+
return `- \`${escInline(head)}\`: ${escInline(o.description)}${escInline(suffix)}`;
|
|
77
|
+
}),
|
|
78
|
+
];
|
|
79
|
+
const notesLines = s.notes && s.notes.length > 0
|
|
80
|
+
? ["", "Notes:", "", ...s.notes.map((n) => `- ${escInline(n)}`)]
|
|
81
|
+
: [];
|
|
82
|
+
const examplesLines = s.examples && s.examples.length > 0
|
|
83
|
+
? [
|
|
84
|
+
"",
|
|
85
|
+
"Examples:",
|
|
86
|
+
"",
|
|
87
|
+
...s.examples.flatMap((ex) => {
|
|
88
|
+
const why = ex.why ? [`- ${escInline(ex.why)}`] : [];
|
|
89
|
+
return ["```sh", ex.cmd, "```", ...why];
|
|
90
|
+
}),
|
|
91
|
+
]
|
|
92
|
+
: [];
|
|
93
|
+
return [
|
|
94
|
+
"",
|
|
95
|
+
`### ${s.id.join(" ")}`,
|
|
96
|
+
"",
|
|
97
|
+
...summaryLines,
|
|
98
|
+
...usageLines,
|
|
99
|
+
...optionLines,
|
|
100
|
+
...notesLines,
|
|
101
|
+
...examplesLines,
|
|
102
|
+
];
|
|
103
|
+
});
|
|
104
|
+
return [...groupHeader, ...commandBlocks];
|
|
105
|
+
});
|
|
106
|
+
const lines = [
|
|
107
|
+
"# CLI Reference (Generated)",
|
|
108
|
+
"",
|
|
109
|
+
"This page is generated from the CLI command specs. Do not edit it by hand; edit the specs instead.",
|
|
110
|
+
"",
|
|
111
|
+
"## Index",
|
|
112
|
+
"",
|
|
113
|
+
...indexLines,
|
|
114
|
+
...bodyLines,
|
|
115
|
+
"",
|
|
116
|
+
];
|
|
117
|
+
return lines.join("\n");
|
|
118
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CliError } from "../../shared/errors.js";
|
|
2
|
+
import type { CommandSpec } from "./spec.js";
|
|
3
|
+
export declare function usageError(opts: {
|
|
4
|
+
message: string;
|
|
5
|
+
spec?: CommandSpec<unknown>;
|
|
6
|
+
command?: string;
|
|
7
|
+
context?: Record<string, unknown>;
|
|
8
|
+
}): CliError;
|
|
9
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/cli/spec/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAG7C,wBAAgB,UAAU,CAAC,IAAI,EAAE;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,GAAG,QAAQ,CAgBX"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CliError } from "../../shared/errors.js";
|
|
2
|
+
import { renderCommandHelpText } from "./help-render.js";
|
|
3
|
+
export function usageError(opts) {
|
|
4
|
+
const command = opts.command ?? (opts.spec ? opts.spec.id.join(" ") : undefined);
|
|
5
|
+
const usage = opts.spec && renderCommandHelpText(opts.spec, { compact: true, includeHeader: false });
|
|
6
|
+
const fullMessage = usage ? `${opts.message}\n\n${usage}` : opts.message;
|
|
7
|
+
const context = {};
|
|
8
|
+
if (command)
|
|
9
|
+
context.command = command;
|
|
10
|
+
if (opts.context)
|
|
11
|
+
Object.assign(context, opts.context);
|
|
12
|
+
return new CliError({
|
|
13
|
+
exitCode: 2,
|
|
14
|
+
code: "E_USAGE",
|
|
15
|
+
message: fullMessage,
|
|
16
|
+
context: Object.keys(context).length > 0 ? context : undefined,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { CommandSpec } from "./spec.js";
|
|
2
|
+
export type HelpJson = {
|
|
3
|
+
id: string[];
|
|
4
|
+
group: string;
|
|
5
|
+
summary: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
usage: string[];
|
|
8
|
+
args: {
|
|
9
|
+
name: string;
|
|
10
|
+
required: boolean;
|
|
11
|
+
variadic?: boolean;
|
|
12
|
+
valueHint?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
}[];
|
|
15
|
+
options: {
|
|
16
|
+
name: string;
|
|
17
|
+
kind: "boolean" | "string";
|
|
18
|
+
short?: string;
|
|
19
|
+
description: string;
|
|
20
|
+
hidden?: boolean;
|
|
21
|
+
deprecated?: string;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
repeatable?: boolean;
|
|
24
|
+
minCount?: number;
|
|
25
|
+
valueHint?: string;
|
|
26
|
+
default?: unknown;
|
|
27
|
+
choices?: string[];
|
|
28
|
+
patternHint?: string;
|
|
29
|
+
}[];
|
|
30
|
+
examples: {
|
|
31
|
+
cmd: string;
|
|
32
|
+
why?: string;
|
|
33
|
+
}[];
|
|
34
|
+
notes: string[];
|
|
35
|
+
};
|
|
36
|
+
export declare function renderUsageLines(spec: CommandSpec<unknown>): string[];
|
|
37
|
+
export declare function renderCommandHelpText(spec: CommandSpec<unknown>, opts: {
|
|
38
|
+
compact: boolean;
|
|
39
|
+
includeHeader: boolean;
|
|
40
|
+
}): string;
|
|
41
|
+
export declare function renderCommandHelpJson(spec: CommandSpec<unknown>): HelpJson;
|
|
42
|
+
export declare function renderRegistryHelpText(specs: readonly CommandSpec<unknown>[]): string;
|
|
43
|
+
//# sourceMappingURL=help-render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help-render.d.ts","sourceRoot":"","sources":["../../../src/cli/spec/help-render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,WAAW,EAAiC,MAAM,WAAW,CAAC;AAErF,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,OAAO,CAAC;QAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,EAAE,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;QAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,EAAE,CAAC;IACJ,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1C,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAkBF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,MAAM,EAAE,CAkBrE;AAoDD,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,EAC1B,IAAI,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,GACjD,MAAM,CA+BR;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,QAAQ,CAmD1E;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,SAAS,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,MAAM,CAyBrF"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
function renderArgUsage(arg) {
|
|
2
|
+
const hint = arg.valueHint ?? `<${arg.name}>`;
|
|
3
|
+
const base = arg.variadic ? `${hint} ...` : hint;
|
|
4
|
+
return arg.required ? base : `[${base}]`;
|
|
5
|
+
}
|
|
6
|
+
function renderRequiredStringOptionUsage(opt) {
|
|
7
|
+
const long = `--${opt.name}`;
|
|
8
|
+
const hint = opt.valueHint;
|
|
9
|
+
if (opt.repeatable) {
|
|
10
|
+
const base = `${long} ${hint}`;
|
|
11
|
+
return `${base} [${base} ...]`;
|
|
12
|
+
}
|
|
13
|
+
return `${long} ${hint}`;
|
|
14
|
+
}
|
|
15
|
+
export function renderUsageLines(spec) {
|
|
16
|
+
if (spec.synopsis && spec.synopsis.length > 0)
|
|
17
|
+
return [...spec.synopsis];
|
|
18
|
+
const parts = ["agentplane", ...spec.id];
|
|
19
|
+
const args = spec.args ?? [];
|
|
20
|
+
for (const a of args)
|
|
21
|
+
parts.push(renderArgUsage(a));
|
|
22
|
+
const opts = (spec.options ?? []).filter((o) => !o.hidden);
|
|
23
|
+
const requiredOpts = opts.filter((o) => o.kind === "string" && o.required === true);
|
|
24
|
+
const optionalExists = opts.some((o) => !(o.kind === "string" && o.required));
|
|
25
|
+
// Show required options explicitly to reduce confusion.
|
|
26
|
+
for (const o of requiredOpts)
|
|
27
|
+
parts.push(renderRequiredStringOptionUsage(o));
|
|
28
|
+
if (optionalExists)
|
|
29
|
+
parts.push("[options]");
|
|
30
|
+
return [parts.join(" ")];
|
|
31
|
+
}
|
|
32
|
+
function renderOptionsLines(spec) {
|
|
33
|
+
const opts = (spec.options ?? []).filter((o) => !o.hidden);
|
|
34
|
+
if (opts.length === 0)
|
|
35
|
+
return [];
|
|
36
|
+
const lines = [];
|
|
37
|
+
for (const o of opts) {
|
|
38
|
+
const short = o.short ? `-${o.short}, ` : "";
|
|
39
|
+
let head = ` ${short}--${o.name}`;
|
|
40
|
+
if (o.kind === "string")
|
|
41
|
+
head += ` ${o.valueHint}`;
|
|
42
|
+
const meta = [];
|
|
43
|
+
if (o.kind === "string" && o.required)
|
|
44
|
+
meta.push("required");
|
|
45
|
+
if (o.kind === "string" && o.repeatable)
|
|
46
|
+
meta.push("repeatable");
|
|
47
|
+
if (o.kind === "string" && o.minCount && o.minCount > 0)
|
|
48
|
+
meta.push(`min=${o.minCount}`);
|
|
49
|
+
if (o.kind === "string" && o.choices && o.choices.length > 0)
|
|
50
|
+
meta.push(`choices=${o.choices.join("|")}`);
|
|
51
|
+
if (o.kind === "string" && o.patternHint)
|
|
52
|
+
meta.push(`format=${o.patternHint}`);
|
|
53
|
+
if (o.default !== undefined)
|
|
54
|
+
meta.push(`default=${String(o.default)}`);
|
|
55
|
+
if (o.deprecated)
|
|
56
|
+
meta.push(`deprecated=${o.deprecated}`);
|
|
57
|
+
const suffix = meta.length > 0 ? ` (${meta.join(", ")})` : "";
|
|
58
|
+
lines.push(`${head} ${o.description}${suffix}`);
|
|
59
|
+
}
|
|
60
|
+
return lines;
|
|
61
|
+
}
|
|
62
|
+
function renderArgsLines(spec) {
|
|
63
|
+
const args = spec.args ?? [];
|
|
64
|
+
if (args.length === 0)
|
|
65
|
+
return [];
|
|
66
|
+
const lines = [];
|
|
67
|
+
for (const a of args) {
|
|
68
|
+
const hint = a.valueHint ?? `<${a.name}>`;
|
|
69
|
+
const req = a.required ? "required" : "optional";
|
|
70
|
+
const varSuffix = a.variadic ? ", variadic" : "";
|
|
71
|
+
const desc = a.description ? ` ${a.description}` : "";
|
|
72
|
+
lines.push(` ${a.name} ${hint} (${req}${varSuffix})${desc}`);
|
|
73
|
+
}
|
|
74
|
+
return lines;
|
|
75
|
+
}
|
|
76
|
+
function renderExamplesLines(examples) {
|
|
77
|
+
if (!examples || examples.length === 0)
|
|
78
|
+
return [];
|
|
79
|
+
const lines = [];
|
|
80
|
+
for (const ex of examples) {
|
|
81
|
+
lines.push(` ${ex.cmd}`);
|
|
82
|
+
if (ex.why)
|
|
83
|
+
lines.push(` # ${ex.why}`);
|
|
84
|
+
}
|
|
85
|
+
return lines;
|
|
86
|
+
}
|
|
87
|
+
export function renderCommandHelpText(spec, opts) {
|
|
88
|
+
const lines = [];
|
|
89
|
+
if (opts.includeHeader) {
|
|
90
|
+
lines.push(`${spec.id.join(" ")} - ${spec.summary}`, "");
|
|
91
|
+
}
|
|
92
|
+
lines.push("Usage:");
|
|
93
|
+
for (const u of renderUsageLines(spec))
|
|
94
|
+
lines.push(` ${u}`);
|
|
95
|
+
const argLines = renderArgsLines(spec);
|
|
96
|
+
if (!opts.compact && argLines.length > 0) {
|
|
97
|
+
lines.push("", "Args:", ...argLines);
|
|
98
|
+
}
|
|
99
|
+
const optLines = renderOptionsLines(spec);
|
|
100
|
+
if (optLines.length > 0) {
|
|
101
|
+
lines.push("", "Options:", ...optLines);
|
|
102
|
+
}
|
|
103
|
+
if (!opts.compact && spec.notes && spec.notes.length > 0) {
|
|
104
|
+
lines.push("", "Notes:", ...spec.notes.map((n) => ` - ${n}`));
|
|
105
|
+
}
|
|
106
|
+
if (!opts.compact) {
|
|
107
|
+
const exLines = renderExamplesLines(spec.examples);
|
|
108
|
+
if (exLines.length > 0) {
|
|
109
|
+
lines.push("", "Examples:", ...exLines);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return lines.join("\n");
|
|
113
|
+
}
|
|
114
|
+
export function renderCommandHelpJson(spec) {
|
|
115
|
+
const options = (spec.options ?? []).map((o) => {
|
|
116
|
+
if (o.kind === "boolean") {
|
|
117
|
+
return {
|
|
118
|
+
name: o.name,
|
|
119
|
+
kind: "boolean",
|
|
120
|
+
short: o.short,
|
|
121
|
+
description: o.description,
|
|
122
|
+
hidden: o.hidden,
|
|
123
|
+
deprecated: o.deprecated,
|
|
124
|
+
default: o.default,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
name: o.name,
|
|
129
|
+
kind: "string",
|
|
130
|
+
short: o.short,
|
|
131
|
+
description: o.description,
|
|
132
|
+
hidden: o.hidden,
|
|
133
|
+
deprecated: o.deprecated,
|
|
134
|
+
required: o.required,
|
|
135
|
+
repeatable: o.repeatable,
|
|
136
|
+
minCount: o.minCount,
|
|
137
|
+
valueHint: o.valueHint,
|
|
138
|
+
default: o.default,
|
|
139
|
+
choices: o.choices ? [...o.choices] : undefined,
|
|
140
|
+
patternHint: o.patternHint,
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
const args = (spec.args ?? []).map((a) => ({
|
|
144
|
+
name: a.name,
|
|
145
|
+
required: a.required,
|
|
146
|
+
variadic: a.variadic,
|
|
147
|
+
valueHint: a.valueHint,
|
|
148
|
+
description: a.description,
|
|
149
|
+
}));
|
|
150
|
+
const examples = (spec.examples ?? []).map((e) => ({ cmd: e.cmd, why: e.why }));
|
|
151
|
+
return {
|
|
152
|
+
id: [...spec.id],
|
|
153
|
+
group: spec.group,
|
|
154
|
+
summary: spec.summary,
|
|
155
|
+
description: spec.description,
|
|
156
|
+
usage: renderUsageLines(spec),
|
|
157
|
+
args,
|
|
158
|
+
options,
|
|
159
|
+
examples,
|
|
160
|
+
notes: spec.notes ? [...spec.notes] : [],
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
export function renderRegistryHelpText(specs) {
|
|
164
|
+
const byGroup = new Map();
|
|
165
|
+
for (const s of specs) {
|
|
166
|
+
const arr = byGroup.get(s.group) ?? [];
|
|
167
|
+
arr.push(s);
|
|
168
|
+
byGroup.set(s.group, arr);
|
|
169
|
+
}
|
|
170
|
+
const groups = [...byGroup.keys()].toSorted((a, b) => a.localeCompare(b));
|
|
171
|
+
const lines = [
|
|
172
|
+
"Usage:",
|
|
173
|
+
" agentplane help [<cmd...>] [--compact] [--json]",
|
|
174
|
+
"",
|
|
175
|
+
"Commands:",
|
|
176
|
+
];
|
|
177
|
+
for (const g of groups) {
|
|
178
|
+
lines.push(` ${g}:`);
|
|
179
|
+
const cmds = byGroup.get(g).toSorted((a, b) => a.id.join(" ").localeCompare(b.id.join(" ")));
|
|
180
|
+
for (const s of cmds) {
|
|
181
|
+
lines.push(` ${s.id.join(" ")} ${s.summary}`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return lines.join("\n");
|
|
185
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CommandHandler, CommandSpec } from "./spec.js";
|
|
2
|
+
import type { CommandRegistry } from "./registry.js";
|
|
3
|
+
export type HelpParsed = {
|
|
4
|
+
cmd: string[];
|
|
5
|
+
compact: boolean;
|
|
6
|
+
json: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const helpSpec: CommandSpec<HelpParsed>;
|
|
9
|
+
export declare function makeHelpHandler(registry: CommandRegistry): CommandHandler<HelpParsed>;
|
|
10
|
+
//# sourceMappingURL=help.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/cli/spec/help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAQ7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,WAAW,CAAC,UAAU,CAwB5C,CAAC;AAEF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,eAAe,GAAG,cAAc,CAAC,UAAU,CAAC,CAuCrF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { renderCommandHelpJson, renderCommandHelpText, renderRegistryHelpText, } from "./help-render.js";
|
|
2
|
+
import { suggestOne } from "./suggest.js";
|
|
3
|
+
import { usageError } from "./errors.js";
|
|
4
|
+
export const helpSpec = {
|
|
5
|
+
id: ["help"],
|
|
6
|
+
group: "Core",
|
|
7
|
+
summary: "Show help for a command.",
|
|
8
|
+
description: "Renders spec-derived help for migrated commands. Use --compact for minimal output and --json for machine-readable help.",
|
|
9
|
+
args: [{ name: "cmd", required: false, variadic: true, valueHint: "<cmd>" }],
|
|
10
|
+
options: [
|
|
11
|
+
{ kind: "boolean", name: "compact", description: "Compact help (usage + options)." },
|
|
12
|
+
{ kind: "boolean", name: "json", description: "Emit JSON help (success output)." },
|
|
13
|
+
],
|
|
14
|
+
examples: [
|
|
15
|
+
{ cmd: "agentplane help", why: "List commands available in cli2 registry." },
|
|
16
|
+
{ cmd: "agentplane help task new --compact", why: "Show compact help for a command." },
|
|
17
|
+
{ cmd: "agentplane help task new --json", why: "Show JSON help for a command." },
|
|
18
|
+
],
|
|
19
|
+
parse: (raw) => {
|
|
20
|
+
const cmd = raw.args.cmd ?? [];
|
|
21
|
+
return {
|
|
22
|
+
cmd: Array.isArray(cmd) ? cmd.map(String) : [String(cmd)],
|
|
23
|
+
compact: raw.opts.compact === true,
|
|
24
|
+
json: raw.opts.json === true,
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export function makeHelpHandler(registry) {
|
|
29
|
+
return (_ctx, p) => {
|
|
30
|
+
const specs = registry.list().map((e) => e.spec);
|
|
31
|
+
if (p.cmd.length === 0) {
|
|
32
|
+
if (p.json) {
|
|
33
|
+
const out = specs.map((s) => renderCommandHelpJson(s));
|
|
34
|
+
process.stdout.write(`${JSON.stringify(out, null, 2)}\n`);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
process.stdout.write(`${renderRegistryHelpText(specs)}\n`);
|
|
38
|
+
}
|
|
39
|
+
return Promise.resolve(0);
|
|
40
|
+
}
|
|
41
|
+
const match = registry.match(p.cmd);
|
|
42
|
+
if (match?.consumed !== p.cmd.length) {
|
|
43
|
+
const input = p.cmd.join(" ");
|
|
44
|
+
const candidates = specs.map((s) => s.id.join(" "));
|
|
45
|
+
const suggestion = suggestOne(input, candidates);
|
|
46
|
+
const suffix = suggestion ? ` Did you mean: ${suggestion}?` : "";
|
|
47
|
+
throw usageError({
|
|
48
|
+
spec: helpSpec,
|
|
49
|
+
command: "help",
|
|
50
|
+
message: `Unknown command: ${input}.${suffix}`,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (p.json) {
|
|
54
|
+
process.stdout.write(`${JSON.stringify(renderCommandHelpJson(match.spec), null, 2)}\n`);
|
|
55
|
+
return Promise.resolve(0);
|
|
56
|
+
}
|
|
57
|
+
const text = renderCommandHelpText(match.spec, {
|
|
58
|
+
compact: p.compact,
|
|
59
|
+
includeHeader: true,
|
|
60
|
+
});
|
|
61
|
+
process.stdout.write(`${text}\n`);
|
|
62
|
+
return Promise.resolve(0);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CommandSpec, ParsedRaw } from "./spec.js";
|
|
2
|
+
type ParsedCommand<TParsed> = {
|
|
3
|
+
raw: ParsedRaw;
|
|
4
|
+
parsed: TParsed;
|
|
5
|
+
};
|
|
6
|
+
export declare function parseCommandArgv<TParsed>(spec: CommandSpec<TParsed>, argv: readonly string[]): ParsedCommand<TParsed>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../src/cli/spec/parse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAc,SAAS,EAAE,MAAM,WAAW,CAAC;AAIpE,KAAK,aAAa,CAAC,OAAO,IAAI;IAC5B,GAAG,EAAE,SAAS,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AA6EF,wBAAgB,gBAAgB,CAAC,OAAO,EACtC,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,EAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,aAAa,CAAC,OAAO,CAAC,CAiIxB"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { suggestOne } from "./suggest.js";
|
|
2
|
+
import { usageError } from "./errors.js";
|
|
3
|
+
function isOptionToken(tok) {
|
|
4
|
+
return tok.startsWith("-") && tok !== "-";
|
|
5
|
+
}
|
|
6
|
+
function indexOptions(spec) {
|
|
7
|
+
const byLong = new Map();
|
|
8
|
+
const byShort = new Map();
|
|
9
|
+
const candidates = [];
|
|
10
|
+
for (const o of spec.options ?? []) {
|
|
11
|
+
byLong.set(`--${o.name}`, o);
|
|
12
|
+
candidates.push(`--${o.name}`);
|
|
13
|
+
if (o.short) {
|
|
14
|
+
byShort.set(`-${o.short}`, o);
|
|
15
|
+
candidates.push(`-${o.short}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return { byLong, byShort, candidates };
|
|
19
|
+
}
|
|
20
|
+
function setOpt(raw, opt, value) {
|
|
21
|
+
const key = opt.name;
|
|
22
|
+
if (opt.kind === "boolean") {
|
|
23
|
+
raw.opts[key] = Boolean(value);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const coerced = opt.coerce ? opt.coerce(String(value)) : String(value);
|
|
27
|
+
if (opt.repeatable) {
|
|
28
|
+
const existing = raw.opts[key];
|
|
29
|
+
const arr = Array.isArray(existing) ? [...existing] : [];
|
|
30
|
+
if (Array.isArray(coerced)) {
|
|
31
|
+
for (const v of coerced)
|
|
32
|
+
arr.push(v);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
arr.push(coerced);
|
|
36
|
+
}
|
|
37
|
+
raw.opts[key] = arr;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (raw.opts[key] !== undefined) {
|
|
41
|
+
throw usageError({ message: `Duplicate option: --${key}` });
|
|
42
|
+
}
|
|
43
|
+
raw.opts[key] = coerced;
|
|
44
|
+
}
|
|
45
|
+
function validateOptValue(spec, opt, value) {
|
|
46
|
+
if (opt.kind !== "string")
|
|
47
|
+
return;
|
|
48
|
+
if (opt.choices && opt.choices.length > 0 && !opt.choices.includes(value)) {
|
|
49
|
+
throw usageError({
|
|
50
|
+
spec,
|
|
51
|
+
message: `Invalid value for --${opt.name}: ${value} (expected one of: ${opt.choices.join(", ")})`,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (opt.pattern && !opt.pattern.test(value)) {
|
|
55
|
+
const hint = opt.patternHint ? ` (${opt.patternHint})` : "";
|
|
56
|
+
throw usageError({
|
|
57
|
+
spec,
|
|
58
|
+
message: `Invalid value for --${opt.name}: ${value}${hint}`,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function normalizeForValidation(opt, rawValue) {
|
|
63
|
+
if (opt.kind !== "string")
|
|
64
|
+
return rawValue;
|
|
65
|
+
if (!opt.coerce)
|
|
66
|
+
return rawValue;
|
|
67
|
+
const coerced = opt.coerce(rawValue);
|
|
68
|
+
return typeof coerced === "string" ? coerced : rawValue;
|
|
69
|
+
}
|
|
70
|
+
export function parseCommandArgv(spec, argv) {
|
|
71
|
+
const { byLong, byShort, candidates } = indexOptions(spec);
|
|
72
|
+
const raw = { args: {}, opts: {}, extra: [] };
|
|
73
|
+
const positionals = [];
|
|
74
|
+
for (let i = 0; i < argv.length; i++) {
|
|
75
|
+
const tok = argv[i];
|
|
76
|
+
if (!tok)
|
|
77
|
+
continue;
|
|
78
|
+
if (tok === "--") {
|
|
79
|
+
positionals.push(...argv.slice(i + 1).filter(Boolean));
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
if (!isOptionToken(tok)) {
|
|
83
|
+
positionals.push(tok);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
// Long options: --name or --name=value
|
|
87
|
+
if (tok.startsWith("--")) {
|
|
88
|
+
const eq = tok.indexOf("=");
|
|
89
|
+
const head = eq === -1 ? tok : tok.slice(0, eq);
|
|
90
|
+
const opt = byLong.get(head);
|
|
91
|
+
if (!opt) {
|
|
92
|
+
const sugg = suggestOne(head, candidates);
|
|
93
|
+
const suffix = sugg ? ` Did you mean ${sugg}?` : "";
|
|
94
|
+
throw usageError({ spec, message: `Unknown option: ${head}.${suffix}` });
|
|
95
|
+
}
|
|
96
|
+
if (opt.kind === "boolean") {
|
|
97
|
+
if (eq === -1) {
|
|
98
|
+
setOpt(raw, opt, true);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
throw usageError({ spec, message: `Option ${head} does not take a value` });
|
|
102
|
+
}
|
|
103
|
+
const value = eq === -1 ? argv[i + 1] : tok.slice(eq + 1);
|
|
104
|
+
if (value === undefined || value === null || value === "") {
|
|
105
|
+
throw usageError({ spec, message: `Missing value after ${head}` });
|
|
106
|
+
}
|
|
107
|
+
const rawValue = String(value);
|
|
108
|
+
validateOptValue(spec, opt, normalizeForValidation(opt, rawValue));
|
|
109
|
+
setOpt(raw, opt, rawValue);
|
|
110
|
+
if (eq === -1)
|
|
111
|
+
i++;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
// Short options: -m value (no grouping)
|
|
115
|
+
const opt = byShort.get(tok);
|
|
116
|
+
if (!opt) {
|
|
117
|
+
const sugg = suggestOne(tok, candidates);
|
|
118
|
+
const suffix = sugg ? ` Did you mean ${sugg}?` : "";
|
|
119
|
+
throw usageError({ spec, message: `Unknown option: ${tok}.${suffix}` });
|
|
120
|
+
}
|
|
121
|
+
if (opt.kind === "boolean") {
|
|
122
|
+
setOpt(raw, opt, true);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const value = argv[i + 1];
|
|
126
|
+
if (!value)
|
|
127
|
+
throw usageError({ spec, message: `Missing value after ${tok}` });
|
|
128
|
+
const rawValue = String(value);
|
|
129
|
+
validateOptValue(spec, opt, normalizeForValidation(opt, rawValue));
|
|
130
|
+
setOpt(raw, opt, rawValue);
|
|
131
|
+
i++;
|
|
132
|
+
}
|
|
133
|
+
// Apply defaults and validate required/minCount.
|
|
134
|
+
for (const o of spec.options ?? []) {
|
|
135
|
+
if (o.kind === "boolean") {
|
|
136
|
+
if (raw.opts[o.name] === undefined && o.default !== undefined)
|
|
137
|
+
raw.opts[o.name] = o.default;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (raw.opts[o.name] === undefined && o.default !== undefined)
|
|
141
|
+
raw.opts[o.name] = o.default;
|
|
142
|
+
if (o.required === true && raw.opts[o.name] === undefined) {
|
|
143
|
+
throw usageError({ spec, message: `Missing required option: --${o.name}` });
|
|
144
|
+
}
|
|
145
|
+
if (o.repeatable && o.minCount && o.minCount > 0) {
|
|
146
|
+
const v = raw.opts[o.name];
|
|
147
|
+
const count = Array.isArray(v) ? v.length : 0;
|
|
148
|
+
if (count < o.minCount) {
|
|
149
|
+
throw usageError({
|
|
150
|
+
spec,
|
|
151
|
+
message: `Option --${o.name} must be provided at least ${o.minCount} time(s)`,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// Positional args.
|
|
157
|
+
let cursor = 0;
|
|
158
|
+
for (const a of spec.args ?? []) {
|
|
159
|
+
if (a.variadic) {
|
|
160
|
+
const rest = positionals.slice(cursor);
|
|
161
|
+
if (a.required && rest.length === 0) {
|
|
162
|
+
throw usageError({ spec, message: `Missing required argument: ${a.name}` });
|
|
163
|
+
}
|
|
164
|
+
raw.args[a.name] = rest;
|
|
165
|
+
cursor = positionals.length;
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
const v = positionals[cursor];
|
|
169
|
+
if (v === undefined) {
|
|
170
|
+
if (a.required)
|
|
171
|
+
throw usageError({ spec, message: `Missing required argument: ${a.name}` });
|
|
172
|
+
raw.args[a.name] = undefined;
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
raw.args[a.name] = v;
|
|
176
|
+
cursor++;
|
|
177
|
+
}
|
|
178
|
+
raw.extra = positionals.slice(cursor);
|
|
179
|
+
if (raw.extra.length > 0) {
|
|
180
|
+
throw usageError({ spec, message: `Unexpected argument: ${raw.extra[0]}` });
|
|
181
|
+
}
|
|
182
|
+
if (spec.validateRaw)
|
|
183
|
+
spec.validateRaw(raw);
|
|
184
|
+
const parsed = spec.parse ? spec.parse(raw) : raw.opts;
|
|
185
|
+
if (spec.validate)
|
|
186
|
+
spec.validate(parsed);
|
|
187
|
+
return { raw, parsed };
|
|
188
|
+
}
|