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
|
@@ -1,501 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { mkdir, readdir } from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { promisify } from "node:util";
|
|
5
|
-
import { atomicWriteFile, resolveProject } from "@agentplaneorg/core";
|
|
6
|
-
import { mapCoreError } from "../cli/error-map.js";
|
|
7
|
-
import { fileExists, getPathKind } from "../cli/fs-utils.js";
|
|
8
|
-
import { emptyStateMessage, usageMessage } from "../cli/output.js";
|
|
9
|
-
import { CliError } from "../shared/errors.js";
|
|
10
|
-
import { dedupeStrings } from "../shared/strings.js";
|
|
11
|
-
import { RECIPES_DIR_NAME, RECIPES_SCENARIOS_DIR_NAME, RECIPES_SCENARIOS_INDEX_NAME, normalizeScenarioToolStep, readInstalledRecipesFile, readRecipeManifest, readScenarioDefinition, readScenarioIndex, resolveInstalledRecipeDir, resolveInstalledRecipesPath, resolveProjectRecipesCacheDir, } from "./recipes.js";
|
|
12
|
-
const execFileAsync = promisify(execFile);
|
|
13
|
-
const SCENARIO_USAGE = "Usage: agentplane scenario <list|info|run> [args]";
|
|
14
|
-
const SCENARIO_USAGE_EXAMPLE = "agentplane scenario list";
|
|
15
|
-
const SCENARIO_INFO_USAGE = "Usage: agentplane scenario info <recipe:scenario>";
|
|
16
|
-
const SCENARIO_INFO_USAGE_EXAMPLE = "agentplane scenario info viewer:demo";
|
|
17
|
-
const SCENARIO_RUN_USAGE = "Usage: agentplane scenario run <recipe:scenario>";
|
|
18
|
-
const SCENARIO_RUN_USAGE_EXAMPLE = "agentplane scenario run viewer:demo";
|
|
19
|
-
const SCENARIO_REPORT_NAME = "report.json";
|
|
20
|
-
const SENSITIVE_ARG_FLAGS = new Set([
|
|
21
|
-
"--token",
|
|
22
|
-
"--secret",
|
|
23
|
-
"--password",
|
|
24
|
-
"--api-key",
|
|
25
|
-
"--apikey",
|
|
26
|
-
"--access-key",
|
|
27
|
-
"--client-secret",
|
|
28
|
-
"--auth",
|
|
29
|
-
"--authorization",
|
|
30
|
-
"--bearer",
|
|
31
|
-
]);
|
|
32
|
-
function redactArgs(args) {
|
|
33
|
-
const out = [...args];
|
|
34
|
-
for (let i = 0; i < out.length; i++) {
|
|
35
|
-
const arg = out[i];
|
|
36
|
-
if (!arg)
|
|
37
|
-
continue;
|
|
38
|
-
const eqIndex = arg.indexOf("=");
|
|
39
|
-
const flag = eqIndex === -1 ? arg : arg.slice(0, eqIndex);
|
|
40
|
-
if (!SENSITIVE_ARG_FLAGS.has(flag))
|
|
41
|
-
continue;
|
|
42
|
-
if (eqIndex !== -1) {
|
|
43
|
-
out[i] = `${flag}=<redacted>`;
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
out[i] = flag;
|
|
47
|
-
if (i + 1 < out.length && !out[i + 1]?.startsWith("-")) {
|
|
48
|
-
out[i + 1] = "<redacted>";
|
|
49
|
-
i += 1;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return out;
|
|
53
|
-
}
|
|
54
|
-
function isNotGitRepoError(err) {
|
|
55
|
-
if (err instanceof Error) {
|
|
56
|
-
return err.message.startsWith("Not a git repository");
|
|
57
|
-
}
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
async function getGitDiffSummary(cwd) {
|
|
61
|
-
try {
|
|
62
|
-
const [diff, staged, status] = await Promise.all([
|
|
63
|
-
execFileAsync("git", ["diff", "--stat"], { cwd }),
|
|
64
|
-
execFileAsync("git", ["diff", "--stat", "--staged"], { cwd }),
|
|
65
|
-
execFileAsync("git", ["status", "--porcelain"], { cwd }),
|
|
66
|
-
]);
|
|
67
|
-
const diffStat = String(diff.stdout).trim();
|
|
68
|
-
const stagedStat = String(staged.stdout).trim();
|
|
69
|
-
const statusLines = String(status.stdout).trim();
|
|
70
|
-
return {
|
|
71
|
-
diff_stat: diffStat || undefined,
|
|
72
|
-
staged_stat: stagedStat || undefined,
|
|
73
|
-
status: statusLines
|
|
74
|
-
? statusLines
|
|
75
|
-
.split("\n")
|
|
76
|
-
.map((line) => line.trim())
|
|
77
|
-
.filter(Boolean)
|
|
78
|
-
: [],
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
catch (err) {
|
|
82
|
-
if (isNotGitRepoError(err))
|
|
83
|
-
return undefined;
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function collectScenarioEnvKeys(stepEnv) {
|
|
88
|
-
return dedupeStrings([
|
|
89
|
-
...Object.keys(stepEnv ?? {}),
|
|
90
|
-
"AGENTPLANE_RUN_DIR",
|
|
91
|
-
"AGENTPLANE_STEP_DIR",
|
|
92
|
-
"AGENTPLANE_RECIPES_CACHE_DIR",
|
|
93
|
-
"AGENTPLANE_RECIPE_ID",
|
|
94
|
-
"AGENTPLANE_SCENARIO_ID",
|
|
95
|
-
"AGENTPLANE_TOOL_ID",
|
|
96
|
-
]);
|
|
97
|
-
}
|
|
98
|
-
async function writeScenarioReport(opts) {
|
|
99
|
-
const report = {
|
|
100
|
-
schema_version: 1,
|
|
101
|
-
recipe: opts.recipeId,
|
|
102
|
-
scenario: opts.scenarioId,
|
|
103
|
-
run_id: opts.runId,
|
|
104
|
-
started_at: opts.startedAt,
|
|
105
|
-
ended_at: new Date().toISOString(),
|
|
106
|
-
status: opts.status,
|
|
107
|
-
steps: opts.steps,
|
|
108
|
-
git: opts.gitSummary,
|
|
109
|
-
};
|
|
110
|
-
await atomicWriteFile(path.join(opts.runDir, SCENARIO_REPORT_NAME), `${JSON.stringify(report, null, 2)}\n`, "utf8");
|
|
111
|
-
}
|
|
112
|
-
async function cmdScenarioList(opts) {
|
|
113
|
-
try {
|
|
114
|
-
const installed = await readInstalledRecipesFile(resolveInstalledRecipesPath());
|
|
115
|
-
const entries = [];
|
|
116
|
-
for (const recipe of installed.recipes) {
|
|
117
|
-
const recipeDir = resolveInstalledRecipeDir(recipe);
|
|
118
|
-
const scenariosDir = path.join(recipeDir, RECIPES_SCENARIOS_DIR_NAME);
|
|
119
|
-
if ((await getPathKind(scenariosDir)) === "dir") {
|
|
120
|
-
const files = await readdir(scenariosDir);
|
|
121
|
-
const jsonFiles = files.filter((entry) => entry.toLowerCase().endsWith(".json")).toSorted();
|
|
122
|
-
for (const file of jsonFiles) {
|
|
123
|
-
const scenario = await readScenarioDefinition(path.join(scenariosDir, file));
|
|
124
|
-
entries.push({ recipeId: recipe.id, scenarioId: scenario.id, summary: scenario.summary });
|
|
125
|
-
}
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
const scenariosIndexPath = path.join(recipeDir, RECIPES_SCENARIOS_INDEX_NAME);
|
|
129
|
-
if (await fileExists(scenariosIndexPath)) {
|
|
130
|
-
const index = await readScenarioIndex(scenariosIndexPath);
|
|
131
|
-
for (const scenario of index.scenarios) {
|
|
132
|
-
entries.push({
|
|
133
|
-
recipeId: recipe.id,
|
|
134
|
-
scenarioId: scenario.id,
|
|
135
|
-
summary: scenario.summary,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
if (entries.length === 0) {
|
|
141
|
-
process.stdout.write(`${emptyStateMessage("scenarios", "Install a recipe to add scenarios.")}\n`);
|
|
142
|
-
return 0;
|
|
143
|
-
}
|
|
144
|
-
const sorted = entries.toSorted((a, b) => {
|
|
145
|
-
const byRecipe = a.recipeId.localeCompare(b.recipeId);
|
|
146
|
-
if (byRecipe !== 0)
|
|
147
|
-
return byRecipe;
|
|
148
|
-
return a.scenarioId.localeCompare(b.scenarioId);
|
|
149
|
-
});
|
|
150
|
-
for (const entry of sorted) {
|
|
151
|
-
process.stdout.write(`${entry.recipeId}:${entry.scenarioId} - ${entry.summary ?? "No summary"}\n`);
|
|
152
|
-
}
|
|
153
|
-
return 0;
|
|
154
|
-
}
|
|
155
|
-
catch (err) {
|
|
156
|
-
if (err instanceof CliError)
|
|
157
|
-
throw err;
|
|
158
|
-
throw mapCoreError(err, { command: "scenario list", root: opts.rootOverride ?? null });
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
async function cmdScenarioInfo(opts) {
|
|
162
|
-
try {
|
|
163
|
-
const [recipeId, scenarioId] = opts.id.split(":");
|
|
164
|
-
if (!recipeId || !scenarioId) {
|
|
165
|
-
throw new CliError({
|
|
166
|
-
exitCode: 2,
|
|
167
|
-
code: "E_USAGE",
|
|
168
|
-
message: usageMessage(SCENARIO_INFO_USAGE, SCENARIO_INFO_USAGE_EXAMPLE),
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
const installed = await readInstalledRecipesFile(resolveInstalledRecipesPath());
|
|
172
|
-
const entry = installed.recipes.find((recipe) => recipe.id === recipeId);
|
|
173
|
-
if (!entry) {
|
|
174
|
-
throw new CliError({
|
|
175
|
-
exitCode: 5,
|
|
176
|
-
code: "E_IO",
|
|
177
|
-
message: `Recipe not installed: ${recipeId}`,
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
const recipeDir = resolveInstalledRecipeDir(entry);
|
|
181
|
-
const scenariosDir = path.join(recipeDir, RECIPES_SCENARIOS_DIR_NAME);
|
|
182
|
-
let scenario = null;
|
|
183
|
-
if ((await getPathKind(scenariosDir)) === "dir") {
|
|
184
|
-
const files = await readdir(scenariosDir);
|
|
185
|
-
const jsonFiles = files.filter((file) => file.toLowerCase().endsWith(".json")).toSorted();
|
|
186
|
-
for (const file of jsonFiles) {
|
|
187
|
-
const candidate = await readScenarioDefinition(path.join(scenariosDir, file));
|
|
188
|
-
if (candidate.id === scenarioId) {
|
|
189
|
-
scenario = candidate;
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
let summary;
|
|
195
|
-
if (!scenario) {
|
|
196
|
-
const scenariosIndexPath = path.join(recipeDir, RECIPES_SCENARIOS_INDEX_NAME);
|
|
197
|
-
if (await fileExists(scenariosIndexPath)) {
|
|
198
|
-
const index = await readScenarioIndex(scenariosIndexPath);
|
|
199
|
-
const entrySummary = index.scenarios.find((item) => item.id === scenarioId);
|
|
200
|
-
summary = entrySummary?.summary;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
if (!scenario && !summary) {
|
|
204
|
-
throw new CliError({
|
|
205
|
-
exitCode: 5,
|
|
206
|
-
code: "E_IO",
|
|
207
|
-
message: `Scenario not found: ${recipeId}:${scenarioId}`,
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
process.stdout.write(`Scenario: ${recipeId}:${scenarioId}\n`);
|
|
211
|
-
if (summary)
|
|
212
|
-
process.stdout.write(`Summary: ${summary}\n`);
|
|
213
|
-
if (!scenario) {
|
|
214
|
-
process.stdout.write("Details: Scenario definition not found in recipe.\n");
|
|
215
|
-
return 0;
|
|
216
|
-
}
|
|
217
|
-
if (scenario.summary)
|
|
218
|
-
process.stdout.write(`Summary: ${scenario.summary}\n`);
|
|
219
|
-
if (scenario.description)
|
|
220
|
-
process.stdout.write(`Description: ${scenario.description}\n`);
|
|
221
|
-
process.stdout.write(`Goal: ${scenario.goal}\n`);
|
|
222
|
-
process.stdout.write(`Inputs: ${JSON.stringify(scenario.inputs, null, 2)}\n`);
|
|
223
|
-
process.stdout.write(`Outputs: ${JSON.stringify(scenario.outputs, null, 2)}\n`);
|
|
224
|
-
process.stdout.write("Steps:\n");
|
|
225
|
-
let stepIndex = 1;
|
|
226
|
-
for (const step of scenario.steps) {
|
|
227
|
-
process.stdout.write(` ${stepIndex}. ${JSON.stringify(step)}\n`);
|
|
228
|
-
stepIndex += 1;
|
|
229
|
-
}
|
|
230
|
-
return 0;
|
|
231
|
-
}
|
|
232
|
-
catch (err) {
|
|
233
|
-
if (err instanceof CliError)
|
|
234
|
-
throw err;
|
|
235
|
-
throw mapCoreError(err, { command: "scenario info", root: opts.rootOverride ?? null });
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
async function executeRecipeTool(opts) {
|
|
239
|
-
try {
|
|
240
|
-
const command = opts.runtime === "node" ? "node" : "bash";
|
|
241
|
-
const { stdout, stderr } = await execFileAsync(command, [opts.entrypoint, ...opts.args], {
|
|
242
|
-
cwd: opts.cwd,
|
|
243
|
-
env: opts.env,
|
|
244
|
-
});
|
|
245
|
-
return { exitCode: 0, stdout: String(stdout), stderr: String(stderr) };
|
|
246
|
-
}
|
|
247
|
-
catch (err) {
|
|
248
|
-
let execErr = null;
|
|
249
|
-
if (err && typeof err === "object") {
|
|
250
|
-
execErr = err;
|
|
251
|
-
}
|
|
252
|
-
const exitCode = typeof execErr?.code === "number" ? execErr.code : 1;
|
|
253
|
-
return {
|
|
254
|
-
exitCode,
|
|
255
|
-
stdout: String(execErr?.stdout ?? ""),
|
|
256
|
-
stderr: String(execErr?.stderr ?? ""),
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
function sanitizeRunId(value) {
|
|
261
|
-
return value.replaceAll(/[^a-zA-Z0-9._-]/g, "_");
|
|
262
|
-
}
|
|
263
|
-
async function cmdScenarioRun(opts) {
|
|
264
|
-
try {
|
|
265
|
-
const resolved = await resolveProject({
|
|
266
|
-
cwd: opts.cwd,
|
|
267
|
-
rootOverride: opts.rootOverride ?? null,
|
|
268
|
-
});
|
|
269
|
-
const [recipeId, scenarioId] = opts.id.split(":");
|
|
270
|
-
if (!recipeId || !scenarioId) {
|
|
271
|
-
throw new CliError({
|
|
272
|
-
exitCode: 2,
|
|
273
|
-
code: "E_USAGE",
|
|
274
|
-
message: usageMessage(SCENARIO_RUN_USAGE, SCENARIO_RUN_USAGE_EXAMPLE),
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
const installed = await readInstalledRecipesFile(resolveInstalledRecipesPath());
|
|
278
|
-
const entry = installed.recipes.find((recipe) => recipe.id === recipeId);
|
|
279
|
-
if (!entry) {
|
|
280
|
-
throw new CliError({
|
|
281
|
-
exitCode: 5,
|
|
282
|
-
code: "E_IO",
|
|
283
|
-
message: `Recipe not installed: ${recipeId}`,
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
const recipeDir = resolveInstalledRecipeDir(entry);
|
|
287
|
-
const manifestPath = path.join(recipeDir, "manifest.json");
|
|
288
|
-
const manifest = await readRecipeManifest(manifestPath);
|
|
289
|
-
const scenariosDir = path.join(recipeDir, RECIPES_SCENARIOS_DIR_NAME);
|
|
290
|
-
if ((await getPathKind(scenariosDir)) !== "dir") {
|
|
291
|
-
throw new CliError({
|
|
292
|
-
exitCode: 5,
|
|
293
|
-
code: "E_IO",
|
|
294
|
-
message: `Scenario definitions not found for recipe: ${recipeId}`,
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
let scenario = null;
|
|
298
|
-
const files = await readdir(scenariosDir);
|
|
299
|
-
const jsonFiles = files.filter((file) => file.toLowerCase().endsWith(".json")).toSorted();
|
|
300
|
-
for (const file of jsonFiles) {
|
|
301
|
-
const candidate = await readScenarioDefinition(path.join(scenariosDir, file));
|
|
302
|
-
if (candidate.id === scenarioId) {
|
|
303
|
-
scenario = candidate;
|
|
304
|
-
break;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
if (!scenario) {
|
|
308
|
-
throw new CliError({
|
|
309
|
-
exitCode: 5,
|
|
310
|
-
code: "E_IO",
|
|
311
|
-
message: `Scenario not found: ${recipeId}:${scenarioId}`,
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
const runsRoot = path.join(resolved.agentplaneDir, RECIPES_DIR_NAME, recipeId, "runs");
|
|
315
|
-
await mkdir(runsRoot, { recursive: true });
|
|
316
|
-
const recipesCacheDir = resolveProjectRecipesCacheDir(resolved);
|
|
317
|
-
await mkdir(recipesCacheDir, { recursive: true });
|
|
318
|
-
const runStartedAt = new Date().toISOString();
|
|
319
|
-
const runId = `${new Date()
|
|
320
|
-
.toISOString()
|
|
321
|
-
.replaceAll(":", "-")
|
|
322
|
-
.replaceAll(".", "-")}-${sanitizeRunId(scenarioId)}`;
|
|
323
|
-
const runDir = path.join(runsRoot, runId);
|
|
324
|
-
await mkdir(runDir, { recursive: true });
|
|
325
|
-
const stepsMeta = [];
|
|
326
|
-
const stepsReport = [];
|
|
327
|
-
for (let index = 0; index < scenario.steps.length; index++) {
|
|
328
|
-
const step = normalizeScenarioToolStep(scenario.steps[index], `${recipeId}:${scenarioId}`);
|
|
329
|
-
const toolEntry = manifest.tools?.find((tool) => tool?.id === step.tool);
|
|
330
|
-
if (!toolEntry) {
|
|
331
|
-
throw new CliError({
|
|
332
|
-
exitCode: 5,
|
|
333
|
-
code: "E_IO",
|
|
334
|
-
message: `Tool not found in recipe manifest: ${step.tool}`,
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
const runtime = toolEntry.runtime === "node" || toolEntry.runtime === "bash" ? toolEntry.runtime : "";
|
|
338
|
-
const entrypoint = typeof toolEntry.entrypoint === "string" ? toolEntry.entrypoint : "";
|
|
339
|
-
if (!runtime || !entrypoint) {
|
|
340
|
-
throw new CliError({
|
|
341
|
-
exitCode: 3,
|
|
342
|
-
code: "E_VALIDATION",
|
|
343
|
-
message: `Tool entry is missing runtime/entrypoint: ${step.tool}`,
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
if (Array.isArray(toolEntry.permissions) && toolEntry.permissions.length > 0) {
|
|
347
|
-
process.stdout.write(`Warning: tool ${toolEntry.id} declares permissions: ${toolEntry.permissions.join(", ")}\n`);
|
|
348
|
-
}
|
|
349
|
-
const entrypointPath = path.join(recipeDir, entrypoint);
|
|
350
|
-
if (!(await fileExists(entrypointPath))) {
|
|
351
|
-
throw new CliError({
|
|
352
|
-
exitCode: 5,
|
|
353
|
-
code: "E_IO",
|
|
354
|
-
message: `Tool entrypoint not found: ${entrypoint}`,
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
const stepDir = path.join(runDir, `step-${index + 1}-${sanitizeRunId(step.tool)}`);
|
|
358
|
-
await mkdir(stepDir, { recursive: true });
|
|
359
|
-
const stepEnvKeys = collectScenarioEnvKeys(step.env);
|
|
360
|
-
const env = {
|
|
361
|
-
...process.env,
|
|
362
|
-
...step.env,
|
|
363
|
-
AGENTPLANE_RUN_DIR: runDir,
|
|
364
|
-
AGENTPLANE_STEP_DIR: stepDir,
|
|
365
|
-
AGENTPLANE_RECIPES_CACHE_DIR: recipesCacheDir,
|
|
366
|
-
AGENTPLANE_RECIPE_ID: recipeId,
|
|
367
|
-
AGENTPLANE_SCENARIO_ID: scenarioId,
|
|
368
|
-
AGENTPLANE_TOOL_ID: step.tool,
|
|
369
|
-
};
|
|
370
|
-
const startedAt = Date.now();
|
|
371
|
-
const result = await executeRecipeTool({
|
|
372
|
-
runtime,
|
|
373
|
-
entrypoint: entrypointPath,
|
|
374
|
-
args: step.args,
|
|
375
|
-
cwd: recipeDir,
|
|
376
|
-
env,
|
|
377
|
-
});
|
|
378
|
-
const durationMs = Date.now() - startedAt;
|
|
379
|
-
await atomicWriteFile(path.join(stepDir, "stdout.log"), result.stdout, "utf8");
|
|
380
|
-
await atomicWriteFile(path.join(stepDir, "stderr.log"), result.stderr, "utf8");
|
|
381
|
-
stepsMeta.push({
|
|
382
|
-
tool: step.tool,
|
|
383
|
-
runtime,
|
|
384
|
-
entrypoint,
|
|
385
|
-
exitCode: result.exitCode,
|
|
386
|
-
duration_ms: durationMs,
|
|
387
|
-
});
|
|
388
|
-
stepsReport.push({
|
|
389
|
-
step: index + 1,
|
|
390
|
-
tool: step.tool,
|
|
391
|
-
runtime,
|
|
392
|
-
entrypoint,
|
|
393
|
-
args: redactArgs(step.args),
|
|
394
|
-
env_keys: stepEnvKeys,
|
|
395
|
-
exit_code: result.exitCode,
|
|
396
|
-
duration_ms: durationMs,
|
|
397
|
-
});
|
|
398
|
-
if (result.exitCode !== 0) {
|
|
399
|
-
const gitSummary = await getGitDiffSummary(resolved.gitRoot);
|
|
400
|
-
await writeScenarioReport({
|
|
401
|
-
runDir,
|
|
402
|
-
recipeId,
|
|
403
|
-
scenarioId,
|
|
404
|
-
runId,
|
|
405
|
-
startedAt: runStartedAt,
|
|
406
|
-
status: "failed",
|
|
407
|
-
steps: stepsReport,
|
|
408
|
-
gitSummary,
|
|
409
|
-
});
|
|
410
|
-
await atomicWriteFile(path.join(runDir, "meta.json"), `${JSON.stringify({
|
|
411
|
-
recipe: recipeId,
|
|
412
|
-
scenario: scenarioId,
|
|
413
|
-
run_id: runId,
|
|
414
|
-
steps: stepsMeta,
|
|
415
|
-
}, null, 2)}\n`, "utf8");
|
|
416
|
-
throw new CliError({
|
|
417
|
-
exitCode: result.exitCode,
|
|
418
|
-
code: "E_INTERNAL",
|
|
419
|
-
message: `Scenario step failed: ${step.tool}`,
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
const gitSummary = await getGitDiffSummary(resolved.gitRoot);
|
|
424
|
-
await writeScenarioReport({
|
|
425
|
-
runDir,
|
|
426
|
-
recipeId,
|
|
427
|
-
scenarioId,
|
|
428
|
-
runId,
|
|
429
|
-
startedAt: runStartedAt,
|
|
430
|
-
status: "success",
|
|
431
|
-
steps: stepsReport,
|
|
432
|
-
gitSummary,
|
|
433
|
-
});
|
|
434
|
-
await atomicWriteFile(path.join(runDir, "meta.json"), `${JSON.stringify({
|
|
435
|
-
recipe: recipeId,
|
|
436
|
-
scenario: scenarioId,
|
|
437
|
-
run_id: runId,
|
|
438
|
-
steps: stepsMeta,
|
|
439
|
-
}, null, 2)}\n`, "utf8");
|
|
440
|
-
process.stdout.write(`Run artifacts: ${path.relative(resolved.gitRoot, runDir)}\n`);
|
|
441
|
-
return 0;
|
|
442
|
-
}
|
|
443
|
-
catch (err) {
|
|
444
|
-
if (err instanceof CliError)
|
|
445
|
-
throw err;
|
|
446
|
-
throw mapCoreError(err, { command: "scenario run", root: opts.rootOverride ?? null });
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
export async function cmdScenario(opts) {
|
|
450
|
-
const sub = opts.command;
|
|
451
|
-
if (!sub) {
|
|
452
|
-
throw new CliError({
|
|
453
|
-
exitCode: 2,
|
|
454
|
-
code: "E_USAGE",
|
|
455
|
-
message: usageMessage(SCENARIO_USAGE, SCENARIO_USAGE_EXAMPLE),
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
if (sub === "list") {
|
|
459
|
-
if (opts.args.length > 0) {
|
|
460
|
-
throw new CliError({
|
|
461
|
-
exitCode: 2,
|
|
462
|
-
code: "E_USAGE",
|
|
463
|
-
message: usageMessage(SCENARIO_USAGE, SCENARIO_USAGE_EXAMPLE),
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
return await cmdScenarioList({ cwd: opts.cwd, rootOverride: opts.rootOverride });
|
|
467
|
-
}
|
|
468
|
-
if (sub === "info") {
|
|
469
|
-
if (opts.args.length !== 1) {
|
|
470
|
-
throw new CliError({
|
|
471
|
-
exitCode: 2,
|
|
472
|
-
code: "E_USAGE",
|
|
473
|
-
message: usageMessage(SCENARIO_INFO_USAGE, SCENARIO_INFO_USAGE_EXAMPLE),
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
return await cmdScenarioInfo({
|
|
477
|
-
cwd: opts.cwd,
|
|
478
|
-
rootOverride: opts.rootOverride,
|
|
479
|
-
id: opts.args[0],
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
if (sub === "run") {
|
|
483
|
-
if (opts.args.length !== 1) {
|
|
484
|
-
throw new CliError({
|
|
485
|
-
exitCode: 2,
|
|
486
|
-
code: "E_USAGE",
|
|
487
|
-
message: usageMessage(SCENARIO_RUN_USAGE, SCENARIO_RUN_USAGE_EXAMPLE),
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
return await cmdScenarioRun({
|
|
491
|
-
cwd: opts.cwd,
|
|
492
|
-
rootOverride: opts.rootOverride,
|
|
493
|
-
id: opts.args[0],
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
throw new CliError({
|
|
497
|
-
exitCode: 2,
|
|
498
|
-
code: "E_USAGE",
|
|
499
|
-
message: usageMessage(SCENARIO_USAGE, SCENARIO_USAGE_EXAMPLE),
|
|
500
|
-
});
|
|
501
|
-
}
|
|
1
|
+
export { cmdScenarioInfoParsed, cmdScenarioListParsed, cmdScenarioRunParsed, } from "./scenario/impl/commands.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare class GitContext {
|
|
2
|
+
readonly gitRoot: string;
|
|
3
|
+
private memo;
|
|
4
|
+
constructor(opts: {
|
|
5
|
+
gitRoot: string;
|
|
6
|
+
});
|
|
7
|
+
private statusPorcelainZ;
|
|
8
|
+
statusChangedPaths(): Promise<string[]>;
|
|
9
|
+
statusStagedPaths(): Promise<string[]>;
|
|
10
|
+
statusUnstagedTrackedPaths(): Promise<string[]>;
|
|
11
|
+
headCommit(): Promise<string>;
|
|
12
|
+
stage(paths: string[]): Promise<void>;
|
|
13
|
+
commit(opts: {
|
|
14
|
+
message: string;
|
|
15
|
+
body?: string;
|
|
16
|
+
env?: NodeJS.ProcessEnv;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
headHashSubject(): Promise<{
|
|
19
|
+
hash: string;
|
|
20
|
+
subject: string;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=git-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-context.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/git-context.ts"],"names":[],"mappings":"AAyEA,qBAAa,UAAU;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,OAAO,CAAC,IAAI,CAGL;gBAEK,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;YAIvB,gBAAgB;IAmBxB,kBAAkB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKvC,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKtC,0BAA0B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKrD,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAWvB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAWrC,MAAM,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAcxF,eAAe,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAWpE"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { execFileAsync, gitEnv } from "./git.js";
|
|
2
|
+
function uniqSorted(paths) {
|
|
3
|
+
return [...new Set(paths)].toSorted((a, b) => a.localeCompare(b));
|
|
4
|
+
}
|
|
5
|
+
function parsePorcelainV1Z(output) {
|
|
6
|
+
const text = Buffer.isBuffer(output) ? output.toString("utf8") : output;
|
|
7
|
+
const parts = text.split("\0").filter((p) => p.length > 0);
|
|
8
|
+
const changed = [];
|
|
9
|
+
const staged = [];
|
|
10
|
+
const unstagedTracked = [];
|
|
11
|
+
const untracked = [];
|
|
12
|
+
for (let i = 0; i < parts.length; i++) {
|
|
13
|
+
const entry = parts[i] ?? "";
|
|
14
|
+
if (entry.length < 3)
|
|
15
|
+
continue;
|
|
16
|
+
const x = entry[0] ?? " ";
|
|
17
|
+
const y = entry[1] ?? " ";
|
|
18
|
+
// Porcelain v1: `XY <path>` (or `XY <orig>` NUL `<path>` for renames/copies).
|
|
19
|
+
if (entry[2] !== " ")
|
|
20
|
+
continue;
|
|
21
|
+
const pathA = entry.slice(3);
|
|
22
|
+
if (!pathA)
|
|
23
|
+
continue;
|
|
24
|
+
if (x === "!" && y === "!") {
|
|
25
|
+
// Ignored file (`!!`): not a "changed path" for guard/staging semantics.
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const isUntracked = x === "?" && y === "?";
|
|
29
|
+
if (isUntracked) {
|
|
30
|
+
changed.push(pathA);
|
|
31
|
+
untracked.push(pathA);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const isRenameOrCopy = x === "R" || x === "C";
|
|
35
|
+
if (isRenameOrCopy) {
|
|
36
|
+
const pathB = parts[i + 1] ?? "";
|
|
37
|
+
if (pathB) {
|
|
38
|
+
// Include both sides so allowlist staging can cover renames across prefixes.
|
|
39
|
+
changed.push(pathA, pathB);
|
|
40
|
+
staged.push(pathA, pathB);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
changed.push(pathA);
|
|
44
|
+
staged.push(pathA);
|
|
45
|
+
}
|
|
46
|
+
i++;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
changed.push(pathA);
|
|
50
|
+
if (x !== " ")
|
|
51
|
+
staged.push(pathA);
|
|
52
|
+
if (y !== " ")
|
|
53
|
+
unstagedTracked.push(pathA);
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
changedPaths: uniqSorted(changed),
|
|
57
|
+
stagedPaths: uniqSorted(staged),
|
|
58
|
+
unstagedTrackedPaths: uniqSorted(unstagedTracked),
|
|
59
|
+
untrackedPaths: uniqSorted(untracked),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export class GitContext {
|
|
63
|
+
gitRoot;
|
|
64
|
+
memo = {};
|
|
65
|
+
constructor(opts) {
|
|
66
|
+
this.gitRoot = opts.gitRoot;
|
|
67
|
+
}
|
|
68
|
+
async statusPorcelainZ() {
|
|
69
|
+
this.memo.status ??= (async () => {
|
|
70
|
+
// `--untracked-files=all` is required so allowlist staging can match individual files
|
|
71
|
+
// under untracked directories (tests + real-world "new task" flows).
|
|
72
|
+
const { stdout } = await execFileAsync("git", ["status", "--porcelain", "-z", "--untracked-files=all"], {
|
|
73
|
+
cwd: this.gitRoot,
|
|
74
|
+
env: gitEnv(),
|
|
75
|
+
encoding: "buffer",
|
|
76
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
77
|
+
});
|
|
78
|
+
return parsePorcelainV1Z(stdout);
|
|
79
|
+
})();
|
|
80
|
+
return await this.memo.status;
|
|
81
|
+
}
|
|
82
|
+
async statusChangedPaths() {
|
|
83
|
+
const status = await this.statusPorcelainZ();
|
|
84
|
+
return status.changedPaths;
|
|
85
|
+
}
|
|
86
|
+
async statusStagedPaths() {
|
|
87
|
+
const status = await this.statusPorcelainZ();
|
|
88
|
+
return status.stagedPaths;
|
|
89
|
+
}
|
|
90
|
+
async statusUnstagedTrackedPaths() {
|
|
91
|
+
const status = await this.statusPorcelainZ();
|
|
92
|
+
return status.unstagedTrackedPaths;
|
|
93
|
+
}
|
|
94
|
+
headCommit() {
|
|
95
|
+
this.memo.headCommit ??= (async () => {
|
|
96
|
+
const { stdout } = await execFileAsync("git", ["rev-parse", "HEAD"], {
|
|
97
|
+
cwd: this.gitRoot,
|
|
98
|
+
env: gitEnv(),
|
|
99
|
+
});
|
|
100
|
+
return String(stdout).trim();
|
|
101
|
+
})();
|
|
102
|
+
return this.memo.headCommit;
|
|
103
|
+
}
|
|
104
|
+
async stage(paths) {
|
|
105
|
+
const unique = uniqSorted(paths.map((p) => p.trim()).filter(Boolean));
|
|
106
|
+
if (unique.length === 0)
|
|
107
|
+
return;
|
|
108
|
+
await execFileAsync("git", ["add", "-A", "--", ...unique], {
|
|
109
|
+
cwd: this.gitRoot,
|
|
110
|
+
env: gitEnv(),
|
|
111
|
+
});
|
|
112
|
+
// Invalidate memoized status: staging changes index state.
|
|
113
|
+
this.memo.status = undefined;
|
|
114
|
+
}
|
|
115
|
+
async commit(opts) {
|
|
116
|
+
const args = ["commit", "-m", opts.message];
|
|
117
|
+
if (opts.body)
|
|
118
|
+
args.push("-m", opts.body);
|
|
119
|
+
await execFileAsync("git", args, {
|
|
120
|
+
cwd: this.gitRoot,
|
|
121
|
+
env: opts.env ?? gitEnv(),
|
|
122
|
+
// Commit hooks can produce large output (lint/test logs).
|
|
123
|
+
maxBuffer: 50 * 1024 * 1024,
|
|
124
|
+
});
|
|
125
|
+
// Invalidate memoized values: commit updates HEAD and working tree state.
|
|
126
|
+
this.memo.status = undefined;
|
|
127
|
+
this.memo.headCommit = undefined;
|
|
128
|
+
}
|
|
129
|
+
async headHashSubject() {
|
|
130
|
+
const { stdout } = await execFileAsync("git", ["log", "-1", "--pretty=%H%x00%s"], {
|
|
131
|
+
cwd: this.gitRoot,
|
|
132
|
+
env: gitEnv(),
|
|
133
|
+
encoding: "buffer",
|
|
134
|
+
maxBuffer: 1024 * 1024,
|
|
135
|
+
});
|
|
136
|
+
const text = Buffer.isBuffer(stdout) ? stdout.toString("utf8") : String(stdout);
|
|
137
|
+
const [hash = "", subject = ""] = text.split("\0", 2);
|
|
138
|
+
return { hash: hash.trim(), subject: subject.trim() };
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-deny.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/policy-deny.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG1D,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAS3D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CliError } from "../../shared/errors.js";
|
|
2
|
+
export function throwIfPolicyDenied(res) {
|
|
3
|
+
if (res.ok)
|
|
4
|
+
return;
|
|
5
|
+
const messages = res.errors.map((e) => e.message).join("\n");
|
|
6
|
+
const chosen = res.errors.find((e) => e.code === "E_INTERNAL") ??
|
|
7
|
+
res.errors.find((e) => e.code === "E_USAGE") ??
|
|
8
|
+
res.errors[0];
|
|
9
|
+
if (!chosen)
|
|
10
|
+
return;
|
|
11
|
+
throw new CliError({ exitCode: chosen.exitCode, code: chosen.code, message: messages });
|
|
12
|
+
}
|