@namzu/cli 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/dist/tui/App.d.ts.map +1 -1
  2. package/dist/tui/App.js +22 -2
  3. package/dist/tui/App.js.map +1 -1
  4. package/dist/tui/agent.d.ts +10 -0
  5. package/dist/tui/agent.d.ts.map +1 -1
  6. package/dist/tui/agent.js +10 -0
  7. package/dist/tui/agent.js.map +1 -1
  8. package/dist/tui/slashCommands.d.ts +83 -0
  9. package/dist/tui/slashCommands.d.ts.map +1 -1
  10. package/dist/tui/slashCommands.js +157 -0
  11. package/dist/tui/slashCommands.js.map +1 -1
  12. package/package.json +11 -6
  13. package/dist/__tests__/environment-reaches-the-turn.test.d.ts +0 -17
  14. package/dist/__tests__/environment-reaches-the-turn.test.d.ts.map +0 -1
  15. package/dist/__tests__/environment-reaches-the-turn.test.js +0 -128
  16. package/dist/__tests__/environment-reaches-the-turn.test.js.map +0 -1
  17. package/dist/__tests__/headless-trust-gate.test.d.ts +0 -23
  18. package/dist/__tests__/headless-trust-gate.test.d.ts.map +0 -1
  19. package/dist/__tests__/headless-trust-gate.test.js +0 -227
  20. package/dist/__tests__/headless-trust-gate.test.js.map +0 -1
  21. package/dist/__tests__/mcp-servers-reach-the-session.test.d.ts +0 -17
  22. package/dist/__tests__/mcp-servers-reach-the-session.test.d.ts.map +0 -1
  23. package/dist/__tests__/mcp-servers-reach-the-session.test.js +0 -171
  24. package/dist/__tests__/mcp-servers-reach-the-session.test.js.map +0 -1
  25. package/dist/__tests__/permission-rules-reach-the-turn.test.d.ts +0 -31
  26. package/dist/__tests__/permission-rules-reach-the-turn.test.d.ts.map +0 -1
  27. package/dist/__tests__/permission-rules-reach-the-turn.test.js +0 -132
  28. package/dist/__tests__/permission-rules-reach-the-turn.test.js.map +0 -1
  29. package/dist/__tests__/project-instructions-reach-the-turn.test.d.ts +0 -24
  30. package/dist/__tests__/project-instructions-reach-the-turn.test.d.ts.map +0 -1
  31. package/dist/__tests__/project-instructions-reach-the-turn.test.js +0 -153
  32. package/dist/__tests__/project-instructions-reach-the-turn.test.js.map +0 -1
  33. package/dist/cli.test.d.ts +0 -2
  34. package/dist/cli.test.d.ts.map +0 -1
  35. package/dist/cli.test.js +0 -108
  36. package/dist/cli.test.js.map +0 -1
  37. package/dist/commands/__tests__/eval.test.d.ts +0 -2
  38. package/dist/commands/__tests__/eval.test.d.ts.map +0 -1
  39. package/dist/commands/__tests__/eval.test.js +0 -165
  40. package/dist/commands/__tests__/eval.test.js.map +0 -1
  41. package/dist/commands/__tests__/passthrough-help.test.d.ts +0 -2
  42. package/dist/commands/__tests__/passthrough-help.test.d.ts.map +0 -1
  43. package/dist/commands/__tests__/passthrough-help.test.js +0 -96
  44. package/dist/commands/__tests__/passthrough-help.test.js.map +0 -1
  45. package/dist/commands/__tests__/resume.test.d.ts +0 -15
  46. package/dist/commands/__tests__/resume.test.d.ts.map +0 -1
  47. package/dist/commands/__tests__/resume.test.js +0 -116
  48. package/dist/commands/__tests__/resume.test.js.map +0 -1
  49. package/dist/commands/__tests__/run-exit-code.test.d.ts +0 -2
  50. package/dist/commands/__tests__/run-exit-code.test.d.ts.map +0 -1
  51. package/dist/commands/__tests__/run-exit-code.test.js +0 -100
  52. package/dist/commands/__tests__/run-exit-code.test.js.map +0 -1
  53. package/dist/commands/__tests__/run-flags.test.d.ts +0 -11
  54. package/dist/commands/__tests__/run-flags.test.d.ts.map +0 -1
  55. package/dist/commands/__tests__/run-flags.test.js +0 -238
  56. package/dist/commands/__tests__/run-flags.test.js.map +0 -1
  57. package/dist/commands/__tests__/run-stream-flags.test.d.ts +0 -2
  58. package/dist/commands/__tests__/run-stream-flags.test.d.ts.map +0 -1
  59. package/dist/commands/__tests__/run-stream-flags.test.js +0 -295
  60. package/dist/commands/__tests__/run-stream-flags.test.js.map +0 -1
  61. package/dist/commands/doctor.test.d.ts +0 -2
  62. package/dist/commands/doctor.test.d.ts.map +0 -1
  63. package/dist/commands/doctor.test.js +0 -82
  64. package/dist/commands/doctor.test.js.map +0 -1
  65. package/dist/config/load.test.d.ts +0 -2
  66. package/dist/config/load.test.d.ts.map +0 -1
  67. package/dist/config/load.test.js +0 -57
  68. package/dist/config/load.test.js.map +0 -1
  69. package/dist/context/__tests__/environment.test.d.ts +0 -10
  70. package/dist/context/__tests__/environment.test.d.ts.map +0 -1
  71. package/dist/context/__tests__/environment.test.js +0 -84
  72. package/dist/context/__tests__/environment.test.js.map +0 -1
  73. package/dist/context/__tests__/project.test.d.ts +0 -12
  74. package/dist/context/__tests__/project.test.d.ts.map +0 -1
  75. package/dist/context/__tests__/project.test.js +0 -201
  76. package/dist/context/__tests__/project.test.js.map +0 -1
  77. package/dist/doctor/checks/credentials.test.d.ts +0 -10
  78. package/dist/doctor/checks/credentials.test.d.ts.map +0 -1
  79. package/dist/doctor/checks/credentials.test.js +0 -47
  80. package/dist/doctor/checks/credentials.test.js.map +0 -1
  81. package/dist/doctor/checks/sandbox.test.d.ts +0 -2
  82. package/dist/doctor/checks/sandbox.test.d.ts.map +0 -1
  83. package/dist/doctor/checks/sandbox.test.js +0 -59
  84. package/dist/doctor/checks/sandbox.test.js.map +0 -1
  85. package/dist/doctor/registry.test.d.ts +0 -7
  86. package/dist/doctor/registry.test.d.ts.map +0 -1
  87. package/dist/doctor/registry.test.js +0 -379
  88. package/dist/doctor/registry.test.js.map +0 -1
  89. package/dist/integrations/mcp/__tests__/connect.test.d.ts +0 -11
  90. package/dist/integrations/mcp/__tests__/connect.test.d.ts.map +0 -1
  91. package/dist/integrations/mcp/__tests__/connect.test.js +0 -231
  92. package/dist/integrations/mcp/__tests__/connect.test.js.map +0 -1
  93. package/dist/integrations/providers/discover.test.d.ts +0 -2
  94. package/dist/integrations/providers/discover.test.d.ts.map +0 -1
  95. package/dist/integrations/providers/discover.test.js +0 -93
  96. package/dist/integrations/providers/discover.test.js.map +0 -1
  97. package/dist/integrations/providers/keychain.test.d.ts +0 -2
  98. package/dist/integrations/providers/keychain.test.d.ts.map +0 -1
  99. package/dist/integrations/providers/keychain.test.js +0 -21
  100. package/dist/integrations/providers/keychain.test.js.map +0 -1
  101. package/dist/integrations/providers/oauth.test.d.ts +0 -2
  102. package/dist/integrations/providers/oauth.test.d.ts.map +0 -1
  103. package/dist/integrations/providers/oauth.test.js +0 -86
  104. package/dist/integrations/providers/oauth.test.js.map +0 -1
  105. package/dist/integrations/providers/preferences.test.d.ts +0 -2
  106. package/dist/integrations/providers/preferences.test.d.ts.map +0 -1
  107. package/dist/integrations/providers/preferences.test.js +0 -76
  108. package/dist/integrations/providers/preferences.test.js.map +0 -1
  109. package/dist/integrations/sessions/__tests__/archived-workspace.test.d.ts +0 -21
  110. package/dist/integrations/sessions/__tests__/archived-workspace.test.d.ts.map +0 -1
  111. package/dist/integrations/sessions/__tests__/archived-workspace.test.js +0 -62
  112. package/dist/integrations/sessions/__tests__/archived-workspace.test.js.map +0 -1
  113. package/dist/integrations/subagents/__tests__/delegation-trace.test.d.ts +0 -2
  114. package/dist/integrations/subagents/__tests__/delegation-trace.test.d.ts.map +0 -1
  115. package/dist/integrations/subagents/__tests__/delegation-trace.test.js +0 -114
  116. package/dist/integrations/subagents/__tests__/delegation-trace.test.js.map +0 -1
  117. package/dist/integrations/trust/store.test.d.ts +0 -2
  118. package/dist/integrations/trust/store.test.d.ts.map +0 -1
  119. package/dist/integrations/trust/store.test.js +0 -50
  120. package/dist/integrations/trust/store.test.js.map +0 -1
  121. package/dist/memory/store.test.d.ts +0 -2
  122. package/dist/memory/store.test.d.ts.map +0 -1
  123. package/dist/memory/store.test.js +0 -63
  124. package/dist/memory/store.test.js.map +0 -1
  125. package/dist/output/formatter.test.d.ts +0 -2
  126. package/dist/output/formatter.test.d.ts.map +0 -1
  127. package/dist/output/formatter.test.js +0 -88
  128. package/dist/output/formatter.test.js.map +0 -1
  129. package/dist/output/rendered-payload.test.d.ts +0 -2
  130. package/dist/output/rendered-payload.test.d.ts.map +0 -1
  131. package/dist/output/rendered-payload.test.js +0 -61
  132. package/dist/output/rendered-payload.test.js.map +0 -1
  133. package/dist/permissions/__tests__/mode.test.d.ts +0 -10
  134. package/dist/permissions/__tests__/mode.test.d.ts.map +0 -1
  135. package/dist/permissions/__tests__/mode.test.js +0 -115
  136. package/dist/permissions/__tests__/mode.test.js.map +0 -1
  137. package/dist/permissions/__tests__/rules.test.d.ts +0 -10
  138. package/dist/permissions/__tests__/rules.test.d.ts.map +0 -1
  139. package/dist/permissions/__tests__/rules.test.js +0 -196
  140. package/dist/permissions/__tests__/rules.test.js.map +0 -1
  141. package/dist/skills/store.test.d.ts +0 -2
  142. package/dist/skills/store.test.d.ts.map +0 -1
  143. package/dist/skills/store.test.js +0 -80
  144. package/dist/skills/store.test.js.map +0 -1
  145. package/dist/tui/__tests__/context-gauge.test.d.ts +0 -2
  146. package/dist/tui/__tests__/context-gauge.test.d.ts.map +0 -1
  147. package/dist/tui/__tests__/context-gauge.test.js +0 -83
  148. package/dist/tui/__tests__/context-gauge.test.js.map +0 -1
  149. package/dist/tui/__tests__/deferred-tool-discovery.test.d.ts +0 -24
  150. package/dist/tui/__tests__/deferred-tool-discovery.test.d.ts.map +0 -1
  151. package/dist/tui/__tests__/deferred-tool-discovery.test.js +0 -111
  152. package/dist/tui/__tests__/deferred-tool-discovery.test.js.map +0 -1
  153. package/dist/tui/__tests__/to-agent-event.test.d.ts +0 -2
  154. package/dist/tui/__tests__/to-agent-event.test.d.ts.map +0 -1
  155. package/dist/tui/__tests__/to-agent-event.test.js +0 -230
  156. package/dist/tui/__tests__/to-agent-event.test.js.map +0 -1
  157. package/dist/tui/__tests__/working-directory.test.d.ts +0 -13
  158. package/dist/tui/__tests__/working-directory.test.d.ts.map +0 -1
  159. package/dist/tui/__tests__/working-directory.test.js +0 -109
  160. package/dist/tui/__tests__/working-directory.test.js.map +0 -1
  161. package/dist/tui/agent.test.d.ts +0 -2
  162. package/dist/tui/agent.test.d.ts.map +0 -1
  163. package/dist/tui/agent.test.js +0 -225
  164. package/dist/tui/agent.test.js.map +0 -1
  165. package/dist/tui/markdownParser.test.d.ts +0 -2
  166. package/dist/tui/markdownParser.test.d.ts.map +0 -1
  167. package/dist/tui/markdownParser.test.js +0 -90
  168. package/dist/tui/markdownParser.test.js.map +0 -1
  169. package/dist/tui/mentions.test.d.ts +0 -2
  170. package/dist/tui/mentions.test.d.ts.map +0 -1
  171. package/dist/tui/mentions.test.js +0 -35
  172. package/dist/tui/mentions.test.js.map +0 -1
  173. package/dist/tui/slashCommands.test.d.ts +0 -2
  174. package/dist/tui/slashCommands.test.d.ts.map +0 -1
  175. package/dist/tui/slashCommands.test.js +0 -114
  176. package/dist/tui/slashCommands.test.js.map +0 -1
@@ -1,295 +0,0 @@
1
- import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
2
- import { tmpdir } from 'node:os';
3
- import { join, resolve } from 'node:path';
4
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
5
- import { openSessions } from '../../integrations/sessions/store.js';
6
- import { parseRunFlags } from '../run-flags.js';
7
- import { historyCommand, runStreamCommand, skillsJSONCommand } from '../run-stream.js';
8
- // Mocked so the directory the store is opened at is observable. Nothing here
9
- // touches a real `.namzu` store; `resolveConversation` returning null is the
10
- // "no such session" path, which is what makes the handler terminate.
11
- vi.mock('../../integrations/sessions/store.js', () => ({
12
- openSessions: vi.fn(async () => ({})),
13
- resolveConversation: vi.fn(async () => null),
14
- loadConversation: vi.fn(async () => []),
15
- appendMessages: vi.fn(async () => undefined),
16
- }));
17
- // Stubbed so a turn can be driven to completion without a credential, and so
18
- // the directory the SESSION is created in is observable. What the session then
19
- // does with that directory is asserted in `src/tui/__tests__/`.
20
- const sessionOptions = [];
21
- // Standing in a trusted folder, which is the ordinary production state. These
22
- // tests are about the option surface and the permission table; the gate that
23
- // refuses an untrusted folder is tested in
24
- // `__tests__/headless-trust-gate.test.ts`.
25
- vi.mock('../../integrations/trust/store.js', () => ({
26
- isTrusted: () => true,
27
- trustDir: () => { },
28
- }));
29
- vi.mock('../../tui/agent.js', () => ({
30
- probeAgentSession: vi.fn(async () => ({
31
- preferences: { version: 2, provider: 'anthropic', subagents: { active: [] } },
32
- needsRepickReason: null,
33
- detected: [],
34
- })),
35
- createAgentSession: vi.fn(async (_prefs, _detected, opts) => {
36
- sessionOptions.push(opts);
37
- return {
38
- hasProvider: true,
39
- providerSummary: 'stub',
40
- modelSummary: 'stub',
41
- toolNames: [],
42
- // Present because a real session always sets these: a stub missing a
43
- // field production always has is a fixture for a system that does not
44
- // ship.
45
- instructionFiles: [],
46
- skippedInstructionFiles: [],
47
- mcpConnected: [],
48
- mcpFailed: [],
49
- close: async () => { },
50
- errorHint: null,
51
- send: async function* () { },
52
- };
53
- }),
54
- }));
55
- /**
56
- * `run-stream` folded every argument it did not recognise into `rest`, and
57
- * `rest.join(' ')` is the PROMPT. `--cwd <path>` was in this command's own help
58
- * text and was never parsed, so the invocation our documentation teaches sent
59
- * the model a prompt beginning `--cwd /path …` while silently reading the
60
- * process's own directory.
61
- *
62
- * That is the same defect the sibling test in `passthrough-help.test.ts`
63
- * describes one level up, where `--help` became the prompt. The fix there was
64
- * to stop treating an option as content; the fix here is the same, plus
65
- * actually honouring the flag that was advertised.
66
- */
67
- const ctx = { config: {} };
68
- function capture() {
69
- const lines = [];
70
- const spy = vi.spyOn(process.stdout, 'write').mockImplementation((chunk) => {
71
- lines.push(String(chunk));
72
- return true;
73
- });
74
- return { lines, restore: () => spy.mockRestore() };
75
- }
76
- beforeEach(() => {
77
- vi.mocked(openSessions).mockClear();
78
- sessionOptions.length = 0;
79
- });
80
- afterEach(() => {
81
- vi.restoreAllMocks();
82
- });
83
- async function run(rawArgs) {
84
- const { lines, restore } = capture();
85
- try {
86
- await runStreamCommand.handler({ rawArgs, ctx });
87
- }
88
- finally {
89
- restore();
90
- }
91
- return lines;
92
- }
93
- describe('run-stream does not turn options into prompt text', () => {
94
- it('consumes --cwd instead of speaking it to the model', async () => {
95
- // With `--cwd` unparsed these two tokens WERE the prompt, so the run
96
- // proceeded. Reaching "no prompt" is what proves they were consumed.
97
- const lines = await run(['--cwd', '/tmp/somewhere']);
98
- expect(lines.join('')).toContain('no prompt');
99
- });
100
- it('refuses an option it does not know rather than saying it out loud', async () => {
101
- const lines = await run(['--temperature', '0.5', 'hello']);
102
- const joined = lines.join('');
103
- expect(joined).toContain('unknown option');
104
- expect(joined).toContain('--temperature');
105
- });
106
- it('refuses the flag form written with an equals sign', async () => {
107
- const lines = await run(['--nope=1', 'hello']);
108
- expect(lines.join('')).toContain('--nope');
109
- });
110
- it('still emits a terminal event when it refuses, so a host is not left hanging', async () => {
111
- // The NDJSON contract is that every run ends with `done`. A refusal that
112
- // skipped it would strand a host line-scanning stdout.
113
- const lines = await run(['--bogus', 'hello']);
114
- expect(lines.join('')).toContain('"kind":"done"');
115
- });
116
- });
117
- describe('run-stream works in the directory it was pointed at', () => {
118
- it('hands --cwd to the agent session, not only to the session store', async () => {
119
- // `--session` keeps the turn off stdin: without a session key the command
120
- // reads prior history from a pipe, and in a test runner that pipe never
121
- // closes.
122
- const elsewhere = mkdtempSync(join(tmpdir(), 'namzu-run-stream-'));
123
- try {
124
- await run(['--cwd', elsewhere, '--session', 'k', 'read', 'notes.txt']);
125
- }
126
- finally {
127
- rmSync(elsewhere, { recursive: true, force: true });
128
- }
129
- expect(sessionOptions[0]?.cwd).toBe(elsewhere);
130
- });
131
- it('refuses a --cwd that is not there instead of quietly using this one', async () => {
132
- // The silent fallback is the whole defect: the run proceeds, searches the
133
- // wrong tree, finds nothing, and reports that the file does not exist.
134
- const lines = await run(['--cwd', join(tmpdir(), 'namzu-no-such-dir'), 'hello']);
135
- const joined = lines.join('');
136
- expect(joined).toContain('--cwd does not exist');
137
- expect(joined).toContain('"kind":"done"');
138
- expect(sessionOptions).toEqual([]);
139
- });
140
- });
141
- describe('the flag parser itself', () => {
142
- // Asserted here rather than through the handler: a valid prompt sends the
143
- // handler on to stdin and a provider probe, so the first version of this
144
- // case hung for five seconds and failed on a timeout rather than on the
145
- // behaviour. A pure function deserves to be called.
146
- it('lets `--` carry a prompt that begins with a dash', () => {
147
- const flags = parseRunFlags(['--', '--this-is-the-prompt']);
148
- expect(flags.rest).toEqual(['--this-is-the-prompt']);
149
- expect(flags.unknown).toEqual([]);
150
- });
151
- it('stops interpreting options after `--`', () => {
152
- const flags = parseRunFlags(['--session', 'abc', '--', '--model', 'not-a-flag']);
153
- expect(flags.session).toBe('abc');
154
- expect(flags.model).toBeNull();
155
- expect(flags.rest).toEqual(['--model', 'not-a-flag']);
156
- });
157
- it('reads --cwd in both spellings', () => {
158
- expect(parseRunFlags(['--cwd', '/a', 'hi']).cwd).toBe('/a');
159
- expect(parseRunFlags(['--cwd=/b', 'hi']).cwd).toBe('/b');
160
- expect(parseRunFlags(['--cwd', '/a', 'hi']).rest).toEqual(['hi']);
161
- });
162
- it('leaves a lone dash alone, since that is not an option', () => {
163
- expect(parseRunFlags(['-', 'hi']).unknown).toEqual([]);
164
- expect(parseRunFlags(['-', 'hi']).rest).toEqual(['-', 'hi']);
165
- });
166
- });
167
- describe('skills-json lists the directory it was pointed at', () => {
168
- // A host that lists skills for one checkout and then runs a turn in that
169
- // same checkout has to be told about the same skills both times. It was
170
- // not: this command read the process directory whatever `--cwd` said, so
171
- // it could offer a skill that `run-stream --cwd <there>` then could not
172
- // find, and hide one that was actually available.
173
- function skillIn(root, name) {
174
- mkdirSync(join(root, 'skills', name), { recursive: true });
175
- writeFileSync(join(root, 'skills', name, 'SKILL.md'), `---\nname: ${name}\ndescription: only in this checkout\n---\n\nbody\n`);
176
- }
177
- it('discovers the project skills under --cwd', async () => {
178
- const elsewhere = mkdtempSync(join(tmpdir(), 'namzu-skills-'));
179
- skillIn(elsewhere, 'only-over-there');
180
- const { lines, restore } = capture();
181
- try {
182
- await skillsJSONCommand.handler({ rawArgs: ['--cwd', elsewhere], ctx });
183
- }
184
- finally {
185
- restore();
186
- rmSync(elsewhere, { recursive: true, force: true });
187
- }
188
- const names = JSON.parse(lines.join('').trim()).map((s) => s.name);
189
- expect(names).toContain('only-over-there');
190
- });
191
- // There is deliberately no paired "and not from anywhere else" case: with
192
- // the flag ignored the command read `packages/cli`, which has no skills
193
- // directory, so a negative assertion passes with the defect still in place
194
- // and would only look like coverage.
195
- });
196
- describe('history reads the directory it was pointed at', () => {
197
- it('opens the store at --cwd, not at the process directory', async () => {
198
- // Parsing the flag is not the fix; USING it is. An assertion that the
199
- // command merely survives `--cwd` would pass with the wiring reverted —
200
- // `[]` is printed either way — which would leave the flag parsed and
201
- // still undriven, the exact shape being repaired here.
202
- //
203
- // A real directory, because `--cwd` is now resolved and checked before
204
- // the store is opened: a path that is not there cannot be told apart
205
- // from a session with no messages, so it never reaches the store.
206
- const elsewhere = mkdtempSync(join(tmpdir(), 'namzu-history-'));
207
- const { lines, restore } = capture();
208
- try {
209
- await historyCommand.handler({
210
- rawArgs: ['--cwd', elsewhere, '--session', 'some-key'],
211
- ctx,
212
- });
213
- }
214
- finally {
215
- restore();
216
- rmSync(elsewhere, { recursive: true, force: true });
217
- }
218
- expect(openSessions).toHaveBeenCalledWith(elsewhere);
219
- expect(lines.join('').trim()).toBe('[]');
220
- });
221
- it('resolves a relative --cwd against the process directory', async () => {
222
- // A host that passes `.` or `../sibling` gets the directory it meant,
223
- // and the agent downstream gets an absolute path it cannot misread.
224
- const { restore } = capture();
225
- try {
226
- await historyCommand.handler({ rawArgs: ['--cwd', '.', '--session', 'k'], ctx });
227
- }
228
- finally {
229
- restore();
230
- }
231
- expect(openSessions).toHaveBeenCalledWith(resolve(process.cwd(), '.'));
232
- });
233
- it('falls back to the process directory when --cwd is absent', async () => {
234
- const { restore } = capture();
235
- try {
236
- await historyCommand.handler({ rawArgs: ['--session', 'some-key'], ctx });
237
- }
238
- finally {
239
- restore();
240
- }
241
- expect(openSessions).toHaveBeenCalledWith(process.cwd());
242
- });
243
- });
244
- describe('run-stream honours the permission surface, not just parses it', () => {
245
- // It accepted `--permission-mode` and never used it, and it never compiled
246
- // the `[permissions]` table at all — so an operator who wrote rules, or who
247
- // typed `--permission-mode strict` precisely because they did not trust the
248
- // run, got an unrestricted one that looked like it had obeyed. A safety
249
- // control that parses and does nothing is worse than one that is missing,
250
- // because the absence is visible and the silence is not.
251
- const withConfig = {
252
- config: { permissions: { bash: 'deny' } },
253
- };
254
- async function runWith(rawArgs, context = withConfig) {
255
- const { lines, restore } = capture();
256
- try {
257
- await runStreamCommand.handler({ rawArgs, ctx: context });
258
- }
259
- finally {
260
- restore();
261
- }
262
- return lines;
263
- }
264
- it('compiles the operator table into the session', async () => {
265
- await runWith(['--session', 'k', 'hello']);
266
- expect(sessionOptions[0]?.rules).toEqual([{ type: 'deny_by_name', toolNames: ['bash'] }]);
267
- });
268
- it('passes --permission-mode through instead of ignoring it', async () => {
269
- await runWith(['--session', 'k', '--permission-mode', 'strict', 'hello']);
270
- expect(sessionOptions[0]?.permissionMode).toBe('strict');
271
- });
272
- it('refuses a mode it does not know rather than running unrestricted', async () => {
273
- const lines = await runWith(['--session', 'k', '--permission-mode', 'yolo', 'hello']);
274
- expect(lines.join('')).toContain('--permission-mode must be one of');
275
- expect(sessionOptions).toEqual([]);
276
- });
277
- it('defaults to auto when nothing was asked for, and says so by acting on it', async () => {
278
- await runWith(['--session', 'k', 'hello']);
279
- expect(sessionOptions[0]?.permissionMode).toBe('auto');
280
- });
281
- it('reports an unreadable rule in band, where a host can see it', async () => {
282
- const bad = {
283
- config: { permissions: { bash: { 'git push*': 'maybe' } } },
284
- };
285
- const lines = await runWith(['--session', 'k', 'hello'], bad);
286
- // Parsed, not substring-matched: the line is JSON, so the quotes around
287
- // the pattern are escaped in the raw text and a naive contains() would
288
- // pass or fail for reasons unrelated to what the host actually reads.
289
- const messages = lines
290
- .map((l) => JSON.parse(l))
291
- .map((e) => e.message ?? '');
292
- expect(messages.some((m) => m.includes('permissions.bash."git push*"'))).toBe(true);
293
- });
294
- });
295
- //# sourceMappingURL=run-stream-flags.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-stream-flags.test.js","sourceRoot":"","sources":["../../../src/commands/__tests__/run-stream-flags.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAGtF,6EAA6E;AAC7E,6EAA6E;AAC7E,qEAAqE;AACrE,EAAE,CAAC,IAAI,CAAC,sCAAsC,EAAE,GAAG,EAAE,CAAC,CAAC;IACtD,YAAY,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,CAAU,CAAC;IAC9C,mBAAmB,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC;IAC5C,gBAAgB,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;IACvC,cAAc,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,SAAS,CAAC;CAC5C,CAAC,CAAC,CAAA;AAEH,6EAA6E;AAC7E,+EAA+E;AAC/E,gEAAgE;AAChE,MAAM,cAAc,GAEhB,EAAE,CAAA;AACN,8EAA8E;AAC9E,6EAA6E;AAC7E,2CAA2C;AAC3C,2CAA2C;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,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACvD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC5E,MAAM,GAAG,GAAG;YACX,MAAM,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE;SAC9B,CAAA;QAE9B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,CAAA;QAE7D,wEAAwE;QACxE,uEAAuE;QACvE,sEAAsE;QACtE,MAAM,QAAQ,GAAG,KAAK;aACpB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAyB,CAAC;aACjD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAA;QAC7B,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACpF,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=doctor.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"doctor.test.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.test.ts"],"names":[],"mappings":""}
@@ -1,82 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it } from 'vitest';
2
- import { runDoctorCommand } from './doctor.js';
3
- describe('runDoctorCommand', () => {
4
- let captured;
5
- let originalStdoutWrite;
6
- let originalStderrWrite;
7
- beforeEach(() => {
8
- captured = '';
9
- originalStdoutWrite = process.stdout.write.bind(process.stdout);
10
- originalStderrWrite = process.stderr.write.bind(process.stderr);
11
- process.stdout.write = ((chunk) => {
12
- captured += typeof chunk === 'string' ? chunk : Buffer.from(chunk).toString('utf8');
13
- return true;
14
- });
15
- process.stderr.write = ((chunk) => {
16
- captured += typeof chunk === 'string' ? chunk : Buffer.from(chunk).toString('utf8');
17
- return true;
18
- });
19
- });
20
- afterEach(() => {
21
- process.stdout.write = originalStdoutWrite;
22
- process.stderr.write = originalStderrWrite;
23
- });
24
- it('--help returns 0 and prints usage', async () => {
25
- const code = await runDoctorCommand(['--help']);
26
- expect(code).toBe(0);
27
- expect(captured).toContain('namzu doctor');
28
- expect(captured).toContain('--json');
29
- expect(captured).toContain('--category');
30
- });
31
- it('rejects unknown options with EXIT_USAGE (70)', async () => {
32
- const code = await runDoctorCommand(['--frobnicate']);
33
- expect(code).toBe(64);
34
- expect(captured).toContain('unknown option: --frobnicate');
35
- });
36
- it('--category accepts a valid comma-separated list', async () => {
37
- const code = await runDoctorCommand(['--category', 'sandbox,runtime', '--json']);
38
- expect([0, 1]).toContain(code);
39
- const json = JSON.parse(captured);
40
- expect(json.checks.every((c) => ['sandbox', 'runtime'].includes(c.category))).toBe(true);
41
- });
42
- it('--category rejects an invalid name', async () => {
43
- const code = await runDoctorCommand(['--category', 'sandbox,wat']);
44
- expect(code).toBe(64);
45
- expect(captured).toContain('unknown category: wat');
46
- });
47
- it('--per-check-timeout requires a positive integer', async () => {
48
- const code = await runDoctorCommand(['--per-check-timeout', '-5']);
49
- expect(code).toBe(64);
50
- expect(captured).toContain('--per-check-timeout must be a positive integer');
51
- });
52
- it('--json emits valid JSON conforming to DoctorReport', async () => {
53
- const code = await runDoctorCommand(['--json']);
54
- expect([0, 1]).toContain(code);
55
- const json = JSON.parse(captured);
56
- expect(json).toHaveProperty('version');
57
- expect(json).toHaveProperty('timestamp');
58
- expect(Array.isArray(json.checks)).toBe(true);
59
- expect(json).toHaveProperty('summary.total');
60
- expect(json).toHaveProperty('exit');
61
- });
62
- it('default human output includes the summary line', async () => {
63
- const code = await runDoctorCommand([]);
64
- expect([0, 1]).toContain(code);
65
- expect(captured).toContain('namzu doctor —');
66
- expect(captured).toMatch(/pass: \d+ {2}fail: \d+/);
67
- expect(captured).toMatch(/exit: \d+/);
68
- });
69
- it('built-in checks register with stable ids', async () => {
70
- const code = await runDoctorCommand(['--json']);
71
- expect([0, 1]).toContain(code);
72
- const json = JSON.parse(captured);
73
- const ids = json.checks.map((c) => c.id).sort();
74
- expect(ids).toContain('sandbox.platform');
75
- expect(ids).toContain('runtime.cwd-writable');
76
- expect(ids).toContain('runtime.tmpdir-writable');
77
- expect(ids).toContain('telemetry.installed');
78
- expect(ids).toContain('vault.registered');
79
- expect(ids).toContain('providers.registered');
80
- });
81
- });
82
- //# sourceMappingURL=doctor.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"doctor.test.js","sourceRoot":"","sources":["../../src/commands/doctor.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAEpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IACjC,IAAI,QAAgB,CAAA;IACpB,IAAI,mBAAgD,CAAA;IACpD,IAAI,mBAAgD,CAAA;IAEpD,UAAU,CAAC,GAAG,EAAE;QACf,QAAQ,GAAG,EAAE,CAAA;QACb,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAC/D,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAC/D,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,KAA0B,EAAW,EAAE;YAC/D,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC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AC,QAAQ,CAAC,CAAC,CAAA;QAC/C,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QACjC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAiB,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;QAC/D,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAA;QACzC,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAA;QAC7C,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAA;QAChD,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAA;QAC5C,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAA;QACzC,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=load.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"load.test.d.ts","sourceRoot":"","sources":["../../src/config/load.test.ts"],"names":[],"mappings":""}
@@ -1,57 +0,0 @@
1
- import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';
2
- import { tmpdir } from 'node:os';
3
- import { join } from 'node:path';
4
- import { describe, expect, it } from 'vitest';
5
- import { loadConfig } from './load.js';
6
- describe('loadConfig cascade', () => {
7
- it('returns defaults when nothing is configured', () => {
8
- const home = mkdtempSync(join(tmpdir(), 'namzu-home-'));
9
- const cwd = mkdtempSync(join(tmpdir(), 'namzu-cwd-'));
10
- const cfg = loadConfig({ home, cwd, env: {} });
11
- expect(cfg.format).toBe('text');
12
- expect(cfg.quiet).toBe(false);
13
- });
14
- it('reads user config from ~/.namzu/config.yaml', () => {
15
- const home = mkdtempSync(join(tmpdir(), 'namzu-home-'));
16
- mkdirSync(join(home, '.namzu'), { recursive: true });
17
- writeFileSync(join(home, '.namzu', 'config.yaml'), 'format: yaml\nquiet: true\n');
18
- const cfg = loadConfig({ home, cwd: tmpdir(), env: {} });
19
- expect(cfg.format).toBe('yaml');
20
- expect(cfg.quiet).toBe(true);
21
- });
22
- it('project config overrides user config', () => {
23
- const home = mkdtempSync(join(tmpdir(), 'namzu-home-'));
24
- mkdirSync(join(home, '.namzu'), { recursive: true });
25
- writeFileSync(join(home, '.namzu', 'config.yaml'), 'format: yaml\n');
26
- const cwd = mkdtempSync(join(tmpdir(), 'namzu-cwd-'));
27
- writeFileSync(join(cwd, 'namzu.config.json'), JSON.stringify({ format: 'json' }));
28
- const cfg = loadConfig({ home, cwd, env: {} });
29
- expect(cfg.format).toBe('json');
30
- });
31
- it('env vars override file config', () => {
32
- const home = mkdtempSync(join(tmpdir(), 'namzu-home-'));
33
- mkdirSync(join(home, '.namzu'), { recursive: true });
34
- writeFileSync(join(home, '.namzu', 'config.yaml'), 'format: yaml\n');
35
- const cfg = loadConfig({
36
- home,
37
- cwd: tmpdir(),
38
- env: { NAMZU_FORMAT: 'text' },
39
- });
40
- expect(cfg.format).toBe('text');
41
- });
42
- it('ignores invalid format values silently', () => {
43
- const home = mkdtempSync(join(tmpdir(), 'namzu-home-'));
44
- mkdirSync(join(home, '.namzu'), { recursive: true });
45
- writeFileSync(join(home, '.namzu', 'config.yaml'), 'format: xml\n');
46
- const cfg = loadConfig({ home, cwd: tmpdir(), env: {} });
47
- expect(cfg.format).toBe('text');
48
- });
49
- it('ignores malformed yaml gracefully', () => {
50
- const home = mkdtempSync(join(tmpdir(), 'namzu-home-'));
51
- mkdirSync(join(home, '.namzu'), { recursive: true });
52
- writeFileSync(join(home, '.namzu', 'config.yaml'), ': : : not yaml\n');
53
- const cfg = loadConfig({ home, cwd: tmpdir(), env: {} });
54
- expect(cfg.format).toBe('text');
55
- });
56
- });
57
- //# sourceMappingURL=load.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"load.test.js","sourceRoot":"","sources":["../../src/config/load.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACtD,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC,CAAC,CAAA;QACvD,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,YAAY,CAAC,CAAC,CAAA;QACrD,MAAM,GAAG,GAAG,UAAU,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAA;QAC9C,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC/B,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC9B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACtD,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC,CAAC,CAAA;QACvD,SAAS,CAAC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,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC,CAAC,CAAA;QACvD,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QACpD,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,aAAa,CAAC,EAAE,kBAAkB,CAAC,CAAA;QACtE,MAAM,GAAG,GAAG,UAAU,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAA;QACxD,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAChC,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -1,10 +0,0 @@
1
- /**
2
- * What the block says about a directory, and what it refuses to claim.
3
- *
4
- * The facts here are read from a real repository created in a temp directory
5
- * rather than from a stubbed git: the two calls this makes are the part that
6
- * can be wrong on a real machine, and a fake `git` proves only that the
7
- * composer agrees with itself.
8
- */
9
- export {};
10
- //# sourceMappingURL=environment.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"environment.test.d.ts","sourceRoot":"","sources":["../../../src/context/__tests__/environment.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -1,84 +0,0 @@
1
- /**
2
- * What the block says about a directory, and what it refuses to claim.
3
- *
4
- * The facts here are read from a real repository created in a temp directory
5
- * rather than from a stubbed git: the two calls this makes are the part that
6
- * can be wrong on a real machine, and a fake `git` proves only that the
7
- * composer agrees with itself.
8
- */
9
- import { execFileSync } from 'node:child_process';
10
- import { mkdirSync, mkdtempSync, rmSync } from 'node:fs';
11
- import { tmpdir } from 'node:os';
12
- import { join } from 'node:path';
13
- import { afterEach, beforeEach, describe, expect, it } from 'vitest';
14
- import { composeEnvironmentPrompt, localIsoDate, readEnvironmentFacts, } from '../environment.js';
15
- let root;
16
- beforeEach(() => {
17
- root = mkdtempSync(join(tmpdir(), 'namzu-env-'));
18
- });
19
- afterEach(() => {
20
- rmSync(root, { recursive: true, force: true });
21
- });
22
- function initRepo(dir, branch) {
23
- mkdirSync(dir, { recursive: true });
24
- execFileSync('git', ['init', '--quiet'], { cwd: dir });
25
- // `checkout -b` on an unborn HEAD, so no commit and no identity config are
26
- // needed — and it is the case `rev-parse --abbrev-ref HEAD` cannot answer,
27
- // which is why the reader uses `symbolic-ref`.
28
- execFileSync('git', ['checkout', '-q', '-b', branch], { cwd: dir });
29
- }
30
- describe('the date', () => {
31
- it('is the local calendar date, not the UTC one', () => {
32
- // A machine behind UTC would otherwise be told it is tomorrow, and would
33
- // write tomorrow's date into a changelog — the exact mistake this block
34
- // exists to prevent, made by the block.
35
- const lateEvening = new Date(2026, 7, 6, 23, 30, 0);
36
- expect(localIsoDate(lateEvening)).toBe('2026-08-06');
37
- });
38
- it('zero-pads a single-digit month and day', () => {
39
- expect(localIsoDate(new Date(2026, 0, 5))).toBe('2026-01-05');
40
- });
41
- });
42
- describe('the repository', () => {
43
- it('reports the branch that is checked out', async () => {
44
- const repo = join(root, 'repo');
45
- initRepo(repo, 'feature/parser');
46
- const facts = await readEnvironmentFacts(repo);
47
- expect(facts.isRepository).toBe(true);
48
- expect(facts.branch).toBe('feature/parser');
49
- expect(composeEnvironmentPrompt(facts)).toContain('feature/parser');
50
- });
51
- it('says a directory is not a repository rather than staying quiet', async () => {
52
- const plain = join(root, 'plain');
53
- mkdirSync(plain);
54
- const facts = await readEnvironmentFacts(plain);
55
- expect(facts.isRepository).toBe(false);
56
- expect(facts.branch).toBeNull();
57
- expect(composeEnvironmentPrompt(facts)).toContain('not a git repository');
58
- });
59
- it('distinguishes a detached HEAD from not being a repository at all', async () => {
60
- // The two collapse into one if the reader only asks `symbolic-ref`, and
61
- // the difference is load-bearing: a commit made on a detached HEAD is not
62
- // reachable from any branch, which an agent about to commit should be
63
- // told.
64
- const facts = { today: '2026-08-06', branch: 'detached', isRepository: true };
65
- const prompt = composeEnvironmentPrompt(facts);
66
- expect(prompt).toContain('detached HEAD');
67
- expect(prompt).toContain('not reachable from any branch');
68
- expect(prompt).not.toContain('not a git repository');
69
- });
70
- });
71
- describe('what the block does not claim', () => {
72
- it('says nothing about uncommitted changes', async () => {
73
- // Deliberate. This text is the CACHED prefix of every request, and a
74
- // dirty-file count changes whenever the agent saves a file — carrying it
75
- // would re-key the cache on essentially every turn to say something
76
- // `git status` answers on demand. If a reader adds it, this test is what
77
- // tells them the cost.
78
- const repo = join(root, 'repo');
79
- initRepo(repo, 'main');
80
- const prompt = composeEnvironmentPrompt(await readEnvironmentFacts(repo));
81
- expect(prompt).not.toMatch(/uncommitted|modified file|dirty/i);
82
- });
83
- });
84
- //# sourceMappingURL=environment.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"environment.test.js","sourceRoot":"","sources":["../../../src/context/__tests__/environment.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAEpE,OAAO,EAEN,wBAAwB,EACxB,YAAY,EACZ,oBAAoB,GACpB,MAAM,mBAAmB,CAAA;AAE1B,IAAI,IAAY,CAAA;AAEhB,UAAU,CAAC,GAAG,EAAE;IACf,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,YAAY,CAAC,CAAC,CAAA;AACjD,CAAC,CAAC,CAAA;AAEF,SAAS,CAAC,GAAG,EAAE;IACd,MAAM,CAAC,IAAI,EAAE,EAAE,SA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C,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,+BAA+B,CAAC,CAAA;QACzD,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAA;IACrD,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC9C,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACvD,qEAAqE;QACrE,yEAAyE;QACzE,oEAAoE;QACpE,yEAAyE;QACzE,uBAAuB;QACvB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QAEtB,MAAM,MAAM,GAAG,wBAAwB,CAAC,MAAM,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAA;QAEzE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,kCAAkC,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -1,12 +0,0 @@
1
- /**
2
- * The walk, the boundary, the order and the budget.
3
- *
4
- * These are unit tests on the loader and they prove nothing about whether the
5
- * agent receives what the loader returns — that is
6
- * `src/__tests__/project-instructions-reach-the-turn.test.ts`, and it is the
7
- * one that fails if the wiring is deleted. This file exists for the properties
8
- * the front-door test cannot isolate: where the search STOPS, and what the
9
- * block says when a file was cut.
10
- */
11
- export {};
12
- //# sourceMappingURL=project.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"project.test.d.ts","sourceRoot":"","sources":["../../../src/context/__tests__/project.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}