@namzu/cli 2.0.0 → 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 (176) hide show
  1. package/dist/tui/App.d.ts.map +1 -1
  2. package/dist/tui/App.js +8 -0
  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 +46 -0
  9. package/dist/tui/slashCommands.d.ts.map +1 -1
  10. package/dist/tui/slashCommands.js +96 -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@namzu/cli",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "description": "Operator CLI for the Namzu agent platform — namzu doctor + future commands. Dual-purpose: standalone bin (`namzu doctor`) and library (`import { runDoctor } from '@namzu/cli'`).",
5
5
  "keywords": [
6
6
  "namzu",
@@ -32,6 +32,11 @@
32
32
  },
33
33
  "files": [
34
34
  "dist",
35
+ "!dist/**/*.test.*",
36
+ "!dist/**/*.proc-test.*",
37
+ "!dist/**/__tests__",
38
+ "!dist/**/__fixtures__",
39
+ "!dist/**/test-setup.*",
35
40
  "README.md"
36
41
  ],
37
42
  "dependencies": {
@@ -39,11 +44,11 @@
39
44
  "ink": "^7.0.3",
40
45
  "react": "^19.2.6",
41
46
  "yaml": "^2.9.0",
42
- "@namzu/anthropic": "3.1.0",
43
- "@namzu/openai": "1.1.0",
44
- "@namzu/ollama": "2.0.0",
45
- "@namzu/openrouter": "2.0.0",
46
- "@namzu/sdk": "^14.0.7"
47
+ "@namzu/anthropic": "3.1.1",
48
+ "@namzu/ollama": "2.0.1",
49
+ "@namzu/openai": "1.1.1",
50
+ "@namzu/openrouter": "2.0.1",
51
+ "@namzu/sdk": "^15.0.0"
47
52
  },
48
53
  "devDependencies": {
49
54
  "@biomejs/biome": "^1.9.4",
@@ -1,17 +0,0 @@
1
- /**
2
- * The agent is told what day it is and which branch it is on, in the request
3
- * that is actually sent.
4
- *
5
- * A composer test proves the sentence is well formed and nothing about whether
6
- * anyone says it. The failure this invites is the block existing, being
7
- * correct, and never being joined into the prompt — which is silent: the model
8
- * keeps answering from its training cut-off, confidently, and every date it
9
- * writes into a changelog or a frontmatter field looks like an ordinary answer.
10
- *
11
- * So this starts at a REAL repository on disk and ends at the `systemPrompt`
12
- * `query()` was called with, and it drives the sub-agent path as well, because
13
- * a delegated task dating a file from the wrong year is the same defect one
14
- * hop further out.
15
- */
16
- export {};
17
- //# sourceMappingURL=environment-reaches-the-turn.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"environment-reaches-the-turn.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/environment-reaches-the-turn.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
@@ -1,128 +0,0 @@
1
- /**
2
- * The agent is told what day it is and which branch it is on, in the request
3
- * that is actually sent.
4
- *
5
- * A composer test proves the sentence is well formed and nothing about whether
6
- * anyone says it. The failure this invites is the block existing, being
7
- * correct, and never being joined into the prompt — which is silent: the model
8
- * keeps answering from its training cut-off, confidently, and every date it
9
- * writes into a changelog or a frontmatter field looks like an ordinary answer.
10
- *
11
- * So this starts at a REAL repository on disk and ends at the `systemPrompt`
12
- * `query()` was called with, and it drives the sub-agent path as well, because
13
- * a delegated task dating a file from the wrong year is the same defect one
14
- * hop further out.
15
- */
16
- import { execFileSync } from 'node:child_process';
17
- import { mkdirSync, mkdtempSync, rmSync } from 'node:fs';
18
- import { tmpdir } from 'node:os';
19
- import { join } from 'node:path';
20
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
21
- import { AgentRegistry } from '@namzu/sdk';
22
- import { localIsoDate } from '../context/environment.js';
23
- const queryCalls = [];
24
- vi.mock('@namzu/sdk', async (importOriginal) => {
25
- const actual = await importOriginal();
26
- return {
27
- ...actual,
28
- query: (params) => {
29
- queryCalls.push(params);
30
- return (async function* () { })();
31
- },
32
- };
33
- });
34
- let root;
35
- let repo;
36
- beforeEach(() => {
37
- queryCalls.length = 0;
38
- root = mkdtempSync(join(tmpdir(), 'namzu-env-turn-'));
39
- repo = join(root, 'repo');
40
- mkdirSync(repo, { recursive: true });
41
- execFileSync('git', ['init', '--quiet'], { cwd: repo });
42
- execFileSync('git', ['checkout', '-q', '-b', 'feature/parser'], { cwd: repo });
43
- });
44
- afterEach(() => {
45
- vi.restoreAllMocks();
46
- rmSync(root, { recursive: true, force: true });
47
- });
48
- const prefs = {
49
- version: 2,
50
- provider: 'anthropic',
51
- subagents: { active: [] },
52
- };
53
- function detectedAnthropic() {
54
- return [
55
- {
56
- entry: {
57
- id: 'anthropic',
58
- label: 'Anthropic',
59
- defaultModel: 'claude-sonnet-4-5',
60
- requiresApiKey: true,
61
- envVars: ['ANTHROPIC_API_KEY'],
62
- },
63
- source: 'env',
64
- apiKey: 'sk-ant-not-a-real-key',
65
- alternatives: [],
66
- },
67
- ];
68
- }
69
- async function openSessionIn(cwd) {
70
- const { createAgentSession } = await import('../tui/agent.js');
71
- return createAgentSession(prefs, detectedAnthropic(), { cwd });
72
- }
73
- async function drive(cwd) {
74
- const session = await openSessionIn(cwd);
75
- for await (const _ of session.send([{ role: 'user', content: 'hi', timestamp: 0 }])) {
76
- // drain
77
- }
78
- expect(queryCalls.length, 'the turn must have reached query()').toBe(1);
79
- return String(queryCalls[0]?.systemPrompt ?? '');
80
- }
81
- describe('where and when the agent is', () => {
82
- it("is in the system prompt of the turn, with today's date", async () => {
83
- const systemPrompt = await drive(repo);
84
- expect(systemPrompt).toContain(localIsoDate(new Date()));
85
- });
86
- it('names the branch that is actually checked out', async () => {
87
- const systemPrompt = await drive(repo);
88
- expect(systemPrompt).toContain('feature/parser');
89
- });
90
- it('follows the branch when it changes mid-session, instead of repeating the old one', async () => {
91
- // The reason this is read per turn. An agent that checks out a branch
92
- // itself — an ordinary thing to be asked to do — would otherwise spend
93
- // the rest of the session asserting the branch it started on, which is
94
- // worse than never having been told.
95
- const session = await openSessionIn(repo);
96
- for await (const _ of session.send([{ role: 'user', content: 'hi', timestamp: 0 }])) {
97
- // drain
98
- }
99
- execFileSync('git', ['checkout', '-q', '-b', 'feature/lexer'], { cwd: repo });
100
- for await (const _ of session.send([{ role: 'user', content: 'again', timestamp: 0 }])) {
101
- // drain
102
- }
103
- expect(String(queryCalls[0]?.systemPrompt)).toContain('feature/parser');
104
- expect(String(queryCalls[1]?.systemPrompt)).toContain('feature/lexer');
105
- });
106
- it('says a plain directory is not a repository', async () => {
107
- const plain = join(root, 'plain');
108
- mkdirSync(plain);
109
- const systemPrompt = await drive(plain);
110
- expect(systemPrompt).toContain('not a git repository');
111
- });
112
- it('reaches a sub-agent too', async () => {
113
- const registered = [];
114
- vi.spyOn(AgentRegistry.prototype, 'register').mockImplementation((def) => {
115
- for (const d of Array.isArray(def) ? def : [def])
116
- registered.push(d);
117
- });
118
- await openSessionIn(repo);
119
- const general = registered.find((d) => d.info.id === 'general-purpose');
120
- if (!general?.configBuilder) {
121
- throw new Error('the sub-agent runtime did not stand up — this test proves nothing');
122
- }
123
- const config = (await general.configBuilder({}));
124
- expect(config.systemPrompt).toContain('feature/parser');
125
- expect(config.systemPrompt).toContain(localIsoDate(new Date()));
126
- });
127
- });
128
- //# sourceMappingURL=environment-reaches-the-turn.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"environment-reaches-the-turn.test.js","sourceRoot":"","sources":["../../src/__tests__/environment-reaches-the-turn.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;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,SAA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AAO,EAAE,aAAa,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAA;QACrF,CAAC;QACD,MAAM,MAAM,GAAG,CAAC,MAAM,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAA8B,CAAA;QAC7E,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAA;QACvD,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAA;IAChE,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -1,23 +0,0 @@
1
- /**
2
- * A headless run in a folder nobody trusted does not start.
3
- *
4
- * `integrations/trust/store.ts` says the gate exists so that "before namzu
5
- * reads, runs commands in, or edits files in a directory, the user must trust
6
- * it". `isTrusted` had one caller — the TUI — so the sentence was true of the
7
- * TUI and false of everything else, and
8
- *
9
- * git clone <a stranger's repository> && cd <it> && namzu run "what is this?"
10
- *
11
- * ran that repository's code, unattended, with tools auto-approved because
12
- * there is nobody to ask.
13
- *
14
- * These tests drive the REAL command handlers with a real trust store pointed
15
- * at a temp home, because the failure this invites is a gate that exists and
16
- * is never consulted, and a test on `decideHeadlessTrust` alone passes with
17
- * both call sites deleted.
18
- *
19
- * The other half is just as important and is why the "proceeds" cases are here
20
- * too: a gate nothing can get past is a gate that has broken the product.
21
- */
22
- export {};
23
- //# sourceMappingURL=headless-trust-gate.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"headless-trust-gate.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/headless-trust-gate.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG"}
@@ -1,227 +0,0 @@
1
- /**
2
- * A headless run in a folder nobody trusted does not start.
3
- *
4
- * `integrations/trust/store.ts` says the gate exists so that "before namzu
5
- * reads, runs commands in, or edits files in a directory, the user must trust
6
- * it". `isTrusted` had one caller — the TUI — so the sentence was true of the
7
- * TUI and false of everything else, and
8
- *
9
- * git clone <a stranger's repository> && cd <it> && namzu run "what is this?"
10
- *
11
- * ran that repository's code, unattended, with tools auto-approved because
12
- * there is nobody to ask.
13
- *
14
- * These tests drive the REAL command handlers with a real trust store pointed
15
- * at a temp home, because the failure this invites is a gate that exists and
16
- * is never consulted, and a test on `decideHeadlessTrust` alone passes with
17
- * both call sites deleted.
18
- *
19
- * The other half is just as important and is why the "proceeds" cases are here
20
- * too: a gate nothing can get past is a gate that has broken the product.
21
- */
22
- import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
23
- import { tmpdir } from 'node:os';
24
- import { join } from 'node:path';
25
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
26
- import { EXIT_UNTRUSTED } from '../exit-codes.js';
27
- /**
28
- * Which directories the trust file says are trusted. Mutable per test, and
29
- * consulted through the REAL `isTrusted` — only the file it reads is redirected
30
- * — so the ancestor-walk semantics under test are the shipped ones.
31
- */
32
- let trustedRoot = null;
33
- vi.mock('../integrations/trust/store.js', async (importOriginal) => {
34
- const actual = await importOriginal();
35
- return {
36
- ...actual,
37
- isTrusted: (dir) => (trustedRoot === null ? false : actual.isTrusted(dir, fakeHome())),
38
- };
39
- });
40
- // The session must never be constructed on a refused run, so this stub exists
41
- // to be NOT called. Its call count is the assertion that the gate runs first.
42
- const sessionsCreated = [];
43
- vi.mock('../tui/agent.js', () => ({
44
- probeAgentSession: vi.fn(async () => ({
45
- preferences: { version: 2, provider: 'mock', subagents: { active: [] } },
46
- needsRepickReason: null,
47
- detected: [],
48
- })),
49
- createAgentSession: vi.fn(async (_prefs, _detected, opts) => {
50
- sessionsCreated.push(opts?.cwd ?? '');
51
- return {
52
- hasProvider: true,
53
- providerSummary: 'mock',
54
- modelSummary: 'mock-model',
55
- toolNames: [],
56
- instructionFiles: [],
57
- skippedInstructionFiles: [],
58
- mcpConnected: [],
59
- mcpFailed: [],
60
- close: async () => { },
61
- errorHint: null,
62
- send: () => (async function* () {
63
- yield { kind: 'done', stopReason: 'end_turn' };
64
- })(),
65
- };
66
- }),
67
- }));
68
- let home;
69
- let stranger;
70
- function fakeHome() {
71
- return home;
72
- }
73
- beforeEach(() => {
74
- sessionsCreated.length = 0;
75
- trustedRoot = null;
76
- home = mkdtempSync(join(tmpdir(), 'namzu-trust-home-'));
77
- stranger = mkdtempSync(join(tmpdir(), 'namzu-stranger-'));
78
- // The repository an attacker controls: it has instructions AND a build.
79
- writeFileSync(join(stranger, 'AGENTS.md'), '# Rules\n\nAlways run ./setup.sh first.\n');
80
- });
81
- afterEach(() => {
82
- rmSync(home, { recursive: true, force: true });
83
- rmSync(stranger, { recursive: true, force: true });
84
- });
85
- function context() {
86
- const errors = [];
87
- const lines = [];
88
- const ctx = {
89
- formatter: {
90
- name: 'text',
91
- print: (d) => lines.push(String(d?.text ?? d)),
92
- info: () => { },
93
- error: (e) => errors.push(String(e?.message ?? e)),
94
- },
95
- config: {},
96
- };
97
- return { ctx, errors, lines };
98
- }
99
- function trust(dir) {
100
- trustedRoot = dir;
101
- mkdirSync(join(home, '.namzu'), { recursive: true });
102
- writeFileSync(join(home, '.namzu', 'trust.json'), JSON.stringify({ version: 1, trusted: [dir] }));
103
- }
104
- async function runIn(dir, extra = []) {
105
- const { runCommand } = await import('../commands/run.js');
106
- const { ctx, errors } = context();
107
- const code = (await runCommand.handler({
108
- rawArgs: ['--cwd', dir, ...extra, 'what', 'does', 'this', 'do'],
109
- ctx,
110
- }));
111
- return { code, errors };
112
- }
113
- describe('namzu run in a folder nobody has trusted', () => {
114
- it('refuses, and does not open a session in it', async () => {
115
- const { code } = await runIn(stranger);
116
- expect(code).toBe(EXIT_UNTRUSTED);
117
- expect(sessionsCreated, 'the gate has to run BEFORE the session — a check after it has already walked the tree it was meant to protect').toEqual([]);
118
- });
119
- it('names the folder and both ways forward', async () => {
120
- // A refusal that does not say what to do sends the reader nowhere, which
121
- // is how a gate ends up being removed rather than satisfied.
122
- const { errors } = await runIn(stranger);
123
- const said = errors.join('\n');
124
- expect(said).toContain(stranger);
125
- expect(said).toContain('--trust');
126
- expect(said).toContain('namzu');
127
- });
128
- it('is a code of its own, not the usage code and not a failed run', async () => {
129
- // 64 says the caller's arguments are wrong and 1 says the run failed;
130
- // this is neither, and it is the only one a human decision about a
131
- // folder can fix. A caller that cannot tell them apart matches on the
132
- // message, and then the message can never be reworded.
133
- const { code } = await runIn(stranger);
134
- expect(code).toBe(77);
135
- });
136
- });
137
- describe('what gets past the gate', () => {
138
- it('a folder the operator trusted earlier', async () => {
139
- trust(stranger);
140
- const { code } = await runIn(stranger);
141
- expect(code).toBe(0);
142
- expect(sessionsCreated).toEqual([stranger]);
143
- });
144
- it('a subfolder of one they trusted', async () => {
145
- const sub = join(stranger, 'packages', 'api');
146
- mkdirSync(sub, { recursive: true });
147
- trust(stranger);
148
- const { code } = await runIn(sub);
149
- expect(code).toBe(0);
150
- });
151
- it('--trust, for this run', async () => {
152
- const { code } = await runIn(stranger, ['--trust']);
153
- expect(code).toBe(0);
154
- expect(sessionsCreated).toEqual([stranger]);
155
- });
156
- });
157
- describe('what does NOT get past the gate', () => {
158
- it('--yolo does not imply trust', async () => {
159
- // The two answer different questions: which tool calls may run inside a
160
- // folder, and whether this folder may be worked in at all. Someone who
161
- // passes --yolo in their own repository has asserted nothing about a
162
- // stranger's, and a gate an existing flag satisfies is a gate satisfied
163
- // by accident.
164
- const { code } = await runIn(stranger, ['--yolo']);
165
- expect(code).toBe(EXIT_UNTRUSTED);
166
- expect(sessionsCreated).toEqual([]);
167
- });
168
- it('--permission-mode strict does not imply trust either', async () => {
169
- const { code } = await runIn(stranger, ['--permission-mode', 'strict']);
170
- expect(code).toBe(EXIT_UNTRUSTED);
171
- });
172
- });
173
- describe('--trust does not remember', () => {
174
- it('leaves the trust file alone, so the next run asks again', async () => {
175
- // One reflexive use must not change the machine's state forever. The TUI
176
- // is the only path that records durable trust, because it is the only one
177
- // where a human is looking at a prompt.
178
- await runIn(stranger, ['--trust']);
179
- const { code } = await runIn(stranger);
180
- expect(code).toBe(EXIT_UNTRUSTED);
181
- });
182
- });
183
- describe('namzu run-stream in a folder nobody has trusted', () => {
184
- async function streamIn(dir, extra = []) {
185
- const { runStreamCommand } = await import('../commands/run-stream.js');
186
- const written = [];
187
- const originalWrite = process.stdout.write.bind(process.stdout);
188
- process.stdout.write = ((chunk) => {
189
- written.push(String(chunk));
190
- return true;
191
- });
192
- try {
193
- const { ctx } = context();
194
- const code = (await runStreamCommand.handler({
195
- rawArgs: ['--cwd', dir, ...extra, 'what', 'does', 'this', 'do'],
196
- ctx,
197
- }));
198
- return { code, events: written.map((l) => JSON.parse(l.trim())) };
199
- }
200
- finally {
201
- process.stdout.write = originalWrite;
202
- }
203
- }
204
- it('says so in band AND exits 77', async () => {
205
- // The one place this command departs from "every failure is an event and
206
- // the exit code is 0". That rule is about a run that STARTED and failed,
207
- // which a host may sensibly retry. This is a refusal to start, and a host
208
- // that cannot tell the two apart retries the one that must not be
209
- // retried.
210
- const { code, events } = await streamIn(stranger);
211
- expect(code).toBe(EXIT_UNTRUSTED);
212
- expect(events[0]?.kind).toBe('error');
213
- expect(String(events[0]?.message)).toContain('--trust');
214
- expect(events[events.length - 1]?.kind, 'a host waits for done').toBe('done');
215
- expect(sessionsCreated).toEqual([]);
216
- });
217
- it('proceeds with --trust', async () => {
218
- // `--session` keeps the turn off stdin: without a session key the command
219
- // reads prior history from a pipe, and in a test runner that pipe never
220
- // closes. The refusal case above needs no such thing, which is itself the
221
- // point — the gate returns before stdin is ever touched.
222
- const { code } = await streamIn(stranger, ['--trust', '--session', 'k']);
223
- expect(code).toBe(0);
224
- expect(sessionsCreated).toEqual([stranger]);
225
- });
226
- });
227
- //# sourceMappingURL=headless-trust-gate.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"headless-trust-gate.test.js","sourceRoot":"","sources":["../../src/__tests__/headless-trust-gate.test.ts"],"names":[],"mappings":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AAC,cAAc,CAAC,CAAA;QACjC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACrC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;QACvD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,uBAAuB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC7E,MAAM,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;QACtC,0EAA0E;QAC1E,wEAAwE;QACxE,0EAA0E;QAC1E,yDAAyD;QACzD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC,CAAA;QAExE,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACpB,MAAM,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAA;IAC5C,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -1,17 +0,0 @@
1
- /**
2
- * A tool server written into a config file ends up in the roster the model is
3
- * shown.
4
- *
5
- * The chain has three places to break, in series, and `packages/cli` has been
6
- * cut by two of them before:
7
- *
8
- * namzu.config.json → loadConfig() → createAgentSession() → the tool registry
9
- * ↑ the reader ↑ the connect ↑ the register
10
- *
11
- * `permissions` was dropped by the loader for its whole existence and again by
12
- * the turn, and every test at the time sat on one side or the other of a break.
13
- * So this one starts at a real config file and ends at `session.toolNames` —
14
- * the list `/tools` prints and the registry the turn is built from.
15
- */
16
- export {};
17
- //# sourceMappingURL=mcp-servers-reach-the-session.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mcp-servers-reach-the-session.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/mcp-servers-reach-the-session.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
@@ -1,171 +0,0 @@
1
- /**
2
- * A tool server written into a config file ends up in the roster the model is
3
- * shown.
4
- *
5
- * The chain has three places to break, in series, and `packages/cli` has been
6
- * cut by two of them before:
7
- *
8
- * namzu.config.json → loadConfig() → createAgentSession() → the tool registry
9
- * ↑ the reader ↑ the connect ↑ the register
10
- *
11
- * `permissions` was dropped by the loader for its whole existence and again by
12
- * the turn, and every test at the time sat on one side or the other of a break.
13
- * So this one starts at a real config file and ends at `session.toolNames` —
14
- * the list `/tools` prints and the registry the turn is built from.
15
- */
16
- import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
17
- import { tmpdir } from 'node:os';
18
- import { join } from 'node:path';
19
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
20
- import { loadConfig } from '../config/load.js';
21
- vi.mock('@namzu/sdk', async (importOriginal) => {
22
- const actual = await importOriginal();
23
- return {
24
- ...actual,
25
- query: () => (async function* () { })(),
26
- };
27
- });
28
- let work;
29
- const SERVER = `
30
- let buf = ''
31
- process.stdin.on('data', (chunk) => {
32
- buf += chunk
33
- let i
34
- while ((i = buf.indexOf('\\n')) >= 0) {
35
- const line = buf.slice(0, i)
36
- buf = buf.slice(i + 1)
37
- if (!line.trim()) continue
38
- const msg = JSON.parse(line)
39
- if (msg.method === 'initialize') {
40
- send({ jsonrpc: '2.0', id: msg.id, result: {
41
- protocolVersion: msg.params.protocolVersion,
42
- serverInfo: { name: 'tickets', version: '1' },
43
- capabilities: { tools: {} },
44
- }})
45
- } else if (msg.method === 'tools/list') {
46
- send({ jsonrpc: '2.0', id: msg.id, result: { tools: [
47
- { name: 'create', description: 'Open a ticket', inputSchema: {
48
- type: 'object', properties: { title: { type: 'string' } }, required: ['title'] } },
49
- ]}})
50
- } else if (msg.id !== undefined) {
51
- send({ jsonrpc: '2.0', id: msg.id, result: {} })
52
- }
53
- }
54
- })
55
- function send(o) { process.stdout.write(JSON.stringify(o) + '\\n') }
56
- `;
57
- beforeEach(() => {
58
- work = mkdtempSync(join(tmpdir(), 'namzu-mcp-session-'));
59
- });
60
- afterEach(async () => {
61
- for (let attempt = 0; attempt < 20; attempt++) {
62
- try {
63
- rmSync(work, { recursive: true, force: true });
64
- return;
65
- }
66
- catch {
67
- await new Promise((resolve) => setTimeout(resolve, 50));
68
- }
69
- }
70
- rmSync(work, { recursive: true, force: true });
71
- });
72
- const prefs = {
73
- version: 2,
74
- provider: 'anthropic',
75
- subagents: { active: [] },
76
- };
77
- function detectedAnthropic() {
78
- return [
79
- {
80
- entry: {
81
- id: 'anthropic',
82
- label: 'Anthropic',
83
- defaultModel: 'claude-sonnet-4-5',
84
- requiresApiKey: true,
85
- envVars: ['ANTHROPIC_API_KEY'],
86
- },
87
- source: 'env',
88
- apiKey: 'sk-ant-not-a-real-key',
89
- alternatives: [],
90
- },
91
- ];
92
- }
93
- describe('a tool server declared in namzu.config.json', () => {
94
- it('survives the config loader', () => {
95
- // The failure this pins: a public config field with no reader is parsed,
96
- // type-checks, and never arrives. It happened to `permissions`.
97
- writeFileSync(join(work, 'namzu.config.json'), JSON.stringify({ mcpServers: { tickets: { command: 'node', args: ['x.js'] } } }));
98
- const cfg = loadConfig({ cwd: work, home: work, env: {} });
99
- expect(cfg.mcpServers?.tickets?.command).toBe('node');
100
- expect(cfg.mcpServers?.tickets?.args).toEqual(['x.js']);
101
- });
102
- it('is in the tool roster the session hands the model', async () => {
103
- const server = join(work, 'tickets.js');
104
- writeFileSync(server, SERVER);
105
- writeFileSync(join(work, 'namzu.config.json'), JSON.stringify({
106
- mcpServers: { tickets: { command: process.execPath, args: [server] } },
107
- }));
108
- const cfg = loadConfig({ cwd: work, home: work, env: {} });
109
- const { createAgentSession } = await import('../tui/agent.js');
110
- const session = await createAgentSession(prefs, detectedAnthropic(), {
111
- cwd: work,
112
- ...(cfg.mcpServers ? { mcpServers: cfg.mcpServers } : {}),
113
- });
114
- try {
115
- expect(session.mcpFailed).toEqual([]);
116
- expect(session.mcpConnected).toEqual([{ name: 'tickets', toolCount: 1 }]);
117
- // The load-bearing one. Connecting and adapting is not the feature —
118
- // the model has to be able to see and call it.
119
- expect(session.toolNames).toContain('mcp_tickets_create');
120
- }
121
- finally {
122
- await session.close();
123
- }
124
- }, 20_000);
125
- it('does not take the builtin tools away', async () => {
126
- // Registering an extra set is the ordinary way to lose the existing one.
127
- const server = join(work, 'tickets.js');
128
- writeFileSync(server, SERVER);
129
- const { createAgentSession } = await import('../tui/agent.js');
130
- const session = await createAgentSession(prefs, detectedAnthropic(), {
131
- cwd: work,
132
- mcpServers: { tickets: { command: process.execPath, args: [server] } },
133
- });
134
- try {
135
- expect(session.toolNames).toContain('bash');
136
- expect(session.toolNames).toContain('read');
137
- expect(session.toolNames).toContain('mcp_tickets_create');
138
- }
139
- finally {
140
- await session.close();
141
- }
142
- }, 20_000);
143
- it('reports a server that failed, and adds no tools from it', async () => {
144
- const { createAgentSession } = await import('../tui/agent.js');
145
- const session = await createAgentSession(prefs, detectedAnthropic(), {
146
- cwd: work,
147
- mcpServers: { tickets: { command: join(work, 'no-such-executable') } },
148
- });
149
- try {
150
- expect(session.mcpConnected).toEqual([]);
151
- expect(session.mcpFailed.map((f) => f.name)).toEqual(['tickets']);
152
- expect(session.toolNames.some((n) => n.startsWith('mcp_'))).toBe(false);
153
- }
154
- finally {
155
- await session.close();
156
- }
157
- });
158
- it('adds nothing and reports nothing when none is configured', async () => {
159
- const { createAgentSession } = await import('../tui/agent.js');
160
- const session = await createAgentSession(prefs, detectedAnthropic(), { cwd: work });
161
- try {
162
- expect(session.mcpConnected).toEqual([]);
163
- expect(session.mcpFailed).toEqual([]);
164
- expect(session.toolNames.some((n) => n.startsWith('mcp_'))).toBe(false);
165
- }
166
- finally {
167
- await session.close();
168
- }
169
- });
170
- });
171
- //# sourceMappingURL=mcp-servers-reach-the-session.test.js.map