@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.
Files changed (206) hide show
  1. package/README.md +396 -100
  2. package/bin/codexa.js +62 -144
  3. package/package.json +14 -8
  4. package/src/app.tsx +596 -306
  5. package/src/commands/handler.ts +6 -6
  6. package/src/config/buildInfo.ts +2 -2
  7. package/src/config/layeredConfig.ts +1 -1
  8. package/src/config/persistence.ts +10 -0
  9. package/src/config/runtimeConfig.ts +1 -1
  10. package/src/config/settings.ts +8 -16
  11. package/src/config/trustStore.ts +1 -1
  12. package/src/config/updateCheckCache.ts +19 -1
  13. package/src/core/README.md +52 -0
  14. package/src/core/agent/loop.ts +282 -0
  15. package/src/core/agent/protocol.ts +211 -0
  16. package/src/core/agent/tools.ts +414 -0
  17. package/src/core/{codexExecArgs.ts → codex/codexExecArgs.ts} +2 -2
  18. package/src/core/{codexLaunch.ts → codex/codexLaunch.ts} +3 -3
  19. package/src/core/{codexPrompt.ts → codex/codexPrompt.ts} +3 -3
  20. package/src/core/debug/modelStateDebug.ts +34 -0
  21. package/src/core/executables/antigravityExecutable.ts +48 -0
  22. package/src/core/executables/codexExecutable.ts +1 -0
  23. package/src/core/executables/executableResolver.ts +65 -43
  24. package/src/core/perf/renderDebug.ts +10 -6
  25. package/src/core/process/processValidation.ts +9 -5
  26. package/src/core/providerLauncher/launcher.ts +59 -42
  27. package/src/core/providerLauncher/registry.ts +30 -14
  28. package/src/core/providerLauncher/types.ts +11 -9
  29. package/src/core/providerLauncher/workspaceConfig.ts +41 -26
  30. package/src/core/providerRuntime/anthropic.ts +7 -1
  31. package/src/core/providerRuntime/antigravity.ts +305 -0
  32. package/src/core/providerRuntime/claudeCodeDiscovery.ts +268 -22
  33. package/src/core/providerRuntime/claudeCodeDiscoveryDebug.ts +55 -0
  34. package/src/core/providerRuntime/contextMetadata.ts +12 -24
  35. package/src/core/providerRuntime/local.ts +129 -51
  36. package/src/core/providerRuntime/models.ts +22 -11
  37. package/src/core/providerRuntime/registry.ts +58 -31
  38. package/src/core/providerRuntime/types.ts +19 -14
  39. package/src/core/providers/codexSubprocess.ts +2 -2
  40. package/src/core/providers/types.ts +1 -1
  41. package/src/core/{attachments.ts → shared/attachments.ts} +27 -4
  42. package/src/core/{cleanupFastFail.ts → shared/cleanupFastFail.ts} +1 -1
  43. package/src/core/{hollowResponseFormat.ts → shared/hollowResponseFormat.ts} +1 -1
  44. package/src/core/terminal/clearFrameBoundary.ts +814 -0
  45. package/src/core/terminal/frameLock.ts +109 -0
  46. package/src/core/terminal/inkRenderReset.ts +123 -0
  47. package/src/core/terminal/terminalControl.ts +22 -0
  48. package/src/core/terminal/terminalTitle.ts +16 -102
  49. package/src/core/version/channel.ts +23 -0
  50. package/src/core/version/updateCheck.ts +193 -0
  51. package/src/core/{launchContext.ts → workspace/launchContext.ts} +32 -39
  52. package/src/core/{planStorage.ts → workspace/planStorage.ts} +2 -2
  53. package/src/core/{workspaceGuard.ts → workspace/workspaceGuard.ts} +97 -13
  54. package/src/headless/execRunner.ts +2 -2
  55. package/src/index.tsx +43 -89
  56. package/src/session/appSession.ts +10 -7
  57. package/src/session/chatLifecycle.ts +1 -1
  58. package/src/session/liveRenderScheduler.ts +1 -1
  59. package/src/session/types.ts +3 -2
  60. package/src/ui/ActionRequiredBlock.tsx +5 -5
  61. package/src/ui/ActivityBars.tsx +3 -3
  62. package/src/ui/ActivityIndicator.tsx +6 -6
  63. package/src/ui/AgentBlock.tsx +6 -6
  64. package/src/ui/AnimatedStatusText.tsx +1 -1
  65. package/src/ui/AppShell.tsx +670 -719
  66. package/src/ui/AttachmentImportPanel.tsx +8 -8
  67. package/src/ui/AuthPanel.tsx +20 -20
  68. package/src/ui/BottomComposer.tsx +158 -118
  69. package/src/ui/DashCard.tsx +3 -3
  70. package/src/ui/Markdown.tsx +17 -17
  71. package/src/ui/ModelPickerScreen.tsx +222 -42
  72. package/src/ui/ModelReasoningPicker.tsx +15 -15
  73. package/src/ui/Panel.tsx +3 -3
  74. package/src/ui/PlanActionPicker.tsx +6 -6
  75. package/src/ui/PlanReviewPanel.tsx +9 -9
  76. package/src/ui/ProviderPicker.tsx +735 -321
  77. package/src/ui/RunFooter.tsx +3 -3
  78. package/src/ui/RuntimeStatusBar.tsx +108 -0
  79. package/src/ui/SelectionPanel.tsx +8 -4
  80. package/src/ui/SettingsPanel.tsx +9 -9
  81. package/src/ui/Spinner.tsx +1 -1
  82. package/src/ui/TextEntryPanel.tsx +11 -11
  83. package/src/ui/ThinkingBlock.tsx +8 -8
  84. package/src/ui/Timeline.tsx +1625 -1472
  85. package/src/ui/TopHeader.tsx +437 -293
  86. package/src/ui/TranscriptShell.tsx +322 -0
  87. package/src/ui/TurnGroup.tsx +33 -33
  88. package/src/ui/UpdateAvailableCard.tsx +41 -0
  89. package/src/ui/UpdatePromptPanel.tsx +197 -0
  90. package/src/ui/focus.ts +3 -0
  91. package/src/ui/layout.ts +299 -25
  92. package/src/ui/layoutListWindow.ts +145 -0
  93. package/src/ui/logoVariants.ts +103 -0
  94. package/src/ui/modeDisplay.ts +12 -12
  95. package/src/ui/runtimeDisplay.ts +112 -0
  96. package/src/ui/textLayout.ts +15 -4
  97. package/src/ui/theme.tsx +274 -395
  98. package/src/ui/timelineMeasure.ts +218 -136
  99. package/scripts/audit-codexa-capabilities.mjs +0 -466
  100. package/scripts/gen-build-info.mjs +0 -33
  101. package/scripts/smoke-terminal-bench.mjs +0 -35
  102. package/src/appRenderStability.test.ts +0 -131
  103. package/src/commands/handler.test.ts +0 -655
  104. package/src/config/launchArgs.test.ts +0 -189
  105. package/src/config/layeredConfig.test.ts +0 -143
  106. package/src/config/persistence.test.ts +0 -114
  107. package/src/config/runtimeConfig.test.ts +0 -218
  108. package/src/config/settings.test.ts +0 -155
  109. package/src/config/trustStore.test.ts +0 -29
  110. package/src/core/attachments.test.ts +0 -155
  111. package/src/core/auth/codexAuth.test.ts +0 -68
  112. package/src/core/cleanupFastFail.test.ts +0 -76
  113. package/src/core/codex.ts +0 -124
  114. package/src/core/codexExecArgs.test.ts +0 -195
  115. package/src/core/codexLaunch.test.ts +0 -205
  116. package/src/core/codexPrompt.test.ts +0 -252
  117. package/src/core/executables/codexExecutable.test.ts +0 -212
  118. package/src/core/executables/executableResolver.test.ts +0 -129
  119. package/src/core/executables/geminiExecutable.test.ts +0 -116
  120. package/src/core/executables/pathSanityScan.test.ts +0 -47
  121. package/src/core/githubDiagnostics.test.ts +0 -92
  122. package/src/core/hollowResponseFormat.test.ts +0 -58
  123. package/src/core/launchContext.test.ts +0 -157
  124. package/src/core/models/codexCapabilities.test.ts +0 -45
  125. package/src/core/models/codexModelCapabilities.test.ts +0 -246
  126. package/src/core/models/modelSpecs.test.ts +0 -283
  127. package/src/core/perf/renderDebug.test.ts +0 -230
  128. package/src/core/planStorage.test.ts +0 -143
  129. package/src/core/process/CommandRunner.test.ts +0 -105
  130. package/src/core/projectInstructions.test.ts +0 -50
  131. package/src/core/providerLauncher/launcher.test.ts +0 -238
  132. package/src/core/providerLauncher/registry.test.ts +0 -324
  133. package/src/core/providerLauncher/workspaceConfig.test.ts +0 -638
  134. package/src/core/providerRuntime/anthropic.test.ts +0 -1120
  135. package/src/core/providerRuntime/capabilityProfile.test.ts +0 -311
  136. package/src/core/providerRuntime/contextMetadata.test.ts +0 -468
  137. package/src/core/providerRuntime/gemini.test.ts +0 -437
  138. package/src/core/providerRuntime/lmstudio.test.ts +0 -168
  139. package/src/core/providerRuntime/local.test.ts +0 -787
  140. package/src/core/providerRuntime/registry.test.ts +0 -233
  141. package/src/core/providers/codexJsonStream.test.ts +0 -148
  142. package/src/core/providers/codexSubprocess.test.ts +0 -68
  143. package/src/core/providers/codexTranscript.test.ts +0 -284
  144. package/src/core/terminal/startupClear.test.ts +0 -55
  145. package/src/core/terminal/terminalCapabilities.test.ts +0 -93
  146. package/src/core/terminal/terminalControl.test.ts +0 -75
  147. package/src/core/terminal/terminalSanitize.test.ts +0 -22
  148. package/src/core/terminal/terminalSelection.test.ts +0 -42
  149. package/src/core/terminal/terminalTitle.test.ts +0 -328
  150. package/src/core/updateCheck.test.ts +0 -194
  151. package/src/core/updateCheck.ts +0 -172
  152. package/src/core/workspaceActivity.test.ts +0 -163
  153. package/src/core/workspaceGuard.test.ts +0 -151
  154. package/src/core/workspaceRoot.test.ts +0 -23
  155. package/src/exec.test.ts +0 -13
  156. package/src/headless/execArgs.test.ts +0 -147
  157. package/src/headless/execRunner.test.ts +0 -436
  158. package/src/index.test.tsx +0 -620
  159. package/src/session/appSession.test.ts +0 -897
  160. package/src/session/chatLifecycle.test.ts +0 -64
  161. package/src/session/liveRenderScheduler.test.ts +0 -201
  162. package/src/session/planFlow.test.ts +0 -103
  163. package/src/session/planTranscript.test.ts +0 -65
  164. package/src/session/promptRunSchedule.test.ts +0 -36
  165. package/src/ui/ActivityIndicator.test.tsx +0 -58
  166. package/src/ui/AgentBlock.test.ts +0 -6
  167. package/src/ui/AnimatedStatusText.test.ts +0 -16
  168. package/src/ui/AppShell.test.tsx +0 -1776
  169. package/src/ui/AttachmentImportPanel.test.tsx +0 -204
  170. package/src/ui/BottomComposer.test.ts +0 -674
  171. package/src/ui/CodexLogo.tsx +0 -55
  172. package/src/ui/Markdown.test.ts +0 -157
  173. package/src/ui/ModelPickerProviderScope.test.tsx +0 -411
  174. package/src/ui/ModelPickerScreen.test.tsx +0 -99
  175. package/src/ui/ModelPickerState.test.tsx +0 -151
  176. package/src/ui/ModelReasoningPicker.test.tsx +0 -447
  177. package/src/ui/PlanReviewPanel.test.tsx +0 -267
  178. package/src/ui/PromptCardBorder.test.tsx +0 -161
  179. package/src/ui/ProviderPicker.test.tsx +0 -289
  180. package/src/ui/ProviderShortcut.test.tsx +0 -143
  181. package/src/ui/SettingsPanel.test.tsx +0 -233
  182. package/src/ui/StaticTranscriptItem.tsx +0 -56
  183. package/src/ui/Timeline.test.ts +0 -2067
  184. package/src/ui/TimelineNavigation.test.tsx +0 -201
  185. package/src/ui/TopHeader.test.tsx +0 -254
  186. package/src/ui/TurnGroup.test.tsx +0 -365
  187. package/src/ui/busyStatusAnimation.test.ts +0 -30
  188. package/src/ui/commandNormalize.test.ts +0 -142
  189. package/src/ui/diffRenderer.test.ts +0 -102
  190. package/src/ui/focusFlow.test.tsx +0 -1098
  191. package/src/ui/inputBuffer.test.ts +0 -151
  192. package/src/ui/layout.test.ts +0 -146
  193. package/src/ui/modeDisplay.test.ts +0 -42
  194. package/src/ui/runActivityView.test.ts +0 -89
  195. package/src/ui/runLifecycleView.test.tsx +0 -237
  196. package/src/ui/statusRenderIsolation.test.tsx +0 -654
  197. package/src/ui/terminalAnswerFormat.test.ts +0 -19
  198. package/src/ui/textLayout.test.ts +0 -18
  199. package/src/ui/themeFlow.test.ts +0 -53
  200. package/src/ui/timelineMeasureCache.test.ts +0 -986
  201. /package/src/core/{inputDebug.ts → debug/inputDebug.ts} +0 -0
  202. /package/src/core/{clipboard.ts → shared/clipboard.ts} +0 -0
  203. /package/src/core/{githubDiagnostics.ts → shared/githubDiagnostics.ts} +0 -0
  204. /package/src/core/{projectInstructions.ts → workspace/projectInstructions.ts} +0 -0
  205. /package/src/core/{workspaceActivity.ts → workspace/workspaceActivity.ts} +0 -0
  206. /package/src/core/{workspaceRoot.ts → workspace/workspaceRoot.ts} +0 -0
@@ -1,163 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { mkdtempSync, mkdirSync, rmSync, unlinkSync, writeFileSync } from "fs";
3
- import { tmpdir } from "os";
4
- import { join } from "path";
5
- import test from "node:test";
6
- import {
7
- captureWorkspaceSnapshot,
8
- createWorkspaceActivityTracker,
9
- createTextDiffExcerpt,
10
- diffWorkspaceSnapshots,
11
- } from "./workspaceActivity.js";
12
-
13
- function createTempWorkspace(): string {
14
- return mkdtempSync(join(tmpdir(), "codex-workspace-activity-"));
15
- }
16
-
17
- test("detects created files in the workspace snapshot diff", () => {
18
- const root = createTempWorkspace();
19
- try {
20
- const before = captureWorkspaceSnapshot(root);
21
- writeFileSync(join(root, "new-file.ts"), "const value = 1;\n", "utf8");
22
- const after = captureWorkspaceSnapshot(root);
23
- const activity = diffWorkspaceSnapshots(before, after, 123);
24
-
25
- assert.equal(activity.length, 1);
26
- assert.equal(activity[0]?.operation, "created");
27
- assert.equal(activity[0]?.path, "new-file.ts");
28
- assert.equal(activity[0]?.addedLines, 1);
29
- } finally {
30
- rmSync(root, { recursive: true, force: true });
31
- }
32
- });
33
-
34
- test("detects modified files with diff preview", () => {
35
- const root = createTempWorkspace();
36
- try {
37
- const file = join(root, "edited.py");
38
- writeFileSync(file, "print('before')\nvalue = 1\n", "utf8");
39
- const before = captureWorkspaceSnapshot(root);
40
-
41
- writeFileSync(file, "print('after')\nvalue = 2\nextra = True\n", "utf8");
42
- const after = captureWorkspaceSnapshot(root);
43
- const activity = diffWorkspaceSnapshots(before, after, 456);
44
-
45
- assert.equal(activity.length, 1);
46
- assert.equal(activity[0]?.operation, "modified");
47
- assert.equal(activity[0]?.path, "edited.py");
48
- assert.equal(activity[0]?.addedLines, 3);
49
- assert.equal(activity[0]?.removedLines, 2);
50
- assert.equal(activity[0]?.diffLines?.[0]?.kind, "removed");
51
- assert.equal(activity[0]?.diffLines?.at(-1)?.kind, "added");
52
- } finally {
53
- rmSync(root, { recursive: true, force: true });
54
- }
55
- });
56
-
57
- test("detects deleted files", () => {
58
- const root = createTempWorkspace();
59
- try {
60
- const file = join(root, "gone.txt");
61
- writeFileSync(file, "goodbye\n", "utf8");
62
- const before = captureWorkspaceSnapshot(root);
63
-
64
- unlinkSync(file);
65
- const after = captureWorkspaceSnapshot(root);
66
- const activity = diffWorkspaceSnapshots(before, after, 789);
67
-
68
- assert.equal(activity.length, 1);
69
- assert.equal(activity[0]?.operation, "deleted");
70
- assert.equal(activity[0]?.path, "gone.txt");
71
- assert.equal(activity[0]?.removedLines, 1);
72
- } finally {
73
- rmSync(root, { recursive: true, force: true });
74
- }
75
- });
76
-
77
- test("ignores excluded directories like node_modules and .git", () => {
78
- const root = createTempWorkspace();
79
- try {
80
- const before = captureWorkspaceSnapshot(root);
81
- mkdirSync(join(root, "node_modules"), { recursive: true });
82
- mkdirSync(join(root, ".git"), { recursive: true });
83
- writeFileSync(join(root, "node_modules", "ignored.js"), "console.log('x')", "utf8");
84
- writeFileSync(join(root, ".git", "ignored.txt"), "internal", "utf8");
85
- const after = captureWorkspaceSnapshot(root);
86
- const activity = diffWorkspaceSnapshots(before, after, 111);
87
-
88
- assert.equal(activity.length, 0);
89
- } finally {
90
- rmSync(root, { recursive: true, force: true });
91
- }
92
- });
93
-
94
- test("workspace activity tracker can reuse a provided initial snapshot", async () => {
95
- const root = createTempWorkspace();
96
- try {
97
- writeFileSync(join(root, "edited.txt"), "before\n", "utf8");
98
- writeFileSync(join(root, "gone.txt"), "delete me\n", "utf8");
99
- const before = captureWorkspaceSnapshot(root);
100
-
101
- writeFileSync(join(root, "new-file.ts"), "const value = 1;\n", "utf8");
102
- writeFileSync(join(root, "edited.txt"), "after\n", "utf8");
103
- unlinkSync(join(root, "gone.txt"));
104
-
105
- const activity = await new Promise<ReturnType<typeof diffWorkspaceSnapshots>>((resolve, reject) => {
106
- let tracker: ReturnType<typeof createWorkspaceActivityTracker> | null = null;
107
- const timeout = setTimeout(() => {
108
- tracker?.stop();
109
- reject(new Error("Timed out waiting for workspace activity."));
110
- }, 500);
111
- tracker = createWorkspaceActivityTracker({
112
- rootDir: root,
113
- initialSnapshot: before,
114
- pollIntervalMs: 10,
115
- onActivity: (items) => {
116
- clearTimeout(timeout);
117
- tracker?.stop();
118
- resolve(items);
119
- },
120
- });
121
- });
122
-
123
- const operationsByPath = new Map(activity.map((item) => [item.path, item.operation]));
124
- assert.equal(operationsByPath.get("new-file.ts"), "created");
125
- assert.equal(operationsByPath.get("edited.txt"), "modified");
126
- assert.equal(operationsByPath.get("gone.txt"), "deleted");
127
- } finally {
128
- rmSync(root, { recursive: true, force: true });
129
- }
130
- });
131
-
132
- test("skips inline diff previews for oversized files", () => {
133
- const root = createTempWorkspace();
134
- try {
135
- const file = join(root, "large.txt");
136
- const largeContent = `${"a".repeat(129 * 1024)}\n`;
137
- writeFileSync(file, largeContent, "utf8");
138
- const before = captureWorkspaceSnapshot(root);
139
-
140
- writeFileSync(file, `${largeContent}tail\n`, "utf8");
141
- const after = captureWorkspaceSnapshot(root);
142
- const activity = diffWorkspaceSnapshots(before, after, 222);
143
-
144
- assert.equal(activity.length, 1);
145
- assert.equal(activity[0]?.operation, "modified");
146
- assert.equal(activity[0]?.diffLines, undefined);
147
- } finally {
148
- rmSync(root, { recursive: true, force: true });
149
- }
150
- });
151
-
152
- test("creates green/red diff excerpts for mixed edits", () => {
153
- const diff = createTextDiffExcerpt(
154
- ["alpha", "beta", "gamma"].join("\n"),
155
- ["alpha", "beta-2", "gamma", "delta"].join("\n"),
156
- );
157
-
158
- assert(diff);
159
- assert.equal(diff.addedLines, 2);
160
- assert.equal(diff.removedLines, 1);
161
- assert.equal(diff.diffLines?.some((line) => line.kind === "added"), true);
162
- assert.equal(diff.diffLines?.some((line) => line.kind === "removed"), true);
163
- });
@@ -1,151 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import {
4
- containsDirectoryNavigationCommand,
5
- findOutsideWorkspacePaths,
6
- getPromptWorkspaceGuardMessage,
7
- getShellWorkspaceGuardMessage,
8
- isPathInsideAllowedRoots,
9
- isPathInsideWorkspace,
10
- resolveWorkspacePath,
11
- } from "./workspaceGuard.js";
12
- import { normalizeWorkspaceRoot } from "./workspaceRoot.js";
13
-
14
- const workspaceRoot = normalizeWorkspaceRoot("C:/Users/Example/OneDrive/Desktop/3-Python/Programs/2-Personal/20-Tester");
15
-
16
- test("allows absolute paths inside the locked workspace", () => {
17
- const violations = findOutsideWorkspacePaths(
18
- "Please update C:\\Users\\Example\\OneDrive\\Desktop\\3-Python\\Programs\\2-Personal\\20-Tester\\src\\main.py",
19
- workspaceRoot,
20
- );
21
-
22
- assert.deepEqual(violations, []);
23
- });
24
-
25
- test("blocks absolute paths outside the locked workspace", () => {
26
- const violations = findOutsideWorkspacePaths(
27
- "Please edit C:\\Users\\Example\\Desktop\\Other\\notes.txt",
28
- workspaceRoot,
29
- );
30
-
31
- assert.equal(violations.length, 1);
32
- assert.equal(
33
- violations[0]?.normalizedPath,
34
- "C:\\Users\\Example\\Desktop\\Other\\notes.txt",
35
- );
36
- });
37
-
38
- test("parses quoted windows paths with spaces", () => {
39
- const violations = findOutsideWorkspacePaths(
40
- "Use \"C:\\Users\\Example\\Desktop\\Other Folder\\notes file.txt\" instead",
41
- workspaceRoot,
42
- );
43
-
44
- assert.equal(violations.length, 1);
45
- assert.equal(
46
- violations[0]?.normalizedPath,
47
- "C:\\Users\\Example\\Desktop\\Other Folder\\notes file.txt",
48
- );
49
- });
50
-
51
- test("resolves relative paths inside the workspace", () => {
52
- assert.equal(
53
- resolveWorkspacePath("src\\main.py", workspaceRoot),
54
- "C:\\Users\\Example\\OneDrive\\Desktop\\3-Python\\Programs\\2-Personal\\20-Tester\\src\\main.py",
55
- );
56
- assert.equal(isPathInsideWorkspace("src\\main.py", workspaceRoot), true);
57
- });
58
-
59
- test("blocks explicit relative paths that escape the workspace", () => {
60
- const violations = findOutsideWorkspacePaths("Edit ..\\outside.txt", workspaceRoot);
61
-
62
- assert.equal(violations.length, 1);
63
- assert.equal(
64
- violations[0]?.normalizedPath,
65
- "C:\\Users\\Example\\OneDrive\\Desktop\\3-Python\\Programs\\2-Personal\\outside.txt",
66
- );
67
- });
68
-
69
- test("treats same-path drive letter case differences as inside the workspace", () => {
70
- assert.equal(
71
- isPathInsideWorkspace(
72
- "c:\\users\\Example\\onedrive\\desktop\\3-python\\programs\\2-personal\\20-tester\\src\\main.py",
73
- workspaceRoot,
74
- ),
75
- true,
76
- );
77
- });
78
-
79
- test("allows configured writable roots outside the locked workspace", () => {
80
- const extraRoot = "C:\\Users\\Example\\Desktop\\Allowed Root";
81
-
82
- assert.equal(
83
- isPathInsideAllowedRoots("C:\\Users\\Example\\Desktop\\Allowed Root\\notes.txt", workspaceRoot, [extraRoot]),
84
- true,
85
- );
86
-
87
- const promptMessage = getPromptWorkspaceGuardMessage(
88
- "Edit \"C:\\Users\\Example\\Desktop\\Allowed Root\\notes.txt\"",
89
- workspaceRoot,
90
- [extraRoot],
91
- );
92
- assert.equal(promptMessage, null);
93
-
94
- const shellMessage = getShellWorkspaceGuardMessage(
95
- "type \"C:\\Users\\Example\\Desktop\\Allowed Root\\notes.txt\"",
96
- workspaceRoot,
97
- [extraRoot],
98
- );
99
- assert.equal(shellMessage, null);
100
- });
101
-
102
- test("still blocks paths outside the workspace and configured writable roots", () => {
103
- const extraRoot = "C:\\Users\\Example\\Desktop\\Allowed Root";
104
- const message = getPromptWorkspaceGuardMessage(
105
- "Edit C:\\Users\\Example\\Desktop\\Other\\notes.txt",
106
- workspaceRoot,
107
- [extraRoot],
108
- );
109
-
110
- assert(message);
111
- assert.match(message, /Allowed writable roots:/i);
112
- assert.match(message, /Allowed Root/i);
113
- });
114
-
115
- test("returns a prompt guard message before a run starts", () => {
116
- const message = getPromptWorkspaceGuardMessage(
117
- "Edit C:\\Users\\Example\\Desktop\\Other\\notes.txt",
118
- workspaceRoot,
119
- );
120
-
121
- assert(message);
122
- assert.match(message, /Run blocked/i);
123
- assert.match(message, /Locked workspace:/i);
124
- });
125
-
126
- test("blocks directory-changing shell commands", () => {
127
- assert.equal(containsDirectoryNavigationCommand("cd .."), true);
128
- assert.equal(containsDirectoryNavigationCommand("Set-Location .."), true);
129
- assert.equal(containsDirectoryNavigationCommand("pushd .."), true);
130
-
131
- const message = getShellWorkspaceGuardMessage("cd ..", workspaceRoot);
132
- assert(message);
133
- assert.match(message, /Directory-changing commands/i);
134
- });
135
-
136
- test("blocks shell commands that reference outside absolute paths", () => {
137
- const message = getShellWorkspaceGuardMessage(
138
- "type C:\\Users\\Example\\Desktop\\Other\\notes.txt",
139
- workspaceRoot,
140
- );
141
-
142
- assert(message);
143
- assert.match(message, /Outside path references:/i);
144
- });
145
-
146
- test("blocks shell commands that reference escaping relative paths", () => {
147
- const message = getShellWorkspaceGuardMessage("type ..\\outside.txt", workspaceRoot);
148
-
149
- assert(message);
150
- assert.match(message, /Outside path references:/i);
151
- });
@@ -1,23 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import { normalizeWorkspaceRoot, resolveWorkspaceRoot } from "./workspaceRoot.js";
4
-
5
- test("prefers CODEX_WORKSPACE_ROOT when provided", () => {
6
- const originalWorkspace = process.env.CODEX_WORKSPACE_ROOT;
7
- try {
8
- process.env.CODEX_WORKSPACE_ROOT = "D:/project/";
9
- assert.equal(resolveWorkspaceRoot(), normalizeWorkspaceRoot("D:/project/"));
10
- } finally {
11
- process.env.CODEX_WORKSPACE_ROOT = originalWorkspace;
12
- }
13
- });
14
-
15
- test("falls back to process.cwd when no workspace override exists", () => {
16
- const originalWorkspace = process.env.CODEX_WORKSPACE_ROOT;
17
- try {
18
- delete process.env.CODEX_WORKSPACE_ROOT;
19
- assert.equal(resolveWorkspaceRoot(), normalizeWorkspaceRoot(process.cwd()));
20
- } finally {
21
- process.env.CODEX_WORKSPACE_ROOT = originalWorkspace;
22
- }
23
- });
package/src/exec.test.ts DELETED
@@ -1,13 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { readFileSync } from "node:fs";
3
- import { fileURLToPath } from "node:url";
4
- import test from "node:test";
5
-
6
- test("codexa exec entrypoint does not import interactive UI modules", () => {
7
- const source = readFileSync(fileURLToPath(new URL("./exec.ts", import.meta.url)), "utf8");
8
-
9
- assert.doesNotMatch(source, /from\s+["']\.\/index(?:\.js)?["']/);
10
- assert.doesNotMatch(source, /from\s+["']\.\/app(?:\.js)?["']/);
11
- assert.doesNotMatch(source, /from\s+["']ink["']/);
12
- assert.doesNotMatch(source, /from\s+["']react["']/);
13
- });
@@ -1,147 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import { parseHeadlessExecArgs } from "./execArgs.js";
4
-
5
- test("parses codexa exec positional prompt", () => {
6
- const parsed = parseHeadlessExecArgs(["Print", "the", "directory"]);
7
-
8
- assert.equal(parsed.ok, true);
9
- if (!parsed.ok) return;
10
- assert.equal(parsed.value.prompt, "Print the directory");
11
- assert.equal(parsed.value.promptPolicy, "raw");
12
- assert.equal(parsed.value.launchArgs.initialPrompt, "Print the directory");
13
- });
14
-
15
- test("parses codexa exec --prompt value", () => {
16
- const parsed = parseHeadlessExecArgs(["--prompt", "Print the directory"]);
17
-
18
- assert.equal(parsed.ok, true);
19
- if (!parsed.ok) return;
20
- assert.equal(parsed.value.prompt, "Print the directory");
21
- });
22
-
23
- test("parses codexa exec --prompt=value", () => {
24
- const parsed = parseHeadlessExecArgs(["--prompt=Print the directory"]);
25
-
26
- assert.equal(parsed.ok, true);
27
- if (!parsed.ok) return;
28
- assert.equal(parsed.value.prompt, "Print the directory");
29
- });
30
-
31
- test("rejects missing and empty prompts", () => {
32
- const missing = parseHeadlessExecArgs([]);
33
- assert.equal(missing.ok, false);
34
- if (!missing.ok) {
35
- assert.match(missing.error, /missing prompt/i);
36
- }
37
-
38
- const empty = parseHeadlessExecArgs(["--prompt", " "]);
39
- assert.equal(empty.ok, false);
40
- if (!empty.ok) {
41
- assert.match(empty.error, /--prompt/i);
42
- }
43
- });
44
-
45
- test("parses codexa exec --reasoning value", () => {
46
- const parsed = parseHeadlessExecArgs(["--reasoning", "medium", "Print files"]);
47
-
48
- assert.equal(parsed.ok, true);
49
- if (!parsed.ok) return;
50
- assert.equal(parsed.value.prompt, "Print files");
51
- assert.deepEqual(parsed.value.launchArgs.configOverrides, ["model_reasoning_effort=medium"]);
52
- assert.deepEqual(parsed.value.launchArgs.passthroughArgs, ["--reasoning", "medium"]);
53
- });
54
-
55
- test("parses codexa exec --reasoning=value", () => {
56
- const parsed = parseHeadlessExecArgs(["--reasoning=high", "Print files"]);
57
-
58
- assert.equal(parsed.ok, true);
59
- if (!parsed.ok) return;
60
- assert.equal(parsed.value.prompt, "Print files");
61
- assert.deepEqual(parsed.value.launchArgs.configOverrides, ["model_reasoning_effort=high"]);
62
- assert.deepEqual(parsed.value.launchArgs.passthroughArgs, ["--reasoning=high"]);
63
- });
64
-
65
- test("parses timing and prompt policy flags without forwarding them to Codex", () => {
66
- const parsed = parseHeadlessExecArgs([
67
- "--timing",
68
- "--codexa-prompt-policy",
69
- "wrapped",
70
- "Print files",
71
- ]);
72
-
73
- assert.equal(parsed.ok, true);
74
- if (!parsed.ok) return;
75
- assert.equal(parsed.value.timing, true);
76
- assert.equal(parsed.value.promptPolicy, "wrapped");
77
- assert.equal(parsed.value.prompt, "Print files");
78
- assert.deepEqual(parsed.value.launchArgs.passthroughArgs, []);
79
- });
80
-
81
- test("rejects invalid prompt policy values", () => {
82
- const parsed = parseHeadlessExecArgs(["--codexa-prompt-policy", "verbose", "Prompt"]);
83
-
84
- assert.equal(parsed.ok, false);
85
- if (!parsed.ok) {
86
- assert.match(parsed.error, /codexa-prompt-policy/i);
87
- }
88
- });
89
-
90
- test("parses codexa exec --model and --reasoning together", () => {
91
- const parsed = parseHeadlessExecArgs([
92
- "--model", "gpt-5.4-mini",
93
- "--reasoning", "medium",
94
- "Reply with exactly: CODEXA_READY",
95
- ]);
96
-
97
- assert.equal(parsed.ok, true);
98
- if (!parsed.ok) return;
99
- assert.equal(parsed.value.prompt, "Reply with exactly: CODEXA_READY");
100
- assert.deepEqual(parsed.value.launchArgs.configOverrides, [
101
- "model=\"gpt-5.4-mini\"",
102
- "model_reasoning_effort=medium",
103
- ]);
104
- });
105
-
106
- test("preserves profile and repeated config overrides", () => {
107
- const parsed = parseHeadlessExecArgs([
108
- "--benchmark-diagnostics",
109
- "--skip-git-repo-check",
110
- "--profile",
111
- "bench",
112
- "--model",
113
- "gpt-5.4-mini",
114
- "-c",
115
- "model_reasoning_effort=medium",
116
- "--config",
117
- "sandbox_mode=\"workspace-write\"",
118
- "--config=approval_policy=\"never\"",
119
- "Print",
120
- "files",
121
- ]);
122
-
123
- assert.equal(parsed.ok, true);
124
- if (!parsed.ok) return;
125
- assert.equal(parsed.value.benchmarkDiagnostics, true);
126
- assert.equal(parsed.value.timing, true);
127
- assert.equal(parsed.value.prompt, "Print files");
128
- assert.equal(parsed.value.launchArgs.profile, "bench");
129
- assert.deepEqual(parsed.value.launchArgs.configOverrides, [
130
- "model=\"gpt-5.4-mini\"",
131
- "model_reasoning_effort=medium",
132
- "sandbox_mode=\"workspace-write\"",
133
- "approval_policy=\"never\"",
134
- ]);
135
- assert.deepEqual(parsed.value.launchArgs.passthroughArgs, [
136
- "--skip-git-repo-check",
137
- "--profile",
138
- "bench",
139
- "--model",
140
- "gpt-5.4-mini",
141
- "-c",
142
- "model_reasoning_effort=medium",
143
- "--config",
144
- "sandbox_mode=\"workspace-write\"",
145
- "--config=approval_policy=\"never\"",
146
- ]);
147
- });