oh-my-claude-sisyphus 3.6.1 → 3.6.2
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/commands/psm.md +180 -0
- package/dist/__tests__/analytics/analytics-summary.test.d.ts +2 -0
- package/dist/__tests__/analytics/analytics-summary.test.d.ts.map +1 -0
- package/dist/__tests__/analytics/analytics-summary.test.js +267 -0
- package/dist/__tests__/analytics/analytics-summary.test.js.map +1 -0
- package/dist/__tests__/analytics/cost-estimator.test.d.ts +2 -0
- package/dist/__tests__/analytics/cost-estimator.test.d.ts.map +1 -0
- package/dist/__tests__/analytics/cost-estimator.test.js +212 -0
- package/dist/__tests__/analytics/cost-estimator.test.js.map +1 -0
- package/dist/__tests__/hooks/auto-slash-command/executor.test.d.ts +7 -0
- package/dist/__tests__/hooks/auto-slash-command/executor.test.d.ts.map +1 -0
- package/dist/__tests__/hooks/auto-slash-command/executor.test.js +374 -0
- package/dist/__tests__/hooks/auto-slash-command/executor.test.js.map +1 -0
- package/dist/__tests__/hud/auto-tracking.integration.test.d.ts +2 -0
- package/dist/__tests__/hud/auto-tracking.integration.test.d.ts.map +1 -0
- package/dist/__tests__/hud/auto-tracking.integration.test.js +12 -0
- package/dist/__tests__/hud/auto-tracking.integration.test.js.map +1 -0
- package/dist/__tests__/learned-skills/config.test.d.ts +2 -0
- package/dist/__tests__/learned-skills/config.test.d.ts.map +1 -0
- package/dist/__tests__/learned-skills/config.test.js +37 -0
- package/dist/__tests__/learned-skills/config.test.js.map +1 -0
- package/dist/__tests__/learned-skills/detector.test.d.ts +2 -0
- package/dist/__tests__/learned-skills/detector.test.d.ts.map +1 -0
- package/dist/__tests__/learned-skills/detector.test.js +99 -0
- package/dist/__tests__/learned-skills/detector.test.js.map +1 -0
- package/dist/__tests__/learned-skills/finder.test.d.ts +2 -0
- package/dist/__tests__/learned-skills/finder.test.d.ts.map +1 -0
- package/dist/__tests__/learned-skills/finder.test.js +59 -0
- package/dist/__tests__/learned-skills/finder.test.js.map +1 -0
- package/dist/__tests__/learned-skills/loader.test.d.ts +2 -0
- package/dist/__tests__/learned-skills/loader.test.d.ts.map +1 -0
- package/dist/__tests__/learned-skills/loader.test.js +69 -0
- package/dist/__tests__/learned-skills/loader.test.js.map +1 -0
- package/dist/__tests__/learned-skills/parser.test.d.ts +2 -0
- package/dist/__tests__/learned-skills/parser.test.d.ts.map +1 -0
- package/dist/__tests__/learned-skills/parser.test.js +81 -0
- package/dist/__tests__/learned-skills/parser.test.js.map +1 -0
- package/dist/__tests__/learned-skills/validator.test.d.ts +2 -0
- package/dist/__tests__/learned-skills/validator.test.d.ts.map +1 -0
- package/dist/__tests__/learned-skills/validator.test.js +85 -0
- package/dist/__tests__/learned-skills/validator.test.js.map +1 -0
- package/dist/agents/codex-agents.d.ts +20 -0
- package/dist/agents/codex-agents.d.ts.map +1 -0
- package/dist/agents/codex-agents.js +36 -0
- package/dist/agents/codex-agents.js.map +1 -0
- package/dist/agents/document-writer.d.ts +11 -0
- package/dist/agents/document-writer.d.ts.map +1 -0
- package/dist/agents/document-writer.js +209 -0
- package/dist/agents/document-writer.js.map +1 -0
- package/dist/agents/frontend-engineer.d.ts +11 -0
- package/dist/agents/frontend-engineer.d.ts.map +1 -0
- package/dist/agents/frontend-engineer.js +115 -0
- package/dist/agents/frontend-engineer.js.map +1 -0
- package/dist/agents/librarian.d.ts +12 -0
- package/dist/agents/librarian.d.ts.map +1 -0
- package/dist/agents/librarian.js +103 -0
- package/dist/agents/librarian.js.map +1 -0
- package/dist/agents/metis.d.ts +12 -0
- package/dist/agents/metis.d.ts.map +1 -0
- package/dist/agents/metis.js +117 -0
- package/dist/agents/metis.js.map +1 -0
- package/dist/agents/momus.d.ts +12 -0
- package/dist/agents/momus.d.ts.map +1 -0
- package/dist/agents/momus.js +128 -0
- package/dist/agents/momus.js.map +1 -0
- package/dist/agents/multimodal-looker.d.ts +11 -0
- package/dist/agents/multimodal-looker.d.ts.map +1 -0
- package/dist/agents/multimodal-looker.js +70 -0
- package/dist/agents/multimodal-looker.js.map +1 -0
- package/dist/agents/oracle.d.ts +13 -0
- package/dist/agents/oracle.d.ts.map +1 -0
- package/dist/agents/oracle.js +191 -0
- package/dist/agents/oracle.js.map +1 -0
- package/dist/agents/orchestrator-sisyphus.d.ts +11 -0
- package/dist/agents/orchestrator-sisyphus.d.ts.map +1 -0
- package/dist/agents/orchestrator-sisyphus.js +115 -0
- package/dist/agents/orchestrator-sisyphus.js.map +1 -0
- package/dist/agents/prometheus.d.ts +12 -0
- package/dist/agents/prometheus.d.ts.map +1 -0
- package/dist/agents/prometheus.js +195 -0
- package/dist/agents/prometheus.js.map +1 -0
- package/dist/agents/sisyphus-junior.d.ts +12 -0
- package/dist/agents/sisyphus-junior.d.ts.map +1 -0
- package/dist/agents/sisyphus-junior.js +93 -0
- package/dist/agents/sisyphus-junior.js.map +1 -0
- package/dist/cli/analytics.js +0 -0
- package/dist/cli/components/CostDashboard.d.ts +15 -0
- package/dist/cli/components/CostDashboard.d.ts.map +1 -0
- package/dist/cli/components/CostDashboard.js +15 -0
- package/dist/cli/components/CostDashboard.js.map +1 -0
- package/dist/cli/components/LiveStats.d.ts +16 -0
- package/dist/cli/components/LiveStats.d.ts.map +1 -0
- package/dist/cli/components/LiveStats.js +16 -0
- package/dist/cli/components/LiveStats.js.map +1 -0
- package/dist/cli/components/SessionBrowser.d.ts +14 -0
- package/dist/cli/components/SessionBrowser.d.ts.map +1 -0
- package/dist/cli/components/SessionBrowser.js +14 -0
- package/dist/cli/components/SessionBrowser.js.map +1 -0
- package/dist/cli/index.js +0 -0
- package/dist/cli/tui.d.ts +21 -0
- package/dist/cli/tui.d.ts.map +1 -0
- package/dist/cli/tui.js +21 -0
- package/dist/cli/tui.js.map +1 -0
- package/dist/hooks/autopilot/signals.d.ts +20 -0
- package/dist/hooks/autopilot/signals.d.ts.map +1 -0
- package/dist/hooks/autopilot/signals.js +75 -0
- package/dist/hooks/autopilot/signals.js.map +1 -0
- package/dist/hooks/autopilot/summary.d.ts +27 -0
- package/dist/hooks/autopilot/summary.d.ts.map +1 -0
- package/dist/hooks/autopilot/summary.js +160 -0
- package/dist/hooks/autopilot/summary.js.map +1 -0
- package/dist/hooks/autopilot/transition.d.ts +39 -0
- package/dist/hooks/autopilot/transition.d.ts.map +1 -0
- package/dist/hooks/autopilot/transition.js +216 -0
- package/dist/hooks/autopilot/transition.js.map +1 -0
- package/dist/hooks/context-window-limit-recovery/constants.d.ts +28 -0
- package/dist/hooks/context-window-limit-recovery/constants.d.ts.map +1 -0
- package/dist/hooks/context-window-limit-recovery/constants.js +85 -0
- package/dist/hooks/context-window-limit-recovery/constants.js.map +1 -0
- package/dist/hooks/context-window-limit-recovery/index.d.ts +62 -0
- package/dist/hooks/context-window-limit-recovery/index.d.ts.map +1 -0
- package/dist/hooks/context-window-limit-recovery/index.js +201 -0
- package/dist/hooks/context-window-limit-recovery/index.js.map +1 -0
- package/dist/hooks/context-window-limit-recovery/parser.d.ts +31 -0
- package/dist/hooks/context-window-limit-recovery/parser.d.ts.map +1 -0
- package/dist/hooks/context-window-limit-recovery/parser.js +241 -0
- package/dist/hooks/context-window-limit-recovery/parser.js.map +1 -0
- package/dist/hooks/context-window-limit-recovery/types.d.ts +84 -0
- package/dist/hooks/context-window-limit-recovery/types.d.ts.map +1 -0
- package/dist/hooks/context-window-limit-recovery/types.js +34 -0
- package/dist/hooks/context-window-limit-recovery/types.js.map +1 -0
- package/dist/hooks/edit-error-recovery/index.d.ts +62 -0
- package/dist/hooks/edit-error-recovery/index.d.ts.map +1 -0
- package/dist/hooks/edit-error-recovery/index.js +89 -0
- package/dist/hooks/edit-error-recovery/index.js.map +1 -0
- package/dist/hooks/learned-skills/config.d.ts +53 -0
- package/dist/hooks/learned-skills/config.d.ts.map +1 -0
- package/dist/hooks/learned-skills/config.js +103 -0
- package/dist/hooks/learned-skills/config.js.map +1 -0
- package/dist/hooks/learned-skills/constants.d.ts +24 -0
- package/dist/hooks/learned-skills/constants.d.ts.map +1 -0
- package/dist/hooks/learned-skills/constants.js +26 -0
- package/dist/hooks/learned-skills/constants.js.map +1 -0
- package/dist/hooks/learned-skills/detection-hook.d.ts +39 -0
- package/dist/hooks/learned-skills/detection-hook.d.ts.map +1 -0
- package/dist/hooks/learned-skills/detection-hook.js +83 -0
- package/dist/hooks/learned-skills/detection-hook.js.map +1 -0
- package/dist/hooks/learned-skills/detector.d.ts +30 -0
- package/dist/hooks/learned-skills/detector.d.ts.map +1 -0
- package/dist/hooks/learned-skills/detector.js +150 -0
- package/dist/hooks/learned-skills/detector.js.map +1 -0
- package/dist/hooks/learned-skills/finder.d.ts +21 -0
- package/dist/hooks/learned-skills/finder.d.ts.map +1 -0
- package/dist/hooks/learned-skills/finder.js +117 -0
- package/dist/hooks/learned-skills/finder.js.map +1 -0
- package/dist/hooks/learned-skills/index.d.ts +62 -0
- package/dist/hooks/learned-skills/index.d.ts.map +1 -0
- package/dist/hooks/learned-skills/index.js +137 -0
- package/dist/hooks/learned-skills/index.js.map +1 -0
- package/dist/hooks/learned-skills/loader.d.ts +20 -0
- package/dist/hooks/learned-skills/loader.d.ts.map +1 -0
- package/dist/hooks/learned-skills/loader.js +107 -0
- package/dist/hooks/learned-skills/loader.js.map +1 -0
- package/dist/hooks/learned-skills/parser.d.ts +21 -0
- package/dist/hooks/learned-skills/parser.d.ts.map +1 -0
- package/dist/hooks/learned-skills/parser.js +190 -0
- package/dist/hooks/learned-skills/parser.js.map +1 -0
- package/dist/hooks/learned-skills/promotion.d.ts +29 -0
- package/dist/hooks/learned-skills/promotion.d.ts.map +1 -0
- package/dist/hooks/learned-skills/promotion.js +87 -0
- package/dist/hooks/learned-skills/promotion.js.map +1 -0
- package/dist/hooks/learned-skills/types.d.ts +109 -0
- package/dist/hooks/learned-skills/types.d.ts.map +1 -0
- package/dist/hooks/learned-skills/types.js +8 -0
- package/dist/hooks/learned-skills/types.js.map +1 -0
- package/dist/hooks/learned-skills/validator.d.ts +15 -0
- package/dist/hooks/learned-skills/validator.d.ts.map +1 -0
- package/dist/hooks/learned-skills/validator.js +87 -0
- package/dist/hooks/learned-skills/validator.js.map +1 -0
- package/dist/hooks/learned-skills/writer.d.ts +27 -0
- package/dist/hooks/learned-skills/writer.d.ts.map +1 -0
- package/dist/hooks/learned-skills/writer.js +126 -0
- package/dist/hooks/learned-skills/writer.js.map +1 -0
- package/dist/hooks/mnemosyne/config.d.ts +53 -0
- package/dist/hooks/mnemosyne/config.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/config.js +103 -0
- package/dist/hooks/mnemosyne/config.js.map +1 -0
- package/dist/hooks/mnemosyne/constants.d.ts +24 -0
- package/dist/hooks/mnemosyne/constants.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/constants.js +26 -0
- package/dist/hooks/mnemosyne/constants.js.map +1 -0
- package/dist/hooks/mnemosyne/detection-hook.d.ts +39 -0
- package/dist/hooks/mnemosyne/detection-hook.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/detection-hook.js +83 -0
- package/dist/hooks/mnemosyne/detection-hook.js.map +1 -0
- package/dist/hooks/mnemosyne/detector.d.ts +30 -0
- package/dist/hooks/mnemosyne/detector.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/detector.js +150 -0
- package/dist/hooks/mnemosyne/detector.js.map +1 -0
- package/dist/hooks/mnemosyne/finder.d.ts +21 -0
- package/dist/hooks/mnemosyne/finder.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/finder.js +117 -0
- package/dist/hooks/mnemosyne/finder.js.map +1 -0
- package/dist/hooks/mnemosyne/index.d.ts +62 -0
- package/dist/hooks/mnemosyne/index.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/index.js +137 -0
- package/dist/hooks/mnemosyne/index.js.map +1 -0
- package/dist/hooks/mnemosyne/loader.d.ts +20 -0
- package/dist/hooks/mnemosyne/loader.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/loader.js +113 -0
- package/dist/hooks/mnemosyne/loader.js.map +1 -0
- package/dist/hooks/mnemosyne/parser.d.ts +21 -0
- package/dist/hooks/mnemosyne/parser.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/parser.js +190 -0
- package/dist/hooks/mnemosyne/parser.js.map +1 -0
- package/dist/hooks/mnemosyne/promotion.d.ts +29 -0
- package/dist/hooks/mnemosyne/promotion.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/promotion.js +87 -0
- package/dist/hooks/mnemosyne/promotion.js.map +1 -0
- package/dist/hooks/mnemosyne/types.d.ts +109 -0
- package/dist/hooks/mnemosyne/types.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/types.js +8 -0
- package/dist/hooks/mnemosyne/types.js.map +1 -0
- package/dist/hooks/mnemosyne/validator.d.ts +15 -0
- package/dist/hooks/mnemosyne/validator.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/validator.js +87 -0
- package/dist/hooks/mnemosyne/validator.js.map +1 -0
- package/dist/hooks/mnemosyne/writer.d.ts +27 -0
- package/dist/hooks/mnemosyne/writer.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/writer.js +126 -0
- package/dist/hooks/mnemosyne/writer.js.map +1 -0
- package/dist/hooks/ralph-loop/index.d.ts +116 -0
- package/dist/hooks/ralph-loop/index.d.ts.map +1 -0
- package/dist/hooks/ralph-loop/index.js +322 -0
- package/dist/hooks/ralph-loop/index.js.map +1 -0
- package/dist/hooks/ralph-prd/index.d.ts +130 -0
- package/dist/hooks/ralph-prd/index.d.ts.map +1 -0
- package/dist/hooks/ralph-prd/index.js +310 -0
- package/dist/hooks/ralph-prd/index.js.map +1 -0
- package/dist/hooks/ralph-progress/index.d.ts +102 -0
- package/dist/hooks/ralph-progress/index.d.ts.map +1 -0
- package/dist/hooks/ralph-progress/index.js +408 -0
- package/dist/hooks/ralph-progress/index.js.map +1 -0
- package/dist/hooks/ralph-verifier/index.d.ts +72 -0
- package/dist/hooks/ralph-verifier/index.d.ts.map +1 -0
- package/dist/hooks/ralph-verifier/index.js +223 -0
- package/dist/hooks/ralph-verifier/index.js.map +1 -0
- package/dist/hooks/session-recovery/constants.d.ts +56 -0
- package/dist/hooks/session-recovery/constants.d.ts.map +1 -0
- package/dist/hooks/session-recovery/constants.js +78 -0
- package/dist/hooks/session-recovery/constants.js.map +1 -0
- package/dist/hooks/session-recovery/index.d.ts +53 -0
- package/dist/hooks/session-recovery/index.d.ts.map +1 -0
- package/dist/hooks/session-recovery/index.js +321 -0
- package/dist/hooks/session-recovery/index.js.map +1 -0
- package/dist/hooks/session-recovery/storage.d.ts +76 -0
- package/dist/hooks/session-recovery/storage.d.ts.map +1 -0
- package/dist/hooks/session-recovery/storage.js +383 -0
- package/dist/hooks/session-recovery/storage.js.map +1 -0
- package/dist/hooks/session-recovery/types.d.ts +145 -0
- package/dist/hooks/session-recovery/types.d.ts.map +1 -0
- package/dist/hooks/session-recovery/types.js +8 -0
- package/dist/hooks/session-recovery/types.js.map +1 -0
- package/dist/hooks/sisyphus-orchestrator/constants.d.ts +23 -0
- package/dist/hooks/sisyphus-orchestrator/constants.d.ts.map +1 -0
- package/dist/hooks/sisyphus-orchestrator/constants.js +142 -0
- package/dist/hooks/sisyphus-orchestrator/constants.js.map +1 -0
- package/dist/hooks/sisyphus-orchestrator/index.d.ts +113 -0
- package/dist/hooks/sisyphus-orchestrator/index.d.ts.map +1 -0
- package/dist/hooks/sisyphus-orchestrator/index.js +309 -0
- package/dist/hooks/sisyphus-orchestrator/index.js.map +1 -0
- package/dist/hooks/subagent-tracker/index.d.ts +83 -0
- package/dist/hooks/subagent-tracker/index.d.ts.map +1 -0
- package/dist/hooks/subagent-tracker/index.js +207 -0
- package/dist/hooks/subagent-tracker/index.js.map +1 -0
- package/dist/hooks/ultraqa-loop/index.d.ts +94 -0
- package/dist/hooks/ultraqa-loop/index.d.ts.map +1 -0
- package/dist/hooks/ultraqa-loop/index.js +216 -0
- package/dist/hooks/ultraqa-loop/index.js.map +1 -0
- package/dist/hooks/ultrawork-state/index.d.ts +62 -0
- package/dist/hooks/ultrawork-state/index.d.ts.map +1 -0
- package/dist/hooks/ultrawork-state/index.js +208 -0
- package/dist/hooks/ultrawork-state/index.js.map +1 -0
- package/dist/hud/sisyphus-state.d.ts +31 -0
- package/dist/hud/sisyphus-state.d.ts.map +1 -0
- package/dist/hud/sisyphus-state.js +163 -0
- package/dist/hud/sisyphus-state.js.map +1 -0
- package/docs/design/project-session-manager.md +1033 -0
- package/package.json +1 -1
- package/skills/project-session-manager/SKILL.md +410 -0
- package/skills/project-session-manager/lib/config.sh +86 -0
- package/skills/project-session-manager/lib/parse.sh +121 -0
- package/skills/project-session-manager/lib/session.sh +132 -0
- package/skills/project-session-manager/lib/tmux.sh +103 -0
- package/skills/project-session-manager/lib/worktree.sh +171 -0
- package/skills/project-session-manager/psm.sh +629 -0
- package/skills/project-session-manager/templates/feature.md +56 -0
- package/skills/project-session-manager/templates/issue-fix.md +57 -0
- package/skills/project-session-manager/templates/pr-review.md +65 -0
- package/skills/project-session-manager/templates/projects.json +19 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autopilot Summary Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates human-readable summaries when autopilot completes.
|
|
5
|
+
*/
|
|
6
|
+
import { readAutopilotState } from './state.js';
|
|
7
|
+
/**
|
|
8
|
+
* Generate a summary of the autopilot run
|
|
9
|
+
*/
|
|
10
|
+
export function generateSummary(directory) {
|
|
11
|
+
const state = readAutopilotState(directory);
|
|
12
|
+
if (!state) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const startTime = new Date(state.started_at).getTime();
|
|
16
|
+
const endTime = state.completed_at
|
|
17
|
+
? new Date(state.completed_at).getTime()
|
|
18
|
+
: Date.now();
|
|
19
|
+
const duration = endTime - startTime;
|
|
20
|
+
const phasesCompleted = [];
|
|
21
|
+
if (state.expansion.spec_path)
|
|
22
|
+
phasesCompleted.push('expansion');
|
|
23
|
+
if (state.planning.approved)
|
|
24
|
+
phasesCompleted.push('planning');
|
|
25
|
+
if (state.execution.ralph_completed_at)
|
|
26
|
+
phasesCompleted.push('execution');
|
|
27
|
+
if (state.qa.qa_completed_at)
|
|
28
|
+
phasesCompleted.push('qa');
|
|
29
|
+
if (state.validation.all_approved)
|
|
30
|
+
phasesCompleted.push('validation');
|
|
31
|
+
if (state.phase === 'complete')
|
|
32
|
+
phasesCompleted.push('complete');
|
|
33
|
+
let testsStatus = 'Not run';
|
|
34
|
+
if (state.qa.test_status === 'passing') {
|
|
35
|
+
testsStatus = 'Passing';
|
|
36
|
+
}
|
|
37
|
+
else if (state.qa.test_status === 'failing') {
|
|
38
|
+
testsStatus = 'Failing';
|
|
39
|
+
}
|
|
40
|
+
else if (state.qa.test_status === 'skipped') {
|
|
41
|
+
testsStatus = 'Skipped';
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
originalIdea: state.originalIdea,
|
|
45
|
+
filesCreated: state.execution.files_created,
|
|
46
|
+
filesModified: state.execution.files_modified,
|
|
47
|
+
testsStatus,
|
|
48
|
+
duration,
|
|
49
|
+
agentsSpawned: state.total_agents_spawned,
|
|
50
|
+
phasesCompleted
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Format duration in human-readable format
|
|
55
|
+
*/
|
|
56
|
+
function formatDuration(ms) {
|
|
57
|
+
const seconds = Math.floor(ms / 1000);
|
|
58
|
+
const minutes = Math.floor(seconds / 60);
|
|
59
|
+
const hours = Math.floor(minutes / 60);
|
|
60
|
+
if (hours > 0) {
|
|
61
|
+
const remainingMinutes = minutes % 60;
|
|
62
|
+
return `${hours}h ${remainingMinutes}m`;
|
|
63
|
+
}
|
|
64
|
+
if (minutes > 0) {
|
|
65
|
+
const remainingSeconds = seconds % 60;
|
|
66
|
+
return `${minutes}m ${remainingSeconds}s`;
|
|
67
|
+
}
|
|
68
|
+
return `${seconds}s`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Generate formatted summary output
|
|
72
|
+
*/
|
|
73
|
+
export function formatSummary(summary) {
|
|
74
|
+
const lines = [
|
|
75
|
+
'',
|
|
76
|
+
'╭──────────────────────────────────────────────────────╮',
|
|
77
|
+
'│ AUTOPILOT COMPLETE │',
|
|
78
|
+
'├──────────────────────────────────────────────────────┤'
|
|
79
|
+
];
|
|
80
|
+
// Original idea (truncate if too long)
|
|
81
|
+
const ideaDisplay = summary.originalIdea.length > 50
|
|
82
|
+
? summary.originalIdea.substring(0, 47) + '...'
|
|
83
|
+
: summary.originalIdea;
|
|
84
|
+
lines.push(`│ Original Idea: ${ideaDisplay.padEnd(36)} │`);
|
|
85
|
+
lines.push('│ │');
|
|
86
|
+
// Delivered section
|
|
87
|
+
lines.push('│ Delivered: │');
|
|
88
|
+
lines.push(`│ • ${summary.filesCreated.length} files created${' '.repeat(36 - String(summary.filesCreated.length).length)}│`);
|
|
89
|
+
lines.push(`│ • ${summary.filesModified.length} files modified${' '.repeat(35 - String(summary.filesModified.length).length)}│`);
|
|
90
|
+
lines.push(`│ • Tests: ${summary.testsStatus}${' '.repeat(36 - summary.testsStatus.length)}│`);
|
|
91
|
+
lines.push('│ │');
|
|
92
|
+
// Metrics
|
|
93
|
+
lines.push('│ Metrics: │');
|
|
94
|
+
const durationStr = formatDuration(summary.duration);
|
|
95
|
+
lines.push(`│ • Duration: ${durationStr}${' '.repeat(35 - durationStr.length)}│`);
|
|
96
|
+
lines.push(`│ • Agents spawned: ${summary.agentsSpawned}${' '.repeat(30 - String(summary.agentsSpawned).length)}│`);
|
|
97
|
+
lines.push(`│ • Phases completed: ${summary.phasesCompleted.length}/5${' '.repeat(27)}│`);
|
|
98
|
+
lines.push('╰──────────────────────────────────────────────────────╯');
|
|
99
|
+
lines.push('');
|
|
100
|
+
return lines.join('\n');
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Generate a compact summary for HUD display
|
|
104
|
+
*/
|
|
105
|
+
export function formatCompactSummary(state) {
|
|
106
|
+
const phase = state.phase.toUpperCase();
|
|
107
|
+
const files = state.execution.files_created.length + state.execution.files_modified.length;
|
|
108
|
+
const agents = state.total_agents_spawned;
|
|
109
|
+
if (state.phase === 'complete') {
|
|
110
|
+
return `[AUTOPILOT ✓] Complete | ${files} files | ${agents} agents`;
|
|
111
|
+
}
|
|
112
|
+
if (state.phase === 'failed') {
|
|
113
|
+
return `[AUTOPILOT ✗] Failed at ${state.phase}`;
|
|
114
|
+
}
|
|
115
|
+
const phaseIndex = ['expansion', 'planning', 'execution', 'qa', 'validation'].indexOf(state.phase);
|
|
116
|
+
return `[AUTOPILOT] Phase ${phaseIndex + 1}/5: ${phase} | ${files} files`;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Generate failure summary
|
|
120
|
+
*/
|
|
121
|
+
export function formatFailureSummary(state, error) {
|
|
122
|
+
const lines = [
|
|
123
|
+
'',
|
|
124
|
+
'╭──────────────────────────────────────────────────────╮',
|
|
125
|
+
'│ AUTOPILOT FAILED │',
|
|
126
|
+
'├──────────────────────────────────────────────────────┤',
|
|
127
|
+
`│ Failed at phase: ${state.phase.toUpperCase().padEnd(33)} │`
|
|
128
|
+
];
|
|
129
|
+
if (error) {
|
|
130
|
+
const errorLines = error.match(/.{1,48}/g) || [error];
|
|
131
|
+
lines.push('│ │');
|
|
132
|
+
lines.push('│ Error: │');
|
|
133
|
+
for (const line of errorLines.slice(0, 3)) {
|
|
134
|
+
lines.push(`│ ${line.padEnd(50)} │`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
lines.push('│ │');
|
|
138
|
+
lines.push('│ Progress preserved. Run /autopilot to resume. │');
|
|
139
|
+
lines.push('╰──────────────────────────────────────────────────────╯');
|
|
140
|
+
lines.push('');
|
|
141
|
+
return lines.join('\n');
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* List files for detailed summary
|
|
145
|
+
*/
|
|
146
|
+
export function formatFileList(files, title, maxFiles = 10) {
|
|
147
|
+
if (files.length === 0) {
|
|
148
|
+
return '';
|
|
149
|
+
}
|
|
150
|
+
const lines = [`\n### ${title} (${files.length})`];
|
|
151
|
+
const displayFiles = files.slice(0, maxFiles);
|
|
152
|
+
for (const file of displayFiles) {
|
|
153
|
+
lines.push(`- ${file}`);
|
|
154
|
+
}
|
|
155
|
+
if (files.length > maxFiles) {
|
|
156
|
+
lines.push(`- ... and ${files.length - maxFiles} more`);
|
|
157
|
+
}
|
|
158
|
+
return lines.join('\n');
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=summary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summary.js","sourceRoot":"","sources":["../../../src/hooks/autopilot/summary.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGhD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,MAAM,KAAK,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC5C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC;IACvD,MAAM,OAAO,GAAG,KAAK,CAAC,YAAY;QAChC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;QACxC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;IACf,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;IAErC,MAAM,eAAe,GAAqB,EAAE,CAAC;IAC7C,IAAI,KAAK,CAAC,SAAS,CAAC,SAAS;QAAE,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACjE,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ;QAAE,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9D,IAAI,KAAK,CAAC,SA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AAC,CAAC;IACvE,KAAK,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;IACvE,KAAK,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;IACvE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAe,EAAE,KAAa,EAAE,WAAmB,EAAE;IAClF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,KAAK,GAAa,CAAC,SAAS,KAAK,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAE7D,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC9C,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,GAAG,QAAQ,EAAE,CAAC;QAC5B,KAAK,CAAC,IAAI,CAAC,aAAa,KAAK,CAAC,MAAM,GAAG,QAAQ,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autopilot Phase Transitions
|
|
3
|
+
*
|
|
4
|
+
* Handles transitions between phases, especially the critical Ralph → UltraQA
|
|
5
|
+
* and UltraQA → Validation transitions that must respect mutual exclusion.
|
|
6
|
+
*/
|
|
7
|
+
import type { AutopilotState } from './types.js';
|
|
8
|
+
export interface TransitionResult {
|
|
9
|
+
success: boolean;
|
|
10
|
+
error?: string;
|
|
11
|
+
state?: AutopilotState;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Transition from Ralph (Phase 2: Execution) to UltraQA (Phase 3: QA)
|
|
15
|
+
*
|
|
16
|
+
* This handles the mutual exclusion by:
|
|
17
|
+
* 1. Saving Ralph's progress to autopilot state
|
|
18
|
+
* 2. Cleanly terminating Ralph mode (and linked Ultrawork)
|
|
19
|
+
* 3. Starting UltraQA mode
|
|
20
|
+
* 4. Preserving context for potential rollback
|
|
21
|
+
*/
|
|
22
|
+
export declare function transitionRalphToUltraQA(directory: string, sessionId: string): TransitionResult;
|
|
23
|
+
/**
|
|
24
|
+
* Transition from UltraQA (Phase 3: QA) to Validation (Phase 4)
|
|
25
|
+
*/
|
|
26
|
+
export declare function transitionUltraQAToValidation(directory: string): TransitionResult;
|
|
27
|
+
/**
|
|
28
|
+
* Transition from Validation (Phase 4) to Complete
|
|
29
|
+
*/
|
|
30
|
+
export declare function transitionToComplete(directory: string): TransitionResult;
|
|
31
|
+
/**
|
|
32
|
+
* Transition to failed state
|
|
33
|
+
*/
|
|
34
|
+
export declare function transitionToFailed(directory: string, error: string): TransitionResult;
|
|
35
|
+
/**
|
|
36
|
+
* Get a prompt for Claude to execute the transition
|
|
37
|
+
*/
|
|
38
|
+
export declare function getTransitionPrompt(fromPhase: string, toPhase: string): string;
|
|
39
|
+
//# sourceMappingURL=transition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../../src/hooks/autopilot/transition.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoBH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,cAAc,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,gBAAgB,CAkElB;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,MAAM,GAChB,gBAAgB,CAyClB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAWxE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GACZ,gBAAgB,CAWlB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,MAAM,CA6ER"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autopilot Phase Transitions
|
|
3
|
+
*
|
|
4
|
+
* Handles transitions between phases, especially the critical Ralph → UltraQA
|
|
5
|
+
* and UltraQA → Validation transitions that must respect mutual exclusion.
|
|
6
|
+
*/
|
|
7
|
+
import { readRalphState, clearRalphState, clearLinkedUltraworkState } from '../ralph-loop/index.js';
|
|
8
|
+
import { startUltraQA, clearUltraQAState, readUltraQAState } from '../ultraqa-loop/index.js';
|
|
9
|
+
import { readAutopilotState, transitionPhase, updateExecution, updateQA } from './state.js';
|
|
10
|
+
/**
|
|
11
|
+
* Transition from Ralph (Phase 2: Execution) to UltraQA (Phase 3: QA)
|
|
12
|
+
*
|
|
13
|
+
* This handles the mutual exclusion by:
|
|
14
|
+
* 1. Saving Ralph's progress to autopilot state
|
|
15
|
+
* 2. Cleanly terminating Ralph mode (and linked Ultrawork)
|
|
16
|
+
* 3. Starting UltraQA mode
|
|
17
|
+
* 4. Preserving context for potential rollback
|
|
18
|
+
*/
|
|
19
|
+
export function transitionRalphToUltraQA(directory, sessionId) {
|
|
20
|
+
const autopilotState = readAutopilotState(directory);
|
|
21
|
+
if (!autopilotState || autopilotState.phase !== 'execution') {
|
|
22
|
+
return {
|
|
23
|
+
success: false,
|
|
24
|
+
error: 'Not in execution phase - cannot transition to QA'
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const ralphState = readRalphState(directory);
|
|
28
|
+
// Step 1: Preserve Ralph progress in autopilot state
|
|
29
|
+
const executionUpdated = updateExecution(directory, {
|
|
30
|
+
ralph_iterations: ralphState?.iteration ?? autopilotState.execution.ralph_iterations,
|
|
31
|
+
ralph_completed_at: new Date().toISOString(),
|
|
32
|
+
ultrawork_active: false
|
|
33
|
+
});
|
|
34
|
+
if (!executionUpdated) {
|
|
35
|
+
return {
|
|
36
|
+
success: false,
|
|
37
|
+
error: 'Failed to update execution state'
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Step 2: Cleanly terminate Ralph (and linked Ultrawork)
|
|
41
|
+
if (ralphState?.linked_ultrawork) {
|
|
42
|
+
clearLinkedUltraworkState(directory);
|
|
43
|
+
}
|
|
44
|
+
const ralphCleared = clearRalphState(directory);
|
|
45
|
+
if (!ralphCleared) {
|
|
46
|
+
return {
|
|
47
|
+
success: false,
|
|
48
|
+
error: 'Failed to clear Ralph state'
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// Step 3: Transition to QA phase
|
|
52
|
+
const newState = transitionPhase(directory, 'qa');
|
|
53
|
+
if (!newState) {
|
|
54
|
+
return {
|
|
55
|
+
success: false,
|
|
56
|
+
error: 'Failed to transition to QA phase'
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// Step 4: Start UltraQA
|
|
60
|
+
const qaResult = startUltraQA(directory, 'tests', sessionId, { maxCycles: 5 });
|
|
61
|
+
if (!qaResult.success) {
|
|
62
|
+
// Rollback on failure - restore execution phase
|
|
63
|
+
transitionPhase(directory, 'execution');
|
|
64
|
+
updateExecution(directory, { ralph_completed_at: undefined });
|
|
65
|
+
return {
|
|
66
|
+
success: false,
|
|
67
|
+
error: qaResult.error || 'Failed to start UltraQA'
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
success: true,
|
|
72
|
+
state: newState
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Transition from UltraQA (Phase 3: QA) to Validation (Phase 4)
|
|
77
|
+
*/
|
|
78
|
+
export function transitionUltraQAToValidation(directory) {
|
|
79
|
+
const autopilotState = readAutopilotState(directory);
|
|
80
|
+
if (!autopilotState || autopilotState.phase !== 'qa') {
|
|
81
|
+
return {
|
|
82
|
+
success: false,
|
|
83
|
+
error: 'Not in QA phase - cannot transition to validation'
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const qaState = readUltraQAState(directory);
|
|
87
|
+
// Preserve QA progress
|
|
88
|
+
const qaUpdated = updateQA(directory, {
|
|
89
|
+
ultraqa_cycles: qaState?.cycle ?? autopilotState.qa.ultraqa_cycles,
|
|
90
|
+
qa_completed_at: new Date().toISOString()
|
|
91
|
+
});
|
|
92
|
+
if (!qaUpdated) {
|
|
93
|
+
return {
|
|
94
|
+
success: false,
|
|
95
|
+
error: 'Failed to update QA state'
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// Terminate UltraQA
|
|
99
|
+
clearUltraQAState(directory);
|
|
100
|
+
// Transition to validation
|
|
101
|
+
const newState = transitionPhase(directory, 'validation');
|
|
102
|
+
if (!newState) {
|
|
103
|
+
return {
|
|
104
|
+
success: false,
|
|
105
|
+
error: 'Failed to transition to validation phase'
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
success: true,
|
|
110
|
+
state: newState
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Transition from Validation (Phase 4) to Complete
|
|
115
|
+
*/
|
|
116
|
+
export function transitionToComplete(directory) {
|
|
117
|
+
const state = transitionPhase(directory, 'complete');
|
|
118
|
+
if (!state) {
|
|
119
|
+
return {
|
|
120
|
+
success: false,
|
|
121
|
+
error: 'Failed to transition to complete phase'
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return { success: true, state };
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Transition to failed state
|
|
128
|
+
*/
|
|
129
|
+
export function transitionToFailed(directory, error) {
|
|
130
|
+
const state = transitionPhase(directory, 'failed');
|
|
131
|
+
if (!state) {
|
|
132
|
+
return {
|
|
133
|
+
success: false,
|
|
134
|
+
error: 'Failed to transition to failed phase'
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return { success: true, state };
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get a prompt for Claude to execute the transition
|
|
141
|
+
*/
|
|
142
|
+
export function getTransitionPrompt(fromPhase, toPhase) {
|
|
143
|
+
if (fromPhase === 'execution' && toPhase === 'qa') {
|
|
144
|
+
return `## PHASE TRANSITION: Execution → QA
|
|
145
|
+
|
|
146
|
+
The execution phase is complete. Transitioning to QA phase.
|
|
147
|
+
|
|
148
|
+
**CRITICAL**: Ralph mode must be cleanly terminated before UltraQA can start.
|
|
149
|
+
|
|
150
|
+
The transition handler has:
|
|
151
|
+
1. Preserved Ralph iteration count and progress
|
|
152
|
+
2. Cleared Ralph state (and linked Ultrawork)
|
|
153
|
+
3. Started UltraQA in 'tests' mode
|
|
154
|
+
|
|
155
|
+
You are now in QA phase. Run the QA cycle:
|
|
156
|
+
1. Build: npm run build (or equivalent)
|
|
157
|
+
2. Lint: npm run lint (or equivalent)
|
|
158
|
+
3. Test: npm test (or equivalent)
|
|
159
|
+
|
|
160
|
+
Fix any failures and repeat until all pass.
|
|
161
|
+
|
|
162
|
+
Signal when QA passes: QA_COMPLETE
|
|
163
|
+
`;
|
|
164
|
+
}
|
|
165
|
+
if (fromPhase === 'qa' && toPhase === 'validation') {
|
|
166
|
+
return `## PHASE TRANSITION: QA → Validation
|
|
167
|
+
|
|
168
|
+
All QA checks have passed. Transitioning to validation phase.
|
|
169
|
+
|
|
170
|
+
The transition handler has:
|
|
171
|
+
1. Preserved UltraQA cycle count
|
|
172
|
+
2. Cleared UltraQA state
|
|
173
|
+
3. Updated phase to 'validation'
|
|
174
|
+
|
|
175
|
+
You are now in validation phase. Spawn parallel validation architects:
|
|
176
|
+
|
|
177
|
+
\`\`\`
|
|
178
|
+
// Spawn all three in parallel
|
|
179
|
+
Task(subagent_type="oh-my-claudecode:architect", model="opus",
|
|
180
|
+
prompt="FUNCTIONAL COMPLETENESS REVIEW: Verify all requirements from spec are implemented")
|
|
181
|
+
|
|
182
|
+
Task(subagent_type="oh-my-claudecode:security-reviewer", model="opus",
|
|
183
|
+
prompt="SECURITY REVIEW: Check for vulnerabilities, injection risks, auth issues")
|
|
184
|
+
|
|
185
|
+
Task(subagent_type="oh-my-claudecode:code-reviewer", model="opus",
|
|
186
|
+
prompt="CODE QUALITY REVIEW: Check patterns, maintainability, test coverage")
|
|
187
|
+
\`\`\`
|
|
188
|
+
|
|
189
|
+
Aggregate verdicts:
|
|
190
|
+
- All APPROVED → Signal: AUTOPILOT_COMPLETE
|
|
191
|
+
- Any REJECTED → Fix issues and re-validate (max 3 rounds)
|
|
192
|
+
`;
|
|
193
|
+
}
|
|
194
|
+
if (fromPhase === 'expansion' && toPhase === 'planning') {
|
|
195
|
+
return `## PHASE TRANSITION: Expansion → Planning
|
|
196
|
+
|
|
197
|
+
The idea has been expanded into a detailed specification.
|
|
198
|
+
|
|
199
|
+
Read the spec and create an implementation plan using the Architect agent (direct planning mode).
|
|
200
|
+
|
|
201
|
+
Signal when Critic approves the plan: PLANNING_COMPLETE
|
|
202
|
+
`;
|
|
203
|
+
}
|
|
204
|
+
if (fromPhase === 'planning' && toPhase === 'execution') {
|
|
205
|
+
return `## PHASE TRANSITION: Planning → Execution
|
|
206
|
+
|
|
207
|
+
The plan has been approved. Starting execution phase with Ralph + Ultrawork.
|
|
208
|
+
|
|
209
|
+
Execute tasks from the plan in parallel where possible.
|
|
210
|
+
|
|
211
|
+
Signal when all tasks complete: EXECUTION_COMPLETE
|
|
212
|
+
`;
|
|
213
|
+
}
|
|
214
|
+
return '';
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=transition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transition.js","sourceRoot":"","sources":["../../../src/hooks/autopilot/transition.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,cAAc,EACd,eAAe,EACf,yBAAyB,EAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,kBAAkB,EAElB,eAAe,EACf,eAAe,EACf,QAAQ,EAET,MAAM,YAAY,CAAC;AASpB;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CACtC,SAAiB,EACjB,SAAiB;IAEjB,MAAM,cAAc,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAErD,IAAI,CAAC,cAAc,IAAI,cAAc,CAAC,KAAK,KAAK,WAAW,EAAE,CAAC;QAC5D,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,kDAAkD;SAC1D,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAE7C,qDAAqD;IACrD,MAAM,gBAAgB,GAAG,eAAe,CAAC,SAAS,EAAE;QAClD,gBAAgB,EAAE,UAAU,EAAE,SAAS,IAAI,cAAc,CAAC,SAAS,CAAC,gBAAgB;QACpF,kBAAkB,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QAC5C,gBAAgB,EAAE,KAAK;KACxB,CAAC,CAAC;IAEH,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,kCAAkC;SAC1C,CAAC;IACJ,CAAC;IAED,yDAAyD;IACzD,IAAI,UAAU,EAAE,gBAAgB,EAAE,CAAC;QACjC,yBAAyB,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;IACD,MAAM,YAAY,GAAG,eAAe,CAAC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C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,SAAiB,EACjB,OAAe;IAEf,IAAI,SAAS,KAAK,WAAW,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAClD,OAAO;;;;;;;;;;;;;;;;;;;CAmBV,CAAC;IACA,CAAC;IAED,IAAI,SAAS,KAAK,IAAI,IAAI,OAAO,KAAK,YAAY,EAAE,CAAC;QACnD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BV,CAAC;IACA,CAAC;IAED,IAAI,SAAS,KAAK,WAAW,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;QACxD,OAAO;;;;;;;CAOV,CAAC;IACA,CAAC;IAED,IAAI,SAAS,KAAK,UAAU,IAAI,OAAO,KAAK,WAAW,EAAE,CAAC;QACxD,OAAO;;;;;;;CAOV,CAAC;IACA,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Window Limit Recovery Constants
|
|
3
|
+
*
|
|
4
|
+
* Messages and prompts for recovery from context limit errors.
|
|
5
|
+
*
|
|
6
|
+
* Adapted from oh-my-opencode's anthropic-context-window-limit-recovery hook.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Recovery message when context window limit is hit
|
|
10
|
+
*/
|
|
11
|
+
export declare const CONTEXT_LIMIT_RECOVERY_MESSAGE = "CONTEXT WINDOW LIMIT REACHED - IMMEDIATE ACTION REQUIRED\n\nThe conversation has exceeded the model's context window limit. To continue working effectively, you must take one of these actions:\n\n1. SUMMARIZE THE CONVERSATION\n - Use the /compact command if available\n - Or provide a concise summary of what has been accomplished so far\n - Include key decisions, code changes, and remaining tasks\n\n2. START A FRESH CONTEXT\n - If summarization isn't sufficient, suggest starting a new session\n - Provide a handoff message with essential context\n\n3. REDUCE OUTPUT SIZE\n - When showing code, show only relevant portions\n - Use file paths and line numbers instead of full code blocks\n - Be more concise in explanations\n\nIMPORTANT: Do not attempt to continue without addressing this limit.\nThe API will reject further requests until the context is reduced.\n\nCurrent Status:\n- Context limit exceeded\n- Further API calls will fail until context is reduced\n- Action required before continuing\n";
|
|
12
|
+
/**
|
|
13
|
+
* Short notification for context limit
|
|
14
|
+
*/
|
|
15
|
+
export declare const CONTEXT_LIMIT_SHORT_MESSAGE = "Context window limit reached. Please use /compact to summarize the conversation or start a new session.";
|
|
16
|
+
/**
|
|
17
|
+
* Recovery message for non-empty content errors
|
|
18
|
+
*/
|
|
19
|
+
export declare const NON_EMPTY_CONTENT_RECOVERY_MESSAGE = "API ERROR: Non-empty content validation failed.\n\nThis error typically occurs when:\n- A message has empty text content\n- The conversation structure is invalid\n\nSuggested actions:\n1. Continue with a new message\n2. If the error persists, start a new session\n\nThe system will attempt automatic recovery.\n";
|
|
20
|
+
/**
|
|
21
|
+
* Recovery message when truncation was applied
|
|
22
|
+
*/
|
|
23
|
+
export declare const TRUNCATION_APPLIED_MESSAGE = "CONTEXT OPTIMIZATION APPLIED\n\nSome tool outputs have been truncated to fit within the context window.\nThe conversation can now continue normally.\n\nIf you need to see the full output of a previous tool call, you can:\n- Re-run the specific command\n- Ask to see a particular file or section\n\nContinuing with the current task...\n";
|
|
24
|
+
/**
|
|
25
|
+
* Message when recovery fails
|
|
26
|
+
*/
|
|
27
|
+
export declare const RECOVERY_FAILED_MESSAGE = "CONTEXT RECOVERY FAILED\n\nAll automatic recovery attempts have been exhausted.\nPlease start a new session to continue.\n\nBefore starting a new session:\n1. Note what has been accomplished\n2. Save any important code changes\n3. Document the current state of the task\n\nYou can copy this conversation summary to continue in a new session.\n";
|
|
28
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/hooks/context-window-limit-recovery/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,eAAO,MAAM,8BAA8B,kgCAyB1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,4GAA4G,CAAC;AAErJ;;GAEG;AACH,eAAO,MAAM,kCAAkC,4TAW9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,oVAUtC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,4VAWnC,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Window Limit Recovery Constants
|
|
3
|
+
*
|
|
4
|
+
* Messages and prompts for recovery from context limit errors.
|
|
5
|
+
*
|
|
6
|
+
* Adapted from oh-my-opencode's anthropic-context-window-limit-recovery hook.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Recovery message when context window limit is hit
|
|
10
|
+
*/
|
|
11
|
+
export const CONTEXT_LIMIT_RECOVERY_MESSAGE = `CONTEXT WINDOW LIMIT REACHED - IMMEDIATE ACTION REQUIRED
|
|
12
|
+
|
|
13
|
+
The conversation has exceeded the model's context window limit. To continue working effectively, you must take one of these actions:
|
|
14
|
+
|
|
15
|
+
1. SUMMARIZE THE CONVERSATION
|
|
16
|
+
- Use the /compact command if available
|
|
17
|
+
- Or provide a concise summary of what has been accomplished so far
|
|
18
|
+
- Include key decisions, code changes, and remaining tasks
|
|
19
|
+
|
|
20
|
+
2. START A FRESH CONTEXT
|
|
21
|
+
- If summarization isn't sufficient, suggest starting a new session
|
|
22
|
+
- Provide a handoff message with essential context
|
|
23
|
+
|
|
24
|
+
3. REDUCE OUTPUT SIZE
|
|
25
|
+
- When showing code, show only relevant portions
|
|
26
|
+
- Use file paths and line numbers instead of full code blocks
|
|
27
|
+
- Be more concise in explanations
|
|
28
|
+
|
|
29
|
+
IMPORTANT: Do not attempt to continue without addressing this limit.
|
|
30
|
+
The API will reject further requests until the context is reduced.
|
|
31
|
+
|
|
32
|
+
Current Status:
|
|
33
|
+
- Context limit exceeded
|
|
34
|
+
- Further API calls will fail until context is reduced
|
|
35
|
+
- Action required before continuing
|
|
36
|
+
`;
|
|
37
|
+
/**
|
|
38
|
+
* Short notification for context limit
|
|
39
|
+
*/
|
|
40
|
+
export const CONTEXT_LIMIT_SHORT_MESSAGE = `Context window limit reached. Please use /compact to summarize the conversation or start a new session.`;
|
|
41
|
+
/**
|
|
42
|
+
* Recovery message for non-empty content errors
|
|
43
|
+
*/
|
|
44
|
+
export const NON_EMPTY_CONTENT_RECOVERY_MESSAGE = `API ERROR: Non-empty content validation failed.
|
|
45
|
+
|
|
46
|
+
This error typically occurs when:
|
|
47
|
+
- A message has empty text content
|
|
48
|
+
- The conversation structure is invalid
|
|
49
|
+
|
|
50
|
+
Suggested actions:
|
|
51
|
+
1. Continue with a new message
|
|
52
|
+
2. If the error persists, start a new session
|
|
53
|
+
|
|
54
|
+
The system will attempt automatic recovery.
|
|
55
|
+
`;
|
|
56
|
+
/**
|
|
57
|
+
* Recovery message when truncation was applied
|
|
58
|
+
*/
|
|
59
|
+
export const TRUNCATION_APPLIED_MESSAGE = `CONTEXT OPTIMIZATION APPLIED
|
|
60
|
+
|
|
61
|
+
Some tool outputs have been truncated to fit within the context window.
|
|
62
|
+
The conversation can now continue normally.
|
|
63
|
+
|
|
64
|
+
If you need to see the full output of a previous tool call, you can:
|
|
65
|
+
- Re-run the specific command
|
|
66
|
+
- Ask to see a particular file or section
|
|
67
|
+
|
|
68
|
+
Continuing with the current task...
|
|
69
|
+
`;
|
|
70
|
+
/**
|
|
71
|
+
* Message when recovery fails
|
|
72
|
+
*/
|
|
73
|
+
export const RECOVERY_FAILED_MESSAGE = `CONTEXT RECOVERY FAILED
|
|
74
|
+
|
|
75
|
+
All automatic recovery attempts have been exhausted.
|
|
76
|
+
Please start a new session to continue.
|
|
77
|
+
|
|
78
|
+
Before starting a new session:
|
|
79
|
+
1. Note what has been accomplished
|
|
80
|
+
2. Save any important code changes
|
|
81
|
+
3. Document the current state of the task
|
|
82
|
+
|
|
83
|
+
You can copy this conversation summary to continue in a new session.
|
|
84
|
+
`;
|
|
85
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/hooks/context-window-limit-recovery/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;CAyB7C,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,yGAAyG,CAAC;AAErJ;;GAEG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG;;;;;;;;;;;CAWjD,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;;;;;;;;;;CAUzC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;CAWtC,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Window Limit Recovery Hook
|
|
3
|
+
*
|
|
4
|
+
* Detects context window limit errors and injects recovery messages
|
|
5
|
+
* to help Claude recover gracefully.
|
|
6
|
+
*
|
|
7
|
+
* Adapted from oh-my-opencode's anthropic-context-window-limit-recovery hook.
|
|
8
|
+
*
|
|
9
|
+
* Note: This is a simplified version for Claude Code's shell hook system.
|
|
10
|
+
* The original uses OpenCode's plugin event system for more sophisticated
|
|
11
|
+
* recovery like automatic summarization and truncation.
|
|
12
|
+
*/
|
|
13
|
+
import type { ParsedTokenLimitError, RecoveryResult } from './types.js';
|
|
14
|
+
/**
|
|
15
|
+
* Configuration for context limit recovery hook
|
|
16
|
+
*/
|
|
17
|
+
export interface ContextLimitRecoveryConfig {
|
|
18
|
+
/** Whether to show detailed recovery messages */
|
|
19
|
+
detailed?: boolean;
|
|
20
|
+
/** Custom recovery message */
|
|
21
|
+
customMessage?: string;
|
|
22
|
+
/** Whether to enable the hook */
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create context window limit recovery hook
|
|
27
|
+
*
|
|
28
|
+
* This hook monitors for token/context limit errors and injects
|
|
29
|
+
* helpful recovery messages when detected.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createContextLimitRecoveryHook(config?: ContextLimitRecoveryConfig): {
|
|
32
|
+
/**
|
|
33
|
+
* PostToolUse - Check for context limit errors in tool responses
|
|
34
|
+
*/
|
|
35
|
+
postToolUse: (input: {
|
|
36
|
+
tool_name: string;
|
|
37
|
+
session_id: string;
|
|
38
|
+
tool_input: Record<string, unknown>;
|
|
39
|
+
tool_response?: string;
|
|
40
|
+
}) => string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Notification - Check for error notifications
|
|
43
|
+
* (Called when errors are passed through notification system)
|
|
44
|
+
*/
|
|
45
|
+
onError: (input: {
|
|
46
|
+
session_id: string;
|
|
47
|
+
error: unknown;
|
|
48
|
+
}) => RecoveryResult;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Check if text contains a context limit error
|
|
52
|
+
*/
|
|
53
|
+
export declare function detectContextLimitError(text: string): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Parse error to get detailed token limit info
|
|
56
|
+
*/
|
|
57
|
+
export declare function parseContextLimitError(error: unknown): ParsedTokenLimitError | null;
|
|
58
|
+
export type { ParsedTokenLimitError, RetryState, TruncateState, RecoveryResult, } from './types.js';
|
|
59
|
+
export { RETRY_CONFIG, TRUNCATE_CONFIG } from './types.js';
|
|
60
|
+
export { CONTEXT_LIMIT_RECOVERY_MESSAGE, CONTEXT_LIMIT_SHORT_MESSAGE, NON_EMPTY_CONTENT_RECOVERY_MESSAGE, TRUNCATION_APPLIED_MESSAGE, RECOVERY_FAILED_MESSAGE, } from './constants.js';
|
|
61
|
+
export { parseTokenLimitError, containsTokenLimitError, TOKEN_LIMIT_PATTERNS, TOKEN_LIMIT_KEYWORDS, } from './parser.js';
|
|
62
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/context-window-limit-recovery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAgBH,OAAO,KAAK,EACV,qBAAqB,EAGrB,cAAc,EACf,MAAM,YAAY,CAAC;AAsEpB;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8BAA8B;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iCAAiC;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,CAAC,EAAE,0BAA0B;IAUjC;;OAEG;yBACkB;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,KAAG,MAAM,GAAG,IAAI;IAmCjB;;;OAGG;qBACc;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,OAAO,CAAC;KAChB,KAAG,cAAc;EA6BrB;AA8DD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,GACb,qBAAqB,GAAG,IAAI,CAE9B;AAGD,YAAY,EACV,qBAAqB,EACrB,UAAU,EACV,aAAa,EACb,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE3D,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,kCAAkC,EAClC,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,gBAAgB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