@adhdev/daemon-core 0.6.58 → 0.6.60
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/index.d.ts +1 -1
- package/dist/index.js +87 -89
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/detection/ide-detector.ts +1 -1
- package/src/providers/provider-loader.ts +3 -6
- package/providers/_builtin/.github/workflows/generate-registry.yml +0 -76
- package/providers/_builtin/COMPATIBILITY.md +0 -217
- package/providers/_builtin/CONTRIBUTING.md +0 -200
- package/providers/_builtin/README.md +0 -119
- package/providers/_builtin/_helpers/index.js +0 -188
- package/providers/_builtin/acp/agentpool/provider.json +0 -54
- package/providers/_builtin/acp/amp/provider.json +0 -52
- package/providers/_builtin/acp/auggie/provider.json +0 -57
- package/providers/_builtin/acp/autodev/provider.json +0 -54
- package/providers/_builtin/acp/autohand/provider.json +0 -52
- package/providers/_builtin/acp/blackbox-ai/provider.json +0 -54
- package/providers/_builtin/acp/claude-agent/provider.json +0 -57
- package/providers/_builtin/acp/cline-acp/provider.json +0 -54
- package/providers/_builtin/acp/codebuddy/provider.json +0 -54
- package/providers/_builtin/acp/codex-cli/provider.json +0 -57
- package/providers/_builtin/acp/corust-agent/provider.json +0 -52
- package/providers/_builtin/acp/crow-cli/provider.json +0 -54
- package/providers/_builtin/acp/cursor-acp/provider.json +0 -54
- package/providers/_builtin/acp/deepagents/provider.json +0 -52
- package/providers/_builtin/acp/dimcode/provider.json +0 -54
- package/providers/_builtin/acp/docker-cagent/provider.json +0 -57
- package/providers/_builtin/acp/factory-droid/provider.json +0 -60
- package/providers/_builtin/acp/fast-agent/provider.json +0 -52
- package/providers/_builtin/acp/gemini-cli/provider.json +0 -114
- package/providers/_builtin/acp/github-copilot/provider.json +0 -54
- package/providers/_builtin/acp/goose/provider.json +0 -57
- package/providers/_builtin/acp/junie/provider.json +0 -52
- package/providers/_builtin/acp/kilo/provider.json +0 -54
- package/providers/_builtin/acp/kimi-cli/provider.json +0 -57
- package/providers/_builtin/acp/minion-code/provider.json +0 -52
- package/providers/_builtin/acp/mistral-vibe/provider.json +0 -57
- package/providers/_builtin/acp/nova/provider.json +0 -54
- package/providers/_builtin/acp/openclaw/provider.json +0 -54
- package/providers/_builtin/acp/opencode/provider.json +0 -52
- package/providers/_builtin/acp/openhands/provider.json +0 -54
- package/providers/_builtin/acp/pi-acp/provider.json +0 -52
- package/providers/_builtin/acp/qoder/provider.json +0 -54
- package/providers/_builtin/acp/qwen-code/provider.json +0 -60
- package/providers/_builtin/acp/stakpak/provider.json +0 -54
- package/providers/_builtin/acp/vtcode/provider.json +0 -54
- package/providers/_builtin/cli/aider-cli/provider.json +0 -37
- package/providers/_builtin/cli/aider-cli/scripts/1.0/detect_status.js +0 -20
- package/providers/_builtin/cli/aider-cli/scripts/1.0/parse_approval.js +0 -10
- package/providers/_builtin/cli/aider-cli/scripts/1.0/parse_output.js +0 -97
- package/providers/_builtin/cli/aider-cli/scripts/1.0/scripts.js +0 -7
- package/providers/_builtin/cli/claude-cli/provider.json +0 -121
- package/providers/_builtin/cli/claude-cli/scripts/1.0/detect_status.js +0 -83
- package/providers/_builtin/cli/claude-cli/scripts/1.0/parse_approval.js +0 -97
- package/providers/_builtin/cli/claude-cli/scripts/1.0/parse_output.js +0 -417
- package/providers/_builtin/cli/claude-cli/scripts/1.0/scripts.js +0 -42
- package/providers/_builtin/cli/codex-cli/provider.json +0 -90
- package/providers/_builtin/cli/codex-cli/scripts/1.0/detect_status.js +0 -54
- package/providers/_builtin/cli/codex-cli/scripts/1.0/parse_approval.js +0 -91
- package/providers/_builtin/cli/codex-cli/scripts/1.0/parse_output.js +0 -522
- package/providers/_builtin/cli/codex-cli/scripts/1.0/scripts.js +0 -11
- package/providers/_builtin/cli/cursor-cli/provider.json +0 -37
- package/providers/_builtin/cli/cursor-cli/scripts/1.0/detect_status.js +0 -19
- package/providers/_builtin/cli/cursor-cli/scripts/1.0/parse_approval.js +0 -10
- package/providers/_builtin/cli/cursor-cli/scripts/1.0/parse_output.js +0 -48
- package/providers/_builtin/cli/cursor-cli/scripts/1.0/scripts.js +0 -7
- package/providers/_builtin/cli/gemini-cli/provider.json +0 -109
- package/providers/_builtin/cli/gemini-cli/scripts/1.0/detect_status.js +0 -26
- package/providers/_builtin/cli/gemini-cli/scripts/1.0/parse_approval.js +0 -22
- package/providers/_builtin/cli/gemini-cli/scripts/1.0/parse_output.js +0 -71
- package/providers/_builtin/cli/gemini-cli/scripts/1.0/scripts.js +0 -12
- package/providers/_builtin/cli/github-copilot-cli/provider.json +0 -37
- package/providers/_builtin/cli/github-copilot-cli/scripts/1.0/detect_status.js +0 -19
- package/providers/_builtin/cli/github-copilot-cli/scripts/1.0/parse_approval.js +0 -9
- package/providers/_builtin/cli/github-copilot-cli/scripts/1.0/parse_output.js +0 -48
- package/providers/_builtin/cli/github-copilot-cli/scripts/1.0/scripts.js +0 -7
- package/providers/_builtin/cli/goose-cli/provider.json +0 -37
- package/providers/_builtin/cli/goose-cli/scripts/1.0/detect_status.js +0 -20
- package/providers/_builtin/cli/goose-cli/scripts/1.0/parse_approval.js +0 -10
- package/providers/_builtin/cli/goose-cli/scripts/1.0/parse_output.js +0 -48
- package/providers/_builtin/cli/goose-cli/scripts/1.0/scripts.js +0 -7
- package/providers/_builtin/cli/opencode-cli/provider.json +0 -37
- package/providers/_builtin/cli/opencode-cli/scripts/1.0/detect_status.js +0 -15
- package/providers/_builtin/cli/opencode-cli/scripts/1.0/parse_approval.js +0 -9
- package/providers/_builtin/cli/opencode-cli/scripts/1.0/parse_output.js +0 -48
- package/providers/_builtin/cli/opencode-cli/scripts/1.0/scripts.js +0 -7
- package/providers/_builtin/docs/CDP_SELECTOR_GUIDE.md +0 -370
- package/providers/_builtin/docs/PROVIDER_GUIDE.md +0 -916
- package/providers/_builtin/extension/cline/provider.json +0 -37
- package/providers/_builtin/extension/cline/scripts/1.0/focus_editor.js +0 -48
- package/providers/_builtin/extension/cline/scripts/1.0/list_chats.js +0 -100
- package/providers/_builtin/extension/cline/scripts/1.0/list_models.js +0 -43
- package/providers/_builtin/extension/cline/scripts/1.0/list_modes.js +0 -35
- package/providers/_builtin/extension/cline/scripts/1.0/new_session.js +0 -85
- package/providers/_builtin/extension/cline/scripts/1.0/open_panel.js +0 -25
- package/providers/_builtin/extension/cline/scripts/1.0/read_chat.js +0 -270
- package/providers/_builtin/extension/cline/scripts/1.0/resolve_action.js +0 -83
- package/providers/_builtin/extension/cline/scripts/1.0/scripts.js +0 -82
- package/providers/_builtin/extension/cline/scripts/1.0/send_message.js +0 -95
- package/providers/_builtin/extension/cline/scripts/1.0/set_mode.js +0 -36
- package/providers/_builtin/extension/cline/scripts/1.0/set_model.js +0 -36
- package/providers/_builtin/extension/cline/scripts/1.0/switch_session.js +0 -206
- package/providers/_builtin/extension/codex/provider.json +0 -38
- package/providers/_builtin/extension/codex/scripts/1.0/click_conversation_webview.js +0 -24
- package/providers/_builtin/extension/codex/scripts/1.0/explore_chat_webview.js +0 -110
- package/providers/_builtin/extension/codex/scripts/1.0/explore_controls_webview.js +0 -75
- package/providers/_builtin/extension/codex/scripts/1.0/explore_dom.js +0 -58
- package/providers/_builtin/extension/codex/scripts/1.0/explore_dropdown_webview.js +0 -64
- package/providers/_builtin/extension/codex/scripts/1.0/inspect_code_webview.js +0 -55
- package/providers/_builtin/extension/codex/scripts/1.0/list_models.js +0 -63
- package/providers/_builtin/extension/codex/scripts/1.0/list_modes.js +0 -140
- package/providers/_builtin/extension/codex/scripts/1.0/message_structure_webview.js +0 -79
- package/providers/_builtin/extension/codex/scripts/1.0/new_session.js +0 -26
- package/providers/_builtin/extension/codex/scripts/1.0/read_chat.js +0 -516
- package/providers/_builtin/extension/codex/scripts/1.0/resolve_action.js +0 -82
- package/providers/_builtin/extension/codex/scripts/1.0/send_message.js +0 -42
- package/providers/_builtin/extension/codex/scripts/1.0/set_mode.js +0 -165
- package/providers/_builtin/extension/codex/scripts/1.0/set_model.js +0 -86
- package/providers/_builtin/extension/roo-code/provider.json +0 -37
- package/providers/_builtin/extension/roo-code/scripts/1.0/scripts.js +0 -82
- package/providers/_builtin/ide/antigravity/provider.json +0 -88
- package/providers/_builtin/ide/antigravity/scripts/1.0/focus_editor.js +0 -20
- package/providers/_builtin/ide/antigravity/scripts/1.0/list_chats.js +0 -137
- package/providers/_builtin/ide/antigravity/scripts/1.0/list_models.js +0 -61
- package/providers/_builtin/ide/antigravity/scripts/1.0/list_modes.js +0 -72
- package/providers/_builtin/ide/antigravity/scripts/1.0/new_session.js +0 -75
- package/providers/_builtin/ide/antigravity/scripts/1.0/read_chat.js +0 -352
- package/providers/_builtin/ide/antigravity/scripts/1.0/resolve_action.js +0 -63
- package/providers/_builtin/ide/antigravity/scripts/1.0/scripts.js +0 -67
- package/providers/_builtin/ide/antigravity/scripts/1.0/send_message.js +0 -56
- package/providers/_builtin/ide/antigravity/scripts/1.0/set_mode.js +0 -67
- package/providers/_builtin/ide/antigravity/scripts/1.0/set_model.js +0 -72
- package/providers/_builtin/ide/antigravity/scripts/1.0/switch_session.js +0 -114
- package/providers/_builtin/ide/cursor/provider.json +0 -70
- package/providers/_builtin/ide/cursor/scripts/1.0/dismiss_notification.js +0 -30
- package/providers/_builtin/ide/cursor/scripts/1.0/focus_editor.js +0 -13
- package/providers/_builtin/ide/cursor/scripts/1.0/list_models.js +0 -78
- package/providers/_builtin/ide/cursor/scripts/1.0/list_modes.js +0 -40
- package/providers/_builtin/ide/cursor/scripts/1.0/list_notifications.js +0 -23
- package/providers/_builtin/ide/cursor/scripts/1.0/list_sessions.js +0 -42
- package/providers/_builtin/ide/cursor/scripts/1.0/new_session.js +0 -20
- package/providers/_builtin/ide/cursor/scripts/1.0/open_panel.js +0 -23
- package/providers/_builtin/ide/cursor/scripts/1.0/read_chat.js +0 -318
- package/providers/_builtin/ide/cursor/scripts/1.0/resolve_action.js +0 -19
- package/providers/_builtin/ide/cursor/scripts/1.0/scripts.js +0 -78
- package/providers/_builtin/ide/cursor/scripts/1.0/send_message.js +0 -23
- package/providers/_builtin/ide/cursor/scripts/1.0/set_mode.js +0 -38
- package/providers/_builtin/ide/cursor/scripts/1.0/set_model.js +0 -81
- package/providers/_builtin/ide/cursor/scripts/1.0/switch_session.js +0 -28
- package/providers/_builtin/ide/kiro/provider.json +0 -68
- package/providers/_builtin/ide/kiro/scripts/1.0/focus_editor.js +0 -20
- package/providers/_builtin/ide/kiro/scripts/1.0/open_panel.js +0 -47
- package/providers/_builtin/ide/kiro/scripts/1.0/resolve_action.js +0 -54
- package/providers/_builtin/ide/kiro/scripts/1.0/send_message.js +0 -29
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_dump_html.js +0 -1
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_list_models.js +0 -42
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_list_modes.js +0 -22
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_list_sessions.js +0 -21
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_new_session.js +0 -34
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_read_chat.js +0 -161
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_resolve_action.js +0 -62
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_send_message.js +0 -94
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_set_mode.js +0 -34
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_set_model.js +0 -47
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_switch_session.js +0 -26
- package/providers/_builtin/ide/pearai/.tmp/after_rich.json +0 -157
- package/providers/_builtin/ide/pearai/.tmp/after_rich_raw.json +0 -161
- package/providers/_builtin/ide/pearai/.tmp/after_switch.json +0 -592
- package/providers/_builtin/ide/pearai/.tmp/after_switch_raw.json +0 -596
- package/providers/_builtin/ide/pearai/.tmp/home_dump_raw.json +0 -176
- package/providers/_builtin/ide/pearai/.tmp/items_raw.json +0 -778
- package/providers/_builtin/ide/pearai/.tmp/webview_dump.json +0 -157
- package/providers/_builtin/ide/pearai/.tmp/webview_dump_raw.json +0 -161
- package/providers/_builtin/ide/pearai/provider.json +0 -71
- package/providers/_builtin/ide/pearai/scripts/1.0/focus_editor.js +0 -16
- package/providers/_builtin/ide/pearai/scripts/1.0/list_models.js +0 -45
- package/providers/_builtin/ide/pearai/scripts/1.0/list_modes.js +0 -44
- package/providers/_builtin/ide/pearai/scripts/1.0/list_sessions.js +0 -93
- package/providers/_builtin/ide/pearai/scripts/1.0/new_session.js +0 -38
- package/providers/_builtin/ide/pearai/scripts/1.0/open_panel.js +0 -23
- package/providers/_builtin/ide/pearai/scripts/1.0/read_chat.js +0 -169
- package/providers/_builtin/ide/pearai/scripts/1.0/resolve_action.js +0 -60
- package/providers/_builtin/ide/pearai/scripts/1.0/scripts.js +0 -111
- package/providers/_builtin/ide/pearai/scripts/1.0/send_message.js +0 -104
- package/providers/_builtin/ide/pearai/scripts/1.0/set_mode.js +0 -51
- package/providers/_builtin/ide/pearai/scripts/1.0/set_model.js +0 -54
- package/providers/_builtin/ide/pearai/scripts/1.0/switch_session.js +0 -81
- package/providers/_builtin/ide/trae/provider.json +0 -72
- package/providers/_builtin/ide/trae/scripts/1.0/focus_editor.js +0 -20
- package/providers/_builtin/ide/trae/scripts/1.0/list_chats.js +0 -24
- package/providers/_builtin/ide/trae/scripts/1.0/list_models.js +0 -39
- package/providers/_builtin/ide/trae/scripts/1.0/list_modes.js +0 -39
- package/providers/_builtin/ide/trae/scripts/1.0/new_session.js +0 -30
- package/providers/_builtin/ide/trae/scripts/1.0/open_panel.js +0 -44
- package/providers/_builtin/ide/trae/scripts/1.0/read_chat.js +0 -113
- package/providers/_builtin/ide/trae/scripts/1.0/resolve_action.js +0 -54
- package/providers/_builtin/ide/trae/scripts/1.0/scripts.js +0 -82
- package/providers/_builtin/ide/trae/scripts/1.0/send_message.js +0 -69
- package/providers/_builtin/ide/trae/scripts/1.0/set_mode.js +0 -15
- package/providers/_builtin/ide/trae/scripts/1.0/set_model.js +0 -15
- package/providers/_builtin/ide/trae/scripts/1.0/switch_session.js +0 -23
- package/providers/_builtin/ide/vscode/provider.json +0 -74
- package/providers/_builtin/ide/vscode/scripts/1.0/focus_editor.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/list_models.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/list_sessions.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/new_session.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/open_panel.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/read_chat.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/resolve_action.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/scripts.js +0 -25
- package/providers/_builtin/ide/vscode/scripts/1.0/send_message.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/set_model.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/switch_session.js +0 -1
- package/providers/_builtin/ide/vscode-insiders/provider.json +0 -68
- package/providers/_builtin/ide/vscodium/provider.json +0 -69
- package/providers/_builtin/ide/windsurf/provider.json +0 -57
- package/providers/_builtin/ide/windsurf/scripts/1.0/focus_editor.js +0 -36
- package/providers/_builtin/ide/windsurf/scripts/1.0/list_chats.js +0 -23
- package/providers/_builtin/ide/windsurf/scripts/1.0/list_models.js +0 -56
- package/providers/_builtin/ide/windsurf/scripts/1.0/list_modes.js +0 -63
- package/providers/_builtin/ide/windsurf/scripts/1.0/list_sessions.js +0 -79
- package/providers/_builtin/ide/windsurf/scripts/1.0/new_session.js +0 -58
- package/providers/_builtin/ide/windsurf/scripts/1.0/open_panel.js +0 -67
- package/providers/_builtin/ide/windsurf/scripts/1.0/read_chat.js +0 -253
- package/providers/_builtin/ide/windsurf/scripts/1.0/resolve_action.js +0 -82
- package/providers/_builtin/ide/windsurf/scripts/1.0/scripts.js +0 -82
- package/providers/_builtin/ide/windsurf/scripts/1.0/send_message.js +0 -20
- package/providers/_builtin/ide/windsurf/scripts/1.0/set_mode.js +0 -43
- package/providers/_builtin/ide/windsurf/scripts/1.0/set_model.js +0 -49
- package/providers/_builtin/ide/windsurf/scripts/1.0/switch_session.js +0 -82
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/focus_editor.js +0 -30
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/list_chats.js +0 -117
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/list_models.js +0 -39
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/list_modes.js +0 -39
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/new_session.js +0 -69
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/open_panel.js +0 -58
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/read_chat.js +0 -315
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/resolve_action.js +0 -68
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/scripts.js +0 -82
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/send_message.js +0 -87
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/set_mode.js +0 -15
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/set_model.js +0 -15
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/switch_session.js +0 -58
- package/providers/_builtin/registry.json +0 -376
- package/providers/_builtin/validate.js +0 -156
|
@@ -1,522 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Codex CLI — parse_output
|
|
3
|
-
*/
|
|
4
|
-
'use strict';
|
|
5
|
-
|
|
6
|
-
const detectStatus = require('./detect_status.js');
|
|
7
|
-
const parseApproval = require('./parse_approval.js');
|
|
8
|
-
|
|
9
|
-
function splitLines(text) {
|
|
10
|
-
return String(text || '')
|
|
11
|
-
.replace(/\u0007/g, '')
|
|
12
|
-
.split(/\r\n|\n|\r/g)
|
|
13
|
-
.map(line => line.replace(/\s+$/, ''));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function normalize(line) {
|
|
17
|
-
return String(line || '')
|
|
18
|
-
.replace(/\u0007/g, '')
|
|
19
|
-
.replace(/^\d+;/, '')
|
|
20
|
-
.replace(/\s+/g, ' ')
|
|
21
|
-
.trim();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function tokenizePrompt(text) {
|
|
25
|
-
return String(text || '')
|
|
26
|
-
.replace(/\s+/g, ' ')
|
|
27
|
-
.trim()
|
|
28
|
-
.split(/[^A-Za-z0-9_.:/-]+/)
|
|
29
|
-
.map(token => token.trim().toLowerCase())
|
|
30
|
-
.filter(token => token.length >= 4);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function findPromptLineIndex(lines, promptText) {
|
|
34
|
-
const tokens = tokenizePrompt(promptText);
|
|
35
|
-
if (tokens.length === 0) return -1;
|
|
36
|
-
|
|
37
|
-
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
38
|
-
const line = normalize(lines[index]).toLowerCase();
|
|
39
|
-
if (!line) continue;
|
|
40
|
-
const matched = tokens.filter(token => line.includes(token)).length;
|
|
41
|
-
if (matched >= Math.min(tokens.length, 3)) return index;
|
|
42
|
-
}
|
|
43
|
-
return -1;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function sliceAfterLatestPrompt(text, promptText) {
|
|
47
|
-
const lines = splitLines(text);
|
|
48
|
-
const index = findPromptLineIndex(lines, promptText);
|
|
49
|
-
if (index < 0) return text;
|
|
50
|
-
return lines.slice(index + 1).join('\n');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function isBoxLine(line) {
|
|
54
|
-
return /^[─═╭╮╰╯│┌┐└┘├┤┬┴┼]+$/.test(line);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function isHeaderLine(line) {
|
|
58
|
-
return /^OpenAI Codex\b/i.test(line)
|
|
59
|
-
|| /^>_ OpenAI Codex\b/i.test(line)
|
|
60
|
-
|| /(?:^|[│\s])model:\s+/i.test(line)
|
|
61
|
-
|| /(?:^|[│\s])directory:\s+/i.test(line);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function isFooterLine(line) {
|
|
65
|
-
return /⏎\s+send/i.test(line)
|
|
66
|
-
|| /⌃J\s+newline/i.test(line)
|
|
67
|
-
|| /⌃T\s+transcript/i.test(line)
|
|
68
|
-
|| /⌃C\s+quit/i.test(line)
|
|
69
|
-
|| /\b\d+(?:\.\d+)?[KM]?\s+tokens used\b/i.test(line)
|
|
70
|
-
|| /\b\d+% context left\b/i.test(line);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function isWelcomeLine(line) {
|
|
74
|
-
return /To get started, describe a task/i.test(line)
|
|
75
|
-
|| /^\/(?:init|status|approvals|model)\b/.test(line)
|
|
76
|
-
|| /create an AGENTS\.md file/i.test(line)
|
|
77
|
-
|| /show current session configuration/i.test(line)
|
|
78
|
-
|| /choose what Codex can do without approval/i.test(line)
|
|
79
|
-
|| /choose what model and reasoning effort to use/i.test(line)
|
|
80
|
-
|| /Update available!/i.test(line)
|
|
81
|
-
|| /npm install -g @openai\/codex@latest/i.test(line);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function isStatusLine(line) {
|
|
85
|
-
return /Esc to interrupt/i.test(line)
|
|
86
|
-
|| /(?:Thinking|Planning|Searching|Reading|Working|Analyzing|Inspecting|Responding|Following instructions clearly)[^\n]*\(\d+s\b/i.test(line)
|
|
87
|
-
|| /^[⠁-⣿]+$/.test(line);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function isApprovalLine(line) {
|
|
91
|
-
return /You are running Codex in/i.test(line)
|
|
92
|
-
|| /Allow Codex to (?:run|apply)/i.test(line)
|
|
93
|
-
|| /Press Enter to continue/i.test(line)
|
|
94
|
-
|| /^(?:[>▌]\s*)?\d+\.\s+/.test(line);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function isInputLine(line) {
|
|
98
|
-
return /^▌\s*/.test(line) || /^>\s*$/.test(line);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function isPlaceholderLine(line) {
|
|
102
|
-
return /^(?:Write tests for @filename|Explain this codebase|Summarize recent commits|Implement \{feature\})$/i.test(line);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function isAssistantLeadLine(line) {
|
|
106
|
-
return /^>\s+/.test(line) || /^•\s+/.test(line);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function stripAssistantLead(line) {
|
|
110
|
-
return String(line || '').replace(/^(?:>\s+|•\s+)/, '').trim();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function isTranscriptNoise(line) {
|
|
114
|
-
return !line
|
|
115
|
-
|| isBoxLine(line)
|
|
116
|
-
|| isHeaderLine(line)
|
|
117
|
-
|| isFooterLine(line)
|
|
118
|
-
|| isWelcomeLine(line)
|
|
119
|
-
|| isStatusLine(line)
|
|
120
|
-
|| isApprovalLine(line)
|
|
121
|
-
|| isInputLine(line)
|
|
122
|
-
|| /^…\s+\+\d+\s+lines\b/i.test(line)
|
|
123
|
-
|| isPlaceholderLine(line);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function cleanContentLine(rawLine) {
|
|
127
|
-
const normalized = normalize(rawLine);
|
|
128
|
-
if (!normalized || isTranscriptNoise(normalized)) return '';
|
|
129
|
-
let cleaned = normalized
|
|
130
|
-
.replace(/^✔\s+/, '')
|
|
131
|
-
.replace(/^\s*│\s*/, '')
|
|
132
|
-
.replace(/▌.*$/g, '')
|
|
133
|
-
.replace(/⏎\s+send.*$/i, '')
|
|
134
|
-
.replace(/\b\d+(?:\.\d+)?[KM]?\s+tokens used\b.*$/i, '')
|
|
135
|
-
.replace(/\b\d+% context left\b.*$/i, '')
|
|
136
|
-
.replace(/\b(?:Working|Thinking|Planning|Searching|Reading|Analyzing|Inspecting|Responding)[^.!?]*$/i, '')
|
|
137
|
-
.replace(/Write tests for @filename.*$/i, '')
|
|
138
|
-
.replace(/([.!?])(?:[A-Za-z0-9]{3,}){3,}$/g, '$1')
|
|
139
|
-
.trim();
|
|
140
|
-
if (/^[{\[]/.test(cleaned)) {
|
|
141
|
-
cleaned = cleaned.replace(/([}\]])[A-Za-z0-9]+$/, '$1');
|
|
142
|
-
}
|
|
143
|
-
return cleaned;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function cleanAssistantLeadContent(line) {
|
|
147
|
-
return cleanContentLine(line)
|
|
148
|
-
.replace(/^>\s+/, '')
|
|
149
|
-
.replace(/^•\s+/, '')
|
|
150
|
-
.trim();
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function isWelcomeScreen(text) {
|
|
154
|
-
return /OpenAI Codex/i.test(text)
|
|
155
|
-
&& /To get started, describe a task/i.test(text);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function collectAssistantLines(lines) {
|
|
159
|
-
const blocks = [];
|
|
160
|
-
let current = null;
|
|
161
|
-
let collecting = false;
|
|
162
|
-
|
|
163
|
-
for (const rawLine of lines) {
|
|
164
|
-
const line = normalize(rawLine);
|
|
165
|
-
|
|
166
|
-
if (!line) {
|
|
167
|
-
if (collecting && current && current.lines.length > 0 && current.lines[current.lines.length - 1] !== '') {
|
|
168
|
-
current.lines.push('');
|
|
169
|
-
}
|
|
170
|
-
continue;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (isInputLine(line)) {
|
|
174
|
-
collecting = false;
|
|
175
|
-
current = null;
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (isAssistantLeadLine(line)) {
|
|
180
|
-
const stripped = cleanAssistantLeadContent(stripAssistantLead(line));
|
|
181
|
-
collecting = true;
|
|
182
|
-
current = {
|
|
183
|
-
kind: /^>\s+/.test(line) ? 'assistant' : 'tool',
|
|
184
|
-
lines: [],
|
|
185
|
-
};
|
|
186
|
-
blocks.push(current);
|
|
187
|
-
if (stripped) current.lines.push(stripped);
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (!collecting) continue;
|
|
192
|
-
|
|
193
|
-
const cleaned = cleanContentLine(rawLine);
|
|
194
|
-
if (!cleaned) continue;
|
|
195
|
-
if (current && current.lines[current.lines.length - 1] !== cleaned) current.lines.push(cleaned);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const preferred = [...blocks].reverse().find(block => block.kind === 'assistant' && block.lines.some(Boolean))
|
|
199
|
-
|| [...blocks].reverse().find(block => block.lines.some(Boolean));
|
|
200
|
-
const result = preferred ? preferred.lines.slice() : [];
|
|
201
|
-
while (result[0] === '') result.shift();
|
|
202
|
-
while (result[result.length - 1] === '') result.pop();
|
|
203
|
-
|
|
204
|
-
return result;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function cleanFallbackLines(lines) {
|
|
208
|
-
const result = [];
|
|
209
|
-
for (const rawLine of lines) {
|
|
210
|
-
const line = normalize(rawLine);
|
|
211
|
-
if (!isAssistantLeadLine(line)) continue;
|
|
212
|
-
const stripped = stripAssistantLead(line);
|
|
213
|
-
if (stripped && result[result.length - 1] !== stripped) result.push(stripped);
|
|
214
|
-
}
|
|
215
|
-
return result;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function extractAssistantText(text) {
|
|
219
|
-
return collectAssistantLines(splitLines(text)).join('\n').trim();
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
function extractTrailingLeadAnswer(text) {
|
|
223
|
-
const lines = splitLines(text);
|
|
224
|
-
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
225
|
-
const line = normalize(lines[index]);
|
|
226
|
-
if (!isAssistantLeadLine(line)) continue;
|
|
227
|
-
const cleaned = cleanAssistantLeadContent(stripAssistantLead(line));
|
|
228
|
-
if (!cleaned || shouldSuppressAssistantText(cleaned)) continue;
|
|
229
|
-
return cleaned;
|
|
230
|
-
}
|
|
231
|
-
return '';
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function extractFallbackText(text) {
|
|
235
|
-
return cleanFallbackLines(splitLines(text)).join('\n').trim();
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function chooseRicherText(primary, secondary) {
|
|
239
|
-
const a = String(primary || '').trim();
|
|
240
|
-
const b = String(secondary || '').trim();
|
|
241
|
-
if (!a) return b;
|
|
242
|
-
if (!b) return a;
|
|
243
|
-
const aLines = a.split('\n').length;
|
|
244
|
-
const bLines = b.split('\n').length;
|
|
245
|
-
if (aLines > bLines + 1 || a.length > b.length + 60) return a;
|
|
246
|
-
if (bLines > aLines + 1 || b.length > a.length + 60) return b;
|
|
247
|
-
return a.length >= b.length ? a : b;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function extractVisibleContent(text) {
|
|
251
|
-
const blocks = [];
|
|
252
|
-
let current = [];
|
|
253
|
-
for (const rawLine of splitLines(text)) {
|
|
254
|
-
const cleaned = cleanContentLine(rawLine);
|
|
255
|
-
if (!cleaned) {
|
|
256
|
-
if (current.length > 0) {
|
|
257
|
-
blocks.push(current);
|
|
258
|
-
current = [];
|
|
259
|
-
}
|
|
260
|
-
continue;
|
|
261
|
-
}
|
|
262
|
-
current.push(cleaned);
|
|
263
|
-
}
|
|
264
|
-
if (current.length > 0) blocks.push(current);
|
|
265
|
-
const chosen = [...blocks].reverse().find(block => block.length > 1) || blocks[blocks.length - 1] || [];
|
|
266
|
-
return chosen.join('\n').trim();
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function mergeLineContent(existing, incoming) {
|
|
270
|
-
const left = String(existing || '').trim();
|
|
271
|
-
const right = String(incoming || '').trim();
|
|
272
|
-
if (!left) return right;
|
|
273
|
-
if (!right) return left;
|
|
274
|
-
if (left === right) return right;
|
|
275
|
-
|
|
276
|
-
const leftLines = left.split('\n');
|
|
277
|
-
const rightLines = right.split('\n');
|
|
278
|
-
const leftNorm = leftLines.map(line => normalize(line));
|
|
279
|
-
const rightNorm = rightLines.map(line => normalize(line));
|
|
280
|
-
const maxOverlap = Math.min(leftLines.length, rightLines.length);
|
|
281
|
-
|
|
282
|
-
for (let overlap = maxOverlap; overlap >= 1; overlap--) {
|
|
283
|
-
const leftTail = leftNorm.slice(leftNorm.length - overlap);
|
|
284
|
-
const rightHead = rightNorm.slice(0, overlap);
|
|
285
|
-
if (leftTail.every((line, index) => line === rightHead[index])) {
|
|
286
|
-
return [...leftLines.slice(0, leftLines.length - overlap), ...rightLines].join('\n').trim();
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (left.includes(right)) return left;
|
|
291
|
-
if (right.includes(left)) return right;
|
|
292
|
-
return chooseRicherText(left, right);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
function finalizeAssistantText(text) {
|
|
296
|
-
const value = String(text || '').trim();
|
|
297
|
-
if (!value) return '';
|
|
298
|
-
const lines = value.split('\n');
|
|
299
|
-
if (/^>\s*[{[]/.test(lines[0] || '')) {
|
|
300
|
-
lines[0] = lines[0].replace(/^>\s*/, '');
|
|
301
|
-
}
|
|
302
|
-
return lines.join('\n').trim();
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function looksLikeStructuredAnswer(text) {
|
|
306
|
-
const value = String(text || '').trim();
|
|
307
|
-
if (!value) return false;
|
|
308
|
-
const firstLine = value.split('\n')[0] || '';
|
|
309
|
-
return /^TITLE=/.test(firstLine)
|
|
310
|
-
|| /^NEWS=/.test(firstLine)
|
|
311
|
-
|| /^[A-Z][A-Z0-9_]*=/.test(firstLine)
|
|
312
|
-
|| /^[{\[]/.test(firstLine);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function isStructuredAnswerLine(line) {
|
|
316
|
-
const value = String(line || '').trim();
|
|
317
|
-
return /^TITLE=/.test(value)
|
|
318
|
-
|| /^NEWS=/.test(value)
|
|
319
|
-
|| /^[A-Z][A-Z0-9_]*=/.test(value)
|
|
320
|
-
|| /^[{\[]/.test(value);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function extractStructuredAnswer(text) {
|
|
324
|
-
const lines = splitLines(text)
|
|
325
|
-
.map(cleanContentLine)
|
|
326
|
-
.filter(Boolean);
|
|
327
|
-
if (lines.length === 0) return '';
|
|
328
|
-
|
|
329
|
-
const trailing = [];
|
|
330
|
-
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
331
|
-
const line = lines[i];
|
|
332
|
-
if (isStructuredAnswerLine(line)) {
|
|
333
|
-
trailing.unshift(line);
|
|
334
|
-
continue;
|
|
335
|
-
}
|
|
336
|
-
if (trailing.length > 0) break;
|
|
337
|
-
}
|
|
338
|
-
if (trailing.length >= 2) return trailing.join('\n').trim();
|
|
339
|
-
|
|
340
|
-
const blocks = [];
|
|
341
|
-
let current = [];
|
|
342
|
-
for (const line of lines) {
|
|
343
|
-
if (isStructuredAnswerLine(line)) {
|
|
344
|
-
current.push(line);
|
|
345
|
-
} else if (current.length > 0) {
|
|
346
|
-
blocks.push(current);
|
|
347
|
-
current = [];
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
if (current.length > 0) blocks.push(current);
|
|
351
|
-
const chosen = [...blocks].reverse().find(block => block.length >= 2) || [];
|
|
352
|
-
return chosen.join('\n').trim();
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
function looksLikeCorruptToolText(text) {
|
|
356
|
-
const value = String(text || '');
|
|
357
|
-
if (!value) return false;
|
|
358
|
-
return /Ran zsh -lc/i.test(value)
|
|
359
|
-
|| /• Added /i.test(value)
|
|
360
|
-
|| /… \+\d+ lines/.test(value)
|
|
361
|
-
|| /└ /.test(value)
|
|
362
|
-
|| /�/.test(value);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
function shouldSuppressAssistantText(text) {
|
|
366
|
-
const value = String(text || '').trim();
|
|
367
|
-
if (!value) return true;
|
|
368
|
-
return /^>_ OpenAI Codex\b/.test(value)
|
|
369
|
-
|| /^OpenAI Codex\b/.test(value)
|
|
370
|
-
|| looksLikeCorruptToolText(value) && !looksLikeStructuredAnswer(value);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
function shouldDropPartialText(text) {
|
|
374
|
-
const value = String(text || '').trim();
|
|
375
|
-
if (!value) return true;
|
|
376
|
-
return /^>_ OpenAI Codex\b/.test(value)
|
|
377
|
-
|| /^OpenAI Codex\b/.test(value)
|
|
378
|
-
|| /^[│\s]+$/.test(value)
|
|
379
|
-
|| /(?:Working|Planning|Searching|Reading|Analyzing|Considering)/i.test(value) && !/\n/.test(value);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
function shouldKeepPartialText(text) {
|
|
383
|
-
const value = String(text || '').trim();
|
|
384
|
-
if (!value || shouldDropPartialText(value) || looksLikeCorruptToolText(value)) return false;
|
|
385
|
-
return looksLikeStructuredAnswer(value) || value.split('\n').length >= 3;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
function containsUiNoise(text) {
|
|
389
|
-
return /⏎\s+send|⌃J\s+newline|⌃T\s+transcript|⌃C\s+quit|\b\d+(?:\.\d+)?[KM]?\s+tokens used\b|\b\d+% context left\b|Working\(\d+s/i.test(String(text || ''));
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
function extractInlineLeadAnswer(text) {
|
|
393
|
-
const lines = splitLines(text);
|
|
394
|
-
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
395
|
-
const rawLine = lines[index];
|
|
396
|
-
const match = rawLine.match(/>\s+(.+)$/);
|
|
397
|
-
if (!match) continue;
|
|
398
|
-
const cleaned = cleanAssistantLeadContent(`> ${match[1]}`);
|
|
399
|
-
if (cleaned && !shouldSuppressAssistantText(cleaned)) return cleaned;
|
|
400
|
-
}
|
|
401
|
-
return '';
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
function buildMessages(previousMessages, assistantText, partialText) {
|
|
405
|
-
const base = Array.isArray(previousMessages)
|
|
406
|
-
? previousMessages
|
|
407
|
-
.filter(message => message && (message.role === 'user' || message.role === 'assistant'))
|
|
408
|
-
.map(message => ({
|
|
409
|
-
role: message.role,
|
|
410
|
-
content: typeof message.content === 'string' ? message.content : String(message.content || ''),
|
|
411
|
-
timestamp: message.timestamp,
|
|
412
|
-
}))
|
|
413
|
-
: [];
|
|
414
|
-
|
|
415
|
-
const lastUser = [...base].reverse().find(message => message.role === 'user')?.content || '';
|
|
416
|
-
const rawCandidate = finalizeAssistantText(assistantText || partialText);
|
|
417
|
-
const inlineLead = extractInlineLeadAnswer(rawCandidate);
|
|
418
|
-
const promptEcho = tokenizePrompt(lastUser)
|
|
419
|
-
.slice(0, 6)
|
|
420
|
-
.filter(token => normalize(rawCandidate).toLowerCase().includes(token))
|
|
421
|
-
.length >= 2;
|
|
422
|
-
const candidate = (inlineLead && (containsUiNoise(rawCandidate) || promptEcho))
|
|
423
|
-
? inlineLead
|
|
424
|
-
: rawCandidate;
|
|
425
|
-
if (!candidate || shouldSuppressAssistantText(candidate)) return base;
|
|
426
|
-
|
|
427
|
-
const last = base[base.length - 1];
|
|
428
|
-
if (last && last.role === 'assistant') {
|
|
429
|
-
if (looksLikeStructuredAnswer(candidate) && !looksLikeStructuredAnswer(last.content)) {
|
|
430
|
-
last.content = candidate;
|
|
431
|
-
} else {
|
|
432
|
-
const merged = mergeLineContent(last.content, candidate);
|
|
433
|
-
if (last.content !== merged) last.content = merged;
|
|
434
|
-
}
|
|
435
|
-
} else {
|
|
436
|
-
base.push({ role: 'assistant', content: candidate });
|
|
437
|
-
}
|
|
438
|
-
return base;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
function toMessageObjects(messages, status) {
|
|
442
|
-
return messages.slice(-50).map((message, index, slice) => ({
|
|
443
|
-
id: `msg_${index}`,
|
|
444
|
-
role: message.role,
|
|
445
|
-
content: typeof message.content === 'string' && message.content.length > 6000
|
|
446
|
-
? `${message.content.slice(0, 6000)}\n[... truncated]`
|
|
447
|
-
: message.content,
|
|
448
|
-
index,
|
|
449
|
-
kind: 'standard',
|
|
450
|
-
...(status === 'generating' && index === slice.length - 1 && message.role === 'assistant'
|
|
451
|
-
? { meta: { streaming: true } }
|
|
452
|
-
: {}),
|
|
453
|
-
}));
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
module.exports = function parseOutput(input) {
|
|
457
|
-
const screenText = String(input?.screenText || '');
|
|
458
|
-
const buffer = String(input?.buffer || '');
|
|
459
|
-
const transcript = screenText || buffer;
|
|
460
|
-
const tail = String(input?.recentBuffer || transcript.slice(-500));
|
|
461
|
-
const previousMessages = Array.isArray(input?.messages) ? input.messages : [];
|
|
462
|
-
const lastUserMessage = [...previousMessages].reverse().find(message => message && message.role === 'user');
|
|
463
|
-
const promptScope = lastUserMessage?.content || '';
|
|
464
|
-
const scopedScreenText = sliceAfterLatestPrompt(screenText, promptScope);
|
|
465
|
-
const scopedBufferText = sliceAfterLatestPrompt(buffer, promptScope);
|
|
466
|
-
|
|
467
|
-
const status = detectStatus({
|
|
468
|
-
tail,
|
|
469
|
-
screenText,
|
|
470
|
-
rawBuffer: input?.rawBuffer || '',
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
const activeModal = status === 'waiting_approval'
|
|
474
|
-
? parseApproval({ buffer: transcript, rawBuffer: input?.rawBuffer || '', tail })
|
|
475
|
-
: null;
|
|
476
|
-
|
|
477
|
-
if (status === 'waiting_approval' || (status === 'idle' && isWelcomeScreen(transcript))) {
|
|
478
|
-
return {
|
|
479
|
-
id: 'cli_session',
|
|
480
|
-
status,
|
|
481
|
-
title: 'Codex CLI',
|
|
482
|
-
messages: toMessageObjects(previousMessages, status),
|
|
483
|
-
activeModal,
|
|
484
|
-
};
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
const bufferAssistantText = finalizeAssistantText(extractAssistantText(scopedBufferText || buffer));
|
|
488
|
-
const screenAssistantText = finalizeAssistantText(extractAssistantText(scopedScreenText || screenText));
|
|
489
|
-
const trailingLeadText = finalizeAssistantText(
|
|
490
|
-
extractTrailingLeadAnswer(scopedScreenText || screenText) || extractTrailingLeadAnswer(scopedBufferText || buffer),
|
|
491
|
-
);
|
|
492
|
-
const visibleContentText = finalizeAssistantText(extractVisibleContent(scopedScreenText || screenText));
|
|
493
|
-
const structuredAnswerText = finalizeAssistantText(
|
|
494
|
-
extractStructuredAnswer(scopedScreenText || screenText) || extractStructuredAnswer(scopedBufferText || buffer),
|
|
495
|
-
);
|
|
496
|
-
const assistantText = structuredAnswerText
|
|
497
|
-
|| trailingLeadText
|
|
498
|
-
|| looksLikeStructuredAnswer(screenAssistantText) || looksLikeCorruptToolText(bufferAssistantText)
|
|
499
|
-
? structuredAnswerText || trailingLeadText || screenAssistantText || visibleContentText || bufferAssistantText
|
|
500
|
-
: finalizeAssistantText(mergeLineContent(
|
|
501
|
-
mergeLineContent(
|
|
502
|
-
chooseRicherText(bufferAssistantText, screenAssistantText),
|
|
503
|
-
visibleContentText,
|
|
504
|
-
),
|
|
505
|
-
screenAssistantText,
|
|
506
|
-
));
|
|
507
|
-
const partialText = status === 'generating'
|
|
508
|
-
? finalizeAssistantText(chooseRicherText(
|
|
509
|
-
extractFallbackText(buffer),
|
|
510
|
-
extractFallbackText(String(input?.partialResponse || '')),
|
|
511
|
-
))
|
|
512
|
-
: '';
|
|
513
|
-
const messages = buildMessages(previousMessages, assistantText, shouldKeepPartialText(partialText) ? partialText : '');
|
|
514
|
-
|
|
515
|
-
return {
|
|
516
|
-
id: 'cli_session',
|
|
517
|
-
status,
|
|
518
|
-
title: 'Codex CLI',
|
|
519
|
-
messages: toMessageObjects(messages, status),
|
|
520
|
-
activeModal,
|
|
521
|
-
};
|
|
522
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Codex CLI Scripts — v1.0
|
|
3
|
-
*/
|
|
4
|
-
'use strict';
|
|
5
|
-
const path = require('path');
|
|
6
|
-
const DIR = __dirname;
|
|
7
|
-
function loadModule(name) { try { return require(path.join(DIR, name)); } catch { return null; } }
|
|
8
|
-
|
|
9
|
-
module.exports.parseOutput = (input) => { const m = loadModule('parse_output.js'); return m ? m(input) : null; };
|
|
10
|
-
module.exports.detectStatus = (input) => { const m = loadModule('detect_status.js'); return m ? m(input) : null; };
|
|
11
|
-
module.exports.parseApproval = (input) => { const m = loadModule('parse_approval.js'); return m ? m(input) : null; };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"type": "cursor-cli",
|
|
3
|
-
"name": "Cursor CLI",
|
|
4
|
-
"category": "cli",
|
|
5
|
-
"aliases": [
|
|
6
|
-
"cursor"
|
|
7
|
-
],
|
|
8
|
-
"icon": "🤖",
|
|
9
|
-
"displayName": "Cursor CLI",
|
|
10
|
-
"settings": {
|
|
11
|
-
"mode": {
|
|
12
|
-
"type": "select",
|
|
13
|
-
"default": "chat",
|
|
14
|
-
"public": true,
|
|
15
|
-
"label": "Display Mode",
|
|
16
|
-
"description": "terminal: Native PTY view, chat: Parsed message view",
|
|
17
|
-
"options": [
|
|
18
|
-
"terminal",
|
|
19
|
-
"chat"
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"binary": "agent",
|
|
24
|
-
"spawn": {
|
|
25
|
-
"command": "agent",
|
|
26
|
-
"args": [],
|
|
27
|
-
"shell": true,
|
|
28
|
-
"env": {}
|
|
29
|
-
},
|
|
30
|
-
"compatibility": [
|
|
31
|
-
{
|
|
32
|
-
"ideVersion": ">=2026.0.0",
|
|
33
|
-
"scriptDir": "scripts/1.0"
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
"defaultScriptDir": "scripts/1.0"
|
|
37
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cursor CLI — detect_status
|
|
3
|
-
* Cursor's terminal agent uses similar TUI patterns to Claude.
|
|
4
|
-
*/
|
|
5
|
-
'use strict';
|
|
6
|
-
module.exports = function detectStatus(input) {
|
|
7
|
-
const { tail } = input;
|
|
8
|
-
if (!tail) return 'idle';
|
|
9
|
-
// waiting_approval
|
|
10
|
-
if (/Allow\s*once/i.test(tail) || /Always\s*allow/i.test(tail)) return 'waiting_approval';
|
|
11
|
-
if (/\(y\/n\)/i.test(tail) || /\[Y\/n\]/i.test(tail)) return 'waiting_approval';
|
|
12
|
-
if (/approve|confirm/i.test(tail) && /deny|cancel/i.test(tail)) return 'waiting_approval';
|
|
13
|
-
// generating
|
|
14
|
-
if (/[\u2800-\u28ff]/.test(tail)) return 'generating';
|
|
15
|
-
if (/[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]/.test(tail)) return 'generating';
|
|
16
|
-
if (/thinking|processing|generating/i.test(tail)) return 'generating';
|
|
17
|
-
if (/esc to (cancel|interrupt|stop)/i.test(tail)) return 'generating';
|
|
18
|
-
return 'idle';
|
|
19
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
module.exports = function parseApproval(input) {
|
|
3
|
-
const { tail } = input;
|
|
4
|
-
if (!tail) return null;
|
|
5
|
-
const hasApproval = /Allow\s*once/i.test(tail) || /Always\s*allow/i.test(tail) ||
|
|
6
|
-
/\(y\/n\)/i.test(tail) || (/approve/i.test(tail) && /deny/i.test(tail));
|
|
7
|
-
if (!hasApproval) return null;
|
|
8
|
-
const lines = tail.split('\n').map(l => l.trim()).filter(l => l && !/^[─═╭╮╰╯│]+$/.test(l));
|
|
9
|
-
return { message: lines.slice(-5).join(' ').slice(0, 200) || 'Approval required', buttons: ['Allow', 'Always allow', 'Deny'] };
|
|
10
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const detectStatus = require('./detect_status.js');
|
|
3
|
-
const parseApproval = require('./parse_approval.js');
|
|
4
|
-
|
|
5
|
-
function splitTurns(buffer) {
|
|
6
|
-
const messages = [];
|
|
7
|
-
if (!buffer || buffer.length < 5) return messages;
|
|
8
|
-
const lines = buffer.split('\n');
|
|
9
|
-
let currentRole = null, currentContent = [], msgIndex = 0, started = false;
|
|
10
|
-
for (const line of lines) {
|
|
11
|
-
const trimmed = line.trim();
|
|
12
|
-
const userMatch = trimmed.match(/^[❯›>$]\s+(.+)$/);
|
|
13
|
-
if (userMatch && userMatch[1].length > 1) {
|
|
14
|
-
started = true;
|
|
15
|
-
if (currentRole && currentContent.length > 0) {
|
|
16
|
-
const text = currentContent.join('\n').trim();
|
|
17
|
-
if (text.length > 1) { messages.push({ id: `msg_${msgIndex}`, role: currentRole, content: text.slice(0, 6000), index: msgIndex, kind: 'standard' }); msgIndex++; }
|
|
18
|
-
}
|
|
19
|
-
currentRole = 'user'; currentContent = [userMatch[1]]; continue;
|
|
20
|
-
}
|
|
21
|
-
if (!started) continue;
|
|
22
|
-
if (currentRole === 'user' && trimmed && !userMatch) {
|
|
23
|
-
const text = currentContent.join('\n').trim();
|
|
24
|
-
if (text.length > 1) { messages.push({ id: `msg_${msgIndex}`, role: 'user', content: text, index: msgIndex, kind: 'standard' }); msgIndex++; }
|
|
25
|
-
currentRole = 'assistant'; currentContent = [];
|
|
26
|
-
}
|
|
27
|
-
if (!trimmed || /^[─═╭╮╰╯│]+$/.test(trimmed) || /^[\u2800-\u28ff]+$/.test(trimmed)) continue;
|
|
28
|
-
if (currentRole) currentContent.push(trimmed);
|
|
29
|
-
}
|
|
30
|
-
if (currentRole && currentContent.length > 0) {
|
|
31
|
-
const text = currentContent.join('\n').trim();
|
|
32
|
-
if (text.length > 1) messages.push({ id: `msg_${msgIndex}`, role: currentRole, content: text.slice(0, 6000), index: msgIndex, kind: 'standard' });
|
|
33
|
-
}
|
|
34
|
-
return messages.length > 50 ? messages.slice(-50) : messages;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
module.exports = function parseOutput(input) {
|
|
38
|
-
const { buffer, recentBuffer, partialResponse, screenText } = input;
|
|
39
|
-
const transcript = buffer || screenText;
|
|
40
|
-
const tail = recentBuffer || (transcript || '').slice(-500);
|
|
41
|
-
const status = detectStatus({ tail });
|
|
42
|
-
const activeModal = status === 'waiting_approval' ? parseApproval({ buffer: transcript, tail }) : null;
|
|
43
|
-
const messages = splitTurns(transcript);
|
|
44
|
-
if (status === 'generating' && partialResponse && partialResponse.trim().length > 2) {
|
|
45
|
-
messages.push({ id: 'msg_partial', role: 'assistant', content: partialResponse.trim().slice(0, 6000), index: messages.length, kind: 'standard', meta: { streaming: true } });
|
|
46
|
-
}
|
|
47
|
-
return { id: 'cli_session', status, title: 'Cursor CLI', messages, activeModal };
|
|
48
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const DIR = __dirname;
|
|
4
|
-
function loadModule(name) { try { return require(path.join(DIR, name)); } catch { return null; } }
|
|
5
|
-
module.exports.parseOutput = (input) => { const m = loadModule('parse_output.js'); return m ? m(input) : null; };
|
|
6
|
-
module.exports.detectStatus = (input) => { const m = loadModule('detect_status.js'); return m ? m(input) : null; };
|
|
7
|
-
module.exports.parseApproval = (input) => { const m = loadModule('parse_approval.js'); return m ? m(input) : null; };
|