agentplane 0.3.15 → 0.3.17
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/assets/policy/incidents.md +7 -0
- package/bin/agentplane.js +1 -1
- package/bin/framework-dev-contract.js +1 -0
- package/dist/.build-manifest.json +641 -351
- package/dist/backends/task-backend/load.d.ts.map +1 -1
- package/dist/backends/task-backend/load.js +32 -19
- package/dist/backends/task-backend/local-backend-doc.d.ts.map +1 -1
- package/dist/backends/task-backend/local-backend-doc.js +1 -1
- package/dist/backends/task-backend/redmine/backend-runtime.d.ts +5 -0
- package/dist/backends/task-backend/redmine/backend-runtime.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-runtime.js +4 -0
- package/dist/backends/task-backend/redmine/backend-sync/context.d.ts +44 -0
- package/dist/backends/task-backend/redmine/backend-sync/context.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-sync/context.js +8 -0
- package/dist/backends/task-backend/redmine/backend-sync/ids.d.ts +6 -0
- package/dist/backends/task-backend/redmine/backend-sync/ids.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-sync/ids.js +21 -0
- package/dist/backends/task-backend/redmine/backend-sync/migration.d.ts +4 -0
- package/dist/backends/task-backend/redmine/backend-sync/migration.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-sync/migration.js +87 -0
- package/dist/backends/task-backend/redmine/backend-sync/status.d.ts +10 -0
- package/dist/backends/task-backend/redmine/backend-sync/status.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-sync/status.js +78 -0
- package/dist/backends/task-backend/redmine/backend-sync/sync.d.ts +12 -0
- package/dist/backends/task-backend/redmine/backend-sync/sync.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-sync/sync.js +82 -0
- package/dist/backends/task-backend/redmine/backend-sync/write.d.ts +5 -0
- package/dist/backends/task-backend/redmine/backend-sync/write.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-sync/write.js +100 -0
- package/dist/backends/task-backend/redmine/backend-sync.d.ts +6 -66
- package/dist/backends/task-backend/redmine/backend-sync.d.ts.map +1 -1
- package/dist/backends/task-backend/redmine/backend-sync.js +5 -367
- package/dist/backends/task-backend/redmine/mapping.js +1 -1
- package/dist/backends/task-backend/redmine/runtime-context.d.ts +98 -0
- package/dist/backends/task-backend/redmine/runtime-context.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/runtime-context.js +57 -0
- package/dist/backends/task-backend/redmine/runtime-methods.d.ts +33 -0
- package/dist/backends/task-backend/redmine/runtime-methods.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/runtime-methods.js +86 -0
- package/dist/backends/task-backend/redmine/runtime-operations.d.ts +19 -0
- package/dist/backends/task-backend/redmine/runtime-operations.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/runtime-operations.js +83 -0
- package/dist/backends/task-backend/redmine/runtime-state.d.ts +10 -0
- package/dist/backends/task-backend/redmine/runtime-state.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/runtime-state.js +45 -0
- package/dist/backends/task-backend/redmine-backend.d.ts +2 -33
- package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -1
- package/dist/backends/task-backend/redmine-backend.js +26 -241
- package/dist/backends/task-backend/shared/constants.d.ts +1 -1
- package/dist/backends/task-backend/shared/constants.d.ts.map +1 -1
- package/dist/backends/task-backend/shared/constants.js +1 -1
- package/dist/backends/task-backend/shared/errors.d.ts +12 -0
- package/dist/backends/task-backend/shared/errors.d.ts.map +1 -1
- package/dist/backends/task-backend/shared/errors.js +12 -0
- package/dist/backends/task-index.d.ts +0 -4
- package/dist/backends/task-index.d.ts.map +1 -1
- package/dist/backends/task-index.js +0 -33
- package/dist/cli/archive.d.ts.map +1 -1
- package/dist/cli/archive.js +3 -5
- package/dist/cli/error-map.d.ts +7 -1
- package/dist/cli/error-map.d.ts.map +1 -1
- package/dist/cli/error-map.js +231 -19
- package/dist/cli/exit-codes.d.ts +14 -2
- package/dist/cli/exit-codes.d.ts.map +1 -1
- package/dist/cli/exit-codes.js +25 -11
- package/dist/cli/http.d.ts.map +1 -1
- package/dist/cli/http.js +34 -15
- package/dist/cli/output.d.ts +3 -0
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +25 -14
- package/dist/cli/prompts.d.ts.map +1 -1
- package/dist/cli/prompts.js +44 -0
- package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/core.js +34 -76
- package/dist/cli/run-cli/command-catalog/lifecycle.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/lifecycle.js +23 -26
- package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/project.js +39 -54
- package/dist/cli/run-cli/command-catalog/shared.d.ts +15 -3
- package/dist/cli/run-cli/command-catalog/shared.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/shared.js +19 -6
- package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/task.js +63 -57
- package/dist/cli/run-cli/command-loaders.d.ts +170 -0
- package/dist/cli/run-cli/command-loaders.d.ts.map +1 -0
- package/dist/cli/run-cli/command-loaders.js +128 -0
- package/dist/cli/run-cli/commands/init/model.d.ts +42 -0
- package/dist/cli/run-cli/commands/init/model.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/orchestrate.d.ts +9 -0
- package/dist/cli/run-cli/commands/init/orchestrate.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/orchestrate.js +321 -0
- package/dist/cli/run-cli/commands/init/parsers.d.ts +5 -0
- package/dist/cli/run-cli/commands/init/parsers.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/parsers.js +36 -0
- package/dist/cli/run-cli/commands/init/presets.d.ts +15 -0
- package/dist/cli/run-cli/commands/init/presets.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/presets.js +63 -0
- package/dist/cli/run-cli/commands/init/spec.d.ts +5 -0
- package/dist/cli/run-cli/commands/init/spec.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/spec.js +212 -0
- package/dist/cli/run-cli/commands/init/write-config.d.ts +1 -0
- package/dist/cli/run-cli/commands/init/write-config.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/write-config.js +1 -0
- package/dist/cli/run-cli/commands/init/write-gitignore.js +1 -1
- package/dist/cli/run-cli/commands/init.d.ts +1 -28
- package/dist/cli/run-cli/commands/init.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init.js +1 -596
- package/dist/cli/run-cli/update-warning.d.ts +1 -0
- package/dist/cli/run-cli/update-warning.d.ts.map +1 -1
- package/dist/cli/run-cli/update-warning.js +10 -2
- package/dist/cli/run-cli.d.ts.map +1 -1
- package/dist/cli/run-cli.js +1 -2
- package/dist/cli/spec/errors.d.ts +18 -1
- package/dist/cli/spec/errors.d.ts.map +1 -1
- package/dist/cli/spec/errors.js +27 -4
- package/dist/cli/spec/parse.d.ts.map +1 -1
- package/dist/cli/spec/parse.js +8 -1
- package/dist/commands/backend.d.ts.map +1 -1
- package/dist/commands/backend.js +66 -118
- package/dist/commands/block.spec.js +1 -1
- package/dist/commands/branch/work-start.d.ts.map +1 -1
- package/dist/commands/branch/work-start.direct.d.ts +13 -0
- package/dist/commands/branch/work-start.direct.d.ts.map +1 -0
- package/dist/commands/branch/work-start.direct.js +75 -0
- package/dist/commands/branch/work-start.git.d.ts +3 -0
- package/dist/commands/branch/work-start.git.d.ts.map +1 -0
- package/dist/commands/branch/work-start.git.js +19 -0
- package/dist/commands/branch/work-start.hook-shim.d.ts +2 -0
- package/dist/commands/branch/work-start.hook-shim.d.ts.map +1 -0
- package/dist/commands/branch/work-start.hook-shim.js +38 -0
- package/dist/commands/branch/work-start.js +6 -235
- package/dist/commands/branch/work-start.materialize.d.ts +16 -0
- package/dist/commands/branch/work-start.materialize.d.ts.map +1 -0
- package/dist/commands/branch/work-start.materialize.js +110 -0
- package/dist/commands/commit.spec.js +1 -1
- package/dist/commands/doctor/branch-pr.js +1 -1
- package/dist/commands/doctor/fixes.d.ts +0 -5
- package/dist/commands/doctor/fixes.d.ts.map +1 -1
- package/dist/commands/doctor/fixes.js +1 -71
- package/dist/commands/doctor/runtime.d.ts.map +1 -1
- package/dist/commands/doctor/runtime.js +2 -2
- package/dist/commands/doctor/workflow.d.ts.map +1 -1
- package/dist/commands/doctor/workflow.js +2 -23
- package/dist/commands/doctor/workspace.js +1 -1
- package/dist/commands/doctor.run.d.ts.map +1 -1
- package/dist/commands/doctor.run.js +1 -3
- package/dist/commands/finish.spec.js +1 -1
- package/dist/commands/guard/commit.command.js +1 -1
- package/dist/commands/guard/impl/clean.d.ts +6 -0
- package/dist/commands/guard/impl/clean.d.ts.map +1 -0
- package/dist/commands/guard/impl/clean.js +29 -0
- package/dist/commands/guard/impl/close-dirt.d.ts +6 -0
- package/dist/commands/guard/impl/close-dirt.d.ts.map +1 -0
- package/dist/commands/guard/impl/close-dirt.js +56 -0
- package/dist/commands/guard/impl/commands.d.ts +4 -36
- package/dist/commands/guard/impl/commands.d.ts.map +1 -1
- package/dist/commands/guard/impl/commands.js +4 -549
- package/dist/commands/guard/impl/comment-commit.js +1 -1
- package/dist/commands/guard/impl/commit-diagnostics.d.ts +4 -0
- package/dist/commands/guard/impl/commit-diagnostics.d.ts.map +1 -0
- package/dist/commands/guard/impl/commit-diagnostics.js +150 -0
- package/dist/commands/guard/impl/commit.d.ts +25 -0
- package/dist/commands/guard/impl/commit.d.ts.map +1 -0
- package/dist/commands/guard/impl/commit.js +366 -0
- package/dist/commands/guard/impl/guard-commit.d.ts +3 -0
- package/dist/commands/guard/impl/guard-commit.d.ts.map +1 -0
- package/dist/commands/guard/impl/guard-commit.js +21 -0
- package/dist/commands/guard/impl/policy.d.ts +1 -0
- package/dist/commands/guard/impl/policy.d.ts.map +1 -1
- package/dist/commands/guard/impl/policy.js +9 -2
- package/dist/commands/guard/impl/suggest.d.ts +6 -0
- package/dist/commands/guard/impl/suggest.d.ts.map +1 -0
- package/dist/commands/guard/impl/suggest.js +33 -0
- package/dist/commands/hooks/index.d.ts +4 -17
- package/dist/commands/hooks/index.d.ts.map +1 -1
- package/dist/commands/hooks/index.js +4 -415
- package/dist/commands/hooks/install.d.ts +11 -0
- package/dist/commands/hooks/install.d.ts.map +1 -0
- package/dist/commands/hooks/install.js +136 -0
- package/dist/commands/hooks/run.commit-msg.d.ts +3 -0
- package/dist/commands/hooks/run.commit-msg.d.ts.map +1 -0
- package/dist/commands/hooks/run.commit-msg.js +67 -0
- package/dist/commands/hooks/run.d.ts +9 -0
- package/dist/commands/hooks/run.d.ts.map +1 -0
- package/dist/commands/hooks/run.js +45 -0
- package/dist/commands/hooks/run.post-merge.d.ts +3 -0
- package/dist/commands/hooks/run.post-merge.d.ts.map +1 -0
- package/dist/commands/hooks/run.post-merge.js +44 -0
- package/dist/commands/hooks/run.pre-commit.d.ts +3 -0
- package/dist/commands/hooks/run.pre-commit.d.ts.map +1 -0
- package/dist/commands/hooks/run.pre-commit.js +48 -0
- package/dist/commands/hooks/run.pre-push.d.ts +6 -0
- package/dist/commands/hooks/run.pre-push.d.ts.map +1 -0
- package/dist/commands/hooks/run.pre-push.js +88 -0
- package/dist/commands/hooks/shared.d.ts +7 -0
- package/dist/commands/hooks/shared.d.ts.map +1 -0
- package/dist/commands/hooks/shared.js +41 -0
- package/dist/commands/pr/integrate/cmd.js +1 -1
- package/dist/commands/pr/integrate/internal/prepare.js +1 -1
- package/dist/commands/pr/internal/auto-commit.d.ts.map +1 -1
- package/dist/commands/pr/internal/auto-commit.js +2 -5
- package/dist/commands/pr/internal/gh-api.d.ts.map +1 -1
- package/dist/commands/pr/internal/gh-api.js +15 -8
- package/dist/commands/pr/internal/sync-branch.d.ts +0 -1
- package/dist/commands/pr/internal/sync-branch.d.ts.map +1 -1
- package/dist/commands/pr/internal/sync-branch.js +2 -5
- package/dist/commands/pr/internal/sync.d.ts.map +1 -1
- package/dist/commands/pr/internal/sync.js +30 -0
- package/dist/commands/pr/open.d.ts.map +1 -1
- package/dist/commands/pr/open.js +98 -8
- package/dist/commands/recipes/impl/index.d.ts.map +1 -1
- package/dist/commands/recipes/impl/index.js +13 -3
- package/dist/commands/recipes/impl/resolver.js +1 -1
- package/dist/commands/recipes/impl/version.js +1 -1
- package/dist/commands/release/apply.command.js +1 -1
- package/dist/commands/release/apply.mutation.d.ts +1 -0
- package/dist/commands/release/apply.mutation.d.ts.map +1 -1
- package/dist/commands/release/apply.mutation.js +4 -0
- package/dist/commands/release/apply.pipeline/finalize.d.ts +21 -0
- package/dist/commands/release/apply.pipeline/finalize.d.ts.map +1 -0
- package/dist/commands/release/apply.pipeline/finalize.js +80 -0
- package/dist/commands/release/apply.pipeline/mutation.d.ts +18 -0
- package/dist/commands/release/apply.pipeline/mutation.d.ts.map +1 -0
- package/dist/commands/release/apply.pipeline/mutation.js +78 -0
- package/dist/commands/release/apply.pipeline/preflight.d.ts +25 -0
- package/dist/commands/release/apply.pipeline/preflight.d.ts.map +1 -0
- package/dist/commands/release/apply.pipeline/preflight.js +69 -0
- package/dist/commands/release/apply.pipeline/shared.d.ts +2 -0
- package/dist/commands/release/apply.pipeline/shared.d.ts.map +1 -0
- package/dist/commands/release/apply.pipeline/shared.js +5 -0
- package/dist/commands/release/apply.pipeline/state.d.ts +25 -0
- package/dist/commands/release/apply.pipeline/state.d.ts.map +1 -0
- package/dist/commands/release/apply.pipeline/state.js +129 -0
- package/dist/commands/release/apply.pipeline.d.ts +1 -1
- package/dist/commands/release/apply.pipeline.d.ts.map +1 -1
- package/dist/commands/release/apply.pipeline.js +4 -347
- package/dist/commands/release/apply.preflight.d.ts +9 -6
- package/dist/commands/release/apply.preflight.d.ts.map +1 -1
- package/dist/commands/release/apply.preflight.js +71 -51
- package/dist/commands/runtime.command.d.ts +2 -2
- package/dist/commands/runtime.command.d.ts.map +1 -1
- package/dist/commands/runtime.command.js +2 -2
- package/dist/commands/scenario/impl/commands.d.ts.map +1 -1
- package/dist/commands/scenario/impl/commands.js +52 -39
- package/dist/commands/scenario/impl/report.d.ts.map +1 -1
- package/dist/commands/scenario/impl/report.js +4 -7
- package/dist/commands/shared/allow-prefix-policy.d.ts.map +1 -0
- package/dist/{shared → commands/shared}/allow-prefix-policy.js +1 -1
- package/dist/commands/shared/comment-format.d.ts.map +1 -0
- package/dist/commands/shared/diagnostics.d.ts.map +1 -0
- package/dist/commands/shared/git-context.d.ts +1 -27
- package/dist/commands/shared/git-context.d.ts.map +1 -1
- package/dist/commands/shared/git-context.js +1 -156
- package/dist/commands/shared/git-diff.d.ts +1 -10
- package/dist/commands/shared/git-diff.d.ts.map +1 -1
- package/dist/commands/shared/git-diff.js +1 -49
- package/dist/commands/shared/git-ops.d.ts +1 -14
- package/dist/commands/shared/git-ops.d.ts.map +1 -1
- package/dist/commands/shared/git-ops.js +20 -150
- package/dist/commands/shared/git-worktree.d.ts +1 -9
- package/dist/commands/shared/git-worktree.d.ts.map +1 -1
- package/dist/commands/shared/git-worktree.js +1 -68
- package/dist/commands/shared/git.d.ts +1 -3
- package/dist/commands/shared/git.d.ts.map +1 -1
- package/dist/commands/shared/git.js +1 -14
- package/dist/commands/shared/policy-deny.d.ts +1 -1
- package/dist/commands/shared/reconcile-check.js +1 -1
- package/dist/commands/shared/task-backend.d.ts.map +1 -1
- package/dist/commands/shared/task-backend.js +24 -2
- package/dist/commands/shared/task-store/intents.d.ts.map +1 -1
- package/dist/commands/shared/task-store/intents.js +1 -1
- package/dist/commands/start.spec.js +1 -1
- package/dist/commands/task/close-tail-state.d.ts +7 -0
- package/dist/commands/task/close-tail-state.d.ts.map +1 -0
- package/dist/commands/task/close-tail-state.js +18 -0
- package/dist/commands/task/derive.js +1 -1
- package/dist/commands/task/finish-close.d.ts +22 -0
- package/dist/commands/task/finish-close.d.ts.map +1 -0
- package/dist/commands/task/finish-close.js +119 -0
- package/dist/commands/task/finish-command.d.ts +3 -0
- package/dist/commands/task/finish-command.d.ts.map +1 -0
- package/dist/commands/task/finish-command.js +56 -0
- package/dist/commands/task/finish-execute.d.ts +8 -0
- package/dist/commands/task/finish-execute.d.ts.map +1 -0
- package/dist/commands/task/finish-execute.js +272 -0
- package/dist/commands/task/finish-findings.d.ts +20 -0
- package/dist/commands/task/finish-findings.d.ts.map +1 -0
- package/dist/commands/task/finish-findings.js +27 -0
- package/dist/commands/task/finish-plan.d.ts +7 -0
- package/dist/commands/task/finish-plan.d.ts.map +1 -0
- package/dist/commands/task/finish-plan.js +157 -0
- package/dist/commands/task/finish-types.d.ts +69 -0
- package/dist/commands/task/finish-types.d.ts.map +1 -0
- package/dist/commands/task/finish.d.ts +1 -42
- package/dist/commands/task/finish.d.ts.map +1 -1
- package/dist/commands/task/finish.js +1 -527
- package/dist/commands/task/hosted-close-pr.command.d.ts +2 -7
- package/dist/commands/task/hosted-close-pr.command.d.ts.map +1 -1
- package/dist/commands/task/hosted-close-pr.command.js +9 -348
- package/dist/commands/task/hosted-close-pr.execute.d.ts +3 -0
- package/dist/commands/task/hosted-close-pr.execute.d.ts.map +1 -0
- package/dist/commands/task/hosted-close-pr.execute.js +135 -0
- package/dist/commands/task/hosted-close-pr.postcheck.d.ts +3 -0
- package/dist/commands/task/hosted-close-pr.postcheck.d.ts.map +1 -0
- package/dist/commands/task/hosted-close-pr.postcheck.js +13 -0
- package/dist/commands/task/hosted-close-pr.precheck.d.ts +4 -0
- package/dist/commands/task/hosted-close-pr.precheck.d.ts.map +1 -0
- package/dist/commands/task/hosted-close-pr.precheck.js +288 -0
- package/dist/commands/task/hosted-close-pr.report.d.ts +4 -0
- package/dist/commands/task/hosted-close-pr.report.d.ts.map +1 -0
- package/dist/commands/task/hosted-close-pr.report.js +42 -0
- package/dist/commands/task/hosted-close-pr.types.d.ts +75 -0
- package/dist/commands/task/hosted-close-pr.types.d.ts.map +1 -0
- package/dist/commands/task/hosted-merge-sync/builders.d.ts +35 -0
- package/dist/commands/task/hosted-merge-sync/builders.d.ts.map +1 -0
- package/dist/commands/task/hosted-merge-sync/builders.js +148 -0
- package/dist/commands/task/hosted-merge-sync/github.d.ts +10 -0
- package/dist/commands/task/hosted-merge-sync/github.d.ts.map +1 -0
- package/dist/commands/task/hosted-merge-sync/github.js +113 -0
- package/dist/commands/task/hosted-merge-sync/local-branch.d.ts +12 -0
- package/dist/commands/task/hosted-merge-sync/local-branch.d.ts.map +1 -0
- package/dist/commands/task/hosted-merge-sync/local-branch.js +143 -0
- package/dist/commands/task/hosted-merge-sync/model.d.ts +47 -0
- package/dist/commands/task/hosted-merge-sync/model.d.ts.map +1 -0
- package/dist/commands/task/hosted-merge-sync/pr-meta.d.ts +12 -0
- package/dist/commands/task/hosted-merge-sync/pr-meta.d.ts.map +1 -0
- package/dist/commands/task/hosted-merge-sync/pr-meta.js +26 -0
- package/dist/commands/task/hosted-merge-sync.d.ts +5 -63
- package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
- package/dist/commands/task/hosted-merge-sync.js +10 -444
- package/dist/commands/task/new.js +1 -1
- package/dist/commands/task/set-status.command.js +1 -1
- package/dist/commands/task/shared/direct-work-lock.d.ts.map +1 -0
- package/dist/commands/task/shared/git-log.d.ts.map +1 -0
- package/dist/commands/task/shared/transitions.d.ts +1 -1
- package/dist/commands/task/shared/transitions.d.ts.map +1 -1
- package/dist/commands/task/shared/transitions.js +4 -6
- package/dist/commands/upgrade/apply.js +1 -1
- package/dist/commands/upgrade/materialize.d.ts.map +1 -1
- package/dist/commands/upgrade/materialize.js +0 -7
- package/dist/commands/upgrade/source.d.ts +0 -1
- package/dist/commands/upgrade/source.d.ts.map +1 -1
- package/dist/commands/upgrade/source.js +1 -9
- package/dist/commands/workflow-playbook.command.d.ts.map +1 -1
- package/dist/commands/workflow-playbook.command.js +8 -7
- package/dist/harness/hooks-lifecycle.d.ts.map +1 -1
- package/dist/harness/hooks-lifecycle.js +11 -7
- package/dist/meta/release.d.ts.map +1 -1
- package/dist/meta/release.js +8 -4
- package/dist/policy/engine.d.ts +1 -1
- package/dist/policy/evaluate.d.ts +1 -1
- package/dist/policy/{types.d.ts → model.d.ts} +1 -1
- package/dist/policy/{types.d.ts.map → model.d.ts.map} +1 -1
- package/dist/policy/result.d.ts +1 -1
- package/dist/policy/rules/allowlist.d.ts +1 -1
- package/dist/policy/rules/branch-pr-base.d.ts +1 -1
- package/dist/policy/rules/clean-tree.d.ts +1 -1
- package/dist/policy/rules/commit-subject.d.ts +1 -1
- package/dist/policy/rules/protected-paths.d.ts +1 -1
- package/dist/runner/adapters/base.d.ts +42 -0
- package/dist/runner/adapters/base.d.ts.map +1 -0
- package/dist/runner/adapters/base.js +107 -0
- package/dist/runner/adapters/codex-preparation.d.ts +7 -0
- package/dist/runner/adapters/codex-preparation.d.ts.map +1 -0
- package/dist/runner/adapters/codex-preparation.js +86 -0
- package/dist/runner/adapters/codex.d.ts.map +1 -1
- package/dist/runner/adapters/codex.js +30 -175
- package/dist/runner/adapters/custom-preparation.d.ts +9 -0
- package/dist/runner/adapters/custom-preparation.d.ts.map +1 -0
- package/dist/runner/adapters/custom-preparation.js +191 -0
- package/dist/runner/adapters/custom.d.ts.map +1 -1
- package/dist/runner/adapters/custom.js +26 -279
- package/dist/runner/context/base-prompts.d.ts.map +1 -1
- package/dist/runner/context/base-prompts.js +4 -0
- package/dist/runner/context/project-skill-prompt-blocks.d.ts +5 -0
- package/dist/runner/context/project-skill-prompt-blocks.d.ts.map +1 -0
- package/dist/runner/context/project-skill-prompt-blocks.js +57 -0
- package/dist/runner/process-supervision/run.d.ts +30 -0
- package/dist/runner/process-supervision/run.d.ts.map +1 -0
- package/dist/runner/process-supervision/run.js +351 -0
- package/dist/runner/process-supervision/signals.d.ts +16 -0
- package/dist/runner/process-supervision/signals.d.ts.map +1 -0
- package/dist/runner/process-supervision/signals.js +85 -0
- package/dist/runner/process-supervision/state.d.ts +10 -0
- package/dist/runner/process-supervision/state.d.ts.map +1 -0
- package/dist/runner/process-supervision/state.js +42 -0
- package/dist/runner/process-supervision/streams.d.ts +6 -0
- package/dist/runner/process-supervision/streams.d.ts.map +1 -0
- package/dist/runner/process-supervision/streams.js +23 -0
- package/dist/runner/process-supervision.d.ts +5 -47
- package/dist/runner/process-supervision.d.ts.map +1 -1
- package/dist/runner/process-supervision.js +3 -490
- package/dist/runner/usecases/scenario-materialize-task.js +1 -1
- package/dist/runtime/approvals/index.d.ts +1 -1
- package/dist/runtime/approvals/{types.d.ts → model.d.ts} +1 -1
- package/dist/runtime/approvals/{types.d.ts.map → model.d.ts.map} +1 -1
- package/dist/runtime/approvals/runtime.d.ts +1 -1
- package/dist/runtime/behavior/index.d.ts +1 -1
- package/dist/runtime/behavior/{types.d.ts → model.d.ts} +1 -1
- package/dist/runtime/behavior/{types.d.ts.map → model.d.ts.map} +1 -1
- package/dist/runtime/behavior/model.js +1 -0
- package/dist/runtime/behavior/resolve.d.ts +1 -1
- package/dist/runtime/capabilities/backend.d.ts +1 -1
- package/dist/runtime/capabilities/index.d.ts +1 -1
- package/dist/runtime/capabilities/{types.d.ts → model.d.ts} +1 -1
- package/dist/runtime/capabilities/{types.d.ts.map → model.d.ts.map} +1 -1
- package/dist/runtime/capabilities/model.js +1 -0
- package/dist/runtime/capabilities/recipe.d.ts +1 -1
- package/dist/runtime/capabilities/registry.d.ts +1 -1
- package/dist/runtime/capabilities/runner.d.ts +1 -1
- package/dist/runtime/execution-context.d.ts.map +1 -1
- package/dist/runtime/execution-context.js +16 -0
- package/dist/runtime/execution-profile/index.d.ts +1 -1
- package/dist/runtime/execution-profile/{types.d.ts → model.d.ts} +1 -1
- package/dist/runtime/execution-profile/{types.d.ts.map → model.d.ts.map} +1 -1
- package/dist/runtime/execution-profile/model.js +1 -0
- package/dist/runtime/execution-profile/resolve.d.ts +1 -1
- package/dist/runtime/explain/index.d.ts +1 -1
- package/dist/runtime/explain/{types.d.ts → model.d.ts} +1 -1
- package/dist/runtime/explain/{types.d.ts.map → model.d.ts.map} +1 -1
- package/dist/runtime/explain/model.js +1 -0
- package/dist/runtime/explain/resolve.d.ts +1 -1
- package/dist/runtime/protocol/index.d.ts +1 -1
- package/dist/runtime/protocol/index.js +1 -1
- package/dist/runtime/protocol/{types.d.ts → model.d.ts} +1 -1
- package/dist/runtime/protocol/{types.d.ts.map → model.d.ts.map} +1 -1
- package/dist/runtime/protocol/resolve.d.ts +1 -1
- package/dist/runtime/protocol/resolve.js +1 -1
- package/dist/runtime/shared/repo-cli-version.d.ts.map +1 -0
- package/dist/{shared → runtime/shared}/repo-cli-version.js +1 -1
- package/dist/runtime/shared/runtime-artifacts.d.ts.map +1 -0
- package/dist/{shared → runtime/shared}/runtime-source.d.ts +1 -1
- package/dist/runtime/shared/runtime-source.d.ts.map +1 -0
- package/dist/{shared → runtime/shared}/runtime-source.js +1 -1
- package/dist/runtime/shared/version-compare.d.ts.map +1 -0
- package/dist/runtime/task-intake/resolve.js +1 -1
- package/dist/shared/errors.d.ts +56 -3
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/errors.js +72 -4
- package/dist/shared/trace-events.d.ts +13 -0
- package/dist/shared/trace-events.d.ts.map +1 -0
- package/dist/shared/trace-events.js +17 -0
- package/dist/shared/workflow-artifacts.d.ts.map +1 -1
- package/dist/shared/workflow-artifacts.js +1 -8
- package/dist/{shared/task-doc-conflicts.d.ts → task-doc/conflicts.d.ts} +1 -1
- package/dist/task-doc/conflicts.d.ts.map +1 -0
- package/dist/{shared/task-doc-conflicts.js → task-doc/conflicts.js} +1 -1
- package/dist/{shared/task-doc-state.d.ts → task-doc/state.d.ts} +1 -1
- package/dist/task-doc/state.d.ts.map +1 -0
- package/dist/workflow-runtime/file-ops.d.ts.map +1 -1
- package/dist/workflow-runtime/file-ops.js +1 -20
- package/dist/workflow-runtime/paths.d.ts.map +1 -1
- package/dist/workflow-runtime/paths.js +0 -1
- package/dist/workflow-runtime/types.d.ts +0 -1
- package/dist/workflow-runtime/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/cli/run-cli/error-guidance.d.ts +0 -9
- package/dist/cli/run-cli/error-guidance.d.ts.map +0 -1
- package/dist/cli/run-cli/error-guidance.js +0 -210
- package/dist/cli/run-cli.test-helpers.d.ts +0 -2
- package/dist/cli/run-cli.test-helpers.d.ts.map +0 -1
- package/dist/cli/run-cli.test-helpers.js +0 -1
- package/dist/commands/recipes.test-helpers.d.ts +0 -202
- package/dist/commands/recipes.test-helpers.d.ts.map +0 -1
- package/dist/commands/recipes.test-helpers.js +0 -483
- package/dist/commands/release.test-helpers.d.ts +0 -38
- package/dist/commands/release.test-helpers.d.ts.map +0 -1
- package/dist/commands/release.test-helpers.js +0 -55
- package/dist/commands/task.test-helpers.d.ts +0 -13
- package/dist/commands/task.test-helpers.d.ts.map +0 -1
- package/dist/commands/task.test-helpers.js +0 -65
- package/dist/runner/test-helpers.d.ts +0 -30
- package/dist/runner/test-helpers.d.ts.map +0 -1
- package/dist/runner/test-helpers.js +0 -97
- package/dist/shared/agent-emoji.d.ts +0 -5
- package/dist/shared/agent-emoji.d.ts.map +0 -1
- package/dist/shared/agent-emoji.js +0 -51
- package/dist/shared/allow-prefix-policy.d.ts.map +0 -1
- package/dist/shared/comment-format.d.ts.map +0 -1
- package/dist/shared/diagnostics.d.ts.map +0 -1
- package/dist/shared/direct-work-lock.d.ts.map +0 -1
- package/dist/shared/git-log.d.ts.map +0 -1
- package/dist/shared/repo-cli-version.d.ts.map +0 -1
- package/dist/shared/runtime-artifacts.d.ts.map +0 -1
- package/dist/shared/runtime-source.d.ts.map +0 -1
- package/dist/shared/task-doc-conflicts.d.ts.map +0 -1
- package/dist/shared/task-doc-state.d.ts.map +0 -1
- package/dist/shared/version-compare.d.ts.map +0 -1
- package/dist/testing/cli-harness/recipe-archives.d.ts +0 -28
- package/dist/testing/cli-harness/recipe-archives.d.ts.map +0 -1
- package/dist/testing/cli-harness/recipe-archives.js +0 -374
- package/dist/testing/cli-harness/stdio.d.ts +0 -26
- package/dist/testing/cli-harness/stdio.d.ts.map +0 -1
- package/dist/testing/cli-harness/stdio.js +0 -84
- package/dist/testing/cli-harness.d.ts +0 -25
- package/dist/testing/cli-harness.d.ts.map +0 -1
- package/dist/testing/cli-harness.js +0 -313
- package/dist/testing/index.d.ts +0 -2
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js +0 -1
- /package/dist/{policy/types.js → cli/run-cli/commands/init/model.js} +0 -0
- /package/dist/{shared → commands/shared}/allow-prefix-policy.d.ts +0 -0
- /package/dist/{shared → commands/shared}/comment-format.d.ts +0 -0
- /package/dist/{shared → commands/shared}/comment-format.js +0 -0
- /package/dist/{shared → commands/shared}/diagnostics.d.ts +0 -0
- /package/dist/{shared → commands/shared}/diagnostics.js +0 -0
- /package/dist/{runtime/approvals/types.js → commands/task/finish-types.js} +0 -0
- /package/dist/{runtime/behavior/types.js → commands/task/hosted-close-pr.types.js} +0 -0
- /package/dist/{runtime/capabilities/types.js → commands/task/hosted-merge-sync/model.js} +0 -0
- /package/dist/{shared → commands/task/shared}/direct-work-lock.d.ts +0 -0
- /package/dist/{shared → commands/task/shared}/direct-work-lock.js +0 -0
- /package/dist/{shared → commands/task/shared}/git-log.d.ts +0 -0
- /package/dist/{shared → commands/task/shared}/git-log.js +0 -0
- /package/dist/{runtime/execution-profile/types.js → policy/model.js} +0 -0
- /package/dist/runtime/{explain/types.js → approvals/model.js} +0 -0
- /package/dist/runtime/protocol/{types.js → model.js} +0 -0
- /package/dist/{shared → runtime/shared}/repo-cli-version.d.ts +0 -0
- /package/dist/{shared → runtime/shared}/runtime-artifacts.d.ts +0 -0
- /package/dist/{shared → runtime/shared}/runtime-artifacts.js +0 -0
- /package/dist/{shared → runtime/shared}/version-compare.d.ts +0 -0
- /package/dist/{shared → runtime/shared}/version-compare.js +0 -0
- /package/dist/{shared/task-doc-state.js → task-doc/state.js} +0 -0
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
quiet: boolean;
|
|
6
|
-
}): Promise<number>;
|
|
7
|
-
export declare function cmdHooksUninstall(opts: {
|
|
8
|
-
cwd: string;
|
|
9
|
-
rootOverride?: string;
|
|
10
|
-
quiet: boolean;
|
|
11
|
-
}): Promise<number>;
|
|
12
|
-
export declare function cmdHooksRun(opts: {
|
|
13
|
-
cwd: string;
|
|
14
|
-
rootOverride?: string;
|
|
15
|
-
hook: (typeof HOOK_NAMES)[number];
|
|
16
|
-
args: string[];
|
|
17
|
-
}): Promise<number>;
|
|
1
|
+
export { HOOK_NAMES, type HookName } from "./shared.js";
|
|
2
|
+
export { cmdHooksInstall, cmdHooksUninstall } from "./install.js";
|
|
3
|
+
export { cmdHooksRun } from "./run.js";
|
|
4
|
+
export { resolvePrePushHookScriptPath } from "./run.pre-push.js";
|
|
18
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/hooks/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,415 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { loadConfig, resolveBaseBranch, resolveProject } from "@agentplaneorg/core";
|
|
6
|
-
import { evaluatePolicy } from "../../policy/evaluate.js";
|
|
7
|
-
import { mapBackendError, mapCoreError } from "../../cli/error-map.js";
|
|
8
|
-
import { fileExists } from "../../cli/fs-utils.js";
|
|
9
|
-
import { infoMessage, successMessage } from "../../cli/output.js";
|
|
10
|
-
import { CliError } from "../../shared/errors.js";
|
|
11
|
-
import { cmdCleanupMerged } from "../branch/index.js";
|
|
12
|
-
import { GitContext } from "../shared/git-context.js";
|
|
13
|
-
import { throwIfPolicyDenied } from "../shared/policy-deny.js";
|
|
14
|
-
import { gitCurrentBranch, gitRevParse } from "../shared/git-ops.js";
|
|
15
|
-
import { parseTaskIdFromBranch, parseTaskIdFromCloseBranch } from "../shared/git-worktree.js";
|
|
16
|
-
import { isPathWithin } from "../shared/path.js";
|
|
17
|
-
import { loadCommandContext } from "../shared/task-backend.js";
|
|
18
|
-
const HOOK_MARKER = "agentplane-hook";
|
|
19
|
-
const SHIM_MARKER = "agentplane-hook-shim";
|
|
20
|
-
export const HOOK_NAMES = ["commit-msg", "pre-commit", "pre-push", "post-merge"];
|
|
21
|
-
async function inferTaskIdFromBranchContext(opts) {
|
|
22
|
-
try {
|
|
23
|
-
const branch = await gitCurrentBranch(opts.gitRoot);
|
|
24
|
-
return (parseTaskIdFromBranch(opts.taskPrefix, branch) ?? parseTaskIdFromCloseBranch(branch) ?? "");
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return "";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async function resolveGitHooksDir(cwd) {
|
|
31
|
-
const repoRoot = await gitRevParse(cwd, ["--show-toplevel"]);
|
|
32
|
-
const commonDirRaw = await gitRevParse(cwd, ["--git-common-dir"]);
|
|
33
|
-
const hooksRaw = await gitRevParse(cwd, ["--git-path", "hooks"]);
|
|
34
|
-
const commonDir = path.resolve(path.isAbsolute(commonDirRaw) ? commonDirRaw : path.join(repoRoot, commonDirRaw));
|
|
35
|
-
const hooksDir = path.resolve(path.isAbsolute(hooksRaw) ? hooksRaw : path.join(repoRoot, hooksRaw));
|
|
36
|
-
const resolvedRoot = path.resolve(repoRoot);
|
|
37
|
-
if (!isPathWithin(resolvedRoot, hooksDir) && !isPathWithin(commonDir, hooksDir)) {
|
|
38
|
-
throw new CliError({
|
|
39
|
-
exitCode: 5,
|
|
40
|
-
code: "E_GIT",
|
|
41
|
-
message: [
|
|
42
|
-
"Refusing to manage git hooks outside the repository.",
|
|
43
|
-
`hooks_path=${hooksDir}`,
|
|
44
|
-
`repo_root=${resolvedRoot}`,
|
|
45
|
-
`common_dir=${commonDir}`,
|
|
46
|
-
"Fix:",
|
|
47
|
-
" 1) Use a repo-relative core.hooksPath (e.g., .git/hooks)",
|
|
48
|
-
" 2) Re-run `agentplane hooks install`",
|
|
49
|
-
].join("\n"),
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return hooksDir;
|
|
53
|
-
}
|
|
54
|
-
async function fileIsManaged(filePath, marker) {
|
|
55
|
-
try {
|
|
56
|
-
const content = await readFile(filePath, "utf8");
|
|
57
|
-
return content.includes(marker);
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function hookScriptText(hook) {
|
|
64
|
-
return [
|
|
65
|
-
"#!/usr/bin/env sh",
|
|
66
|
-
`# ${HOOK_MARKER} (do not edit)`,
|
|
67
|
-
"set -e",
|
|
68
|
-
'REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"',
|
|
69
|
-
'SHIM="$REPO_ROOT/.agentplane/bin/agentplane"',
|
|
70
|
-
'if [ -x "$SHIM" ]; then',
|
|
71
|
-
' exec "$SHIM" hooks run ' + hook + ' "$@"',
|
|
72
|
-
"fi",
|
|
73
|
-
"if ! command -v agentplane >/dev/null 2>&1; then",
|
|
74
|
-
' echo "agentplane hooks: runner not found (PATH missing and shim unavailable)." >&2',
|
|
75
|
-
" exit 127",
|
|
76
|
-
"fi",
|
|
77
|
-
"exec agentplane hooks run " + hook + ' "$@"',
|
|
78
|
-
"",
|
|
79
|
-
].join("\n");
|
|
80
|
-
}
|
|
81
|
-
function shimScriptText() {
|
|
82
|
-
return [
|
|
83
|
-
"#!/usr/bin/env sh",
|
|
84
|
-
`# ${SHIM_MARKER} (do not edit)`,
|
|
85
|
-
"set -e",
|
|
86
|
-
'SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"',
|
|
87
|
-
'REPO_ROOT="$(dirname "$(dirname "$SCRIPT_DIR")")"',
|
|
88
|
-
'LOCAL_BIN="$REPO_ROOT/packages/agentplane/bin/agentplane.js"',
|
|
89
|
-
'if command -v node >/dev/null 2>&1 && [ -f "$LOCAL_BIN" ]; then',
|
|
90
|
-
' exec node "$LOCAL_BIN" "$@"',
|
|
91
|
-
"fi",
|
|
92
|
-
'ENV_BIN="${AGENTPLANE_HOOK_RUNNER:-}"',
|
|
93
|
-
'if [ -n "$ENV_BIN" ] && command -v node >/dev/null 2>&1 && [ -f "$ENV_BIN" ]; then',
|
|
94
|
-
' exec node "$ENV_BIN" "$@"',
|
|
95
|
-
"fi",
|
|
96
|
-
"if command -v agentplane >/dev/null 2>&1; then",
|
|
97
|
-
' exec agentplane "$@"',
|
|
98
|
-
"fi",
|
|
99
|
-
"if command -v npx >/dev/null 2>&1; then",
|
|
100
|
-
' exec npx --yes agentplane "$@"',
|
|
101
|
-
"fi",
|
|
102
|
-
'echo "agentplane shim: runner not found (need env runner, repo-local source, agentplane in PATH, or node+npx)." >&2',
|
|
103
|
-
" exit 127",
|
|
104
|
-
"",
|
|
105
|
-
].join("\n");
|
|
106
|
-
}
|
|
107
|
-
async function ensureShim(agentplaneDir, gitRoot) {
|
|
108
|
-
const shimDir = path.join(agentplaneDir, "bin");
|
|
109
|
-
const shimPath = path.join(shimDir, "agentplane");
|
|
110
|
-
await mkdir(shimDir, { recursive: true });
|
|
111
|
-
if (await fileExists(shimPath)) {
|
|
112
|
-
const managed = await fileIsManaged(shimPath, SHIM_MARKER);
|
|
113
|
-
if (!managed) {
|
|
114
|
-
throw new CliError({
|
|
115
|
-
exitCode: 5,
|
|
116
|
-
code: "E_GIT",
|
|
117
|
-
message: `Refusing to overwrite existing shim: ${path.relative(gitRoot, shimPath)}`,
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
await writeFile(shimPath, shimScriptText(), "utf8");
|
|
122
|
-
await chmod(shimPath, 0o755);
|
|
123
|
-
}
|
|
124
|
-
function readCommitSubject(message) {
|
|
125
|
-
for (const line of message.split("\n")) {
|
|
126
|
-
const trimmed = line.trim();
|
|
127
|
-
if (!trimmed || trimmed.startsWith("#"))
|
|
128
|
-
continue;
|
|
129
|
-
return trimmed;
|
|
130
|
-
}
|
|
131
|
-
return "";
|
|
132
|
-
}
|
|
133
|
-
function resolveBundledPrePushHookScriptPath() {
|
|
134
|
-
return fileURLToPath(new URL("../../../../../scripts/run-pre-push-hook.mjs", import.meta.url));
|
|
135
|
-
}
|
|
136
|
-
async function readHookStdinUtf8(timeoutMs = 25) {
|
|
137
|
-
if (process.stdin.isTTY)
|
|
138
|
-
return "";
|
|
139
|
-
const chunks = [];
|
|
140
|
-
const consume = () => {
|
|
141
|
-
let chunk = process.stdin.read();
|
|
142
|
-
while (chunk !== null) {
|
|
143
|
-
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));
|
|
144
|
-
chunk = process.stdin.read();
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
consume();
|
|
148
|
-
if (chunks.length > 0 || process.stdin.readableEnded) {
|
|
149
|
-
return Buffer.concat(chunks).toString("utf8");
|
|
150
|
-
}
|
|
151
|
-
await new Promise((resolve) => {
|
|
152
|
-
const finish = () => {
|
|
153
|
-
clearTimeout(timer);
|
|
154
|
-
process.stdin.off("readable", onReadable);
|
|
155
|
-
process.stdin.off("end", onEnd);
|
|
156
|
-
resolve();
|
|
157
|
-
};
|
|
158
|
-
const onReadable = () => {
|
|
159
|
-
consume();
|
|
160
|
-
finish();
|
|
161
|
-
};
|
|
162
|
-
const onEnd = () => {
|
|
163
|
-
consume();
|
|
164
|
-
finish();
|
|
165
|
-
};
|
|
166
|
-
const timer = setTimeout(finish, timeoutMs);
|
|
167
|
-
process.stdin.on("readable", onReadable);
|
|
168
|
-
process.stdin.on("end", onEnd);
|
|
169
|
-
process.stdin.resume();
|
|
170
|
-
});
|
|
171
|
-
consume();
|
|
172
|
-
return Buffer.concat(chunks).toString("utf8");
|
|
173
|
-
}
|
|
174
|
-
export async function cmdHooksInstall(opts) {
|
|
175
|
-
try {
|
|
176
|
-
const resolved = await resolveProject({
|
|
177
|
-
cwd: opts.cwd,
|
|
178
|
-
rootOverride: opts.rootOverride ?? null,
|
|
179
|
-
});
|
|
180
|
-
const hooksDir = await resolveGitHooksDir(resolved.gitRoot);
|
|
181
|
-
await mkdir(hooksDir, { recursive: true });
|
|
182
|
-
await mkdir(resolved.agentplaneDir, { recursive: true });
|
|
183
|
-
await ensureShim(resolved.agentplaneDir, resolved.gitRoot);
|
|
184
|
-
for (const hook of HOOK_NAMES) {
|
|
185
|
-
const hookPath = path.join(hooksDir, hook);
|
|
186
|
-
if (await fileExists(hookPath)) {
|
|
187
|
-
const managed = await fileIsManaged(hookPath, HOOK_MARKER);
|
|
188
|
-
if (!managed) {
|
|
189
|
-
throw new CliError({
|
|
190
|
-
exitCode: 5,
|
|
191
|
-
code: "E_GIT",
|
|
192
|
-
message: `Refusing to overwrite existing hook: ${path.relative(resolved.gitRoot, hookPath)}`,
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
await writeFile(hookPath, hookScriptText(hook), "utf8");
|
|
197
|
-
await chmod(hookPath, 0o755);
|
|
198
|
-
}
|
|
199
|
-
if (!opts.quiet) {
|
|
200
|
-
process.stdout.write(`${path.relative(resolved.gitRoot, hooksDir)}\n`);
|
|
201
|
-
}
|
|
202
|
-
return 0;
|
|
203
|
-
}
|
|
204
|
-
catch (err) {
|
|
205
|
-
if (err instanceof CliError)
|
|
206
|
-
throw err;
|
|
207
|
-
throw mapCoreError(err, { command: "hooks install", root: opts.rootOverride ?? null });
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
export async function cmdHooksUninstall(opts) {
|
|
211
|
-
try {
|
|
212
|
-
const resolved = await resolveProject({
|
|
213
|
-
cwd: opts.cwd,
|
|
214
|
-
rootOverride: opts.rootOverride ?? null,
|
|
215
|
-
});
|
|
216
|
-
const hooksDir = await resolveGitHooksDir(resolved.gitRoot);
|
|
217
|
-
let removed = 0;
|
|
218
|
-
for (const hook of HOOK_NAMES) {
|
|
219
|
-
const hookPath = path.join(hooksDir, hook);
|
|
220
|
-
if (!(await fileExists(hookPath)))
|
|
221
|
-
continue;
|
|
222
|
-
const managed = await fileIsManaged(hookPath, HOOK_MARKER);
|
|
223
|
-
if (!managed)
|
|
224
|
-
continue;
|
|
225
|
-
await rm(hookPath, { force: true });
|
|
226
|
-
removed++;
|
|
227
|
-
}
|
|
228
|
-
if (!opts.quiet) {
|
|
229
|
-
process.stdout.write(removed > 0
|
|
230
|
-
? `${successMessage("removed hooks", undefined, `count=${removed}`)}\n`
|
|
231
|
-
: `${infoMessage("no agentplane hooks found")}\n`);
|
|
232
|
-
}
|
|
233
|
-
return 0;
|
|
234
|
-
}
|
|
235
|
-
catch (err) {
|
|
236
|
-
if (err instanceof CliError)
|
|
237
|
-
throw err;
|
|
238
|
-
throw mapCoreError(err, { command: "hooks uninstall", root: opts.rootOverride ?? null });
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
export async function cmdHooksRun(opts) {
|
|
242
|
-
try {
|
|
243
|
-
if (opts.hook === "commit-msg") {
|
|
244
|
-
const messagePath = opts.args[0];
|
|
245
|
-
if (!messagePath) {
|
|
246
|
-
throw new CliError({
|
|
247
|
-
exitCode: 2,
|
|
248
|
-
code: "E_USAGE",
|
|
249
|
-
message: "Missing commit message file path",
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
const raw = await readFile(messagePath, "utf8");
|
|
253
|
-
const subject = readCommitSubject(raw);
|
|
254
|
-
const resolved = await resolveProject({
|
|
255
|
-
cwd: opts.cwd,
|
|
256
|
-
rootOverride: opts.rootOverride ?? null,
|
|
257
|
-
});
|
|
258
|
-
const loaded = await loadConfig(resolved.agentplaneDir);
|
|
259
|
-
const taskId = (process.env.AGENTPLANE_TASK_ID ?? "").trim() ||
|
|
260
|
-
(await inferTaskIdFromBranchContext({
|
|
261
|
-
gitRoot: resolved.gitRoot,
|
|
262
|
-
taskPrefix: loaded.config.branch.task_prefix,
|
|
263
|
-
}));
|
|
264
|
-
const statusTo = (process.env.AGENTPLANE_STATUS_TO ?? "").trim().toUpperCase();
|
|
265
|
-
const emoji = subject.split(/\s+/).find(Boolean) ?? "";
|
|
266
|
-
if (taskId && statusTo === "DONE" && emoji !== "✅") {
|
|
267
|
-
throw new CliError({
|
|
268
|
-
exitCode: 5,
|
|
269
|
-
code: "E_GIT",
|
|
270
|
-
message: "Finish commits must use a checkmark emoji.\n" +
|
|
271
|
-
"Expected:\n" +
|
|
272
|
-
" ✅ <TASK_SUFFIX> <scope>: <summary>",
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
const res = evaluatePolicy({
|
|
276
|
-
action: "hook_commit_msg",
|
|
277
|
-
config: loaded.config,
|
|
278
|
-
taskId,
|
|
279
|
-
git: { stagedPaths: [] },
|
|
280
|
-
commit: { subject },
|
|
281
|
-
});
|
|
282
|
-
throwIfPolicyDenied(res);
|
|
283
|
-
return 0;
|
|
284
|
-
}
|
|
285
|
-
if (opts.hook === "pre-commit") {
|
|
286
|
-
const resolved = await resolveProject({
|
|
287
|
-
cwd: opts.cwd,
|
|
288
|
-
rootOverride: opts.rootOverride ?? null,
|
|
289
|
-
});
|
|
290
|
-
const staged = await new GitContext({ gitRoot: resolved.gitRoot }).statusStagedPaths();
|
|
291
|
-
if (staged.length === 0)
|
|
292
|
-
return 0;
|
|
293
|
-
const allowTasks = (process.env.AGENTPLANE_ALLOW_TASKS ?? "").trim() === "1";
|
|
294
|
-
const allowBase = (process.env.AGENTPLANE_ALLOW_BASE ?? "").trim() === "1";
|
|
295
|
-
const allowPolicy = (process.env.AGENTPLANE_ALLOW_POLICY ?? "").trim() === "1";
|
|
296
|
-
const allowConfig = (process.env.AGENTPLANE_ALLOW_CONFIG ?? "").trim() === "1";
|
|
297
|
-
const allowHooks = (process.env.AGENTPLANE_ALLOW_HOOKS ?? "").trim() === "1";
|
|
298
|
-
const allowCI = (process.env.AGENTPLANE_ALLOW_CI ?? "").trim() === "1";
|
|
299
|
-
const loaded = await loadConfig(resolved.agentplaneDir);
|
|
300
|
-
const inBranchPr = loaded.config.workflow_mode === "branch_pr";
|
|
301
|
-
const baseBranch = inBranchPr
|
|
302
|
-
? await resolveBaseBranch({
|
|
303
|
-
cwd: opts.cwd,
|
|
304
|
-
rootOverride: opts.rootOverride ?? null,
|
|
305
|
-
cliBaseOpt: null,
|
|
306
|
-
mode: loaded.config.workflow_mode,
|
|
307
|
-
})
|
|
308
|
-
: null;
|
|
309
|
-
const currentBranch = inBranchPr ? await gitCurrentBranch(resolved.gitRoot) : undefined;
|
|
310
|
-
const res = evaluatePolicy({
|
|
311
|
-
action: "hook_pre_commit",
|
|
312
|
-
config: loaded.config,
|
|
313
|
-
taskId: (process.env.AGENTPLANE_TASK_ID ?? "").trim(),
|
|
314
|
-
git: {
|
|
315
|
-
stagedPaths: staged,
|
|
316
|
-
currentBranch,
|
|
317
|
-
baseBranch,
|
|
318
|
-
},
|
|
319
|
-
allow: {
|
|
320
|
-
allowTasks,
|
|
321
|
-
allowBase,
|
|
322
|
-
allowPolicy,
|
|
323
|
-
allowConfig,
|
|
324
|
-
allowHooks,
|
|
325
|
-
allowCI,
|
|
326
|
-
},
|
|
327
|
-
});
|
|
328
|
-
throwIfPolicyDenied(res);
|
|
329
|
-
return 0;
|
|
330
|
-
}
|
|
331
|
-
if (opts.hook === "pre-push") {
|
|
332
|
-
const resolved = await resolveProject({
|
|
333
|
-
cwd: opts.cwd,
|
|
334
|
-
rootOverride: opts.rootOverride ?? null,
|
|
335
|
-
});
|
|
336
|
-
const scriptPath = resolveBundledPrePushHookScriptPath();
|
|
337
|
-
if (!(await fileExists(scriptPath))) {
|
|
338
|
-
throw new CliError({
|
|
339
|
-
exitCode: 2,
|
|
340
|
-
code: "E_USAGE",
|
|
341
|
-
message: `Missing pre-push hook script: ${scriptPath}`,
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
const result = spawnSync("node", [scriptPath], {
|
|
345
|
-
cwd: resolved.gitRoot,
|
|
346
|
-
env: process.env,
|
|
347
|
-
encoding: "utf8",
|
|
348
|
-
input: await readHookStdinUtf8(),
|
|
349
|
-
stdio: ["pipe", "inherit", "inherit"],
|
|
350
|
-
});
|
|
351
|
-
if (result.error)
|
|
352
|
-
throw result.error;
|
|
353
|
-
return result.status ?? (result.signal ? 1 : 0);
|
|
354
|
-
}
|
|
355
|
-
if (opts.hook === "post-merge") {
|
|
356
|
-
try {
|
|
357
|
-
const ctx = await loadCommandContext({
|
|
358
|
-
cwd: opts.cwd,
|
|
359
|
-
rootOverride: opts.rootOverride ?? null,
|
|
360
|
-
});
|
|
361
|
-
if (ctx.config.workflow_mode !== "branch_pr")
|
|
362
|
-
return 0;
|
|
363
|
-
const baseBranch = await resolveBaseBranch({
|
|
364
|
-
cwd: opts.cwd,
|
|
365
|
-
rootOverride: opts.rootOverride ?? null,
|
|
366
|
-
cliBaseOpt: null,
|
|
367
|
-
mode: ctx.config.workflow_mode,
|
|
368
|
-
});
|
|
369
|
-
if (!baseBranch)
|
|
370
|
-
return 0;
|
|
371
|
-
const currentBranch = await gitCurrentBranch(ctx.resolvedProject.gitRoot);
|
|
372
|
-
if (currentBranch !== baseBranch)
|
|
373
|
-
return 0;
|
|
374
|
-
return await cmdCleanupMerged({
|
|
375
|
-
ctx,
|
|
376
|
-
cwd: opts.cwd,
|
|
377
|
-
rootOverride: opts.rootOverride,
|
|
378
|
-
base: baseBranch,
|
|
379
|
-
yes: true,
|
|
380
|
-
archive: false,
|
|
381
|
-
deleteRemoteBranches: false,
|
|
382
|
-
fetch: false,
|
|
383
|
-
quiet: true,
|
|
384
|
-
skipUnsafeWorktrees: true,
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
catch (error) {
|
|
388
|
-
const message = error instanceof Error && error.message.trim().length > 0
|
|
389
|
-
? error.message.trim()
|
|
390
|
-
: String(error);
|
|
391
|
-
process.stderr.write(`warning: post-merge cleanup skipped: ${message}\n`);
|
|
392
|
-
return 0;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
return 0;
|
|
396
|
-
}
|
|
397
|
-
catch (err) {
|
|
398
|
-
const status = err?.status;
|
|
399
|
-
const stdout = err?.stdout;
|
|
400
|
-
const stderr = err?.stderr;
|
|
401
|
-
if (typeof stdout === "string" && stdout.length > 0)
|
|
402
|
-
process.stdout.write(stdout);
|
|
403
|
-
if (typeof stderr === "string" && stderr.length > 0)
|
|
404
|
-
process.stderr.write(stderr);
|
|
405
|
-
if (typeof status === "number" && Number.isInteger(status) && status >= 0) {
|
|
406
|
-
return status;
|
|
407
|
-
}
|
|
408
|
-
if (err instanceof CliError)
|
|
409
|
-
throw err;
|
|
410
|
-
throw mapBackendError(err, {
|
|
411
|
-
command: `hooks run ${opts.hook}`,
|
|
412
|
-
root: opts.rootOverride ?? null,
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
}
|
|
1
|
+
export { HOOK_NAMES } from "./shared.js";
|
|
2
|
+
export { cmdHooksInstall, cmdHooksUninstall } from "./install.js";
|
|
3
|
+
export { cmdHooksRun } from "./run.js";
|
|
4
|
+
export { resolvePrePushHookScriptPath } from "./run.pre-push.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function cmdHooksInstall(opts: {
|
|
2
|
+
cwd: string;
|
|
3
|
+
rootOverride?: string;
|
|
4
|
+
quiet: boolean;
|
|
5
|
+
}): Promise<number>;
|
|
6
|
+
export declare function cmdHooksUninstall(opts: {
|
|
7
|
+
cwd: string;
|
|
8
|
+
rootOverride?: string;
|
|
9
|
+
quiet: boolean;
|
|
10
|
+
}): Promise<number>;
|
|
11
|
+
//# sourceMappingURL=install.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/commands/hooks/install.ts"],"names":[],"mappings":"AAkFA,wBAAsB,eAAe,CAAC,IAAI,EAAE;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmClB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CA4BlB"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { chmod, mkdir, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { resolveProject } from "@agentplaneorg/core";
|
|
4
|
+
import { mapCoreError } from "../../cli/error-map.js";
|
|
5
|
+
import { fileExists } from "../../cli/fs-utils.js";
|
|
6
|
+
import { infoMessage, successMessage } from "../../cli/output.js";
|
|
7
|
+
import { CliError } from "../../shared/errors.js";
|
|
8
|
+
import { fileIsManaged, HOOK_MARKER, HOOK_NAMES, resolveGitHooksDir, SHIM_MARKER, } from "./shared.js";
|
|
9
|
+
function hookScriptText(hook) {
|
|
10
|
+
return [
|
|
11
|
+
"#!/usr/bin/env sh",
|
|
12
|
+
`# ${HOOK_MARKER} (do not edit)`,
|
|
13
|
+
"set -e",
|
|
14
|
+
'REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"',
|
|
15
|
+
'SHIM="$REPO_ROOT/.agentplane/bin/agentplane"',
|
|
16
|
+
'if [ -x "$SHIM" ]; then',
|
|
17
|
+
' exec "$SHIM" hooks run ' + hook + ' "$@"',
|
|
18
|
+
"fi",
|
|
19
|
+
"if ! command -v agentplane >/dev/null 2>&1; then",
|
|
20
|
+
' echo "agentplane hooks: runner not found (PATH missing and shim unavailable)." >&2',
|
|
21
|
+
" exit 127",
|
|
22
|
+
"fi",
|
|
23
|
+
"exec agentplane hooks run " + hook + ' "$@"',
|
|
24
|
+
"",
|
|
25
|
+
].join("\n");
|
|
26
|
+
}
|
|
27
|
+
function shimScriptText() {
|
|
28
|
+
return [
|
|
29
|
+
"#!/usr/bin/env sh",
|
|
30
|
+
`# ${SHIM_MARKER} (do not edit)`,
|
|
31
|
+
"set -e",
|
|
32
|
+
'SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"',
|
|
33
|
+
'REPO_ROOT="$(dirname "$(dirname "$SCRIPT_DIR")")"',
|
|
34
|
+
'LOCAL_BIN="$REPO_ROOT/packages/agentplane/bin/agentplane.js"',
|
|
35
|
+
'if command -v node >/dev/null 2>&1 && [ -f "$LOCAL_BIN" ]; then',
|
|
36
|
+
' exec node "$LOCAL_BIN" "$@"',
|
|
37
|
+
"fi",
|
|
38
|
+
'ENV_BIN="${AGENTPLANE_HOOK_RUNNER:-}"',
|
|
39
|
+
'if [ -n "$ENV_BIN" ] && command -v node >/dev/null 2>&1 && [ -f "$ENV_BIN" ]; then',
|
|
40
|
+
' exec node "$ENV_BIN" "$@"',
|
|
41
|
+
"fi",
|
|
42
|
+
"if command -v agentplane >/dev/null 2>&1; then",
|
|
43
|
+
' exec agentplane "$@"',
|
|
44
|
+
"fi",
|
|
45
|
+
"if command -v npx >/dev/null 2>&1; then",
|
|
46
|
+
' exec npx --yes agentplane "$@"',
|
|
47
|
+
"fi",
|
|
48
|
+
'echo "agentplane shim: runner not found (need env runner, repo-local source, agentplane in PATH, or node+npx)." >&2',
|
|
49
|
+
" exit 127",
|
|
50
|
+
"",
|
|
51
|
+
].join("\n");
|
|
52
|
+
}
|
|
53
|
+
async function ensureShim(agentplaneDir, gitRoot) {
|
|
54
|
+
const shimDir = path.join(agentplaneDir, "bin");
|
|
55
|
+
const shimPath = path.join(shimDir, "agentplane");
|
|
56
|
+
await mkdir(shimDir, { recursive: true });
|
|
57
|
+
if (await fileExists(shimPath)) {
|
|
58
|
+
const managed = await fileIsManaged(shimPath, SHIM_MARKER);
|
|
59
|
+
if (!managed) {
|
|
60
|
+
throw new CliError({
|
|
61
|
+
exitCode: 5,
|
|
62
|
+
code: "E_GIT",
|
|
63
|
+
message: `Refusing to overwrite existing shim: ${path.relative(gitRoot, shimPath)}`,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
await writeFile(shimPath, shimScriptText(), "utf8");
|
|
68
|
+
await chmod(shimPath, 0o755);
|
|
69
|
+
}
|
|
70
|
+
export async function cmdHooksInstall(opts) {
|
|
71
|
+
try {
|
|
72
|
+
const resolved = await resolveProject({
|
|
73
|
+
cwd: opts.cwd,
|
|
74
|
+
rootOverride: opts.rootOverride ?? null,
|
|
75
|
+
});
|
|
76
|
+
const hooksDir = await resolveGitHooksDir(resolved.gitRoot);
|
|
77
|
+
await mkdir(hooksDir, { recursive: true });
|
|
78
|
+
await mkdir(resolved.agentplaneDir, { recursive: true });
|
|
79
|
+
await ensureShim(resolved.agentplaneDir, resolved.gitRoot);
|
|
80
|
+
for (const hook of HOOK_NAMES) {
|
|
81
|
+
const hookPath = path.join(hooksDir, hook);
|
|
82
|
+
if (await fileExists(hookPath)) {
|
|
83
|
+
const managed = await fileIsManaged(hookPath, HOOK_MARKER);
|
|
84
|
+
if (!managed) {
|
|
85
|
+
throw new CliError({
|
|
86
|
+
exitCode: 5,
|
|
87
|
+
code: "E_GIT",
|
|
88
|
+
message: `Refusing to overwrite existing hook: ${path.relative(resolved.gitRoot, hookPath)}`,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
await writeFile(hookPath, hookScriptText(hook), "utf8");
|
|
93
|
+
await chmod(hookPath, 0o755);
|
|
94
|
+
}
|
|
95
|
+
if (!opts.quiet) {
|
|
96
|
+
process.stdout.write(`${path.relative(resolved.gitRoot, hooksDir)}\n`);
|
|
97
|
+
}
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
if (err instanceof CliError)
|
|
102
|
+
throw err;
|
|
103
|
+
throw mapCoreError(err, { command: "hooks install", root: opts.rootOverride ?? null });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export async function cmdHooksUninstall(opts) {
|
|
107
|
+
try {
|
|
108
|
+
const resolved = await resolveProject({
|
|
109
|
+
cwd: opts.cwd,
|
|
110
|
+
rootOverride: opts.rootOverride ?? null,
|
|
111
|
+
});
|
|
112
|
+
const hooksDir = await resolveGitHooksDir(resolved.gitRoot);
|
|
113
|
+
let removed = 0;
|
|
114
|
+
for (const hook of HOOK_NAMES) {
|
|
115
|
+
const hookPath = path.join(hooksDir, hook);
|
|
116
|
+
if (!(await fileExists(hookPath)))
|
|
117
|
+
continue;
|
|
118
|
+
const managed = await fileIsManaged(hookPath, HOOK_MARKER);
|
|
119
|
+
if (!managed)
|
|
120
|
+
continue;
|
|
121
|
+
await rm(hookPath, { force: true });
|
|
122
|
+
removed++;
|
|
123
|
+
}
|
|
124
|
+
if (!opts.quiet) {
|
|
125
|
+
process.stdout.write(removed > 0
|
|
126
|
+
? `${successMessage("removed hooks", undefined, `count=${removed}`)}\n`
|
|
127
|
+
: `${infoMessage("no agentplane hooks found")}\n`);
|
|
128
|
+
}
|
|
129
|
+
return 0;
|
|
130
|
+
}
|
|
131
|
+
catch (err) {
|
|
132
|
+
if (err instanceof CliError)
|
|
133
|
+
throw err;
|
|
134
|
+
throw mapCoreError(err, { command: "hooks uninstall", root: opts.rootOverride ?? null });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.commit-msg.d.ts","sourceRoot":"","sources":["../../../src/commands/hooks/run.commit-msg.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAyBhD,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CA+C7E"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { loadConfig, resolveProject } from "@agentplaneorg/core";
|
|
3
|
+
import { evaluatePolicy } from "../../policy/evaluate.js";
|
|
4
|
+
import { CliError } from "../../shared/errors.js";
|
|
5
|
+
import { throwIfPolicyDenied } from "../shared/policy-deny.js";
|
|
6
|
+
import { gitCurrentBranch } from "../shared/git-ops.js";
|
|
7
|
+
import { parseTaskIdFromBranch, parseTaskIdFromCloseBranch } from "../shared/git-worktree.js";
|
|
8
|
+
async function inferTaskIdFromBranchContext(opts) {
|
|
9
|
+
try {
|
|
10
|
+
const branch = await gitCurrentBranch(opts.gitRoot);
|
|
11
|
+
return (parseTaskIdFromBranch(opts.taskPrefix, branch) ?? parseTaskIdFromCloseBranch(branch) ?? "");
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function readCommitSubject(message) {
|
|
18
|
+
for (const line of message.split("\n")) {
|
|
19
|
+
const trimmed = line.trim();
|
|
20
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
21
|
+
continue;
|
|
22
|
+
return trimmed;
|
|
23
|
+
}
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
26
|
+
export async function runCommitMsgHook(opts) {
|
|
27
|
+
const messagePath = opts.args[0];
|
|
28
|
+
if (!messagePath) {
|
|
29
|
+
throw new CliError({
|
|
30
|
+
exitCode: 2,
|
|
31
|
+
code: "E_USAGE",
|
|
32
|
+
message: "Missing commit message file path",
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const raw = await readFile(messagePath, "utf8");
|
|
36
|
+
const subject = readCommitSubject(raw);
|
|
37
|
+
const resolved = await resolveProject({
|
|
38
|
+
cwd: opts.cwd,
|
|
39
|
+
rootOverride: opts.rootOverride ?? null,
|
|
40
|
+
});
|
|
41
|
+
const loaded = await loadConfig(resolved.agentplaneDir);
|
|
42
|
+
const taskId = (process.env.AGENTPLANE_TASK_ID ?? "").trim() ||
|
|
43
|
+
(await inferTaskIdFromBranchContext({
|
|
44
|
+
gitRoot: resolved.gitRoot,
|
|
45
|
+
taskPrefix: loaded.config.branch.task_prefix,
|
|
46
|
+
}));
|
|
47
|
+
const statusTo = (process.env.AGENTPLANE_STATUS_TO ?? "").trim().toUpperCase();
|
|
48
|
+
const emoji = subject.split(/\s+/).find(Boolean) ?? "";
|
|
49
|
+
if (taskId && statusTo === "DONE" && emoji !== "✅") {
|
|
50
|
+
throw new CliError({
|
|
51
|
+
exitCode: 5,
|
|
52
|
+
code: "E_GIT",
|
|
53
|
+
message: "Finish commits must use a checkmark emoji.\n" +
|
|
54
|
+
"Expected:\n" +
|
|
55
|
+
" ✅ <TASK_SUFFIX> <scope>: <summary>",
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const res = evaluatePolicy({
|
|
59
|
+
action: "hook_commit_msg",
|
|
60
|
+
config: loaded.config,
|
|
61
|
+
taskId,
|
|
62
|
+
git: { stagedPaths: [] },
|
|
63
|
+
commit: { subject },
|
|
64
|
+
});
|
|
65
|
+
throwIfPolicyDenied(res);
|
|
66
|
+
return 0;
|
|
67
|
+
}
|