@apralabs/apra-fleet 0.4.2 → 0.4.3
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 +38 -5
- package/dist/agents/backlog-groomer.md +25 -0
- package/dist/agents/ci-watcher.md +11 -0
- package/dist/agents/deployer.md +37 -2
- package/dist/agents/doer.md +36 -12
- package/dist/agents/harvester.md +11 -0
- package/dist/agents/integ-test-runner.md +11 -0
- package/dist/agents/kb-reconciler.md +9 -0
- package/dist/agents/plan-reviewer.md +110 -22
- package/dist/agents/planner.md +125 -37
- package/dist/agents/regression-test-runner.md +11 -0
- package/dist/agents/reviewer.md +13 -2
- package/dist/agents/schemas/plan-reviewer-output.json +37 -0
- package/dist/cli/agent-transform.d.ts +83 -2
- package/dist/cli/agent-transform.d.ts.map +1 -1
- package/dist/cli/agent-transform.js +266 -21
- package/dist/cli/agent-transform.js.map +1 -1
- package/dist/cli/auth.d.ts.map +1 -1
- package/dist/cli/auth.js +28 -9
- package/dist/cli/auth.js.map +1 -1
- package/dist/cli/config.d.ts +7 -5
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +44 -34
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/install.d.ts +33 -0
- package/dist/cli/install.d.ts.map +1 -1
- package/dist/cli/install.js +290 -23
- package/dist/cli/install.js.map +1 -1
- package/dist/cli/kb-directives.d.ts.map +1 -1
- package/dist/cli/kb-directives.js +2 -1
- package/dist/cli/kb-directives.js.map +1 -1
- package/dist/cli/register-member.d.ts.map +1 -1
- package/dist/cli/register-member.js +6 -2
- package/dist/cli/register-member.js.map +1 -1
- package/dist/commands/kb-server.d.ts +3 -0
- package/dist/commands/kb-server.d.ts.map +1 -1
- package/dist/commands/kb-server.js +43 -3
- package/dist/commands/kb-server.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/os/linux.d.ts +6 -0
- package/dist/os/linux.d.ts.map +1 -1
- package/dist/os/linux.js +35 -2
- package/dist/os/linux.js.map +1 -1
- package/dist/os/os-commands.d.ts +61 -2
- package/dist/os/os-commands.d.ts.map +1 -1
- package/dist/os/windows-gitbash.d.ts +5 -0
- package/dist/os/windows-gitbash.d.ts.map +1 -1
- package/dist/os/windows-gitbash.js +15 -0
- package/dist/os/windows-gitbash.js.map +1 -1
- package/dist/os/windows.d.ts +6 -0
- package/dist/os/windows.d.ts.map +1 -1
- package/dist/os/windows.js +46 -3
- package/dist/os/windows.js.map +1 -1
- package/dist/providers/agy.d.ts +115 -6
- package/dist/providers/agy.d.ts.map +1 -1
- package/dist/providers/agy.js +569 -53
- package/dist/providers/agy.js.map +1 -1
- package/dist/providers/claude.d.ts +81 -3
- package/dist/providers/claude.d.ts.map +1 -1
- package/dist/providers/claude.js +344 -10
- package/dist/providers/claude.js.map +1 -1
- package/dist/providers/codex.d.ts +4 -2
- package/dist/providers/codex.d.ts.map +1 -1
- package/dist/providers/codex.js +19 -2
- package/dist/providers/codex.js.map +1 -1
- package/dist/providers/copilot.d.ts +4 -2
- package/dist/providers/copilot.d.ts.map +1 -1
- package/dist/providers/copilot.js +20 -2
- package/dist/providers/copilot.js.map +1 -1
- package/dist/providers/none.d.ts +4 -2
- package/dist/providers/none.d.ts.map +1 -1
- package/dist/providers/none.js +17 -2
- package/dist/providers/none.js.map +1 -1
- package/dist/providers/opencode.d.ts +3 -1
- package/dist/providers/opencode.d.ts.map +1 -1
- package/dist/providers/opencode.js +22 -2
- package/dist/providers/opencode.js.map +1 -1
- package/dist/providers/provider.d.ts +201 -6
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/provider.js +56 -0
- package/dist/providers/provider.js.map +1 -1
- package/dist/services/agy-project.d.ts +102 -0
- package/dist/services/agy-project.d.ts.map +1 -0
- package/dist/services/agy-project.js +356 -0
- package/dist/services/agy-project.js.map +1 -0
- package/dist/services/auth-socket.js +4 -4
- package/dist/services/auth-web.js +1 -1
- package/dist/services/cloud/lifecycle.d.ts.map +1 -1
- package/dist/services/cloud/lifecycle.js +33 -4
- package/dist/services/cloud/lifecycle.js.map +1 -1
- package/dist/services/credential-cleanup.d.ts.map +1 -1
- package/dist/services/credential-cleanup.js +35 -17
- package/dist/services/credential-cleanup.js.map +1 -1
- package/dist/services/exit-drain.d.ts +44 -0
- package/dist/services/exit-drain.d.ts.map +1 -0
- package/dist/services/exit-drain.js +52 -0
- package/dist/services/exit-drain.js.map +1 -0
- package/dist/services/github-app.d.ts.map +1 -1
- package/dist/services/github-app.js +32 -4
- package/dist/services/github-app.js.map +1 -1
- package/dist/services/http-transport.d.ts +1 -0
- package/dist/services/http-transport.d.ts.map +1 -1
- package/dist/services/http-transport.js +48 -1
- package/dist/services/http-transport.js.map +1 -1
- package/dist/services/knowledge/kb-config.d.ts +42 -0
- package/dist/services/knowledge/kb-config.d.ts.map +1 -0
- package/dist/services/knowledge/kb-config.js +54 -0
- package/dist/services/knowledge/kb-config.js.map +1 -0
- package/dist/services/knowledge/kb-providers.d.ts +7 -1
- package/dist/services/knowledge/kb-providers.d.ts.map +1 -1
- package/dist/services/knowledge/kb-providers.js +191 -17
- package/dist/services/knowledge/kb-providers.js.map +1 -1
- package/dist/services/knowledge/require-sqlite-project.d.ts +32 -0
- package/dist/services/knowledge/require-sqlite-project.d.ts.map +1 -0
- package/dist/services/knowledge/require-sqlite-project.js +38 -0
- package/dist/services/knowledge/require-sqlite-project.js.map +1 -0
- package/dist/services/model-pricing.d.ts.map +1 -1
- package/dist/services/model-pricing.js +7 -3
- package/dist/services/model-pricing.js.map +1 -1
- package/dist/services/secret-token.d.ts +38 -0
- package/dist/services/secret-token.d.ts.map +1 -0
- package/dist/services/secret-token.js +51 -0
- package/dist/services/secret-token.js.map +1 -0
- package/dist/services/service-manager/types.d.ts +3 -1
- package/dist/services/service-manager/types.d.ts.map +1 -1
- package/dist/services/service-manager/windows.d.ts +14 -2
- package/dist/services/service-manager/windows.d.ts.map +1 -1
- package/dist/services/service-manager/windows.js +65 -7
- package/dist/services/service-manager/windows.js.map +1 -1
- package/dist/services/ssh.d.ts.map +1 -1
- package/dist/services/ssh.js +58 -2
- package/dist/services/ssh.js.map +1 -1
- package/dist/services/stall/read-log-tail.d.ts.map +1 -1
- package/dist/services/stall/read-log-tail.js +20 -10
- package/dist/services/stall/read-log-tail.js.map +1 -1
- package/dist/services/stall/stall-detector.d.ts +53 -4
- package/dist/services/stall/stall-detector.d.ts.map +1 -1
- package/dist/services/stall/stall-detector.js +212 -34
- package/dist/services/stall/stall-detector.js.map +1 -1
- package/dist/services/strategy.d.ts.map +1 -1
- package/dist/services/strategy.js +79 -2
- package/dist/services/strategy.js.map +1 -1
- package/dist/services/substitution-engine.js +2 -2
- package/dist/services/substitution-engine.js.map +1 -1
- package/dist/services/tool-registry.d.ts.map +1 -1
- package/dist/services/tool-registry.js +5 -3
- package/dist/services/tool-registry.js.map +1 -1
- package/dist/services/vcs/azure-devops.d.ts +66 -1
- package/dist/services/vcs/azure-devops.d.ts.map +1 -1
- package/dist/services/vcs/azure-devops.js +192 -21
- package/dist/services/vcs/azure-devops.js.map +1 -1
- package/dist/services/vcs/types.d.ts +1 -1
- package/dist/skills/fleet-sprint-cli/SKILL.md +18 -0
- package/dist/skills/pm/SKILL.md +1 -1
- package/dist/skills/pm/cost.md +0 -3
- package/dist/skills/pm/fleet-addendum.md +2 -2
- package/dist/tools/check-status.d.ts +7 -4
- package/dist/tools/check-status.d.ts.map +1 -1
- package/dist/tools/check-status.js +2 -0
- package/dist/tools/check-status.js.map +1 -1
- package/dist/tools/compose-permissions.d.ts +6 -0
- package/dist/tools/compose-permissions.d.ts.map +1 -1
- package/dist/tools/compose-permissions.js +182 -34
- package/dist/tools/compose-permissions.js.map +1 -1
- package/dist/tools/credential-store-set.js +1 -1
- package/dist/tools/execute-command.d.ts.map +1 -1
- package/dist/tools/execute-command.js +31 -20
- package/dist/tools/execute-command.js.map +1 -1
- package/dist/tools/execute-prompt.d.ts +15 -2
- package/dist/tools/execute-prompt.d.ts.map +1 -1
- package/dist/tools/execute-prompt.js +1196 -892
- package/dist/tools/execute-prompt.js.map +1 -1
- package/dist/tools/kb-capture.d.ts +2 -2
- package/dist/tools/kb-capture.d.ts.map +1 -1
- package/dist/tools/kb-capture.js +29 -5
- package/dist/tools/kb-capture.js.map +1 -1
- package/dist/tools/kb-export.d.ts +2 -2
- package/dist/tools/kb-export.d.ts.map +1 -1
- package/dist/tools/kb-export.js +3 -28
- package/dist/tools/kb-export.js.map +1 -1
- package/dist/tools/kb-feedback.d.ts.map +1 -1
- package/dist/tools/kb-feedback.js +3 -1
- package/dist/tools/kb-feedback.js.map +1 -1
- package/dist/tools/kb-freshness-sweep.d.ts.map +1 -1
- package/dist/tools/kb-freshness-sweep.js +3 -1
- package/dist/tools/kb-freshness-sweep.js.map +1 -1
- package/dist/tools/kb-import.d.ts.map +1 -1
- package/dist/tools/kb-import.js +2 -1
- package/dist/tools/kb-import.js.map +1 -1
- package/dist/tools/kb-list.d.ts.map +1 -1
- package/dist/tools/kb-list.js +3 -1
- package/dist/tools/kb-list.js.map +1 -1
- package/dist/tools/kb-query.d.ts +2 -2
- package/dist/tools/kb-reconcile-prefilter.d.ts.map +1 -1
- package/dist/tools/kb-reconcile-prefilter.js +3 -1
- package/dist/tools/kb-reconcile-prefilter.js.map +1 -1
- package/dist/tools/kb-resolve-contradiction.d.ts.map +1 -1
- package/dist/tools/kb-resolve-contradiction.js +3 -1
- package/dist/tools/kb-resolve-contradiction.js.map +1 -1
- package/dist/tools/kb-setup.d.ts.map +1 -1
- package/dist/tools/kb-setup.js +125 -20
- package/dist/tools/kb-setup.js.map +1 -1
- package/dist/tools/kb-stats.d.ts.map +1 -1
- package/dist/tools/kb-stats.js +64 -43
- package/dist/tools/kb-stats.js.map +1 -1
- package/dist/tools/list-members.d.ts +2 -2
- package/dist/tools/list-members.d.ts.map +1 -1
- package/dist/tools/list-members.js +1 -0
- package/dist/tools/list-members.js.map +1 -1
- package/dist/tools/member-detail.d.ts +2 -2
- package/dist/tools/member-detail.d.ts.map +1 -1
- package/dist/tools/member-detail.js +17 -0
- package/dist/tools/member-detail.js.map +1 -1
- package/dist/tools/member-reservation.d.ts +58 -1
- package/dist/tools/member-reservation.d.ts.map +1 -1
- package/dist/tools/member-reservation.js +61 -20
- package/dist/tools/member-reservation.js.map +1 -1
- package/dist/tools/provision-auth.d.ts +80 -1
- package/dist/tools/provision-auth.d.ts.map +1 -1
- package/dist/tools/provision-auth.js +142 -54
- package/dist/tools/provision-auth.js.map +1 -1
- package/dist/tools/provision-vcs-auth.d.ts +91 -1
- package/dist/tools/provision-vcs-auth.d.ts.map +1 -1
- package/dist/tools/provision-vcs-auth.js +209 -49
- package/dist/tools/provision-vcs-auth.js.map +1 -1
- package/dist/tools/register-member.d.ts +12 -9
- package/dist/tools/register-member.d.ts.map +1 -1
- package/dist/tools/register-member.js +99 -12
- package/dist/tools/register-member.js.map +1 -1
- package/dist/tools/remove-member.d.ts.map +1 -1
- package/dist/tools/remove-member.js +27 -2
- package/dist/tools/remove-member.js.map +1 -1
- package/dist/tools/send-email.d.ts +2 -2
- package/dist/tools/setup-git-app.d.ts.map +1 -1
- package/dist/tools/setup-git-app.js +11 -7
- package/dist/tools/setup-git-app.js.map +1 -1
- package/dist/tools/shutdown-server.d.ts +2 -0
- package/dist/tools/shutdown-server.d.ts.map +1 -1
- package/dist/tools/shutdown-server.js +23 -1
- package/dist/tools/shutdown-server.js.map +1 -1
- package/dist/tools/update-member.d.ts +12 -9
- package/dist/tools/update-member.d.ts.map +1 -1
- package/dist/tools/update-member.js +43 -11
- package/dist/tools/update-member.js.map +1 -1
- package/dist/tools/vcs-credential-exec.d.ts +127 -0
- package/dist/tools/vcs-credential-exec.d.ts.map +1 -0
- package/dist/tools/vcs-credential-exec.js +197 -0
- package/dist/tools/vcs-credential-exec.js.map +1 -0
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/log-helpers.d.ts.map +1 -1
- package/dist/utils/log-helpers.js +2 -2
- package/dist/utils/log-helpers.js.map +1 -1
- package/dist/utils/prompt-errors.d.ts.map +1 -1
- package/dist/utils/prompt-errors.js +7 -1
- package/dist/utils/prompt-errors.js.map +1 -1
- package/dist/utils/shell-escape.d.ts +16 -0
- package/dist/utils/shell-escape.d.ts.map +1 -1
- package/dist/utils/shell-escape.js +22 -2
- package/dist/utils/shell-escape.js.map +1 -1
- package/dist/utils/vcs-provider-detect.d.ts +65 -0
- package/dist/utils/vcs-provider-detect.d.ts.map +1 -0
- package/dist/utils/vcs-provider-detect.js +109 -0
- package/dist/utils/vcs-provider-detect.js.map +1 -0
- package/dist/utils/workspace-trust.d.ts +20 -17
- package/dist/utils/workspace-trust.d.ts.map +1 -1
- package/dist/utils/workspace-trust.js +87 -1
- package/dist/utils/workspace-trust.js.map +1 -1
- package/dist/workflows/auto-sprint.js +176 -15
- package/package.json +6 -4
- package/packages/apra-fleet-client/src/client/api.mjs +319 -17
- package/packages/apra-fleet-client/src/client/errors.mjs +6 -2
- package/packages/apra-fleet-se/apra-pm/agents/_shared/GRAPH-SEMANTICS.md +10 -2
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +25 -0
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +11 -0
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +37 -2
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +36 -12
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +11 -0
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +11 -0
- package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +9 -0
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +110 -22
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +125 -37
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +11 -0
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +13 -2
- package/packages/apra-fleet-se/apra-pm/agents/schemas/plan-reviewer-output.json +37 -0
- package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +1 -1
- package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +0 -3
- package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +2 -2
- package/packages/apra-fleet-se/bin/cli.mjs +149 -1
- package/packages/apra-fleet-se/bin/serve.mjs +78 -4
- package/packages/apra-fleet-se/fleet-sprint/abort.mjs +481 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +491 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-identity-check.mjs +282 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-identity.mjs +208 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +638 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-transitions.mjs +301 -0
- package/packages/apra-fleet-se/fleet-sprint/branch-ensure.mjs +96 -0
- package/packages/apra-fleet-se/fleet-sprint/conflict-ladder.mjs +8 -0
- package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +61 -14
- package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +516 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-failure.mjs +184 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +1121 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-safety-guard.mjs +216 -4
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +1 -1
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +276 -0
- package/packages/apra-fleet-se/fleet-sprint/docs/escalate-to-llm-design.md +1 -1
- package/packages/apra-fleet-se/fleet-sprint/docs/run-sprint-cycle-prelude-decision.md +215 -0
- package/packages/apra-fleet-se/fleet-sprint/dolt-literal-guard.mjs +56 -1
- package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +996 -32
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +267 -0
- package/packages/apra-fleet-se/fleet-sprint/explicit-id-create-guard.mjs +501 -0
- package/packages/apra-fleet-se/fleet-sprint/fatal-diagnostics.mjs +134 -0
- package/packages/apra-fleet-se/fleet-sprint/full-db-fetch-guard.mjs +102 -0
- package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +556 -0
- package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +495 -0
- package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +564 -0
- package/packages/apra-fleet-se/fleet-sprint/inline-ladder-guard.mjs +216 -0
- package/packages/apra-fleet-se/fleet-sprint/kb.mjs +728 -0
- package/packages/apra-fleet-se/fleet-sprint/mcp-result.mjs +75 -0
- package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +252 -0
- package/packages/apra-fleet-se/fleet-sprint/member-sync.mjs +581 -0
- package/packages/apra-fleet-se/fleet-sprint/member-target.mjs +93 -0
- package/packages/apra-fleet-se/fleet-sprint/newtask-text.mjs +266 -0
- package/packages/apra-fleet-se/fleet-sprint/parent-notes-staleness.mjs +201 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +136 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +822 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/ensure-sprint-branch.mjs +294 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +403 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +180 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/integ-test.mjs +358 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +390 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +323 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +232 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/regression-test.mjs +174 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/replan.mjs +197 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +305 -0
- package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +559 -0
- package/packages/apra-fleet-se/fleet-sprint/role-policies.mjs +1416 -0
- package/packages/apra-fleet-se/fleet-sprint/round-session.mjs +100 -0
- package/packages/apra-fleet-se/fleet-sprint/runner.js +1467 -9798
- package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +17 -12
- package/packages/apra-fleet-se/fleet-sprint/shell-command-guard.mjs +304 -0
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +18 -0
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +21 -2
- package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +454 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +239 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +163 -0
- package/packages/apra-fleet-se/fleet-sprint/unbracketed-push-guard.mjs +234 -0
- package/packages/apra-fleet-se/fleet-sprint/usage-limit-controller.mjs +211 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +1279 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +153 -19
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +71 -21
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +28 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +131 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +140 -16
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +1 -0
- package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +77 -2
- package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +559 -0
- package/packages/apra-fleet-se/package.json +1 -1
- package/packages/apra-fleet-workflow/src/viewer/index.mjs +17 -6
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +49 -7
- package/skills/fleet/SKILL.md +8 -8
- package/skills/fleet/auth-azdevops.md +14 -3
- package/skills/fleet/auth-bitbucket.md +2 -2
- package/skills/fleet/auth-github.md +5 -4
- package/skills/fleet/onboarding.md +3 -3
- package/skills/fleet/permissions.md +5 -1
- package/skills/fleet/profiles/node.json +1 -1
- package/skills/fleet/troubleshooting.md +3 -3
- package/version.json +1 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// Unified member OS/shell registry (apra-fleet-3swo.2.5).
|
|
3
|
+
//
|
|
4
|
+
// Extracted move-only from fleet-sprint/runner.js, which owned
|
|
5
|
+
// `resolveMemberTarget`, its per-member cache and the `resolveMemberOs`
|
|
6
|
+
// back-compat wrapper as private/local state. This module is now the single
|
|
7
|
+
// owner; runner.js imports and re-exports all three so its existing facade
|
|
8
|
+
// (dolt-settle.mjs's doc comments, vcs-providers/azure-devops.mjs's doc
|
|
9
|
+
// comments, vcs-providers/shell-helpers.mjs's doc comments, and the two test
|
|
10
|
+
// files that import resolveMemberOs/clearMemberOsCache by name from
|
|
11
|
+
// runner.js) stays intact.
|
|
12
|
+
//
|
|
13
|
+
// CONTRACT (do not change without checking every reference above): the
|
|
14
|
+
// resolved shape is { os, shell }, where os is a lowercase string like
|
|
15
|
+
// 'windows' | 'linux' | 'darwin' and shell is one of '' | 'gitbash' |
|
|
16
|
+
// 'pwsh7' | 'powershell5'.
|
|
17
|
+
// =============================================================================
|
|
18
|
+
|
|
19
|
+
// memberName -> resolved { os, shell } ('windows' | 'linux' | 'darwin' | ...
|
|
20
|
+
// and '' | 'gitbash' | ... respectively), cached for the lifetime of the
|
|
21
|
+
// runner process: a member's OS/shell never changes mid-sprint, and
|
|
22
|
+
// member_detail performs a live connectivity check, so this must not be
|
|
23
|
+
// re-dispatched per credential read (raiseVcsPrForMember can call it twice
|
|
24
|
+
// on the auth-retry path alone).
|
|
25
|
+
const memberOsCache = new Map();
|
|
26
|
+
|
|
27
|
+
// Test seam: the OS cache is process-lifetime state, so a test exercising two
|
|
28
|
+
// different member OSes for the same member name must be able to clear it.
|
|
29
|
+
export function clearMemberOsCache() {
|
|
30
|
+
memberOsCache.clear();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Resolves `member`'s { os, shell } from the fleet member registry via
|
|
34
|
+
// fleetApi.memberDetail() ('member_detail' is the only MCP surface exposing
|
|
35
|
+
// Agent.os/Agent's registered shell -- src/tools/member-detail.ts; it does
|
|
36
|
+
// NOT expose a homeDir). Mirrors VCSModule.resolveProvider()'s member_detail
|
|
37
|
+
// JSON-parsing shape.
|
|
38
|
+
//
|
|
39
|
+
// Unlike resolveProvider, an unresolvable OS is NOT a hard error here: the
|
|
40
|
+
// ONLY behavioral difference it drives is which shell string the credential
|
|
41
|
+
// read is built as, and the historical (POSIX) string must stay byte-identical
|
|
42
|
+
// for every non-Windows member and for any caller that has no memberDetail
|
|
43
|
+
// wired. So a missing/unparseable/absent-`os` response degrades to 'linux'
|
|
44
|
+
// (the pre-existing behavior) and is logged, never thrown. A windows member
|
|
45
|
+
// whose record carries no `shell` (or an unrecognized one) resolves to '' --
|
|
46
|
+
// getSeCommands() treats that as the PowerShell implementation, matching what
|
|
47
|
+
// every Windows member was assumed to be before shells were recorded.
|
|
48
|
+
// @param {{ fleetApi?: object, member: string, log?: Function }} opts
|
|
49
|
+
// @returns {Promise<{ os: string, shell: string }>}
|
|
50
|
+
export async function resolveMemberTarget({ fleetApi, member, log = () => {} }) {
|
|
51
|
+
if (memberOsCache.has(member)) return memberOsCache.get(member);
|
|
52
|
+
try {
|
|
53
|
+
if (!fleetApi || typeof fleetApi.memberDetail !== 'function') {
|
|
54
|
+
throw new Error('no fleetApi.memberDetail() injected');
|
|
55
|
+
}
|
|
56
|
+
const res = await fleetApi.memberDetail({ member_name: member, format: 'json' });
|
|
57
|
+
const text = typeof res === 'string'
|
|
58
|
+
? res
|
|
59
|
+
: (res && Array.isArray(res.content) && res.content[0] && typeof res.content[0].text === 'string')
|
|
60
|
+
? res.content[0].text
|
|
61
|
+
: '';
|
|
62
|
+
const parsed = JSON.parse(text);
|
|
63
|
+
if (parsed && typeof parsed.os === 'string' && parsed.os.trim()) {
|
|
64
|
+
const os = parsed.os.trim().toLowerCase();
|
|
65
|
+
const shell = (parsed && typeof parsed.shell === 'string') ? parsed.shell.trim().toLowerCase() : '';
|
|
66
|
+
const target = { os, shell };
|
|
67
|
+
// Only a genuine member_detail-derived OS/shell is cached. Caching
|
|
68
|
+
// the 'linux' fallback below would permanently pin a member that
|
|
69
|
+
// hit a transient failure (asleep, flaky SSH, MCP hiccup) to
|
|
70
|
+
// POSIX command construction for the rest of the runner process
|
|
71
|
+
// -- including the auth-retry credential read at
|
|
72
|
+
// raiseVcsPrForMember, whose entire purpose is to recover from
|
|
73
|
+
// exactly this kind of transient failure. See apra-fleet-ot2z.13.
|
|
74
|
+
memberOsCache.set(member, target);
|
|
75
|
+
return target;
|
|
76
|
+
}
|
|
77
|
+
throw new Error('member_detail response carried no "os" field');
|
|
78
|
+
} catch (err) {
|
|
79
|
+
log(`Could not resolve OS for member '${member}' from member_detail (${err && err.message ? err.message : err}); assuming POSIX ('linux') for member-bound command construction.`);
|
|
80
|
+
return { os: 'linux', shell: '' };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Back-compat wrapper: existing callers (and tests) that only need the OS
|
|
85
|
+
// string keep working unchanged. Resolves and caches both os and shell (see
|
|
86
|
+
// resolveMemberTarget above); callers that also need the shell (e.g. the VCS
|
|
87
|
+
// credential-read path) should call resolveMemberTarget directly.
|
|
88
|
+
// @param {{ fleetApi?: object, member: string, log?: Function }} opts
|
|
89
|
+
// @returns {Promise<string>}
|
|
90
|
+
export async function resolveMemberOs(opts) {
|
|
91
|
+
const { os } = await resolveMemberTarget(opts);
|
|
92
|
+
return os;
|
|
93
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
// Verdict/newTask text surface for fleet-sprint (apra-fleet-3swo.6.14).
|
|
2
|
+
// Extracted out of runner.js; runner.js re-exports every symbol it previously
|
|
3
|
+
// exported from this region, so existing importers of fleet-sprint/runner.js
|
|
4
|
+
// resolve unchanged.
|
|
5
|
+
//
|
|
6
|
+
// This module owns:
|
|
7
|
+
// - extractContestedBeadIds: reads the beads a plan-reviewer verdict calls
|
|
8
|
+
// out from its structured `findings` array, so a CHANGES_NEEDED verdict
|
|
9
|
+
// confined to specific beads can be told apart from a plan-wide one. Falls
|
|
10
|
+
// back to the deprecated free-text `notes` scan only for a verdict that
|
|
11
|
+
// carries no `findings` key at all.
|
|
12
|
+
// - SAFE_TEXT_RE: the newTask-title shell-injection allowlist (still
|
|
13
|
+
// exported, unchanged shape -- see its own header comment below for why).
|
|
14
|
+
// - normalizeTierToken: bead-metadata model-value tier normalization by
|
|
15
|
+
// containment ('cheap'/'standard'/'premium').
|
|
16
|
+
// - trackRejectedNewTaskForResurfacing / clearResubmittedNewTask /
|
|
17
|
+
// reconcilePendingRejectedNewTasks / buildRejectedNewTaskResurfaceLines:
|
|
18
|
+
// the pending-rejected-newTask resurfacing pipeline that feeds the
|
|
19
|
+
// planner prompt (see prompts.mjs's buildPlannerPrompt, which imports
|
|
20
|
+
// buildRejectedNewTaskResurfaceLines back from runner.js's facade).
|
|
21
|
+
//
|
|
22
|
+
// CROSS-FEATURE HANDOFF, now PARTLY LANDED: the Phase 5 bead that replaces
|
|
23
|
+
// plan-reviewer prose scraping with a structured findings field has run --
|
|
24
|
+
// extractContestedBeadIds reads `findings` first and keeps the notes scan only
|
|
25
|
+
// as a deprecated, absent-`findings` fallback (see its own comment for the
|
|
26
|
+
// removal release). What remains outstanding is the LATER Phase 5 bead that
|
|
27
|
+
// deletes the retired prose-scraper fallback outright and updates the facade
|
|
28
|
+
// symbol pins; until it runs, the fallback and the facade enumeration entry
|
|
29
|
+
// both stay exactly where they are.
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Determines whether a plan-reviewer verdict is CONFINED to specific beads
|
|
33
|
+
* rather than spanning the whole plan.
|
|
34
|
+
*
|
|
35
|
+
* PRIMARY CHANNEL (structured): the plan-reviewer contract carries an optional
|
|
36
|
+
* per-bead `findings` array of `{ id, kind, detail }`. When it is PRESENT the
|
|
37
|
+
* contested set is read from it directly -- no text scanning at all. Per the
|
|
38
|
+
* contract, an EMPTY findings array is the explicit "the objection is
|
|
39
|
+
* plan-wide and names no individual bead" signal, so an empty array yields an
|
|
40
|
+
* empty contested set, which the caller already treats as whole-plan
|
|
41
|
+
* contested. `findings` ids are still intersected with `taskAssignments`, so
|
|
42
|
+
* this function keeps returning a SUBSET of the in-scope task ids in
|
|
43
|
+
* taskAssignments order -- exactly what the notes scan returned.
|
|
44
|
+
*
|
|
45
|
+
* FALLBACK CHANNEL (deprecated prose scan): a verdict produced against the
|
|
46
|
+
* previous contract has NO `findings` key at all. For that case only, `notes`
|
|
47
|
+
* is scanned for literal occurrences of each id already known to be in scope
|
|
48
|
+
* via `taskAssignments`. Absence of the key -- not its emptiness -- is what
|
|
49
|
+
* selects the fallback, which is why the two cases cannot be conflated.
|
|
50
|
+
*
|
|
51
|
+
* @param {{ notes?: string, findings?: Array<{ id?: string }>, taskAssignments?: Array<{ id?: string }> }} verdict
|
|
52
|
+
* @returns {string[]} the subset of taskAssignments ids the verdict calls out
|
|
53
|
+
*/
|
|
54
|
+
export function extractContestedBeadIds(verdict) {
|
|
55
|
+
if (!verdict || !Array.isArray(verdict.taskAssignments)) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
const allIds = verdict.taskAssignments
|
|
59
|
+
.map((a) => a && a.id)
|
|
60
|
+
.filter((id) => typeof id === 'string' && id.length > 0);
|
|
61
|
+
|
|
62
|
+
if (Array.isArray(verdict.findings)) {
|
|
63
|
+
const namedIds = new Set(
|
|
64
|
+
verdict.findings
|
|
65
|
+
.map((f) => f && f.id)
|
|
66
|
+
.filter((id) => typeof id === 'string' && id.length > 0)
|
|
67
|
+
);
|
|
68
|
+
return allIds.filter((id) => namedIds.has(id));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return contestedBeadIdsFromNotesProse(verdict.notes, allIds);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// DEPRECATED prose-scraping fallback for extractContestedBeadIds.
|
|
75
|
+
//
|
|
76
|
+
// This is the pre-`findings` channel: before the plan-reviewer contract grew a
|
|
77
|
+
// structured per-bead findings array, `notes` was free text that named the
|
|
78
|
+
// offending bead ids, so the only way to tell a confined CHANGES_NEEDED from a
|
|
79
|
+
// plan-wide one was to scan that text. It survives for exactly one release so
|
|
80
|
+
// a verdict produced against the previous contract still routes correctly.
|
|
81
|
+
//
|
|
82
|
+
// An id matches only at a non-identifier-character boundary (or the string
|
|
83
|
+
// start/end), so a shorter id cannot false-positive inside a longer one that
|
|
84
|
+
// merely extends it. That boundary rule is preserved verbatim -- a verdict
|
|
85
|
+
// routed through this fallback must produce the same contested set it did
|
|
86
|
+
// before the structured field existed.
|
|
87
|
+
//
|
|
88
|
+
// Do not add a new caller: read `verdict.findings`.
|
|
89
|
+
//
|
|
90
|
+
// @deprecated since the structured plan-reviewer findings field; removal
|
|
91
|
+
// release: v0.5.0
|
|
92
|
+
/**
|
|
93
|
+
* @param {unknown} notes the verdict's free-text notes field
|
|
94
|
+
* @param {string[]} allIds the in-scope task ids, in taskAssignments order
|
|
95
|
+
* @returns {string[]} the subset of allIds that notes calls out by name
|
|
96
|
+
*/
|
|
97
|
+
function contestedBeadIdsFromNotesProse(notes, allIds) {
|
|
98
|
+
if (typeof notes !== 'string') {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
return allIds.filter((id) => {
|
|
102
|
+
const escaped = id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
103
|
+
const boundary = '(?:^|[^A-Za-z0-9_-])';
|
|
104
|
+
const endBoundary = '(?:$|[^A-Za-z0-9_-])';
|
|
105
|
+
const re = new RegExp(`${boundary}${escaped}${endBoundary}`);
|
|
106
|
+
return re.test(notes);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ---------------------------------------------------------------------------
|
|
111
|
+
// newTasks validation. Reviewer-authored newTasks are LLM output, and the
|
|
112
|
+
// reviewer's context includes the diff under review, so an adversarial
|
|
113
|
+
// diff/commit could try to steer it into emitting text crafted to break out of
|
|
114
|
+
// a shell command.
|
|
115
|
+
//
|
|
116
|
+
// SAFE_TEXT_RE (title only) deliberately excludes: backtick, `$`,
|
|
117
|
+
// double-quote (the command's own quoting delimiter -- allowing it back in
|
|
118
|
+
// would let a title close the quote early regardless of any other
|
|
119
|
+
// restriction), and backslash (blocks a trailing-backslash "escape the
|
|
120
|
+
// closing quote" trick as well as any other backslash-based escape
|
|
121
|
+
// sequence). The allowed punctuation (`.,:;!?()'-_/+[]` plus space) covers
|
|
122
|
+
// realistic task titles while remaining inert as shell syntax in both POSIX
|
|
123
|
+
// and Windows member shells.
|
|
124
|
+
//
|
|
125
|
+
// apra-fleet-v75: `[`, `]` and `+` are allowed. The title is interpolated as
|
|
126
|
+
// `bd create "${title}"` -- inside double quotes, brackets never glob and `+`
|
|
127
|
+
// has no meaning, in POSIX shells or PowerShell. Excluding them rejected this
|
|
128
|
+
// project's own bead-title convention ([bug]/[epic]/[test] prefixes), which
|
|
129
|
+
// `bd create` itself accepts; a real reviewer follow-up was dropped mid-sprint
|
|
130
|
+
// on exactly that. The characters that ARE live inside double quotes --
|
|
131
|
+
// `"`, `\`, backtick, `$` -- remain excluded, which is what this guard is for.
|
|
132
|
+
//
|
|
133
|
+
// `description` no longer reaches this shell-interpolation risk at all
|
|
134
|
+
// (apra-fleet-eft.56.1, transport hardened in eft.73.1):
|
|
135
|
+
// createChildBeadWithAllocatedId() stages it to a member-local temp file
|
|
136
|
+
// (base64-carried, member-side) and hands that path to `bd create
|
|
137
|
+
// --body-file`, never interpolating it into a command string. That removed
|
|
138
|
+
// the injection
|
|
139
|
+
// surface SAFE_TEXT_RE existed to close for descriptions, so
|
|
140
|
+
// SAFE_DESCRIPTION_RE only enforces the repo's own ASCII-only convention
|
|
141
|
+
// (plus non-empty) -- legitimate technical characters ('=', '&', '+', '"',
|
|
142
|
+
// backticks-as-text, '%', '#', '[', ']', etc.) are allowed again.
|
|
143
|
+
export const SAFE_TEXT_RE = /^[A-Za-z0-9 .,:;!?()'_/+[\]-]+$/;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Normalizes a bead-metadata model value by CONTAINMENT: a value that
|
|
147
|
+
* (case-insensitively) contains exactly ONE of the three tier names --
|
|
148
|
+
* 'cheap', 'standard', 'premium' -- becomes that bare tier name, so
|
|
149
|
+
* 'standard-tier', 'tier-standard' and 'Standard (default)' all resolve to
|
|
150
|
+
* 'standard'. A value containing zero tier names (an explicit provider model
|
|
151
|
+
* id) or more than one (ambiguous) passes through unchanged. This is the
|
|
152
|
+
* single read site for that metadata: an un-normalized alias would reach the
|
|
153
|
+
* dispatch as a literal provider model name and fail it outright.
|
|
154
|
+
* @param {unknown} raw
|
|
155
|
+
* @returns {unknown}
|
|
156
|
+
*/
|
|
157
|
+
export function normalizeTierToken(raw) {
|
|
158
|
+
if (typeof raw !== 'string') return raw;
|
|
159
|
+
const lowered = raw.toLowerCase();
|
|
160
|
+
const matches = ['cheap', 'standard', 'premium'].filter((tier) => lowered.includes(tier));
|
|
161
|
+
return matches.length === 1 ? matches[0] : raw;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// ---------------------------------------------------------------------------
|
|
165
|
+
// Resurfacing rejected newTasks into the next planning dispatch
|
|
166
|
+
// ---------------------------------------------------------------------------
|
|
167
|
+
//
|
|
168
|
+
// A note appended by appendRejectedFindingToParentNotes() is readable by a
|
|
169
|
+
// human but invisible to the planner, which is dispatched without resume and
|
|
170
|
+
// never reads bead notes. These helpers instead track the current set of
|
|
171
|
+
// not-yet-resubmitted rejected newTasks in run state so the planner prompt can
|
|
172
|
+
// carry them as explicit "previously rejected, fix and resubmit" items, and
|
|
173
|
+
// drop each one once resubmitted so the list cannot grow without bound. All
|
|
174
|
+
// are pure: the caller owns the array and none of these mutate it in place.
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Records a newly-rejected newTask into the pending resurface list, keyed by
|
|
178
|
+
* title -- a newTask rejected twice under the same title keeps only the
|
|
179
|
+
* LATEST rejection reason/cycle (dedup by title), so a repeatedly-resubmitted-
|
|
180
|
+
* and-repeatedly-rejected item cannot grow the list unboundedly.
|
|
181
|
+
* @param {Array<{title: string, description: string, reason: string, cycle: number|string}>} pending
|
|
182
|
+
* @param {{title: unknown, description: unknown, reason: string, cycle: number|string}} rejected
|
|
183
|
+
* @returns {Array<{title: string, description: string, reason: string, cycle: number|string}>} a NEW array
|
|
184
|
+
*/
|
|
185
|
+
export function trackRejectedNewTaskForResurfacing(pending, rejected) {
|
|
186
|
+
const title = String((rejected && rejected.title) || '(untitled)');
|
|
187
|
+
const description = String((rejected && rejected.description) || '');
|
|
188
|
+
const entry = { title, description, reason: String(rejected && rejected.reason), cycle: rejected && rejected.cycle };
|
|
189
|
+
const withoutDup = (Array.isArray(pending) ? pending : []).filter((p) => p.title !== title);
|
|
190
|
+
return [...withoutDup, entry];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Drops any pending rejected-newTask entries matching a newTask that has now
|
|
195
|
+
* been successfully created.
|
|
196
|
+
*
|
|
197
|
+
* `resubmitted` may be a bare title string (title-only match) or a
|
|
198
|
+
* `{title, description}` object, in which case a match on EITHER the title OR
|
|
199
|
+
* a non-empty description clears the entry. Description matching is what
|
|
200
|
+
* clears a resubmission whose title was corrected in response to the
|
|
201
|
+
* rejection reason -- title-only matching would leave such an item pending
|
|
202
|
+
* forever.
|
|
203
|
+
* @param {Array<{title: string, description?: string}>} pending
|
|
204
|
+
* @param {string|{title?: string, description?: string}} resubmitted
|
|
205
|
+
* @returns {Array<{title: string}>} a NEW array
|
|
206
|
+
*/
|
|
207
|
+
export function clearResubmittedNewTask(pending, resubmitted) {
|
|
208
|
+
const list = Array.isArray(pending) ? pending : [];
|
|
209
|
+
const title = typeof resubmitted === 'string' ? resubmitted : String((resubmitted && resubmitted.title) || '');
|
|
210
|
+
const description = (resubmitted && typeof resubmitted === 'object' && resubmitted.description)
|
|
211
|
+
? String(resubmitted.description) : '';
|
|
212
|
+
return list.filter((p) => {
|
|
213
|
+
const titleMatches = p.title === title;
|
|
214
|
+
const descriptionMatches = description.length > 0 && String((p && p.description) || '') === description;
|
|
215
|
+
return !(titleMatches || descriptionMatches);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Reconciles the pending resurface list against the parent bead's CURRENT
|
|
221
|
+
* children, matching purely on description and ignoring titles. The planner
|
|
222
|
+
* resubmits a corrected finding directly via `bd create` and never calls
|
|
223
|
+
* clearResubmittedNewTask(), so without this pass a planner resubmission would
|
|
224
|
+
* stay pending and reappear in every later planning prompt of the run. Call it
|
|
225
|
+
* after any phase that may have created children under the parent (chiefly the
|
|
226
|
+
* Plan phase), passing the live child list.
|
|
227
|
+
* @param {Array<{title: string, description?: string}>} pending
|
|
228
|
+
* @param {Array<{description?: string}>} currentChildren
|
|
229
|
+
* @returns {Array<{title: string, description?: string}>} a NEW array
|
|
230
|
+
*/
|
|
231
|
+
export function reconcilePendingRejectedNewTasks(pending, currentChildren) {
|
|
232
|
+
const list = Array.isArray(pending) ? pending : [];
|
|
233
|
+
if (list.length === 0) return list;
|
|
234
|
+
const children = Array.isArray(currentChildren) ? currentChildren : [];
|
|
235
|
+
const childDescriptions = new Set(
|
|
236
|
+
children
|
|
237
|
+
.map((c) => String((c && c.description) || '').trim())
|
|
238
|
+
.filter((d) => d.length > 0)
|
|
239
|
+
);
|
|
240
|
+
if (childDescriptions.size === 0) return list;
|
|
241
|
+
return list.filter((p) => {
|
|
242
|
+
const description = String((p && p.description) || '').trim();
|
|
243
|
+
return description.length === 0 || !childDescriptions.has(description);
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Formats the pending rejected-newTask items as explicit "previously rejected,
|
|
249
|
+
* fix and resubmit" prompt lines for the planner prompt. Returns `[]` when
|
|
250
|
+
* nothing is pending, so the prompt is unchanged in that case.
|
|
251
|
+
* @param {Array<{title: string, description: string, reason: string, cycle: number|string}>} pending
|
|
252
|
+
* @returns {string[]}
|
|
253
|
+
*/
|
|
254
|
+
export function buildRejectedNewTaskResurfaceLines(pending) {
|
|
255
|
+
if (!Array.isArray(pending) || pending.length === 0) return [];
|
|
256
|
+
const lines = [
|
|
257
|
+
`${pending.length} previously REJECTED newTask(s) from an earlier round must be fixed and ` +
|
|
258
|
+
're-submitted this planning pass. Verbatim title/description below, plus why each was ' +
|
|
259
|
+
'rejected -- correct the stated defect (do not just resend the item unchanged), then create ' +
|
|
260
|
+
'it via bd create as normal:',
|
|
261
|
+
];
|
|
262
|
+
pending.forEach((r, i) => {
|
|
263
|
+
lines.push(`${i + 1}. Title: "${r.title}"\nDescription: ${r.description}\nRejected because: ${r.reason} (cycle ${r.cycle})`);
|
|
264
|
+
});
|
|
265
|
+
return lines;
|
|
266
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// PARENT-NOTES STALENESS SIGNAL (apra-fleet-fsxg).
|
|
3
|
+
//
|
|
4
|
+
// A structural, tooling-computed advisory that does NOT depend on the model
|
|
5
|
+
// remembering to look: when a bead in the dispatch scope had its NOTES updated
|
|
6
|
+
// AFTER its most recently created child, its existing decomposition may predate
|
|
7
|
+
// the latest NOTES corrections. The planner/plan-reviewer role prompts already
|
|
8
|
+
// TELL the agent to read a bead's NOTES before decomposing/reviewing (see the
|
|
9
|
+
// companion role-prompt fixes), but a prompt instruction is the weakest layer:
|
|
10
|
+
// it fires only if the model chooses to perform the check, which is exactly the
|
|
11
|
+
// failure mode that motivated this -- an original decomposition simply never
|
|
12
|
+
// looked at NOTES. This module turns "remember to check for a stale
|
|
13
|
+
// decomposition" into "here is a specific bead the tooling already flagged --
|
|
14
|
+
// go look", closer to a linter finding than a style-guide reminder.
|
|
15
|
+
//
|
|
16
|
+
// STRICTLY ADVISORY: nothing here ever blocks a dispatch or fails a plan. A
|
|
17
|
+
// fired signal only ADDS a note to the planner/plan-reviewer dispatch context;
|
|
18
|
+
// an absent or errored signal changes nothing. A false negative (the bd calls
|
|
19
|
+
// fail, or beads exposes no notes-change timestamp) simply falls back to the
|
|
20
|
+
// pre-existing prompt-only behaviour.
|
|
21
|
+
//
|
|
22
|
+
// GENERIC: every string this module emits is product-generic. It names no
|
|
23
|
+
// target repo, build command, env var, or bead id -- the only ids that appear
|
|
24
|
+
// in its output are interpolated at RUNTIME from the live sprint scope (exactly
|
|
25
|
+
// as buildPlannerPrompt already interpolates targetIssues), never written as
|
|
26
|
+
// literals. Registered in guarded-modules.mjs; its two command() call sites
|
|
27
|
+
// each name member_name explicitly.
|
|
28
|
+
//
|
|
29
|
+
// WHY `bd history` AND NOT `updated_at`. beads stores `notes` as a single text
|
|
30
|
+
// field with no notes-specific timestamp; the bead-level `updated_at` moves on
|
|
31
|
+
// ANY mutation (status, priority, claim, close), so using it as a proxy for
|
|
32
|
+
// "notes last changed" would false-positive constantly and violate this
|
|
33
|
+
// feature's "no false positives on the common case" requirement. `bd history
|
|
34
|
+
// <id> --json` returns a per-commit snapshot of the whole issue (including its
|
|
35
|
+
// notes text), so walking it oldest-first isolates the exact commit at which
|
|
36
|
+
// the notes text last actually changed.
|
|
37
|
+
// =============================================================================
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Derives the timestamp at which a bead's NOTES text last actually changed,
|
|
41
|
+
* from `bd history <id> --json` output. The history is an array of per-commit
|
|
42
|
+
* snapshots, NEWEST first, each shaped `{ CommitDate, Issue: { notes } }`.
|
|
43
|
+
*
|
|
44
|
+
* Walks the snapshots oldest-first, tracking the commit at which the notes
|
|
45
|
+
* text last transitioned to a new value. Returns that commit's date string, or
|
|
46
|
+
* `null` when the bead never carried notes, when the notes text never changed
|
|
47
|
+
* from empty, or when the CURRENT (newest) notes are empty -- an empty final
|
|
48
|
+
* notes field describes no correction, so it is never a staleness signal.
|
|
49
|
+
*
|
|
50
|
+
* @param {Array<{ CommitDate?: string, Issue?: { notes?: unknown } }>} history
|
|
51
|
+
* @returns {string|null} the ISO-ish date string of the last notes change, or null
|
|
52
|
+
*/
|
|
53
|
+
export function notesLastUpdatedAtFromHistory(history) {
|
|
54
|
+
if (!Array.isArray(history) || history.length === 0) return null;
|
|
55
|
+
// History arrives newest-first; walk it oldest-first so a change is
|
|
56
|
+
// recorded at the commit that INTRODUCED it, not the latest commit that
|
|
57
|
+
// merely carried it forward unchanged.
|
|
58
|
+
const oldestFirst = [...history].reverse();
|
|
59
|
+
let prevNotes = '';
|
|
60
|
+
let lastChangeDate = null;
|
|
61
|
+
for (const entry of oldestFirst) {
|
|
62
|
+
const rawNotes = entry && entry.Issue && typeof entry.Issue.notes === 'string'
|
|
63
|
+
? entry.Issue.notes
|
|
64
|
+
: '';
|
|
65
|
+
const notes = rawNotes.trim();
|
|
66
|
+
if (notes !== prevNotes) {
|
|
67
|
+
lastChangeDate = entry && typeof entry.CommitDate === 'string' ? entry.CommitDate : lastChangeDate;
|
|
68
|
+
prevNotes = notes;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Final notes empty (never set, or explicitly cleared): no correction to be
|
|
72
|
+
// stale against.
|
|
73
|
+
if (prevNotes.length === 0) return null;
|
|
74
|
+
return lastChangeDate;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Picks the child with the most recent valid `created_at`, or null if none of
|
|
79
|
+
* the children carry a parseable creation timestamp.
|
|
80
|
+
* @param {Array<{ id?: string, created_at?: string }>} children
|
|
81
|
+
* @returns {{ id?: string, created_at: string }|null}
|
|
82
|
+
*/
|
|
83
|
+
function mostRecentlyCreatedChild(children) {
|
|
84
|
+
if (!Array.isArray(children)) return null;
|
|
85
|
+
let best = null;
|
|
86
|
+
let bestTime = -Infinity;
|
|
87
|
+
for (const child of children) {
|
|
88
|
+
const createdAt = child && typeof child.created_at === 'string' ? child.created_at : null;
|
|
89
|
+
if (!createdAt) continue;
|
|
90
|
+
const time = Date.parse(createdAt);
|
|
91
|
+
if (Number.isNaN(time)) continue;
|
|
92
|
+
if (time > bestTime) {
|
|
93
|
+
bestTime = time;
|
|
94
|
+
best = { id: child && child.id, created_at: createdAt };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return best;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Decides whether a single bead's NOTES are newer than its most recently
|
|
102
|
+
* created child and, if so, returns a generic, advisory staleness note naming
|
|
103
|
+
* the bead; otherwise returns null.
|
|
104
|
+
*
|
|
105
|
+
* Returns null (NO false positive) when the bead has no children, when no child
|
|
106
|
+
* carries a parseable creation timestamp, when the notes-updated timestamp is
|
|
107
|
+
* absent/unparseable, or when the notes are NOT strictly newer than the most
|
|
108
|
+
* recently created child (the common case: notes predate the decomposition).
|
|
109
|
+
*
|
|
110
|
+
* @param {{ id: string, notesUpdatedAt: string|null, children: Array<{ id?: string, created_at?: string }> }} args
|
|
111
|
+
* @returns {string|null}
|
|
112
|
+
*/
|
|
113
|
+
export function computeParentNotesStalenessNote({ id, notesUpdatedAt, children }) {
|
|
114
|
+
if (typeof notesUpdatedAt !== 'string' || notesUpdatedAt.length === 0) return null;
|
|
115
|
+
const notesTime = Date.parse(notesUpdatedAt);
|
|
116
|
+
if (Number.isNaN(notesTime)) return null;
|
|
117
|
+
|
|
118
|
+
const child = mostRecentlyCreatedChild(children);
|
|
119
|
+
if (!child) return null;
|
|
120
|
+
const childTime = Date.parse(child.created_at);
|
|
121
|
+
if (Number.isNaN(childTime)) return null;
|
|
122
|
+
|
|
123
|
+
// Strictly newer: notes exactly co-timed with the last child are not stale.
|
|
124
|
+
if (notesTime <= childTime) return null;
|
|
125
|
+
|
|
126
|
+
const childLabel = child.id ? `${child.id}, created ${child.created_at}` : `created ${child.created_at}`;
|
|
127
|
+
return (
|
|
128
|
+
`Bead ${id}: its NOTES were last updated (${notesUpdatedAt}) AFTER its most recently ` +
|
|
129
|
+
`created child (${childLabel}). Its existing decomposition may predate the latest NOTES ` +
|
|
130
|
+
`entries -- read this bead's full NOTES and verify its existing children are still consistent ` +
|
|
131
|
+
`with them before proceeding, treating any later correction/amendment recorded in NOTES as ` +
|
|
132
|
+
`authoritative over stale DESCRIPTION text or any child that contradicts it.`
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Formats a set of per-bead staleness notes into one prominent, advisory block
|
|
138
|
+
* for injection into a planner/plan-reviewer dispatch prompt. Returns null when
|
|
139
|
+
* there is nothing to surface, so the prompt is unchanged in the common case.
|
|
140
|
+
* @param {string[]} notes
|
|
141
|
+
* @returns {string|null}
|
|
142
|
+
*/
|
|
143
|
+
export function formatStalenessBlock(notes) {
|
|
144
|
+
if (!Array.isArray(notes) || notes.length === 0) return null;
|
|
145
|
+
const header =
|
|
146
|
+
'TOOLING-COMPUTED STALENESS SIGNAL -- the dispatch tooling detected, without relying on you ' +
|
|
147
|
+
'to remember to check, that the following in-scope bead(s) had their NOTES updated AFTER their ' +
|
|
148
|
+
'most recently created child. Their existing decomposition may therefore predate the latest ' +
|
|
149
|
+
'NOTES corrections. This is ADVISORY ONLY: it never blocks planning and is not itself a defect, ' +
|
|
150
|
+
'but treat each as a specific bead to inspect first:';
|
|
151
|
+
return [header, ...notes.map((n, i) => `${i + 1}. ${n}`)].join('\n\n');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Computes the parent-NOTES staleness notes for a set of scope bead ids by
|
|
156
|
+
* reading each bead's children (`bd list --parent <id> --json`) and, when it
|
|
157
|
+
* has children, its notes-change history (`bd history <id> --json`). Pure
|
|
158
|
+
* fetch-and-compute: never mutates beads, never blocks, and swallows per-bead
|
|
159
|
+
* bd failures (advisory feature -- a failed probe simply yields no note).
|
|
160
|
+
*
|
|
161
|
+
* @param {{
|
|
162
|
+
* command: (label: string, opts: object) => Promise<unknown>,
|
|
163
|
+
* member: string,
|
|
164
|
+
* rootIds: string[],
|
|
165
|
+
* parseBdJson: (raw: unknown, label: string) => unknown,
|
|
166
|
+
* log?: (msg: string) => void,
|
|
167
|
+
* }} args
|
|
168
|
+
* @returns {Promise<string[]>} one note per stale bead, in rootIds order
|
|
169
|
+
*/
|
|
170
|
+
export async function collectParentNotesStalenessNotes({ command, member, rootIds, parseBdJson, log }) {
|
|
171
|
+
const notes = [];
|
|
172
|
+
const ids = Array.isArray(rootIds) ? rootIds : [];
|
|
173
|
+
for (const id of ids) {
|
|
174
|
+
if (!id) continue;
|
|
175
|
+
let children;
|
|
176
|
+
try {
|
|
177
|
+
const label = `bd list --parent ${id} --json`;
|
|
178
|
+
const raw = await command(label, { member_name: member, silent: true });
|
|
179
|
+
children = parseBdJson(raw, label);
|
|
180
|
+
} catch (err) {
|
|
181
|
+
if (log) log(`[fleet-sprint] parent-NOTES staleness: child listing for '${id}' FAILED (non-fatal, skipped): ${err.message}`);
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (!Array.isArray(children) || children.length === 0) continue;
|
|
185
|
+
|
|
186
|
+
let notesUpdatedAt = null;
|
|
187
|
+
try {
|
|
188
|
+
const hLabel = `bd history ${id} --json`;
|
|
189
|
+
const hRaw = await command(hLabel, { member_name: member, silent: true });
|
|
190
|
+
const history = parseBdJson(hRaw, hLabel);
|
|
191
|
+
notesUpdatedAt = notesLastUpdatedAtFromHistory(history);
|
|
192
|
+
} catch (err) {
|
|
193
|
+
if (log) log(`[fleet-sprint] parent-NOTES staleness: history read for '${id}' FAILED (non-fatal, skipped): ${err.message}`);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const note = computeParentNotesStalenessNote({ id, notesUpdatedAt, children });
|
|
198
|
+
if (note) notes.push(note);
|
|
199
|
+
}
|
|
200
|
+
return notes;
|
|
201
|
+
}
|