@golba98/codexa 1.0.2 → 1.0.4
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/README.md +396 -100
- package/bin/codexa.js +62 -144
- package/package.json +14 -8
- package/src/app.tsx +596 -306
- package/src/commands/handler.ts +6 -6
- package/src/config/buildInfo.ts +2 -2
- package/src/config/layeredConfig.ts +1 -1
- package/src/config/persistence.ts +10 -0
- package/src/config/runtimeConfig.ts +1 -1
- package/src/config/settings.ts +8 -16
- package/src/config/trustStore.ts +1 -1
- package/src/config/updateCheckCache.ts +19 -1
- package/src/core/README.md +52 -0
- package/src/core/agent/loop.ts +282 -0
- package/src/core/agent/protocol.ts +211 -0
- package/src/core/agent/tools.ts +414 -0
- package/src/core/{codexExecArgs.ts → codex/codexExecArgs.ts} +2 -2
- package/src/core/{codexLaunch.ts → codex/codexLaunch.ts} +3 -3
- package/src/core/{codexPrompt.ts → codex/codexPrompt.ts} +3 -3
- package/src/core/debug/modelStateDebug.ts +34 -0
- package/src/core/executables/antigravityExecutable.ts +48 -0
- package/src/core/executables/codexExecutable.ts +1 -0
- package/src/core/executables/executableResolver.ts +65 -43
- package/src/core/perf/renderDebug.ts +10 -6
- package/src/core/process/processValidation.ts +9 -5
- package/src/core/providerLauncher/launcher.ts +59 -42
- package/src/core/providerLauncher/registry.ts +30 -14
- package/src/core/providerLauncher/types.ts +11 -9
- package/src/core/providerLauncher/workspaceConfig.ts +41 -26
- package/src/core/providerRuntime/anthropic.ts +7 -1
- package/src/core/providerRuntime/antigravity.ts +305 -0
- package/src/core/providerRuntime/claudeCodeDiscovery.ts +268 -22
- package/src/core/providerRuntime/claudeCodeDiscoveryDebug.ts +55 -0
- package/src/core/providerRuntime/contextMetadata.ts +12 -24
- package/src/core/providerRuntime/local.ts +129 -51
- package/src/core/providerRuntime/models.ts +22 -11
- package/src/core/providerRuntime/registry.ts +58 -31
- package/src/core/providerRuntime/types.ts +19 -14
- package/src/core/providers/codexSubprocess.ts +2 -2
- package/src/core/providers/types.ts +1 -1
- package/src/core/{attachments.ts → shared/attachments.ts} +27 -4
- package/src/core/{cleanupFastFail.ts → shared/cleanupFastFail.ts} +1 -1
- package/src/core/{hollowResponseFormat.ts → shared/hollowResponseFormat.ts} +1 -1
- package/src/core/terminal/clearFrameBoundary.ts +814 -0
- package/src/core/terminal/frameLock.ts +109 -0
- package/src/core/terminal/inkRenderReset.ts +123 -0
- package/src/core/terminal/terminalControl.ts +22 -0
- package/src/core/terminal/terminalTitle.ts +16 -102
- package/src/core/version/channel.ts +23 -0
- package/src/core/version/updateCheck.ts +193 -0
- package/src/core/{launchContext.ts → workspace/launchContext.ts} +32 -39
- package/src/core/{planStorage.ts → workspace/planStorage.ts} +2 -2
- package/src/core/{workspaceGuard.ts → workspace/workspaceGuard.ts} +97 -13
- package/src/headless/execRunner.ts +2 -2
- package/src/index.tsx +43 -89
- package/src/session/appSession.ts +10 -7
- package/src/session/chatLifecycle.ts +1 -1
- package/src/session/liveRenderScheduler.ts +1 -1
- package/src/session/types.ts +3 -2
- package/src/ui/ActionRequiredBlock.tsx +5 -5
- package/src/ui/ActivityBars.tsx +3 -3
- package/src/ui/ActivityIndicator.tsx +6 -6
- package/src/ui/AgentBlock.tsx +6 -6
- package/src/ui/AnimatedStatusText.tsx +1 -1
- package/src/ui/AppShell.tsx +670 -719
- package/src/ui/AttachmentImportPanel.tsx +8 -8
- package/src/ui/AuthPanel.tsx +20 -20
- package/src/ui/BottomComposer.tsx +158 -118
- package/src/ui/DashCard.tsx +3 -3
- package/src/ui/Markdown.tsx +17 -17
- package/src/ui/ModelPickerScreen.tsx +222 -42
- package/src/ui/ModelReasoningPicker.tsx +15 -15
- package/src/ui/Panel.tsx +3 -3
- package/src/ui/PlanActionPicker.tsx +6 -6
- package/src/ui/PlanReviewPanel.tsx +9 -9
- package/src/ui/ProviderPicker.tsx +735 -321
- package/src/ui/RunFooter.tsx +3 -3
- package/src/ui/RuntimeStatusBar.tsx +108 -0
- package/src/ui/SelectionPanel.tsx +8 -4
- package/src/ui/SettingsPanel.tsx +9 -9
- package/src/ui/Spinner.tsx +1 -1
- package/src/ui/TextEntryPanel.tsx +11 -11
- package/src/ui/ThinkingBlock.tsx +8 -8
- package/src/ui/Timeline.tsx +1625 -1472
- package/src/ui/TopHeader.tsx +437 -293
- package/src/ui/TranscriptShell.tsx +322 -0
- package/src/ui/TurnGroup.tsx +33 -33
- package/src/ui/UpdateAvailableCard.tsx +41 -0
- package/src/ui/UpdatePromptPanel.tsx +197 -0
- package/src/ui/focus.ts +3 -0
- package/src/ui/layout.ts +299 -25
- package/src/ui/layoutListWindow.ts +145 -0
- package/src/ui/logoVariants.ts +103 -0
- package/src/ui/modeDisplay.ts +12 -12
- package/src/ui/runtimeDisplay.ts +112 -0
- package/src/ui/textLayout.ts +15 -4
- package/src/ui/theme.tsx +274 -395
- package/src/ui/timelineMeasure.ts +218 -136
- package/scripts/audit-codexa-capabilities.mjs +0 -466
- package/scripts/gen-build-info.mjs +0 -33
- package/scripts/smoke-terminal-bench.mjs +0 -35
- package/src/appRenderStability.test.ts +0 -131
- package/src/commands/handler.test.ts +0 -655
- package/src/config/launchArgs.test.ts +0 -189
- package/src/config/layeredConfig.test.ts +0 -143
- package/src/config/persistence.test.ts +0 -114
- package/src/config/runtimeConfig.test.ts +0 -218
- package/src/config/settings.test.ts +0 -155
- package/src/config/trustStore.test.ts +0 -29
- package/src/core/attachments.test.ts +0 -155
- package/src/core/auth/codexAuth.test.ts +0 -68
- package/src/core/cleanupFastFail.test.ts +0 -76
- package/src/core/codex.ts +0 -124
- package/src/core/codexExecArgs.test.ts +0 -195
- package/src/core/codexLaunch.test.ts +0 -205
- package/src/core/codexPrompt.test.ts +0 -252
- package/src/core/executables/codexExecutable.test.ts +0 -212
- package/src/core/executables/executableResolver.test.ts +0 -129
- package/src/core/executables/geminiExecutable.test.ts +0 -116
- package/src/core/executables/pathSanityScan.test.ts +0 -47
- package/src/core/githubDiagnostics.test.ts +0 -92
- package/src/core/hollowResponseFormat.test.ts +0 -58
- package/src/core/launchContext.test.ts +0 -157
- package/src/core/models/codexCapabilities.test.ts +0 -45
- package/src/core/models/codexModelCapabilities.test.ts +0 -246
- package/src/core/models/modelSpecs.test.ts +0 -283
- package/src/core/perf/renderDebug.test.ts +0 -230
- package/src/core/planStorage.test.ts +0 -143
- package/src/core/process/CommandRunner.test.ts +0 -105
- package/src/core/projectInstructions.test.ts +0 -50
- package/src/core/providerLauncher/launcher.test.ts +0 -238
- package/src/core/providerLauncher/registry.test.ts +0 -324
- package/src/core/providerLauncher/workspaceConfig.test.ts +0 -638
- package/src/core/providerRuntime/anthropic.test.ts +0 -1120
- package/src/core/providerRuntime/capabilityProfile.test.ts +0 -311
- package/src/core/providerRuntime/contextMetadata.test.ts +0 -468
- package/src/core/providerRuntime/gemini.test.ts +0 -437
- package/src/core/providerRuntime/lmstudio.test.ts +0 -168
- package/src/core/providerRuntime/local.test.ts +0 -787
- package/src/core/providerRuntime/registry.test.ts +0 -233
- package/src/core/providers/codexJsonStream.test.ts +0 -148
- package/src/core/providers/codexSubprocess.test.ts +0 -68
- package/src/core/providers/codexTranscript.test.ts +0 -284
- package/src/core/terminal/startupClear.test.ts +0 -55
- package/src/core/terminal/terminalCapabilities.test.ts +0 -93
- package/src/core/terminal/terminalControl.test.ts +0 -75
- package/src/core/terminal/terminalSanitize.test.ts +0 -22
- package/src/core/terminal/terminalSelection.test.ts +0 -42
- package/src/core/terminal/terminalTitle.test.ts +0 -328
- package/src/core/updateCheck.test.ts +0 -194
- package/src/core/updateCheck.ts +0 -172
- package/src/core/workspaceActivity.test.ts +0 -163
- package/src/core/workspaceGuard.test.ts +0 -151
- package/src/core/workspaceRoot.test.ts +0 -23
- package/src/exec.test.ts +0 -13
- package/src/headless/execArgs.test.ts +0 -147
- package/src/headless/execRunner.test.ts +0 -436
- package/src/index.test.tsx +0 -620
- package/src/session/appSession.test.ts +0 -897
- package/src/session/chatLifecycle.test.ts +0 -64
- package/src/session/liveRenderScheduler.test.ts +0 -201
- package/src/session/planFlow.test.ts +0 -103
- package/src/session/planTranscript.test.ts +0 -65
- package/src/session/promptRunSchedule.test.ts +0 -36
- package/src/ui/ActivityIndicator.test.tsx +0 -58
- package/src/ui/AgentBlock.test.ts +0 -6
- package/src/ui/AnimatedStatusText.test.ts +0 -16
- package/src/ui/AppShell.test.tsx +0 -1776
- package/src/ui/AttachmentImportPanel.test.tsx +0 -204
- package/src/ui/BottomComposer.test.ts +0 -674
- package/src/ui/CodexLogo.tsx +0 -55
- package/src/ui/Markdown.test.ts +0 -157
- package/src/ui/ModelPickerProviderScope.test.tsx +0 -411
- package/src/ui/ModelPickerScreen.test.tsx +0 -99
- package/src/ui/ModelPickerState.test.tsx +0 -151
- package/src/ui/ModelReasoningPicker.test.tsx +0 -447
- package/src/ui/PlanReviewPanel.test.tsx +0 -267
- package/src/ui/PromptCardBorder.test.tsx +0 -161
- package/src/ui/ProviderPicker.test.tsx +0 -289
- package/src/ui/ProviderShortcut.test.tsx +0 -143
- package/src/ui/SettingsPanel.test.tsx +0 -233
- package/src/ui/StaticTranscriptItem.tsx +0 -56
- package/src/ui/Timeline.test.ts +0 -2067
- package/src/ui/TimelineNavigation.test.tsx +0 -201
- package/src/ui/TopHeader.test.tsx +0 -254
- package/src/ui/TurnGroup.test.tsx +0 -365
- package/src/ui/busyStatusAnimation.test.ts +0 -30
- package/src/ui/commandNormalize.test.ts +0 -142
- package/src/ui/diffRenderer.test.ts +0 -102
- package/src/ui/focusFlow.test.tsx +0 -1098
- package/src/ui/inputBuffer.test.ts +0 -151
- package/src/ui/layout.test.ts +0 -146
- package/src/ui/modeDisplay.test.ts +0 -42
- package/src/ui/runActivityView.test.ts +0 -89
- package/src/ui/runLifecycleView.test.tsx +0 -237
- package/src/ui/statusRenderIsolation.test.tsx +0 -654
- package/src/ui/terminalAnswerFormat.test.ts +0 -19
- package/src/ui/textLayout.test.ts +0 -18
- package/src/ui/themeFlow.test.ts +0 -53
- package/src/ui/timelineMeasureCache.test.ts +0 -986
- /package/src/core/{inputDebug.ts → debug/inputDebug.ts} +0 -0
- /package/src/core/{clipboard.ts → shared/clipboard.ts} +0 -0
- /package/src/core/{githubDiagnostics.ts → shared/githubDiagnostics.ts} +0 -0
- /package/src/core/{projectInstructions.ts → workspace/projectInstructions.ts} +0 -0
- /package/src/core/{workspaceActivity.ts → workspace/workspaceActivity.ts} +0 -0
- /package/src/core/{workspaceRoot.ts → workspace/workspaceRoot.ts} +0 -0
|
@@ -1,436 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import test from "node:test";
|
|
3
|
-
import {
|
|
4
|
-
HEADLESS_EXEC_PROVIDER_UNAVAILABLE,
|
|
5
|
-
HEADLESS_EXEC_RUN_FAILED,
|
|
6
|
-
createHeadlessExecTiming,
|
|
7
|
-
runHeadlessExec,
|
|
8
|
-
type HeadlessExecIo,
|
|
9
|
-
} from "./execRunner.js";
|
|
10
|
-
import { normalizeRuntimeConfig, resolveRuntimeConfig, type ResolvedRuntimeConfig } from "../config/runtimeConfig.js";
|
|
11
|
-
import type { LayeredConfigResult } from "../config/layeredConfig.js";
|
|
12
|
-
import type { LaunchArgs } from "../config/launchArgs.js";
|
|
13
|
-
import type { BackendProvider } from "../core/providers/types.js";
|
|
14
|
-
|
|
15
|
-
function createLaunchArgs(): LaunchArgs {
|
|
16
|
-
return {
|
|
17
|
-
help: false,
|
|
18
|
-
version: false,
|
|
19
|
-
initialPrompt: "Prompt",
|
|
20
|
-
profile: null,
|
|
21
|
-
configOverrides: [],
|
|
22
|
-
passthroughArgs: [],
|
|
23
|
-
modelOverride: null,
|
|
24
|
-
noClear: false,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function createIo(): HeadlessExecIo & { stdoutText: () => string; stderrText: () => string } {
|
|
29
|
-
let stdout = "";
|
|
30
|
-
let stderr = "";
|
|
31
|
-
return {
|
|
32
|
-
stdout: {
|
|
33
|
-
write: (chunk: string) => {
|
|
34
|
-
stdout += chunk;
|
|
35
|
-
return true;
|
|
36
|
-
},
|
|
37
|
-
} as NodeJS.WriteStream,
|
|
38
|
-
stderr: {
|
|
39
|
-
write: (chunk: string) => {
|
|
40
|
-
stderr += chunk;
|
|
41
|
-
return true;
|
|
42
|
-
},
|
|
43
|
-
} as NodeJS.WriteStream,
|
|
44
|
-
stdoutText: () => stdout,
|
|
45
|
-
stderrText: () => stderr,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function createLayeredConfig(): LayeredConfigResult {
|
|
50
|
-
return {
|
|
51
|
-
runtime: normalizeRuntimeConfig({
|
|
52
|
-
provider: "codex-subprocess",
|
|
53
|
-
model: "gpt-5.4-mini",
|
|
54
|
-
reasoningLevel: "medium",
|
|
55
|
-
mode: "full-auto",
|
|
56
|
-
planMode: true,
|
|
57
|
-
policy: {
|
|
58
|
-
approvalPolicy: "never",
|
|
59
|
-
sandboxMode: "danger-full-access",
|
|
60
|
-
networkAccess: "enabled",
|
|
61
|
-
writableRoots: ["C:/Repo/extra"],
|
|
62
|
-
serviceTier: "fast",
|
|
63
|
-
personality: "pragmatic",
|
|
64
|
-
},
|
|
65
|
-
}),
|
|
66
|
-
diagnostics: {
|
|
67
|
-
projectRoot: "C:\\Repo",
|
|
68
|
-
projectTrusted: true,
|
|
69
|
-
selectedProfile: null,
|
|
70
|
-
selectedProfileSource: null,
|
|
71
|
-
cliOverrides: [],
|
|
72
|
-
layers: [{ label: "test", status: "loaded" }],
|
|
73
|
-
ignoredEntries: [],
|
|
74
|
-
fieldSources: {
|
|
75
|
-
provider: "test",
|
|
76
|
-
model: "test",
|
|
77
|
-
reasoningLevel: "test",
|
|
78
|
-
mode: "test",
|
|
79
|
-
planMode: "test",
|
|
80
|
-
geminiCommandPath: "test",
|
|
81
|
-
"policy.approvalPolicy": "test",
|
|
82
|
-
"policy.sandboxMode": "test",
|
|
83
|
-
"policy.networkAccess": "test",
|
|
84
|
-
"policy.writableRoots": "test",
|
|
85
|
-
"policy.serviceTier": "test",
|
|
86
|
-
"policy.personality": "test",
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function createProvider(run: BackendProvider["run"]): BackendProvider {
|
|
93
|
-
return {
|
|
94
|
-
id: "codex-subprocess",
|
|
95
|
-
label: "Mock Codex",
|
|
96
|
-
description: "Mock provider",
|
|
97
|
-
authState: "delegated",
|
|
98
|
-
authLabel: "Mock",
|
|
99
|
-
statusMessage: "Mock",
|
|
100
|
-
supportsModels: () => true,
|
|
101
|
-
run,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
test("streams assistant deltas to stdout and progress/tool/error diagnostics to stderr", async () => {
|
|
106
|
-
const io = createIo();
|
|
107
|
-
const provider = createProvider((_prompt, _options, handlers) => {
|
|
108
|
-
handlers.onProgress?.({ id: "p1", source: "reasoning", text: "thinking" });
|
|
109
|
-
handlers.onToolActivity?.({
|
|
110
|
-
id: "tool-1",
|
|
111
|
-
command: "pwd",
|
|
112
|
-
status: "running",
|
|
113
|
-
startedAt: Date.now(),
|
|
114
|
-
});
|
|
115
|
-
handlers.onAssistantDelta?.("Hello ");
|
|
116
|
-
handlers.onAssistantDelta?.("world");
|
|
117
|
-
handlers.onResponse("Hello world");
|
|
118
|
-
return () => {};
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
const result = await runHeadlessExec(
|
|
122
|
-
{ prompt: "Prompt", launchArgs: createLaunchArgs(), workspaceRoot: "C:\\Repo" },
|
|
123
|
-
io,
|
|
124
|
-
{
|
|
125
|
-
resolveLayeredConfig: () => createLayeredConfig(),
|
|
126
|
-
getBackendProvider: () => provider,
|
|
127
|
-
loadProjectInstructions: () => ({ status: "missing" }),
|
|
128
|
-
},
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
assert.equal(result.exitCode, 0);
|
|
132
|
-
assert.equal(io.stdoutText(), "Hello world");
|
|
133
|
-
assert.doesNotMatch(`${io.stdoutText()}\n${io.stderrText()}`, /██████|Codexa v|Workspace:|Provider:|Context:/);
|
|
134
|
-
assert.match(io.stderrText(), /startup:/);
|
|
135
|
-
assert.match(io.stderrText(), /reasoning: thinking/);
|
|
136
|
-
assert.match(io.stderrText(), /tool: running: pwd/);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
test("emits final_answer_observed timing before provider response settles", async () => {
|
|
140
|
-
const io = createIo();
|
|
141
|
-
const provider = createProvider((_prompt, _options, handlers) => {
|
|
142
|
-
handlers.onAssistantDelta?.("READY");
|
|
143
|
-
handlers.onFinalAnswerObserved?.("READY");
|
|
144
|
-
handlers.onResponse("READY");
|
|
145
|
-
return () => {};
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
const result = await runHeadlessExec(
|
|
149
|
-
{
|
|
150
|
-
prompt: "Prompt",
|
|
151
|
-
launchArgs: createLaunchArgs(),
|
|
152
|
-
workspaceRoot: "C:\\Repo",
|
|
153
|
-
benchmarkDiagnostics: createHeadlessExecTiming({
|
|
154
|
-
enabled: true,
|
|
155
|
-
stderr: io.stderr,
|
|
156
|
-
startTimeMs: Date.now(),
|
|
157
|
-
}),
|
|
158
|
-
},
|
|
159
|
-
io,
|
|
160
|
-
{
|
|
161
|
-
resolveLayeredConfig: () => createLayeredConfig(),
|
|
162
|
-
getBackendProvider: () => provider,
|
|
163
|
-
loadProjectInstructions: () => ({ status: "missing" }),
|
|
164
|
-
},
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
assert.equal(result.exitCode, 0);
|
|
168
|
-
assert.match(io.stderrText(), /final_answer_observed/);
|
|
169
|
-
assert.match(io.stderrText(), /\[codexa exec timing\]/);
|
|
170
|
-
assert.match(io.stderrText(), /final_answer_character_count=5/);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
test("timing is silent when disabled", async () => {
|
|
174
|
-
const io = createIo();
|
|
175
|
-
const provider = createProvider((_prompt, _options, handlers) => {
|
|
176
|
-
handlers.onResponse("ok");
|
|
177
|
-
return () => {};
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
const result = await runHeadlessExec(
|
|
181
|
-
{ prompt: "Prompt", launchArgs: createLaunchArgs(), workspaceRoot: "C:\\Repo" },
|
|
182
|
-
io,
|
|
183
|
-
{
|
|
184
|
-
resolveLayeredConfig: () => createLayeredConfig(),
|
|
185
|
-
getBackendProvider: () => provider,
|
|
186
|
-
loadProjectInstructions: () => ({ status: "missing" }),
|
|
187
|
-
},
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
assert.equal(result.exitCode, 0);
|
|
191
|
-
assert.doesNotMatch(io.stderrText(), /\[codexa exec timing\]/);
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
test("raw prompt policy sends the exact prompt and skips project instructions", async () => {
|
|
195
|
-
const io = createIo();
|
|
196
|
-
const captured: Array<{ prompt: string; promptPolicy: string | undefined; projectInstructions: unknown }> = [];
|
|
197
|
-
let projectInstructionLoadCount = 0;
|
|
198
|
-
const provider = createProvider((prompt, options, handlers) => {
|
|
199
|
-
captured.push({
|
|
200
|
-
prompt,
|
|
201
|
-
promptPolicy: options.promptPolicy,
|
|
202
|
-
projectInstructions: options.projectInstructions,
|
|
203
|
-
});
|
|
204
|
-
handlers.onResponse("ok");
|
|
205
|
-
return () => {};
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
const result = await runHeadlessExec(
|
|
209
|
-
{
|
|
210
|
-
prompt: "Reply with exactly: CODEXA_READY",
|
|
211
|
-
launchArgs: createLaunchArgs(),
|
|
212
|
-
workspaceRoot: "C:\\Repo",
|
|
213
|
-
},
|
|
214
|
-
io,
|
|
215
|
-
{
|
|
216
|
-
resolveLayeredConfig: () => createLayeredConfig(),
|
|
217
|
-
getBackendProvider: () => provider,
|
|
218
|
-
loadProjectInstructions: () => {
|
|
219
|
-
projectInstructionLoadCount += 1;
|
|
220
|
-
return {
|
|
221
|
-
status: "loaded",
|
|
222
|
-
instructions: { path: "C:\\Repo\\AGENTS.md", content: "extra instructions" },
|
|
223
|
-
};
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
assert.equal(result.exitCode, 0);
|
|
229
|
-
assert.equal(projectInstructionLoadCount, 0);
|
|
230
|
-
assert.equal(captured[0]?.prompt, "Reply with exactly: CODEXA_READY");
|
|
231
|
-
assert.equal(captured[0]?.promptPolicy, "raw");
|
|
232
|
-
assert.equal(captured[0]?.projectInstructions, null);
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
test("wrapped prompt policy loads project instructions for compatibility", async () => {
|
|
236
|
-
const io = createIo();
|
|
237
|
-
let capturedProjectInstructions: unknown = null;
|
|
238
|
-
const provider = createProvider((_prompt, options, handlers) => {
|
|
239
|
-
capturedProjectInstructions = options.projectInstructions;
|
|
240
|
-
handlers.onResponse("ok");
|
|
241
|
-
return () => {};
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
const result = await runHeadlessExec(
|
|
245
|
-
{
|
|
246
|
-
prompt: "Prompt",
|
|
247
|
-
launchArgs: createLaunchArgs(),
|
|
248
|
-
workspaceRoot: "C:\\Repo",
|
|
249
|
-
promptPolicy: "wrapped",
|
|
250
|
-
},
|
|
251
|
-
io,
|
|
252
|
-
{
|
|
253
|
-
resolveLayeredConfig: () => createLayeredConfig(),
|
|
254
|
-
getBackendProvider: () => provider,
|
|
255
|
-
loadProjectInstructions: () => ({
|
|
256
|
-
status: "loaded",
|
|
257
|
-
instructions: { path: "C:\\Repo\\AGENTS.md", content: "extra instructions" },
|
|
258
|
-
}),
|
|
259
|
-
},
|
|
260
|
-
);
|
|
261
|
-
|
|
262
|
-
assert.equal(result.exitCode, 0);
|
|
263
|
-
assert.deepEqual(capturedProjectInstructions, {
|
|
264
|
-
path: "C:\\Repo\\AGENTS.md",
|
|
265
|
-
content: "extra instructions",
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
test("does not duplicate equivalent tool activity as progress", async () => {
|
|
270
|
-
const io = createIo();
|
|
271
|
-
const provider = createProvider((_prompt, _options, handlers) => {
|
|
272
|
-
handlers.onToolActivity?.({
|
|
273
|
-
id: "tool-1",
|
|
274
|
-
command: "Get-ChildItem",
|
|
275
|
-
status: "running",
|
|
276
|
-
startedAt: Date.now(),
|
|
277
|
-
});
|
|
278
|
-
handlers.onProgress?.({ id: "tool-1", source: "tool", text: "Running Get-ChildItem" });
|
|
279
|
-
handlers.onResponse("ok");
|
|
280
|
-
return () => {};
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
const result = await runHeadlessExec(
|
|
284
|
-
{ prompt: "Prompt", launchArgs: createLaunchArgs(), workspaceRoot: "C:\\Repo" },
|
|
285
|
-
io,
|
|
286
|
-
{
|
|
287
|
-
resolveLayeredConfig: () => createLayeredConfig(),
|
|
288
|
-
getBackendProvider: () => provider,
|
|
289
|
-
loadProjectInstructions: () => ({ status: "missing" }),
|
|
290
|
-
},
|
|
291
|
-
);
|
|
292
|
-
|
|
293
|
-
assert.equal(result.exitCode, 0);
|
|
294
|
-
assert.match(io.stderrText(), /tool: running: Get-ChildItem/);
|
|
295
|
-
assert.doesNotMatch(io.stderrText(), /tool: Running Get-ChildItem/);
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
test("returns exit code 0 on provider success without deltas", async () => {
|
|
299
|
-
const io = createIo();
|
|
300
|
-
const provider = createProvider((_prompt, _options, handlers) => {
|
|
301
|
-
handlers.onResponse("Final answer");
|
|
302
|
-
return () => {};
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
const result = await runHeadlessExec(
|
|
306
|
-
{ prompt: "Prompt", launchArgs: createLaunchArgs(), workspaceRoot: "C:\\Repo" },
|
|
307
|
-
io,
|
|
308
|
-
{
|
|
309
|
-
resolveLayeredConfig: () => createLayeredConfig(),
|
|
310
|
-
getBackendProvider: () => provider,
|
|
311
|
-
loadProjectInstructions: () => ({ status: "missing" }),
|
|
312
|
-
},
|
|
313
|
-
);
|
|
314
|
-
|
|
315
|
-
assert.equal(result.exitCode, 0);
|
|
316
|
-
assert.equal(io.stdoutText(), "Final answer");
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
test("keeps structured fallback events out of stdout", async () => {
|
|
320
|
-
const io = createIo();
|
|
321
|
-
const provider = createProvider((_prompt, _options, handlers) => {
|
|
322
|
-
handlers.onAssistantDelta?.("{\"type\":\"item.completed\",\"item\":{\"type\":\"agent_message\",\"text\":\"raw\"}}\n");
|
|
323
|
-
handlers.onAssistantDelta?.("Actual answer");
|
|
324
|
-
handlers.onResponse("Actual answer");
|
|
325
|
-
return () => {};
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
const result = await runHeadlessExec(
|
|
329
|
-
{ prompt: "Prompt", launchArgs: createLaunchArgs(), workspaceRoot: "C:\\Repo" },
|
|
330
|
-
io,
|
|
331
|
-
{
|
|
332
|
-
resolveLayeredConfig: () => createLayeredConfig(),
|
|
333
|
-
getBackendProvider: () => provider,
|
|
334
|
-
loadProjectInstructions: () => ({ status: "missing" }),
|
|
335
|
-
},
|
|
336
|
-
);
|
|
337
|
-
|
|
338
|
-
assert.equal(result.exitCode, 0);
|
|
339
|
-
assert.equal(io.stdoutText(), "Actual answer");
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
test("returns non-zero when provider is unavailable", async () => {
|
|
343
|
-
const io = createIo();
|
|
344
|
-
const provider = createProvider(undefined);
|
|
345
|
-
|
|
346
|
-
const result = await runHeadlessExec(
|
|
347
|
-
{ prompt: "Prompt", launchArgs: createLaunchArgs(), workspaceRoot: "C:\\Repo" },
|
|
348
|
-
io,
|
|
349
|
-
{
|
|
350
|
-
resolveLayeredConfig: () => createLayeredConfig(),
|
|
351
|
-
getBackendProvider: () => provider,
|
|
352
|
-
loadProjectInstructions: () => ({ status: "missing" }),
|
|
353
|
-
},
|
|
354
|
-
);
|
|
355
|
-
|
|
356
|
-
assert.equal(result.exitCode, HEADLESS_EXEC_PROVIDER_UNAVAILABLE);
|
|
357
|
-
assert.match(io.stderrText(), /unavailable/i);
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
test("returns non-zero on provider error", async () => {
|
|
361
|
-
const io = createIo();
|
|
362
|
-
const provider = createProvider((_prompt, _options, handlers) => {
|
|
363
|
-
handlers.onError("Provider exploded");
|
|
364
|
-
return () => {};
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
const result = await runHeadlessExec(
|
|
368
|
-
{ prompt: "Prompt", launchArgs: createLaunchArgs(), workspaceRoot: "C:\\Repo" },
|
|
369
|
-
io,
|
|
370
|
-
{
|
|
371
|
-
resolveLayeredConfig: () => createLayeredConfig(),
|
|
372
|
-
getBackendProvider: () => provider,
|
|
373
|
-
loadProjectInstructions: () => ({ status: "missing" }),
|
|
374
|
-
},
|
|
375
|
-
);
|
|
376
|
-
|
|
377
|
-
assert.equal(result.exitCode, HEADLESS_EXEC_RUN_FAILED);
|
|
378
|
-
assert.match(io.stderrText(), /Provider exploded/);
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
test("missing-file failure remains non-zero and visible", async () => {
|
|
382
|
-
const io = createIo();
|
|
383
|
-
const provider = createProvider((_prompt, _options, handlers) => {
|
|
384
|
-
handlers.onError("Process exited with code 1", "Get-Content: Cannot find path 'missing.txt' because it does not exist.");
|
|
385
|
-
return () => {};
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
const result = await runHeadlessExec(
|
|
389
|
-
{ prompt: "Read missing.txt", launchArgs: createLaunchArgs(), workspaceRoot: "C:\\Repo" },
|
|
390
|
-
io,
|
|
391
|
-
{
|
|
392
|
-
resolveLayeredConfig: () => createLayeredConfig(),
|
|
393
|
-
getBackendProvider: () => provider,
|
|
394
|
-
loadProjectInstructions: () => ({ status: "missing" }),
|
|
395
|
-
},
|
|
396
|
-
);
|
|
397
|
-
|
|
398
|
-
assert.equal(result.exitCode, HEADLESS_EXEC_RUN_FAILED);
|
|
399
|
-
assert.match(io.stderrText(), /missing\.txt/);
|
|
400
|
-
assert.match(io.stderrText(), /does not exist/);
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
test("forces planMode off while preserving other runtime settings", async () => {
|
|
404
|
-
const io = createIo();
|
|
405
|
-
const capturedRuntimes: ResolvedRuntimeConfig[] = [];
|
|
406
|
-
const provider = createProvider((_prompt, options, handlers) => {
|
|
407
|
-
capturedRuntimes.push(options.runtime);
|
|
408
|
-
handlers.onResponse("ok");
|
|
409
|
-
return () => {};
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
const result = await runHeadlessExec(
|
|
413
|
-
{ prompt: "Prompt", launchArgs: createLaunchArgs(), workspaceRoot: "C:\\Repo" },
|
|
414
|
-
io,
|
|
415
|
-
{
|
|
416
|
-
resolveLayeredConfig: () => createLayeredConfig(),
|
|
417
|
-
resolveRuntimeConfig,
|
|
418
|
-
getBackendProvider: () => provider,
|
|
419
|
-
loadProjectInstructions: () => ({ status: "missing" }),
|
|
420
|
-
},
|
|
421
|
-
);
|
|
422
|
-
|
|
423
|
-
assert.equal(result.exitCode, 0);
|
|
424
|
-
const capturedRuntime = capturedRuntimes[0];
|
|
425
|
-
assert.ok(capturedRuntime);
|
|
426
|
-
assert.equal(capturedRuntime.planMode, false);
|
|
427
|
-
assert.equal(capturedRuntime.model, "gpt-5.4-mini");
|
|
428
|
-
assert.equal(capturedRuntime.reasoningLevel, "medium");
|
|
429
|
-
assert.equal(capturedRuntime.mode, "full-auto");
|
|
430
|
-
assert.equal(capturedRuntime.policy.approvalPolicy, "never");
|
|
431
|
-
assert.equal(capturedRuntime.policy.sandboxMode, "danger-full-access");
|
|
432
|
-
assert.equal(capturedRuntime.policy.networkAccess, true);
|
|
433
|
-
assert.deepEqual(capturedRuntime.policy.writableRoots, ["C:\\Repo\\extra"]);
|
|
434
|
-
assert.equal(capturedRuntime.policy.serviceTier, "fast");
|
|
435
|
-
assert.equal(capturedRuntime.policy.personality, "pragmatic");
|
|
436
|
-
});
|