@developerz.ai/aitm 0.0.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.
Files changed (126) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -0
  3. package/dist/agent-config/agent-config-detector.d.ts +15 -0
  4. package/dist/agent-config/agent-config-detector.js +56 -0
  5. package/dist/agent-config/agent-config-detector.js.map +1 -0
  6. package/dist/cli/args.d.ts +37 -0
  7. package/dist/cli/args.js +238 -0
  8. package/dist/cli/args.js.map +1 -0
  9. package/dist/cli/cli.d.ts +15 -0
  10. package/dist/cli/cli.js +113 -0
  11. package/dist/cli/cli.js.map +1 -0
  12. package/dist/cli/commands.d.ts +83 -0
  13. package/dist/cli/commands.js +521 -0
  14. package/dist/cli/commands.js.map +1 -0
  15. package/dist/compaction/compactor.d.ts +20 -0
  16. package/dist/compaction/compactor.js +75 -0
  17. package/dist/compaction/compactor.js.map +1 -0
  18. package/dist/config/config-loader.d.ts +25 -0
  19. package/dist/config/config-loader.js +275 -0
  20. package/dist/config/config-loader.js.map +1 -0
  21. package/dist/config/config-writer.d.ts +14 -0
  22. package/dist/config/config-writer.js +178 -0
  23. package/dist/config/config-writer.js.map +1 -0
  24. package/dist/config/schema.d.ts +85 -0
  25. package/dist/config/schema.js +38 -0
  26. package/dist/config/schema.js.map +1 -0
  27. package/dist/credentials/credentials.d.ts +15 -0
  28. package/dist/credentials/credentials.js +58 -0
  29. package/dist/credentials/credentials.js.map +1 -0
  30. package/dist/credentials/defaults.d.ts +2 -0
  31. package/dist/credentials/defaults.js +21 -0
  32. package/dist/credentials/defaults.js.map +1 -0
  33. package/dist/fs/atomic-write.d.ts +1 -0
  34. package/dist/fs/atomic-write.js +27 -0
  35. package/dist/fs/atomic-write.js.map +1 -0
  36. package/dist/github/errors.d.ts +18 -0
  37. package/dist/github/errors.js +20 -0
  38. package/dist/github/errors.js.map +1 -0
  39. package/dist/github/github-client.d.ts +47 -0
  40. package/dist/github/github-client.js +417 -0
  41. package/dist/github/github-client.js.map +1 -0
  42. package/dist/github/schema.d.ts +44 -0
  43. package/dist/github/schema.js +23 -0
  44. package/dist/github/schema.js.map +1 -0
  45. package/dist/index.d.ts +26 -0
  46. package/dist/index.js +22 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/logger/logger.d.ts +36 -0
  49. package/dist/logger/logger.js +123 -0
  50. package/dist/logger/logger.js.map +1 -0
  51. package/dist/loop/run-loop-adapter.d.ts +46 -0
  52. package/dist/loop/run-loop-adapter.js +270 -0
  53. package/dist/loop/run-loop-adapter.js.map +1 -0
  54. package/dist/loop/take-over-flow.d.ts +57 -0
  55. package/dist/loop/take-over-flow.js +183 -0
  56. package/dist/loop/take-over-flow.js.map +1 -0
  57. package/dist/loop/work-loop.d.ts +95 -0
  58. package/dist/loop/work-loop.js +211 -0
  59. package/dist/loop/work-loop.js.map +1 -0
  60. package/dist/mcp/mcp-client.d.ts +27 -0
  61. package/dist/mcp/mcp-client.js +123 -0
  62. package/dist/mcp/mcp-client.js.map +1 -0
  63. package/dist/mcp/schema.d.ts +53 -0
  64. package/dist/mcp/schema.js +39 -0
  65. package/dist/mcp/schema.js.map +1 -0
  66. package/dist/openrouter/client.d.ts +28 -0
  67. package/dist/openrouter/client.js +40 -0
  68. package/dist/openrouter/client.js.map +1 -0
  69. package/dist/openrouter/model-limits.d.ts +21 -0
  70. package/dist/openrouter/model-limits.js +39 -0
  71. package/dist/openrouter/model-limits.js.map +1 -0
  72. package/dist/openrouter/server-tools.d.ts +35 -0
  73. package/dist/openrouter/server-tools.js +25 -0
  74. package/dist/openrouter/server-tools.js.map +1 -0
  75. package/dist/orchestrator/orchestrator.d.ts +60 -0
  76. package/dist/orchestrator/orchestrator.js +180 -0
  77. package/dist/orchestrator/orchestrator.js.map +1 -0
  78. package/dist/orchestrator/subagent-tools.d.ts +44 -0
  79. package/dist/orchestrator/subagent-tools.js +133 -0
  80. package/dist/orchestrator/subagent-tools.js.map +1 -0
  81. package/dist/orchestrator/system-prompts.d.ts +4 -0
  82. package/dist/orchestrator/system-prompts.js +78 -0
  83. package/dist/orchestrator/system-prompts.js.map +1 -0
  84. package/dist/plan/plan-graph.d.ts +11 -0
  85. package/dist/plan/plan-graph.js +69 -0
  86. package/dist/plan/plan-graph.js.map +1 -0
  87. package/dist/plan/schema.d.ts +30 -0
  88. package/dist/plan/schema.js +24 -0
  89. package/dist/plan/schema.js.map +1 -0
  90. package/dist/state/schema.d.ts +88 -0
  91. package/dist/state/schema.js +53 -0
  92. package/dist/state/schema.js.map +1 -0
  93. package/dist/state/state-store.d.ts +16 -0
  94. package/dist/state/state-store.js +129 -0
  95. package/dist/state/state-store.js.map +1 -0
  96. package/dist/subagents/factory.d.ts +8 -0
  97. package/dist/subagents/factory.js +10 -0
  98. package/dist/subagents/factory.js.map +1 -0
  99. package/dist/subagents/planner.d.ts +31 -0
  100. package/dist/subagents/planner.js +83 -0
  101. package/dist/subagents/planner.js.map +1 -0
  102. package/dist/subagents/reviewer.d.ts +60 -0
  103. package/dist/subagents/reviewer.js +159 -0
  104. package/dist/subagents/reviewer.js.map +1 -0
  105. package/dist/subagents/worker.d.ts +71 -0
  106. package/dist/subagents/worker.js +180 -0
  107. package/dist/subagents/worker.js.map +1 -0
  108. package/dist/testing/temp-repo.d.ts +7 -0
  109. package/dist/testing/temp-repo.js +21 -0
  110. package/dist/testing/temp-repo.js.map +1 -0
  111. package/dist/tools/datetime.d.ts +12 -0
  112. package/dist/tools/datetime.js +42 -0
  113. package/dist/tools/datetime.js.map +1 -0
  114. package/dist/tools/fetch-html.d.ts +32 -0
  115. package/dist/tools/fetch-html.js +139 -0
  116. package/dist/tools/fetch-html.js.map +1 -0
  117. package/dist/tools/github-thread-tool.d.ts +10 -0
  118. package/dist/tools/github-thread-tool.js +36 -0
  119. package/dist/tools/github-thread-tool.js.map +1 -0
  120. package/dist/tools/web-fetch.d.ts +31 -0
  121. package/dist/tools/web-fetch.js +223 -0
  122. package/dist/tools/web-fetch.js.map +1 -0
  123. package/dist/workspace/worktree-pool.d.ts +21 -0
  124. package/dist/workspace/worktree-pool.js +104 -0
  125. package/dist/workspace/worktree-pool.js.map +1 -0
  126. package/package.json +50 -0
@@ -0,0 +1,180 @@
1
+ // docs/architecture.md §Flow, docs/subagents.md §Composition
2
+ // Top-level agent. Owns:
3
+ // - prompt composition (style payload + role prefix + rolling context)
4
+ // - routing between Planner / Worker / Reviewer (each exposed as a tool)
5
+ // - **PR creation** — title, body, commit message: docs say Worker opens the PR,
6
+ // but the Worker can be inconsistent on global-context narration. Orchestrator
7
+ // re-composes the commit message and opens the PR via GitHubClient, taking the
8
+ // Worker's draft as input. This is the reliability win: one place that knows
9
+ // the whole plan writes the PR-level prose.
10
+ //
11
+ // SDK references:
12
+ // docs/vendor/ai-sdk/chunk-04.md §"ToolLoopAgent"
13
+ // docs/vendor/ai-sdk/chunk-09.md §"Subagents" §"Controlling What the Model Sees"
14
+ // docs/vendor/ai-sdk/chunk-09.md §"Loop Control" — stopWhen: [stepCountIs(N), hasToolCall('done')]
15
+ import { generateText, hasToolCall, Output, stepCountIs, ToolLoopAgent } from 'ai';
16
+ import { ExecaError, execa } from 'execa';
17
+ import { z } from 'zod';
18
+ import { makePlannerTool, makeReviewerTool, makeWorkerTool, } from "./subagent-tools.js";
19
+ export const defaultRunCmd = async (file, args, options) => {
20
+ try {
21
+ const r = await execa(file, [...args], options?.cwd ? { cwd: options.cwd } : {});
22
+ return {
23
+ stdout: typeof r.stdout === 'string' ? r.stdout : '',
24
+ stderr: typeof r.stderr === 'string' ? r.stderr : '',
25
+ exitCode: r.exitCode ?? 0,
26
+ };
27
+ }
28
+ catch (err) {
29
+ if (err instanceof ExecaError) {
30
+ return {
31
+ stdout: typeof err.stdout === 'string' ? err.stdout : '',
32
+ stderr: typeof err.stderr === 'string' ? err.stderr : '',
33
+ exitCode: err.exitCode ?? 1,
34
+ };
35
+ }
36
+ throw err;
37
+ }
38
+ };
39
+ // Inlined per CLAUDE.md "no premature abstraction". Full system prompt is
40
+ // `agentConfig.contents + ORCHESTRATOR_ROLE_PREFIX + rollingContext`.
41
+ export const ORCHESTRATOR_ROLE_PREFIX = [
42
+ '',
43
+ '## Role: Orchestrator',
44
+ '',
45
+ 'You coordinate three subagents — Planner, Worker, Reviewer — each exposed as a tool.',
46
+ 'You see the whole plan and the rolling context, so you also own per-PR prose:',
47
+ 'the final commit message and the PR title + body.',
48
+ '',
49
+ 'Flow:',
50
+ ' 1. Call the planner tool once to produce the PR-group DAG.',
51
+ ' 2. For each ready group, call the worker tool. The harness then commits + opens the PR.',
52
+ ' 3. For each merged PR with unresolved review threads, call the reviewer tool.',
53
+ ' 4. Stop when every group is merged or blocked.',
54
+ '',
55
+ 'Rules:',
56
+ ' - Be specific and terse. No marketing prose.',
57
+ ' - Conventional commit subjects, ≤72 chars.',
58
+ ].join('\n');
59
+ // Structured-output schema for PR composition. Title cap reinforces conventional-commit
60
+ // brevity; body is free-form markdown.
61
+ const PrCompositionSchema = z.object({
62
+ title: z.string().min(1).max(72),
63
+ body: z.string().min(1),
64
+ });
65
+ // Fallback session cap when caller passes null / 0 / negative `maxSessions`.
66
+ export const DEFAULT_MAX_STEPS = 50;
67
+ // Resolve the agent step cap from caller-provided `maxSessions`. Falls back to the
68
+ // default when the value is null, zero, or negative. Exported for unit testing.
69
+ export function resolveMaxSteps(maxSessions) {
70
+ return typeof maxSessions === 'number' && maxSessions > 0 ? maxSessions : DEFAULT_MAX_STEPS;
71
+ }
72
+ export class Orchestrator {
73
+ init;
74
+ constructor(init) {
75
+ this.init = init;
76
+ }
77
+ build(context) {
78
+ const commonDeps = {
79
+ credentials: this.init.credentials,
80
+ styleContents: this.init.agentConfig.contents,
81
+ rollingContext: this.init.rollingContext,
82
+ };
83
+ const tools = {
84
+ planner: makePlannerTool({ ...commonDeps, plannerTools: context.plannerTools }),
85
+ worker: makeWorkerTool({
86
+ ...commonDeps,
87
+ workerTools: context.workerTools,
88
+ worktreePath: context.worktreePath,
89
+ baseBranch: context.baseBranch,
90
+ group: context.group,
91
+ }),
92
+ reviewer: makeReviewerTool({
93
+ ...commonDeps,
94
+ reviewerTools: context.reviewerTools,
95
+ worktreePath: context.worktreePath,
96
+ pr: context.pr,
97
+ threads: context.threads,
98
+ }),
99
+ };
100
+ return new ToolLoopAgent({
101
+ model: this.init.credentials.modelFor('orchestrator'),
102
+ instructions: this.buildSystemPrompt(),
103
+ tools,
104
+ stopWhen: [stepCountIs(resolveMaxSteps(this.init.maxSessions)), hasToolCall('done')],
105
+ });
106
+ }
107
+ buildSystemPrompt() {
108
+ return [
109
+ this.init.agentConfig.contents,
110
+ ORCHESTRATOR_ROLE_PREFIX,
111
+ this.init.rollingContext,
112
+ ].join('\n');
113
+ }
114
+ // Re-write the Worker's draft commit message via the orchestrator model, then
115
+ // `git commit --amend` on the active worktree. Returns the new HEAD SHA.
116
+ async finalizeCommit(group, delivery, worktreePath) {
117
+ const refined = await this.refineCommitMessage(group, delivery);
118
+ const runCmd = this.init.runCmd ?? defaultRunCmd;
119
+ const amend = await runCmd('git', ['commit', '--amend', '-m', refined], { cwd: worktreePath });
120
+ if (amend.exitCode !== 0) {
121
+ throw new Error(`git commit --amend failed: ${amend.stderr.trim() || amend.stdout.trim()}`);
122
+ }
123
+ const sha = await runCmd('git', ['rev-parse', 'HEAD'], { cwd: worktreePath });
124
+ if (sha.exitCode !== 0) {
125
+ throw new Error(`git rev-parse HEAD failed: ${sha.stderr.trim() || sha.stdout.trim()}`);
126
+ }
127
+ return sha.stdout.trim();
128
+ }
129
+ // Compose PR title + body via the orchestrator model, then open the PR through the github
130
+ // client. Falls back to `aitm/<group.id>` when `group.branch` is unset.
131
+ async openPr(group, delivery, baseBranch) {
132
+ const { title, body } = await this.composePr(group, delivery);
133
+ const head = group.branch ?? `aitm/${group.id}`;
134
+ return this.init.github.createPr({ title, body, base: baseBranch, head });
135
+ }
136
+ async refineCommitMessage(group, delivery) {
137
+ const { text } = await generateText({
138
+ model: this.init.credentials.modelFor('orchestrator'),
139
+ prompt: this.buildCommitPrompt(group, delivery),
140
+ });
141
+ return text.trim();
142
+ }
143
+ buildCommitPrompt(group, delivery) {
144
+ return [
145
+ this.buildSystemPrompt(),
146
+ '',
147
+ 'Rewrite the worker draft into a final commit message.',
148
+ 'Subject ≤72 chars, conventional-commit style. Body optional, one paragraph.',
149
+ 'Output ONLY the message — no labels, no quotes.',
150
+ '',
151
+ `PR group: ${group.id} — ${group.title}`,
152
+ `Worker draft: ${delivery.draftCommitMessage}`,
153
+ 'Files changed:',
154
+ ...delivery.changes.map((c) => ` - ${c.kind} ${c.path}: ${c.summary}`),
155
+ ].join('\n');
156
+ }
157
+ async composePr(group, delivery) {
158
+ const result = await generateText({
159
+ model: this.init.credentials.modelFor('orchestrator'),
160
+ prompt: this.buildPrPrompt(group, delivery),
161
+ output: Output.object({ schema: PrCompositionSchema, name: 'PrComposition' }),
162
+ });
163
+ return result.experimental_output;
164
+ }
165
+ buildPrPrompt(group, delivery) {
166
+ return [
167
+ this.buildSystemPrompt(),
168
+ '',
169
+ 'Compose the pull-request title and body for this PR group. Return JSON.',
170
+ '- title: conventional-commit style, ≤72 chars',
171
+ '- body: short summary + bulleted file changes + relevant rolling context',
172
+ '',
173
+ `PR group: ${group.id} — ${group.title}`,
174
+ `Worker draft message: ${delivery.draftCommitMessage}`,
175
+ 'Files changed:',
176
+ ...delivery.changes.map((c) => ` - ${c.kind} ${c.path}: ${c.summary}`),
177
+ ].join('\n');
178
+ }
179
+ }
180
+ //# sourceMappingURL=orchestrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../src/orchestrator/orchestrator.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,yBAAyB;AACzB,yEAAyE;AACzE,2EAA2E;AAC3E,mFAAmF;AACnF,mFAAmF;AACnF,mFAAmF;AACnF,iFAAiF;AACjF,gDAAgD;AAChD,EAAE;AACF,kBAAkB;AAClB,oDAAoD;AACpD,mFA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AAM,EAAE,mBAAmB,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;SAC9E,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,mBAAmB,CAAC;IACpC,CAAC;IAEO,aAAa,CAAC,KAAc,EAAE,QAAwB;QAC5D,OAAO;YACL,IAAI,CAAC,iBAAiB,EAAE;YACxB,EAAE;YACF,yEAAyE;YACzE,+CAA+C;YAC/C,0EAA0E;YAC1E,EAAE;YACF,aAAa,KAAK,CAAC,EAAE,MAAM,KAAK,CAAC,KAAK,EAAE;YACxC,yBAAyB,QAAQ,CAAC,kBAAkB,EAAE;YACtD,gBAAgB;YAChB,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;SACxE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,44 @@
1
+ import type { LanguageModel, Tool } from 'ai';
2
+ import { z } from 'zod';
3
+ import type { Role } from '../credentials/credentials.ts';
4
+ import type { ReviewThread } from '../github/schema.ts';
5
+ import type { PrGroup } from '../state/schema.ts';
6
+ import { type PlannerResult, type PlannerTools } from '../subagents/planner.ts';
7
+ import { type ReviewerResult, type ReviewerTools } from '../subagents/reviewer.ts';
8
+ import { type WorkerResult, type WorkerTools } from '../subagents/worker.ts';
9
+ export type ModelProvider = {
10
+ modelFor(role: Role): LanguageModel;
11
+ };
12
+ type CommonDeps = {
13
+ credentials: ModelProvider;
14
+ styleContents: string;
15
+ rollingContext: string;
16
+ };
17
+ export type PlannerToolDeps = CommonDeps & {
18
+ plannerTools: PlannerTools;
19
+ };
20
+ export type WorkerToolDeps = CommonDeps & {
21
+ workerTools: WorkerTools;
22
+ worktreePath: string;
23
+ baseBranch: string;
24
+ group: PrGroup;
25
+ };
26
+ export type ReviewerToolDeps = CommonDeps & {
27
+ reviewerTools: ReviewerTools;
28
+ worktreePath: string;
29
+ pr: number;
30
+ threads: ReviewThread[];
31
+ };
32
+ export type SubagentToolDeps = PlannerToolDeps & WorkerToolDeps & ReviewerToolDeps;
33
+ declare const plannerInputSchema: z.ZodObject<{
34
+ goal: z.ZodString;
35
+ criteria: z.ZodOptional<z.ZodString>;
36
+ maxPrs: z.ZodNumber;
37
+ }, z.core.$strip>;
38
+ type PlannerToolInput = z.infer<typeof plannerInputSchema>;
39
+ declare const emptyInputSchema: z.ZodObject<{}, z.core.$strip>;
40
+ type EmptyInput = z.infer<typeof emptyInputSchema>;
41
+ export declare function makePlannerTool(deps: PlannerToolDeps): Tool<PlannerToolInput, PlannerResult>;
42
+ export declare function makeWorkerTool(deps: WorkerToolDeps): Tool<EmptyInput, WorkerResult>;
43
+ export declare function makeReviewerTool(deps: ReviewerToolDeps): Tool<EmptyInput, ReviewerResult>;
44
+ export {};
@@ -0,0 +1,133 @@
1
+ // Wrap each subagent as a tool consumable by the Orchestrator agent.
2
+ // Pattern verbatim from docs/vendor/ai-sdk/chunk-09.md §"Subagents" and §"Controlling What the
3
+ // Model Sees" — `toModelOutput` keeps the Orchestrator context lean by collapsing the full
4
+ // subagent result to a one-line `<role> [<status>]: <summary>`.
5
+ //
6
+ // Note: AI SDK 6 names the field `toModelOutput` (the SDK-5 name was
7
+ // `experimental_toToolResultContent`; the task brief uses the older spelling).
8
+ //
9
+ // Each wrapper:
10
+ // - inputSchema — Zod schema; the Orchestrator's model fills it in per call
11
+ // - execute — builds the subagent via its factory using `credentials.modelFor(role)` and
12
+ // runs the matching runner; returns the full structured result
13
+ // - toModelOutput — collapses that result to a single status line for the Orchestrator
14
+ import { tool } from 'ai';
15
+ import { z } from 'zod';
16
+ import { createPlannerAgent, PLANNER_SYSTEM_PREFIX, runPlanner, } from "../subagents/planner.js";
17
+ import { createReviewerAgent, REVIEWER_SYSTEM_PREFIX, runReviewer, } from "../subagents/reviewer.js";
18
+ import { createWorkerAgent, runWorker, WORKER_SYSTEM_PREFIX, } from "../subagents/worker.js";
19
+ const plannerInputSchema = z.object({
20
+ goal: z.string().min(1).describe('User goal to plan PR groups for'),
21
+ criteria: z.string().optional().describe('Optional acceptance criteria'),
22
+ maxPrs: z.number().int().positive().describe('Cap on PR-group count'),
23
+ });
24
+ // Worker + Reviewer have all state bound in deps — the Orchestrator's model invokes them with
25
+ // no arguments, signalling "process the currently-active group / review threads".
26
+ const emptyInputSchema = z.object({});
27
+ export function makePlannerTool(deps) {
28
+ return tool({
29
+ description: 'Run the Planner subagent. Given a goal, returns an ordered DAG of PR groups; each group is a single cohesive pull request.',
30
+ inputSchema: plannerInputSchema,
31
+ execute: async (input) => {
32
+ const agent = createPlannerAgent({
33
+ model: deps.credentials.modelFor('planner'),
34
+ tools: deps.plannerTools,
35
+ systemPrompt: deps.styleContents + PLANNER_SYSTEM_PREFIX,
36
+ });
37
+ return runPlanner(agent, {
38
+ goal: input.goal,
39
+ styleContents: deps.styleContents,
40
+ maxPrs: input.maxPrs,
41
+ ...(input.criteria !== undefined ? { criteria: input.criteria } : {}),
42
+ });
43
+ },
44
+ toModelOutput: ({ output }) => ({ type: 'text', value: summarizePlannerResult(output) }),
45
+ });
46
+ }
47
+ export function makeWorkerTool(deps) {
48
+ return tool({
49
+ description: 'Run the Worker subagent on the active PR group. Produces a file manifest, fans out per-file editors, commits on the group branch.',
50
+ inputSchema: emptyInputSchema,
51
+ execute: async () => {
52
+ const agent = createWorkerAgent({
53
+ model: deps.credentials.modelFor('worker'),
54
+ tools: deps.workerTools,
55
+ systemPrompt: deps.styleContents + WORKER_SYSTEM_PREFIX,
56
+ });
57
+ return runWorker(agent, {
58
+ group: deps.group,
59
+ worktreePath: deps.worktreePath,
60
+ baseBranch: deps.baseBranch,
61
+ styleContents: deps.styleContents,
62
+ rollingContext: deps.rollingContext,
63
+ });
64
+ },
65
+ toModelOutput: ({ output }) => ({ type: 'text', value: summarizeWorkerResult(output) }),
66
+ });
67
+ }
68
+ export function makeReviewerTool(deps) {
69
+ return tool({
70
+ description: 'Run the Reviewer subagent on outstanding PR review threads. Each thread resolves to fixed / replied / wontfix.',
71
+ inputSchema: emptyInputSchema,
72
+ execute: async () => {
73
+ const agent = createReviewerAgent({
74
+ model: deps.credentials.modelFor('reviewer'),
75
+ tools: deps.reviewerTools,
76
+ systemPrompt: deps.styleContents + REVIEWER_SYSTEM_PREFIX,
77
+ });
78
+ return runReviewer(agent, {
79
+ pr: deps.pr,
80
+ threads: deps.threads,
81
+ worktreePath: deps.worktreePath,
82
+ styleContents: deps.styleContents,
83
+ });
84
+ },
85
+ toModelOutput: ({ output }) => ({ type: 'text', value: summarizeReviewerResult(output) }),
86
+ });
87
+ }
88
+ // Cap per-line summary length so a verbose subagent reply (long IDs, multiline draft
89
+ // commit messages, error payloads) can't bloat the orchestrator's context. 220 chars
90
+ // is enough for a status line + a few tens of chars of free text.
91
+ const MAX_SUMMARY_CHARS = 220;
92
+ // Show only the first N planner group IDs, then `+M more` — the count alone is what
93
+ // matters to the orchestrator; the orchestrator can re-read the plan if it needs the
94
+ // full ID list.
95
+ const MAX_PREVIEW_IDS = 8;
96
+ function compactOneLine(text, max = MAX_SUMMARY_CHARS) {
97
+ return text.replace(/\s+/g, ' ').trim().slice(0, max);
98
+ }
99
+ function summarizePlannerResult(r) {
100
+ if (r.kind === 'ok') {
101
+ const ids = r.plan.groups.map((g) => g.id);
102
+ const preview = ids.slice(0, MAX_PREVIEW_IDS).join(', ');
103
+ const suffix = ids.length > MAX_PREVIEW_IDS ? `, +${ids.length - MAX_PREVIEW_IDS} more` : '';
104
+ return compactOneLine(`planner [ok]: ${r.plan.groups.length} group(s) — ${preview}${suffix}`);
105
+ }
106
+ if (r.kind === 'blocked')
107
+ return compactOneLine(`planner [blocked]: ${r.reason}`);
108
+ return compactOneLine(`planner [error]: ${r.error}`);
109
+ }
110
+ function summarizeWorkerResult(r) {
111
+ if (r.kind === 'ok') {
112
+ const d = r.delivery;
113
+ return compactOneLine(`worker [ok]: ${d.branch} — ${d.draftCommitMessage} (${d.changes.length} file(s))`);
114
+ }
115
+ if (r.kind === 'blocked')
116
+ return compactOneLine(`worker [blocked]: ${r.reason}`);
117
+ return compactOneLine(`worker [error]: ${r.error}`);
118
+ }
119
+ function summarizeReviewerResult(r) {
120
+ if (r.kind === 'ok') {
121
+ const counts = r.resolutions.reduce((acc, x) => {
122
+ acc[x.kind] = (acc[x.kind] ?? 0) + 1;
123
+ return acc;
124
+ }, {});
125
+ const parts = Object.entries(counts).map(([k, v]) => `${k}=${v}`);
126
+ const tail = parts.length > 0 ? ` — ${parts.join(', ')}` : '';
127
+ return compactOneLine(`reviewer [ok]: ${r.resolutions.length} resolution(s)${tail}`);
128
+ }
129
+ if (r.kind === 'blocked')
130
+ return compactOneLine(`reviewer [blocked]: ${r.reason}`);
131
+ return compactOneLine(`reviewer [error]: ${r.error}`);
132
+ }
133
+ //# sourceMappingURL=subagent-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagent-tools.js","sourceRoot":"","sources":["../../src/orchestrator/subagent-tools.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,+FAA+F;AAC/F,2FAA2F;AAC3F,gEAAgE;AAChE,EAAE;AACF,qEAAqE;AACrE,+EAA+E;AAC/E,EAAE;AACF,gBAAgB;AAChB,+EAA+E;AAC/E,gGAAgG;AAChG,kFAAkF;AAClF,yFAAyF;AAGzF,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EAGrB,UAAU,GACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EAGtB,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,oBAAoB,GAGrB,MAAM,wBAAwB,CAAC;AAoChC,MAAM,kBAAkB,GAAG,C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,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClE,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,OAAO,cAAc,CAAC,kBAAkB,CAAC,CAAC,WAAW,CAAC,MAAM,iBAAiB,IAAI,EAAE,CAAC,CAAC;IACvF,CAAC;IACD,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,cAAc,CAAC,uBAAuB,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACnF,OAAO,cAAc,CAAC,qBAAqB,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const ORCHESTRATOR_PREFIX: string;
2
+ export declare const PLANNER_PREFIX: string;
3
+ export declare const WORKER_PREFIX: string;
4
+ export declare const REVIEWER_PREFIX: string;
@@ -0,0 +1,78 @@
1
+ // Role system-prompt prefixes for each agent. Inlined per CLAUDE.md "no premature abstraction".
2
+ // Appended after `agentConfig.contents` (house style) to form the full instructions string.
3
+ export const ORCHESTRATOR_PREFIX = [
4
+ '',
5
+ '## Role: Orchestrator',
6
+ '',
7
+ 'You coordinate three subagents — Planner, Worker, Reviewer — each exposed as a tool.',
8
+ 'You see the whole plan and the rolling context, so you own per-PR prose:',
9
+ 'the final commit message and the PR title + body.',
10
+ '',
11
+ 'Flow:',
12
+ ' 1. Call the planner tool once to produce the PR-group DAG.',
13
+ ' 2. For each ready group, call the worker tool.',
14
+ ' 3. For each merged PR with unresolved review threads, call the reviewer tool.',
15
+ ' 4. Stop when every group is merged or blocked.',
16
+ '',
17
+ 'Rules:',
18
+ ' - SRP: one concern per PR group, one tool call per concern.',
19
+ ' - Be specific and terse. No marketing prose.',
20
+ ' - Conventional commit subjects, ≤72 chars.',
21
+ ].join('\n');
22
+ export const PLANNER_PREFIX = [
23
+ '',
24
+ '## Role: Planner',
25
+ '',
26
+ 'You receive a goal and optional acceptance criteria.',
27
+ 'You output a directed-acyclic plan of PR groups: each group is one cohesive pull request,',
28
+ 'roughly 300 lines of code, that can be reviewed independently.',
29
+ '',
30
+ 'Rules:',
31
+ ' - SRP: one coherent responsibility per PR group.',
32
+ ' - Ground the plan in the actual repo before emitting — use read-only tools.',
33
+ ' - Each group has a stable slug id, a one-line title, an ordered task list,',
34
+ ' and a dependsOn list of earlier group ids.',
35
+ ' - Prefer parallelizable siblings over a single linear chain.',
36
+ ' - Do not invent files. Do not propose work outside the repo.',
37
+ ' - Return JSON that matches the Plan schema exactly.',
38
+ ].join('\n');
39
+ export const WORKER_PREFIX = [
40
+ '',
41
+ '## Role: Worker',
42
+ '',
43
+ 'You receive one PR group: a coherent batch of tasks that land in a single pull request.',
44
+ 'Work in two phases.',
45
+ '',
46
+ 'Phase 1 — manifest. Use read-only tools to ground yourself in existing code,',
47
+ 'then emit a FileManifest JSON listing every file to create/modify/delete plus a',
48
+ 'one-line draft commit message. Do not edit yet.',
49
+ '',
50
+ 'Phase 2 — edits. Each manifest entry is handled by a dedicated editor subagent.',
51
+ '',
52
+ 'Rules:',
53
+ ' - SRP: one responsibility per file; split unrelated edits.',
54
+ ' - Stay inside the worktree provided. No work outside the repo.',
55
+ ' - draftCommitMessage subject ≤72 chars.',
56
+ ' - Return the FileManifest JSON exactly matching the schema.',
57
+ ].join('\n');
58
+ export const REVIEWER_PREFIX = [
59
+ '',
60
+ '## Role: Reviewer',
61
+ '',
62
+ 'You receive ONE unresolved PR review thread at a time and decide between three outcomes,',
63
+ 'emitting a ThreadResolutionOutput JSON.',
64
+ '',
65
+ '- "fixed": the reviewer is right — make the code change, reply explaining the fix,',
66
+ ' resolve the thread, emit { kind: "fixed", commitMessage }.',
67
+ '- "replied": a question/clarification only — answer via reply, no code change,',
68
+ ' emit { kind: "replied" }.',
69
+ '- "wontfix": stale, out-of-scope, or disagree — reply with reason, resolve the thread,',
70
+ ' emit { kind: "wontfix", reason }.',
71
+ '',
72
+ 'Rules:',
73
+ ' - SRP: one thread per invocation.',
74
+ ' - Stay inside the worktree. No work outside the repo.',
75
+ ' - Resolve the thread for "fixed" and "wontfix"; leave it open for "replied".',
76
+ ' - Return JSON that matches the ThreadResolutionOutput schema exactly.',
77
+ ].join('\n');
78
+ //# sourceMappingURL=system-prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-prompts.js","sourceRoot":"","sources":["../../src/orchestrator/system-prompts.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,4FAA4F;AAE5F,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,EAAE;IACF,uBAAuB;IACvB,EAAE;IACF,sFAAsF;IACtF,0EAA0E;IAC1E,mDAAmD;IACnD,EAAE;IACF,OAAO;IACP,8DAA8D;IAC9D,kDAAkD;IAClD,iFAAiF;IACjF,kDAAkD;IAClD,EAAE;IACF,QAAQ;IACR,+DAA+D;IAC/D,gDAAgD;IAChD,8CAA8C;CAC/C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,EAAE;IACF,kBAAkB;IAClB,EAAE;IACF,sDAAsD;IACtD,2FAA2F;IAC3F,gEAAgE;IAChE,EAAE;IACF,QAAQ;IACR,oDAAoD;IACpD,+EAA+E;IAC/E,8EAA8E;IAC9E,gDAAgD;IAChD,gEAAgE;IAChE,gEAAgE;IAChE,uDAAuD;CACxD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,EAAE;IACF,iBAAiB;IACjB,EAAE;IACF,yFAAyF;IACzF,qBAAqB;IACrB,EAAE;IACF,8EAA8E;IAC9E,iFAAiF;IACjF,iDAAiD;IACjD,EAAE;IACF,iFAAiF;IACjF,EAAE;IACF,QAAQ;IACR,8DAA8D;IAC9D,kEAAkE;IAClE,2CAA2C;IAC3C,+DAA+D;CAChE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,EAAE;IACF,mBAAmB;IACnB,EAAE;IACF,0FAA0F;IAC1F,yCAAyC;IACzC,EAAE;IACF,oFAAoF;IACpF,8DAA8D;IAC9D,gFAAgF;IAChF,6BAA6B;IAC7B,wFAAwF;IACxF,qCAAqC;IACrC,EAAE;IACF,QAAQ;IACR,qCAAqC;IACrC,yDAAyD;IACzD,gFAAgF;IAChF,yEAAyE;CAC1E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { PrGroup } from '../state/schema.ts';
2
+ export declare class PlanGraph {
3
+ private readonly groups;
4
+ private readonly index;
5
+ constructor(groups: ReadonlyArray<PrGroup>);
6
+ ready(): PrGroup[];
7
+ blocked(): PrGroup[];
8
+ byId(id: string): PrGroup | undefined;
9
+ isComplete(): boolean;
10
+ static validate(groups: ReadonlyArray<PrGroup>): void;
11
+ }
@@ -0,0 +1,69 @@
1
+ // Dependency DAG over PR groups. Drives concurrent execution in src/loop/work-loop.ts.
2
+ // Why a graph and not a list — docs/task-groups.md (extended): large goals split into
3
+ // independent PRs that can run in parallel. A linear list serializes work needlessly.
4
+ export class PlanGraph {
5
+ groups;
6
+ index;
7
+ constructor(groups) {
8
+ this.groups = groups;
9
+ PlanGraph.validate(groups);
10
+ this.index = new Map(groups.map((g) => [g.id, g]));
11
+ }
12
+ // Groups currently ready to run: status === 'pending' AND all deps merged.
13
+ ready() {
14
+ return this.groups.filter((g) => g.status === 'pending' &&
15
+ g.dependsOn.every((dep) => this.index.get(dep)?.status === 'merged'));
16
+ }
17
+ // Groups blocked on at least one unmerged dep.
18
+ blocked() {
19
+ return this.groups.filter((g) => g.status === 'pending' &&
20
+ g.dependsOn.some((dep) => this.index.get(dep)?.status !== 'merged'));
21
+ }
22
+ byId(id) {
23
+ return this.index.get(id);
24
+ }
25
+ // True when every group is in a terminal state (merged or blocked).
26
+ isComplete() {
27
+ return this.groups.every((g) => g.status === 'merged' || g.status === 'blocked');
28
+ }
29
+ // Static: detect cycles + dangling deps at plan-acceptance time.
30
+ // DFS coloring — white=unvisited, gray=on stack, black=fully explored.
31
+ static validate(groups) {
32
+ const ids = new Set();
33
+ for (const g of groups) {
34
+ if (ids.has(g.id)) {
35
+ throw new Error(`PlanGraph: duplicate group id '${g.id}'`);
36
+ }
37
+ ids.add(g.id);
38
+ }
39
+ for (const g of groups) {
40
+ for (const dep of g.dependsOn) {
41
+ if (!ids.has(dep)) {
42
+ throw new Error(`PlanGraph: group '${g.id}' depends on unknown group '${dep}'`);
43
+ }
44
+ }
45
+ }
46
+ const byId = new Map(groups.map((g) => [g.id, g]));
47
+ const color = new Map();
48
+ const visit = (id, path) => {
49
+ const state = color.get(id);
50
+ if (state === 'black')
51
+ return;
52
+ if (state === 'gray') {
53
+ const cycle = [...path.slice(path.indexOf(id)), id].join(' -> ');
54
+ throw new Error(`PlanGraph: cycle detected: ${cycle}`);
55
+ }
56
+ color.set(id, 'gray');
57
+ const node = byId.get(id);
58
+ if (node) {
59
+ for (const dep of node.dependsOn) {
60
+ visit(dep, [...path, id]);
61
+ }
62
+ }
63
+ color.set(id, 'black');
64
+ };
65
+ for (const g of groups)
66
+ visit(g.id, []);
67
+ }
68
+ }
69
+ //# sourceMappingURL=plan-graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-graph.js","sourceRoot":"","sources":["../../src/plan/plan-graph.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,sFAAsF;AACtF,sFAAsF;AAItF,MAAM,OAAO,SAAS;IAGS;IAFZ,KAAK,CAAuB;IAE7C,YAA6B,MAA8B;QAA9B,WAAM,GAAN,MAAM,CAAwB;QACzD,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,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AAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YACtB,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC1B,IAAI,IAAI,EAAE,CAAC;gBACT,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;oBACjC,KAAK,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;gBAC5B,CAAC;YACH,CAAC;YACD,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACzB,CAAC,CAAC;QAEF,KAAK,MAAM,CAAC,IAAI,MAAM;YAAE,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF"}
@@ -0,0 +1,30 @@
1
+ import { z } from 'zod';
2
+ export declare const PlannedTaskSchema: z.ZodObject<{
3
+ description: z.ZodString;
4
+ filesHint: z.ZodOptional<z.ZodArray<z.ZodString>>;
5
+ }, z.core.$strip>;
6
+ export type PlannedTask = z.infer<typeof PlannedTaskSchema>;
7
+ export declare const PlannedGroupSchema: z.ZodObject<{
8
+ id: z.ZodString;
9
+ title: z.ZodString;
10
+ tasks: z.ZodArray<z.ZodObject<{
11
+ description: z.ZodString;
12
+ filesHint: z.ZodOptional<z.ZodArray<z.ZodString>>;
13
+ }, z.core.$strip>>;
14
+ dependsOn: z.ZodDefault<z.ZodArray<z.ZodString>>;
15
+ }, z.core.$strip>;
16
+ export type PlannedGroup = z.infer<typeof PlannedGroupSchema>;
17
+ export declare const PlanSchema: z.ZodObject<{
18
+ goal: z.ZodString;
19
+ criteria: z.ZodOptional<z.ZodString>;
20
+ groups: z.ZodArray<z.ZodObject<{
21
+ id: z.ZodString;
22
+ title: z.ZodString;
23
+ tasks: z.ZodArray<z.ZodObject<{
24
+ description: z.ZodString;
25
+ filesHint: z.ZodOptional<z.ZodArray<z.ZodString>>;
26
+ }, z.core.$strip>>;
27
+ dependsOn: z.ZodDefault<z.ZodArray<z.ZodString>>;
28
+ }, z.core.$strip>>;
29
+ }, z.core.$strip>;
30
+ export type Plan = z.infer<typeof PlanSchema>;
@@ -0,0 +1,24 @@
1
+ // Plan-time output of Planner subagent — see docs/subagents.md §Roster (Planner row).
2
+ // PrGroup is persisted via src/state/schema.ts; the plan schema below is what
3
+ // Planner returns to the Orchestrator before that persistence step.
4
+ import { z } from 'zod';
5
+ export const PlannedTaskSchema = z.object({
6
+ description: z.string(),
7
+ // Optional file hint helps Worker plan its parallel file-edit fanout.
8
+ // See docs/vendor/ai-sdk/chunk-09.md §"Orchestrator-Worker" — Worker uses this
9
+ // to emit a file manifest, then Promise.all over per-file editor subagents.
10
+ filesHint: z.array(z.string()).optional(),
11
+ });
12
+ export const PlannedGroupSchema = z.object({
13
+ id: z.string(),
14
+ title: z.string(),
15
+ tasks: z.array(PlannedTaskSchema),
16
+ // Group ids that must merge before this group runs. Empty = root of DAG.
17
+ dependsOn: z.array(z.string()).default([]),
18
+ });
19
+ export const PlanSchema = z.object({
20
+ goal: z.string(),
21
+ criteria: z.string().optional(),
22
+ groups: z.array(PlannedGroupSchema),
23
+ });
24
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/plan/schema.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,8EAA8E;AAC9E,oEAAoE;AAEpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,sEAAsE;IACtE,+EAA+E;IAC/E,4EAA4E;IAC5E,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC1C,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC;IACjC,yEAAyE;IACzE,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CAC3C,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC;CACpC,CAAC,CAAC"}