@golba98/codexa 1.0.1 → 1.0.3

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 (234) hide show
  1. package/README.md +391 -94
  2. package/package.json +14 -8
  3. package/src/app.tsx +196 -63
  4. package/src/commands/handler.ts +9 -4
  5. package/src/config/buildInfo.ts +3 -0
  6. package/src/config/launchArgs.ts +10 -0
  7. package/src/config/layeredConfig.ts +0 -0
  8. package/src/config/persistence.ts +51 -0
  9. package/src/config/runtimeConfig.ts +4 -0
  10. package/src/config/settings.ts +6 -13
  11. package/src/config/toml-serialize.ts +0 -0
  12. package/src/config/trustStore.ts +0 -0
  13. package/src/config/updateCheckCache.ts +63 -0
  14. package/src/core/attachments.ts +0 -0
  15. package/src/core/auth/codexAuth.ts +0 -0
  16. package/src/core/channel.ts +23 -0
  17. package/src/core/cleanupFastFail.ts +0 -0
  18. package/src/core/clipboard.ts +0 -0
  19. package/src/core/codex.ts +0 -0
  20. package/src/core/codexExecArgs.ts +0 -0
  21. package/src/core/codexLaunch.ts +0 -0
  22. package/src/core/codexPrompt.ts +0 -0
  23. package/src/core/executables/claudeExecutable.ts +0 -0
  24. package/src/core/executables/codexExecutable.ts +1 -0
  25. package/src/core/executables/executableResolver.ts +61 -43
  26. package/src/core/executables/geminiExecutable.ts +0 -0
  27. package/src/core/githubDiagnostics.ts +0 -0
  28. package/src/core/hollowResponseFormat.ts +0 -0
  29. package/src/core/inputDebug.ts +0 -0
  30. package/src/core/launchContext.ts +33 -33
  31. package/src/core/models/codexCapabilities.ts +0 -0
  32. package/src/core/models/codexModelCapabilities.ts +0 -0
  33. package/src/core/models/modelSpecs.ts +0 -0
  34. package/src/core/perf/profiler.ts +0 -0
  35. package/src/core/perf/renderDebug.ts +0 -0
  36. package/src/core/planStorage.ts +0 -0
  37. package/src/core/process/CommandRunner.ts +0 -0
  38. package/src/core/process/processValidation.ts +9 -5
  39. package/src/core/projectInstructions.ts +0 -0
  40. package/src/core/providerLauncher/launcher.ts +59 -42
  41. package/src/core/providerLauncher/registry.ts +0 -0
  42. package/src/core/providerLauncher/types.ts +0 -0
  43. package/src/core/providerLauncher/workspaceConfig.ts +0 -0
  44. package/src/core/providerRuntime/anthropic.ts +0 -0
  45. package/src/core/providerRuntime/capabilityProfile.ts +0 -0
  46. package/src/core/providerRuntime/claudeCodeDiscovery.ts +0 -0
  47. package/src/core/providerRuntime/contextMetadata.ts +0 -0
  48. package/src/core/providerRuntime/gemini.ts +0 -0
  49. package/src/core/providerRuntime/lmstudio.ts +0 -0
  50. package/src/core/providerRuntime/local.ts +0 -0
  51. package/src/core/providerRuntime/models.ts +0 -0
  52. package/src/core/providerRuntime/reasoning.ts +0 -0
  53. package/src/core/providerRuntime/registry.ts +0 -0
  54. package/src/core/providerRuntime/types.ts +0 -0
  55. package/src/core/providers/codexJsonStream.ts +0 -0
  56. package/src/core/providers/codexSubprocess.ts +0 -0
  57. package/src/core/providers/codexTranscript.ts +0 -0
  58. package/src/core/providers/openaiNative.ts +0 -0
  59. package/src/core/providers/registry.ts +0 -0
  60. package/src/core/providers/types.ts +0 -0
  61. package/src/core/terminal/startupClear.ts +20 -0
  62. package/src/core/terminal/terminalCapabilities.ts +0 -0
  63. package/src/core/terminal/terminalControl.ts +0 -0
  64. package/src/core/terminal/terminalSanitize.ts +0 -0
  65. package/src/core/terminal/terminalSelection.ts +0 -0
  66. package/src/core/terminal/terminalTitle.ts +0 -0
  67. package/src/core/updateCheck.ts +188 -0
  68. package/src/core/workspaceActivity.ts +0 -0
  69. package/src/core/workspaceGuard.ts +0 -0
  70. package/src/core/workspaceRoot.ts +0 -0
  71. package/src/exec.ts +0 -0
  72. package/src/headless/execArgs.ts +1 -0
  73. package/src/headless/execRunner.ts +0 -0
  74. package/src/index.tsx +13 -9
  75. package/src/session/appSession.ts +0 -0
  76. package/src/session/chatLifecycle.ts +0 -0
  77. package/src/session/liveRenderScheduler.ts +0 -0
  78. package/src/session/planFlow.ts +0 -0
  79. package/src/session/planTranscript.ts +0 -0
  80. package/src/session/promptRunSchedule.ts +0 -0
  81. package/src/session/types.ts +2 -1
  82. package/src/test/runtimeTestUtils.ts +0 -0
  83. package/src/types/react-dom.d.ts +0 -0
  84. package/src/ui/ActionRequiredBlock.tsx +5 -5
  85. package/src/ui/ActivityBars.tsx +3 -3
  86. package/src/ui/ActivityIndicator.tsx +6 -6
  87. package/src/ui/AgentBlock.tsx +6 -6
  88. package/src/ui/AnimatedStatusText.tsx +1 -1
  89. package/src/ui/AppShell.tsx +13 -5
  90. package/src/ui/AttachmentImportPanel.tsx +8 -8
  91. package/src/ui/AuthPanel.tsx +20 -20
  92. package/src/ui/BackendPicker.tsx +0 -0
  93. package/src/ui/BottomComposer.tsx +117 -78
  94. package/src/ui/DashCard.tsx +3 -3
  95. package/src/ui/Markdown.tsx +17 -17
  96. package/src/ui/ModePicker.tsx +0 -0
  97. package/src/ui/ModelPicker.tsx +0 -0
  98. package/src/ui/ModelPickerScreen.tsx +10 -10
  99. package/src/ui/ModelReasoningPicker.tsx +14 -14
  100. package/src/ui/Panel.tsx +3 -3
  101. package/src/ui/PermissionsPanel.tsx +0 -0
  102. package/src/ui/PlanActionPicker.tsx +6 -6
  103. package/src/ui/PlanReviewPanel.tsx +8 -8
  104. package/src/ui/ProviderPicker.tsx +18 -18
  105. package/src/ui/ReasoningPicker.tsx +0 -0
  106. package/src/ui/RunFooter.tsx +3 -3
  107. package/src/ui/SelectionPanel.tsx +4 -4
  108. package/src/ui/SettingsPanel.tsx +8 -8
  109. package/src/ui/Spinner.tsx +1 -1
  110. package/src/ui/StaticIntroItem.tsx +0 -0
  111. package/src/ui/StaticTranscriptItem.tsx +0 -0
  112. package/src/ui/TextEntryPanel.tsx +10 -10
  113. package/src/ui/ThemePicker.tsx +0 -0
  114. package/src/ui/ThinkingBlock.tsx +8 -8
  115. package/src/ui/Timeline.tsx +21 -17
  116. package/src/ui/TopHeader.tsx +421 -257
  117. package/src/ui/TurnGroup.tsx +31 -31
  118. package/src/ui/UpdateAvailableCard.tsx +41 -0
  119. package/src/ui/UpdatePromptPanel.tsx +203 -0
  120. package/src/ui/busyStatusAnimation.ts +0 -0
  121. package/src/ui/commandNormalize.ts +0 -0
  122. package/src/ui/diffRenderer.ts +0 -0
  123. package/src/ui/focus.ts +3 -0
  124. package/src/ui/inputBuffer.ts +0 -0
  125. package/src/ui/layout.ts +1 -1
  126. package/src/ui/logoVariants.ts +107 -0
  127. package/src/ui/modeDisplay.ts +12 -12
  128. package/src/ui/outputPipeline.ts +0 -0
  129. package/src/ui/progressEntries.ts +0 -0
  130. package/src/ui/runActivityView.ts +0 -0
  131. package/src/ui/runtimeDisplay.ts +100 -0
  132. package/src/ui/slashCommands.ts +0 -0
  133. package/src/ui/terminalAnswerFormat.ts +0 -0
  134. package/src/ui/textLayout.ts +0 -0
  135. package/src/ui/theme.tsx +274 -395
  136. package/src/ui/themeFlow.ts +0 -0
  137. package/src/ui/timelineMeasure.ts +29 -19
  138. package/src/ui/useThrottledValue.ts +0 -0
  139. package/scripts/audit-codexa-capabilities.mjs +0 -466
  140. package/scripts/smoke-terminal-bench.mjs +0 -35
  141. package/src/appRenderStability.test.ts +0 -131
  142. package/src/commands/handler.test.ts +0 -643
  143. package/src/config/launchArgs.test.ts +0 -158
  144. package/src/config/layeredConfig.test.ts +0 -143
  145. package/src/config/persistence.test.ts +0 -110
  146. package/src/config/runtimeConfig.test.ts +0 -218
  147. package/src/config/settings.test.ts +0 -155
  148. package/src/config/trustStore.test.ts +0 -29
  149. package/src/core/attachments.test.ts +0 -155
  150. package/src/core/auth/codexAuth.test.ts +0 -68
  151. package/src/core/cleanupFastFail.test.ts +0 -76
  152. package/src/core/codexExecArgs.test.ts +0 -195
  153. package/src/core/codexLaunch.test.ts +0 -205
  154. package/src/core/codexPrompt.test.ts +0 -252
  155. package/src/core/executables/codexExecutable.test.ts +0 -212
  156. package/src/core/executables/executableResolver.test.ts +0 -129
  157. package/src/core/executables/geminiExecutable.test.ts +0 -116
  158. package/src/core/executables/pathSanityScan.test.ts +0 -47
  159. package/src/core/githubDiagnostics.test.ts +0 -92
  160. package/src/core/hollowResponseFormat.test.ts +0 -58
  161. package/src/core/launchContext.test.ts +0 -157
  162. package/src/core/models/codexCapabilities.test.ts +0 -45
  163. package/src/core/models/codexModelCapabilities.test.ts +0 -246
  164. package/src/core/models/modelSpecs.test.ts +0 -283
  165. package/src/core/perf/renderDebug.test.ts +0 -230
  166. package/src/core/planStorage.test.ts +0 -143
  167. package/src/core/process/CommandRunner.test.ts +0 -105
  168. package/src/core/projectInstructions.test.ts +0 -50
  169. package/src/core/providerLauncher/launcher.test.ts +0 -238
  170. package/src/core/providerLauncher/registry.test.ts +0 -324
  171. package/src/core/providerLauncher/workspaceConfig.test.ts +0 -638
  172. package/src/core/providerRuntime/anthropic.test.ts +0 -1120
  173. package/src/core/providerRuntime/capabilityProfile.test.ts +0 -311
  174. package/src/core/providerRuntime/contextMetadata.test.ts +0 -468
  175. package/src/core/providerRuntime/gemini.test.ts +0 -437
  176. package/src/core/providerRuntime/lmstudio.test.ts +0 -168
  177. package/src/core/providerRuntime/local.test.ts +0 -787
  178. package/src/core/providerRuntime/registry.test.ts +0 -233
  179. package/src/core/providers/codexJsonStream.test.ts +0 -148
  180. package/src/core/providers/codexSubprocess.test.ts +0 -68
  181. package/src/core/providers/codexTranscript.test.ts +0 -284
  182. package/src/core/terminal/terminalCapabilities.test.ts +0 -93
  183. package/src/core/terminal/terminalControl.test.ts +0 -75
  184. package/src/core/terminal/terminalSanitize.test.ts +0 -22
  185. package/src/core/terminal/terminalSelection.test.ts +0 -42
  186. package/src/core/terminal/terminalTitle.test.ts +0 -328
  187. package/src/core/workspaceActivity.test.ts +0 -163
  188. package/src/core/workspaceGuard.test.ts +0 -151
  189. package/src/core/workspaceRoot.test.ts +0 -23
  190. package/src/exec.test.ts +0 -13
  191. package/src/headless/execArgs.test.ts +0 -147
  192. package/src/headless/execRunner.test.ts +0 -434
  193. package/src/index.test.tsx +0 -618
  194. package/src/session/appSession.test.ts +0 -897
  195. package/src/session/chatLifecycle.test.ts +0 -64
  196. package/src/session/liveRenderScheduler.test.ts +0 -201
  197. package/src/session/planFlow.test.ts +0 -103
  198. package/src/session/planTranscript.test.ts +0 -65
  199. package/src/session/promptRunSchedule.test.ts +0 -36
  200. package/src/ui/ActivityIndicator.test.tsx +0 -58
  201. package/src/ui/AgentBlock.test.ts +0 -6
  202. package/src/ui/AnimatedStatusText.test.ts +0 -16
  203. package/src/ui/AppShell.test.tsx +0 -1739
  204. package/src/ui/AttachmentImportPanel.test.tsx +0 -204
  205. package/src/ui/BottomComposer.test.ts +0 -674
  206. package/src/ui/CodexLogo.tsx +0 -55
  207. package/src/ui/Markdown.test.ts +0 -157
  208. package/src/ui/ModelPickerProviderScope.test.tsx +0 -411
  209. package/src/ui/ModelPickerScreen.test.tsx +0 -99
  210. package/src/ui/ModelPickerState.test.tsx +0 -151
  211. package/src/ui/ModelReasoningPicker.test.tsx +0 -447
  212. package/src/ui/PlanReviewPanel.test.tsx +0 -267
  213. package/src/ui/PromptCardBorder.test.tsx +0 -161
  214. package/src/ui/ProviderPicker.test.tsx +0 -289
  215. package/src/ui/ProviderShortcut.test.tsx +0 -143
  216. package/src/ui/SettingsPanel.test.tsx +0 -233
  217. package/src/ui/Timeline.test.ts +0 -2067
  218. package/src/ui/TimelineNavigation.test.tsx +0 -201
  219. package/src/ui/TopHeader.test.tsx +0 -239
  220. package/src/ui/TurnGroup.test.tsx +0 -365
  221. package/src/ui/busyStatusAnimation.test.ts +0 -30
  222. package/src/ui/commandNormalize.test.ts +0 -142
  223. package/src/ui/diffRenderer.test.ts +0 -102
  224. package/src/ui/focusFlow.test.tsx +0 -1098
  225. package/src/ui/inputBuffer.test.ts +0 -151
  226. package/src/ui/layout.test.ts +0 -145
  227. package/src/ui/modeDisplay.test.ts +0 -42
  228. package/src/ui/runActivityView.test.ts +0 -89
  229. package/src/ui/runLifecycleView.test.tsx +0 -237
  230. package/src/ui/statusRenderIsolation.test.tsx +0 -654
  231. package/src/ui/terminalAnswerFormat.test.ts +0 -19
  232. package/src/ui/textLayout.test.ts +0 -18
  233. package/src/ui/themeFlow.test.ts +0 -53
  234. package/src/ui/timelineMeasureCache.test.ts +0 -986
@@ -1,328 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import {
4
- acquireTerminalTitleGuard,
5
- buildTerminalTitleSequence,
6
- computeTerminalTitle,
7
- deriveTerminalTitle,
8
- formatTerminalTitleLabel,
9
- getIntendedTerminalTitle,
10
- normalizeTerminalTitle,
11
- reassertTerminalTitle,
12
- reassertIntendedTerminalTitle,
13
- sanitizeTerminalTitle,
14
- setIntendedTerminalTitle,
15
- setTerminalTitle,
16
- startTerminalTitleStartupGuard,
17
- beginColdStartSequence,
18
- createTerminalTitleSequenceStripper,
19
- stripTerminalTitleSequences,
20
- stripTerminalTitleSequencesFromChunk,
21
- traceTerminalTitleSequences,
22
- writeCodexaTerminalTitle,
23
- writeGuardedTerminalOutput,
24
- __resetTerminalTitleCache,
25
- } from "./terminalTitle.js";
26
-
27
- function sleep(ms: number): Promise<void> {
28
- return new Promise((resolve) => setTimeout(resolve, ms));
29
- }
30
-
31
- test("buildTerminalTitleSequence emits OSC 0 and OSC 2 with sanitized title text", () => {
32
- const sequence = buildTerminalTitleSequence("Codexa\u0007!");
33
- assert.equal(sequence, "\x1b]0;Codexa !\x07\x1b]2;Codexa !\x07");
34
- assert.equal(sanitizeTerminalTitle(" Codexa "), "Codexa");
35
- });
36
-
37
- test("title normalization never exposes raw Windows paths", () => {
38
- assert.equal(normalizeTerminalTitle("C:\\WINDOWS\\system"), "Codexa");
39
- assert.equal(normalizeTerminalTitle("c:/Users/example"), "Codexa");
40
- assert.equal(normalizeTerminalTitle("\\\\server\\share"), "Codexa");
41
- assert.equal(buildTerminalTitleSequence("C:\\WINDOWS\\system"), buildTerminalTitleSequence("Codexa"));
42
- });
43
-
44
- test("stripTerminalTitleSequences removes OSC 0 title sequences with BEL terminator", () => {
45
- assert.equal(
46
- stripTerminalTitleSequences("hello\x1b]0;C:\\WINDOWS\\system\x07world"),
47
- "helloworld",
48
- );
49
- });
50
-
51
- test("stripTerminalTitleSequences removes OSC 2 title sequences with BEL terminator", () => {
52
- assert.equal(
53
- stripTerminalTitleSequences("hello\x1b]2;Codex\x07world"),
54
- "helloworld",
55
- );
56
- });
57
-
58
- test("stripTerminalTitleSequences preserves normal ANSI SGR colour sequences", () => {
59
- const input = "\x1b[31mred\x1b[0m";
60
- assert.equal(stripTerminalTitleSequences(input), input);
61
- });
62
-
63
- test("stripTerminalTitleSequences removes title OSC from mixed output while preserving SGR", () => {
64
- assert.equal(
65
- stripTerminalTitleSequences("start\x1b]0;C:\\WINDOWS\\system\x07middle\x1b[32mok\x1b[0mend"),
66
- "startmiddle\x1b[32mok\x1b[0mend",
67
- );
68
- });
69
-
70
- test("stripTerminalTitleSequences removes OSC title sequences with ST terminator", () => {
71
- assert.equal(
72
- stripTerminalTitleSequences("hello\x1b]0;C:\\WINDOWS\\system\x1b\\world"),
73
- "helloworld",
74
- );
75
- });
76
-
77
- test("stripTerminalTitleSequencesFromChunk handles Buffer input", () => {
78
- assert.equal(
79
- stripTerminalTitleSequencesFromChunk(Buffer.from("hello\x1b]0;C:\\WINDOWS\\system\x07world", "utf8")),
80
- "helloworld",
81
- );
82
- });
83
-
84
- test("createTerminalTitleSequenceStripper removes title sequences split across chunks", () => {
85
- const stripper = createTerminalTitleSequenceStripper({
86
- source: "test",
87
- stream: "stdout",
88
- origin: "child",
89
- });
90
-
91
- assert.equal(stripper.process("hello\x1b]0;C:\\WINDOWS"), "hello");
92
- assert.equal(stripper.process("\\system\x07world"), "world");
93
- assert.equal(stripper.flush(), "");
94
- });
95
-
96
- test("formatTerminalTitleLabel follows the workspace leaf and app-name rules", () => {
97
- assert.equal(
98
- formatTerminalTitleLabel("C:\\Development\\1-JavaScript\\13-Custom-CLI-Normal", "dir"),
99
- "13-Custom-CLI-Normal",
100
- );
101
- assert.equal(
102
- formatTerminalTitleLabel("C:\\Development\\1-JavaScript\\13-Custom-CLI-Normal", "name"),
103
- "Codexa",
104
- );
105
- assert.equal(
106
- formatTerminalTitleLabel("C:\\Development\\1-JavaScript\\13-Custom-CLI-Normal", "simple"),
107
- "Codexa",
108
- );
109
- });
110
-
111
- test("deriveTerminalTitle follows terminal title mode on startup", () => {
112
- const workspaceRoot = "C:\\Development\\1-JavaScript\\13-Custom-CLI-Normal";
113
-
114
- assert.equal(deriveTerminalTitle(workspaceRoot, "dir"), "13-Custom-CLI-Normal");
115
- assert.equal(deriveTerminalTitle(workspaceRoot, "name"), "Codexa");
116
- assert.equal(deriveTerminalTitle(workspaceRoot, "simple"), "Codexa");
117
- });
118
-
119
- test("computeTerminalTitle follows the requested mapping", () => {
120
- const workspaceName = "13-Custom-CLI-Normal";
121
- assert.equal(computeTerminalTitle({ terminalTitleMode: "dir", workspaceName }), "13-Custom-CLI-Normal");
122
- assert.equal(computeTerminalTitle({ terminalTitleMode: "name" }), "Codexa");
123
- assert.equal(computeTerminalTitle({ terminalTitleMode: "simple" }), "Codexa");
124
- assert.equal(computeTerminalTitle({ terminalTitleMode: "dir", appName: "Other" }), "Other");
125
- });
126
-
127
- test("reassertTerminalTitle writes both title sequences without mutating process title", () => {
128
- const writes: string[] = [];
129
- const originalTitle = process.title;
130
-
131
- try {
132
- reassertTerminalTitle("Codexa", (chunk) => {
133
- writes.push(chunk);
134
- });
135
-
136
- assert.equal(process.title, originalTitle);
137
- assert.deepEqual(writes, [buildTerminalTitleSequence("Codexa")]);
138
- } finally {
139
- process.title = originalTitle;
140
- }
141
- });
142
-
143
- test("acquireTerminalTitleGuard asserts immediately, ticks while active, and reasserts on release", async () => {
144
- let calls = 0;
145
- const release = acquireTerminalTitleGuard(10, () => {
146
- calls += 1;
147
- });
148
-
149
- await sleep(35);
150
- release();
151
-
152
- const callsAfterRelease = calls;
153
- await sleep(20);
154
-
155
- assert.ok(callsAfterRelease >= 3, `expected at least 3 title assertions, got ${callsAfterRelease}`);
156
- assert.equal(calls, callsAfterRelease);
157
- });
158
-
159
- test("acquireTerminalTitleGuard release is idempotent", () => {
160
- let calls = 0;
161
- const release = acquireTerminalTitleGuard(50, () => {
162
- calls += 1;
163
- });
164
-
165
- release();
166
- const callsAfterFirstRelease = calls;
167
- release();
168
-
169
- assert.equal(callsAfterFirstRelease, 2);
170
- assert.equal(calls, callsAfterFirstRelease);
171
- });
172
-
173
- test("setTerminalTitle deduplicates identical title writes", () => {
174
- const writes: string[] = [];
175
- __resetTerminalTitleCache();
176
-
177
- setTerminalTitle("Codexa", { write: (chunk) => writes.push(chunk) });
178
- setTerminalTitle("Codexa", { write: (chunk) => writes.push(chunk) });
179
- setTerminalTitle("Other", { write: (chunk) => writes.push(chunk) });
180
-
181
- assert.equal(writes.length, 2);
182
- assert.equal(writes[0], buildTerminalTitleSequence("Codexa"));
183
- assert.equal(writes[1], buildTerminalTitleSequence("Other"));
184
- });
185
-
186
- test("writeCodexaTerminalTitle delegates to central title writer with force support", () => {
187
- const writes: string[] = [];
188
- __resetTerminalTitleCache();
189
-
190
- writeCodexaTerminalTitle("Codexa", { force: true, reason: "test", write: (chunk) => writes.push(chunk) });
191
-
192
- assert.deepEqual(writes, [buildTerminalTitleSequence("Codexa")]);
193
- });
194
-
195
- test("intended terminal title fallback is safe and later replaced by workspace title", () => {
196
- const writes: string[] = [];
197
- __resetTerminalTitleCache();
198
-
199
- setIntendedTerminalTitle("C:\\WINDOWS\\system", {
200
- force: true,
201
- reason: "test-fallback",
202
- write: (chunk) => writes.push(chunk),
203
- });
204
- assert.equal(getIntendedTerminalTitle(), "Codexa");
205
- assert.equal(writes.at(-1), buildTerminalTitleSequence("Codexa"));
206
-
207
- setIntendedTerminalTitle("13-Custom-CLI-Normal", {
208
- force: true,
209
- reason: "test-workspace",
210
- write: (chunk) => writes.push(chunk),
211
- });
212
- assert.equal(getIntendedTerminalTitle(), "13-Custom-CLI-Normal");
213
- assert.equal(writes.at(-1), buildTerminalTitleSequence("13-Custom-CLI-Normal"));
214
- });
215
-
216
- test("busy idle reassertion keeps the same intended title", () => {
217
- const writes: string[] = [];
218
- __resetTerminalTitleCache();
219
-
220
- setIntendedTerminalTitle("13-Custom-CLI-Normal", {
221
- force: true,
222
- write: (chunk) => writes.push(chunk),
223
- });
224
- reassertIntendedTerminalTitle({ reason: "busy-start", write: (chunk) => writes.push(chunk) });
225
- reassertIntendedTerminalTitle({ reason: "busy-end", write: (chunk) => writes.push(chunk) });
226
-
227
- assert.equal(getIntendedTerminalTitle(), "13-Custom-CLI-Normal");
228
- assert.deepEqual(writes, [
229
- buildTerminalTitleSequence("13-Custom-CLI-Normal"),
230
- buildTerminalTitleSequence("13-Custom-CLI-Normal"),
231
- buildTerminalTitleSequence("13-Custom-CLI-Normal"),
232
- ]);
233
- });
234
-
235
- test("writeGuardedTerminalOutput strips external title OSC and preserves SGR", () => {
236
- const writes: string[] = [];
237
- const result = writeGuardedTerminalOutput(
238
- (chunk) => {
239
- writes.push(chunk);
240
- return true;
241
- },
242
- "start\x1b]0;C:\\WINDOWS\\system\x07middle\x1b[32mok\x1b[0mend",
243
- { source: "test", stream: "stdout", origin: "child" },
244
- );
245
-
246
- assert.equal(result, true);
247
- assert.deepEqual(writes, ["startmiddle\x1b[32mok\x1b[0mend"]);
248
- });
249
-
250
- test("setTerminalTitle force option bypasses dedup", () => {
251
- const writes: string[] = [];
252
- __resetTerminalTitleCache();
253
-
254
- setTerminalTitle("Codexa", { write: (chunk) => writes.push(chunk) });
255
- setTerminalTitle("Codexa", { force: true, write: (chunk) => writes.push(chunk) });
256
- setTerminalTitle("Codexa", { force: true, write: (chunk) => writes.push(chunk) });
257
-
258
- assert.equal(writes.length, 3);
259
- writes.forEach((w) => assert.equal(w, buildTerminalTitleSequence("Codexa")));
260
- });
261
-
262
- test("beginColdStartSequence writes immediately then retries", async () => {
263
- const writes: string[] = [];
264
- __resetTerminalTitleCache();
265
-
266
- const cancel = beginColdStartSequence("Codexa", { write: (chunk) => writes.push(chunk) });
267
-
268
- assert.equal(writes.length, 1, "should write immediately");
269
-
270
- await sleep(60);
271
- assert.equal(writes.length, 2, "should have retried at 50ms");
272
-
273
- cancel();
274
- await sleep(300);
275
- assert.equal(writes.length, 2, "should not have retried further after cancel");
276
- });
277
-
278
- test("startup guard reasserts intended title until cancelled", async () => {
279
- const writes: string[] = [];
280
- __resetTerminalTitleCache();
281
-
282
- setIntendedTerminalTitle("13-Custom-CLI-Normal", {
283
- force: true,
284
- write: (chunk) => writes.push(chunk),
285
- });
286
- const cancel = startTerminalTitleStartupGuard({
287
- intervalMs: 10,
288
- durationMs: 100,
289
- write: (chunk) => writes.push(chunk),
290
- });
291
-
292
- await sleep(25);
293
- cancel();
294
- const writesAfterCancel = writes.length;
295
- await sleep(25);
296
-
297
- assert.ok(writesAfterCancel >= 3, `expected guard to reassert title, got ${writesAfterCancel} writes`);
298
- assert.equal(writes.length, writesAfterCancel);
299
- assert.ok(writes.every((chunk) => chunk === buildTerminalTitleSequence("13-Custom-CLI-Normal")));
300
- });
301
-
302
- test("stripTerminalTitleSequences handles very long unterminated OSC without hanging", () => {
303
- const long = "\x1b]0;" + "A".repeat(100_000);
304
- const start = Date.now();
305
- const result = stripTerminalTitleSequences(long);
306
- assert.ok(Date.now() - start < 100, "must complete in under 100 ms");
307
- assert.ok(result.includes("\x1b]0;"), "unterminated sequence passes through unchanged");
308
- });
309
-
310
- test("stripTerminalTitleSequences strips OSC sequence with empty title", () => {
311
- assert.equal(stripTerminalTitleSequences("pre\x1b]0;\x07post"), "prepost");
312
- assert.equal(stripTerminalTitleSequences("pre\x1b]2;\x1b\\post"), "prepost");
313
- });
314
-
315
- test("createTerminalTitleSequenceStripper handles OSC split across chunks with ST terminator", () => {
316
- const stripper = createTerminalTitleSequenceStripper({ source: "test", stream: "stdout", origin: "child" });
317
- assert.equal(stripper.process("hello\x1b]2;MyTitle"), "hello");
318
- assert.equal(stripper.process("\x1b\\world"), "world");
319
- assert.equal(stripper.flush(), "");
320
- });
321
-
322
- test("traceTerminalTitleSequences does not hang on crafted adversarial input", () => {
323
- const crafted = "\x1b]0;" + "X".repeat(10_000) + "\x1b]2;" + "Y".repeat(10_000);
324
- const start = Date.now();
325
- const found = traceTerminalTitleSequences(crafted, { source: "test", stream: "stdout", origin: "child" });
326
- assert.ok(Date.now() - start < 100, "must complete in under 100 ms");
327
- assert.equal(found, false, "no complete sequences in adversarial input");
328
- });
@@ -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
- });