@promptwheel/mcp 0.6.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 (134) hide show
  1. package/README.md +178 -0
  2. package/dist/advance-helpers.d.ts +27 -0
  3. package/dist/advance-helpers.d.ts.map +1 -0
  4. package/dist/advance-helpers.js +127 -0
  5. package/dist/advance-helpers.js.map +1 -0
  6. package/dist/advance-prompts.d.ts +48 -0
  7. package/dist/advance-prompts.d.ts.map +1 -0
  8. package/dist/advance-prompts.js +420 -0
  9. package/dist/advance-prompts.js.map +1 -0
  10. package/dist/advance.d.ts +30 -0
  11. package/dist/advance.d.ts.map +1 -0
  12. package/dist/advance.js +752 -0
  13. package/dist/advance.js.map +1 -0
  14. package/dist/codebase-index.d.ts +5 -0
  15. package/dist/codebase-index.d.ts.map +1 -0
  16. package/dist/codebase-index.js +5 -0
  17. package/dist/codebase-index.js.map +1 -0
  18. package/dist/dedup-memory.d.ts +30 -0
  19. package/dist/dedup-memory.d.ts.map +1 -0
  20. package/dist/dedup-memory.js +76 -0
  21. package/dist/dedup-memory.js.map +1 -0
  22. package/dist/direct-client.d.ts +57 -0
  23. package/dist/direct-client.d.ts.map +1 -0
  24. package/dist/direct-client.js +92 -0
  25. package/dist/direct-client.js.map +1 -0
  26. package/dist/event-handlers-qa.d.ts +5 -0
  27. package/dist/event-handlers-qa.d.ts.map +1 -0
  28. package/dist/event-handlers-qa.js +186 -0
  29. package/dist/event-handlers-qa.js.map +1 -0
  30. package/dist/event-handlers-scout.d.ts +5 -0
  31. package/dist/event-handlers-scout.d.ts.map +1 -0
  32. package/dist/event-handlers-scout.js +270 -0
  33. package/dist/event-handlers-scout.js.map +1 -0
  34. package/dist/event-handlers-ticket.d.ts +5 -0
  35. package/dist/event-handlers-ticket.d.ts.map +1 -0
  36. package/dist/event-handlers-ticket.js +232 -0
  37. package/dist/event-handlers-ticket.js.map +1 -0
  38. package/dist/event-helpers.d.ts +46 -0
  39. package/dist/event-helpers.d.ts.map +1 -0
  40. package/dist/event-helpers.js +125 -0
  41. package/dist/event-helpers.js.map +1 -0
  42. package/dist/event-processor.d.ts +15 -0
  43. package/dist/event-processor.d.ts.map +1 -0
  44. package/dist/event-processor.js +111 -0
  45. package/dist/event-processor.js.map +1 -0
  46. package/dist/formulas.d.ts +27 -0
  47. package/dist/formulas.d.ts.map +1 -0
  48. package/dist/formulas.js +109 -0
  49. package/dist/formulas.js.map +1 -0
  50. package/dist/guidelines.d.ts +16 -0
  51. package/dist/guidelines.d.ts.map +1 -0
  52. package/dist/guidelines.js +44 -0
  53. package/dist/guidelines.js.map +1 -0
  54. package/dist/index.d.ts +9 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +42 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/learnings.d.ts +42 -0
  59. package/dist/learnings.d.ts.map +1 -0
  60. package/dist/learnings.js +117 -0
  61. package/dist/learnings.js.map +1 -0
  62. package/dist/project-metadata.d.ts +34 -0
  63. package/dist/project-metadata.d.ts.map +1 -0
  64. package/dist/project-metadata.js +617 -0
  65. package/dist/project-metadata.js.map +1 -0
  66. package/dist/proposals.d.ts +23 -0
  67. package/dist/proposals.d.ts.map +1 -0
  68. package/dist/proposals.js +201 -0
  69. package/dist/proposals.js.map +1 -0
  70. package/dist/qa-stats.d.ts +51 -0
  71. package/dist/qa-stats.d.ts.map +1 -0
  72. package/dist/qa-stats.js +121 -0
  73. package/dist/qa-stats.js.map +1 -0
  74. package/dist/run-manager.d.ts +97 -0
  75. package/dist/run-manager.d.ts.map +1 -0
  76. package/dist/run-manager.js +583 -0
  77. package/dist/run-manager.js.map +1 -0
  78. package/dist/run-state-bridge.d.ts +13 -0
  79. package/dist/run-state-bridge.d.ts.map +1 -0
  80. package/dist/run-state-bridge.js +101 -0
  81. package/dist/run-state-bridge.js.map +1 -0
  82. package/dist/scope-policy.d.ts +83 -0
  83. package/dist/scope-policy.d.ts.map +1 -0
  84. package/dist/scope-policy.js +278 -0
  85. package/dist/scope-policy.js.map +1 -0
  86. package/dist/server.d.ts +18 -0
  87. package/dist/server.d.ts.map +1 -0
  88. package/dist/server.js +35 -0
  89. package/dist/server.js.map +1 -0
  90. package/dist/spindle.d.ts +41 -0
  91. package/dist/spindle.d.ts.map +1 -0
  92. package/dist/spindle.js +230 -0
  93. package/dist/spindle.js.map +1 -0
  94. package/dist/state.d.ts +36 -0
  95. package/dist/state.d.ts.map +1 -0
  96. package/dist/state.js +50 -0
  97. package/dist/state.js.map +1 -0
  98. package/dist/ticket-worker.d.ts +37 -0
  99. package/dist/ticket-worker.d.ts.map +1 -0
  100. package/dist/ticket-worker.js +527 -0
  101. package/dist/ticket-worker.js.map +1 -0
  102. package/dist/tool-registry.d.ts +35 -0
  103. package/dist/tool-registry.d.ts.map +1 -0
  104. package/dist/tool-registry.js +129 -0
  105. package/dist/tool-registry.js.map +1 -0
  106. package/dist/tools/execute.d.ts +17 -0
  107. package/dist/tools/execute.d.ts.map +1 -0
  108. package/dist/tools/execute.js +418 -0
  109. package/dist/tools/execute.js.map +1 -0
  110. package/dist/tools/git.d.ts +7 -0
  111. package/dist/tools/git.d.ts.map +1 -0
  112. package/dist/tools/git.js +98 -0
  113. package/dist/tools/git.js.map +1 -0
  114. package/dist/tools/intelligence.d.ts +10 -0
  115. package/dist/tools/intelligence.d.ts.map +1 -0
  116. package/dist/tools/intelligence.js +432 -0
  117. package/dist/tools/intelligence.js.map +1 -0
  118. package/dist/tools/session.d.ts +7 -0
  119. package/dist/tools/session.d.ts.map +1 -0
  120. package/dist/tools/session.js +533 -0
  121. package/dist/tools/session.js.map +1 -0
  122. package/dist/tools/trajectory.d.ts +10 -0
  123. package/dist/tools/trajectory.d.ts.map +1 -0
  124. package/dist/tools/trajectory.js +374 -0
  125. package/dist/tools/trajectory.js.map +1 -0
  126. package/dist/trajectory-io.d.ts +21 -0
  127. package/dist/trajectory-io.d.ts.map +1 -0
  128. package/dist/trajectory-io.js +105 -0
  129. package/dist/trajectory-io.js.map +1 -0
  130. package/dist/types.d.ts +229 -0
  131. package/dist/types.d.ts.map +1 -0
  132. package/dist/types.js +13 -0
  133. package/dist/types.js.map +1 -0
  134. package/package.json +63 -0
@@ -0,0 +1,420 @@
1
+ import { getRegistry } from './tool-registry.js';
2
+ export function buildScoutEscalation(retryCount, explorationLog, scoutedDirs, codebaseIndex) {
3
+ const parts = [
4
+ '## Previous Attempts Found Nothing — Fresh Approach Required',
5
+ '',
6
+ ];
7
+ if (explorationLog.length > 0) {
8
+ parts.push('### What Was Already Tried');
9
+ for (const entry of explorationLog) {
10
+ parts.push(entry);
11
+ }
12
+ parts.push('');
13
+ }
14
+ // Suggest unexplored modules from codebase index
15
+ const exploredSet = new Set(scoutedDirs.map(d => d.replace(/\/$/, '')));
16
+ const unexplored = [];
17
+ if (codebaseIndex) {
18
+ for (const mod of codebaseIndex.modules) {
19
+ if (!exploredSet.has(mod.path) && !exploredSet.has(mod.path + '/')) {
20
+ unexplored.push(mod.path);
21
+ }
22
+ }
23
+ }
24
+ parts.push('### What to Do Differently');
25
+ parts.push('');
26
+ parts.push('Knowing everything from the attempts above, take a completely different angle:');
27
+ parts.push('- Do NOT re-read the directories listed above.');
28
+ if (unexplored.length > 0) {
29
+ parts.push(`- Try unexplored areas: ${unexplored.slice(0, 8).map(d => `\`${d}\``).join(', ')}`);
30
+ }
31
+ parts.push('- Switch categories: if you looked for bugs, look for tests. If tests, try security.');
32
+ parts.push('- Read at least 15 NEW source files.');
33
+ parts.push('- If genuinely nothing to improve, explain your analysis across all attempts.');
34
+ return parts.join('\n');
35
+ }
36
+ export function buildScoutPrompt(scope, categories, minConfidence, maxProposals, dedupContext, formula, hints, eco, minImpactScore = 3, scoutedDirs = [], excludeDirs = [], coverageContext) {
37
+ const parts = [
38
+ '# Scout Phase',
39
+ '',
40
+ 'Identify improvements by reading source code. Return proposals in a `<proposals>` XML block containing a JSON array.',
41
+ '',
42
+ ...(!eco ? ['**IMPORTANT:** Do not use the Task or Explore tools. Read files directly using Read, Glob, and Grep. Do not delegate to subagents.', ''] : []),
43
+ '## How to Scout',
44
+ '',
45
+ 'STEP 1 — Discover: Use Glob to list all files in scope. Group them by directory or module (e.g. `src/auth/`, `src/api/`, `lib/utils/`). Identify entry points, core logic, and test directories.',
46
+ '',
47
+ 'STEP 2 — Pick a Partition: Choose one or two directories/modules to analyze deeply this cycle. Do NOT try to skim everything — go deep on a focused slice. On future cycles, different partitions will be explored.',
48
+ '',
49
+ 'STEP 3 — Read & Analyze: Use Read to open 10-15 source files within your chosen partition(s). Read related files together (e.g. a module and its tests, a handler and its helpers). For each file, look for:',
50
+ ' - Bugs, incorrect logic, off-by-one errors',
51
+ ' - Missing error handling or edge cases',
52
+ ' - Missing or inadequate tests for the code you read',
53
+ ' - Security issues (injection, auth bypass, secrets in code)',
54
+ ' - Performance problems (N+1 queries, unnecessary re-renders, blocking I/O)',
55
+ ' - Dead code, unreachable branches',
56
+ ' - Meaningful refactoring opportunities (not cosmetic)',
57
+ '',
58
+ 'STEP 4 — Propose: Only after reading source files, write proposals with specific file paths and line-level detail.',
59
+ '',
60
+ 'DO NOT run lint or typecheck commands as a substitute for reading code.',
61
+ 'DO NOT propose changes unless you have READ the files you are proposing to change.',
62
+ '',
63
+ `**Scope:** \`${scope}\``,
64
+ `**Categories:** ${categories.join(', ')}`,
65
+ `**Min confidence:** ${minConfidence}`,
66
+ `**Min impact score:** ${minImpactScore} (proposals below this will be rejected)`,
67
+ `**Max proposals:** ${maxProposals}`,
68
+ '',
69
+ '**DO NOT propose changes to these files** (read-only context): CLAUDE.md, .claude/**',
70
+ ...(excludeDirs.length > 0 ? [
71
+ `**Skip these directories when scouting** (build artifacts, vendor, generated): ${excludeDirs.map(d => `\`${d}\``).join(', ')}`,
72
+ ] : []),
73
+ '',
74
+ ...(coverageContext ? [
75
+ `## Coverage Context`,
76
+ '',
77
+ `Overall codebase coverage: ${coverageContext.scannedSectors}/${coverageContext.totalSectors} sectors scanned (${coverageContext.sectorPercent ?? coverageContext.percent}% of sectors, ${coverageContext.percent}% of files).`,
78
+ ...(coverageContext.percent < 50 ? ['Many sectors remain unscanned. Focus on high-impact issues rather than minor cleanups.'] : []),
79
+ ...(coverageContext.sectorSummary ? ['', coverageContext.sectorSummary] : []),
80
+ '',
81
+ ] : []),
82
+ '## Quality Bar',
83
+ '',
84
+ '- Proposals must have **real user or developer impact** — not just lint cleanup or style nits.',
85
+ '- Do NOT propose fixes for lint warnings, unused variables, or cosmetic issues unless they cause actual bugs or test failures.',
86
+ '- If project guidelines are provided above, **respect them**. Do NOT propose changes the guidelines explicitly discourage (e.g., "avoid over-engineering", "don\'t change code you didn\'t touch").',
87
+ '- Focus on: bugs, security issues, performance problems, correctness, and meaningful refactors.',
88
+ '',
89
+ '## Category Rules',
90
+ '',
91
+ '- Any proposal that creates new test files (e.g. .test.ts, .spec.ts, test_*.py, *_test.go, *Test.java) or adds test coverage MUST use category "test" — NEVER label test-writing as "fix", "refactor", or any other category.',
92
+ '- If "test" is not in the categories list above, do NOT propose writing new tests. Focus on the allowed categories only.',
93
+ '- If "test" IS allowed, you may generate test proposals freely.',
94
+ '',
95
+ ];
96
+ if (scoutedDirs.length > 0) {
97
+ parts.push('## Already Explored (prefer unexplored directories)');
98
+ parts.push('');
99
+ parts.push('These directories were analyzed in previous scout cycles. Prefer exploring different areas first:');
100
+ for (const dir of scoutedDirs) {
101
+ parts.push(`- \`${dir}\``);
102
+ }
103
+ parts.push('');
104
+ }
105
+ if (dedupContext.length > 0) {
106
+ parts.push('**Already completed (do not duplicate):**');
107
+ for (const title of dedupContext) {
108
+ parts.push(`- ${title}`);
109
+ }
110
+ parts.push('');
111
+ }
112
+ if (formula) {
113
+ parts.push(`**Formula:** ${formula.name} — ${formula.description}`);
114
+ if (formula.prompt) {
115
+ parts.push('');
116
+ parts.push('**Formula instructions:**');
117
+ parts.push(formula.prompt);
118
+ }
119
+ if (formula.risk_tolerance) {
120
+ parts.push(`**Risk tolerance:** ${formula.risk_tolerance}`);
121
+ }
122
+ parts.push('');
123
+ }
124
+ if (hints.length > 0) {
125
+ parts.push('**Hints from user:**');
126
+ for (const hint of hints) {
127
+ parts.push(`- ${hint}`);
128
+ }
129
+ parts.push('');
130
+ }
131
+ parts.push('## Required Fields', '', 'Each proposal in the JSON array MUST include ALL of these fields:', '- `category` (string): one of the categories listed above', '- `title` (string): concise, unique title', '- `description` (string): what needs to change and why', '- `acceptance_criteria` (string[]): how to verify the change is correct', '- `verification_commands` (string[]): commands to run (use the project\'s detected test runner — see Project Tooling above)', '- `allowed_paths` (string[]): file paths/globs this change may touch', '- `files` (string[]): specific files to modify', '- `confidence` (number 0-100): how confident you are this is correct', '- `impact_score` (number 1-10): how much this matters', '- `risk` (string): "low", "medium", or "high"', '- `touched_files_estimate` (number): expected number of files changed', '- `rollback_note` (string): how to revert if something goes wrong', '', '## Scoring', '', 'Proposals are ranked by `impact_score × confidence`. Prefer low-risk proposals.', '', '## Output', '', 'Wrap the JSON array in a `<proposals>` XML block:', '```', '<proposals>', '[{ ... }, { ... }]', '</proposals>', '```', '', 'Then call `promptwheel_ingest_event` with type `SCOUT_OUTPUT` and payload:', '`{ "proposals": [...], "explored_dirs": ["src/auth/", "src/api/"] }`', '', 'The `explored_dirs` field should list the top-level directories you analyzed (e.g. `src/services/`, `lib/utils/`). This is used to rotate to unexplored areas in future cycles.');
132
+ if (coverageContext) {
133
+ parts.push('');
134
+ parts.push('If this sector appears misclassified (e.g., labeled as production but contains only tests/config/generated code, or vice versa), include in the SCOUT_OUTPUT payload:');
135
+ parts.push('`"sector_reclassification": { "production": true/false, "confidence": "medium"|"high" }`');
136
+ }
137
+ return parts.join('\n');
138
+ }
139
+ export function buildPlanPrompt(ticket) {
140
+ const constraintNote = getRegistry().getConstraintNote({ phase: 'EXECUTE', category: ticket.category ?? null });
141
+ const toolRestrictionLines = constraintNote
142
+ ? ['', '## Tool Restrictions', '', constraintNote, '']
143
+ : [''];
144
+ return [
145
+ '# Commit Plan Required',
146
+ '',
147
+ `**Ticket:** ${ticket.title}`,
148
+ '',
149
+ ticket.description ?? '',
150
+ '',
151
+ 'Before making changes, output a `<commit-plan>` XML block with:',
152
+ '```json',
153
+ '{',
154
+ ` "ticket_id": "<ticket-id>",`,
155
+ ' "files_to_touch": [{"path": "...", "action": "create|modify|delete", "reason": "..."}],',
156
+ ' "expected_tests": ["npm test -- --grep ..."],',
157
+ ' "estimated_lines": <number>,',
158
+ ' "risk_level": "low|medium|high"',
159
+ '}',
160
+ '```',
161
+ '',
162
+ `**Allowed paths:** ${ticket.allowedPaths.length > 0 ? ticket.allowedPaths.join(', ') : 'any'}`,
163
+ `**Verification commands:** ${ticket.verificationCommands.join(', ') || 'none specified'}`,
164
+ ...toolRestrictionLines,
165
+ 'Then call `promptwheel_ingest_event` with type `PLAN_SUBMITTED` and the plan as payload.',
166
+ ].join('\n');
167
+ }
168
+ export function buildExecutePrompt(ticket, plan) {
169
+ const parts = [
170
+ `# Execute: ${ticket.title}`,
171
+ '',
172
+ ticket.description ?? '',
173
+ '',
174
+ ];
175
+ if (plan) {
176
+ parts.push('## Approved Commit Plan');
177
+ parts.push('```json');
178
+ parts.push(JSON.stringify(plan, null, 2));
179
+ parts.push('```');
180
+ parts.push('');
181
+ parts.push('Follow the plan above. Only touch the files listed.');
182
+ parts.push('');
183
+ }
184
+ parts.push('## Constraints', `- Only modify files in: ${ticket.allowedPaths.length > 0 ? ticket.allowedPaths.join(', ') : 'any'}`, '- Make minimal, focused changes', '');
185
+ const constraintNote = getRegistry().getConstraintNote({ phase: 'EXECUTE', category: ticket.category ?? null });
186
+ if (constraintNote) {
187
+ parts.push('## Tool Restrictions', '', constraintNote, '');
188
+ }
189
+ parts.push('## When done', 'Output a `<ticket-result>` block with status, changed_files, summary, lines_added, lines_removed.', 'Then call `promptwheel_ingest_event` with type `TICKET_RESULT` and the result as payload.');
190
+ return parts.join('\n');
191
+ }
192
+ export function buildQaPrompt(ticket) {
193
+ return [
194
+ `# QA: ${ticket.title}`,
195
+ '',
196
+ 'Run the following verification commands and report results:',
197
+ '',
198
+ ...ticket.verificationCommands.map(c => `\`\`\`bash\n${c}\n\`\`\``),
199
+ '',
200
+ 'For each command, call `promptwheel_ingest_event` with type `QA_COMMAND_RESULT` and:',
201
+ '`{ "command": "...", "success": true/false, "output": "stdout+stderr" }`',
202
+ '',
203
+ 'After all commands, call `promptwheel_ingest_event` with type `QA_PASSED` if all pass, or `QA_FAILED` with failure details.',
204
+ ].join('\n');
205
+ }
206
+ export function buildPlanningPreamble(ticket) {
207
+ const meta = ticket.metadata;
208
+ const confidence = typeof meta?.scoutConfidence === 'number' ? meta.scoutConfidence : undefined;
209
+ const complexity = typeof meta?.estimatedComplexity === 'string' ? meta.estimatedComplexity : undefined;
210
+ if ((confidence !== undefined && confidence < 50) || complexity === 'moderate' || complexity === 'complex') {
211
+ return [
212
+ '## Approach — This is a complex change',
213
+ '',
214
+ `The automated analysis flagged this as uncertain (confidence: ${confidence ?? '?'}%). Before writing code:`,
215
+ '1. Read all relevant files to understand the full context',
216
+ '2. Identify all touch points and potential side effects',
217
+ '3. Write out your implementation plan before making changes',
218
+ '4. Implement incrementally, verifying at each step',
219
+ '',
220
+ ].join('\n') + '\n';
221
+ }
222
+ return '';
223
+ }
224
+ /** Escape a string for use inside double-quoted shell arguments */
225
+ export function shellEscape(s) {
226
+ return s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\$/g, '\\$').replace(/`/g, '\\`');
227
+ }
228
+ export function buildInlineTicketPrompt(ticket, constraints, guidelinesBlock, metadataBlock, createPrs, draft, direct, setupCommand, baselineFailures = []) {
229
+ const slug = ticket.title.toLowerCase().replace(/[^a-z0-9]+/g, '-').slice(0, 40);
230
+ const branch = `promptwheel/${ticket.id}/${slug}`;
231
+ const worktree = `.promptwheel/worktrees/${ticket.id}`;
232
+ const verifyBlock = constraints.required_commands.length > 0
233
+ ? constraints.required_commands.map(c => `\`\`\`bash\n${c}\n\`\`\``).join('\n')
234
+ : 'Run the project\'s test suite to verify your changes. Use the test runner shown in **Project Tooling** above (e.g. `npm test`, `pytest`, `cargo test`, `go test ./...`). If no test runner is specified, check for a test command in the project\'s config files.';
235
+ const planningPreamble = buildPlanningPreamble(ticket);
236
+ // Build tool restriction block from registry
237
+ const inlineConstraintNote = getRegistry().getConstraintNote({ phase: 'EXECUTE', category: ticket.category ?? null });
238
+ const toolRestrictionBlock = inlineConstraintNote
239
+ ? ['## Tool Restrictions', '', inlineConstraintNote, '']
240
+ : [];
241
+ // Direct mode: simpler flow, edit in place, no worktrees
242
+ if (direct) {
243
+ return [
244
+ `# PromptWheel Ticket: ${ticket.title}`,
245
+ '',
246
+ planningPreamble,
247
+ guidelinesBlock,
248
+ metadataBlock,
249
+ ticket.description ?? '',
250
+ '',
251
+ '## Constraints',
252
+ '',
253
+ `- **Allowed paths:** ${constraints.allowed_paths.length > 0 ? constraints.allowed_paths.join(', ') : 'any'}`,
254
+ `- **Denied paths:** ${constraints.denied_paths.length > 0 ? constraints.denied_paths.join(', ') : 'none'}`,
255
+ `- **Max files:** ${constraints.max_files || 'unlimited'}`,
256
+ `- **Max lines:** ${constraints.max_lines || 'unlimited'}`,
257
+ '',
258
+ ...toolRestrictionBlock,
259
+ '## Step 1 — Implement the change',
260
+ '',
261
+ '- Read the relevant files first to understand the current state.',
262
+ '- Make minimal, focused changes that match the ticket description.',
263
+ '- Only modify files within the allowed paths.',
264
+ '- Follow any project guidelines provided above.',
265
+ '',
266
+ '## Step 2 — Verify',
267
+ '',
268
+ verifyBlock,
269
+ '',
270
+ ...(baselineFailures.length > 0 ? [
271
+ `**Pre-existing failures (IGNORE these — they were failing before your changes):** ${baselineFailures.join(', ')}`,
272
+ '',
273
+ 'Only fix failures that are NEW — caused by your changes. If a command was already failing, do not try to fix it.',
274
+ ] : [
275
+ 'If tests fail due to your changes, fix the issues and re-run.',
276
+ ]),
277
+ '',
278
+ '## Step 3 — Commit',
279
+ '',
280
+ '```bash',
281
+ 'git add -A',
282
+ `git commit -m "${shellEscape(ticket.title)}"`,
283
+ '```',
284
+ '',
285
+ '## Output',
286
+ '',
287
+ 'When done, output a summary in this exact format:',
288
+ '',
289
+ '```',
290
+ `TICKET_ID: ${ticket.id}`,
291
+ 'STATUS: success | failed',
292
+ 'PR_URL: none',
293
+ 'BRANCH: (current)',
294
+ 'SUMMARY: <one line summary of what was done>',
295
+ '```',
296
+ '',
297
+ 'If anything goes wrong and you cannot complete the ticket, output STATUS: failed with a reason.',
298
+ ].join('\n');
299
+ }
300
+ // Worktree mode: isolated branches for parallel execution or PR workflow
301
+ return [
302
+ `# PromptWheel Ticket: ${ticket.title}`,
303
+ '',
304
+ planningPreamble,
305
+ guidelinesBlock,
306
+ metadataBlock,
307
+ ticket.description ?? '',
308
+ '',
309
+ '## Constraints',
310
+ '',
311
+ `- **Allowed paths:** ${constraints.allowed_paths.length > 0 ? constraints.allowed_paths.join(', ') : 'any'}`,
312
+ `- **Denied paths:** ${constraints.denied_paths.length > 0 ? constraints.denied_paths.join(', ') : 'none'}`,
313
+ `- **Max files:** ${constraints.max_files || 'unlimited'}`,
314
+ `- **Max lines:** ${constraints.max_lines || 'unlimited'}`,
315
+ '',
316
+ ...toolRestrictionBlock,
317
+ '## Step 1 — Set up worktree',
318
+ '',
319
+ '```bash',
320
+ `git worktree add ${worktree} -b ${branch}`,
321
+ '```',
322
+ '',
323
+ `All work MUST happen inside \`${worktree}/\`. Do NOT modify files in the main working tree.`,
324
+ '',
325
+ ...(setupCommand ? [
326
+ '```bash',
327
+ `cd ${worktree}`,
328
+ setupCommand,
329
+ '```',
330
+ '',
331
+ 'Wait for setup to complete before proceeding. If setup fails, try to continue anyway.',
332
+ '',
333
+ ] : []),
334
+ '## Step 2 — Implement the change',
335
+ '',
336
+ '- Read the relevant files first to understand the current state.',
337
+ '- Make minimal, focused changes that match the ticket description.',
338
+ '- Only modify files within the allowed paths.',
339
+ '- Follow any project guidelines provided above.',
340
+ '',
341
+ '## Step 3 — Verify',
342
+ '',
343
+ 'Run verification commands inside the worktree:',
344
+ '',
345
+ '```bash',
346
+ `cd ${worktree}`,
347
+ '```',
348
+ '',
349
+ verifyBlock,
350
+ '',
351
+ ...(baselineFailures.length > 0 ? [
352
+ `**Pre-existing failures (IGNORE these — they were failing before your changes):** ${baselineFailures.join(', ')}`,
353
+ '',
354
+ 'Only fix failures that are NEW — caused by your changes. If a command was already failing, do not try to fix it.',
355
+ ] : [
356
+ 'If tests fail due to your changes, fix the issues and re-run.',
357
+ ]),
358
+ '',
359
+ '## Step 4 — Commit and push',
360
+ '',
361
+ '```bash',
362
+ `cd ${worktree}`,
363
+ 'git add -A',
364
+ `git commit -m "${shellEscape(ticket.title)}"`,
365
+ ...(createPrs ? [`git push -u origin ${branch}`] : []),
366
+ '```',
367
+ '',
368
+ ...(createPrs ? [
369
+ '## Step 5 — Create PR',
370
+ '',
371
+ `Create a ${draft ? 'draft ' : ''}pull request:`,
372
+ '',
373
+ '```bash',
374
+ `cd ${worktree}`,
375
+ `gh pr create --title "${shellEscape(ticket.title)}"${draft ? ' --draft' : ''} --body "$(cat <<'PROMPTWHEEL_BODY_EOF'`,
376
+ ticket.description?.slice(0, 500) ?? ticket.title,
377
+ '',
378
+ 'Generated by PromptWheel',
379
+ `PROMPTWHEEL_BODY_EOF`,
380
+ `)"`,
381
+ '```',
382
+ '',
383
+ ] : []),
384
+ '## Output',
385
+ '',
386
+ 'When done, output a summary in this exact format:',
387
+ '',
388
+ '```',
389
+ `TICKET_ID: ${ticket.id}`,
390
+ 'STATUS: success | failed',
391
+ `PR_URL: <url or "none">`,
392
+ `BRANCH: ${branch}`,
393
+ 'SUMMARY: <one line summary of what was done>',
394
+ '```',
395
+ '',
396
+ 'If anything goes wrong and you cannot complete the ticket, output STATUS: failed with a reason.',
397
+ ].join('\n');
398
+ }
399
+ export function buildPrPrompt(ticket, draftPr) {
400
+ const title = ticket?.title ?? 'PromptWheel changes';
401
+ return [
402
+ '# Create PR',
403
+ '',
404
+ `Create a ${draftPr ? 'draft ' : ''}pull request for the changes.`,
405
+ '',
406
+ `**Title:** ${title}`,
407
+ ticket?.description ? `**Description:** ${ticket.description.slice(0, 200)}` : '',
408
+ '',
409
+ '## Dry-run first',
410
+ '',
411
+ '1. Stage changes: `git add <files>`',
412
+ '2. Create commit: `git commit -m "..."`',
413
+ '3. Verify the commit looks correct: `git diff HEAD~1 --stat`',
414
+ '4. Push to remote: `git push -u origin <branch>`',
415
+ `5. Create ${draftPr ? 'draft ' : ''}PR: \`gh pr create${draftPr ? ' --draft' : ''}\``,
416
+ '',
417
+ 'Call `promptwheel_ingest_event` with type `PR_CREATED` and `{ "url": "<pr-url>", "branch": "<branch-name>" }` as payload.',
418
+ ].join('\n');
419
+ }
420
+ //# sourceMappingURL=advance-prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advance-prompts.js","sourceRoot":"","sources":["../src/advance-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAKjD,MAAM,UAAU,oBAAoB,CAClC,UAAkB,EAClB,cAAwB,EACxB,WAAqB,EACrB,aAAmC;IAEnC,MAAM,KAAK,GAAG;QACZ,8DAA8D;QAC9D,EAAE;KACH,CAAC;IAEF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QACzC,KAAK,MAAM,KAAK,IAAI,cAAc,EAAE,CAAC;YACnC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,iDAAiD;IACjD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACxE,MAAM,UAAU,GAAa,EAAE,C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AAQ,CAAC,CAAC,CAAC,EAAE,+BAA+B;QAClE,EAAE;QACF,cAAc,KAAK,EAAE;QACrB,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,oBAAoB,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;QACjF,EAAE;QACF,kBAAkB;QAClB,EAAE;QACF,qCAAqC;QACrC,yCAAyC;QACzC,8DAA8D;QAC9D,kDAAkD;QAClD,aAAa,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,qBAAqB,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI;QACtF,EAAE;QACF,2HAA2H;KAC5H,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Advance Engine — the deterministic state machine.
3
+ *
4
+ * `advance()` is called by the client on every loop iteration.
5
+ * It returns what to do next (prompt + constraints) or STOP.
6
+ *
7
+ * State machine transitions (from docs/PLUGIN_ROADMAP.md):
8
+ *
9
+ * SCOUT → NEXT_TICKET | DONE | FAILED_BUDGET
10
+ * NEXT_TICKET → PLAN | SCOUT | DONE
11
+ * PLAN → EXECUTE | PLAN | BLOCKED_NEEDS_HUMAN | FAILED_BUDGET
12
+ * EXECUTE → QA | NEXT_TICKET | BLOCKED_NEEDS_HUMAN | FAILED_BUDGET | FAILED_SPINDLE
13
+ * QA → PR | EXECUTE | NEXT_TICKET | FAILED_BUDGET
14
+ * PR → NEXT_TICKET | FAILED_VALIDATION
15
+ */
16
+ import type { DatabaseAdapter } from '@promptwheel/core';
17
+ import type { Project } from '@promptwheel/core';
18
+ import { RunManager } from './run-manager.js';
19
+ import type { AdvanceResponse } from './types.js';
20
+ export interface AdvanceContext {
21
+ run: RunManager;
22
+ db: DatabaseAdapter;
23
+ project: Project;
24
+ }
25
+ /**
26
+ * Core advance function. Called once per loop iteration.
27
+ * Returns the next action for the client to perform.
28
+ */
29
+ export declare function advance(ctx: AdvanceContext): Promise<AdvanceResponse>;
30
+ //# sourceMappingURL=advance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advance.d.ts","sourceRoot":"","sources":["../src/advance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,YAAY,CAAC;AAiDpB,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,UAAU,CAAC;IAChB,EAAE,EAAE,eAAe,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CA2G3E"}