aicodeman 0.2.8
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/LICENSE +21 -0
- package/README.md +403 -0
- package/dist/ai-checker-base.d.ts +175 -0
- package/dist/ai-checker-base.d.ts.map +1 -0
- package/dist/ai-checker-base.js +424 -0
- package/dist/ai-checker-base.js.map +1 -0
- package/dist/ai-idle-checker.d.ts +53 -0
- package/dist/ai-idle-checker.d.ts.map +1 -0
- package/dist/ai-idle-checker.js +141 -0
- package/dist/ai-idle-checker.js.map +1 -0
- package/dist/ai-plan-checker.d.ts +52 -0
- package/dist/ai-plan-checker.d.ts.map +1 -0
- package/dist/ai-plan-checker.js +103 -0
- package/dist/ai-plan-checker.js.map +1 -0
- package/dist/bash-tool-parser.d.ts +191 -0
- package/dist/bash-tool-parser.d.ts.map +1 -0
- package/dist/bash-tool-parser.js +598 -0
- package/dist/bash-tool-parser.js.map +1 -0
- package/dist/cli.d.ts +12 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +460 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/buffer-limits.d.ts +59 -0
- package/dist/config/buffer-limits.d.ts.map +1 -0
- package/dist/config/buffer-limits.js +74 -0
- package/dist/config/buffer-limits.js.map +1 -0
- package/dist/config/map-limits.d.ts +40 -0
- package/dist/config/map-limits.d.ts.map +1 -0
- package/dist/config/map-limits.js +52 -0
- package/dist/config/map-limits.js.map +1 -0
- package/dist/file-stream-manager.d.ts +148 -0
- package/dist/file-stream-manager.d.ts.map +1 -0
- package/dist/file-stream-manager.js +351 -0
- package/dist/file-stream-manager.js.map +1 -0
- package/dist/hooks-config.d.ts +31 -0
- package/dist/hooks-config.d.ts.map +1 -0
- package/dist/hooks-config.js +115 -0
- package/dist/hooks-config.js.map +1 -0
- package/dist/image-watcher.d.ts +86 -0
- package/dist/image-watcher.d.ts.map +1 -0
- package/dist/image-watcher.js +275 -0
- package/dist/image-watcher.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/mux-factory.d.ts +13 -0
- package/dist/mux-factory.d.ts.map +1 -0
- package/dist/mux-factory.js +19 -0
- package/dist/mux-factory.js.map +1 -0
- package/dist/mux-interface.d.ts +145 -0
- package/dist/mux-interface.d.ts.map +1 -0
- package/dist/mux-interface.js +9 -0
- package/dist/mux-interface.js.map +1 -0
- package/dist/plan-orchestrator.d.ts +123 -0
- package/dist/plan-orchestrator.d.ts.map +1 -0
- package/dist/plan-orchestrator.js +500 -0
- package/dist/plan-orchestrator.js.map +1 -0
- package/dist/prompts/index.d.ts +9 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +9 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/planner.d.ts +14 -0
- package/dist/prompts/planner.d.ts.map +1 -0
- package/dist/prompts/planner.js +83 -0
- package/dist/prompts/planner.js.map +1 -0
- package/dist/prompts/research-agent.d.ts +10 -0
- package/dist/prompts/research-agent.d.ts.map +1 -0
- package/dist/prompts/research-agent.js +143 -0
- package/dist/prompts/research-agent.js.map +1 -0
- package/dist/push-store.d.ts +41 -0
- package/dist/push-store.d.ts.map +1 -0
- package/dist/push-store.js +168 -0
- package/dist/push-store.js.map +1 -0
- package/dist/ralph-config.d.ts +67 -0
- package/dist/ralph-config.d.ts.map +1 -0
- package/dist/ralph-config.js +134 -0
- package/dist/ralph-config.js.map +1 -0
- package/dist/ralph-loop.d.ts +124 -0
- package/dist/ralph-loop.d.ts.map +1 -0
- package/dist/ralph-loop.js +418 -0
- package/dist/ralph-loop.js.map +1 -0
- package/dist/ralph-tracker.d.ts +1081 -0
- package/dist/ralph-tracker.d.ts.map +1 -0
- package/dist/ralph-tracker.js +3343 -0
- package/dist/ralph-tracker.js.map +1 -0
- package/dist/respawn-controller.d.ts +1182 -0
- package/dist/respawn-controller.d.ts.map +1 -0
- package/dist/respawn-controller.js +2754 -0
- package/dist/respawn-controller.js.map +1 -0
- package/dist/run-summary.d.ts +123 -0
- package/dist/run-summary.d.ts.map +1 -0
- package/dist/run-summary.js +325 -0
- package/dist/run-summary.js.map +1 -0
- package/dist/session-lifecycle-log.d.ts +36 -0
- package/dist/session-lifecycle-log.d.ts.map +1 -0
- package/dist/session-lifecycle-log.js +101 -0
- package/dist/session-lifecycle-log.js.map +1 -0
- package/dist/session-manager.d.ts +97 -0
- package/dist/session-manager.d.ts.map +1 -0
- package/dist/session-manager.js +224 -0
- package/dist/session-manager.js.map +1 -0
- package/dist/session.d.ts +686 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +2025 -0
- package/dist/session.js.map +1 -0
- package/dist/state-store.d.ts +189 -0
- package/dist/state-store.d.ts.map +1 -0
- package/dist/state-store.js +730 -0
- package/dist/state-store.js.map +1 -0
- package/dist/subagent-watcher.d.ts +345 -0
- package/dist/subagent-watcher.d.ts.map +1 -0
- package/dist/subagent-watcher.js +1469 -0
- package/dist/subagent-watcher.js.map +1 -0
- package/dist/task-queue.d.ts +108 -0
- package/dist/task-queue.d.ts.map +1 -0
- package/dist/task-queue.js +235 -0
- package/dist/task-queue.js.map +1 -0
- package/dist/task-tracker.d.ts +306 -0
- package/dist/task-tracker.d.ts.map +1 -0
- package/dist/task-tracker.js +488 -0
- package/dist/task-tracker.js.map +1 -0
- package/dist/task.d.ts +73 -0
- package/dist/task.d.ts.map +1 -0
- package/dist/task.js +177 -0
- package/dist/task.js.map +1 -0
- package/dist/team-watcher.d.ts +53 -0
- package/dist/team-watcher.d.ts.map +1 -0
- package/dist/team-watcher.js +313 -0
- package/dist/team-watcher.js.map +1 -0
- package/dist/templates/case-template.md +461 -0
- package/dist/templates/claude-md.d.ts +26 -0
- package/dist/templates/claude-md.d.ts.map +1 -0
- package/dist/templates/claude-md.js +74 -0
- package/dist/templates/claude-md.js.map +1 -0
- package/dist/tmux-manager.d.ts +181 -0
- package/dist/tmux-manager.d.ts.map +1 -0
- package/dist/tmux-manager.js +1405 -0
- package/dist/tmux-manager.js.map +1 -0
- package/dist/transcript-watcher.d.ts +110 -0
- package/dist/transcript-watcher.d.ts.map +1 -0
- package/dist/transcript-watcher.js +338 -0
- package/dist/transcript-watcher.js.map +1 -0
- package/dist/tunnel-manager.d.ts +54 -0
- package/dist/tunnel-manager.d.ts.map +1 -0
- package/dist/tunnel-manager.js +251 -0
- package/dist/tunnel-manager.js.map +1 -0
- package/dist/types.d.ts +1139 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +215 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/buffer-accumulator.d.ts +111 -0
- package/dist/utils/buffer-accumulator.d.ts.map +1 -0
- package/dist/utils/buffer-accumulator.js +172 -0
- package/dist/utils/buffer-accumulator.js.map +1 -0
- package/dist/utils/claude-cli-resolver.d.ts +26 -0
- package/dist/utils/claude-cli-resolver.d.ts.map +1 -0
- package/dist/utils/claude-cli-resolver.js +78 -0
- package/dist/utils/claude-cli-resolver.js.map +1 -0
- package/dist/utils/cleanup-manager.d.ts +165 -0
- package/dist/utils/cleanup-manager.d.ts.map +1 -0
- package/dist/utils/cleanup-manager.js +274 -0
- package/dist/utils/cleanup-manager.js.map +1 -0
- package/dist/utils/index.d.ts +19 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +19 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/lru-map.d.ts +140 -0
- package/dist/utils/lru-map.d.ts.map +1 -0
- package/dist/utils/lru-map.js +234 -0
- package/dist/utils/lru-map.js.map +1 -0
- package/dist/utils/nice-wrapper.d.ts +13 -0
- package/dist/utils/nice-wrapper.d.ts.map +1 -0
- package/dist/utils/nice-wrapper.js +17 -0
- package/dist/utils/nice-wrapper.js.map +1 -0
- package/dist/utils/opencode-cli-resolver.d.ts +21 -0
- package/dist/utils/opencode-cli-resolver.d.ts.map +1 -0
- package/dist/utils/opencode-cli-resolver.js +67 -0
- package/dist/utils/opencode-cli-resolver.js.map +1 -0
- package/dist/utils/regex-patterns.d.ts +64 -0
- package/dist/utils/regex-patterns.d.ts.map +1 -0
- package/dist/utils/regex-patterns.js +74 -0
- package/dist/utils/regex-patterns.js.map +1 -0
- package/dist/utils/stale-expiration-map.d.ts +159 -0
- package/dist/utils/stale-expiration-map.d.ts.map +1 -0
- package/dist/utils/stale-expiration-map.js +277 -0
- package/dist/utils/stale-expiration-map.js.map +1 -0
- package/dist/utils/string-similarity.d.ts +108 -0
- package/dist/utils/string-similarity.d.ts.map +1 -0
- package/dist/utils/string-similarity.js +189 -0
- package/dist/utils/string-similarity.js.map +1 -0
- package/dist/utils/token-validation.d.ts +39 -0
- package/dist/utils/token-validation.d.ts.map +1 -0
- package/dist/utils/token-validation.js +59 -0
- package/dist/utils/token-validation.js.map +1 -0
- package/dist/utils/type-safety.d.ts +33 -0
- package/dist/utils/type-safety.d.ts.map +1 -0
- package/dist/utils/type-safety.js +35 -0
- package/dist/utils/type-safety.js.map +1 -0
- package/dist/web/public/app.js +491 -0
- package/dist/web/public/app.js.br +0 -0
- package/dist/web/public/app.js.gz +0 -0
- package/dist/web/public/index.html +1675 -0
- package/dist/web/public/index.html.br +0 -0
- package/dist/web/public/index.html.gz +0 -0
- package/dist/web/public/manifest.json +8 -0
- package/dist/web/public/mobile.css +1 -0
- package/dist/web/public/mobile.css.br +0 -0
- package/dist/web/public/mobile.css.gz +0 -0
- package/dist/web/public/ralph-wizard.js +1037 -0
- package/dist/web/public/ralph-wizard.js.br +0 -0
- package/dist/web/public/ralph-wizard.js.gz +0 -0
- package/dist/web/public/styles.css +1 -0
- package/dist/web/public/styles.css.br +0 -0
- package/dist/web/public/styles.css.gz +0 -0
- package/dist/web/public/sw.js +67 -0
- package/dist/web/public/sw.js.br +0 -0
- package/dist/web/public/sw.js.gz +0 -0
- package/dist/web/public/upload.html +155 -0
- package/dist/web/public/upload.html.br +0 -0
- package/dist/web/public/upload.html.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-fit.min.js +1 -0
- package/dist/web/public/vendor/xterm-addon-fit.min.js.br +0 -0
- package/dist/web/public/vendor/xterm-addon-fit.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-unicode11.min.js +1 -0
- package/dist/web/public/vendor/xterm-addon-unicode11.min.js.br +0 -0
- package/dist/web/public/vendor/xterm-addon-unicode11.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-webgl.min.js +2 -0
- package/dist/web/public/vendor/xterm-addon-webgl.min.js.br +0 -0
- package/dist/web/public/vendor/xterm-addon-webgl.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm.css +209 -0
- package/dist/web/public/vendor/xterm.css.br +0 -0
- package/dist/web/public/vendor/xterm.css.gz +0 -0
- package/dist/web/public/vendor/xterm.min.js +9 -0
- package/dist/web/public/vendor/xterm.min.js.br +0 -0
- package/dist/web/public/vendor/xterm.min.js.gz +0 -0
- package/dist/web/schemas.d.ts +479 -0
- package/dist/web/schemas.d.ts.map +1 -0
- package/dist/web/schemas.js +448 -0
- package/dist/web/schemas.js.map +1 -0
- package/dist/web/server.d.ts +207 -0
- package/dist/web/server.d.ts.map +1 -0
- package/dist/web/server.js +5784 -0
- package/dist/web/server.js.map +1 -0
- package/package.json +110 -0
- package/scripts/postinstall.js +390 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview AI-Powered Plan Mode Checker for Auto-Accept
|
|
3
|
+
*
|
|
4
|
+
* Spawns a fresh Claude CLI session in a tmux session to analyze terminal output
|
|
5
|
+
* and determine if Claude Code is showing a plan mode approval prompt.
|
|
6
|
+
* Used as a confirmation gate before auto-accepting prompts.
|
|
7
|
+
*
|
|
8
|
+
* ## How It Works
|
|
9
|
+
*
|
|
10
|
+
* 1. Generate temp file path for output capture
|
|
11
|
+
* 2. Spawn tmux: `tmux new-session -d -s codeman-plancheck-<short> bash -c 'claude -p ...'`
|
|
12
|
+
* 3. Poll the temp file every 500ms for `__PLANCHECK_DONE__` marker
|
|
13
|
+
* 4. Parse the file content for PLAN_MODE/NOT_PLAN_MODE on the first line
|
|
14
|
+
* 5. Kill tmux session and delete temp file
|
|
15
|
+
*
|
|
16
|
+
* ## Error Handling
|
|
17
|
+
*
|
|
18
|
+
* - Tmux spawn fails: 30s cooldown, increment error counter
|
|
19
|
+
* - Check times out (60s): Kill session, 30s cooldown
|
|
20
|
+
* - Can't parse verdict: Treat as NOT_PLAN_MODE, 30s cooldown
|
|
21
|
+
* - 3 consecutive errors: Disable AI plan check
|
|
22
|
+
*
|
|
23
|
+
* @module ai-plan-checker
|
|
24
|
+
*/
|
|
25
|
+
import { AiCheckerBase, type AiCheckerConfigBase, type AiCheckerResultBase, type AiCheckerStateBase } from './ai-checker-base.js';
|
|
26
|
+
export type AiPlanCheckConfig = AiCheckerConfigBase;
|
|
27
|
+
export type AiPlanCheckVerdict = 'PLAN_MODE' | 'NOT_PLAN_MODE' | 'ERROR';
|
|
28
|
+
export type AiPlanCheckResult = AiCheckerResultBase<AiPlanCheckVerdict>;
|
|
29
|
+
export type AiPlanCheckState = AiCheckerStateBase<AiPlanCheckVerdict>;
|
|
30
|
+
/**
|
|
31
|
+
* Manages AI-powered plan mode detection by spawning a fresh Claude CLI session
|
|
32
|
+
* to analyze terminal output and confirm plan mode approval prompts.
|
|
33
|
+
*/
|
|
34
|
+
export declare class AiPlanChecker extends AiCheckerBase<AiPlanCheckVerdict, AiPlanCheckConfig, AiPlanCheckResult, AiPlanCheckState> {
|
|
35
|
+
protected readonly muxNamePrefix = "codeman-plancheck-";
|
|
36
|
+
protected readonly doneMarker = "__PLANCHECK_DONE__";
|
|
37
|
+
protected readonly tempFilePrefix = "codeman-plancheck";
|
|
38
|
+
protected readonly logPrefix = "[AiPlanChecker]";
|
|
39
|
+
protected readonly checkDescription = "AI plan check";
|
|
40
|
+
constructor(sessionId: string, config?: Partial<AiPlanCheckConfig>);
|
|
41
|
+
protected buildPrompt(terminalBuffer: string): string;
|
|
42
|
+
protected parseVerdict(output: string): {
|
|
43
|
+
verdict: AiPlanCheckVerdict;
|
|
44
|
+
reasoning: string;
|
|
45
|
+
} | null;
|
|
46
|
+
protected getPositiveVerdict(): AiPlanCheckVerdict;
|
|
47
|
+
protected getNegativeVerdict(): AiPlanCheckVerdict;
|
|
48
|
+
protected getErrorVerdict(): AiPlanCheckVerdict;
|
|
49
|
+
protected createErrorResult(reasoning: string, durationMs: number): AiPlanCheckResult;
|
|
50
|
+
protected createResult(verdict: AiPlanCheckVerdict, reasoning: string, durationMs: number): AiPlanCheckResult;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=ai-plan-checker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-plan-checker.d.ts","sourceRoot":"","sources":["../src/ai-plan-checker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,sBAAsB,CAAC;AAI9B,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAEpD,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,eAAe,GAAG,OAAO,CAAC;AAEzE,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;AAExE,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;AA2CtE;;;GAGG;AACH,qBAAa,aAAc,SAAQ,aAAa,CAC9C,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,CACjB;IACC,SAAS,CAAC,QAAQ,CAAC,aAAa,wBAAwB;IACxD,SAAS,CAAC,QAAQ,CAAC,UAAU,wBAAwB;IACrD,SAAS,CAAC,QAAQ,CAAC,cAAc,uBAAuB;IACxD,SAAS,CAAC,QAAQ,CAAC,SAAS,qBAAqB;IACjD,SAAS,CAAC,QAAQ,CAAC,gBAAgB,mBAAmB;gBAE1C,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,CAAC,iBAAiB,CAAM;IAItE,SAAS,CAAC,WAAW,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM;IAIrD,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,kBAAkB,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAWjG,SAAS,CAAC,kBAAkB,IAAI,kBAAkB;IAIlD,SAAS,CAAC,kBAAkB,IAAI,kBAAkB;IAIlD,SAAS,CAAC,eAAe,IAAI,kBAAkB;IAI/C,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,iBAAiB;IAIrF,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,iBAAiB;CAG9G"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview AI-Powered Plan Mode Checker for Auto-Accept
|
|
3
|
+
*
|
|
4
|
+
* Spawns a fresh Claude CLI session in a tmux session to analyze terminal output
|
|
5
|
+
* and determine if Claude Code is showing a plan mode approval prompt.
|
|
6
|
+
* Used as a confirmation gate before auto-accepting prompts.
|
|
7
|
+
*
|
|
8
|
+
* ## How It Works
|
|
9
|
+
*
|
|
10
|
+
* 1. Generate temp file path for output capture
|
|
11
|
+
* 2. Spawn tmux: `tmux new-session -d -s codeman-plancheck-<short> bash -c 'claude -p ...'`
|
|
12
|
+
* 3. Poll the temp file every 500ms for `__PLANCHECK_DONE__` marker
|
|
13
|
+
* 4. Parse the file content for PLAN_MODE/NOT_PLAN_MODE on the first line
|
|
14
|
+
* 5. Kill tmux session and delete temp file
|
|
15
|
+
*
|
|
16
|
+
* ## Error Handling
|
|
17
|
+
*
|
|
18
|
+
* - Tmux spawn fails: 30s cooldown, increment error counter
|
|
19
|
+
* - Check times out (60s): Kill session, 30s cooldown
|
|
20
|
+
* - Can't parse verdict: Treat as NOT_PLAN_MODE, 30s cooldown
|
|
21
|
+
* - 3 consecutive errors: Disable AI plan check
|
|
22
|
+
*
|
|
23
|
+
* @module ai-plan-checker
|
|
24
|
+
*/
|
|
25
|
+
import { AiCheckerBase, } from './ai-checker-base.js';
|
|
26
|
+
// ========== Constants ==========
|
|
27
|
+
const DEFAULT_PLAN_CHECK_CONFIG = {
|
|
28
|
+
enabled: true,
|
|
29
|
+
model: 'claude-opus-4-5-20251101',
|
|
30
|
+
maxContextChars: 8000,
|
|
31
|
+
checkTimeoutMs: 60000,
|
|
32
|
+
cooldownMs: 30000,
|
|
33
|
+
errorCooldownMs: 30000,
|
|
34
|
+
maxConsecutiveErrors: 3,
|
|
35
|
+
};
|
|
36
|
+
/** Pattern to match PLAN_MODE or NOT_PLAN_MODE as the first word(s) of output */
|
|
37
|
+
const VERDICT_PATTERN = /^\s*(PLAN_MODE|NOT_PLAN_MODE)\b/i;
|
|
38
|
+
/** The prompt sent to the AI plan checker */
|
|
39
|
+
const AI_PLAN_CHECK_PROMPT = `Analyze this terminal output from a running Claude Code session. Determine if the terminal is currently showing a PLAN MODE APPROVAL PROMPT or not.
|
|
40
|
+
|
|
41
|
+
A plan mode approval prompt is a numbered selection menu that Claude Code shows when it wants the user to approve a plan before proceeding. It typically has these characteristics:
|
|
42
|
+
- A numbered list of options (e.g., "1. Yes", "2. No", "3. Type your own")
|
|
43
|
+
- A selection indicator arrow (❯ or >) pointing to one of the options
|
|
44
|
+
- Text asking for approval like "Would you like to proceed?" or "Ready to implement?"
|
|
45
|
+
- The prompt appears at the BOTTOM of the output (most recent content)
|
|
46
|
+
|
|
47
|
+
NOT a plan mode prompt:
|
|
48
|
+
- Claude actively working (spinners, "Thinking", tool execution)
|
|
49
|
+
- A completed response with no selection menu
|
|
50
|
+
- An AskUserQuestion/elicitation dialog (different format, free-text input)
|
|
51
|
+
- Network lag or mid-output pause
|
|
52
|
+
- Any state without a visible numbered selection menu
|
|
53
|
+
|
|
54
|
+
Terminal output (most recent at bottom):
|
|
55
|
+
---
|
|
56
|
+
{TERMINAL_BUFFER}
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
Answer with EXACTLY one of these on the first line: PLAN_MODE or NOT_PLAN_MODE
|
|
60
|
+
Then optionally explain briefly why.`;
|
|
61
|
+
// ========== AiPlanChecker Class ==========
|
|
62
|
+
/**
|
|
63
|
+
* Manages AI-powered plan mode detection by spawning a fresh Claude CLI session
|
|
64
|
+
* to analyze terminal output and confirm plan mode approval prompts.
|
|
65
|
+
*/
|
|
66
|
+
export class AiPlanChecker extends AiCheckerBase {
|
|
67
|
+
muxNamePrefix = 'codeman-plancheck-';
|
|
68
|
+
doneMarker = '__PLANCHECK_DONE__';
|
|
69
|
+
tempFilePrefix = 'codeman-plancheck';
|
|
70
|
+
logPrefix = '[AiPlanChecker]';
|
|
71
|
+
checkDescription = 'AI plan check';
|
|
72
|
+
constructor(sessionId, config = {}) {
|
|
73
|
+
super(sessionId, DEFAULT_PLAN_CHECK_CONFIG, config);
|
|
74
|
+
}
|
|
75
|
+
buildPrompt(terminalBuffer) {
|
|
76
|
+
return AI_PLAN_CHECK_PROMPT.replace('{TERMINAL_BUFFER}', terminalBuffer);
|
|
77
|
+
}
|
|
78
|
+
parseVerdict(output) {
|
|
79
|
+
const match = output.match(VERDICT_PATTERN);
|
|
80
|
+
if (!match)
|
|
81
|
+
return null;
|
|
82
|
+
const verdict = match[1].toUpperCase();
|
|
83
|
+
const lines = output.split('\n');
|
|
84
|
+
const reasoning = lines.slice(1).join('\n').trim() || `AI determined: ${verdict}`;
|
|
85
|
+
return { verdict, reasoning };
|
|
86
|
+
}
|
|
87
|
+
getPositiveVerdict() {
|
|
88
|
+
return 'PLAN_MODE';
|
|
89
|
+
}
|
|
90
|
+
getNegativeVerdict() {
|
|
91
|
+
return 'NOT_PLAN_MODE';
|
|
92
|
+
}
|
|
93
|
+
getErrorVerdict() {
|
|
94
|
+
return 'ERROR';
|
|
95
|
+
}
|
|
96
|
+
createErrorResult(reasoning, durationMs) {
|
|
97
|
+
return { verdict: 'ERROR', reasoning, durationMs };
|
|
98
|
+
}
|
|
99
|
+
createResult(verdict, reasoning, durationMs) {
|
|
100
|
+
return { verdict, reasoning, durationMs };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=ai-plan-checker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-plan-checker.js","sourceRoot":"","sources":["../src/ai-plan-checker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,aAAa,GAId,MAAM,sBAAsB,CAAC;AAY9B,kCAAkC;AAElC,MAAM,yBAAyB,GAAsB;IACnD,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,0BAA0B;IACjC,eAAe,EAAE,IAAI;IACrB,cAAc,EAAE,KAAK;IACrB,UAAU,EAAE,KAAK;IACjB,eAAe,EAAE,KAAK;IACtB,oBAAoB,EAAE,CAAC;CACxB,CAAC;AAEF,iFAAiF;AACjF,MAAM,eAAe,GAAG,kCAAkC,CAAC;AAE3D,6CAA6C;AAC7C,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;qCAqBQ,CAAC;AAEtC,4CAA4C;AAE5C;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,aAKlC;IACoB,aAAa,GAAG,oBAAoB,CAAC;IACrC,UAAU,GAAG,oBAAoB,CAAC;IAClC,cAAc,GAAG,mBAAmB,CAAC;IACrC,SAAS,GAAG,iBAAiB,CAAC;IAC9B,gBAAgB,GAAG,eAAe,CAAC;IAEtD,YAAY,SAAiB,EAAE,SAAqC,EAAE;QACpE,KAAK,CAAC,SAAS,EAAE,yBAAyB,EAAE,MAAM,CAAC,CAAC;IACtD,CAAC;IAES,WAAW,CAAC,cAAsB;QAC1C,OAAO,oBAAoB,CAAC,OAAO,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;IAC3E,CAAC;IAES,YAAY,CAAC,MAAc;QACnC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC5C,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QAExB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAmC,CAAC;QACxE,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,kBAAkB,OAAO,EAAE,CAAC;QAElF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAChC,CAAC;IAES,kBAAkB;QAC1B,OAAO,WAAW,CAAC;IACrB,CAAC;IAES,kBAAkB;QAC1B,OAAO,eAAe,CAAC;IACzB,CAAC;IAES,eAAe;QACvB,OAAO,OAAO,CAAC;IACjB,CAAC;IAES,iBAAiB,CAAC,SAAiB,EAAE,UAAkB;QAC/D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;IACrD,CAAC;IAES,YAAY,CAAC,OAA2B,EAAE,SAAiB,EAAE,UAAkB;QACvF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Bash Tool Parser - Detects active Bash tool commands with file paths
|
|
3
|
+
*
|
|
4
|
+
* This module parses terminal output from Claude Code sessions to detect:
|
|
5
|
+
* - Bash tool invocations (● Bash(command) pattern)
|
|
6
|
+
* - File paths within commands (for tail, cat, head, grep, watch, less)
|
|
7
|
+
* - Tool completion (✓ or ✗ status)
|
|
8
|
+
*
|
|
9
|
+
* When a file-viewing command is detected, emits events with clickable paths
|
|
10
|
+
* that can be used to open live log viewer windows.
|
|
11
|
+
*
|
|
12
|
+
* @module bash-tool-parser
|
|
13
|
+
*/
|
|
14
|
+
import { EventEmitter } from 'node:events';
|
|
15
|
+
import { ActiveBashTool } from './types.js';
|
|
16
|
+
/**
|
|
17
|
+
* Events emitted by BashToolParser.
|
|
18
|
+
*/
|
|
19
|
+
export interface BashToolParserEvents {
|
|
20
|
+
/** New Bash tool with file paths started */
|
|
21
|
+
toolStart: [tool: ActiveBashTool];
|
|
22
|
+
/** Bash tool completed */
|
|
23
|
+
toolEnd: [tool: ActiveBashTool];
|
|
24
|
+
/** Active tools list updated */
|
|
25
|
+
toolsUpdate: [tools: ActiveBashTool[]];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Configuration options for BashToolParser.
|
|
29
|
+
*/
|
|
30
|
+
export interface BashToolParserConfig {
|
|
31
|
+
/** Session ID this parser belongs to */
|
|
32
|
+
sessionId: string;
|
|
33
|
+
/** Whether the parser is enabled (default: true) */
|
|
34
|
+
enabled?: boolean;
|
|
35
|
+
/** Working directory for resolving relative paths */
|
|
36
|
+
workingDir?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Parses Claude Code terminal output to detect Bash tool commands with file paths.
|
|
40
|
+
* Emits events when file-viewing commands are detected, allowing the UI to
|
|
41
|
+
* display clickable paths for opening live log viewers.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const parser = new BashToolParser({ sessionId: 'abc123' });
|
|
46
|
+
* parser.on('toolStart', (tool) => {
|
|
47
|
+
* console.log(`New tool: ${tool.command}`);
|
|
48
|
+
* console.log(`File paths: ${tool.filePaths.join(', ')}`);
|
|
49
|
+
* });
|
|
50
|
+
* parser.processTerminalData(terminalOutput);
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare class BashToolParser extends EventEmitter<BashToolParserEvents> {
|
|
54
|
+
private _sessionId;
|
|
55
|
+
private _enabled;
|
|
56
|
+
private _activeTools;
|
|
57
|
+
private _lineBuffer;
|
|
58
|
+
private _lastToolId;
|
|
59
|
+
private _workingDir;
|
|
60
|
+
private _homeDir;
|
|
61
|
+
private _autoRemoveTimers;
|
|
62
|
+
private _destroyed;
|
|
63
|
+
private _pendingUpdate;
|
|
64
|
+
private _updateTimer;
|
|
65
|
+
constructor(config: BashToolParserConfig);
|
|
66
|
+
/** Whether the parser is currently enabled */
|
|
67
|
+
get enabled(): boolean;
|
|
68
|
+
/** Session ID this parser belongs to */
|
|
69
|
+
get sessionId(): string;
|
|
70
|
+
/** Currently active tools */
|
|
71
|
+
get activeTools(): ActiveBashTool[];
|
|
72
|
+
/** Current working directory used for path resolution */
|
|
73
|
+
get workingDir(): string;
|
|
74
|
+
/**
|
|
75
|
+
* Normalize a file path to its canonical form.
|
|
76
|
+
* - Expands ~ to home directory
|
|
77
|
+
* - Resolves relative paths against working directory
|
|
78
|
+
* - Normalizes . and .. components
|
|
79
|
+
* - Removes trailing slashes
|
|
80
|
+
*/
|
|
81
|
+
normalizePath(path: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* Extract just the filename from a path.
|
|
84
|
+
*/
|
|
85
|
+
private getFilename;
|
|
86
|
+
/**
|
|
87
|
+
* Check if a path is a "shallow root path" - an absolute path with only one
|
|
88
|
+
* component after root (e.g., /test.txt, /file.log).
|
|
89
|
+
* These are often typos where the user meant a relative path.
|
|
90
|
+
*/
|
|
91
|
+
private isShallowRootPath;
|
|
92
|
+
/**
|
|
93
|
+
* Check if a path is inside (or is) the working directory.
|
|
94
|
+
*/
|
|
95
|
+
isPathInWorkingDir(path: string): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Smart path equivalence check.
|
|
98
|
+
* Two paths are considered equivalent if:
|
|
99
|
+
* 1. They normalize to the same path (standard case)
|
|
100
|
+
* 2. One is a "shallow root path" (e.g., /test.txt) and the other is the
|
|
101
|
+
* same filename inside the working directory - the shallow root path
|
|
102
|
+
* is likely a typo and they probably meant the same file.
|
|
103
|
+
*/
|
|
104
|
+
pathsAreEquivalent(path1: string, path2: string): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Given multiple paths, deduplicate and return the "best" paths.
|
|
107
|
+
* Uses smart equivalence checking:
|
|
108
|
+
* - Standard normalization for relative vs absolute paths
|
|
109
|
+
* - Detects likely typos (e.g., /file.txt when workingDir/file.txt exists)
|
|
110
|
+
* - Prefers paths inside the working directory
|
|
111
|
+
* - Prefers longer, more explicit paths
|
|
112
|
+
*/
|
|
113
|
+
deduplicatePaths(paths: string[]): string[];
|
|
114
|
+
/**
|
|
115
|
+
* Update the working directory (e.g., when session changes directory).
|
|
116
|
+
*/
|
|
117
|
+
setWorkingDir(workingDir: string): void;
|
|
118
|
+
/**
|
|
119
|
+
* Check if a file path is already being tracked by an active tool.
|
|
120
|
+
* Uses path normalization to detect equivalent paths.
|
|
121
|
+
* For example, "/test.txt" and "/home/user/test.txt" when workingDir
|
|
122
|
+
* is "/home/user" would NOT be considered equivalent (different files),
|
|
123
|
+
* but "test.txt" and "/home/user/test.txt" WOULD be (same file).
|
|
124
|
+
*/
|
|
125
|
+
isFilePathTracked(filePath: string): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Get all tracked paths (normalized) for debugging.
|
|
128
|
+
*/
|
|
129
|
+
getTrackedPaths(): {
|
|
130
|
+
raw: string;
|
|
131
|
+
normalized: string;
|
|
132
|
+
}[];
|
|
133
|
+
/**
|
|
134
|
+
* Enables the parser.
|
|
135
|
+
*/
|
|
136
|
+
enable(): void;
|
|
137
|
+
/**
|
|
138
|
+
* Disables the parser.
|
|
139
|
+
*/
|
|
140
|
+
disable(): void;
|
|
141
|
+
/**
|
|
142
|
+
* Resets the parser state, clearing all tracked tools.
|
|
143
|
+
*/
|
|
144
|
+
reset(): void;
|
|
145
|
+
/**
|
|
146
|
+
* Process terminal data to detect Bash tool patterns.
|
|
147
|
+
* Call this with each chunk of PTY output.
|
|
148
|
+
*
|
|
149
|
+
* @param data - Raw terminal data (may include ANSI codes)
|
|
150
|
+
*/
|
|
151
|
+
processTerminalData(data: string): void;
|
|
152
|
+
/**
|
|
153
|
+
* Process pre-stripped terminal data (ANSI codes already removed).
|
|
154
|
+
* Use this when the caller has already stripped ANSI to avoid redundant regex work.
|
|
155
|
+
*/
|
|
156
|
+
processCleanData(data: string): void;
|
|
157
|
+
/**
|
|
158
|
+
* Process a single line of terminal output (raw — will strip ANSI).
|
|
159
|
+
*/
|
|
160
|
+
private processLine;
|
|
161
|
+
/**
|
|
162
|
+
* Process a single pre-stripped line of terminal output.
|
|
163
|
+
*/
|
|
164
|
+
private processCleanLine;
|
|
165
|
+
/**
|
|
166
|
+
* Check if a command is a file-viewing command worth tracking.
|
|
167
|
+
*/
|
|
168
|
+
private isFileViewerCommand;
|
|
169
|
+
/**
|
|
170
|
+
* Extract file paths from a command string.
|
|
171
|
+
* Returns deduplicated paths, preferring more complete/absolute versions.
|
|
172
|
+
*/
|
|
173
|
+
private extractFilePaths;
|
|
174
|
+
/**
|
|
175
|
+
* Strip ANSI escape codes from a string.
|
|
176
|
+
*/
|
|
177
|
+
private stripAnsi;
|
|
178
|
+
/**
|
|
179
|
+
* Schedule a debounced update emission.
|
|
180
|
+
*/
|
|
181
|
+
private scheduleUpdate;
|
|
182
|
+
/**
|
|
183
|
+
* Emit the current active tools list.
|
|
184
|
+
*/
|
|
185
|
+
private emitUpdate;
|
|
186
|
+
/**
|
|
187
|
+
* Clean up resources.
|
|
188
|
+
*/
|
|
189
|
+
destroy(): void;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=bash-tool-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash-tool-parser.d.ts","sourceRoot":"","sources":["../src/bash-tool-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO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