@claude-flow/cli 3.63.4 → 3.63.6

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.
@@ -75,53 +75,53 @@ export declare const missionRecordSchema: z.ZodObject<{
75
75
  }, "strict", z.ZodTypeAny, {
76
76
  createdAt: string;
77
77
  updatedAt: string;
78
- schemaVersion: 1;
79
- state: "completed" | "cancelled" | "failed" | "blocked" | "running" | "paused" | "queued" | "draft" | "planned" | "awaitingAuthorization" | "pauseRequested" | "verifying" | "cancelRequested";
80
- acceptance: {
81
- revision: number;
82
- criteriaDigest: string;
83
- };
84
- plan: {
85
- revision: number;
86
- digest: string;
87
- taskGraphRef: string;
88
- };
89
78
  objective: string;
79
+ schemaVersion: 1;
90
80
  missionId: string;
91
81
  tenantId: string;
92
82
  workspaceId: string;
93
83
  ownerPrincipalId: string;
94
84
  revision: number;
85
+ plan: {
86
+ revision: number;
87
+ digest: string;
88
+ taskGraphRef: string;
89
+ };
95
90
  policyRef: string;
96
91
  budgetRef: string;
97
92
  executionMode: "durable-executor" | "session-bound";
93
+ state: "completed" | "running" | "failed" | "queued" | "cancelled" | "draft" | "planned" | "awaitingAuthorization" | "pauseRequested" | "paused" | "blocked" | "verifying" | "cancelRequested";
98
94
  evidenceRefs: string[];
95
+ acceptance: {
96
+ revision: number;
97
+ criteriaDigest: string;
98
+ };
99
99
  lastEventSequence: number;
100
100
  authorizationRef?: string | undefined;
101
101
  }, {
102
102
  createdAt: string;
103
103
  updatedAt: string;
104
- schemaVersion: 1;
105
- state: "completed" | "cancelled" | "failed" | "blocked" | "running" | "paused" | "queued" | "draft" | "planned" | "awaitingAuthorization" | "pauseRequested" | "verifying" | "cancelRequested";
106
- acceptance: {
107
- revision: number;
108
- criteriaDigest: string;
109
- };
110
- plan: {
111
- revision: number;
112
- digest: string;
113
- taskGraphRef: string;
114
- };
115
104
  objective: string;
105
+ schemaVersion: 1;
116
106
  missionId: string;
117
107
  tenantId: string;
118
108
  workspaceId: string;
119
109
  ownerPrincipalId: string;
120
110
  revision: number;
111
+ plan: {
112
+ revision: number;
113
+ digest: string;
114
+ taskGraphRef: string;
115
+ };
121
116
  policyRef: string;
122
117
  budgetRef: string;
123
118
  executionMode: "durable-executor" | "session-bound";
119
+ state: "completed" | "running" | "failed" | "queued" | "cancelled" | "draft" | "planned" | "awaitingAuthorization" | "pauseRequested" | "paused" | "blocked" | "verifying" | "cancelRequested";
124
120
  evidenceRefs: string[];
121
+ acceptance: {
122
+ revision: number;
123
+ criteriaDigest: string;
124
+ };
125
125
  lastEventSequence: number;
126
126
  authorizationRef?: string | undefined;
127
127
  }>;
@@ -145,8 +145,8 @@ export declare const taskSpecSchema: z.ZodObject<{
145
145
  checkpoint: z.ZodOptional<z.ZodString>;
146
146
  acceptanceEvidence: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
147
147
  }, "strict", z.ZodTypeAny, {
148
- id: string;
149
148
  title: string;
149
+ id: string;
150
150
  dependsOn: string[];
151
151
  executor: {
152
152
  mode: "durable-executor" | "session-bound";
@@ -157,16 +157,16 @@ export declare const taskSpecSchema: z.ZodObject<{
157
157
  acceptanceEvidence: string[];
158
158
  checkpoint?: string | undefined;
159
159
  }, {
160
- id: string;
161
160
  title: string;
161
+ id: string;
162
162
  executor: {
163
163
  mode: "durable-executor" | "session-bound";
164
164
  requirement: string;
165
165
  };
166
- checkpoint?: string | undefined;
167
166
  dependsOn?: string[] | undefined;
168
167
  capabilityCeiling?: string[] | undefined;
169
168
  estimatedCostMinor?: number | undefined;
169
+ checkpoint?: string | undefined;
170
170
  acceptanceEvidence?: string[] | undefined;
171
171
  }>;
172
172
  export declare const acceptanceCriterionSchema: z.ZodObject<{
@@ -192,8 +192,8 @@ export declare const acceptanceCriterionSchema: z.ZodObject<{
192
192
  check: string;
193
193
  producer: string;
194
194
  threshold?: string | undefined;
195
- baseline?: string | undefined;
196
195
  inputs?: string[] | undefined;
196
+ baseline?: string | undefined;
197
197
  independent?: boolean | undefined;
198
198
  mandatory?: boolean | undefined;
199
199
  }>;
@@ -207,16 +207,16 @@ export declare const budgetSpecSchema: z.ZodObject<{
207
207
  }, "strict", z.ZodTypeAny, {
208
208
  currency: string;
209
209
  ceilingMinor: number;
210
- concurrency?: number | undefined;
211
210
  tokens?: number | undefined;
212
211
  wallTimeSeconds?: number | undefined;
212
+ concurrency?: number | undefined;
213
213
  retries?: number | undefined;
214
214
  }, {
215
215
  currency: string;
216
216
  ceilingMinor: number;
217
- concurrency?: number | undefined;
218
217
  tokens?: number | undefined;
219
218
  wallTimeSeconds?: number | undefined;
219
+ concurrency?: number | undefined;
220
220
  retries?: number | undefined;
221
221
  }>;
222
222
  export declare const planBodySchema: z.ZodObject<{
@@ -239,8 +239,8 @@ export declare const planBodySchema: z.ZodObject<{
239
239
  checkpoint: z.ZodOptional<z.ZodString>;
240
240
  acceptanceEvidence: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
241
241
  }, "strict", z.ZodTypeAny, {
242
- id: string;
243
242
  title: string;
243
+ id: string;
244
244
  dependsOn: string[];
245
245
  executor: {
246
246
  mode: "durable-executor" | "session-bound";
@@ -251,16 +251,16 @@ export declare const planBodySchema: z.ZodObject<{
251
251
  acceptanceEvidence: string[];
252
252
  checkpoint?: string | undefined;
253
253
  }, {
254
- id: string;
255
254
  title: string;
255
+ id: string;
256
256
  executor: {
257
257
  mode: "durable-executor" | "session-bound";
258
258
  requirement: string;
259
259
  };
260
- checkpoint?: string | undefined;
261
260
  dependsOn?: string[] | undefined;
262
261
  capabilityCeiling?: string[] | undefined;
263
262
  estimatedCostMinor?: number | undefined;
263
+ checkpoint?: string | undefined;
264
264
  acceptanceEvidence?: string[] | undefined;
265
265
  }>, "many">;
266
266
  acceptance: z.ZodArray<z.ZodObject<{
@@ -286,8 +286,8 @@ export declare const planBodySchema: z.ZodObject<{
286
286
  check: string;
287
287
  producer: string;
288
288
  threshold?: string | undefined;
289
- baseline?: string | undefined;
290
289
  inputs?: string[] | undefined;
290
+ baseline?: string | undefined;
291
291
  independent?: boolean | undefined;
292
292
  mandatory?: boolean | undefined;
293
293
  }>, "many">;
@@ -301,16 +301,16 @@ export declare const planBodySchema: z.ZodObject<{
301
301
  }, "strict", z.ZodTypeAny, {
302
302
  currency: string;
303
303
  ceilingMinor: number;
304
- concurrency?: number | undefined;
305
304
  tokens?: number | undefined;
306
305
  wallTimeSeconds?: number | undefined;
306
+ concurrency?: number | undefined;
307
307
  retries?: number | undefined;
308
308
  }, {
309
309
  currency: string;
310
310
  ceilingMinor: number;
311
- concurrency?: number | undefined;
312
311
  tokens?: number | undefined;
313
312
  wallTimeSeconds?: number | undefined;
313
+ concurrency?: number | undefined;
314
314
  retries?: number | undefined;
315
315
  }>;
316
316
  scope: z.ZodDefault<z.ZodObject<{
@@ -322,8 +322,8 @@ export declare const planBodySchema: z.ZodObject<{
322
322
  }>>;
323
323
  }, "strict", z.ZodTypeAny, {
324
324
  tasks: {
325
- id: string;
326
325
  title: string;
326
+ id: string;
327
327
  dependsOn: string[];
328
328
  executor: {
329
329
  mode: "durable-executor" | "session-bound";
@@ -334,17 +334,6 @@ export declare const planBodySchema: z.ZodObject<{
334
334
  acceptanceEvidence: string[];
335
335
  checkpoint?: string | undefined;
336
336
  }[];
337
- scope: {
338
- capabilities: string[];
339
- };
340
- budget: {
341
- currency: string;
342
- ceilingMinor: number;
343
- concurrency?: number | undefined;
344
- tokens?: number | undefined;
345
- wallTimeSeconds?: number | undefined;
346
- retries?: number | undefined;
347
- };
348
337
  acceptance: {
349
338
  id: string;
350
339
  check: string;
@@ -355,38 +344,49 @@ export declare const planBodySchema: z.ZodObject<{
355
344
  threshold?: string | undefined;
356
345
  baseline?: string | undefined;
357
346
  }[];
347
+ budget: {
348
+ currency: string;
349
+ ceilingMinor: number;
350
+ tokens?: number | undefined;
351
+ wallTimeSeconds?: number | undefined;
352
+ concurrency?: number | undefined;
353
+ retries?: number | undefined;
354
+ };
355
+ scope: {
356
+ capabilities: string[];
357
+ };
358
358
  }, {
359
359
  tasks: {
360
- id: string;
361
360
  title: string;
361
+ id: string;
362
362
  executor: {
363
363
  mode: "durable-executor" | "session-bound";
364
364
  requirement: string;
365
365
  };
366
- checkpoint?: string | undefined;
367
366
  dependsOn?: string[] | undefined;
368
367
  capabilityCeiling?: string[] | undefined;
369
368
  estimatedCostMinor?: number | undefined;
369
+ checkpoint?: string | undefined;
370
370
  acceptanceEvidence?: string[] | undefined;
371
371
  }[];
372
- budget: {
373
- currency: string;
374
- ceilingMinor: number;
375
- concurrency?: number | undefined;
376
- tokens?: number | undefined;
377
- wallTimeSeconds?: number | undefined;
378
- retries?: number | undefined;
379
- };
380
372
  acceptance: {
381
373
  id: string;
382
374
  check: string;
383
375
  producer: string;
384
376
  threshold?: string | undefined;
385
- baseline?: string | undefined;
386
377
  inputs?: string[] | undefined;
378
+ baseline?: string | undefined;
387
379
  independent?: boolean | undefined;
388
380
  mandatory?: boolean | undefined;
389
381
  }[];
382
+ budget: {
383
+ currency: string;
384
+ ceilingMinor: number;
385
+ tokens?: number | undefined;
386
+ wallTimeSeconds?: number | undefined;
387
+ concurrency?: number | undefined;
388
+ retries?: number | undefined;
389
+ };
390
390
  scope?: {
391
391
  capabilities?: string[] | undefined;
392
392
  } | undefined;
@@ -397,11 +397,11 @@ export declare const createInputSchema: z.ZodObject<{
397
397
  requestId: z.ZodString;
398
398
  objective: z.ZodString;
399
399
  }, "strict", z.ZodTypeAny, {
400
- requestId: string;
401
400
  objective: string;
402
- }, {
403
401
  requestId: string;
402
+ }, {
404
403
  objective: string;
404
+ requestId: string;
405
405
  }>;
406
406
  export declare const planInputSchema: z.ZodObject<{
407
407
  requestId: z.ZodString;
@@ -427,8 +427,8 @@ export declare const planInputSchema: z.ZodObject<{
427
427
  checkpoint: z.ZodOptional<z.ZodString>;
428
428
  acceptanceEvidence: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
429
429
  }, "strict", z.ZodTypeAny, {
430
- id: string;
431
430
  title: string;
431
+ id: string;
432
432
  dependsOn: string[];
433
433
  executor: {
434
434
  mode: "durable-executor" | "session-bound";
@@ -439,16 +439,16 @@ export declare const planInputSchema: z.ZodObject<{
439
439
  acceptanceEvidence: string[];
440
440
  checkpoint?: string | undefined;
441
441
  }, {
442
- id: string;
443
442
  title: string;
443
+ id: string;
444
444
  executor: {
445
445
  mode: "durable-executor" | "session-bound";
446
446
  requirement: string;
447
447
  };
448
- checkpoint?: string | undefined;
449
448
  dependsOn?: string[] | undefined;
450
449
  capabilityCeiling?: string[] | undefined;
451
450
  estimatedCostMinor?: number | undefined;
451
+ checkpoint?: string | undefined;
452
452
  acceptanceEvidence?: string[] | undefined;
453
453
  }>, "many">;
454
454
  acceptance: z.ZodArray<z.ZodObject<{
@@ -474,8 +474,8 @@ export declare const planInputSchema: z.ZodObject<{
474
474
  check: string;
475
475
  producer: string;
476
476
  threshold?: string | undefined;
477
- baseline?: string | undefined;
478
477
  inputs?: string[] | undefined;
478
+ baseline?: string | undefined;
479
479
  independent?: boolean | undefined;
480
480
  mandatory?: boolean | undefined;
481
481
  }>, "many">;
@@ -489,16 +489,16 @@ export declare const planInputSchema: z.ZodObject<{
489
489
  }, "strict", z.ZodTypeAny, {
490
490
  currency: string;
491
491
  ceilingMinor: number;
492
- concurrency?: number | undefined;
493
492
  tokens?: number | undefined;
494
493
  wallTimeSeconds?: number | undefined;
494
+ concurrency?: number | undefined;
495
495
  retries?: number | undefined;
496
496
  }, {
497
497
  currency: string;
498
498
  ceilingMinor: number;
499
- concurrency?: number | undefined;
500
499
  tokens?: number | undefined;
501
500
  wallTimeSeconds?: number | undefined;
501
+ concurrency?: number | undefined;
502
502
  retries?: number | undefined;
503
503
  }>;
504
504
  scope: z.ZodDefault<z.ZodObject<{
@@ -510,8 +510,8 @@ export declare const planInputSchema: z.ZodObject<{
510
510
  }>>;
511
511
  }, "strict", z.ZodTypeAny, {
512
512
  tasks: {
513
- id: string;
514
513
  title: string;
514
+ id: string;
515
515
  dependsOn: string[];
516
516
  executor: {
517
517
  mode: "durable-executor" | "session-bound";
@@ -522,17 +522,6 @@ export declare const planInputSchema: z.ZodObject<{
522
522
  acceptanceEvidence: string[];
523
523
  checkpoint?: string | undefined;
524
524
  }[];
525
- scope: {
526
- capabilities: string[];
527
- };
528
- budget: {
529
- currency: string;
530
- ceilingMinor: number;
531
- concurrency?: number | undefined;
532
- tokens?: number | undefined;
533
- wallTimeSeconds?: number | undefined;
534
- retries?: number | undefined;
535
- };
536
525
  acceptance: {
537
526
  id: string;
538
527
  check: string;
@@ -543,48 +532,60 @@ export declare const planInputSchema: z.ZodObject<{
543
532
  threshold?: string | undefined;
544
533
  baseline?: string | undefined;
545
534
  }[];
535
+ budget: {
536
+ currency: string;
537
+ ceilingMinor: number;
538
+ tokens?: number | undefined;
539
+ wallTimeSeconds?: number | undefined;
540
+ concurrency?: number | undefined;
541
+ retries?: number | undefined;
542
+ };
543
+ scope: {
544
+ capabilities: string[];
545
+ };
546
546
  }, {
547
547
  tasks: {
548
- id: string;
549
548
  title: string;
549
+ id: string;
550
550
  executor: {
551
551
  mode: "durable-executor" | "session-bound";
552
552
  requirement: string;
553
553
  };
554
- checkpoint?: string | undefined;
555
554
  dependsOn?: string[] | undefined;
556
555
  capabilityCeiling?: string[] | undefined;
557
556
  estimatedCostMinor?: number | undefined;
557
+ checkpoint?: string | undefined;
558
558
  acceptanceEvidence?: string[] | undefined;
559
559
  }[];
560
- budget: {
561
- currency: string;
562
- ceilingMinor: number;
563
- concurrency?: number | undefined;
564
- tokens?: number | undefined;
565
- wallTimeSeconds?: number | undefined;
566
- retries?: number | undefined;
567
- };
568
560
  acceptance: {
569
561
  id: string;
570
562
  check: string;
571
563
  producer: string;
572
564
  threshold?: string | undefined;
573
- baseline?: string | undefined;
574
565
  inputs?: string[] | undefined;
566
+ baseline?: string | undefined;
575
567
  independent?: boolean | undefined;
576
568
  mandatory?: boolean | undefined;
577
569
  }[];
570
+ budget: {
571
+ currency: string;
572
+ ceilingMinor: number;
573
+ tokens?: number | undefined;
574
+ wallTimeSeconds?: number | undefined;
575
+ concurrency?: number | undefined;
576
+ retries?: number | undefined;
577
+ };
578
578
  scope?: {
579
579
  capabilities?: string[] | undefined;
580
580
  } | undefined;
581
581
  }>;
582
582
  }, "strict", z.ZodTypeAny, {
583
583
  requestId: string;
584
+ missionId: string;
584
585
  plan: {
585
586
  tasks: {
586
- id: string;
587
587
  title: string;
588
+ id: string;
588
589
  dependsOn: string[];
589
590
  executor: {
590
591
  mode: "durable-executor" | "session-bound";
@@ -595,17 +596,6 @@ export declare const planInputSchema: z.ZodObject<{
595
596
  acceptanceEvidence: string[];
596
597
  checkpoint?: string | undefined;
597
598
  }[];
598
- scope: {
599
- capabilities: string[];
600
- };
601
- budget: {
602
- currency: string;
603
- ceilingMinor: number;
604
- concurrency?: number | undefined;
605
- tokens?: number | undefined;
606
- wallTimeSeconds?: number | undefined;
607
- retries?: number | undefined;
608
- };
609
599
  acceptance: {
610
600
  id: string;
611
601
  check: string;
@@ -616,48 +606,58 @@ export declare const planInputSchema: z.ZodObject<{
616
606
  threshold?: string | undefined;
617
607
  baseline?: string | undefined;
618
608
  }[];
609
+ budget: {
610
+ currency: string;
611
+ ceilingMinor: number;
612
+ tokens?: number | undefined;
613
+ wallTimeSeconds?: number | undefined;
614
+ concurrency?: number | undefined;
615
+ retries?: number | undefined;
616
+ };
617
+ scope: {
618
+ capabilities: string[];
619
+ };
619
620
  };
620
- missionId: string;
621
621
  expectedRevision: number;
622
622
  }, {
623
623
  requestId: string;
624
+ missionId: string;
624
625
  plan: {
625
626
  tasks: {
626
- id: string;
627
627
  title: string;
628
+ id: string;
628
629
  executor: {
629
630
  mode: "durable-executor" | "session-bound";
630
631
  requirement: string;
631
632
  };
632
- checkpoint?: string | undefined;
633
633
  dependsOn?: string[] | undefined;
634
634
  capabilityCeiling?: string[] | undefined;
635
635
  estimatedCostMinor?: number | undefined;
636
+ checkpoint?: string | undefined;
636
637
  acceptanceEvidence?: string[] | undefined;
637
638
  }[];
638
- budget: {
639
- currency: string;
640
- ceilingMinor: number;
641
- concurrency?: number | undefined;
642
- tokens?: number | undefined;
643
- wallTimeSeconds?: number | undefined;
644
- retries?: number | undefined;
645
- };
646
639
  acceptance: {
647
640
  id: string;
648
641
  check: string;
649
642
  producer: string;
650
643
  threshold?: string | undefined;
651
- baseline?: string | undefined;
652
644
  inputs?: string[] | undefined;
645
+ baseline?: string | undefined;
653
646
  independent?: boolean | undefined;
654
647
  mandatory?: boolean | undefined;
655
648
  }[];
649
+ budget: {
650
+ currency: string;
651
+ ceilingMinor: number;
652
+ tokens?: number | undefined;
653
+ wallTimeSeconds?: number | undefined;
654
+ concurrency?: number | undefined;
655
+ retries?: number | undefined;
656
+ };
656
657
  scope?: {
657
658
  capabilities?: string[] | undefined;
658
659
  } | undefined;
659
660
  };
660
- missionId: string;
661
661
  expectedRevision: number;
662
662
  }>;
663
663
  export declare const getInputSchema: z.ZodObject<{
@@ -7,8 +7,8 @@
7
7
  * (a 2.1.107 npm-global beside a current native one, say) silently decides.
8
8
  */
9
9
  import { execFileSync } from 'node:child_process';
10
- import { existsSync, realpathSync, statSync } from 'node:fs';
11
- import { delimiter, join } from 'node:path';
10
+ import { closeSync, existsSync, fstatSync, openSync, readSync, realpathSync, statSync } from 'node:fs';
11
+ import { delimiter, dirname, join, resolve } from 'node:path';
12
12
  export const MODS_DEFAULT_ON = '2.1.287';
13
13
  export const MODS_FIRST = '2.1.277';
14
14
  const parse = (v) => v.split('.').map((n) => Number(n));
@@ -52,6 +52,98 @@ export const defaultVersionOf = (path) => {
52
52
  return null;
53
53
  }
54
54
  };
55
+ /** Known npm/cmd-shim Node launcher forms (legacy basedir and basedir_win).
56
+ * Match the whole template, not comments or arbitrary shell code. Unknown npm
57
+ * versions/formats simply keep the independent probe result. Never execute it.
58
+ */
59
+ const npmCmdShim = (entry, modern) => [
60
+ '@ECHO off', 'GOTO start', ':find_dp0', 'SET dp0=%~dp0', 'EXIT /b', ':start',
61
+ 'SETLOCAL', 'CALL :find_dp0', '', 'IF EXIST "%dp0%\\node.exe" (',
62
+ ' SET "_prog=%dp0%\\node.exe"', ') ELSE (', ' SET "_prog=node"',
63
+ ...(!modern ? [' SET PATHEXT=%PATHEXT:;.JS;=;%'] : []), ')', '',
64
+ 'endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & '
65
+ + (modern ? 'set PATHEXT=%PATHEXT:;.JS;=;% & ' : '')
66
+ + `"%_prog%" "%dp0%\\${entry.replaceAll('/', '\\')}" %*`, '',
67
+ ].join('\r\n');
68
+ const npmPosixShim = (entry, modern) => [
69
+ '#!/bin/sh', 'basedir=$(dirname "$(echo "$0" | sed -e \'s,\\\\,/,g\')")',
70
+ ...(modern ? ['basedir_win="$basedir"'] : []), '',
71
+ modern ? 'case `uname -a` in' : 'case `uname` in',
72
+ ...(modern ? [
73
+ ' *CYGWIN*|*MINGW*|*MSYS*)', ' if command -v cygpath > /dev/null 2>&1; then',
74
+ ' basedir_win=`cygpath -w "$basedir"`', ' fi', ' ;;', ' *WSL2*)',
75
+ ' if command -v wslpath > /dev/null 2>&1; then',
76
+ ' basedir_win="$(wslpath -w "$basedir" 2> /dev/null)"',
77
+ ' if [ $? -ne 0 ] || [ -z "$basedir_win" ]; then',
78
+ ' echo "Error: wslpath failed to convert path. WSL environment may be misconfigured." >&2',
79
+ ' exit 1', ' fi', ' fi', ' ;;',
80
+ ] : [
81
+ ' *CYGWIN*|*MINGW*|*MSYS*)', ' if command -v cygpath > /dev/null 2>&1; then',
82
+ ' basedir=`cygpath -w "$basedir"`', ' fi', ' ;;',
83
+ ]), 'esac', '',
84
+ ...(modern ? [
85
+ 'PROG_EXE="$basedir/node.exe"', 'if ! [ -x "$PROG_EXE" ]; then',
86
+ ' PROG_EXE="$basedir/node"', ' if ! [ -x "$PROG_EXE" ]; then',
87
+ ' PROG_EXE=node', ' if ! [ -x "$PROG_EXE" ]; then', ' PROG_EXE=node.exe',
88
+ ' fi', ' fi', 'fi', '', `exec "$PROG_EXE" "$basedir_win/${entry}" "$@"`,
89
+ ] : [
90
+ 'if [ -x "$basedir/node" ]; then', ` exec "$basedir/node" "$basedir/${entry}" "$@"`,
91
+ 'else ', ` exec node "$basedir/${entry}" "$@"`, 'fi',
92
+ ]), '',
93
+ ].join('\n');
94
+ // A no-shebang/native bin uses npm's direct-exec forms, not a Node wrapper.
95
+ const npmDirectCmdShim = (entry) => [
96
+ '@ECHO off', 'GOTO start', ':find_dp0', 'SET dp0=%~dp0', 'EXIT /b', ':start',
97
+ 'SETLOCAL', 'CALL :find_dp0', `"%dp0%\\${entry.replaceAll('/', '\\')}" %*`, '',
98
+ ].join('\r\n');
99
+ const npmDirectPosixShim = (entry, modern) => {
100
+ const nodeShim = npmPosixShim(entry, modern);
101
+ const preamble = nodeShim.slice(0, nodeShim.indexOf(modern ? 'PROG_EXE=' : 'if [ -x'));
102
+ return preamble + `exec "$basedir/${entry}" "$@"\n`;
103
+ };
104
+ function npmShimTarget(path, cmd) {
105
+ let fd;
106
+ try {
107
+ fd = openSync(path, 'r');
108
+ const stat = fstatSync(fd);
109
+ if (!stat.isFile() || stat.size > 64 * 1024)
110
+ return null;
111
+ // Also cap the actual read if a file grows after stat.
112
+ const bytes = Buffer.alloc(64 * 1024 + 1);
113
+ let size = 0;
114
+ while (size < bytes.length) {
115
+ const n = readSync(fd, bytes, size, bytes.length - size, null);
116
+ if (!n)
117
+ break;
118
+ size += n;
119
+ }
120
+ if (size > 64 * 1024)
121
+ return null;
122
+ const text = bytes.subarray(0, size).toString('utf8').replace(/\r\n/g, '\n').trimEnd();
123
+ const targets = cmd
124
+ ? [...text.matchAll(/"%dp0%\\([^"\r\n]+)" +%\*$/gm)].map(m => m[1].replaceAll('\\', '/'))
125
+ : [...text.matchAll(/^\s*exec (?:[^\r\n]* )?"\$basedir(?:_win)?\/([^"\r\n]+)" +"\$@"$/gm)].map(m => m[1]);
126
+ const entry = targets[0];
127
+ if (!entry || targets.some(t => t !== entry) || !/^[a-zA-Z0-9@._ /-]+$/.test(entry) || entry.startsWith('/'))
128
+ return null;
129
+ const template = cmd ? npmCmdShim : npmPosixShim;
130
+ const normalize = (value) => value.replace(/\r\n/g, '\n').trimEnd();
131
+ const node = [false, true].some(modern => normalize(template(entry, modern)) === text);
132
+ const direct = cmd ? normalize(npmDirectCmdShim(entry)) === text
133
+ : [false, true].some(modern => normalize(npmDirectPosixShim(entry, modern)) === text);
134
+ if (!node && !direct)
135
+ return null;
136
+ const target = realpathSync(resolve(dirname(path), entry));
137
+ return statSync(target).isFile() ? { path: target, mode: node ? 'node' : 'direct' } : null;
138
+ }
139
+ catch {
140
+ return null;
141
+ }
142
+ finally {
143
+ if (fd !== undefined)
144
+ closeSync(fd);
145
+ }
146
+ }
55
147
  /** Every `claude` on PATH, in PATH order (the first is what runs), plus ~/.local/bin. */
56
148
  export function findClaudeInstalls(env, home, versionOf = defaultVersionOf) {
57
149
  const names = process.platform === 'win32' ? ['claude.exe', 'claude.cmd', 'claude'] : ['claude'];
@@ -59,6 +151,7 @@ export function findClaudeInstalls(env, home, versionOf = defaultVersionOf) {
59
151
  const seen = new Set();
60
152
  const installs = [];
61
153
  for (const dir of dirs) {
154
+ let cmd;
62
155
  for (const name of names) {
63
156
  const path = join(dir, name);
64
157
  let real;
@@ -73,7 +166,19 @@ export function findClaudeInstalls(env, home, versionOf = defaultVersionOf) {
73
166
  if (seen.has(real))
74
167
  continue;
75
168
  seen.add(real);
76
- installs.push({ path, version: versionOf(path) });
169
+ let version = versionOf(path);
170
+ if (process.platform === 'win32' && name === 'claude' && version === null && cmd?.version) {
171
+ const target = npmShimTarget(path, false);
172
+ const cmdTarget = npmShimTarget(cmd.path, true);
173
+ if (target && cmdTarget && target.path === cmdTarget.path && target.mode === cmdTarget.mode)
174
+ version = cmd.version;
175
+ }
176
+ const install = { path, version };
177
+ installs.push(install);
178
+ // Only a .cmd actually probed in this directory can supply a version.
179
+ // A realpath-deduplicated alias in another directory proves nothing here.
180
+ if (name === 'claude.cmd')
181
+ cmd = install;
77
182
  }
78
183
  }
79
184
  return installs;