oh-my-claude-sisyphus 3.7.2 → 3.7.3
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/dist/__tests__/compatibility-security.test.d.ts +13 -0
- package/dist/__tests__/compatibility-security.test.d.ts.map +1 -0
- package/dist/__tests__/compatibility-security.test.js +403 -0
- package/dist/__tests__/compatibility-security.test.js.map +1 -0
- package/dist/__tests__/compatibility.test.d.ts +7 -0
- package/dist/__tests__/compatibility.test.d.ts.map +1 -0
- package/dist/__tests__/compatibility.test.js +484 -0
- package/dist/__tests__/compatibility.test.js.map +1 -0
- package/dist/__tests__/hud/analytics-display.test.js +4 -0
- package/dist/__tests__/hud/analytics-display.test.js.map +1 -1
- package/dist/cli/analytics.js +0 -0
- package/dist/cli/index.js +0 -0
- package/dist/compatibility/discovery.d.ts +58 -0
- package/dist/compatibility/discovery.d.ts.map +1 -0
- package/dist/compatibility/discovery.js +619 -0
- package/dist/compatibility/discovery.js.map +1 -0
- package/dist/compatibility/index.d.ts +51 -0
- package/dist/compatibility/index.d.ts.map +1 -0
- package/dist/compatibility/index.js +72 -0
- package/dist/compatibility/index.js.map +1 -0
- package/dist/compatibility/mcp-bridge.d.ts +138 -0
- package/dist/compatibility/mcp-bridge.d.ts.map +1 -0
- package/dist/compatibility/mcp-bridge.js +524 -0
- package/dist/compatibility/mcp-bridge.js.map +1 -0
- package/dist/compatibility/permission-adapter.d.ts +79 -0
- package/dist/compatibility/permission-adapter.d.ts.map +1 -0
- package/dist/compatibility/permission-adapter.js +369 -0
- package/dist/compatibility/permission-adapter.js.map +1 -0
- package/dist/compatibility/registry.d.ts +161 -0
- package/dist/compatibility/registry.d.ts.map +1 -0
- package/dist/compatibility/registry.js +389 -0
- package/dist/compatibility/registry.js.map +1 -0
- package/dist/compatibility/types.d.ts +249 -0
- package/dist/compatibility/types.d.ts.map +1 -0
- package/dist/compatibility/types.js +8 -0
- package/dist/compatibility/types.js.map +1 -0
- package/dist/features/rate-limit-wait/daemon.d.ts.map +1 -1
- package/dist/features/rate-limit-wait/daemon.js +3 -0
- package/dist/features/rate-limit-wait/daemon.js.map +1 -1
- package/dist/hud/analytics-display.d.ts +1 -1
- package/dist/hud/analytics-display.d.ts.map +1 -1
- package/dist/hud/analytics-display.js +24 -7
- package/dist/hud/analytics-display.js.map +1 -1
- package/docs/COMPATIBILITY.md +1051 -0
- package/package.json +3 -1
- package/dist/__tests__/analytics/analytics-summary.test.d.ts +0 -2
- package/dist/__tests__/analytics/analytics-summary.test.d.ts.map +0 -1
- package/dist/__tests__/analytics/analytics-summary.test.js +0 -267
- package/dist/__tests__/analytics/analytics-summary.test.js.map +0 -1
- package/dist/__tests__/analytics/cost-estimator.test.d.ts +0 -2
- package/dist/__tests__/analytics/cost-estimator.test.d.ts.map +0 -1
- package/dist/__tests__/analytics/cost-estimator.test.js +0 -212
- package/dist/__tests__/analytics/cost-estimator.test.js.map +0 -1
- package/dist/__tests__/hooks/auto-slash-command/executor.test.d.ts +0 -7
- package/dist/__tests__/hooks/auto-slash-command/executor.test.d.ts.map +0 -1
- package/dist/__tests__/hooks/auto-slash-command/executor.test.js +0 -374
- package/dist/__tests__/hooks/auto-slash-command/executor.test.js.map +0 -1
- package/dist/__tests__/hud/auto-tracking.integration.test.d.ts +0 -2
- package/dist/__tests__/hud/auto-tracking.integration.test.d.ts.map +0 -1
- package/dist/__tests__/hud/auto-tracking.integration.test.js +0 -12
- package/dist/__tests__/hud/auto-tracking.integration.test.js.map +0 -1
- package/dist/__tests__/learned-skills/config.test.d.ts +0 -2
- package/dist/__tests__/learned-skills/config.test.d.ts.map +0 -1
- package/dist/__tests__/learned-skills/config.test.js +0 -37
- package/dist/__tests__/learned-skills/config.test.js.map +0 -1
- package/dist/__tests__/learned-skills/detector.test.d.ts +0 -2
- package/dist/__tests__/learned-skills/detector.test.d.ts.map +0 -1
- package/dist/__tests__/learned-skills/detector.test.js +0 -99
- package/dist/__tests__/learned-skills/detector.test.js.map +0 -1
- package/dist/__tests__/learned-skills/finder.test.d.ts +0 -2
- package/dist/__tests__/learned-skills/finder.test.d.ts.map +0 -1
- package/dist/__tests__/learned-skills/finder.test.js +0 -59
- package/dist/__tests__/learned-skills/finder.test.js.map +0 -1
- package/dist/__tests__/learned-skills/loader.test.d.ts +0 -2
- package/dist/__tests__/learned-skills/loader.test.d.ts.map +0 -1
- package/dist/__tests__/learned-skills/loader.test.js +0 -69
- package/dist/__tests__/learned-skills/loader.test.js.map +0 -1
- package/dist/__tests__/learned-skills/parser.test.d.ts +0 -2
- package/dist/__tests__/learned-skills/parser.test.d.ts.map +0 -1
- package/dist/__tests__/learned-skills/parser.test.js +0 -81
- package/dist/__tests__/learned-skills/parser.test.js.map +0 -1
- package/dist/__tests__/learned-skills/validator.test.d.ts +0 -2
- package/dist/__tests__/learned-skills/validator.test.d.ts.map +0 -1
- package/dist/__tests__/learned-skills/validator.test.js +0 -85
- package/dist/__tests__/learned-skills/validator.test.js.map +0 -1
- package/dist/agents/codex-agents.d.ts +0 -20
- package/dist/agents/codex-agents.d.ts.map +0 -1
- package/dist/agents/codex-agents.js +0 -36
- package/dist/agents/codex-agents.js.map +0 -1
- package/dist/agents/document-writer.d.ts +0 -11
- package/dist/agents/document-writer.d.ts.map +0 -1
- package/dist/agents/document-writer.js +0 -209
- package/dist/agents/document-writer.js.map +0 -1
- package/dist/agents/frontend-engineer.d.ts +0 -11
- package/dist/agents/frontend-engineer.d.ts.map +0 -1
- package/dist/agents/frontend-engineer.js +0 -115
- package/dist/agents/frontend-engineer.js.map +0 -1
- package/dist/agents/librarian.d.ts +0 -12
- package/dist/agents/librarian.d.ts.map +0 -1
- package/dist/agents/librarian.js +0 -103
- package/dist/agents/librarian.js.map +0 -1
- package/dist/agents/metis.d.ts +0 -12
- package/dist/agents/metis.d.ts.map +0 -1
- package/dist/agents/metis.js +0 -117
- package/dist/agents/metis.js.map +0 -1
- package/dist/agents/momus.d.ts +0 -12
- package/dist/agents/momus.d.ts.map +0 -1
- package/dist/agents/momus.js +0 -128
- package/dist/agents/momus.js.map +0 -1
- package/dist/agents/multimodal-looker.d.ts +0 -11
- package/dist/agents/multimodal-looker.d.ts.map +0 -1
- package/dist/agents/multimodal-looker.js +0 -70
- package/dist/agents/multimodal-looker.js.map +0 -1
- package/dist/agents/oracle.d.ts +0 -13
- package/dist/agents/oracle.d.ts.map +0 -1
- package/dist/agents/oracle.js +0 -191
- package/dist/agents/oracle.js.map +0 -1
- package/dist/agents/orchestrator-sisyphus.d.ts +0 -11
- package/dist/agents/orchestrator-sisyphus.d.ts.map +0 -1
- package/dist/agents/orchestrator-sisyphus.js +0 -115
- package/dist/agents/orchestrator-sisyphus.js.map +0 -1
- package/dist/agents/prometheus.d.ts +0 -12
- package/dist/agents/prometheus.d.ts.map +0 -1
- package/dist/agents/prometheus.js +0 -195
- package/dist/agents/prometheus.js.map +0 -1
- package/dist/agents/sisyphus-junior.d.ts +0 -12
- package/dist/agents/sisyphus-junior.d.ts.map +0 -1
- package/dist/agents/sisyphus-junior.js +0 -93
- package/dist/agents/sisyphus-junior.js.map +0 -1
- package/dist/cli/components/CostDashboard.d.ts +0 -15
- package/dist/cli/components/CostDashboard.d.ts.map +0 -1
- package/dist/cli/components/CostDashboard.js +0 -15
- package/dist/cli/components/CostDashboard.js.map +0 -1
- package/dist/cli/components/LiveStats.d.ts +0 -16
- package/dist/cli/components/LiveStats.d.ts.map +0 -1
- package/dist/cli/components/LiveStats.js +0 -16
- package/dist/cli/components/LiveStats.js.map +0 -1
- package/dist/cli/components/SessionBrowser.d.ts +0 -14
- package/dist/cli/components/SessionBrowser.d.ts.map +0 -1
- package/dist/cli/components/SessionBrowser.js +0 -14
- package/dist/cli/components/SessionBrowser.js.map +0 -1
- package/dist/cli/tui.d.ts +0 -21
- package/dist/cli/tui.d.ts.map +0 -1
- package/dist/cli/tui.js +0 -21
- package/dist/cli/tui.js.map +0 -1
- package/dist/hooks/autopilot/signals.d.ts +0 -20
- package/dist/hooks/autopilot/signals.d.ts.map +0 -1
- package/dist/hooks/autopilot/signals.js +0 -75
- package/dist/hooks/autopilot/signals.js.map +0 -1
- package/dist/hooks/autopilot/summary.d.ts +0 -27
- package/dist/hooks/autopilot/summary.d.ts.map +0 -1
- package/dist/hooks/autopilot/summary.js +0 -160
- package/dist/hooks/autopilot/summary.js.map +0 -1
- package/dist/hooks/autopilot/transition.d.ts +0 -39
- package/dist/hooks/autopilot/transition.d.ts.map +0 -1
- package/dist/hooks/autopilot/transition.js +0 -216
- package/dist/hooks/autopilot/transition.js.map +0 -1
- package/dist/hooks/context-window-limit-recovery/constants.d.ts +0 -28
- package/dist/hooks/context-window-limit-recovery/constants.d.ts.map +0 -1
- package/dist/hooks/context-window-limit-recovery/constants.js +0 -85
- package/dist/hooks/context-window-limit-recovery/constants.js.map +0 -1
- package/dist/hooks/context-window-limit-recovery/index.d.ts +0 -62
- package/dist/hooks/context-window-limit-recovery/index.d.ts.map +0 -1
- package/dist/hooks/context-window-limit-recovery/index.js +0 -201
- package/dist/hooks/context-window-limit-recovery/index.js.map +0 -1
- package/dist/hooks/context-window-limit-recovery/parser.d.ts +0 -31
- package/dist/hooks/context-window-limit-recovery/parser.d.ts.map +0 -1
- package/dist/hooks/context-window-limit-recovery/parser.js +0 -241
- package/dist/hooks/context-window-limit-recovery/parser.js.map +0 -1
- package/dist/hooks/context-window-limit-recovery/types.d.ts +0 -84
- package/dist/hooks/context-window-limit-recovery/types.d.ts.map +0 -1
- package/dist/hooks/context-window-limit-recovery/types.js +0 -34
- package/dist/hooks/context-window-limit-recovery/types.js.map +0 -1
- package/dist/hooks/edit-error-recovery/index.d.ts +0 -62
- package/dist/hooks/edit-error-recovery/index.d.ts.map +0 -1
- package/dist/hooks/edit-error-recovery/index.js +0 -89
- package/dist/hooks/edit-error-recovery/index.js.map +0 -1
- package/dist/hooks/learned-skills/config.d.ts +0 -53
- package/dist/hooks/learned-skills/config.d.ts.map +0 -1
- package/dist/hooks/learned-skills/config.js +0 -103
- package/dist/hooks/learned-skills/config.js.map +0 -1
- package/dist/hooks/learned-skills/constants.d.ts +0 -24
- package/dist/hooks/learned-skills/constants.d.ts.map +0 -1
- package/dist/hooks/learned-skills/constants.js +0 -26
- package/dist/hooks/learned-skills/constants.js.map +0 -1
- package/dist/hooks/learned-skills/detection-hook.d.ts +0 -39
- package/dist/hooks/learned-skills/detection-hook.d.ts.map +0 -1
- package/dist/hooks/learned-skills/detection-hook.js +0 -83
- package/dist/hooks/learned-skills/detection-hook.js.map +0 -1
- package/dist/hooks/learned-skills/detector.d.ts +0 -30
- package/dist/hooks/learned-skills/detector.d.ts.map +0 -1
- package/dist/hooks/learned-skills/detector.js +0 -150
- package/dist/hooks/learned-skills/detector.js.map +0 -1
- package/dist/hooks/learned-skills/finder.d.ts +0 -21
- package/dist/hooks/learned-skills/finder.d.ts.map +0 -1
- package/dist/hooks/learned-skills/finder.js +0 -117
- package/dist/hooks/learned-skills/finder.js.map +0 -1
- package/dist/hooks/learned-skills/index.d.ts +0 -62
- package/dist/hooks/learned-skills/index.d.ts.map +0 -1
- package/dist/hooks/learned-skills/index.js +0 -137
- package/dist/hooks/learned-skills/index.js.map +0 -1
- package/dist/hooks/learned-skills/loader.d.ts +0 -20
- package/dist/hooks/learned-skills/loader.d.ts.map +0 -1
- package/dist/hooks/learned-skills/loader.js +0 -107
- package/dist/hooks/learned-skills/loader.js.map +0 -1
- package/dist/hooks/learned-skills/parser.d.ts +0 -21
- package/dist/hooks/learned-skills/parser.d.ts.map +0 -1
- package/dist/hooks/learned-skills/parser.js +0 -190
- package/dist/hooks/learned-skills/parser.js.map +0 -1
- package/dist/hooks/learned-skills/promotion.d.ts +0 -29
- package/dist/hooks/learned-skills/promotion.d.ts.map +0 -1
- package/dist/hooks/learned-skills/promotion.js +0 -87
- package/dist/hooks/learned-skills/promotion.js.map +0 -1
- package/dist/hooks/learned-skills/types.d.ts +0 -109
- package/dist/hooks/learned-skills/types.d.ts.map +0 -1
- package/dist/hooks/learned-skills/types.js +0 -8
- package/dist/hooks/learned-skills/types.js.map +0 -1
- package/dist/hooks/learned-skills/validator.d.ts +0 -15
- package/dist/hooks/learned-skills/validator.d.ts.map +0 -1
- package/dist/hooks/learned-skills/validator.js +0 -87
- package/dist/hooks/learned-skills/validator.js.map +0 -1
- package/dist/hooks/learned-skills/writer.d.ts +0 -27
- package/dist/hooks/learned-skills/writer.d.ts.map +0 -1
- package/dist/hooks/learned-skills/writer.js +0 -126
- package/dist/hooks/learned-skills/writer.js.map +0 -1
- package/dist/hooks/mnemosyne/config.d.ts +0 -53
- package/dist/hooks/mnemosyne/config.d.ts.map +0 -1
- package/dist/hooks/mnemosyne/config.js +0 -103
- package/dist/hooks/mnemosyne/config.js.map +0 -1
- package/dist/hooks/mnemosyne/constants.d.ts +0 -24
- package/dist/hooks/mnemosyne/constants.d.ts.map +0 -1
- package/dist/hooks/mnemosyne/constants.js +0 -26
- package/dist/hooks/mnemosyne/constants.js.map +0 -1
- package/dist/hooks/mnemosyne/detection-hook.d.ts +0 -39
- package/dist/hooks/mnemosyne/detection-hook.d.ts.map +0 -1
- package/dist/hooks/mnemosyne/detection-hook.js +0 -83
- package/dist/hooks/mnemosyne/detection-hook.js.map +0 -1
- package/dist/hooks/mnemosyne/detector.d.ts +0 -30
- package/dist/hooks/mnemosyne/detector.d.ts.map +0 -1
- package/dist/hooks/mnemosyne/detector.js +0 -150
- package/dist/hooks/mnemosyne/detector.js.map +0 -1
- package/dist/hooks/mnemosyne/finder.d.ts +0 -21
- package/dist/hooks/mnemosyne/finder.d.ts.map +0 -1
- package/dist/hooks/mnemosyne/finder.js +0 -117
- package/dist/hooks/mnemosyne/finder.js.map +0 -1
- package/dist/hooks/mnemosyne/index.d.ts +0 -62
- package/dist/hooks/mnemosyne/index.d.ts.map +0 -1
- package/dist/hooks/mnemosyne/index.js +0 -137
- package/dist/hooks/mnemosyne/index.js.map +0 -1
- package/dist/hooks/mnemosyne/loader.d.ts +0 -20
- package/dist/hooks/mnemosyne/loader.d.ts.map +0 -1
- package/dist/hooks/mnemosyne/loader.js +0 -113
- package/dist/hooks/mnemosyne/loader.js.map +0 -1
- package/dist/hooks/mnemosyne/parser.d.ts +0 -21
- package/dist/hooks/mnemosyne/parser.d.ts.map +0 -1
- package/dist/hooks/mnemosyne/parser.js +0 -190
- package/dist/hooks/mnemosyne/parser.js.map +0 -1
- package/dist/hooks/mnemosyne/promotion.d.ts +0 -29
- package/dist/hooks/mnemosyne/promotion.d.ts.map +0 -1
- package/dist/hooks/mnemosyne/promotion.js +0 -87
- package/dist/hooks/mnemosyne/promotion.js.map +0 -1
- package/dist/hooks/mnemosyne/types.d.ts +0 -109
- package/dist/hooks/mnemosyne/types.d.ts.map +0 -1
- package/dist/hooks/mnemosyne/types.js +0 -8
- package/dist/hooks/mnemosyne/types.js.map +0 -1
- package/dist/hooks/mnemosyne/validator.d.ts +0 -15
- package/dist/hooks/mnemosyne/validator.d.ts.map +0 -1
- package/dist/hooks/mnemosyne/validator.js +0 -87
- package/dist/hooks/mnemosyne/validator.js.map +0 -1
- package/dist/hooks/mnemosyne/writer.d.ts +0 -27
- package/dist/hooks/mnemosyne/writer.d.ts.map +0 -1
- package/dist/hooks/mnemosyne/writer.js +0 -126
- package/dist/hooks/mnemosyne/writer.js.map +0 -1
- package/dist/hooks/ralph-loop/index.d.ts +0 -116
- package/dist/hooks/ralph-loop/index.d.ts.map +0 -1
- package/dist/hooks/ralph-loop/index.js +0 -322
- package/dist/hooks/ralph-loop/index.js.map +0 -1
- package/dist/hooks/ralph-prd/index.d.ts +0 -130
- package/dist/hooks/ralph-prd/index.d.ts.map +0 -1
- package/dist/hooks/ralph-prd/index.js +0 -310
- package/dist/hooks/ralph-prd/index.js.map +0 -1
- package/dist/hooks/ralph-progress/index.d.ts +0 -102
- package/dist/hooks/ralph-progress/index.d.ts.map +0 -1
- package/dist/hooks/ralph-progress/index.js +0 -408
- package/dist/hooks/ralph-progress/index.js.map +0 -1
- package/dist/hooks/ralph-verifier/index.d.ts +0 -72
- package/dist/hooks/ralph-verifier/index.d.ts.map +0 -1
- package/dist/hooks/ralph-verifier/index.js +0 -223
- package/dist/hooks/ralph-verifier/index.js.map +0 -1
- package/dist/hooks/session-recovery/constants.d.ts +0 -56
- package/dist/hooks/session-recovery/constants.d.ts.map +0 -1
- package/dist/hooks/session-recovery/constants.js +0 -78
- package/dist/hooks/session-recovery/constants.js.map +0 -1
- package/dist/hooks/session-recovery/index.d.ts +0 -53
- package/dist/hooks/session-recovery/index.d.ts.map +0 -1
- package/dist/hooks/session-recovery/index.js +0 -321
- package/dist/hooks/session-recovery/index.js.map +0 -1
- package/dist/hooks/session-recovery/storage.d.ts +0 -76
- package/dist/hooks/session-recovery/storage.d.ts.map +0 -1
- package/dist/hooks/session-recovery/storage.js +0 -383
- package/dist/hooks/session-recovery/storage.js.map +0 -1
- package/dist/hooks/session-recovery/types.d.ts +0 -145
- package/dist/hooks/session-recovery/types.d.ts.map +0 -1
- package/dist/hooks/session-recovery/types.js +0 -8
- package/dist/hooks/session-recovery/types.js.map +0 -1
- package/dist/hooks/sisyphus-orchestrator/constants.d.ts +0 -23
- package/dist/hooks/sisyphus-orchestrator/constants.d.ts.map +0 -1
- package/dist/hooks/sisyphus-orchestrator/constants.js +0 -142
- package/dist/hooks/sisyphus-orchestrator/constants.js.map +0 -1
- package/dist/hooks/sisyphus-orchestrator/index.d.ts +0 -113
- package/dist/hooks/sisyphus-orchestrator/index.d.ts.map +0 -1
- package/dist/hooks/sisyphus-orchestrator/index.js +0 -309
- package/dist/hooks/sisyphus-orchestrator/index.js.map +0 -1
- package/dist/hooks/ultraqa-loop/index.d.ts +0 -94
- package/dist/hooks/ultraqa-loop/index.d.ts.map +0 -1
- package/dist/hooks/ultraqa-loop/index.js +0 -216
- package/dist/hooks/ultraqa-loop/index.js.map +0 -1
- package/dist/hooks/ultrawork-state/index.d.ts +0 -62
- package/dist/hooks/ultrawork-state/index.d.ts.map +0 -1
- package/dist/hooks/ultrawork-state/index.js +0 -208
- package/dist/hooks/ultrawork-state/index.js.map +0 -1
- package/dist/hud/sisyphus-state.d.ts +0 -31
- package/dist/hud/sisyphus-state.d.ts.map +0 -1
- package/dist/hud/sisyphus-state.js +0 -163
- package/dist/hud/sisyphus-state.js.map +0 -1
|
@@ -1,216 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,EAC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AO,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"}
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,85 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,62 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,CAAC;AAExB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,aAAa,CAAC"}
|
|
@@ -1,201 +0,0 @@
|
|
|
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 * as fs from 'fs';
|
|
14
|
-
import * as path from 'path';
|
|
15
|
-
import { tmpdir } from 'os';
|
|
16
|
-
import { parseTokenLimitError, containsTokenLimitError, } from './parser.js';
|
|
17
|
-
import { CONTEXT_LIMIT_RECOVERY_MESSAGE, CONTEXT_LIMIT_SHORT_MESSAGE, NON_EMPTY_CONTENT_RECOVERY_MESSAGE, RECOVERY_FAILED_MESSAGE, } from './constants.js';
|
|
18
|
-
import { RETRY_CONFIG } from './types.js';
|
|
19
|
-
const DEBUG = process.env.CONTEXT_LIMIT_RECOVERY_DEBUG === '1';
|
|
20
|
-
const DEBUG_FILE = path.join(tmpdir(), 'context-limit-recovery-debug.log');
|
|
21
|
-
function debugLog(...args) {
|
|
22
|
-
if (DEBUG) {
|
|
23
|
-
const msg = `[${new Date().toISOString()}] [context-limit-recovery] ${args
|
|
24
|
-
.map((a) => typeof a === 'object' ? JSON.stringify(a, null, 2) : String(a))
|
|
25
|
-
.join(' ')}\n`;
|
|
26
|
-
fs.appendFileSync(DEBUG_FILE, msg);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const sessionStates = new Map();
|
|
30
|
-
const STATE_TTL = 300_000; // 5 minutes
|
|
31
|
-
/**
|
|
32
|
-
* Get or create session state
|
|
33
|
-
*/
|
|
34
|
-
function getSessionState(sessionId) {
|
|
35
|
-
let state = sessionStates.get(sessionId);
|
|
36
|
-
const now = Date.now();
|
|
37
|
-
// Reset stale state
|
|
38
|
-
if (state && now - state.lastErrorTime > STATE_TTL) {
|
|
39
|
-
state = undefined;
|
|
40
|
-
}
|
|
41
|
-
if (!state) {
|
|
42
|
-
state = {
|
|
43
|
-
retryState: { attempt: 0, lastAttemptTime: 0 },
|
|
44
|
-
truncateState: { truncateAttempt: 0 },
|
|
45
|
-
lastErrorTime: now,
|
|
46
|
-
errorCount: 0,
|
|
47
|
-
};
|
|
48
|
-
sessionStates.set(sessionId, state);
|
|
49
|
-
}
|
|
50
|
-
return state;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Clean up old session states
|
|
54
|
-
*/
|
|
55
|
-
function cleanupSessionStates() {
|
|
56
|
-
const now = Date.now();
|
|
57
|
-
for (const [sessionId, state] of sessionStates) {
|
|
58
|
-
if (now - state.lastErrorTime > STATE_TTL) {
|
|
59
|
-
sessionStates.delete(sessionId);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
// Run cleanup periodically
|
|
64
|
-
let cleanupIntervalStarted = false;
|
|
65
|
-
/**
|
|
66
|
-
* Create context window limit recovery hook
|
|
67
|
-
*
|
|
68
|
-
* This hook monitors for token/context limit errors and injects
|
|
69
|
-
* helpful recovery messages when detected.
|
|
70
|
-
*/
|
|
71
|
-
export function createContextLimitRecoveryHook(config) {
|
|
72
|
-
debugLog('createContextLimitRecoveryHook called', { config });
|
|
73
|
-
if (!cleanupIntervalStarted) {
|
|
74
|
-
cleanupIntervalStarted = true;
|
|
75
|
-
setInterval(cleanupSessionStates, 60_000);
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
/**
|
|
79
|
-
* PostToolUse - Check for context limit errors in tool responses
|
|
80
|
-
*/
|
|
81
|
-
postToolUse: (input) => {
|
|
82
|
-
if (!input.tool_response) {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
// Check if response contains token limit error
|
|
86
|
-
const parsed = parseTokenLimitError(input.tool_response);
|
|
87
|
-
if (!parsed && !containsTokenLimitError(input.tool_response)) {
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
debugLog('detected token limit error', {
|
|
91
|
-
tool: input.tool_name,
|
|
92
|
-
sessionId: input.session_id,
|
|
93
|
-
parsed,
|
|
94
|
-
});
|
|
95
|
-
const state = getSessionState(input.session_id);
|
|
96
|
-
state.lastErrorTime = Date.now();
|
|
97
|
-
state.errorCount++;
|
|
98
|
-
// Generate appropriate recovery message
|
|
99
|
-
const recovery = generateRecoveryMessage(parsed, state, config);
|
|
100
|
-
if (recovery.message) {
|
|
101
|
-
debugLog('injecting recovery message', {
|
|
102
|
-
errorType: recovery.errorType,
|
|
103
|
-
attempt: state.retryState.attempt,
|
|
104
|
-
});
|
|
105
|
-
return recovery.message;
|
|
106
|
-
}
|
|
107
|
-
return null;
|
|
108
|
-
},
|
|
109
|
-
/**
|
|
110
|
-
* Notification - Check for error notifications
|
|
111
|
-
* (Called when errors are passed through notification system)
|
|
112
|
-
*/
|
|
113
|
-
onError: (input) => {
|
|
114
|
-
const parsed = parseTokenLimitError(input.error);
|
|
115
|
-
if (!parsed) {
|
|
116
|
-
return {
|
|
117
|
-
attempted: false,
|
|
118
|
-
success: false,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
debugLog('error notification contains token limit error', {
|
|
122
|
-
sessionId: input.session_id,
|
|
123
|
-
parsed,
|
|
124
|
-
});
|
|
125
|
-
const state = getSessionState(input.session_id);
|
|
126
|
-
state.lastErrorTime = Date.now();
|
|
127
|
-
state.errorCount++;
|
|
128
|
-
const recovery = generateRecoveryMessage(parsed, state, config);
|
|
129
|
-
return {
|
|
130
|
-
attempted: true,
|
|
131
|
-
success: !!recovery.message,
|
|
132
|
-
message: recovery.message,
|
|
133
|
-
errorType: recovery.errorType,
|
|
134
|
-
};
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Generate appropriate recovery message based on error and state
|
|
140
|
-
*/
|
|
141
|
-
function generateRecoveryMessage(parsed, state, config) {
|
|
142
|
-
// Use custom message if provided
|
|
143
|
-
if (config?.customMessage) {
|
|
144
|
-
return {
|
|
145
|
-
message: config.customMessage,
|
|
146
|
-
errorType: parsed?.errorType,
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
// Handle non-empty content error
|
|
150
|
-
if (parsed?.errorType?.includes('non-empty content')) {
|
|
151
|
-
return {
|
|
152
|
-
message: NON_EMPTY_CONTENT_RECOVERY_MESSAGE,
|
|
153
|
-
errorType: 'non-empty content',
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
// Check retry limits
|
|
157
|
-
state.retryState.attempt++;
|
|
158
|
-
state.retryState.lastAttemptTime = Date.now();
|
|
159
|
-
if (state.retryState.attempt > RETRY_CONFIG.maxAttempts) {
|
|
160
|
-
return {
|
|
161
|
-
message: RECOVERY_FAILED_MESSAGE,
|
|
162
|
-
errorType: 'recovery_exhausted',
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
// Return detailed or short message based on config
|
|
166
|
-
if (config?.detailed !== false) {
|
|
167
|
-
let message = CONTEXT_LIMIT_RECOVERY_MESSAGE;
|
|
168
|
-
// Add token info if available
|
|
169
|
-
if (parsed?.currentTokens && parsed?.maxTokens) {
|
|
170
|
-
message += `\nToken Details:
|
|
171
|
-
- Current: ${parsed.currentTokens.toLocaleString()} tokens
|
|
172
|
-
- Maximum: ${parsed.maxTokens.toLocaleString()} tokens
|
|
173
|
-
- Over limit by: ${(parsed.currentTokens - parsed.maxTokens).toLocaleString()} tokens
|
|
174
|
-
`;
|
|
175
|
-
}
|
|
176
|
-
return {
|
|
177
|
-
message,
|
|
178
|
-
errorType: parsed?.errorType || 'token_limit_exceeded',
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
return {
|
|
182
|
-
message: CONTEXT_LIMIT_SHORT_MESSAGE,
|
|
183
|
-
errorType: parsed?.errorType || 'token_limit_exceeded',
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Check if text contains a context limit error
|
|
188
|
-
*/
|
|
189
|
-
export function detectContextLimitError(text) {
|
|
190
|
-
return containsTokenLimitError(text);
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Parse error to get detailed token limit info
|
|
194
|
-
*/
|
|
195
|
-
export function parseContextLimitError(error) {
|
|
196
|
-
return parseTokenLimitError(error);
|
|
197
|
-
}
|
|
198
|
-
export { RETRY_CONFIG, TRUNCATE_CONFIG } from './types.js';
|
|
199
|
-
export { CONTEXT_LIMIT_RECOVERY_MESSAGE, CONTEXT_LIMIT_SHORT_MESSAGE, NON_EMPTY_CONTENT_RECOVERY_MESSAGE, TRUNCATION_APPLIED_MESSAGE, RECOVERY_FAILED_MESSAGE, } from './constants.js';
|
|
200
|
-
export { parseTokenLimitError, containsTokenLimitError, TOKEN_LIMIT_PATTERNS, TOKEN_LIMIT_KEYWORDS, } from './parser.js';
|
|
201
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/context-window-limit-recovery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAE5B,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,kCAAkC,EAClC,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAOxB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,KAAK,GAAG,CAAC;AAC/D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,kCAAkC,CAAC,CAAC;AAE3E,SAAS,QAAQ,CAAC,GAAG,IAAe;IAClC,IAAI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AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAY;IAClD,OAAO,uBAAuB,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAc;IAEd,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAUD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE3D,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,kCAAkC,EAClC,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,aAAa,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Context Window Limit Error Parser
|
|
3
|
-
*
|
|
4
|
-
* Parses error responses to detect token/context limit errors.
|
|
5
|
-
*
|
|
6
|
-
* Adapted from oh-my-opencode's anthropic-context-window-limit-recovery hook.
|
|
7
|
-
*/
|
|
8
|
-
import type { ParsedTokenLimitError } from './types.js';
|
|
9
|
-
/**
|
|
10
|
-
* Patterns to extract token counts from error messages
|
|
11
|
-
*/
|
|
12
|
-
declare const TOKEN_LIMIT_PATTERNS: RegExp[];
|
|
13
|
-
/**
|
|
14
|
-
* Keywords indicating token limit errors
|
|
15
|
-
*/
|
|
16
|
-
declare const TOKEN_LIMIT_KEYWORDS: string[];
|
|
17
|
-
/**
|
|
18
|
-
* Patterns indicating thinking block structure errors (NOT token limit)
|
|
19
|
-
* These should be handled differently
|
|
20
|
-
*/
|
|
21
|
-
declare const THINKING_BLOCK_ERROR_PATTERNS: RegExp[];
|
|
22
|
-
/**
|
|
23
|
-
* Parse an error to detect if it's a token limit error
|
|
24
|
-
*/
|
|
25
|
-
export declare function parseTokenLimitError(err: unknown): ParsedTokenLimitError | null;
|
|
26
|
-
/**
|
|
27
|
-
* Check if a string contains a token limit error indication
|
|
28
|
-
*/
|
|
29
|
-
export declare function containsTokenLimitError(text: string): boolean;
|
|
30
|
-
export { TOKEN_LIMIT_PATTERNS, TOKEN_LIMIT_KEYWORDS, THINKING_BLOCK_ERROR_PATTERNS, };
|
|
31
|
-
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/hooks/context-window-limit-recovery/parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;GAEG;AACH,QAAA,MAAM,oBAAoB,UAMzB,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,oBAAoB,UASzB,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,6BAA6B,UAOlC,CAAC;AAuDF;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,OAAO,GACX,qBAAqB,GAAG,IAAI,CA8J9B;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D;AAGD,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,6BAA6B,GAC9B,CAAC"}
|