@backburner/cli 0.1.0
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/LICENSE +21 -0
- package/README.md +329 -0
- package/dist/src/agents/antigravity-launch.js +162 -0
- package/dist/src/agents/antigravity.js +251 -0
- package/dist/src/agents/claude-launch.js +117 -0
- package/dist/src/agents/claude.js +271 -0
- package/dist/src/agents/codex-launch.js +82 -0
- package/dist/src/agents/codex.js +261 -0
- package/dist/src/agents/composite-runner.js +13 -0
- package/dist/src/agents/extraction.js +442 -0
- package/dist/src/agents/failure-feedback.js +132 -0
- package/dist/src/agents/gemini-launch.js +96 -0
- package/dist/src/agents/gemini.js +392 -0
- package/dist/src/agents/job-agent-assignments.js +180 -0
- package/dist/src/agents/lifecycle-feedback.js +147 -0
- package/dist/src/agents/limit-detector.js +83 -0
- package/dist/src/agents/opencode-launch.js +138 -0
- package/dist/src/agents/opencode.js +156 -0
- package/dist/src/agents/plan-breakdown-feedback.js +97 -0
- package/dist/src/agents/pool.js +168 -0
- package/dist/src/agents/prompt.js +462 -0
- package/dist/src/agents/provider-sessions.js +105 -0
- package/dist/src/agents/review-feedback.js +255 -0
- package/dist/src/agents/selection.js +113 -0
- package/dist/src/agents/service.js +1087 -0
- package/dist/src/agents/types.js +1 -0
- package/dist/src/agents/wave-assessment-feedback.js +69 -0
- package/dist/src/attention/derive.js +337 -0
- package/dist/src/capabilities/index.js +2 -0
- package/dist/src/capabilities/projection.js +183 -0
- package/dist/src/capabilities/types.js +1 -0
- package/dist/src/capabilities/validator.js +87 -0
- package/dist/src/cli/commands/broker-smoke.js +96 -0
- package/dist/src/cli/commands/broker.js +56 -0
- package/dist/src/cli/commands/init.js +4 -0
- package/dist/src/cli/commands/journal.js +43 -0
- package/dist/src/cli/commands/run-loop.js +56 -0
- package/dist/src/cli/commands/run.js +1241 -0
- package/dist/src/cli/commands/tui.js +187 -0
- package/dist/src/cli/dispatcher.js +51 -0
- package/dist/src/cli/errors.js +2 -0
- package/dist/src/cli/init.js +92 -0
- package/dist/src/cli/options.js +86 -0
- package/dist/src/cli/output.js +231 -0
- package/dist/src/cli/run-journal.js +342 -0
- package/dist/src/cli/run-types.js +1 -0
- package/dist/src/cli/run.js +32 -0
- package/dist/src/cli/runtime/dispatch-lifecycle.js +772 -0
- package/dist/src/cli/runtime/provider-runtime-types.js +1 -0
- package/dist/src/cli/runtime/provider-runtime.js +152 -0
- package/dist/src/cli/runtime/provider-tools.js +73 -0
- package/dist/src/cli/runtime/providers/antigravity.js +26 -0
- package/dist/src/cli/runtime/providers/claude.js +20 -0
- package/dist/src/cli/runtime/providers/codex.js +20 -0
- package/dist/src/cli/runtime/providers/gemini.js +20 -0
- package/dist/src/cli/runtime/providers/opencode.js +20 -0
- package/dist/src/cli/runtime/run-context.js +131 -0
- package/dist/src/cli/tui/index.js +3 -0
- package/dist/src/cli/tui/screen.js +388 -0
- package/dist/src/cli/tui/tracker.js +558 -0
- package/dist/src/cli/tui/types.js +1 -0
- package/dist/src/cli/tui/views.js +1006 -0
- package/dist/src/config/loader.js +136 -0
- package/dist/src/config/schemas.js +403 -0
- package/dist/src/config/types.js +1 -0
- package/dist/src/context/types.js +331 -0
- package/dist/src/domain/entities.js +1 -0
- package/dist/src/git/backburner-git-tool-service.js +680 -0
- package/dist/src/git/gitops-lifecycle.js +56 -0
- package/dist/src/git/merge-prep-workspace.js +357 -0
- package/dist/src/git/types.js +484 -0
- package/dist/src/github/broker-model-content.js +215 -0
- package/dist/src/github/broker-server.js +237 -0
- package/dist/src/github/broker.js +638 -0
- package/dist/src/github/composed.js +53 -0
- package/dist/src/github/gateway.js +478 -0
- package/dist/src/github/normalize.js +222 -0
- package/dist/src/github/pr-classification.js +73 -0
- package/dist/src/github/scoped-broker.js +35 -0
- package/dist/src/github/security.js +126 -0
- package/dist/src/github/service.js +332 -0
- package/dist/src/github/types.js +1 -0
- package/dist/src/github/utils.js +16 -0
- package/dist/src/journal/index.js +4 -0
- package/dist/src/journal/reader.js +62 -0
- package/dist/src/journal/renderer.js +50 -0
- package/dist/src/journal/service.js +72 -0
- package/dist/src/journal/types.js +1 -0
- package/dist/src/journal/writer.js +19 -0
- package/dist/src/mcps/bridge.js +166 -0
- package/dist/src/mcps/index.js +5 -0
- package/dist/src/mcps/reconcile.js +113 -0
- package/dist/src/mcps/smithery-client.js +186 -0
- package/dist/src/mcps/smithery.js +164 -0
- package/dist/src/mcps/types.js +1 -0
- package/dist/src/memory/json-store.js +71 -0
- package/dist/src/memory/prompt.js +16 -0
- package/dist/src/memory/scope.js +31 -0
- package/dist/src/memory/store.js +1 -0
- package/dist/src/memory/tool-service.js +142 -0
- package/dist/src/memory/types.js +12 -0
- package/dist/src/onboarding/config-writer.js +96 -0
- package/dist/src/onboarding/engine.js +86 -0
- package/dist/src/onboarding/prompt.js +102 -0
- package/dist/src/onboarding/services/provider-discovery.js +58 -0
- package/dist/src/onboarding/services/repo-discovery.js +246 -0
- package/dist/src/onboarding/steps/check-github-auth.js +32 -0
- package/dist/src/onboarding/steps/check-requirements.js +34 -0
- package/dist/src/onboarding/steps/configure-models.js +105 -0
- package/dist/src/onboarding/steps/configure-paths.js +33 -0
- package/dist/src/onboarding/steps/discover-providers.js +38 -0
- package/dist/src/onboarding/steps/discover-repos.js +39 -0
- package/dist/src/onboarding/steps/generate-config.js +106 -0
- package/dist/src/onboarding/steps/readiness-validation.js +158 -0
- package/dist/src/onboarding/steps/select-repos.js +76 -0
- package/dist/src/onboarding/steps/show-summary.js +97 -0
- package/dist/src/onboarding/steps/welcome.js +27 -0
- package/dist/src/onboarding/types.js +1 -0
- package/dist/src/onboarding/validators/git-access.js +63 -0
- package/dist/src/onboarding/validators/github-auth.js +85 -0
- package/dist/src/onboarding/validators/tool-checker.js +153 -0
- package/dist/src/onboarding/validators/workspace.js +83 -0
- package/dist/src/prompts/resolver.js +106 -0
- package/dist/src/retrospectives/candidates.js +224 -0
- package/dist/src/retrospectives/derive.js +169 -0
- package/dist/src/retrospectives/ingest.js +321 -0
- package/dist/src/retrospectives/management-prs.js +380 -0
- package/dist/src/retrospectives/proposals.js +199 -0
- package/dist/src/retrospectives/scopes.js +272 -0
- package/dist/src/retrospectives/scoring.js +171 -0
- package/dist/src/retrospectives/types.js +1 -0
- package/dist/src/state/loader.js +473 -0
- package/dist/src/state/types.js +15 -0
- package/dist/src/tasks/derivation/builders.js +70 -0
- package/dist/src/tasks/derivation/handlers/comment-response.js +169 -0
- package/dist/src/tasks/derivation/handlers/implement-plan.js +103 -0
- package/dist/src/tasks/derivation/handlers/index.js +54 -0
- package/dist/src/tasks/derivation/handlers/packet-pr-control.js +92 -0
- package/dist/src/tasks/derivation/handlers/packet-worktree.js +29 -0
- package/dist/src/tasks/derivation/handlers/plan-breakdown.js +45 -0
- package/dist/src/tasks/derivation/handlers/prepare-for-merge.js +91 -0
- package/dist/src/tasks/derivation/handlers/product-discovery.js +36 -0
- package/dist/src/tasks/derivation/handlers/retry-failed-task.js +125 -0
- package/dist/src/tasks/derivation/handlers/review-pr.js +28 -0
- package/dist/src/tasks/derivation/handlers/shared.js +24 -0
- package/dist/src/tasks/derivation/handlers/sync-parent-branch.js +100 -0
- package/dist/src/tasks/derivation/handlers/wave-assessment.js +223 -0
- package/dist/src/tasks/derivation/handlers/write-plan.js +101 -0
- package/dist/src/tasks/derivation/handlers/write-product-spec.js +49 -0
- package/dist/src/tasks/derivation/runner.js +18 -0
- package/dist/src/tasks/derivation/types.js +1 -0
- package/dist/src/tasks/derive.js +810 -0
- package/dist/src/tasks/mcp-skip.js +10 -0
- package/dist/src/tasks/retry.js +10 -0
- package/dist/src/tasks/task.js +184 -0
- package/dist/src/tasks/types.js +1 -0
- package/dist/src/utils/command-runner.js +192 -0
- package/dist/src/utils/json.js +38 -0
- package/dist/src/utils/logger.js +43 -0
- package/dist/src/utils/paths.js +38 -0
- package/dist/src/utils/slug.js +10 -0
- package/dist/src/workflows/registry.js +174 -0
- package/dist/src/workflows/triage.js +90 -0
- package/dist/src/workflows/workstream-machine/derive-events.js +121 -0
- package/dist/src/workflows/workstream-machine/evaluate.js +24 -0
- package/dist/src/workflows/workstream-machine/events.js +1 -0
- package/dist/src/workflows/workstream-machine/machine.js +355 -0
- package/dist/src/workflows/workstream-machine/selectors.js +19 -0
- package/dist/src/workflows/workstream-machine/types.js +1 -0
- package/dist/src/workstreams/branch-sync.js +87 -0
- package/dist/src/workstreams/derive.js +629 -0
- package/dist/src/workstreams/mcp-blockers.js +420 -0
- package/dist/src/workstreams/packet-candidates.js +42 -0
- package/dist/src/workstreams/packet-lifecycle-feedback.js +60 -0
- package/dist/src/workstreams/packet-lifecycle-report.js +199 -0
- package/dist/src/workstreams/packet-plan.js +597 -0
- package/dist/src/workstreams/packet-projections.js +190 -0
- package/dist/src/workstreams/parent-branch-sync-action.js +312 -0
- package/dist/src/workstreams/parent-branch-sync.js +148 -0
- package/dist/src/workstreams/phases.js +4 -0
- package/dist/src/workstreams/plan-breakdown-generator/export.js +19 -0
- package/dist/src/workstreams/plan-breakdown-generator/index.js +6 -0
- package/dist/src/workstreams/plan-breakdown-generator/inspect.js +50 -0
- package/dist/src/workstreams/plan-breakdown-generator/patch.js +139 -0
- package/dist/src/workstreams/plan-breakdown-generator/session.js +19 -0
- package/dist/src/workstreams/plan-breakdown-generator/store.js +27 -0
- package/dist/src/workstreams/plan-breakdown-generator/tools.js +407 -0
- package/dist/src/workstreams/plan-breakdown-generator/types.js +6 -0
- package/dist/src/workstreams/plan-breakdown-generator/validate.js +212 -0
- package/dist/src/workstreams/plan-breakdown-schema.js +175 -0
- package/dist/src/workstreams/utils.js +15 -0
- package/dist/src/workstreams/wave-assessment/checkpoint.js +172 -0
- package/dist/src/workstreams/wave-assessment/index.js +3 -0
- package/dist/src/workstreams/wave-assessment/session.js +84 -0
- package/dist/src/workstreams/wave-assessment/store.js +51 -0
- package/dist/src/workstreams/wave-assessment/tools.js +419 -0
- package/dist/src/workstreams/wave-assessment/types.js +1 -0
- package/dist/src/workstreams/wave-assessment/validate.js +78 -0
- package/dist/src/worktrees/service.js +839 -0
- package/dist/src/worktrees/workspace-ownership.js +34 -0
- package/dist/src/worktrees/workspace-recovery.js +177 -0
- package/package.json +61 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
export class DefaultContextBuilder {
|
|
3
|
+
build(input) {
|
|
4
|
+
const productSpecSourceSentence = input.productSpecDocumentPath
|
|
5
|
+
? ` The Product Spec is the product source of truth for this workstream when present: ${displayDocumentPath(input.productSpecDocumentPath, input.localRepoPath)}. Do not rely only on the original issue once a Product Spec exists.`
|
|
6
|
+
: "";
|
|
7
|
+
const base = {
|
|
8
|
+
repoIdentifier: input.repoIdentifier,
|
|
9
|
+
...(input.localRepoPath ? { localRepoPath: input.localRepoPath } : {}),
|
|
10
|
+
...(input.branchName ? { branchName: input.branchName } : {}),
|
|
11
|
+
...(input.packetId ? { packetId: input.packetId } : {}),
|
|
12
|
+
...(input.planDocumentPath ? { planDocumentPath: input.planDocumentPath } : {}),
|
|
13
|
+
...(input.productSpecDocumentPath ? { productSpecDocumentPath: input.productSpecDocumentPath } : {}),
|
|
14
|
+
...(input.logDocumentPath ? { logDocumentPath: input.logDocumentPath } : {}),
|
|
15
|
+
...(input.labels ? { labels: [...input.labels].sort((left, right) => left.localeCompare(right)) } : { labels: [] }),
|
|
16
|
+
...(input.preflight ? { preflight: input.preflight } : {}),
|
|
17
|
+
...(input.prepareForMerge ? { prepareForMerge: input.prepareForMerge } : {}),
|
|
18
|
+
...(input.waveAssessmentCheckpoint ? { waveAssessmentCheckpoint: input.waveAssessmentCheckpoint } : {}),
|
|
19
|
+
...(input.finalizedWaveAssessment ? { finalizedWaveAssessment: input.finalizedWaveAssessment } : {}),
|
|
20
|
+
...(input.retrospectiveCandidate ? { retrospectiveCandidate: input.retrospectiveCandidate } : {}),
|
|
21
|
+
...(input.retrospectiveProblem ? { retrospectiveProblem: input.retrospectiveProblem } : {}),
|
|
22
|
+
...(input.learningOpportunity ? { learningOpportunity: input.learningOpportunity } : {})
|
|
23
|
+
};
|
|
24
|
+
switch (input.taskKind) {
|
|
25
|
+
case "product_discovery":
|
|
26
|
+
return {
|
|
27
|
+
...base,
|
|
28
|
+
issueUrl: input.sourceUrl,
|
|
29
|
+
...(input.issueTitle ? { issueTitle: compactText(input.issueTitle, 300) } : {}),
|
|
30
|
+
...(input.issueBody ? { issueBody: compactText(input.issueBody, 2000) } : {}),
|
|
31
|
+
instruction: "Act as a Product Manager presenting product analysis to the CTO on the issue thread. Post a GitHub issue comment through the configured broker. Include concise understanding, product problem, target user or persona if inferable, goals, non-goals, assumptions, suggested product direction, alternatives/tradeoffs, proposed acceptance criteria, open questions, and whether a future UI/UX step may be useful. Explicitly state this is product analysis, not implementation planning. Do not include implementation plan, architecture, files, code, branch, or worktree details."
|
|
32
|
+
};
|
|
33
|
+
case "triage_issue":
|
|
34
|
+
throw new Error("triage_issue is no longer an active task kind; use product_discovery instead.");
|
|
35
|
+
case "respond_issue_comment":
|
|
36
|
+
if (isProductWorkflowPhase(input.workflowPhase)) {
|
|
37
|
+
return {
|
|
38
|
+
...base,
|
|
39
|
+
issueUrl: input.parentUrl ?? input.sourceUrl,
|
|
40
|
+
...(input.issueTitle ? { issueTitle: compactText(input.issueTitle, 300) } : {}),
|
|
41
|
+
...(input.issueBody ? { issueBody: compactText(input.issueBody, 2000) } : {}),
|
|
42
|
+
...(input.commentUrl ? { commentUrl: input.commentUrl } : {}),
|
|
43
|
+
...(input.commentText ? { relevantCommentText: input.commentText } : {}),
|
|
44
|
+
instruction: 'You are in the Product Discovery/Product Specification phase. This is a mutual discovery dialogue, not a routing decision. Read the parent issue and the new comment, then post a GitHub issue comment through the configured broker as Product Manager refining product understanding with the user. Do not return a JSON routing decision. Do not mention "start_implementation", "answer_only", files, code, architecture, branches, or worktrees. If anything is unclear or ambiguous, surface it in an "Open Questions" section and invite the user to answer. The user signals readiness to proceed by applying the product approval label; your job is to ensure they are confident in doing so.'
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
...base,
|
|
49
|
+
issueUrl: input.parentUrl ?? input.sourceUrl,
|
|
50
|
+
...(input.issueTitle ? { issueTitle: compactText(input.issueTitle, 300) } : {}),
|
|
51
|
+
...(input.issueBody ? { issueBody: compactText(input.issueBody, 2000) } : {}),
|
|
52
|
+
...(input.commentUrl ? { commentUrl: input.commentUrl } : {}),
|
|
53
|
+
...(input.commentText ? { relevantCommentText: input.commentText } : {}),
|
|
54
|
+
instruction: "Read the parent issue and the new comment, then post a GitHub issue comment through the configured broker MCP. Answer in the context of the active workstream phase. Do not return a JSON routing decision, and do not use answer_only or start_implementation. Implementation authorization comes from explicit workflow labels, not from issue-comment follow-up decisions."
|
|
55
|
+
};
|
|
56
|
+
case "write_product_spec":
|
|
57
|
+
return {
|
|
58
|
+
...base,
|
|
59
|
+
...(input.sourceKind === "issue"
|
|
60
|
+
? { issueUrl: input.sourceUrl }
|
|
61
|
+
: { pullRequestUrl: input.sourceUrl }),
|
|
62
|
+
...(input.parentUrl ? { issueUrl: input.parentUrl } : {}),
|
|
63
|
+
...(input.issueTitle ? { issueTitle: compactText(input.issueTitle, 300) } : {}),
|
|
64
|
+
...(input.issueBody ? { issueBody: compactText(input.issueBody, 2000) } : {}),
|
|
65
|
+
instruction: `Write or update ${displayDocumentPath(input.productSpecDocumentPath, input.localRepoPath)} as the Product Spec for this workstream, and document the product-specification work in ${displayDocumentPath(input.logDocumentPath, input.localRepoPath)}. Use the issue and Product Discovery discussion. Stay product-focused: include issue link, problem statement, product decision summary, goals, non-goals, user stories, personas where appropriate, success criteria, acceptance criteria, assumptions, constraints, dependencies, open questions, UI/UX recommendation if needed, and a note that downstream planner, implementer, and reviewer must read this spec. Do not write an implementation plan.`
|
|
66
|
+
};
|
|
67
|
+
case "review_pr":
|
|
68
|
+
return {
|
|
69
|
+
...base,
|
|
70
|
+
pullRequestUrl: input.sourceUrl,
|
|
71
|
+
instruction: `Review the pull request at HEAD ${input.headSha ?? "unknown"} — re-read the current state of changed files from the local checkout; do not rely on prior session findings. Finish with JSON. Use {"action":"APPROVE","summary":"..."} when there are no actionable findings. Use {"action":"REQUEST_CHANGES","summary":"...","inlineComments":[{"path":"relative/file.ts","line":12,"body":"..."}]} when changes are required. Use {"action":"COMMENT","summary":"..."} for non-blocking feedback. Findings must be actionable, use repo-relative paths, and use line numbers on the PR head version that are suitable for inline code review comments.`
|
|
72
|
+
};
|
|
73
|
+
case "respond_pr_comment":
|
|
74
|
+
return {
|
|
75
|
+
...base,
|
|
76
|
+
pullRequestUrl: input.parentUrl ?? input.sourceUrl,
|
|
77
|
+
...(input.commentUrl ? { commentUrl: input.commentUrl } : {}),
|
|
78
|
+
...(input.commentText ? { relevantCommentText: input.commentText } : {}),
|
|
79
|
+
...(input.pullRequestReviewLocation ? { pullRequestReviewLocation: input.pullRequestReviewLocation } : {}),
|
|
80
|
+
instruction: `Read the pull request at HEAD ${input.headSha ?? "unknown"} and the comment, then resolve the request or respond with the required follow-up.`
|
|
81
|
+
};
|
|
82
|
+
case "write_plan":
|
|
83
|
+
return {
|
|
84
|
+
...base,
|
|
85
|
+
...(input.sourceKind === "issue"
|
|
86
|
+
? { issueUrl: input.sourceUrl }
|
|
87
|
+
: { pullRequestUrl: input.sourceUrl }),
|
|
88
|
+
...(input.parentUrl ? { issueUrl: input.parentUrl } : {}),
|
|
89
|
+
...(input.issueTitle ? { issueTitle: input.issueTitle } : {}),
|
|
90
|
+
...(input.issueBody ? { issueBody: input.issueBody } : {}),
|
|
91
|
+
...(input.commentUrl ? { commentUrl: input.commentUrl } : {}),
|
|
92
|
+
...(input.commentText ? { relevantCommentText: input.commentText } : {}),
|
|
93
|
+
instruction: `Write or update ${displayDocumentPath(input.planDocumentPath, input.localRepoPath)} with a comprehensive implementation plan for a later cheap-model implementation pass, and document the planning work in ${displayDocumentPath(input.logDocumentPath, input.localRepoPath)}.${productSpecSourceSentence} Do not begin implementation.`
|
|
94
|
+
};
|
|
95
|
+
case "implement_plan":
|
|
96
|
+
return {
|
|
97
|
+
...base,
|
|
98
|
+
...(input.sourceKind === "issue"
|
|
99
|
+
? { issueUrl: input.sourceUrl }
|
|
100
|
+
: { pullRequestUrl: input.sourceUrl }),
|
|
101
|
+
...(input.parentUrl ? { issueUrl: input.parentUrl } : {}),
|
|
102
|
+
...(input.issueTitle ? { issueTitle: compactText(input.issueTitle, 300) } : {}),
|
|
103
|
+
...(input.issueBody ? { issueBody: compactText(input.issueBody, 2000) } : {}),
|
|
104
|
+
instruction: `Implement the approved plan from ${displayDocumentPath(input.planDocumentPath, input.localRepoPath)} and continue documenting work in ${displayDocumentPath(input.logDocumentPath, input.localRepoPath)}.${productSpecSourceSentence}`
|
|
105
|
+
};
|
|
106
|
+
case "plan_breakdown":
|
|
107
|
+
return {
|
|
108
|
+
...base,
|
|
109
|
+
...(input.sourceKind === "issue"
|
|
110
|
+
? {
|
|
111
|
+
issueUrl: input.sourceUrl,
|
|
112
|
+
...(input.issueTitle ? { issueTitle: compactText(input.issueTitle, 300) } : {}),
|
|
113
|
+
...(input.issueBody ? { issueBody: compactText(input.issueBody, 2000) } : {})
|
|
114
|
+
}
|
|
115
|
+
: { pullRequestUrl: input.sourceUrl }),
|
|
116
|
+
instruction: buildPlanBreakdownInstruction()
|
|
117
|
+
};
|
|
118
|
+
case "wave_plan_assessment":
|
|
119
|
+
return {
|
|
120
|
+
...base,
|
|
121
|
+
pullRequestUrl: input.sourceUrl,
|
|
122
|
+
...(input.parentUrl ? { issueUrl: input.parentUrl } : {}),
|
|
123
|
+
...(input.issueTitle ? { issueTitle: compactText(input.issueTitle, 300) } : {}),
|
|
124
|
+
...(input.issueBody ? { issueBody: compactText(input.issueBody, 2000) } : {}),
|
|
125
|
+
instruction: [
|
|
126
|
+
"Assess the completed packet wave at the plan level before the next wave starts.",
|
|
127
|
+
"This task is only about the parent issue/parent PR plan, not packet PR implementation review.",
|
|
128
|
+
"Use the wave_assessment MCP tools to create and finalize the assessment for the provided checkpoint.",
|
|
129
|
+
"Call wave_assessment.start_session with sessionId, workstreamId, waveId, parentPrNumber, assessedParentHeadSha, originalPlanningSessionId, currentPlanRevision, and planNodeIds from the task packet.",
|
|
130
|
+
"When completing or exporting the session, pass currentIdentity with workstreamId, waveId, parentPrNumber, parentHeadSha, and planRevision from the task packet.",
|
|
131
|
+
"Decide whether the next wave should continue, replan, or be blocked.",
|
|
132
|
+
"Do not post the parent PR assessment comment yourself; finalize with the wave_assessment tools and return the session id so the orchestrator can publish the canonical comment.",
|
|
133
|
+
"Do not modify repository files, packet PRs, branches, or git state.",
|
|
134
|
+
'Return exactly one JSON object at the end: { "sessionId": "<finalized wave assessment session id>" }. Do not return raw assessment JSON.'
|
|
135
|
+
].join(" ")
|
|
136
|
+
};
|
|
137
|
+
case "wave_plan_replanning":
|
|
138
|
+
return {
|
|
139
|
+
...base,
|
|
140
|
+
pullRequestUrl: input.sourceUrl,
|
|
141
|
+
...(input.parentUrl ? { issueUrl: input.parentUrl } : {}),
|
|
142
|
+
...(input.issueTitle ? { issueTitle: compactText(input.issueTitle, 300) } : {}),
|
|
143
|
+
...(input.issueBody ? { issueBody: compactText(input.issueBody, 2000) } : {}),
|
|
144
|
+
instruction: [
|
|
145
|
+
"Revise the parent packet plan using the finalized wave assessment provided in the task packet.",
|
|
146
|
+
"The finalized assessment is required input; do not proceed from memory or an unfinalized draft.",
|
|
147
|
+
"This task is plan-level replanning for the parent issue/parent PR only, not packet PR implementation work.",
|
|
148
|
+
"Use the wave_assessment MCP context as needed and preserve a clear audit trail for the parent PR.",
|
|
149
|
+
"Do not edit packet implementation PRs or run branch sync."
|
|
150
|
+
].join(" ")
|
|
151
|
+
};
|
|
152
|
+
case "sync_parent_branch_preflight":
|
|
153
|
+
return {
|
|
154
|
+
...base,
|
|
155
|
+
issueUrl: input.sourceUrl,
|
|
156
|
+
...(input.issueTitle ? { issueTitle: compactText(input.issueTitle, 300) } : {}),
|
|
157
|
+
...(input.issueBody ? { issueBody: compactText(input.issueBody, 2000) } : {}),
|
|
158
|
+
instruction: "Do not modify files or run git sync commands. Inspect/report the parent branch sync preflight before the next packet wave. Confirm that the current packet wave is complete, identify the parent integration branch and default branch, list completed packet IDs and pending future packet IDs, and explain that actual branch sync is out of scope for this task."
|
|
159
|
+
};
|
|
160
|
+
case "sync_parent_branch":
|
|
161
|
+
return {
|
|
162
|
+
...base,
|
|
163
|
+
pullRequestUrl: input.sourceUrl,
|
|
164
|
+
instruction: "Resolve the requested parent branch sync for the packet workstream using the provided preflight context. Preserve the safety distinction between behind_default, diverged, and unknown/missing refs; leave the workspace clean after success or failure; do not advance the packet wave manually. The orchestrator remains responsible for remote publication handoff."
|
|
165
|
+
};
|
|
166
|
+
case "prepare_pr_for_merge":
|
|
167
|
+
return {
|
|
168
|
+
...base,
|
|
169
|
+
pullRequestUrl: input.sourceUrl,
|
|
170
|
+
instruction: buildPrepareForMergeInstruction()
|
|
171
|
+
};
|
|
172
|
+
case "extract_retrospective_problems":
|
|
173
|
+
return {
|
|
174
|
+
...base,
|
|
175
|
+
instruction: buildRetrospectiveExtractInstruction()
|
|
176
|
+
};
|
|
177
|
+
case "investigate_learning_opportunity":
|
|
178
|
+
return {
|
|
179
|
+
...base,
|
|
180
|
+
instruction: buildRetrospectiveInvestigateInstruction()
|
|
181
|
+
};
|
|
182
|
+
case "draft_management_learning_proposal":
|
|
183
|
+
return {
|
|
184
|
+
...base,
|
|
185
|
+
instruction: buildRetrospectiveProposalInstruction()
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function buildRetrospectiveExtractInstruction() {
|
|
191
|
+
return [
|
|
192
|
+
"Your goal is to extract structured observations about recurring problems from a completed workstream.",
|
|
193
|
+
"Read the provided candidate record and its evidence references.",
|
|
194
|
+
"Treat product_discovery and write_product_spec as first-class product workflow tasks: evaluate whether product understanding, approval gating, Product Spec quality, or Product-to-planning handoff contributed to the problem.",
|
|
195
|
+
"Identify one or more distinct problems that occurred during this workstream and could be improved in the future.",
|
|
196
|
+
"Return exactly one JSON object with the following contract:",
|
|
197
|
+
"{",
|
|
198
|
+
' "problems": [',
|
|
199
|
+
" {",
|
|
200
|
+
' "candidateId": "string (matches the source candidate id)",',
|
|
201
|
+
' "problemSummary": "string (concise summary of the problem)",',
|
|
202
|
+
' "evidenceReferences": [{ "kind": "...", "id": "...", "url": "...", "summary": "..." }],',
|
|
203
|
+
' "affectedRepos": ["string (repo ids)"],',
|
|
204
|
+
' "affectedRoles": ["string (agent roles)"],',
|
|
205
|
+
' "affectedTaskKinds": ["string (task kinds)"],',
|
|
206
|
+
' "affectedProviders": ["string (agent providers)"],',
|
|
207
|
+
' "confidence": "low | medium | high",',
|
|
208
|
+
' "impact": "low | medium | high",',
|
|
209
|
+
' "transferability": "low | medium | high",',
|
|
210
|
+
' "improvementLikelihood": "low | medium | high",',
|
|
211
|
+
' "overfittingRisk": "low | medium | high",',
|
|
212
|
+
' "suggestedScopes": [{ "kind": "...", "...": "..." }],',
|
|
213
|
+
' "reasonItMightRecur": "string (why this is a structural problem, not a one-off error)"',
|
|
214
|
+
" }",
|
|
215
|
+
" ]",
|
|
216
|
+
"}",
|
|
217
|
+
"Do not rank, score, or validate the suggested scopes.",
|
|
218
|
+
"Do not write files, create commits, or open pull requests.",
|
|
219
|
+
"Return only the raw JSON object."
|
|
220
|
+
].join("\n");
|
|
221
|
+
}
|
|
222
|
+
function buildRetrospectiveInvestigateInstruction() {
|
|
223
|
+
return [
|
|
224
|
+
"Your goal is to investigate a specific retrospective problem and identify learning opportunities.",
|
|
225
|
+
"Analyze the provided problem record and its evidence.",
|
|
226
|
+
"Determine the root cause and how the orchestrator's behavior or instructions could be improved.",
|
|
227
|
+
"Return exactly one JSON object with the following contract:",
|
|
228
|
+
"{",
|
|
229
|
+
' "problemId": "string (matches the source problem id)",',
|
|
230
|
+
' "investigationSummary": "string (summary of your findings)",',
|
|
231
|
+
' "investigationResult": "string (detailed analysis)",',
|
|
232
|
+
' "evidenceReferences": [{ "kind": "...", "id": "...", "url": "...", "summary": "..." }],',
|
|
233
|
+
' "selectedScope": { "kind": "...", "...": "..." },',
|
|
234
|
+
' "rationale": "string (why this scope and investigation result are correct)"',
|
|
235
|
+
"}",
|
|
236
|
+
"Do not validate the scope against the filesystem.",
|
|
237
|
+
"Do not materialize management artifacts or proposed edits.",
|
|
238
|
+
"Do not write files, create commits, or open pull requests.",
|
|
239
|
+
"Return only the raw JSON object."
|
|
240
|
+
].join("\n");
|
|
241
|
+
}
|
|
242
|
+
function buildRetrospectiveProposalInstruction() {
|
|
243
|
+
return [
|
|
244
|
+
"Your goal is to draft a structured management learning proposal based on an investigated opportunity.",
|
|
245
|
+
"Review the opportunity and problem context.",
|
|
246
|
+
"Draft a specific, actionable improvement to the orchestrator's guidance (e.g. GEMINI.md or instruction files).",
|
|
247
|
+
"Return exactly one JSON object with the following contract:",
|
|
248
|
+
"{",
|
|
249
|
+
' "opportunityId": "string (matches the source opportunity id)",',
|
|
250
|
+
' "problemId": "string (optional source problem id)",',
|
|
251
|
+
' "selectedScope": { "kind": "...", "...": "..." },',
|
|
252
|
+
' "proposedEditMode": "append | refine | supersede | create",',
|
|
253
|
+
' "proposedGuidanceText": "string (the actual markdown or text for the instruction)",',
|
|
254
|
+
' "rationale": "string (why this change is needed)",',
|
|
255
|
+
' "expectedBehaviorChange": "string (what the orchestrator should do differently after this change)"',
|
|
256
|
+
"}",
|
|
257
|
+
"Guidance should be concise and suitable for an existing scoped learning artifact.",
|
|
258
|
+
"Do not provide filesystem paths; the orchestrator will resolve the typed scope to a path.",
|
|
259
|
+
"Do not write files, create branch, create commits, push, or open pull requests.",
|
|
260
|
+
"Return only the raw JSON object."
|
|
261
|
+
].join("\n");
|
|
262
|
+
}
|
|
263
|
+
function buildPrepareForMergeInstruction() {
|
|
264
|
+
return [
|
|
265
|
+
"Your goal is merge preparation only — not feature implementation.",
|
|
266
|
+
"Read the prepareForMerge context from the task packet to get the head branch, base branch, and PR details.",
|
|
267
|
+
"Steps:",
|
|
268
|
+
"1. Verify the working tree is clean before starting. If it is not clean, report the state and stop without making changes.",
|
|
269
|
+
"2. Fetch the latest remote state: git fetch origin.",
|
|
270
|
+
"3. Check out the PR head branch and ensure it tracks origin.",
|
|
271
|
+
"4. Merge the PR base branch into the head branch: git merge origin/<baseBranch>.",
|
|
272
|
+
"5. If conflicts exist, resolve them by understanding both sides' intent. Preserve the work from both branches. Do not delete either side's feature to simplify the merge.",
|
|
273
|
+
"6. Allowed changes only: conflict marker removal with semantic reconciliation, import/export fixes, type fixes caused by merged code shape, formatting fixes, stale test expectation updates when implementation behavior is unchanged, small build/lint/test fixes required by the merged code, package lock updates when required by existing dependency changes.",
|
|
274
|
+
"7. Disallowed: new product features, changed business logic beyond reconciling both branches, feature deletion to simplify the merge, force-push history rewrites, broad refactors, base branch changes, auto-merging the PR.",
|
|
275
|
+
"8. Run the configured verification commands (tests, typecheck, build, lint, or the configured verification command set).",
|
|
276
|
+
"9. If verification passes and all conflicts are resolved: ensure all resolved changes are committed locally. Write a summary of what was resolved and the verification results as the final output of your response. Do not push; the orchestrator owns the remote push. Do not post a GitHub PR comment; the orchestrator posts the final audit comment after confirming the push.",
|
|
277
|
+
"10. If you encounter a conflict you cannot safely resolve without a product decision, or if verification fails in a way that requires product changes: abort the merge (git merge --abort), restore the working tree to a clean state, and post a GitHub comment describing which files conflict, what decisions are needed, what verification was attempted, and why you cannot proceed safely. Do not push partial or conflicted state.",
|
|
278
|
+
"Stop and report when a human product decision is needed.",
|
|
279
|
+
"The orchestrator owns remote publication handoff."
|
|
280
|
+
].join("\n");
|
|
281
|
+
}
|
|
282
|
+
export const PLAN_BREAKDOWN_EXTRA_INSTRUCTIONS = [
|
|
283
|
+
"Plan breakdown is a one-time decomposition step for this workstream; make the generated packet plan good enough to survive later cycles without re-running breakdown.",
|
|
284
|
+
"Do not artificially cap packet count or wave count. Create as many packets as the work needs, including more than 10 packets when that makes implementation safer.",
|
|
285
|
+
"Assume later implementation will be done by a cheap or weaker implementation agent. Each packet needs a clear title, detailed description, concrete acceptance criteria, likely files, dependencies, risk, and verification commands.",
|
|
286
|
+
"Packet PRs are planning shells created from this breakdown. Detailed per-packet plan documents are written later by write_plan tasks, so this breakdown must provide enough raw material for those sub-plans."
|
|
287
|
+
];
|
|
288
|
+
function buildPlanBreakdownInstruction() {
|
|
289
|
+
return [
|
|
290
|
+
"Do not implement code.",
|
|
291
|
+
"You must use the Plan Breakdown Generator tool to decompose this plan.",
|
|
292
|
+
"Start a new session, build candidate packet plans using patches, and validate them.",
|
|
293
|
+
...PLAN_BREAKDOWN_EXTRA_INSTRUCTIONS,
|
|
294
|
+
'Return exactly one JSON object: { "sessionId": "<selected generator session id>" }.',
|
|
295
|
+
"If no valid session can be produced, publish details to GitHub through the configured GitHub broker MCP when appropriate.",
|
|
296
|
+
"Failure details should include blocker, missing information, validation errors, and recommended human action when available.",
|
|
297
|
+
"After failure details are published, finish without returning a valid sessionId.",
|
|
298
|
+
"No valid sessionId means the orchestrator treats the plan_breakdown task as failed.",
|
|
299
|
+
"Do not return raw PlanBreakdownResult JSON directly.",
|
|
300
|
+
"Do not return Markdown as the primary result.",
|
|
301
|
+
"Do not wrap the JSON in a Markdown code fence.",
|
|
302
|
+
"Do not include prose before or after the JSON.",
|
|
303
|
+
"The orchestrator will export the selected session into the final PlanBreakdownResult artifact."
|
|
304
|
+
].join("\n");
|
|
305
|
+
}
|
|
306
|
+
export function buildAgentContext(task, memoryBackground, capabilities) {
|
|
307
|
+
return {
|
|
308
|
+
taskId: task.id,
|
|
309
|
+
...task.context,
|
|
310
|
+
...(memoryBackground ? { memoryBackground } : {}),
|
|
311
|
+
...(capabilities !== undefined ? { capabilities } : {})
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function compactText(value, maxLength = 500) {
|
|
315
|
+
return value.replace(/\s+/g, " ").trim().slice(0, maxLength);
|
|
316
|
+
}
|
|
317
|
+
function isProductWorkflowPhase(phase) {
|
|
318
|
+
return phase === "product_discovery" || phase === "product_specification";
|
|
319
|
+
}
|
|
320
|
+
function displayDocumentPath(documentPath, localRepoPath) {
|
|
321
|
+
if (!documentPath) {
|
|
322
|
+
return "the assigned planning document";
|
|
323
|
+
}
|
|
324
|
+
if (!localRepoPath) {
|
|
325
|
+
return documentPath;
|
|
326
|
+
}
|
|
327
|
+
return relativeToRepo(localRepoPath, documentPath);
|
|
328
|
+
}
|
|
329
|
+
function relativeToRepo(localRepoPath, documentPath) {
|
|
330
|
+
return path.relative(localRepoPath, documentPath).split(path.sep).join("/");
|
|
331
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|