apex-dev 3.0.2 → 3.1.0
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/highlights-eq9cgrbb.scm +604 -0
- package/dist/highlights-ghv9g403.scm +205 -0
- package/dist/highlights-hk7bwhj4.scm +284 -0
- package/dist/highlights-r812a2qc.scm +150 -0
- package/dist/highlights-x6tmsnaa.scm +115 -0
- package/dist/index.js +62590 -0
- package/dist/injections-73j83es3.scm +27 -0
- package/dist/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
- package/dist/tree-sitter-markdown-411r6y9b.wasm +0 -0
- package/dist/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
- package/dist/tree-sitter-typescript-zxjzwt75.wasm +0 -0
- package/dist/tree-sitter-zig-e78zbjpm.wasm +0 -0
- package/package.json +10 -4
- package/.config/amp/settings.json +0 -3
- package/.config/opencode/oh-my-opencode.json +0 -58
- package/.config/opencode/opencode.json +0 -6
- package/.local/share/amp/device-id.json +0 -3
- package/.local/share/amp/history.jsonl +0 -78
- package/.local/share/amp/session.json +0 -6
- package/.local/share/amp/threads/T-019c93b8-fce7-7083-aab9-d5f1c88a9545.json +0 -2528
- package/.local/share/amp/threads/T-019c93c8-4b7a-71df-94ac-867d8236a288.json +0 -7
- package/.local/share/amp/threads/T-019c93cd-5a7d-728e-8289-02e0ef4ca2ff.json +0 -680
- package/.local/share/amp/threads/T-019c93e7-83ca-7633-9eed-12bdcc118163.json +0 -873
- package/.local/share/amp/threads/T-019c93ea-ccd3-765a-88c9-42d7b631e977.json +0 -620
- package/.local/share/amp/threads/T-019c93ee-5977-71af-9ab7-c4611004b703.json +0 -1000
- package/.local/share/amp/threads/T-019c93f0-8328-71ed-a250-6da169cebfe1.json +0 -829
- package/.local/share/amp/threads/T-019c93f5-7bdd-703b-b2cd-0a04da64441a.json +0 -459
- package/.local/share/amp/threads/T-019c93f8-2b2e-733b-8249-9876546d9b5b.json +0 -764
- package/.local/share/amp/threads/T-019c93fd-fade-7195-a3b7-358f180d40b8.json +0 -7
- package/.local/share/amp/threads/T-019c93fe-2e56-705e-827e-eb99bd02e257.json +0 -3593
- package/.local/share/amp/threads/T-019c9408-6e64-77e1-9519-b913e3b24a03.json +0 -1559
- package/.local/share/amp/threads/T-019c9409-feeb-736d-b92c-4f7a263a643c.json +0 -7
- package/.local/share/amp/threads/T-019c940b-8d11-755b-b9e1-f923d8a5e6ba.json +0 -7
- package/.local/share/amp/threads/T-019c943a-6c5e-76a5-bf4e-170f7ad452ce.json +0 -979
- package/.local/share/amp/threads/T-019c94b2-1c8f-76d8-96d0-82449a028849.json +0 -1584
- package/.local/share/amp/threads/T-019c94b6-68f0-726e-92dd-90c5411ca28c.json +0 -7
- package/.local/share/amp/threads/T-019c94bf-a589-72a3-b3c2-a81359d9e0a6.json +0 -7
- package/.local/share/amp/threads/T-019c94e1-1bd9-70ab-b6f2-abd5cab4f4ce.json +0 -1035
- package/.local/share/amp/threads/T-019c94fd-cc4a-714b-896a-74f94020f6eb.json +0 -1310
- package/.local/share/amp/threads/T-019c9501-8976-7138-aca6-245a01a8fe9b.json +0 -7
- package/.local/share/amp/threads/T-019c9504-4b51-763e-8a9f-5d4cdfcf0cfa.json +0 -496
- package/.local/share/amp/threads/T-019c9506-4e3b-74fd-8eda-cedbf3793598.json +0 -2679
- package/.local/share/amp/threads/T-019c9508-178c-718c-88d2-caf816d64f65.json +0 -965
- package/.local/share/amp/threads/T-019c9509-2812-71fd-8fd2-923e29ad34fa.json +0 -7
- package/.local/share/amp/threads/T-019c950e-69fe-77d6-9854-fc73b77a3148.json +0 -4570
- package/.local/share/amp/threads/T-019c9707-6e2b-741c-b4d4-117026a78449.json +0 -2899
- package/.local/share/amp/threads/T-019c971b-6bc0-77b8-8868-f8956d3e71a8.json +0 -7
- package/.local/share/amp/threads/T-019c971b-c87c-75f3-a61f-beb18a1cb25f.json +0 -474
- package/.local/share/amp/threads/T-019c971d-d371-70ac-9805-5c739908e73b.json +0 -802
- package/.local/share/amp/threads/T-019c9722-d73d-74f1-9d1d-8fafaad0ede7.json +0 -7
- package/.local/share/amp/threads/T-019c9761-858c-719b-911f-bc2e4c8cbdde.json +0 -188
- package/.local/share/amp/threads/T-019c9761-f5f3-7606-a900-ebe7f10d6e37.json +0 -121
- package/.local/share/amp/threads/T-019c9763-b1ae-729d-90aa-f59938ce912e.json +0 -799
- package/.local/share/amp/threads/T-019c9769-4a8a-77b8-beab-f48973276f9a.json +0 -1541
- package/.local/share/amp/threads/T-019c9772-edac-7075-b26e-0ada1f8697d2.json +0 -7
- package/.local/share/amp/threads/T-019c97e8-a9ab-71a1-a8f9-109c540c98bf.json +0 -111
- package/.local/share/amp/threads/T-019c97e9-2277-753c-8c5d-df745fa6cfff.json +0 -7
- package/.local/share/amp/threads/T-019c97e9-f28e-758d-9663-e37047a8ed95.json +0 -111
- package/.local/share/amp/threads/T-019c97ea-17c7-77b8-92b2-f641c069bcc9.json +0 -71
- package/.local/share/amp/threads/T-019c97ea-44c6-75b8-88bc-d88113194f6a.json +0 -1611
- package/.local/share/amp/threads/T-019c97ec-abae-7251-a5f6-693adf496a1c.json +0 -7
- package/.local/share/amp/threads/T-019c97f5-8e61-73ad-8c5d-2637abedcde6.json +0 -1341
- package/.local/share/amp/threads/T-019c989d-4f4e-7249-bde0-21d19455ccae.json +0 -163
- package/.local/share/amp/threads/T-019c989d-9024-73c4-bee8-e2ae45028a39.json +0 -124
- package/.local/share/amp/threads/T-019c989e-1394-74ad-8234-ac573fcdb4c7.json +0 -1260
- package/.local/share/amp/threads/T-019c989f-e3dd-772e-85ac-525d0fc88fda.json +0 -403
- package/.local/share/amp/threads/T-019c98a1-7b0c-778a-b311-2e1cff85d710.json +0 -3422
- package/.local/share/amp/threads/T-019c98c5-4b7f-7284-99e9-88aa8c18ba66.json +0 -1830
- package/.local/share/amp/threads/T-019c98d0-f27f-76ec-be10-6df96f22be99.json +0 -4061
- package/.local/share/amp/threads/T-019c98f9-d031-704d-a0c2-f2f395f68f2b.json +0 -509
- package/.local/share/amp/threads/T-019c9919-f9ee-766c-90be-af7a07f6a4c6.json +0 -2075
- package/.local/share/amp/threads/T-019c991c-b98b-7158-9083-cc52408beb13.json +0 -7
- package/.local/share/amp/threads/T-019c991d-66d6-72aa-a9a1-105f7df0ea06.json +0 -7
- package/.local/share/amp/threads/T-019c9c2e-71a4-77ff-bd7f-b053da7f9000.json +0 -1637
- package/.local/share/amp/threads/T-019c9c45-27ca-728b-ba77-835115dfa9b2.json +0 -3893
- package/.local/share/amp/threads/T-019c9c48-45dc-736a-9752-e4119fe698f9.json +0 -7
- package/.local/share/amp/threads/T-019c9c4d-266b-72d0-b56e-74a5777e6583.json +0 -7
- package/.local/share/amp/threads/T-019c9c52-ab89-758f-9178-bda99c39d10b.json +0 -7
- package/.local/share/amp/threads/T-019c9c56-5715-72e2-b8b4-87711a842dd1.json +0 -1799
- package/.local/share/amp/threads/T-019c9c5b-88b1-74cb-97e9-16b23e03daa2.json +0 -727
- package/.local/share/amp/threads/T-019c9c5c-3b3e-721c-ad2e-a2ef245dce3f.json +0 -738
- package/.local/share/amp/threads/T-019c9c5c-fd78-736f-9d29-a66d23839d40.json +0 -256
- package/.local/share/amp/threads/T-019c9c5d-db4a-74cd-ad2a-925fac87131d.json +0 -1859
- package/.local/share/kilo/kilo.db +0 -0
- package/.local/share/kilo/kilo.db-shm +0 -0
- package/.local/share/kilo/kilo.db-wal +0 -0
- package/.local/share/kilo/storage/migration +0 -1
- package/.local/share/kilo/storage/session_diff/ses_36bea4cb9ffe1b0j5HEL14KEaU.json +0 -1
- package/.local/share/kilo/storage/session_diff/ses_36beaa8f2ffeeZ3Y39SQ9UDWQQ.json +0 -1
- package/.local/share/kilo/telemetry-id +0 -1
- package/.local/share/opencode/auth.json +0 -6
- package/.local/share/opencode/opencode.db +0 -0
- package/.local/share/opencode/opencode.db-shm +0 -0
- package/.local/share/opencode/opencode.db-wal +0 -0
- package/.local/share/opencode/storage/agent-usage-reminder/ses_36870ea98ffe8S5ZOCE4F11yFh.json +0 -6
- package/.local/share/opencode/storage/agent-usage-reminder/ses_3687a3e9affewUnHBzvpiPR6df.json +0 -6
- package/.local/share/opencode/storage/agent-usage-reminder/ses_36886e68dffeKVgUWf6lzXdEEt.json +0 -6
- package/.local/share/opencode/storage/agent-usage-reminder/ses_36bee9f1effeJbiHHLWLR6O3WJ.json +0 -6
- package/.local/share/opencode/storage/agent-usage-reminder/ses_36c25e50affef2nhaXq9aSgKH3.json +0 -6
- package/.local/share/opencode/storage/agent-usage-reminder/ses_36c260708ffel4wG4yhdo0knDD.json +0 -6
- package/.local/share/opencode/storage/agent-usage-reminder/ses_36c261531ffeoVcvqXxry2bN9H.json +0 -6
- package/.local/share/opencode/storage/agent-usage-reminder/ses_36c291bddffePWRiaFLLJAC1y7.json +0 -6
- package/.local/share/opencode/storage/migration +0 -1
- package/.local/share/opencode/storage/session_diff/ses_36870ea98ffe8S5ZOCE4F11yFh.json +0 -1
- package/.local/share/opencode/storage/session_diff/ses_3687a3e9affewUnHBzvpiPR6df.json +0 -1
- package/.local/share/opencode/storage/session_diff/ses_36886e68dffeKVgUWf6lzXdEEt.json +0 -1
- package/.local/share/opencode/storage/session_diff/ses_36bee9f1effeJbiHHLWLR6O3WJ.json +0 -1
- package/.local/share/opencode/storage/session_diff/ses_36c25e50affef2nhaXq9aSgKH3.json +0 -1
- package/.local/share/opencode/storage/session_diff/ses_36c260708ffel4wG4yhdo0knDD.json +0 -1
- package/.local/share/opencode/storage/session_diff/ses_36c261531ffeoVcvqXxry2bN9H.json +0 -1
- package/.local/share/opencode/storage/session_diff/ses_36c291bddffePWRiaFLLJAC1y7.json +0 -1
- package/.local/share/opencode/storage/session_diff/ses_36c2af1c5ffegxEaOZOGcVykyy.json +0 -1
- package/.local/share/opencode/storage/session_diff/ses_36c2be235ffeOa6x8UCk1HW4kU.json +0 -1
- package/.local/share/opencode/tool-output/tool_c93da840c0016GrdyAkOnHGezU +0 -2330
- package/.local/share/opencode/tool-output/tool_c9411e784001cRoQqwVDb1a6lY +0 -1017
- package/.local/state/replit/log-query.db +0 -0
- package/.local/state/replit/log-query.db-shm +0 -0
- package/.local/state/replit/log-query.db-wal +0 -0
- package/.replit +0 -41
- package/.upm/store.json +0 -1
- package/AGENTS.md +0 -28
- package/bun.lock +0 -271
- package/generated-icon.png +0 -0
- package/hello.txt +0 -1
- package/index.jsx +0 -24
- package/src/agent.js +0 -504
- package/src/app.jsx +0 -96
- package/src/commands.js +0 -133
- package/src/components/AssistantMessage.jsx +0 -83
- package/src/components/ChatArea.jsx +0 -84
- package/src/components/DiffView.jsx +0 -26
- package/src/components/Divider.jsx +0 -8
- package/src/components/Header.jsx +0 -44
- package/src/components/HelpModal.jsx +0 -81
- package/src/components/InputBar.jsx +0 -32
- package/src/components/Spinner.jsx +0 -23
- package/src/components/StatusBar.jsx +0 -44
- package/src/components/SystemMessage.jsx +0 -31
- package/src/components/ThinkBlock.jsx +0 -29
- package/src/components/ToolCallItem.jsx +0 -43
- package/src/components/UserMessage.jsx +0 -11
- package/src/components/Welcome.jsx +0 -14
- package/src/config.js +0 -196
- package/src/hooks/useLayout.js +0 -15
- package/src/hooks/useStore.js +0 -6
- package/src/prompt.js +0 -101
- package/src/store.js +0 -99
- package/src/theme.js +0 -19
- package/src/thinking.js +0 -54
- package/src/toolExecutors.js +0 -853
- package/src/tools.js +0 -335
- package/src/utils.js +0 -32
- package/tsconfig.json +0 -10
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TextAttributes } from '@opentui/core';
|
|
2
|
-
import { colors } from '../theme.js';
|
|
3
|
-
|
|
4
|
-
export default function UserMessage({ content }) {
|
|
5
|
-
return (
|
|
6
|
-
<box style={{ flexDirection: 'column', paddingLeft: 1, marginTop: 1 }}>
|
|
7
|
-
<text fg={colors.blue} attributes={TextAttributes.BOLD} content="You" />
|
|
8
|
-
<text fg={colors.text} content={content || ''} />
|
|
9
|
-
</box>
|
|
10
|
-
);
|
|
11
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TextAttributes } from '@opentui/core';
|
|
2
|
-
import { colors } from '../theme.js';
|
|
3
|
-
import { useLayout } from '../hooks/useLayout.js';
|
|
4
|
-
import { MAX_TOOL_ITERATIONS } from '../config.js';
|
|
5
|
-
|
|
6
|
-
export default function Welcome() {
|
|
7
|
-
const { isNarrow } = useLayout();
|
|
8
|
-
return (
|
|
9
|
-
<box style={{ flexDirection: 'column', paddingLeft: 1, marginTop: 1 }}>
|
|
10
|
-
<text fg={colors.white} attributes={TextAttributes.BOLD} content="How can I help?" />
|
|
11
|
-
<text fg={colors.dim} content={isNarrow ? `Max ${MAX_TOOL_ITERATIONS} iterations` : `Tools available · Max ${MAX_TOOL_ITERATIONS} iterations per turn`} />
|
|
12
|
-
</box>
|
|
13
|
-
);
|
|
14
|
-
}
|
package/src/config.js
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const OpenAI = require('openai');
|
|
4
|
-
|
|
5
|
-
// ===== Config =====
|
|
6
|
-
const NVIDIA_MODEL = 'z-ai/glm4.7';
|
|
7
|
-
const REVIEWER_MODEL = 'nvidia/llama-3.3-nemotron-70b-instruct';
|
|
8
|
-
const FILE_PICKER_MODEL = 'qwen/qwen3-coder-480b-a35b-instruct';
|
|
9
|
-
const THINKER_MODEL = 'z-ai/glm4.7';
|
|
10
|
-
const COMMANDER_MODEL = 'nvidia/llama-3.3-nemotron-70b-instruct';
|
|
11
|
-
const CONTEXT_PRUNER_MODEL = 'nvidia/llama-3.3-nemotron-70b-instruct';
|
|
12
|
-
const MAX_TOOL_ITERATIONS = 50;
|
|
13
|
-
const MAX_OUTPUT_LEN = 12000;
|
|
14
|
-
const TOOL_TIMEOUT = 60000;
|
|
15
|
-
const PROJECT_ROOT = process.cwd();
|
|
16
|
-
|
|
17
|
-
// ===== Mode System =====
|
|
18
|
-
// Modes: 'default' | 'max' | 'lite'
|
|
19
|
-
let currentMode = 'default';
|
|
20
|
-
|
|
21
|
-
const REVIEWER_SYSTEM_PROMPT = `You are a senior code reviewer. An AI coding assistant just made changes to a codebase. Your job is to review those changes thoroughly and report issues. Be specific — reference exact line numbers, function names, and variables.
|
|
22
|
-
|
|
23
|
-
The caller must always specify the exact files and changes to review. If you receive a vague or generic prompt, review only what is explicitly provided — do NOT infer or assume scope.
|
|
24
|
-
|
|
25
|
-
Focus on:
|
|
26
|
-
1. **Bugs & logic errors** — incorrect conditions, off-by-one, null/undefined risks, race conditions
|
|
27
|
-
2. **Security** — exposed secrets, injection risks, unsafe operations
|
|
28
|
-
3. **Edge cases** — unhandled inputs, missing error handling at boundaries
|
|
29
|
-
4. **Code quality** — naming, readability, dead code, unnecessary complexity
|
|
30
|
-
5. **Correctness** — does the code actually fulfil the stated intent?
|
|
31
|
-
|
|
32
|
-
If everything looks good, say so briefly. If there are problems, list them clearly with severity (critical / warning / nit). You have no tools; your only output is this review.`;
|
|
33
|
-
|
|
34
|
-
const FILE_PICKER_SYSTEM_PROMPT = `You are a precision file-picker agent embedded inside a coding assistant. Your ONLY job is to identify the files in a codebase that are relevant to a given prompt.
|
|
35
|
-
|
|
36
|
-
You will receive:
|
|
37
|
-
1. A full recursive directory tree of the project.
|
|
38
|
-
2. A preview (first 8 lines) of every source file.
|
|
39
|
-
3. A prompt specifying the exact type of files to find.
|
|
40
|
-
|
|
41
|
-
Your task:
|
|
42
|
-
- Analyze the directory tree and file previews carefully.
|
|
43
|
-
- Select ONLY the files that are directly relevant to the prompt.
|
|
44
|
-
- Rank them by relevance (most relevant first).
|
|
45
|
-
- Be precise — do NOT include files that are only tangentially related.
|
|
46
|
-
- If no files match, say so.
|
|
47
|
-
- The caller must always specify the exact type of files they need. If you receive a vague or generic prompt like "give me an overview of the codebase", respond with an empty array — do NOT guess.
|
|
48
|
-
|
|
49
|
-
Output format — return ONLY a JSON array of objects, nothing else:
|
|
50
|
-
[
|
|
51
|
-
{ "path": "relative/path/to/file.js", "reason": "Brief explanation of why this file is relevant" }
|
|
52
|
-
]
|
|
53
|
-
|
|
54
|
-
Do NOT wrap in markdown code fences. Output raw JSON only.`;
|
|
55
|
-
|
|
56
|
-
const THINKER_SYSTEM_PROMPT = `You are Theo the Theorizer, a deep reasoning and planning agent inside a coding assistant. Your job is to think carefully about coding tasks and produce clear, actionable plans.
|
|
57
|
-
|
|
58
|
-
You will receive the conversation history and a specific question or task to reason about.
|
|
59
|
-
|
|
60
|
-
Your process:
|
|
61
|
-
1. Analyze the problem deeply — consider edge cases, dependencies, and implications.
|
|
62
|
-
2. If it's a coding task, plan which files need changes and in what order.
|
|
63
|
-
3. Consider multiple approaches and trade-offs.
|
|
64
|
-
4. Output a clear, structured response with your reasoning and recommendations.
|
|
65
|
-
|
|
66
|
-
Be concise but thorough. Focus on actionable insights, not obvious observations. If you identify risks or potential issues, flag them clearly.`;
|
|
67
|
-
|
|
68
|
-
const COMMANDER_SYSTEM_PROMPT = `You are a terminal command specialist agent. Your job is to determine the right shell commands to accomplish a goal and explain what they do.
|
|
69
|
-
|
|
70
|
-
You will receive a task description. Output a JSON array of commands to execute:
|
|
71
|
-
[
|
|
72
|
-
{ "command": "the shell command", "description": "what this does and why" }
|
|
73
|
-
]
|
|
74
|
-
|
|
75
|
-
Rules:
|
|
76
|
-
- Only suggest safe, non-destructive commands unless explicitly asked for destructive operations.
|
|
77
|
-
- Never suggest commands that expose secrets or credentials.
|
|
78
|
-
- Prefer specific, targeted commands over broad ones.
|
|
79
|
-
- Include error handling where appropriate (e.g., using || or checking exit codes).
|
|
80
|
-
- Output raw JSON only, no markdown fences.`;
|
|
81
|
-
|
|
82
|
-
const CONTEXT_PRUNER_SYSTEM_PROMPT = `You are a context management agent. Your job is to summarize a long conversation history into a concise but complete summary that preserves all important information.
|
|
83
|
-
|
|
84
|
-
Preserve:
|
|
85
|
-
1. All file paths that were read, modified, or created.
|
|
86
|
-
2. Key decisions and their rationale.
|
|
87
|
-
3. Errors encountered and how they were resolved.
|
|
88
|
-
4. The current state of the task (what's done, what's remaining).
|
|
89
|
-
5. Any important code snippets or patterns discussed.
|
|
90
|
-
|
|
91
|
-
Output a structured summary with sections:
|
|
92
|
-
- **Task**: What the user asked for
|
|
93
|
-
- **Progress**: What has been done so far
|
|
94
|
-
- **Files Modified**: List of files changed
|
|
95
|
-
- **Key Decisions**: Important choices made
|
|
96
|
-
- **Current State**: Where things stand now
|
|
97
|
-
- **Remaining**: What still needs to be done (if anything)
|
|
98
|
-
|
|
99
|
-
Be concise but lose no critical details. This summary replaces the full conversation.`;
|
|
100
|
-
|
|
101
|
-
const SELECTOR_SYSTEM_PROMPT = `You are a code implementation selector. You will receive multiple implementation proposals (labeled A, B, C, etc.) for the same coding task. Each proposal includes the strategy used and the resulting changes.
|
|
102
|
-
|
|
103
|
-
Your job:
|
|
104
|
-
1. Analyze each implementation carefully for:
|
|
105
|
-
- **Correctness**: Does it actually solve the stated problem?
|
|
106
|
-
- **Code quality**: Is it clean, readable, and maintainable?
|
|
107
|
-
- **Simplicity**: Is it the simplest correct solution?
|
|
108
|
-
- **Edge cases**: Does it handle edge cases?
|
|
109
|
-
- **Consistency**: Does it match existing code patterns?
|
|
110
|
-
2. Pick the best implementation.
|
|
111
|
-
3. Note any good ideas from non-chosen implementations that could improve the winner.
|
|
112
|
-
|
|
113
|
-
Output JSON only, no markdown fences:
|
|
114
|
-
{
|
|
115
|
-
"chosen": "A",
|
|
116
|
-
"reason": "Brief explanation of why this is the best",
|
|
117
|
-
"improvements": "Any good ideas from other implementations to incorporate"
|
|
118
|
-
}`;
|
|
119
|
-
|
|
120
|
-
const nvidiaClient = new OpenAI({
|
|
121
|
-
apiKey: process.env.NVIDIA_API_KEY || '',
|
|
122
|
-
baseURL: 'https://integrate.api.nvidia.com/v1',
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
// ===== Session State =====
|
|
126
|
-
const session = {
|
|
127
|
-
conversationHistory: [],
|
|
128
|
-
totalTokens: 0,
|
|
129
|
-
totalCost: 0,
|
|
130
|
-
toolCallCount: 0,
|
|
131
|
-
filesModified: new Set(),
|
|
132
|
-
filesRead: new Set(),
|
|
133
|
-
commandsRun: [],
|
|
134
|
-
editHistory: [], // { path, before, after, timestamp }
|
|
135
|
-
startTime: Date.now(),
|
|
136
|
-
turnCount: 0,
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
// ===== Shared Utilities =====
|
|
140
|
-
function truncateOutput(str) {
|
|
141
|
-
if (str.length > MAX_OUTPUT_LEN) {
|
|
142
|
-
return str.slice(0, MAX_OUTPUT_LEN) + `\n... (truncated, ${str.length} chars total)`;
|
|
143
|
-
}
|
|
144
|
-
return str;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const path = require('path');
|
|
148
|
-
|
|
149
|
-
function resolvePath(p) {
|
|
150
|
-
if (!p) return PROJECT_ROOT;
|
|
151
|
-
return path.isAbsolute(p) ? p : path.resolve(PROJECT_ROOT, p);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function timestamp() {
|
|
155
|
-
return new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' });
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function sleep(ms) {
|
|
159
|
-
return new Promise(r => setTimeout(r, ms));
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function getMode() { return currentMode; }
|
|
163
|
-
function setMode(mode) {
|
|
164
|
-
if (['default', 'max', 'lite'].includes(mode)) {
|
|
165
|
-
currentMode = mode;
|
|
166
|
-
return true;
|
|
167
|
-
}
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
module.exports = {
|
|
172
|
-
NVIDIA_MODEL,
|
|
173
|
-
REVIEWER_MODEL,
|
|
174
|
-
THINKER_MODEL,
|
|
175
|
-
COMMANDER_MODEL,
|
|
176
|
-
CONTEXT_PRUNER_MODEL,
|
|
177
|
-
MAX_TOOL_ITERATIONS,
|
|
178
|
-
MAX_OUTPUT_LEN,
|
|
179
|
-
TOOL_TIMEOUT,
|
|
180
|
-
PROJECT_ROOT,
|
|
181
|
-
FILE_PICKER_MODEL,
|
|
182
|
-
FILE_PICKER_SYSTEM_PROMPT,
|
|
183
|
-
REVIEWER_SYSTEM_PROMPT,
|
|
184
|
-
THINKER_SYSTEM_PROMPT,
|
|
185
|
-
COMMANDER_SYSTEM_PROMPT,
|
|
186
|
-
CONTEXT_PRUNER_SYSTEM_PROMPT,
|
|
187
|
-
SELECTOR_SYSTEM_PROMPT,
|
|
188
|
-
nvidiaClient,
|
|
189
|
-
session,
|
|
190
|
-
truncateOutput,
|
|
191
|
-
resolvePath,
|
|
192
|
-
timestamp,
|
|
193
|
-
sleep,
|
|
194
|
-
getMode,
|
|
195
|
-
setMode,
|
|
196
|
-
};
|
package/src/hooks/useLayout.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useTerminalDimensions } from '@opentui/react';
|
|
2
|
-
|
|
3
|
-
const NARROW_THRESHOLD = 60;
|
|
4
|
-
|
|
5
|
-
export function useLayout() {
|
|
6
|
-
const { width } = useTerminalDimensions();
|
|
7
|
-
const w = width || 80;
|
|
8
|
-
const isNarrow = w < NARROW_THRESHOLD;
|
|
9
|
-
return {
|
|
10
|
-
width: w,
|
|
11
|
-
isNarrow,
|
|
12
|
-
indent: isNarrow ? 2 : 4,
|
|
13
|
-
smallIndent: isNarrow ? 1 : 2,
|
|
14
|
-
};
|
|
15
|
-
}
|
package/src/hooks/useStore.js
DELETED
package/src/prompt.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const { execSync } = require('child_process');
|
|
6
|
-
const { PROJECT_ROOT, MAX_TOOL_ITERATIONS, getMode } = require('./config');
|
|
7
|
-
|
|
8
|
-
function buildSystemPrompt() {
|
|
9
|
-
let gitInfo = '';
|
|
10
|
-
try {
|
|
11
|
-
const branch = execSync('git rev-parse --abbrev-ref HEAD 2>/dev/null', { encoding: 'utf-8', cwd: PROJECT_ROOT }).trim();
|
|
12
|
-
const status = execSync('git status --short 2>/dev/null', { encoding: 'utf-8', cwd: PROJECT_ROOT }).trim();
|
|
13
|
-
const remoteUrl = execSync('git config --get remote.origin.url 2>/dev/null', { encoding: 'utf-8', cwd: PROJECT_ROOT }).trim();
|
|
14
|
-
gitInfo = `\nGit branch: ${branch}\nGit remote: ${remoteUrl}\nGit status:\n${status || '(clean)'}`;
|
|
15
|
-
} catch {}
|
|
16
|
-
|
|
17
|
-
let projectInfo = '';
|
|
18
|
-
try {
|
|
19
|
-
const pkg = JSON.parse(fs.readFileSync(path.join(PROJECT_ROOT, 'package.json'), 'utf-8'));
|
|
20
|
-
projectInfo = `\nProject: ${pkg.name || 'unknown'} v${pkg.version || '0.0.0'}`;
|
|
21
|
-
if (pkg.dependencies) projectInfo += `\nDependencies: ${Object.keys(pkg.dependencies).join(', ')}`;
|
|
22
|
-
if (pkg.devDependencies) projectInfo += `\nDev dependencies: ${Object.keys(pkg.devDependencies).join(', ')}`;
|
|
23
|
-
if (pkg.scripts) projectInfo += `\nScripts: ${Object.keys(pkg.scripts).join(', ')}`;
|
|
24
|
-
} catch {}
|
|
25
|
-
|
|
26
|
-
return `You are Apex AI, an agentic CLI coding assistant that runs in the terminal. Be concise, precise, and action-oriented.
|
|
27
|
-
|
|
28
|
-
# Output Style
|
|
29
|
-
- Default to short answers (≤4 lines) unless the user asks for detail.
|
|
30
|
-
- No unnecessary preamble or postamble. Don't narrate obvious steps or explain what you're about to do.
|
|
31
|
-
- After working on files, just stop — don't summarize what you did unless asked.
|
|
32
|
-
- Use bullets and monospace for commands, file paths, and code identifiers.
|
|
33
|
-
- No emojis unless the user uses them first.
|
|
34
|
-
- For casual conversation, greetings, or quick questions, respond naturally without tools or formatting.
|
|
35
|
-
- NEVER say things like "I don't have any tool to call" — just respond with what you know.
|
|
36
|
-
|
|
37
|
-
# Core Behavior
|
|
38
|
-
1. **Finish the task.** When asked to do something, DO it with tools until complete. Don't just explain how.
|
|
39
|
-
2. **Read before edit.** NEVER modify a file you haven't read. Understand existing code first.
|
|
40
|
-
3. **Work incrementally.** Make small changes, verify they work, then continue.
|
|
41
|
-
4. **Keep going.** If a tool call fails, recover and try another approach. Don't give up after one attempt.
|
|
42
|
-
5. **Existing code: be surgical.** Only change what's needed. Don't refactor, add features, or "improve" beyond what was asked. Match existing style, patterns, and dependencies.
|
|
43
|
-
6. **New/greenfield work:** You may propose structure and be creative, but keep scope minimal.
|
|
44
|
-
7. **Act on errors.** If the user pastes an error or stack trace, use tools to locate the exact source, identify root cause, and fix it. Never punt back with "try checking X."
|
|
45
|
-
|
|
46
|
-
# Safety & Side Effects
|
|
47
|
-
- Never expose secrets, API keys, tokens, or credentials. Don't display .env contents.
|
|
48
|
-
- Never run destructive commands (\`rm -rf\`, \`git reset --hard\`, \`git clean -fdx\`) without asking.
|
|
49
|
-
- Never \`git commit\` or \`git push\` unless the user explicitly asks.
|
|
50
|
-
- Don't add new dependencies without confirming the user wants them.
|
|
51
|
-
- NEVER assume a library is available. Check package.json or neighboring files first.
|
|
52
|
-
|
|
53
|
-
# Code Hygiene
|
|
54
|
-
- Do NOT add code comments or docstrings unless the user asks or correctness requires it.
|
|
55
|
-
- Match existing code style, naming conventions, frameworks, and patterns.
|
|
56
|
-
- When creating new files or components, look at existing ones first to follow conventions.
|
|
57
|
-
- Follow security best practices. Never introduce code that exposes or logs secrets.
|
|
58
|
-
|
|
59
|
-
# Validation
|
|
60
|
-
- After code changes, run the most relevant checks: tests, lint, typecheck, or build. Prefer scripts from package.json.
|
|
61
|
-
- If checks fail, fix and re-run. If blocked, clearly state what's failing and why.
|
|
62
|
-
- Start with targeted tests for what you changed, then broaden if needed.
|
|
63
|
-
|
|
64
|
-
# Tool Usage
|
|
65
|
-
- Use Grep/Glob/ListDir to explore and locate code.
|
|
66
|
-
- Use Read to understand files before modifying them.
|
|
67
|
-
- Use Edit for surgical changes to existing files (preferred over Write).
|
|
68
|
-
- Use Patch for multiple edits to the same file.
|
|
69
|
-
- Use Write only for creating new files.
|
|
70
|
-
- Use Bash for running commands (tests, builds, linters, git).
|
|
71
|
-
- Bundle independent tool calls in the same turn for parallel execution.
|
|
72
|
-
- Don't ask for permission to use tools — just use them.
|
|
73
|
-
- When using FilePickerMax, ALWAYS specify the exact type of files you need (e.g. "show me the main entry point and config files", "files handling authentication"). NEVER send generic prompts like "give me an overview of the codebase".
|
|
74
|
-
|
|
75
|
-
# Sub-Agents
|
|
76
|
-
You have access to specialized sub-agents that handle specific tasks:
|
|
77
|
-
- **FilePickerMax**: Scans the codebase to find files relevant to a prompt. Always specify the exact type of files needed.
|
|
78
|
-
- **Thinker**: Deep reasoning and planning for complex tasks. Use when you need to analyze a problem carefully before acting.
|
|
79
|
-
- **ThinkerBestOfN**: (MAX mode only) Spawns N parallel thinkers and picks the best reasoning. Use for critical decisions.
|
|
80
|
-
- **EditorMultiPrompt**: (MAX mode only) Tries multiple implementation strategies in parallel and picks the best one.
|
|
81
|
-
- **CodeReviewMulti**: (MAX mode only) Multiple reviewers analyze code from different perspectives (correctness, security, performance).
|
|
82
|
-
- **Commander**: Plans and executes terminal commands for a specific goal.
|
|
83
|
-
- **ContextPruner**: Summarizes conversation history to free context space.
|
|
84
|
-
|
|
85
|
-
# Modes
|
|
86
|
-
Current mode: ${getMode()}
|
|
87
|
-
- **default**: Standard single-agent pass with auto code review.
|
|
88
|
-
- **max**: Best-of-N thinking, multi-strategy editing, multi-perspective review, auto context pruning. Higher quality, more API calls.
|
|
89
|
-
- **lite**: Fast mode — skips validation and review steps.
|
|
90
|
-
|
|
91
|
-
# Note
|
|
92
|
-
A separate code reviewer runs automatically after edits (skipped in lite mode, multi-perspective in max mode).
|
|
93
|
-
|
|
94
|
-
# Environment
|
|
95
|
-
Working directory: ${PROJECT_ROOT}
|
|
96
|
-
OS: ${process.platform}
|
|
97
|
-
Node: ${process.version}${projectInfo}${gitInfo}
|
|
98
|
-
Maximum tool iterations per turn: ${MAX_TOOL_ITERATIONS}`;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
module.exports = { buildSystemPrompt };
|
package/src/store.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
let state = {
|
|
4
|
-
messages: [],
|
|
5
|
-
streamingContent: '',
|
|
6
|
-
streamingThinking: '',
|
|
7
|
-
isProcessing: false,
|
|
8
|
-
showHelp: false,
|
|
9
|
-
showSummary: false,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
let nextId = 1;
|
|
13
|
-
const listeners = new Set();
|
|
14
|
-
let renderer = null;
|
|
15
|
-
|
|
16
|
-
function getSnapshot() { return state; }
|
|
17
|
-
|
|
18
|
-
function subscribe(listener) {
|
|
19
|
-
listeners.add(listener);
|
|
20
|
-
return () => listeners.delete(listener);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function notify() {
|
|
24
|
-
for (const fn of listeners) fn();
|
|
25
|
-
if (renderer) renderer.requestRender();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function setState(partial) {
|
|
29
|
-
state = { ...state, ...partial };
|
|
30
|
-
notify();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function addMessage(msg) {
|
|
34
|
-
const id = nextId++;
|
|
35
|
-
state = { ...state, messages: [...state.messages, { id, ...msg }] };
|
|
36
|
-
notify();
|
|
37
|
-
return id;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function updateMessage(id, updates) {
|
|
41
|
-
state = {
|
|
42
|
-
...state,
|
|
43
|
-
messages: state.messages.map(m => m.id === id ? { ...m, ...updates } : m),
|
|
44
|
-
};
|
|
45
|
-
notify();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function toggleMessageExpanded(id) {
|
|
49
|
-
state = {
|
|
50
|
-
...state,
|
|
51
|
-
messages: state.messages.map(m => m.id === id ? { ...m, expanded: !m.expanded } : m),
|
|
52
|
-
};
|
|
53
|
-
notify();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function updateStreaming(content, thinking) {
|
|
57
|
-
state = { ...state, streamingContent: content || '', streamingThinking: thinking || '' };
|
|
58
|
-
notify();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function clearStreaming() {
|
|
62
|
-
state = { ...state, streamingContent: '', streamingThinking: '' };
|
|
63
|
-
notify();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function finishStreaming(msg) {
|
|
67
|
-
const id = nextId++;
|
|
68
|
-
state = {
|
|
69
|
-
...state,
|
|
70
|
-
streamingContent: '',
|
|
71
|
-
streamingThinking: '',
|
|
72
|
-
messages: [...state.messages, { id, ...msg }],
|
|
73
|
-
};
|
|
74
|
-
notify();
|
|
75
|
-
return id;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function clearMessages() {
|
|
79
|
-
state = { ...state, messages: [] };
|
|
80
|
-
notify();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function setRenderer(r) { renderer = r; }
|
|
84
|
-
function getRenderer() { return renderer; }
|
|
85
|
-
|
|
86
|
-
module.exports = {
|
|
87
|
-
getSnapshot,
|
|
88
|
-
subscribe,
|
|
89
|
-
setState,
|
|
90
|
-
addMessage,
|
|
91
|
-
updateMessage,
|
|
92
|
-
toggleMessageExpanded,
|
|
93
|
-
updateStreaming,
|
|
94
|
-
clearStreaming,
|
|
95
|
-
finishStreaming,
|
|
96
|
-
clearMessages,
|
|
97
|
-
setRenderer,
|
|
98
|
-
getRenderer,
|
|
99
|
-
};
|
package/src/theme.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const colors = {
|
|
4
|
-
primary: '#6366f1',
|
|
5
|
-
accent: '#818cf8',
|
|
6
|
-
dim: '#666666',
|
|
7
|
-
muted: '#888888',
|
|
8
|
-
text: '#e0e0e0',
|
|
9
|
-
white: '#ffffff',
|
|
10
|
-
green: '#22c55e',
|
|
11
|
-
yellow: '#eab308',
|
|
12
|
-
red: '#ef4444',
|
|
13
|
-
blue: '#3b82f6',
|
|
14
|
-
cyan: '#06b6d4',
|
|
15
|
-
surface: '#1e1e2e',
|
|
16
|
-
border: '#333355',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
module.exports = { colors };
|
package/src/thinking.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function parseThinkBlocks(text) {
|
|
4
|
-
const thinkRegex = /<think>([\s\S]*?)(?:<\/think>|think>)/g;
|
|
5
|
-
const thoughts = [];
|
|
6
|
-
let match;
|
|
7
|
-
while ((match = thinkRegex.exec(text)) !== null) {
|
|
8
|
-
const content = match[1].trim();
|
|
9
|
-
if (content) thoughts.push(content);
|
|
10
|
-
}
|
|
11
|
-
const cleaned = text.replace(/<think>[\s\S]*?(?:<\/think>|think>)/g, '').trim();
|
|
12
|
-
return { thoughts, content: cleaned };
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function findThinkClose(text) {
|
|
16
|
-
const fullClose = text.indexOf('</think>');
|
|
17
|
-
if (fullClose !== -1) return { pos: fullClose, len: 8 };
|
|
18
|
-
let searchFrom = 0;
|
|
19
|
-
while (searchFrom < text.length) {
|
|
20
|
-
const idx = text.indexOf('think>', searchFrom);
|
|
21
|
-
if (idx === -1) break;
|
|
22
|
-
if (idx === 0 || text[idx - 1] !== '<') return { pos: idx, len: 6 };
|
|
23
|
-
searchFrom = idx + 6;
|
|
24
|
-
}
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function stripStrayCloseTag(text) {
|
|
29
|
-
return text.replace(/<\/think>/g, '').replace(/(?<!<)think>/g, '');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function splitAtPartialTag(text) {
|
|
33
|
-
const prefixes = [
|
|
34
|
-
'</think>', '</think', '</thin', '</thi', '</th', '</t', '</',
|
|
35
|
-
'<think>', '<think', '<thin', '<thi', '<th', '<t',
|
|
36
|
-
'<',
|
|
37
|
-
];
|
|
38
|
-
for (const prefix of prefixes) {
|
|
39
|
-
if (text.endsWith(prefix)) {
|
|
40
|
-
if (prefix === '</think>' || prefix === 'think>') {
|
|
41
|
-
return { safe: text.slice(0, -prefix.length), pending: '' };
|
|
42
|
-
}
|
|
43
|
-
return { safe: text.slice(0, -prefix.length), pending: prefix };
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return { safe: text, pending: '' };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
module.exports = {
|
|
50
|
-
parseThinkBlocks,
|
|
51
|
-
findThinkClose,
|
|
52
|
-
stripStrayCloseTag,
|
|
53
|
-
splitAtPartialTag,
|
|
54
|
-
};
|