@linzumi/cli 1.0.272 → 1.0.274

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 (44) hide show
  1. package/README.md +1 -1
  2. package/dist/impl-res/cloud-supervisor.mjs +69 -69
  3. package/dist/impl-res/index.js +355 -314
  4. package/dist/impl-res/mcp-server.mjs +34 -34
  5. package/dist/impl-ts/cloud-supervisor.mjs +69 -69
  6. package/dist/impl-ts/index.js +495 -495
  7. package/dist/impl-ts/mcp-server.mjs +1 -1
  8. package/dist/mcp-server.mjs +1 -1
  9. package/package.json +3 -2
  10. package/scripts/check-package-size-budget.mjs +9 -0
  11. package/scripts/build-auth-parity-oracle.mjs +0 -709
  12. package/scripts/build-canonical-codex-transpiler-oracle.mjs +0 -93
  13. package/scripts/build-config-identity-parity-oracle.mjs +0 -526
  14. package/scripts/build-core-commander-seams-parity-oracle.mjs +0 -799
  15. package/scripts/build-core-daemon-parity-oracle.mjs +0 -573
  16. package/scripts/build-core-dispatch-input-queue-parity-oracle.mjs +0 -225
  17. package/scripts/build-core-fate-ladder-parity-oracle.mjs +0 -350
  18. package/scripts/build-core-generation-overlap-parity-oracle.mjs +0 -292
  19. package/scripts/build-core-integration-parity-oracle.mjs +0 -453
  20. package/scripts/build-core-lifecycle-guards-parity-oracle.mjs +0 -443
  21. package/scripts/build-core-lock-parity-oracle.mjs +0 -462
  22. package/scripts/build-core-reconnect-resume-parity-oracle.mjs +0 -365
  23. package/scripts/build-core-startup-resume-scan-parity-oracle.mjs +0 -296
  24. package/scripts/build-core-supervisor-parity-oracle.mjs +0 -781
  25. package/scripts/build-cross-harness-failover-oracle.mjs +0 -349
  26. package/scripts/build-editor-parity-oracle.mjs +0 -1525
  27. package/scripts/build-forwarding-parity-oracle.mjs +0 -1390
  28. package/scripts/build-harness-claude-parity-oracle.mjs +0 -407
  29. package/scripts/build-harness-codex-parity-oracle.mjs +0 -479
  30. package/scripts/build-mcp-parity-oracle.mjs +0 -412
  31. package/scripts/build-mcp-selector-parity-oracle.mjs +0 -65
  32. package/scripts/build-onboarding-discovery-parity-oracle.mjs +0 -388
  33. package/scripts/build-onboarding-flow-parity-oracle.mjs +0 -562
  34. package/scripts/build-onboarding-gateway-parity-oracle.mjs +0 -313
  35. package/scripts/build-onboarding-support-parity-oracle.mjs +0 -519
  36. package/scripts/build-pipeline-parity-oracle.mjs +0 -614
  37. package/scripts/build-protocol-parity-oracle.mjs +0 -398
  38. package/scripts/build-queue-parity-oracle.mjs +0 -1012
  39. package/scripts/build-session-registry-parity-oracle.mjs +0 -582
  40. package/scripts/build-transport-parity-oracle.mjs +0 -694
  41. package/scripts/build-tui-parity-oracle.mjs +0 -577
  42. package/scripts/build-vm-sandbox-parity-oracle.mjs +0 -1281
  43. package/scripts/build-worker-entry-parity-oracle.mjs +0 -424
  44. package/scripts/build-worker-spawn-parity-oracle.mjs +0 -823
@@ -1,388 +0,0 @@
1
- // Spec: kandan/plans/2026-07-10-compute-nodes-rescript-commander-zero-ts-program.md
2
- // (M3 cluster 13, onboarding - the DISCOVERY STACK slice).
3
- // Relationship: Builds the TS-side PARITY ORACLE for the onboarding
4
- // discovery port. The oracle bundles the REAL TS discovery modules -
5
- // onboardingProjectDiscovery.ts, onboardingConversationDiscovery.ts,
6
- // onboardingDiscoveryAgent.ts, onboardingDiscoveryChildProcess.ts,
7
- // onboardingPlaceResponsiveness.ts - plus the agent builder's REAL seam
8
- // modules (codexHome.ts, mcpConfig.ts, safeWorkingDir.ts, probed so the
9
- // ReScript port's injected deps carry the SAME real values) behind the
10
- // cluster 1/2 one-shot BATCH driver (a JSON array of cases on stdin, a
11
- // JSON array of results on stdout).
12
- //
13
- // CHILD ROLE MODE: when LINZUMI_ONBOARDING_DISCOVERY_ROLE is set in the
14
- // environment the oracle becomes a REAL discovery child running the REAL
15
- // runOnboardingDiscoveryChildRole over process stdin/stdout - exactly the
16
- // CLI entry's dispatch (src/index.ts main) - so EITHER impl's parent can
17
- // spawn this bundle as its discovery child (the cross-impl process legs).
18
- //
19
- // Determinism: both impls scan the SAME conformance-built scratch trees
20
- // (absolute paths ride the cases; nothing is normalized here - the
21
- // conformance normalizes wall-clock durations on both sides identically).
22
- //
23
- // SECRETS: synthetic case payloads only; .differential/ is gitignored.
24
- import { mkdir } from 'node:fs/promises';
25
- import { dirname, join } from 'node:path';
26
- import { fileURLToPath } from 'node:url';
27
- import { build } from 'esbuild';
28
-
29
- const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
30
-
31
- const driverSource = `
32
- import {
33
- discoverCurrentGitProject,
34
- defaultLocalProjectSourceRootsForTest,
35
- } from './src/onboardingProjectDiscovery';
36
- import {
37
- cleanConversationTitleForTest,
38
- discoverLocalConversations,
39
- readLocalConversationImportMessages,
40
- } from './src/onboardingConversationDiscovery';
41
- import {
42
- conversationDiscoveryPrompt,
43
- onboardingDiscoveryAgentPlans,
44
- onboardingDiscoveryAgentProcess,
45
- onboardingDiscoveryAgentProcessesForTest,
46
- projectDiscoveryPrompt,
47
- } from './src/onboardingDiscoveryAgent';
48
- import {
49
- discoverCurrentGitProjectInChildProcess,
50
- discoverLocalConversationsInChildProcess,
51
- onboardingDiscoveryRoleEnvKey,
52
- runOnboardingDiscoveryChildRole,
53
- } from './src/onboardingDiscoveryChildProcess';
54
- import {
55
- isPlaceResponsive,
56
- probeWorkerSourceForTest,
57
- } from './src/onboardingPlaceResponsiveness';
58
- import {
59
- codexCredentialStoreFileArgs,
60
- ensureIsolatedCodexHome,
61
- } from './src/codexHome';
62
- import { codexMcpConfigArgs, linzumiMcpServerConfig } from './src/mcpConfig';
63
- import { assessDangerousCwd } from './src/safeWorkingDir';
64
-
65
- function outcome(run) {
66
- try {
67
- const value = run();
68
- return value === undefined ? { defined: false } : { defined: true, value };
69
- } catch (error) {
70
- return {
71
- threw: true,
72
- message: error instanceof Error ? error.message : String(error),
73
- };
74
- }
75
- }
76
-
77
- const savedEnv = {};
78
-
79
- function setCaseEnv(env) {
80
- for (const [key, value] of Object.entries(env ?? {})) {
81
- savedEnv[key] = process.env[key];
82
- if (value === null) {
83
- delete process.env[key];
84
- } else {
85
- process.env[key] = value;
86
- }
87
- }
88
- }
89
-
90
- function restoreCaseEnv() {
91
- for (const [key, value] of Object.entries(savedEnv)) {
92
- if (value === undefined) {
93
- delete process.env[key];
94
- } else {
95
- process.env[key] = value;
96
- }
97
- delete savedEnv[key];
98
- }
99
- }
100
-
101
- function scriptedResponsiveness(testCase, probeCalls) {
102
- if (testCase.unresponsivePlaces === undefined && testCase.probeTimeoutMs === undefined) {
103
- return undefined;
104
- }
105
- const unresponsive = new Set(testCase.unresponsivePlaces ?? []);
106
- return {
107
- timeoutMs: testCase.probeTimeoutMs,
108
- probe: (path, timeoutMs) => {
109
- probeCalls.push({ path, timeoutMs });
110
- return !unresponsive.has(path);
111
- },
112
- };
113
- }
114
-
115
- function handleProjectDiscovery(testCase) {
116
- const probeCalls = [];
117
- setCaseEnv(testCase.env);
118
- try {
119
- const summary = discoverCurrentGitProject({
120
- cwd: testCase.args.cwd,
121
- nowMs: testCase.args.nowMs ?? undefined,
122
- homeDir: testCase.args.homeDir ?? undefined,
123
- sourceRoots: testCase.args.sourceRoots ?? undefined,
124
- selectedScanRoots: testCase.args.selectedScanRoots ?? undefined,
125
- includeRuntimeCwdHint: testCase.args.includeRuntimeCwdHint ?? undefined,
126
- sourceRootMaxDepth: testCase.args.sourceRootMaxDepth ?? undefined,
127
- sourceRootScanBudgetMs: testCase.args.sourceRootScanBudgetMs ?? undefined,
128
- sourceRootMaxDirectoryVisits:
129
- testCase.args.sourceRootMaxDirectoryVisits ?? undefined,
130
- sourceRootMaxProjectEnrichments:
131
- testCase.args.sourceRootMaxProjectEnrichments ?? undefined,
132
- placeResponsiveness: scriptedResponsiveness(testCase, probeCalls),
133
- });
134
- return { summary, probeCalls };
135
- } finally {
136
- restoreCaseEnv();
137
- }
138
- }
139
-
140
- function handleConversationDiscovery(testCase) {
141
- return {
142
- summary: discoverLocalConversations({
143
- homeDir: testCase.homeDir ?? undefined,
144
- env: testCase.env ?? undefined,
145
- nowMs: testCase.nowMs ?? undefined,
146
- candidateLimit: testCase.candidateLimit ?? undefined,
147
- }),
148
- };
149
- }
150
-
151
- function handleImportMessages(testCase) {
152
- return outcome(() =>
153
- readLocalConversationImportMessages({
154
- source: testCase.source,
155
- importKey: 'oracle-import-key',
156
- path: testCase.path,
157
- displayName: 'oracle-display-name',
158
- activityAt: undefined,
159
- metadata: {},
160
- })
161
- );
162
- }
163
-
164
- // The REAL seam values the ReScript port's injected deps must carry: the
165
- // credential-store args, the composed MCP config args, and the
166
- // dangerous-cwd verdict - probed from the same modules the TS builder
167
- // calls internally.
168
- function handleAgentSeams(testCase) {
169
- const assessment = assessDangerousCwd(testCase.cwd);
170
- return {
171
- credentialStoreFileArgs: codexCredentialStoreFileArgs(),
172
- mcpConfigArgs:
173
- testCase.mcp === undefined
174
- ? null
175
- : codexMcpConfigArgs(
176
- linzumiMcpServerConfig({
177
- command: testCase.mcp.command,
178
- argsPrefix: testCase.mcp.argsPrefix,
179
- kandanUrl: testCase.mcp.serviceUrl,
180
- authFilePath: testCase.mcp.authFilePath,
181
- ownerUsername: testCase.mcp.ownerUsername ?? undefined,
182
- operatingMode: testCase.mcp.operatingMode,
183
- toolScope: testCase.mcp.toolScope,
184
- cwd: testCase.mcp.cwd,
185
- }),
186
- // The discovery exec lane rides the plain approval_policy
187
- // "never" config string, never the granular never-equivalent
188
- // wire object - no tool-approval pin (#3819 security P1),
189
- // matching onboardingDiscoveryAgent.ts.
190
- { neverEquivalentGranularApprovalPolicy: false }
191
- ),
192
- dangerousReason: assessment.dangerous ? assessment.reason : null,
193
- };
194
- }
195
-
196
- function handleAgentProcess(testCase) {
197
- return outcome(() =>
198
- onboardingDiscoveryAgentProcess({
199
- kind: testCase.kind,
200
- workerId: testCase.workerId,
201
- workerLabel: testCase.workerLabel,
202
- codexBin: testCase.codexBin,
203
- cwd: testCase.cwd,
204
- kandanUrl: testCase.serviceUrl,
205
- runnerId: testCase.commanderId,
206
- workspaceSlug: testCase.workspaceSlug,
207
- ownerUsername: testCase.ownerUsername ?? undefined,
208
- model: testCase.model ?? undefined,
209
- authFilePath: testCase.authFilePath,
210
- prompt: testCase.prompt,
211
- linzumiCommand: testCase.mcpCommand,
212
- codexHome: testCase.codexHome,
213
- })
214
- );
215
- }
216
-
217
- function handleProcessesForTest(testCase) {
218
- setCaseEnv(testCase.env);
219
- try {
220
- return outcome(() =>
221
- onboardingDiscoveryAgentProcessesForTest({
222
- codexBin: testCase.codexBin,
223
- cwd: testCase.cwd,
224
- kandanUrl: testCase.serviceUrl,
225
- runnerId: testCase.commanderId,
226
- workspaceSlug: testCase.workspaceSlug,
227
- ownerUsername: testCase.ownerUsername ?? undefined,
228
- model: testCase.model ?? undefined,
229
- })
230
- );
231
- } finally {
232
- restoreCaseEnv();
233
- }
234
- }
235
-
236
- async function handleChildParent(testCase) {
237
- const logs = [];
238
- const log = (event, payload) => logs.push({ event, payload });
239
- setCaseEnv(testCase.env);
240
- try {
241
- const deps = {
242
- log,
243
- timeoutMs: testCase.timeoutMs ?? undefined,
244
- entryPath: testCase.entryPath ?? undefined,
245
- execPath: testCase.execPath ?? undefined,
246
- };
247
- const summary =
248
- testCase.kind === 'projects'
249
- ? await discoverCurrentGitProjectInChildProcess(testCase.args ?? { cwd: process.cwd() }, deps)
250
- : await discoverLocalConversationsInChildProcess(deps);
251
- return { summary, logs };
252
- } finally {
253
- restoreCaseEnv();
254
- }
255
- }
256
-
257
- function handleProbeInjected(testCase) {
258
- const calls = [];
259
- const result = isPlaceResponsive(testCase.path, {
260
- timeoutMs: testCase.timeoutMs ?? undefined,
261
- probe: (path, timeoutMs) => {
262
- calls.push({ path, timeoutMs });
263
- return testCase.verdict;
264
- },
265
- });
266
- return { result, calls };
267
- }
268
-
269
- async function handle(testCase) {
270
- switch (testCase.op) {
271
- case 'projectDiscovery':
272
- return handleProjectDiscovery(testCase);
273
- case 'defaultSourceRoots':
274
- return outcome(() =>
275
- defaultLocalProjectSourceRootsForTest({
276
- cwd: testCase.cwd,
277
- homeDir: testCase.homeDir ?? undefined,
278
- selectedScanRoots: testCase.selectedScanRoots ?? undefined,
279
- })
280
- );
281
- case 'conversationDiscovery':
282
- return handleConversationDiscovery(testCase);
283
- case 'importMessages':
284
- return handleImportMessages(testCase);
285
- case 'cleanTitle':
286
- return outcome(() =>
287
- cleanConversationTitleForTest(testCase.value ?? undefined)
288
- );
289
- case 'agentPlans':
290
- return outcome(() =>
291
- onboardingDiscoveryAgentPlans({
292
- cwd: testCase.cwd,
293
- runnerId: testCase.commanderId,
294
- workspaceSlug: testCase.workspaceSlug,
295
- })
296
- );
297
- case 'projectPrompt':
298
- return outcome(() =>
299
- projectDiscoveryPrompt({
300
- runnerId: testCase.commanderId,
301
- workspaceSlug: testCase.workspaceSlug,
302
- cwd: testCase.cwd ?? undefined,
303
- scope: testCase.scope ?? undefined,
304
- })
305
- );
306
- case 'conversationPrompt':
307
- return outcome(() =>
308
- conversationDiscoveryPrompt({
309
- runnerId: testCase.commanderId,
310
- workspaceSlug: testCase.workspaceSlug,
311
- source: testCase.source ?? undefined,
312
- })
313
- );
314
- case 'agentSeams':
315
- return handleAgentSeams(testCase);
316
- case 'agentProcess':
317
- return handleAgentProcess(testCase);
318
- case 'processesForTest':
319
- return handleProcessesForTest(testCase);
320
- case 'childParent':
321
- return handleChildParent(testCase);
322
- case 'probeSource':
323
- return {
324
- source: probeWorkerSourceForTest(),
325
- roleEnvKey: onboardingDiscoveryRoleEnvKey,
326
- };
327
- case 'probeInjected':
328
- return handleProbeInjected(testCase);
329
- case 'probeReal':
330
- return { result: isPlaceResponsive(testCase.path) };
331
- case 'isolatedCodexHome':
332
- setCaseEnv(testCase.env);
333
- try {
334
- return outcome(() => ensureIsolatedCodexHome());
335
- } finally {
336
- restoreCaseEnv();
337
- }
338
- default:
339
- return { threw: true, message: 'unknown op ' + String(testCase.op) };
340
- }
341
- }
342
-
343
- const roleValue = process.env[onboardingDiscoveryRoleEnvKey];
344
- if (roleValue !== undefined && roleValue !== '') {
345
- // The CLI entry's dispatch, verbatim: this bundle IS a real discovery
346
- // child for whichever parent implementation spawned it.
347
- process.exitCode = await runOnboardingDiscoveryChildRole(
348
- roleValue,
349
- process.stdin,
350
- process.stdout
351
- );
352
- } else {
353
- let stdin = '';
354
- process.stdin.setEncoding('utf8');
355
- for await (const chunk of process.stdin) {
356
- stdin += chunk;
357
- }
358
- const cases = JSON.parse(stdin);
359
- const results = [];
360
- for (const testCase of cases) {
361
- results.push(await handle(testCase));
362
- }
363
- process.stdout.write(JSON.stringify(results));
364
- }
365
- `;
366
-
367
- await mkdir(join(packageRoot, '.differential'), { recursive: true });
368
-
369
- await build({
370
- stdin: {
371
- contents: driverSource,
372
- resolveDir: packageRoot,
373
- sourcefile: 'onboarding-discovery-parity-driver.ts',
374
- loader: 'ts',
375
- },
376
- bundle: true,
377
- platform: 'node',
378
- target: 'node20',
379
- format: 'esm',
380
- outfile: join(
381
- packageRoot,
382
- '.differential/onboarding-discovery-parity-oracle.mjs'
383
- ),
384
- minify: false,
385
- sourcemap: false,
386
- legalComments: 'none',
387
- external: ['ws', 'undici', 'blessed', '@anthropic-ai/claude-agent-sdk'],
388
- });