@namzu/cli 1.0.1 → 2.1.1

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 (211) hide show
  1. package/dist/cli.d.ts.map +1 -1
  2. package/dist/cli.js +0 -2
  3. package/dist/cli.js.map +1 -1
  4. package/dist/integrations/providers/index.d.ts +0 -3
  5. package/dist/integrations/providers/index.d.ts.map +1 -1
  6. package/dist/integrations/providers/index.js +0 -5
  7. package/dist/integrations/providers/index.js.map +1 -1
  8. package/dist/tui/App.d.ts.map +1 -1
  9. package/dist/tui/App.js +8 -0
  10. package/dist/tui/App.js.map +1 -1
  11. package/dist/tui/agent.d.ts +10 -0
  12. package/dist/tui/agent.d.ts.map +1 -1
  13. package/dist/tui/agent.js +10 -0
  14. package/dist/tui/agent.js.map +1 -1
  15. package/dist/tui/slashCommands.d.ts +46 -0
  16. package/dist/tui/slashCommands.d.ts.map +1 -1
  17. package/dist/tui/slashCommands.js +96 -0
  18. package/dist/tui/slashCommands.js.map +1 -1
  19. package/package.json +11 -6
  20. package/dist/__tests__/environment-reaches-the-turn.test.d.ts +0 -17
  21. package/dist/__tests__/environment-reaches-the-turn.test.d.ts.map +0 -1
  22. package/dist/__tests__/environment-reaches-the-turn.test.js +0 -128
  23. package/dist/__tests__/environment-reaches-the-turn.test.js.map +0 -1
  24. package/dist/__tests__/headless-trust-gate.test.d.ts +0 -23
  25. package/dist/__tests__/headless-trust-gate.test.d.ts.map +0 -1
  26. package/dist/__tests__/headless-trust-gate.test.js +0 -227
  27. package/dist/__tests__/headless-trust-gate.test.js.map +0 -1
  28. package/dist/__tests__/mcp-servers-reach-the-session.test.d.ts +0 -17
  29. package/dist/__tests__/mcp-servers-reach-the-session.test.d.ts.map +0 -1
  30. package/dist/__tests__/mcp-servers-reach-the-session.test.js +0 -171
  31. package/dist/__tests__/mcp-servers-reach-the-session.test.js.map +0 -1
  32. package/dist/__tests__/permission-rules-reach-the-turn.test.d.ts +0 -31
  33. package/dist/__tests__/permission-rules-reach-the-turn.test.d.ts.map +0 -1
  34. package/dist/__tests__/permission-rules-reach-the-turn.test.js +0 -132
  35. package/dist/__tests__/permission-rules-reach-the-turn.test.js.map +0 -1
  36. package/dist/__tests__/project-instructions-reach-the-turn.test.d.ts +0 -24
  37. package/dist/__tests__/project-instructions-reach-the-turn.test.d.ts.map +0 -1
  38. package/dist/__tests__/project-instructions-reach-the-turn.test.js +0 -153
  39. package/dist/__tests__/project-instructions-reach-the-turn.test.js.map +0 -1
  40. package/dist/cli.test.d.ts +0 -2
  41. package/dist/cli.test.d.ts.map +0 -1
  42. package/dist/cli.test.js +0 -100
  43. package/dist/cli.test.js.map +0 -1
  44. package/dist/commands/__tests__/eval.test.d.ts +0 -2
  45. package/dist/commands/__tests__/eval.test.d.ts.map +0 -1
  46. package/dist/commands/__tests__/eval.test.js +0 -165
  47. package/dist/commands/__tests__/eval.test.js.map +0 -1
  48. package/dist/commands/__tests__/passthrough-help.test.d.ts +0 -2
  49. package/dist/commands/__tests__/passthrough-help.test.d.ts.map +0 -1
  50. package/dist/commands/__tests__/passthrough-help.test.js +0 -96
  51. package/dist/commands/__tests__/passthrough-help.test.js.map +0 -1
  52. package/dist/commands/__tests__/resume.test.d.ts +0 -15
  53. package/dist/commands/__tests__/resume.test.d.ts.map +0 -1
  54. package/dist/commands/__tests__/resume.test.js +0 -116
  55. package/dist/commands/__tests__/resume.test.js.map +0 -1
  56. package/dist/commands/__tests__/run-exit-code.test.d.ts +0 -2
  57. package/dist/commands/__tests__/run-exit-code.test.d.ts.map +0 -1
  58. package/dist/commands/__tests__/run-exit-code.test.js +0 -100
  59. package/dist/commands/__tests__/run-exit-code.test.js.map +0 -1
  60. package/dist/commands/__tests__/run-flags.test.d.ts +0 -11
  61. package/dist/commands/__tests__/run-flags.test.d.ts.map +0 -1
  62. package/dist/commands/__tests__/run-flags.test.js +0 -238
  63. package/dist/commands/__tests__/run-flags.test.js.map +0 -1
  64. package/dist/commands/__tests__/run-stream-flags.test.d.ts +0 -2
  65. package/dist/commands/__tests__/run-stream-flags.test.d.ts.map +0 -1
  66. package/dist/commands/__tests__/run-stream-flags.test.js +0 -295
  67. package/dist/commands/__tests__/run-stream-flags.test.js.map +0 -1
  68. package/dist/commands/doctor.test.d.ts +0 -2
  69. package/dist/commands/doctor.test.d.ts.map +0 -1
  70. package/dist/commands/doctor.test.js +0 -82
  71. package/dist/commands/doctor.test.js.map +0 -1
  72. package/dist/commands/providers.d.ts +0 -17
  73. package/dist/commands/providers.d.ts.map +0 -1
  74. package/dist/commands/providers.js +0 -274
  75. package/dist/commands/providers.js.map +0 -1
  76. package/dist/config/load.test.d.ts +0 -2
  77. package/dist/config/load.test.d.ts.map +0 -1
  78. package/dist/config/load.test.js +0 -57
  79. package/dist/config/load.test.js.map +0 -1
  80. package/dist/context/__tests__/environment.test.d.ts +0 -10
  81. package/dist/context/__tests__/environment.test.d.ts.map +0 -1
  82. package/dist/context/__tests__/environment.test.js +0 -84
  83. package/dist/context/__tests__/environment.test.js.map +0 -1
  84. package/dist/context/__tests__/project.test.d.ts +0 -12
  85. package/dist/context/__tests__/project.test.d.ts.map +0 -1
  86. package/dist/context/__tests__/project.test.js +0 -201
  87. package/dist/context/__tests__/project.test.js.map +0 -1
  88. package/dist/doctor/checks/credentials.test.d.ts +0 -10
  89. package/dist/doctor/checks/credentials.test.d.ts.map +0 -1
  90. package/dist/doctor/checks/credentials.test.js +0 -47
  91. package/dist/doctor/checks/credentials.test.js.map +0 -1
  92. package/dist/doctor/checks/sandbox.test.d.ts +0 -2
  93. package/dist/doctor/checks/sandbox.test.d.ts.map +0 -1
  94. package/dist/doctor/checks/sandbox.test.js +0 -59
  95. package/dist/doctor/checks/sandbox.test.js.map +0 -1
  96. package/dist/doctor/registry.test.d.ts +0 -7
  97. package/dist/doctor/registry.test.d.ts.map +0 -1
  98. package/dist/doctor/registry.test.js +0 -379
  99. package/dist/doctor/registry.test.js.map +0 -1
  100. package/dist/integrations/mcp/__tests__/connect.test.d.ts +0 -11
  101. package/dist/integrations/mcp/__tests__/connect.test.d.ts.map +0 -1
  102. package/dist/integrations/mcp/__tests__/connect.test.js +0 -231
  103. package/dist/integrations/mcp/__tests__/connect.test.js.map +0 -1
  104. package/dist/integrations/providers/discover.test.d.ts +0 -2
  105. package/dist/integrations/providers/discover.test.d.ts.map +0 -1
  106. package/dist/integrations/providers/discover.test.js +0 -93
  107. package/dist/integrations/providers/discover.test.js.map +0 -1
  108. package/dist/integrations/providers/keychain.test.d.ts +0 -2
  109. package/dist/integrations/providers/keychain.test.d.ts.map +0 -1
  110. package/dist/integrations/providers/keychain.test.js +0 -21
  111. package/dist/integrations/providers/keychain.test.js.map +0 -1
  112. package/dist/integrations/providers/mask.d.ts +0 -7
  113. package/dist/integrations/providers/mask.d.ts.map +0 -1
  114. package/dist/integrations/providers/mask.js +0 -14
  115. package/dist/integrations/providers/mask.js.map +0 -1
  116. package/dist/integrations/providers/mask.test.d.ts +0 -2
  117. package/dist/integrations/providers/mask.test.d.ts.map +0 -1
  118. package/dist/integrations/providers/mask.test.js +0 -20
  119. package/dist/integrations/providers/mask.test.js.map +0 -1
  120. package/dist/integrations/providers/oauth.test.d.ts +0 -2
  121. package/dist/integrations/providers/oauth.test.d.ts.map +0 -1
  122. package/dist/integrations/providers/oauth.test.js +0 -86
  123. package/dist/integrations/providers/oauth.test.js.map +0 -1
  124. package/dist/integrations/providers/preferences.test.d.ts +0 -2
  125. package/dist/integrations/providers/preferences.test.d.ts.map +0 -1
  126. package/dist/integrations/providers/preferences.test.js +0 -76
  127. package/dist/integrations/providers/preferences.test.js.map +0 -1
  128. package/dist/integrations/providers/schema.d.ts +0 -73
  129. package/dist/integrations/providers/schema.d.ts.map +0 -1
  130. package/dist/integrations/providers/schema.js +0 -70
  131. package/dist/integrations/providers/schema.js.map +0 -1
  132. package/dist/integrations/providers/schema.test.d.ts +0 -2
  133. package/dist/integrations/providers/schema.test.d.ts.map +0 -1
  134. package/dist/integrations/providers/schema.test.js +0 -43
  135. package/dist/integrations/providers/schema.test.js.map +0 -1
  136. package/dist/integrations/providers/store.d.ts +0 -32
  137. package/dist/integrations/providers/store.d.ts.map +0 -1
  138. package/dist/integrations/providers/store.js +0 -133
  139. package/dist/integrations/providers/store.js.map +0 -1
  140. package/dist/integrations/providers/store.test.d.ts +0 -2
  141. package/dist/integrations/providers/store.test.d.ts.map +0 -1
  142. package/dist/integrations/providers/store.test.js +0 -135
  143. package/dist/integrations/providers/store.test.js.map +0 -1
  144. package/dist/integrations/sessions/__tests__/archived-workspace.test.d.ts +0 -21
  145. package/dist/integrations/sessions/__tests__/archived-workspace.test.d.ts.map +0 -1
  146. package/dist/integrations/sessions/__tests__/archived-workspace.test.js +0 -62
  147. package/dist/integrations/sessions/__tests__/archived-workspace.test.js.map +0 -1
  148. package/dist/integrations/subagents/__tests__/delegation-trace.test.d.ts +0 -2
  149. package/dist/integrations/subagents/__tests__/delegation-trace.test.d.ts.map +0 -1
  150. package/dist/integrations/subagents/__tests__/delegation-trace.test.js +0 -114
  151. package/dist/integrations/subagents/__tests__/delegation-trace.test.js.map +0 -1
  152. package/dist/integrations/trust/store.test.d.ts +0 -2
  153. package/dist/integrations/trust/store.test.d.ts.map +0 -1
  154. package/dist/integrations/trust/store.test.js +0 -50
  155. package/dist/integrations/trust/store.test.js.map +0 -1
  156. package/dist/memory/store.test.d.ts +0 -2
  157. package/dist/memory/store.test.d.ts.map +0 -1
  158. package/dist/memory/store.test.js +0 -63
  159. package/dist/memory/store.test.js.map +0 -1
  160. package/dist/output/formatter.test.d.ts +0 -2
  161. package/dist/output/formatter.test.d.ts.map +0 -1
  162. package/dist/output/formatter.test.js +0 -88
  163. package/dist/output/formatter.test.js.map +0 -1
  164. package/dist/output/rendered-payload.test.d.ts +0 -2
  165. package/dist/output/rendered-payload.test.d.ts.map +0 -1
  166. package/dist/output/rendered-payload.test.js +0 -61
  167. package/dist/output/rendered-payload.test.js.map +0 -1
  168. package/dist/permissions/__tests__/mode.test.d.ts +0 -10
  169. package/dist/permissions/__tests__/mode.test.d.ts.map +0 -1
  170. package/dist/permissions/__tests__/mode.test.js +0 -115
  171. package/dist/permissions/__tests__/mode.test.js.map +0 -1
  172. package/dist/permissions/__tests__/rules.test.d.ts +0 -10
  173. package/dist/permissions/__tests__/rules.test.d.ts.map +0 -1
  174. package/dist/permissions/__tests__/rules.test.js +0 -196
  175. package/dist/permissions/__tests__/rules.test.js.map +0 -1
  176. package/dist/skills/store.test.d.ts +0 -2
  177. package/dist/skills/store.test.d.ts.map +0 -1
  178. package/dist/skills/store.test.js +0 -80
  179. package/dist/skills/store.test.js.map +0 -1
  180. package/dist/tui/__tests__/context-gauge.test.d.ts +0 -2
  181. package/dist/tui/__tests__/context-gauge.test.d.ts.map +0 -1
  182. package/dist/tui/__tests__/context-gauge.test.js +0 -83
  183. package/dist/tui/__tests__/context-gauge.test.js.map +0 -1
  184. package/dist/tui/__tests__/deferred-tool-discovery.test.d.ts +0 -24
  185. package/dist/tui/__tests__/deferred-tool-discovery.test.d.ts.map +0 -1
  186. package/dist/tui/__tests__/deferred-tool-discovery.test.js +0 -111
  187. package/dist/tui/__tests__/deferred-tool-discovery.test.js.map +0 -1
  188. package/dist/tui/__tests__/to-agent-event.test.d.ts +0 -2
  189. package/dist/tui/__tests__/to-agent-event.test.d.ts.map +0 -1
  190. package/dist/tui/__tests__/to-agent-event.test.js +0 -230
  191. package/dist/tui/__tests__/to-agent-event.test.js.map +0 -1
  192. package/dist/tui/__tests__/working-directory.test.d.ts +0 -13
  193. package/dist/tui/__tests__/working-directory.test.d.ts.map +0 -1
  194. package/dist/tui/__tests__/working-directory.test.js +0 -109
  195. package/dist/tui/__tests__/working-directory.test.js.map +0 -1
  196. package/dist/tui/agent.test.d.ts +0 -2
  197. package/dist/tui/agent.test.d.ts.map +0 -1
  198. package/dist/tui/agent.test.js +0 -225
  199. package/dist/tui/agent.test.js.map +0 -1
  200. package/dist/tui/markdownParser.test.d.ts +0 -2
  201. package/dist/tui/markdownParser.test.d.ts.map +0 -1
  202. package/dist/tui/markdownParser.test.js +0 -90
  203. package/dist/tui/markdownParser.test.js.map +0 -1
  204. package/dist/tui/mentions.test.d.ts +0 -2
  205. package/dist/tui/mentions.test.d.ts.map +0 -1
  206. package/dist/tui/mentions.test.js +0 -35
  207. package/dist/tui/mentions.test.js.map +0 -1
  208. package/dist/tui/slashCommands.test.d.ts +0 -2
  209. package/dist/tui/slashCommands.test.d.ts.map +0 -1
  210. package/dist/tui/slashCommands.test.js +0 -114
  211. 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-st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,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,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;YACnF,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AI,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,17 +0,0 @@
1
- /**
2
- * `namzu providers` — real implementation, replacing the M0 stub.
3
- *
4
- * Subcommands:
5
- * - `ls` List configured profiles (mask secrets by default).
6
- * - `add <name>` Persist a new profile.
7
- * - `remove <name>` Drop a profile from the store.
8
- * - `default <name>` Flip the `default` flag onto one profile.
9
- * - `path` Print the store path (useful for env automation).
10
- *
11
- * Passthrough mode + inner Commander instance — same pattern as `tools`.
12
- * Live provider instantiation (calling `ProviderRegistry.create`) is M3
13
- * work and not done here; M2's job is purely "store + retrieve + display".
14
- */
15
- import type { CommandDef } from './types.js';
16
- export declare const providersCommand: CommandDef;
17
- //# sourceMappingURL=providers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/commands/providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAmBH,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,YAAY,CAAA;AA0M5D,eAAO,MAAM,gBAAgB,EAAE,UAiF9B,CAAA"}