midas-mcp 5.44.4 → 5.44.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/PLUGIN.md +124 -0
- package/.claude/agents/midas-coach.md +108 -0
- package/.claude/agents/midas-reviewer.md +93 -0
- package/.claude/agents/midas-verifier.md +81 -0
- package/.claude/hooks/hooks.json +67 -0
- package/.claude/settings.json +41 -0
- package/.claude/skills/build-debug/SKILL.md +106 -0
- package/.claude/skills/build-implement/SKILL.md +81 -0
- package/.claude/skills/build-rules/SKILL.md +80 -0
- package/.claude/skills/build-test/SKILL.md +89 -0
- package/.claude/skills/horizon-expand/SKILL.md +103 -0
- package/.claude/skills/oneshot-retry/SKILL.md +96 -0
- package/.claude/skills/plan-brainlift/SKILL.md +65 -0
- package/.claude/skills/plan-gameplan/SKILL.md +71 -0
- package/.claude/skills/plan-idea/SKILL.md +51 -0
- package/.claude/skills/plan-prd/SKILL.md +79 -0
- package/.claude/skills/plan-research/SKILL.md +63 -0
- package/.claude/skills/tornado-debug/SKILL.md +128 -0
- package/README.md +51 -1
- package/dist/.claude/PLUGIN.md +124 -0
- package/dist/.claude/agents/midas-coach.md +108 -0
- package/dist/.claude/agents/midas-reviewer.md +93 -0
- package/dist/.claude/agents/midas-verifier.md +81 -0
- package/dist/.claude/hooks/hooks.json +67 -0
- package/dist/.claude/settings.json +41 -0
- package/dist/.claude/skills/build-debug/SKILL.md +106 -0
- package/dist/.claude/skills/build-implement/SKILL.md +81 -0
- package/dist/.claude/skills/build-rules/SKILL.md +80 -0
- package/dist/.claude/skills/build-test/SKILL.md +89 -0
- package/dist/.claude/skills/horizon-expand/SKILL.md +103 -0
- package/dist/.claude/skills/oneshot-retry/SKILL.md +96 -0
- package/dist/.claude/skills/plan-brainlift/SKILL.md +65 -0
- package/dist/.claude/skills/plan-gameplan/SKILL.md +71 -0
- package/dist/.claude/skills/plan-idea/SKILL.md +51 -0
- package/dist/.claude/skills/plan-prd/SKILL.md +79 -0
- package/dist/.claude/skills/plan-research/SKILL.md +63 -0
- package/dist/.claude/skills/tornado-debug/SKILL.md +128 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +56 -2
- package/dist/cli.js.map +1 -1
- package/dist/github-integration.d.ts +37 -0
- package/dist/github-integration.d.ts.map +1 -0
- package/dist/github-integration.js +219 -0
- package/dist/github-integration.js.map +1 -0
- package/dist/phase-detector.d.ts +46 -0
- package/dist/phase-detector.d.ts.map +1 -0
- package/dist/phase-detector.js +251 -0
- package/dist/phase-detector.js.map +1 -0
- package/dist/pilot.d.ts +51 -0
- package/dist/pilot.d.ts.map +1 -1
- package/dist/pilot.js +50 -6
- package/dist/pilot.js.map +1 -1
- package/dist/tools/journal.d.ts +10 -1
- package/dist/tools/journal.d.ts.map +1 -1
- package/dist/tools/journal.js +38 -2
- package/dist/tools/journal.js.map +1 -1
- package/dist/tui-lite.d.ts +23 -0
- package/dist/tui-lite.d.ts.map +1 -0
- package/dist/tui-lite.js +188 -0
- package/dist/tui-lite.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub Integration for Midas
|
|
3
|
+
*
|
|
4
|
+
* Integrates with Claude Code's --from-pr flag for PR-based automation.
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Process PRs with Midas methodology context
|
|
8
|
+
* - Run verification gates on PR code
|
|
9
|
+
* - Add PR review comments based on phase
|
|
10
|
+
* - Auto-update gameplan based on merged PRs
|
|
11
|
+
*/
|
|
12
|
+
import { spawn } from 'child_process';
|
|
13
|
+
import { detectPhaseFromArtifacts } from './phase-detector.js';
|
|
14
|
+
import { sanitizePath } from './security.js';
|
|
15
|
+
/**
|
|
16
|
+
* Parse a GitHub PR URL into components
|
|
17
|
+
*/
|
|
18
|
+
export function parsePRUrl(url) {
|
|
19
|
+
// Match: https://github.com/owner/repo/pull/123
|
|
20
|
+
const match = url.match(/github\.com\/([^\/]+)\/([^\/]+)\/pull\/(\d+)/);
|
|
21
|
+
if (!match)
|
|
22
|
+
return null;
|
|
23
|
+
return {
|
|
24
|
+
owner: match[1],
|
|
25
|
+
repo: match[2],
|
|
26
|
+
prNumber: parseInt(match[3], 10),
|
|
27
|
+
url,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Review a PR using Claude Code's --from-pr flag with Midas methodology
|
|
32
|
+
*/
|
|
33
|
+
export async function reviewPR(prUrl, projectPath = process.cwd()) {
|
|
34
|
+
const safePath = sanitizePath(projectPath);
|
|
35
|
+
const pr = parsePRUrl(prUrl);
|
|
36
|
+
if (!pr) {
|
|
37
|
+
return {
|
|
38
|
+
success: false,
|
|
39
|
+
phase: 'unknown',
|
|
40
|
+
comments: ['Invalid PR URL format'],
|
|
41
|
+
gatesPass: false,
|
|
42
|
+
recommendation: 'comment',
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
// Detect current phase
|
|
46
|
+
const detection = detectPhaseFromArtifacts(safePath);
|
|
47
|
+
const phase = detection.phase.phase === 'IDLE'
|
|
48
|
+
? 'PLAN'
|
|
49
|
+
: detection.phase.phase;
|
|
50
|
+
// Build review prompt based on phase
|
|
51
|
+
const reviewPrompt = buildReviewPrompt(phase, pr);
|
|
52
|
+
return new Promise((resolve) => {
|
|
53
|
+
const args = [
|
|
54
|
+
'--from-pr', prUrl,
|
|
55
|
+
'-p', reviewPrompt,
|
|
56
|
+
'--output-format', 'json',
|
|
57
|
+
'--json-schema', JSON.stringify(PR_REVIEW_SCHEMA),
|
|
58
|
+
'--max-turns', '5',
|
|
59
|
+
];
|
|
60
|
+
let output = '';
|
|
61
|
+
let stderr = '';
|
|
62
|
+
const proc = spawn('claude', args, {
|
|
63
|
+
cwd: safePath,
|
|
64
|
+
env: process.env,
|
|
65
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
66
|
+
});
|
|
67
|
+
proc.stdout.on('data', (data) => {
|
|
68
|
+
output += data.toString();
|
|
69
|
+
});
|
|
70
|
+
proc.stderr.on('data', (data) => {
|
|
71
|
+
stderr += data.toString();
|
|
72
|
+
});
|
|
73
|
+
proc.on('error', () => {
|
|
74
|
+
resolve({
|
|
75
|
+
success: false,
|
|
76
|
+
phase,
|
|
77
|
+
comments: ['Failed to spawn claude CLI'],
|
|
78
|
+
gatesPass: false,
|
|
79
|
+
recommendation: 'comment',
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
proc.on('close', (code) => {
|
|
83
|
+
if (code !== 0) {
|
|
84
|
+
resolve({
|
|
85
|
+
success: false,
|
|
86
|
+
phase,
|
|
87
|
+
comments: [`Review failed with exit code ${code}`],
|
|
88
|
+
gatesPass: false,
|
|
89
|
+
recommendation: 'comment',
|
|
90
|
+
});
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const result = JSON.parse(output);
|
|
95
|
+
resolve({
|
|
96
|
+
success: true,
|
|
97
|
+
phase,
|
|
98
|
+
comments: result.comments || [],
|
|
99
|
+
gatesPass: result.gatesPass ?? false,
|
|
100
|
+
recommendation: result.recommendation || 'comment',
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
resolve({
|
|
105
|
+
success: true,
|
|
106
|
+
phase,
|
|
107
|
+
comments: [output.slice(0, 500)],
|
|
108
|
+
gatesPass: false,
|
|
109
|
+
recommendation: 'comment',
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Build a phase-appropriate review prompt
|
|
117
|
+
*/
|
|
118
|
+
function buildReviewPrompt(phase, pr) {
|
|
119
|
+
const basePrompt = `Review this PR (#${pr.prNumber}) using the Midas Golden Code methodology.
|
|
120
|
+
|
|
121
|
+
Current project phase: ${phase}
|
|
122
|
+
|
|
123
|
+
Review criteria:`;
|
|
124
|
+
const phasePrompts = {
|
|
125
|
+
PLAN: `
|
|
126
|
+
- Does this PR add/update planning documents?
|
|
127
|
+
- Is the brainlift, PRD, or gameplan being properly structured?
|
|
128
|
+
- Are requirements clearly defined?
|
|
129
|
+
- Check for scope creep against the PRD.`,
|
|
130
|
+
BUILD: `
|
|
131
|
+
- Does the code follow the project's .cursorrules conventions?
|
|
132
|
+
- Are there tests for new functionality?
|
|
133
|
+
- Is error handling implemented properly?
|
|
134
|
+
- Check for common issues: hardcoded secrets, console.log, TODO comments
|
|
135
|
+
- Verify the implementation matches the gameplan task.`,
|
|
136
|
+
SHIP: `
|
|
137
|
+
- Are all verification gates passing (build, test, lint)?
|
|
138
|
+
- Is the code production-ready (no debug code, proper logging)?
|
|
139
|
+
- Are there security concerns (secrets, injection, auth)?
|
|
140
|
+
- Is the version appropriately bumped?
|
|
141
|
+
- Is documentation updated?`,
|
|
142
|
+
GROW: `
|
|
143
|
+
- Does this PR address user feedback?
|
|
144
|
+
- Are metrics/monitoring properly integrated?
|
|
145
|
+
- Does it maintain backward compatibility?
|
|
146
|
+
- Is the change documented for users?`,
|
|
147
|
+
};
|
|
148
|
+
return basePrompt + (phasePrompts[phase] || phasePrompts.BUILD) + `
|
|
149
|
+
|
|
150
|
+
Respond with:
|
|
151
|
+
1. List of specific comments/issues found
|
|
152
|
+
2. Whether this would pass gates (build/test/lint)
|
|
153
|
+
3. Your recommendation: approve, request_changes, or comment`;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* JSON Schema for structured PR review output
|
|
157
|
+
*/
|
|
158
|
+
const PR_REVIEW_SCHEMA = {
|
|
159
|
+
type: 'object',
|
|
160
|
+
properties: {
|
|
161
|
+
comments: {
|
|
162
|
+
type: 'array',
|
|
163
|
+
items: { type: 'string' },
|
|
164
|
+
description: 'Specific review comments or issues found',
|
|
165
|
+
},
|
|
166
|
+
gatesPass: {
|
|
167
|
+
type: 'boolean',
|
|
168
|
+
description: 'Whether this PR would pass build/test/lint gates',
|
|
169
|
+
},
|
|
170
|
+
recommendation: {
|
|
171
|
+
type: 'string',
|
|
172
|
+
enum: ['approve', 'request_changes', 'comment'],
|
|
173
|
+
description: 'Overall review recommendation',
|
|
174
|
+
},
|
|
175
|
+
summary: {
|
|
176
|
+
type: 'string',
|
|
177
|
+
description: 'Brief summary of the review',
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
required: ['comments', 'gatesPass', 'recommendation'],
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* CLI handler for: midas pr <url>
|
|
184
|
+
*/
|
|
185
|
+
export async function runPRReview(args) {
|
|
186
|
+
const prUrl = args[0];
|
|
187
|
+
if (!prUrl) {
|
|
188
|
+
console.log('\n Usage: midas pr <github-pr-url>');
|
|
189
|
+
console.log(' Example: midas pr https://github.com/owner/repo/pull/123\n');
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
console.log('\n Reviewing PR with Midas methodology...\n');
|
|
193
|
+
const result = await reviewPR(prUrl);
|
|
194
|
+
const colors = {
|
|
195
|
+
green: '\x1b[32m',
|
|
196
|
+
red: '\x1b[31m',
|
|
197
|
+
yellow: '\x1b[33m',
|
|
198
|
+
reset: '\x1b[0m',
|
|
199
|
+
bold: '\x1b[1m',
|
|
200
|
+
dim: '\x1b[2m',
|
|
201
|
+
};
|
|
202
|
+
// Display result
|
|
203
|
+
console.log(` ${colors.bold}Phase:${colors.reset} ${result.phase}`);
|
|
204
|
+
console.log(` ${colors.bold}Gates:${colors.reset} ${result.gatesPass ? colors.green + 'PASS' : colors.red + 'FAIL'}${colors.reset}`);
|
|
205
|
+
const recColors = {
|
|
206
|
+
approve: colors.green,
|
|
207
|
+
request_changes: colors.red,
|
|
208
|
+
comment: colors.yellow,
|
|
209
|
+
};
|
|
210
|
+
console.log(` ${colors.bold}Recommendation:${colors.reset} ${recColors[result.recommendation]}${result.recommendation}${colors.reset}`);
|
|
211
|
+
if (result.comments.length > 0) {
|
|
212
|
+
console.log(`\n ${colors.bold}Comments:${colors.reset}`);
|
|
213
|
+
for (const comment of result.comments) {
|
|
214
|
+
console.log(` ${colors.dim}-${colors.reset} ${comment}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
console.log('');
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=github-integration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-integration.js","sourceRoot":"","sources":["../src/github-integration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAiB7C;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,gDAAgD;IAChD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;IACxE,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAExB,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QACf,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QACd,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAChC,GAAG;KACJ,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,KAAa,EACb,cAAsB,OAAO,CAAC,GAAG,EAAE;IAEnC,MAAM,QAAQ,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAE7B,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,SAAS;YAChB,QAAQ,EAAE,CAAC,uBAAuB,CAAC;YACnC,SAAS,EAAE,KAAK;YAChB,cAAc,EAAE,SAAS;SAC1B,CAAC;I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C,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic Phase Detection
|
|
3
|
+
*
|
|
4
|
+
* This module detects the current development phase based on artifacts and file
|
|
5
|
+
* existence, NOT AI inference. This provides consistent, reproducible results.
|
|
6
|
+
*
|
|
7
|
+
* Phase detection rules:
|
|
8
|
+
*
|
|
9
|
+
* PLAN phase:
|
|
10
|
+
* - IDEA: No planning docs exist
|
|
11
|
+
* - RESEARCH: Only partial ideas documented
|
|
12
|
+
* - BRAINLIFT: brainlift.md missing or incomplete
|
|
13
|
+
* - PRD: prd.md missing or incomplete
|
|
14
|
+
* - GAMEPLAN: gameplan.md missing or incomplete
|
|
15
|
+
*
|
|
16
|
+
* BUILD phase:
|
|
17
|
+
* - RULES: .cursorrules missing
|
|
18
|
+
* - INDEX/READ/RESEARCH: Early development, few source files
|
|
19
|
+
* - IMPLEMENT: Active development, gameplan tasks in progress
|
|
20
|
+
* - TEST: Tests exist but may be failing
|
|
21
|
+
* - DEBUG: Gates failing, errors present
|
|
22
|
+
*
|
|
23
|
+
* SHIP phase:
|
|
24
|
+
* - REVIEW: All gates pass, preparing for release
|
|
25
|
+
* - DEPLOY: Version bumped, deploying
|
|
26
|
+
* - MONITOR: Deployed, watching
|
|
27
|
+
*
|
|
28
|
+
* GROW phase:
|
|
29
|
+
* - DONE: Project shipped and live
|
|
30
|
+
*/
|
|
31
|
+
import type { Phase } from './state/phase.js';
|
|
32
|
+
export interface DetectionResult {
|
|
33
|
+
phase: Phase;
|
|
34
|
+
confidence: number;
|
|
35
|
+
reason: string;
|
|
36
|
+
artifacts: string[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Detect current phase from artifacts only - no AI calls
|
|
40
|
+
*/
|
|
41
|
+
export declare function detectPhaseFromArtifacts(projectPath: string): DetectionResult;
|
|
42
|
+
/**
|
|
43
|
+
* Format detection result for display
|
|
44
|
+
*/
|
|
45
|
+
export declare function formatDetection(result: DetectionResult): string;
|
|
46
|
+
//# sourceMappingURL=phase-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phase-detector.d.ts","sourceRoot":"","sources":["../src/phase-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAKH,OAAO,KAAK,EAAE,KAAK,EAA2C,MAAM,kBAAkB,CAAC;AAMvF,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,eAAe,CAwJ7E;AA+ED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAQ/D"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic Phase Detection
|
|
3
|
+
*
|
|
4
|
+
* This module detects the current development phase based on artifacts and file
|
|
5
|
+
* existence, NOT AI inference. This provides consistent, reproducible results.
|
|
6
|
+
*
|
|
7
|
+
* Phase detection rules:
|
|
8
|
+
*
|
|
9
|
+
* PLAN phase:
|
|
10
|
+
* - IDEA: No planning docs exist
|
|
11
|
+
* - RESEARCH: Only partial ideas documented
|
|
12
|
+
* - BRAINLIFT: brainlift.md missing or incomplete
|
|
13
|
+
* - PRD: prd.md missing or incomplete
|
|
14
|
+
* - GAMEPLAN: gameplan.md missing or incomplete
|
|
15
|
+
*
|
|
16
|
+
* BUILD phase:
|
|
17
|
+
* - RULES: .cursorrules missing
|
|
18
|
+
* - INDEX/READ/RESEARCH: Early development, few source files
|
|
19
|
+
* - IMPLEMENT: Active development, gameplan tasks in progress
|
|
20
|
+
* - TEST: Tests exist but may be failing
|
|
21
|
+
* - DEBUG: Gates failing, errors present
|
|
22
|
+
*
|
|
23
|
+
* SHIP phase:
|
|
24
|
+
* - REVIEW: All gates pass, preparing for release
|
|
25
|
+
* - DEPLOY: Version bumped, deploying
|
|
26
|
+
* - MONITOR: Deployed, watching
|
|
27
|
+
*
|
|
28
|
+
* GROW phase:
|
|
29
|
+
* - DONE: Project shipped and live
|
|
30
|
+
*/
|
|
31
|
+
import { existsSync, readdirSync } from 'fs';
|
|
32
|
+
import { join } from 'path';
|
|
33
|
+
import { execSync } from 'child_process';
|
|
34
|
+
import { discoverDocsSync } from './docs-discovery.js';
|
|
35
|
+
import { getGatesStatus } from './tracker.js';
|
|
36
|
+
import { getGameplanProgress } from './gameplan-tracker.js';
|
|
37
|
+
import { sanitizePath, isShellSafe } from './security.js';
|
|
38
|
+
/**
|
|
39
|
+
* Detect current phase from artifacts only - no AI calls
|
|
40
|
+
*/
|
|
41
|
+
export function detectPhaseFromArtifacts(projectPath) {
|
|
42
|
+
const safePath = sanitizePath(projectPath);
|
|
43
|
+
// Check planning docs
|
|
44
|
+
const docs = discoverDocsSync(safePath);
|
|
45
|
+
const hasBrainlift = !!docs.brainlift;
|
|
46
|
+
const hasPrd = !!docs.prd;
|
|
47
|
+
const hasGameplan = !!docs.gameplan;
|
|
48
|
+
const hasCursorrules = existsSync(join(safePath, '.cursorrules'));
|
|
49
|
+
// Check source files
|
|
50
|
+
const hasSrc = existsSync(join(safePath, 'src'));
|
|
51
|
+
const srcFileCount = hasSrc ? countFiles(join(safePath, 'src')) : 0;
|
|
52
|
+
// Check tests
|
|
53
|
+
const hasTests = existsSync(join(safePath, 'src', 'tests')) ||
|
|
54
|
+
existsSync(join(safePath, 'tests')) ||
|
|
55
|
+
existsSync(join(safePath, '__tests__'));
|
|
56
|
+
// Check gates
|
|
57
|
+
const gates = getGatesStatus(safePath);
|
|
58
|
+
// Check git for version/deploy signals
|
|
59
|
+
const gitSignals = getGitSignals(safePath);
|
|
60
|
+
// Check gameplan progress
|
|
61
|
+
const gameplan = getGameplanProgress(safePath);
|
|
62
|
+
// Decision tree (order matters - most specific first)
|
|
63
|
+
// GROW: Deployed and live
|
|
64
|
+
if (gitSignals.hasVersionTag && gitSignals.recentPublish) {
|
|
65
|
+
return {
|
|
66
|
+
phase: { phase: 'GROW', step: 'DONE' },
|
|
67
|
+
confidence: 90,
|
|
68
|
+
reason: 'Project has version tags and recent publish commits',
|
|
69
|
+
artifacts: ['git tags', 'publish commits'],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// SHIP: Gates pass, preparing for release
|
|
73
|
+
if (gates.allPass && hasGameplan && gameplan.actual >= 80) {
|
|
74
|
+
if (gitSignals.hasVersionBump) {
|
|
75
|
+
return {
|
|
76
|
+
phase: { phase: 'SHIP', step: 'DEPLOY' },
|
|
77
|
+
confidence: 85,
|
|
78
|
+
reason: 'Version bumped, ready to deploy',
|
|
79
|
+
artifacts: ['package.json version', 'passing gates'],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
phase: { phase: 'SHIP', step: 'REVIEW' },
|
|
84
|
+
confidence: 80,
|
|
85
|
+
reason: 'All gates pass, gameplan mostly complete',
|
|
86
|
+
artifacts: ['gates', 'gameplan progress'],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
// BUILD: Active development
|
|
90
|
+
if (hasCursorrules && hasSrc) {
|
|
91
|
+
// DEBUG: Gates failing
|
|
92
|
+
if (gates.failing.length > 0) {
|
|
93
|
+
return {
|
|
94
|
+
phase: { phase: 'BUILD', step: 'DEBUG' },
|
|
95
|
+
confidence: 85,
|
|
96
|
+
reason: `Gates failing: ${gates.failing.join(', ')}`,
|
|
97
|
+
artifacts: ['gates status'],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
// TEST: Tests exist, running verification
|
|
101
|
+
if (hasTests && gates.allPass) {
|
|
102
|
+
return {
|
|
103
|
+
phase: { phase: 'BUILD', step: 'TEST' },
|
|
104
|
+
confidence: 75,
|
|
105
|
+
reason: 'Tests present and passing, verifying',
|
|
106
|
+
artifacts: ['tests', 'gates'],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
// IMPLEMENT: Actively coding
|
|
110
|
+
if (srcFileCount > 5) {
|
|
111
|
+
return {
|
|
112
|
+
phase: { phase: 'BUILD', step: 'IMPLEMENT' },
|
|
113
|
+
confidence: 70,
|
|
114
|
+
reason: 'Active development with source files',
|
|
115
|
+
artifacts: ['src files', '.cursorrules'],
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
// INDEX/READ: Early development
|
|
119
|
+
return {
|
|
120
|
+
phase: { phase: 'BUILD', step: 'INDEX' },
|
|
121
|
+
confidence: 65,
|
|
122
|
+
reason: 'Project initialized, exploring codebase',
|
|
123
|
+
artifacts: ['.cursorrules'],
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
// BUILD:RULES - Need to set up conventions
|
|
127
|
+
if (hasGameplan && !hasCursorrules) {
|
|
128
|
+
return {
|
|
129
|
+
phase: { phase: 'BUILD', step: 'RULES' },
|
|
130
|
+
confidence: 80,
|
|
131
|
+
reason: 'Gameplan exists but .cursorrules missing',
|
|
132
|
+
artifacts: ['gameplan.md'],
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
// PLAN phase - determine which step based on docs
|
|
136
|
+
if (!hasBrainlift) {
|
|
137
|
+
if (!docs.brainlift && !docs.prd && !docs.gameplan) {
|
|
138
|
+
return {
|
|
139
|
+
phase: { phase: 'PLAN', step: 'IDEA' },
|
|
140
|
+
confidence: 90,
|
|
141
|
+
reason: 'No planning docs exist',
|
|
142
|
+
artifacts: [],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
phase: { phase: 'PLAN', step: 'BRAINLIFT' },
|
|
147
|
+
confidence: 80,
|
|
148
|
+
reason: 'brainlift.md missing',
|
|
149
|
+
artifacts: [],
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
if (!hasPrd) {
|
|
153
|
+
return {
|
|
154
|
+
phase: { phase: 'PLAN', step: 'PRD' },
|
|
155
|
+
confidence: 80,
|
|
156
|
+
reason: 'prd.md missing',
|
|
157
|
+
artifacts: ['brainlift.md'],
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (!hasGameplan) {
|
|
161
|
+
return {
|
|
162
|
+
phase: { phase: 'PLAN', step: 'GAMEPLAN' },
|
|
163
|
+
confidence: 80,
|
|
164
|
+
reason: 'gameplan.md missing',
|
|
165
|
+
artifacts: ['brainlift.md', 'prd.md'],
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
// All planning docs exist but no .cursorrules - ready to build
|
|
169
|
+
return {
|
|
170
|
+
phase: { phase: 'BUILD', step: 'RULES' },
|
|
171
|
+
confidence: 85,
|
|
172
|
+
reason: 'All planning docs complete, ready to start building',
|
|
173
|
+
artifacts: ['brainlift.md', 'prd.md', 'gameplan.md'],
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Count files in a directory recursively
|
|
178
|
+
*/
|
|
179
|
+
function countFiles(dir, depth = 0) {
|
|
180
|
+
if (depth > 5 || !existsSync(dir))
|
|
181
|
+
return 0;
|
|
182
|
+
let count = 0;
|
|
183
|
+
const ignore = ['node_modules', '.git', 'dist', 'build', '.next', '__pycache__'];
|
|
184
|
+
try {
|
|
185
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
186
|
+
if (ignore.includes(entry.name) || entry.name.startsWith('.'))
|
|
187
|
+
continue;
|
|
188
|
+
if (entry.isDirectory()) {
|
|
189
|
+
count += countFiles(join(dir, entry.name), depth + 1);
|
|
190
|
+
}
|
|
191
|
+
else if (entry.name.endsWith('.ts') || entry.name.endsWith('.js') ||
|
|
192
|
+
entry.name.endsWith('.tsx') || entry.name.endsWith('.jsx')) {
|
|
193
|
+
count++;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
// Ignore errors
|
|
199
|
+
}
|
|
200
|
+
return count;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Get signals from git history about deployment status
|
|
204
|
+
*/
|
|
205
|
+
function getGitSignals(projectPath) {
|
|
206
|
+
const signals = {
|
|
207
|
+
hasVersionTag: false,
|
|
208
|
+
hasVersionBump: false,
|
|
209
|
+
recentPublish: false,
|
|
210
|
+
};
|
|
211
|
+
if (!existsSync(join(projectPath, '.git')) || !isShellSafe(projectPath)) {
|
|
212
|
+
return signals;
|
|
213
|
+
}
|
|
214
|
+
try {
|
|
215
|
+
// Check for version tags
|
|
216
|
+
const tags = execSync('git tag -l "v*"', {
|
|
217
|
+
cwd: projectPath,
|
|
218
|
+
encoding: 'utf-8',
|
|
219
|
+
timeout: 5000,
|
|
220
|
+
}).trim();
|
|
221
|
+
signals.hasVersionTag = tags.length > 0;
|
|
222
|
+
// Check recent commits for version bump / publish
|
|
223
|
+
const recentCommits = execSync('git log -10 --format=%s', {
|
|
224
|
+
cwd: projectPath,
|
|
225
|
+
encoding: 'utf-8',
|
|
226
|
+
timeout: 5000,
|
|
227
|
+
}).toLowerCase();
|
|
228
|
+
signals.hasVersionBump = recentCommits.includes('bump') ||
|
|
229
|
+
recentCommits.includes('version') ||
|
|
230
|
+
/\d+\.\d+\.\d+/.test(recentCommits);
|
|
231
|
+
signals.recentPublish = recentCommits.includes('publish') ||
|
|
232
|
+
recentCommits.includes('release') ||
|
|
233
|
+
recentCommits.includes('deploy');
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
// Ignore git errors
|
|
237
|
+
}
|
|
238
|
+
return signals;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Format detection result for display
|
|
242
|
+
*/
|
|
243
|
+
export function formatDetection(result) {
|
|
244
|
+
const phase = result.phase;
|
|
245
|
+
const phaseStr = phase.phase === 'IDLE' ? 'IDLE' :
|
|
246
|
+
`${phase.phase}:${phase.step}`;
|
|
247
|
+
return `Phase: ${phaseStr} (${result.confidence}% confidence)
|
|
248
|
+
Reason: ${result.reason}
|
|
249
|
+
Artifacts: ${result.artifacts.length > 0 ? result.artifacts.join(', ') : 'none'}`;
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=phase-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phase-detector.js","sourceRoot":"","sources":["../src/phase-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,UAAU,EAAY,WAAW,EAAE,MAAM,IAAI,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAS1D;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,WAAmB;IAC1D,MAAM,QAAQ,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;IAE3C,sBAAsB;IACtB,MAAM,IAAI,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACxC,MAAM,YAAY,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;IACtC,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;IAC1B,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IACpC,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;IAElE,qBAAqB;IACrB,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,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AG,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC;YACjC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC;YACjC,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC3D,CAAC;IAAC,MAAM,CAAC;QACP,oBAAoB;IACtB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAuB;IACrD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAC3B,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACjC,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;IAEhD,OAAO,UAAU,QAAQ,KAAK,MAAM,CAAC,UAAU;UACvC,MAAM,CAAC,MAAM;aACV,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;AAClF,CAAC"}
|
package/dist/pilot.d.ts
CHANGED
|
@@ -28,6 +28,55 @@ export interface PilotConfig {
|
|
|
28
28
|
allowedTools: string[];
|
|
29
29
|
pollInterval: number;
|
|
30
30
|
outputFormat: 'text' | 'json' | 'stream-json';
|
|
31
|
+
useStructuredOutput: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* JSON Schema for structured pilot execution results
|
|
35
|
+
* Using Claude Code's --json-schema flag for guaranteed valid output
|
|
36
|
+
*/
|
|
37
|
+
export declare const PILOT_RESULT_SCHEMA: {
|
|
38
|
+
readonly type: "object";
|
|
39
|
+
readonly properties: {
|
|
40
|
+
readonly success: {
|
|
41
|
+
readonly type: "boolean";
|
|
42
|
+
readonly description: "Whether the task was completed successfully";
|
|
43
|
+
};
|
|
44
|
+
readonly summary: {
|
|
45
|
+
readonly type: "string";
|
|
46
|
+
readonly description: "Brief summary of what was accomplished";
|
|
47
|
+
};
|
|
48
|
+
readonly filesChanged: {
|
|
49
|
+
readonly type: "array";
|
|
50
|
+
readonly items: {
|
|
51
|
+
readonly type: "string";
|
|
52
|
+
};
|
|
53
|
+
readonly description: "List of files that were modified";
|
|
54
|
+
};
|
|
55
|
+
readonly testsPass: {
|
|
56
|
+
readonly type: "boolean";
|
|
57
|
+
readonly description: "Whether tests pass after the changes";
|
|
58
|
+
};
|
|
59
|
+
readonly nextSuggestion: {
|
|
60
|
+
readonly type: "string";
|
|
61
|
+
readonly description: "Suggested next action from gameplan";
|
|
62
|
+
};
|
|
63
|
+
readonly errors: {
|
|
64
|
+
readonly type: "array";
|
|
65
|
+
readonly items: {
|
|
66
|
+
readonly type: "string";
|
|
67
|
+
};
|
|
68
|
+
readonly description: "Any errors encountered";
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
readonly required: readonly ["success", "summary"];
|
|
72
|
+
};
|
|
73
|
+
export interface StructuredPilotResult {
|
|
74
|
+
success: boolean;
|
|
75
|
+
summary: string;
|
|
76
|
+
filesChanged?: string[];
|
|
77
|
+
testsPass?: boolean;
|
|
78
|
+
nextSuggestion?: string;
|
|
79
|
+
errors?: string[];
|
|
31
80
|
}
|
|
32
81
|
export interface ExecutionResult {
|
|
33
82
|
success: boolean;
|
|
@@ -38,6 +87,8 @@ export interface ExecutionResult {
|
|
|
38
87
|
}
|
|
39
88
|
/**
|
|
40
89
|
* Execute a prompt via Claude Code CLI
|
|
90
|
+
*
|
|
91
|
+
* Supports structured output via --json-schema for deterministic parsing
|
|
41
92
|
*/
|
|
42
93
|
export declare function executeClaudeCode(prompt: string, config?: Partial<PilotConfig>): Promise<ExecutionResult>;
|
|
43
94
|
/**
|
package/dist/pilot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pilot.d.ts","sourceRoot":"","sources":["../src/pilot.ts"],"names":[],"mappings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