whitesmith 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 (70) hide show
  1. package/dist/__tests__/task-manager.test.d.ts +2 -0
  2. package/dist/__tests__/task-manager.test.d.ts.map +1 -0
  3. package/dist/__tests__/task-manager.test.js +95 -0
  4. package/dist/__tests__/task-manager.test.js.map +1 -0
  5. package/dist/cli.d.ts +5 -0
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/cli.js +147 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/git.d.ts +60 -0
  10. package/dist/git.d.ts.map +1 -0
  11. package/dist/git.js +138 -0
  12. package/dist/git.js.map +1 -0
  13. package/dist/harnesses/agent-harness.d.ts +19 -0
  14. package/dist/harnesses/agent-harness.d.ts.map +1 -0
  15. package/dist/harnesses/agent-harness.js +2 -0
  16. package/dist/harnesses/agent-harness.js.map +1 -0
  17. package/dist/harnesses/index.d.ts +3 -0
  18. package/dist/harnesses/index.d.ts.map +1 -0
  19. package/dist/harnesses/index.js +2 -0
  20. package/dist/harnesses/index.js.map +1 -0
  21. package/dist/harnesses/pi.d.ts +23 -0
  22. package/dist/harnesses/pi.d.ts.map +1 -0
  23. package/dist/harnesses/pi.js +63 -0
  24. package/dist/harnesses/pi.js.map +1 -0
  25. package/dist/index.d.ts +11 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +8 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/orchestrator.d.ts +44 -0
  30. package/dist/orchestrator.d.ts.map +1 -0
  31. package/dist/orchestrator.js +241 -0
  32. package/dist/orchestrator.js.map +1 -0
  33. package/dist/prompts.d.ts +12 -0
  34. package/dist/prompts.d.ts.map +1 -0
  35. package/dist/prompts.js +112 -0
  36. package/dist/prompts.js.map +1 -0
  37. package/dist/providers/github.d.ts +34 -0
  38. package/dist/providers/github.d.ts.map +1 -0
  39. package/dist/providers/github.js +135 -0
  40. package/dist/providers/github.js.map +1 -0
  41. package/dist/providers/index.d.ts +3 -0
  42. package/dist/providers/index.d.ts.map +1 -0
  43. package/dist/providers/index.js +2 -0
  44. package/dist/providers/index.js.map +1 -0
  45. package/dist/providers/issue-provider.d.ts +59 -0
  46. package/dist/providers/issue-provider.d.ts.map +1 -0
  47. package/dist/providers/issue-provider.js +2 -0
  48. package/dist/providers/issue-provider.js.map +1 -0
  49. package/dist/task-manager.d.ts +57 -0
  50. package/dist/task-manager.d.ts.map +1 -0
  51. package/dist/task-manager.js +158 -0
  52. package/dist/task-manager.js.map +1 -0
  53. package/dist/types.d.ts +92 -0
  54. package/dist/types.d.ts.map +1 -0
  55. package/dist/types.js +14 -0
  56. package/dist/types.js.map +1 -0
  57. package/package.json +46 -0
  58. package/src/cli.ts +172 -0
  59. package/src/git.ts +148 -0
  60. package/src/harnesses/agent-harness.ts +15 -0
  61. package/src/harnesses/index.ts +2 -0
  62. package/src/harnesses/pi.ts +82 -0
  63. package/src/index.ts +13 -0
  64. package/src/orchestrator.ts +294 -0
  65. package/src/prompts.ts +114 -0
  66. package/src/providers/github.ts +180 -0
  67. package/src/providers/index.ts +2 -0
  68. package/src/providers/issue-provider.ts +59 -0
  69. package/src/task-manager.ts +190 -0
  70. package/src/types.ts +88 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,sBAAsB,EAAE,oBAAoB,EAAC,MAAM,cAAc,CAAC;AAE1E,YAAY,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAErD,YAAY,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAE5C,YAAY,EAAC,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AACrF,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export { Orchestrator } from './orchestrator.js';
2
+ export { TaskManager } from './task-manager.js';
3
+ export { GitManager } from './git.js';
4
+ export { buildInvestigatePrompt, buildImplementPrompt } from './prompts.js';
5
+ export { GitHubProvider } from './providers/github.js';
6
+ export { PiHarness } from './harnesses/pi.js';
7
+ export { LABELS } from './types.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,sBAAsB,EAAE,oBAAoB,EAAC,MAAM,cAAc,CAAC;AAG1E,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { DevPulseConfig } from './types.js';
2
+ import type { IssueProvider } from './providers/issue-provider.js';
3
+ import type { AgentHarness } from './harnesses/agent-harness.js';
4
+ /**
5
+ * Main orchestrator for whitesmith.
6
+ *
7
+ * The loop:
8
+ * 1. Reconcile — check if any issues with tasks-accepted have all tasks done
9
+ * 2. Investigate — pick an unlabeled issue, generate tasks
10
+ * 3. Implement — pick an available task, implement it
11
+ */
12
+ export declare class Orchestrator {
13
+ private config;
14
+ private issues;
15
+ private agent;
16
+ private tasks;
17
+ private git;
18
+ constructor(config: DevPulseConfig, issues: IssueProvider, agent: AgentHarness);
19
+ /**
20
+ * Run the main loop
21
+ */
22
+ run(): Promise<void>;
23
+ /**
24
+ * Decide the next action to take
25
+ */
26
+ private decideAction;
27
+ /**
28
+ * Find an available task to implement
29
+ */
30
+ private findAvailableTask;
31
+ /**
32
+ * Phase 1: Reconcile — mark issue as completed, close it
33
+ */
34
+ private reconcile;
35
+ /**
36
+ * Phase 2: Investigate — generate tasks for a new issue
37
+ */
38
+ private investigate;
39
+ /**
40
+ * Phase 3: Implement — implement a task and create a PR
41
+ */
42
+ private implement;
43
+ }
44
+ //# sourceMappingURL=orchestrator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAsB,MAAM,YAAY,CAAC;AAEpE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAK/D;;;;;;;GAOG;AACH,qBAAa,YAAY;IACxB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,GAAG,CAAa;gBAEZ,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,YAAY;IAQ9E;;OAEG;IACG,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IA+C1B;;OAEG;YACW,YAAY;IA2B1B;;OAEG;YACW,iBAAiB;IA0B/B;;OAEG;YACW,SAAS;IAevB;;OAEG;YACW,WAAW;IA4EzB;;OAEG;YACW,SAAS;CAqDvB"}
@@ -0,0 +1,241 @@
1
+ import { LABELS } from './types.js';
2
+ import { TaskManager } from './task-manager.js';
3
+ import { GitManager } from './git.js';
4
+ import { buildInvestigatePrompt, buildImplementPrompt } from './prompts.js';
5
+ /**
6
+ * Main orchestrator for whitesmith.
7
+ *
8
+ * The loop:
9
+ * 1. Reconcile — check if any issues with tasks-accepted have all tasks done
10
+ * 2. Investigate — pick an unlabeled issue, generate tasks
11
+ * 3. Implement — pick an available task, implement it
12
+ */
13
+ export class Orchestrator {
14
+ config;
15
+ issues;
16
+ agent;
17
+ tasks;
18
+ git;
19
+ constructor(config, issues, agent) {
20
+ this.config = config;
21
+ this.issues = issues;
22
+ this.agent = agent;
23
+ this.tasks = new TaskManager(config.workDir);
24
+ this.git = new GitManager(config.workDir);
25
+ }
26
+ /**
27
+ * Run the main loop
28
+ */
29
+ async run() {
30
+ console.log('=== whitesmith ===');
31
+ console.log(`Working directory: ${this.config.workDir}`);
32
+ console.log(`Max iterations: ${this.config.maxIterations}`);
33
+ console.log(`Agent command: ${this.config.agentCmd}`);
34
+ console.log('');
35
+ // Ensure labels exist
36
+ await this.issues.ensureLabels(Object.values(LABELS));
37
+ for (let i = 1; i <= this.config.maxIterations; i++) {
38
+ console.log('');
39
+ console.log(`=== Iteration ${i}/${this.config.maxIterations} ===`);
40
+ // Make sure we're on main with latest
41
+ await this.git.fetch();
42
+ await this.git.checkoutMain();
43
+ // Decide what to do
44
+ const action = await this.decideAction();
45
+ console.log(`Action: ${action.type}`);
46
+ switch (action.type) {
47
+ case 'reconcile':
48
+ await this.reconcile(action.issue);
49
+ break;
50
+ case 'investigate':
51
+ await this.investigate(action.issue);
52
+ break;
53
+ case 'implement':
54
+ await this.implement(action.task, action.issue);
55
+ break;
56
+ case 'idle':
57
+ console.log('Nothing to do. All issues are either in-progress or completed.');
58
+ return;
59
+ }
60
+ if (!this.config.noSleep && i < this.config.maxIterations) {
61
+ console.log('Sleeping 5s...');
62
+ await new Promise((r) => setTimeout(r, 5000));
63
+ }
64
+ }
65
+ console.log('');
66
+ console.log('=== Iteration limit reached ===');
67
+ }
68
+ /**
69
+ * Decide the next action to take
70
+ */
71
+ async decideAction() {
72
+ // Priority 1: Reconcile — issues with tasks-accepted where all tasks are done
73
+ const acceptedIssues = await this.issues.listIssues({ labels: [LABELS.TASKS_ACCEPTED] });
74
+ for (const issue of acceptedIssues) {
75
+ if (!this.tasks.hasRemainingTasks(issue.number)) {
76
+ return { type: 'reconcile', issue };
77
+ }
78
+ }
79
+ // Priority 2: Implement — find an available task
80
+ const implementAction = await this.findAvailableTask(acceptedIssues);
81
+ if (implementAction) {
82
+ return implementAction;
83
+ }
84
+ // Priority 3: Investigate — find a new issue (no whitesmith labels)
85
+ const allDevPulseLabels = Object.values(LABELS);
86
+ const newIssues = await this.issues.listIssues({ noLabels: allDevPulseLabels });
87
+ if (newIssues.length > 0) {
88
+ // Pick the oldest issue
89
+ const issue = newIssues[newIssues.length - 1];
90
+ return { type: 'investigate', issue };
91
+ }
92
+ return { type: 'idle' };
93
+ }
94
+ /**
95
+ * Find an available task to implement
96
+ */
97
+ async findAvailableTask(acceptedIssues) {
98
+ for (const issue of acceptedIssues) {
99
+ const issueTasks = this.tasks.listTasks(issue.number);
100
+ for (const task of issueTasks) {
101
+ // Check dependencies are satisfied
102
+ if (!this.tasks.areDependenciesSatisfied(task)) {
103
+ continue;
104
+ }
105
+ // Check if someone is already working on it (branch exists)
106
+ const branch = `task/${task.id}`;
107
+ const branchExists = await this.issues.remoteBranchExists(branch);
108
+ if (branchExists) {
109
+ continue;
110
+ }
111
+ return { type: 'implement', task, issue };
112
+ }
113
+ }
114
+ return null;
115
+ }
116
+ /**
117
+ * Phase 1: Reconcile — mark issue as completed, close it
118
+ */
119
+ async reconcile(issue) {
120
+ console.log(`Reconciling issue #${issue.number}: ${issue.title}`);
121
+ console.log('All tasks completed. Marking issue as done.');
122
+ await this.issues.addLabel(issue.number, LABELS.COMPLETED);
123
+ await this.issues.removeLabel(issue.number, LABELS.TASKS_ACCEPTED);
124
+ await this.issues.comment(issue.number, `✅ All tasks for this issue have been implemented and merged. Closing.`);
125
+ await this.issues.closeIssue(issue.number);
126
+ console.log(`Issue #${issue.number} closed.`);
127
+ }
128
+ /**
129
+ * Phase 2: Investigate — generate tasks for a new issue
130
+ */
131
+ async investigate(issue) {
132
+ console.log(`Investigating issue #${issue.number}: ${issue.title}`);
133
+ // Claim the issue
134
+ await this.issues.addLabel(issue.number, LABELS.INVESTIGATING);
135
+ const branch = `investigate/${issue.number}`;
136
+ const issueTasksDir = `tasks/${issue.number}`;
137
+ try {
138
+ // Create branch from main
139
+ await this.git.deleteLocalBranch(branch);
140
+ await this.git.checkout(branch, { create: true, startPoint: 'origin/main' });
141
+ // Run agent to generate tasks
142
+ const prompt = buildInvestigatePrompt(issue, issueTasksDir);
143
+ const { exitCode } = await this.agent.run({
144
+ prompt,
145
+ workDir: this.config.workDir,
146
+ logFile: this.config.logFile,
147
+ });
148
+ if (exitCode !== 0) {
149
+ console.error(`Agent failed with exit code ${exitCode}`);
150
+ await this.issues.removeLabel(issue.number, LABELS.INVESTIGATING);
151
+ await this.git.checkoutMain();
152
+ return;
153
+ }
154
+ // Verify task files were created
155
+ await this.git.verifyBranch(branch);
156
+ const tasks = this.tasks.listTasks(issue.number);
157
+ if (tasks.length === 0) {
158
+ console.error('Agent did not create any task files');
159
+ await this.issues.removeLabel(issue.number, LABELS.INVESTIGATING);
160
+ await this.git.checkoutMain();
161
+ return;
162
+ }
163
+ // Ensure changes are committed
164
+ await this.git.commitAll(`tasks(#${issue.number}): generate implementation tasks`);
165
+ console.log(`Generated ${tasks.length} task(s) for issue #${issue.number}`);
166
+ if (this.config.noPush) {
167
+ console.log(`Branch '${branch}' ready (--no-push mode)`);
168
+ }
169
+ else {
170
+ // Push and create PR
171
+ await this.git.push(branch);
172
+ const taskList = tasks.map((t) => `- [ ] **${t.id}**: ${t.title}`).join('\n');
173
+ const prUrl = await this.issues.createPR({
174
+ head: branch,
175
+ base: 'main',
176
+ title: `tasks(#${issue.number}): ${issue.title}`,
177
+ body: `## Generated Tasks for #${issue.number}\n\n${taskList}\n\n---\n*Generated by whitesmith from issue #${issue.number}*`,
178
+ });
179
+ await this.issues.removeLabel(issue.number, LABELS.INVESTIGATING);
180
+ await this.issues.addLabel(issue.number, LABELS.TASKS_PROPOSED);
181
+ await this.issues.comment(issue.number, `📋 Tasks have been generated. Review the PR: ${prUrl}`);
182
+ console.log(`PR created: ${prUrl}`);
183
+ }
184
+ }
185
+ catch (error) {
186
+ console.error('Investigation failed:', error instanceof Error ? error.message : error);
187
+ await this.issues.removeLabel(issue.number, LABELS.INVESTIGATING);
188
+ }
189
+ // Return to main
190
+ await this.git.checkoutMain();
191
+ }
192
+ /**
193
+ * Phase 3: Implement — implement a task and create a PR
194
+ */
195
+ async implement(task, issue) {
196
+ console.log(`Implementing task ${task.id}: ${task.title}`);
197
+ console.log(`For issue #${issue.number}: ${issue.title}`);
198
+ const branch = `task/${task.id}`;
199
+ try {
200
+ // Create branch from main
201
+ await this.git.deleteLocalBranch(branch);
202
+ await this.git.checkout(branch, { create: true, startPoint: 'origin/main' });
203
+ // Run agent to implement
204
+ const prompt = buildImplementPrompt(task, issue);
205
+ const { exitCode } = await this.agent.run({
206
+ prompt,
207
+ workDir: this.config.workDir,
208
+ logFile: this.config.logFile,
209
+ });
210
+ if (exitCode !== 0) {
211
+ console.error(`Agent failed with exit code ${exitCode}`);
212
+ await this.git.checkoutMain();
213
+ return;
214
+ }
215
+ // Verify we're still on the right branch
216
+ await this.git.verifyBranch(branch);
217
+ // Ensure changes are committed
218
+ await this.git.commitAll(`feat(#${issue.number}): ${task.title}`);
219
+ if (this.config.noPush) {
220
+ console.log(`Branch '${branch}' ready (--no-push mode)`);
221
+ }
222
+ else {
223
+ // Push and create PR
224
+ await this.git.push(branch);
225
+ const prUrl = await this.issues.createPR({
226
+ head: branch,
227
+ base: 'main',
228
+ title: `feat(#${issue.number}): ${task.title}`,
229
+ body: `## Task: ${task.title}\n\nImplements task \`${task.id}\` from issue #${issue.number}.\n\n### From the task spec:\n\n${task.content}\n\n---\n*Implemented by whitesmith*\n\nCloses #${issue.number} (if all tasks are complete)`,
230
+ });
231
+ console.log(`PR created: ${prUrl}`);
232
+ }
233
+ }
234
+ catch (error) {
235
+ console.error('Implementation failed:', error instanceof Error ? error.message : error);
236
+ }
237
+ // Return to main
238
+ await this.git.checkoutMain();
239
+ }
240
+ }
241
+ //# sourceMappingURL=orchestrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;AAGlC,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,sBAAsB,EAAE,oBAAoB,EAAC,MAAM,cAAc,CAAC;AAE1E;;;;;;;GAOG;AACH,MAAM,OAAO,YAAY;IAChB,MAAM,CAAiB;IACvB,MAAM,CAAgB;IACtB,KAAK,CAAe;IACpB,KAAK,CAAc;IACnB,GAAG,CAAa;IAExB,YAAY,MAAsB,EAAE,MAAqB,EAAE,KAAmB;QAC7E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAI,CAAC,GAAG,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG;QACR,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,mB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AS,CAAC,SAAS,KAAK,CAAC,MAAM,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;YAElE,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACxB,OAAO,CAAC,GAAG,CAAC,WAAW,MAAM,0BAA0B,CAAC,CAAC;YAC1D,CAAC;iBAAM,CAAC;gBACP,qBAAqB;gBACrB,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAE5B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;oBACxC,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,MAAM;oBACZ,KAAK,EAAE,SAAS,KAAK,CAAC,MAAM,MAAM,IAAI,CAAC,KAAK,EAAE;oBAC9C,IAAI,EAAE,YAAY,IAAI,CAAC,KAAK,yBAAyB,IAAI,CAAC,EAAE,kBAAkB,KAAK,CAAC,MAAM,mCAAmC,IAAI,CAAC,OAAO,mDAAmD,KAAK,CAAC,MAAM,8BAA8B;iBACtO,CAAC,CAAC;gBAEH,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,EAAE,CAAC,CAAC;YACrC,CAAC;QACF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACzF,CAAC;QAED,iBAAiB;QACjB,MAAM,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;IAC/B,CAAC;CACD"}
@@ -0,0 +1,12 @@
1
+ import type { Issue, Task } from './types.js';
2
+ /**
3
+ * Build the prompt for the "investigate" phase.
4
+ * The agent reads the issue, understands the codebase, and generates task files.
5
+ */
6
+ export declare function buildInvestigatePrompt(issue: Issue, issueTasksDir: string): string;
7
+ /**
8
+ * Build the prompt for the "implement" phase.
9
+ * The agent implements a specific task and deletes the task file.
10
+ */
11
+ export declare function buildImplementPrompt(task: Task, issue: Issue): string;
12
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,YAAY,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CA8DlF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAuCrE"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Build the prompt for the "investigate" phase.
3
+ * The agent reads the issue, understands the codebase, and generates task files.
4
+ */
5
+ export function buildInvestigatePrompt(issue, issueTasksDir) {
6
+ return `# Task: Generate implementation tasks for Issue #${issue.number}
7
+
8
+ ## Issue
9
+ **Title:** ${issue.title}
10
+ **URL:** ${issue.url}
11
+
12
+ ### Description
13
+ ${issue.body}
14
+
15
+ ## Your Job
16
+
17
+ You are an AI assistant helping break down a GitHub issue into concrete implementation tasks.
18
+
19
+ 1. **Read and understand** the issue above.
20
+ 2. **Explore the codebase** to understand the architecture, conventions, and relevant code.
21
+ 3. **Break the issue down** into 1 or more tasks. Each task should represent a single, reviewable PR's worth of work.
22
+ 4. **Write task files** to the \`${issueTasksDir}\` directory.
23
+
24
+ ## Task File Format
25
+
26
+ Each task file should be named \`<seq>-<short-slug>.md\` (e.g., \`001-add-validation.md\`) and contain:
27
+
28
+ \`\`\`markdown
29
+ ---
30
+ id: "${issue.number}-<seq>"
31
+ issue: ${issue.number}
32
+ title: "<concise title>"
33
+ depends_on: []
34
+ ---
35
+
36
+ ## Description
37
+ <detailed description of what needs to be done>
38
+
39
+ ## Acceptance Criteria
40
+ - <criterion 1>
41
+ - <criterion 2>
42
+
43
+ ## Implementation Notes
44
+ <any relevant notes about approach, files to modify, etc.>
45
+ \`\`\`
46
+
47
+ ## Rules
48
+
49
+ - Sequence numbers start at 001 and increment.
50
+ - The \`id\` field must be \`"${issue.number}-<seq>"\` (e.g., "${issue.number}-001").
51
+ - Use \`depends_on\` to list task IDs that must be completed before this task. For example, if task 002 depends on task 001, set \`depends_on: ["${issue.number}-001"]\`.
52
+ - Each task should be a meaningful, self-contained unit of work that results in one PR.
53
+ - Be specific in descriptions and acceptance criteria — another AI agent will implement these.
54
+ - Consider the existing codebase patterns and conventions.
55
+ - Create the \`${issueTasksDir}\` directory if it doesn't exist.
56
+
57
+ ## When Done
58
+
59
+ After creating all task files, commit your changes:
60
+ \`\`\`
61
+ git add tasks/
62
+ git commit -m "tasks(#${issue.number}): generate implementation tasks"
63
+ \`\`\`
64
+
65
+ Do NOT push. Do NOT create a PR. The orchestrator will handle that.
66
+ `;
67
+ }
68
+ /**
69
+ * Build the prompt for the "implement" phase.
70
+ * The agent implements a specific task and deletes the task file.
71
+ */
72
+ export function buildImplementPrompt(task, issue) {
73
+ return `# Task: Implement "${task.title}"
74
+
75
+ ## Context
76
+
77
+ You are implementing a task generated from GitHub Issue #${issue.number}: "${issue.title}"
78
+
79
+ **Issue URL:** ${issue.url}
80
+ **Task ID:** ${task.id}
81
+ **Task File:** ${task.filePath}
82
+
83
+ ## Task Details
84
+
85
+ ${task.content}
86
+
87
+ ## Your Job
88
+
89
+ 1. **Read the task** above carefully.
90
+ 2. **Explore the codebase** to understand the architecture and conventions.
91
+ 3. **Implement the changes** described in the task.
92
+ 4. **Verify** your implementation meets the acceptance criteria.
93
+ 5. **Delete the task file** at \`${task.filePath}\` — this marks the task as complete.
94
+ 6. **Clean up**: if the task directory \`tasks/${task.issue}/\` is now empty, delete it too.
95
+ 7. **Commit** all changes (implementation + task file deletion):
96
+
97
+ \`\`\`
98
+ git add -A
99
+ git commit -m "feat(#${issue.number}): ${task.title}"
100
+ \`\`\`
101
+
102
+ ## Rules
103
+
104
+ - Follow existing code conventions and patterns.
105
+ - Make clean, reviewable changes.
106
+ - Do NOT push. Do NOT create a PR. The orchestrator will handle that.
107
+ - Do NOT modify other task files.
108
+ - You MUST delete \`${task.filePath}\` as part of your commit.
109
+ - If the \`tasks/${task.issue}/\` directory is empty after deletion, remove it.
110
+ `;
111
+ }
112
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAY,EAAE,aAAqB;IACzE,OAAO,oDAAoD,KAAK,CAAC,MAAM;;;aAG3D,KAAK,CAAC,KAAK;WACb,KAAK,CAAC,GAAG;;;EAGlB,KAAK,CAAC,IAAI;;;;;;;;;mCASuB,aAAa;;;;;;;;OAQzC,KAAK,CAAC,MAAM;SACV,KAAK,CAAC,MAAM;;;;;;;;;;;;;;;;;;;gCAmBW,KAAK,CAAC,MAAM,qBAAqB,KAAK,CAAC,MAAM;mJACsE,KAAK,CAAC,MAAM;;;;iBAI9I,aAAa;;;;;;;wBAON,KAAK,CAAC,MAAM;;;;CAInC,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAU,EAAE,KAAY;IAC5D,OAAO,sBAAsB,IAAI,CAAC,KAAK;;;;2DAImB,KAAK,CAAC,MAAM,MAAM,KAAK,CAAC,KAAK;;iBAEvE,KAAK,CAAC,GAAG;eACX,IAAI,CAAC,EAAE;iBACL,IAAI,CAAC,QAAQ;;;;EAI5B,IAAI,CAAC,OAAO;;;;;;;;mCAQqB,IAAI,CAAC,QAAQ;iDACC,IAAI,CAAC,KAAK;;;;;uBAKpC,KAAK,CAAC,MAAM,MAAM,IAAI,CAAC,KAAK;;;;;;;;;sBAS7B,IAAI,CAAC,QAAQ;mBAChB,IAAI,CAAC,KAAK;CAC5B,CAAC;AACF,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { IssueProvider } from './issue-provider.js';
2
+ import type { Issue } from '../types.js';
3
+ /**
4
+ * GitHub Issues provider using the `gh` CLI.
5
+ */
6
+ export declare class GitHubProvider implements IssueProvider {
7
+ private workDir;
8
+ private repo?;
9
+ constructor(workDir: string, repo?: string);
10
+ private repoFlag;
11
+ private gh;
12
+ listIssues(options?: {
13
+ labels?: string[];
14
+ noLabels?: string[];
15
+ }): Promise<Issue[]>;
16
+ getIssue(number: number): Promise<Issue>;
17
+ addLabel(number: number, label: string): Promise<void>;
18
+ removeLabel(number: number, label: string): Promise<void>;
19
+ comment(number: number, body: string): Promise<void>;
20
+ closeIssue(number: number): Promise<void>;
21
+ createPR(options: {
22
+ head: string;
23
+ base: string;
24
+ title: string;
25
+ body: string;
26
+ }): Promise<string>;
27
+ remoteBranchExists(branch: string): Promise<boolean>;
28
+ getPRForBranch(branch: string): Promise<{
29
+ state: 'open' | 'merged' | 'closed';
30
+ url: string;
31
+ } | null>;
32
+ ensureLabels(labels: string[]): Promise<void>;
33
+ }
34
+ //# sourceMappingURL=github.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/providers/github.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,aAAa,CAAC;AAIvC;;GAEG;AACH,qBAAa,cAAe,YAAW,aAAa;IACnD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,IAAI,CAAC,CAAS;gBAEV,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAK1C,OAAO,CAAC,QAAQ;YAIF,EAAE;IAiBV,UAAU,CAAC,OAAO,CAAC,EAAE;QAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;KAAC,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAkChF,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAkBxC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQzD,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAapD,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,QAAQ,CAAC,OAAO,EAAE;QACvB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KACb,GAAG,OAAO,CAAC,MAAM,CAAC;IAab,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAWpD,cAAc,CACnB,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAC,GAAG,IAAI,CAAC;IAgB/D,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAWnD"}
@@ -0,0 +1,135 @@
1
+ import { exec } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+ const execAsync = promisify(exec);
4
+ /**
5
+ * GitHub Issues provider using the `gh` CLI.
6
+ */
7
+ export class GitHubProvider {
8
+ workDir;
9
+ repo;
10
+ constructor(workDir, repo) {
11
+ this.workDir = workDir;
12
+ this.repo = repo;
13
+ }
14
+ repoFlag() {
15
+ return this.repo ? ` --repo ${this.repo}` : '';
16
+ }
17
+ async gh(args) {
18
+ try {
19
+ const { stdout } = await execAsync(`gh ${args}${this.repoFlag()}`, {
20
+ cwd: this.workDir,
21
+ maxBuffer: 10 * 1024 * 1024,
22
+ });
23
+ return stdout.trim();
24
+ }
25
+ catch (error) {
26
+ const e = error;
27
+ // Some gh commands return exit code 1 for "not found" results
28
+ if (e.stdout !== undefined) {
29
+ return e.stdout.trim();
30
+ }
31
+ throw new Error(`gh ${args} failed: ${e.stderr || e.message}`);
32
+ }
33
+ }
34
+ async listIssues(options) {
35
+ let cmd = 'issue list --state open --json number,title,body,labels,url --limit 100';
36
+ if (options?.labels && options.labels.length > 0) {
37
+ cmd += ` --label "${options.labels.join(',')}"`;
38
+ }
39
+ const raw = await this.gh(cmd);
40
+ if (!raw || raw === '[]')
41
+ return [];
42
+ const issues = JSON.parse(raw);
43
+ let result = issues.map((i) => ({
44
+ number: i.number,
45
+ title: i.title,
46
+ body: i.body || '',
47
+ labels: i.labels.map((l) => l.name),
48
+ url: i.url,
49
+ }));
50
+ // Client-side filter for "no labels" (gh CLI doesn't support negation)
51
+ if (options?.noLabels && options.noLabels.length > 0) {
52
+ result = result.filter((issue) => !issue.labels.some((l) => options.noLabels.includes(l)));
53
+ }
54
+ return result;
55
+ }
56
+ async getIssue(number) {
57
+ const raw = await this.gh(`issue view ${number} --json number,title,body,labels,url`);
58
+ const i = JSON.parse(raw);
59
+ return {
60
+ number: i.number,
61
+ title: i.title,
62
+ body: i.body || '',
63
+ labels: i.labels.map((l) => l.name),
64
+ url: i.url,
65
+ };
66
+ }
67
+ async addLabel(number, label) {
68
+ await this.gh(`issue edit ${number} --add-label "${label}"`);
69
+ }
70
+ async removeLabel(number, label) {
71
+ try {
72
+ await this.gh(`issue edit ${number} --remove-label "${label}"`);
73
+ }
74
+ catch {
75
+ // Ignore if label wasn't present
76
+ }
77
+ }
78
+ async comment(number, body) {
79
+ // Use stdin to avoid shell escaping issues
80
+ await new Promise((resolve, reject) => {
81
+ const child = exec(`gh issue comment ${number} --body-file -${this.repoFlag()}`, { cwd: this.workDir }, (err) => (err ? reject(err) : resolve()));
82
+ child.stdin.write(body);
83
+ child.stdin.end();
84
+ });
85
+ }
86
+ async closeIssue(number) {
87
+ await this.gh(`issue close ${number}`);
88
+ }
89
+ async createPR(options) {
90
+ const url = await new Promise((resolve, reject) => {
91
+ const child = exec(`gh pr create --head "${options.head}" --base "${options.base}" --title "${options.title}" --body-file -${this.repoFlag()}`, { cwd: this.workDir }, (err, stdout) => (err ? reject(err) : resolve(stdout.trim())));
92
+ child.stdin.write(options.body);
93
+ child.stdin.end();
94
+ });
95
+ return url;
96
+ }
97
+ async remoteBranchExists(branch) {
98
+ try {
99
+ const { stdout } = await execAsync(`git ls-remote --heads origin ${branch}`, {
100
+ cwd: this.workDir,
101
+ });
102
+ return stdout.trim().length > 0;
103
+ }
104
+ catch {
105
+ return false;
106
+ }
107
+ }
108
+ async getPRForBranch(branch) {
109
+ try {
110
+ const raw = await this.gh(`pr list --head "${branch}" --state all --json state,url --limit 1`);
111
+ if (!raw || raw === '[]')
112
+ return null;
113
+ const prs = JSON.parse(raw);
114
+ if (prs.length === 0)
115
+ return null;
116
+ const pr = prs[0];
117
+ const state = pr.state.toLowerCase();
118
+ return { state, url: pr.url };
119
+ }
120
+ catch {
121
+ return null;
122
+ }
123
+ }
124
+ async ensureLabels(labels) {
125
+ for (const label of labels) {
126
+ try {
127
+ await this.gh(`label create "${label}" --force --color 7B68EE --description "whitesmith automation"`);
128
+ }
129
+ catch {
130
+ // Label might already exist
131
+ }
132
+ }
133
+ }
134
+ }
135
+ //# sourceMappingURL=github.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.js","sourceRoot":"","sources":["../../src/providers/github.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AAIpC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC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I,CAAC;YACtC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAwC,CAAC;YACnE,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;YAClC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YAClB,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,EAAkC,CAAC;YACrE,OAAO,EAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAC,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAAgB;QAClC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC5B,IAAI,CAAC;gBACJ,MAAM,IAAI,CAAC,EAAE,CACZ,iBAAiB,KAAK,gEAAgE,CACtF,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACR,4BAA4B;YAC7B,CAAC;QACF,CAAC;IACF,CAAC;CACD"}
@@ -0,0 +1,3 @@
1
+ export type { IssueProvider } from './issue-provider.js';
2
+ export { GitHubProvider } from './github.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { GitHubProvider } from './github.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC"}