@standardagents/cli 0.45.3 → 0.45.4

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.
package/dist/index.js CHANGED
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command, Option } from 'commander';
3
- import path9 from 'path';
4
- import fs8 from 'fs';
3
+ import path13 from 'path';
4
+ import fs12 from 'fs';
5
5
  import { fileURLToPath, pathToFileURL } from 'url';
6
6
  import crypto2 from 'crypto';
7
- import os3 from 'os';
7
+ import os4 from 'os';
8
8
  import net from 'net';
9
9
  import childProcess, { spawn, execFileSync, spawnSync } from 'child_process';
10
- import { FIRST_PARTY_PROVIDER_PACKAGES, renderPnpmWorkspaceYaml, AGENT_DOCS, renderAgentBuilderSupportFiles } from '@standardagents/agentbuilder-template';
10
+ import { STANDARD_AGENTS_NPM_SCOPE, FIRST_PARTY_PROVIDER_PACKAGES, BUILD_GUARD_SCRIPT, renderPnpmWorkspaceYaml, AGENT_DOCS, renderAgentBuilderSupportFiles, STANDARD_AGENTS_NPM_REGISTRY } from '@standardagents/agentbuilder-template';
11
11
  import chalk from 'chalk';
12
+ import { parse as parse$1, parseDocument, visit, isScalar, isNode, isMap } from 'yaml';
12
13
  import { parse, modify, applyEdits } from 'jsonc-parser';
13
14
  import { loadFile, writeFile } from 'magicast';
14
15
  import { addVitePlugin } from 'magicast/helpers';
@@ -21,44 +22,44 @@ import { copySkill } from '@standardagents/skill';
21
22
  function findPnpmWorkspaceRoot(startDir) {
22
23
  let currentDir = startDir;
23
24
  while (true) {
24
- if (fs8.existsSync(path9.join(currentDir, "pnpm-workspace.yaml"))) {
25
+ if (fs12.existsSync(path13.join(currentDir, "pnpm-workspace.yaml"))) {
25
26
  return currentDir;
26
27
  }
27
- const parentDir = path9.dirname(currentDir);
28
+ const parentDir = path13.dirname(currentDir);
28
29
  if (parentDir === currentDir) {
29
30
  return null;
30
31
  }
31
32
  currentDir = parentDir;
32
33
  }
33
34
  }
34
- function findStandardAgentsWorkspaceRoot(startDir = path9.dirname(fileURLToPath(import.meta.url))) {
35
+ function findStandardAgentsWorkspaceRoot(startDir = path13.dirname(fileURLToPath(import.meta.url))) {
35
36
  let currentDir = startDir;
36
37
  for (; ; ) {
37
38
  const workspaceRoot = findPnpmWorkspaceRoot(currentDir);
38
39
  if (!workspaceRoot) return null;
39
- const manifestPath = path9.join(workspaceRoot, "package.json");
40
+ const manifestPath = path13.join(workspaceRoot, "package.json");
40
41
  try {
41
- const manifest = JSON.parse(fs8.readFileSync(manifestPath, "utf8"));
42
+ const manifest = JSON.parse(fs12.readFileSync(manifestPath, "utf8"));
42
43
  if (manifest && typeof manifest === "object" && "name" in manifest && manifest.name === "standardagents") {
43
44
  return workspaceRoot;
44
45
  }
45
46
  } catch {
46
47
  }
47
- const parent = path9.dirname(workspaceRoot);
48
+ const parent = path13.dirname(workspaceRoot);
48
49
  if (parent === workspaceRoot) return null;
49
50
  currentDir = parent;
50
51
  }
51
52
  }
52
53
  function resolveStandardAgentsWorkspaceRoot(startDirs = [
53
- path9.dirname(fileURLToPath(import.meta.url)),
54
+ path13.dirname(fileURLToPath(import.meta.url)),
54
55
  process.cwd()
55
56
  ]) {
56
57
  const explicitRoot = process.env.STANDARDAGENTS_WORKSPACE_ROOT?.trim();
57
58
  if (explicitRoot) {
58
- const workspaceRoot = findStandardAgentsWorkspaceRoot(path9.resolve(explicitRoot));
59
+ const workspaceRoot = findStandardAgentsWorkspaceRoot(path13.resolve(explicitRoot));
59
60
  if (workspaceRoot) return workspaceRoot;
60
61
  throw new Error(
61
- `STANDARDAGENTS_WORKSPACE_ROOT=${path9.resolve(explicitRoot)} is not a Standard Agents workspace root`
62
+ `STANDARDAGENTS_WORKSPACE_ROOT=${path13.resolve(explicitRoot)} is not a Standard Agents workspace root`
62
63
  );
63
64
  }
64
65
  for (const startDir of startDirs) {
@@ -68,14 +69,14 @@ function resolveStandardAgentsWorkspaceRoot(startDirs = [
68
69
  return null;
69
70
  }
70
71
  function workspacePackageDir(workspaceRoot, packageName) {
71
- return path9.join(workspaceRoot, "packages", packageName.replace("@standardagents/", ""));
72
+ return path13.join(workspaceRoot, "packages", packageName.replace("@standardagents/", ""));
72
73
  }
73
74
  function validateWorkspacePackageDir(packageName, packageDir) {
74
- const dependencyPackageJsonPath = path9.join(packageDir, "package.json");
75
- if (!fs8.existsSync(dependencyPackageJsonPath)) {
75
+ const dependencyPackageJsonPath = path13.join(packageDir, "package.json");
76
+ if (!fs12.existsSync(dependencyPackageJsonPath)) {
76
77
  throw new Error(`Could not find workspace package for ${packageName} at ${packageDir}`);
77
78
  }
78
- const manifest = JSON.parse(fs8.readFileSync(dependencyPackageJsonPath, "utf8"));
79
+ const manifest = JSON.parse(fs12.readFileSync(dependencyPackageJsonPath, "utf8"));
79
80
  const name = manifest && typeof manifest === "object" && "name" in manifest ? manifest.name : void 0;
80
81
  if (name !== packageName) {
81
82
  throw new Error(`Expected ${packageDir} to contain ${packageName}, found ${String(name ?? "unknown package")}`);
@@ -102,12 +103,12 @@ function packageManagerEnv(base = process.env) {
102
103
  return env;
103
104
  }
104
105
  function writePrivateFileSync(filePath, content) {
105
- const descriptor = fs8.openSync(filePath, "w", 384);
106
+ const descriptor = fs12.openSync(filePath, "w", 384);
106
107
  try {
107
- fs8.fchmodSync(descriptor, 384);
108
- fs8.writeFileSync(descriptor, content, "utf8");
108
+ fs12.fchmodSync(descriptor, 384);
109
+ fs12.writeFileSync(descriptor, content, "utf8");
109
110
  } finally {
110
- fs8.closeSync(descriptor);
111
+ fs12.closeSync(descriptor);
111
112
  }
112
113
  }
113
114
 
@@ -193,11 +194,11 @@ function collapseBlankLines(content) {
193
194
  return (result + outside(content.slice(cursor))).replace(/^\n+/, "");
194
195
  }
195
196
  function readDevVarsFile(projectPath) {
196
- const filePath = path9.join(projectPath, DEV_VARS_FILENAME);
197
- return fs8.existsSync(filePath) ? fs8.readFileSync(filePath, "utf-8") : "";
197
+ const filePath = path13.join(projectPath, DEV_VARS_FILENAME);
198
+ return fs12.existsSync(filePath) ? fs12.readFileSync(filePath, "utf-8") : "";
198
199
  }
199
200
  function writeDevVarsFile(projectPath, content) {
200
- const filePath = path9.join(projectPath, DEV_VARS_FILENAME);
201
+ const filePath = path13.join(projectPath, DEV_VARS_FILENAME);
201
202
  writePrivateFileSync(filePath, content === "" || content.endsWith("\n") ? content : `${content}
202
203
  `);
203
204
  return filePath;
@@ -261,15 +262,520 @@ var logger = {
261
262
  console.log(message);
262
263
  }
263
264
  };
264
- var STATE_RELATIVE_PATH = path9.join(".agents", "bootstrap-session.json");
265
+ var SCOPE_PREFIX = `${STANDARD_AGENTS_NPM_SCOPE}/`;
266
+ var YARN_CLASSIC_REGISTRY = "https://registry.yarnpkg.com/";
267
+ var PUBLIC_REGISTRIES = [STANDARD_AGENTS_NPM_REGISTRY, YARN_CLASSIC_REGISTRY];
268
+ var PLAIN_SEMVER = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
269
+ function isForeignRegistryUrl(url) {
270
+ return /^https?:\/\//.test(url) && !PUBLIC_REGISTRIES.some((registry) => url.startsWith(registry));
271
+ }
272
+ function isFirstPartyRelease(name, version) {
273
+ return typeof name === "string" && name.startsWith(SCOPE_PREFIX) && typeof version === "string" && PLAIN_SEMVER.test(version);
274
+ }
275
+ function publicTarballUrl(registry, name, version) {
276
+ return `${registry}${name}/-/${name.slice(SCOPE_PREFIX.length)}-${version}.tgz`;
277
+ }
278
+ function isObject(value) {
279
+ return typeof value === "object" && value !== null && !Array.isArray(value);
280
+ }
281
+ function migrateNpmEntries(entries, installedNameOf) {
282
+ if (!isObject(entries)) return false;
283
+ let changed = false;
284
+ for (const [key, value] of Object.entries(entries)) {
285
+ if (!isObject(value)) continue;
286
+ const entry = value;
287
+ const name = entry.name ?? installedNameOf(key);
288
+ if (isFirstPartyRelease(name, entry.version) && typeof entry.resolved === "string" && isForeignRegistryUrl(entry.resolved)) {
289
+ value.resolved = publicTarballUrl(STANDARD_AGENTS_NPM_REGISTRY, name, String(entry.version));
290
+ changed = true;
291
+ }
292
+ if (migrateNpmEntries(entry.dependencies, (childKey) => childKey)) changed = true;
293
+ }
294
+ return changed;
295
+ }
296
+ var migratePackageLock = (text) => {
297
+ let lock;
298
+ try {
299
+ lock = JSON.parse(text);
300
+ } catch {
301
+ return text;
302
+ }
303
+ if (!isObject(lock)) return text;
304
+ const installedName = (key) => key.slice(key.lastIndexOf("node_modules/") + "node_modules/".length);
305
+ const changedPackages = migrateNpmEntries(lock.packages, installedName);
306
+ const changedTree = migrateNpmEntries(lock.dependencies, (key) => key);
307
+ if (!changedPackages && !changedTree) return text;
308
+ const indent = /^([ \t]+)"/m.exec(text)?.[1] ?? "";
309
+ const eol = text.includes("\r\n") ? "\r\n" : "\n";
310
+ const body = JSON.stringify(lock, null, indent).replaceAll("\n", eol);
311
+ return /\r?\n$/.test(text) ? `${body}${eol}` : body;
312
+ };
313
+ var migrateBunLock = (text) => text.replace(
314
+ /^(\s*"[^"\n]+":\s*\["(@standardagents\/[^"@\n]+)@([^"\n]+)",\s*)"([^"\n]*)"/gm,
315
+ // bun records an empty string for a package from its configured registry.
316
+ (line, head, name, version, url) => isFirstPartyRelease(name, version) && isForeignRegistryUrl(url) ? `${head}""` : line
317
+ );
318
+ var migrateYarnClassicLock = (text) => {
319
+ if (!text.includes("# yarn lockfile v1")) return text;
320
+ let name = null;
321
+ let version = null;
322
+ return text.split(/(?<=\n)/).map((line) => {
323
+ if (!/^\s/.test(line)) {
324
+ const descriptors = line.trim().replace(/:$/, "").split(/,\s*/).map((descriptor) => descriptor.replace(/^"|"$/g, ""));
325
+ const names = descriptors.map((descriptor) => /^(@standardagents\/[^@\s]+)@(?!npm:|file:|link:|git|https?:|github:)/.exec(descriptor)?.[1]);
326
+ name = names[0] !== void 0 && names.every((candidate) => candidate === names[0]) ? names[0] : null;
327
+ version = null;
328
+ return line;
329
+ }
330
+ if (name === null) return line;
331
+ const versionField = /^\s+version "([^"]+)"/.exec(line);
332
+ if (versionField) {
333
+ version = versionField[1];
334
+ return line;
335
+ }
336
+ const resolvedField = /^(\s+resolved ")([^"#]+)(#[^"]*)?(".*)$/s.exec(line);
337
+ if (!resolvedField || !isFirstPartyRelease(name, version) || !isForeignRegistryUrl(resolvedField[2])) return line;
338
+ return `${resolvedField[1]}${publicTarballUrl(YARN_CLASSIC_REGISTRY, name, String(version))}${resolvedField[3] ?? ""}${resolvedField[4]}`;
339
+ }).join("");
340
+ };
341
+ var LOCKFILE_MIGRATIONS = {
342
+ "package-lock.json": migratePackageLock,
343
+ "npm-shrinkwrap.json": migratePackageLock,
344
+ "bun.lock": migrateBunLock,
345
+ "yarn.lock": migrateYarnClassicLock
346
+ };
347
+ var PACKAGE_MANAGERS = ["npm", "pnpm", "yarn", "bun"];
348
+ var LOCKFILES = [
349
+ ["pnpm-lock.yaml", "pnpm"],
350
+ ["package-lock.json", "npm"],
351
+ ["npm-shrinkwrap.json", "npm"],
352
+ ["yarn.lock", "yarn"],
353
+ ["bun.lock", "bun"],
354
+ ["bun.lockb", "bun"]
355
+ ];
356
+ function isPackageManager(name) {
357
+ return PACKAGE_MANAGERS.includes(name);
358
+ }
359
+ function declaredPackageManager(projectPath) {
360
+ try {
361
+ const manifest = JSON.parse(fs12.readFileSync(path13.join(projectPath, "package.json"), "utf-8"));
362
+ if (!manifest || typeof manifest !== "object" || !("packageManager" in manifest)) return null;
363
+ const declared = /^([a-z]+)@(\d+)/.exec(String(manifest.packageManager));
364
+ return declared && isPackageManager(declared[1]) ? { name: declared[1], major: Number(declared[2]) } : null;
365
+ } catch {
366
+ return null;
367
+ }
368
+ }
369
+ function globToRegExp(glob) {
370
+ if (/[{}[\]()]/.test(glob)) return null;
371
+ const segments = glob.replace(/^\.\//, "").replace(/\/+$/, "").split("/");
372
+ const pattern = segments.map((segment, index) => {
373
+ const last = index === segments.length - 1;
374
+ if (segment === "**") return last ? ".*" : "(?:.*/)?";
375
+ const literal = segment.replace(/[.+^$|\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]");
376
+ return last ? literal : `${literal}/`;
377
+ }).join("");
378
+ return new RegExp(`^${pattern}$`);
379
+ }
380
+ function isPnpmWorkspaceMember(workspaceRoot, projectPath) {
381
+ const relative = path13.relative(workspaceRoot, projectPath).split(path13.sep).join("/");
382
+ if (relative === "") return true;
383
+ if (relative.startsWith("..")) return false;
384
+ let packages;
385
+ try {
386
+ const workspace = parse$1(fs12.readFileSync(path13.join(workspaceRoot, "pnpm-workspace.yaml"), "utf-8"));
387
+ packages = workspace && typeof workspace === "object" && "packages" in workspace ? workspace.packages : void 0;
388
+ } catch {
389
+ return false;
390
+ }
391
+ if (!Array.isArray(packages) || !packages.every((entry) => typeof entry === "string")) return false;
392
+ const matches = (glob) => globToRegExp(glob)?.test(relative);
393
+ const excluded = packages.filter((glob) => glob.startsWith("!")).map((glob) => matches(glob.slice(1)));
394
+ const included = packages.filter((glob) => !glob.startsWith("!")).map(matches);
395
+ if (excluded.some((result) => result !== false)) return false;
396
+ return included.some((result) => result === true);
397
+ }
398
+ function inferProjectPackageManager(projectPath) {
399
+ const declared = declaredPackageManager(projectPath);
400
+ if (declared) return declared.name;
401
+ for (const [lockfile, packageManager] of LOCKFILES) {
402
+ if (fs12.existsSync(path13.join(projectPath, lockfile))) return packageManager;
403
+ }
404
+ const workspaceRoot = findPnpmWorkspaceRoot(projectPath);
405
+ return workspaceRoot && isPnpmWorkspaceMember(workspaceRoot, projectPath) ? "pnpm" : void 0;
406
+ }
407
+ function registryConfigRoot(projectPath, packageManager, isolateFromParent) {
408
+ if (packageManager !== "pnpm" || isolateFromParent) return projectPath;
409
+ const workspaceRoot = findPnpmWorkspaceRoot(projectPath);
410
+ return workspaceRoot && isPnpmWorkspaceMember(workspaceRoot, projectPath) ? workspaceRoot : projectPath;
411
+ }
412
+ var SCOPE_REGISTRY_KEY = `${STANDARD_AGENTS_NPM_SCOPE}:registry`;
413
+ var SCOPE_REGISTRY_PIN = `${SCOPE_REGISTRY_KEY}=${STANDARD_AGENTS_NPM_REGISTRY}`;
414
+ function splitLines(text) {
415
+ const lines = [];
416
+ for (const match of text.matchAll(/([^\r\n]*)(\r\n|\n|\r|$)/g)) {
417
+ if (match[0].length === 0) break;
418
+ lines.push({ body: match[1], eol: match[2] });
419
+ }
420
+ return lines;
421
+ }
422
+ function unquote(value) {
423
+ const quote = value[0];
424
+ if (value.length >= 2 && (quote === '"' || quote === "'") && value.endsWith(quote)) {
425
+ return value.slice(1, -1);
426
+ }
427
+ return value;
428
+ }
429
+ function isCommentOrBlank(body) {
430
+ const trimmed = body.trim();
431
+ return trimmed.length === 0 || trimmed.startsWith(";") || trimmed.startsWith("#");
432
+ }
433
+ function isSectionHeader(body) {
434
+ return /^\[[^\]]*\]$/.test(body.trim());
435
+ }
436
+ function assignmentKey(body) {
437
+ const separator = body.indexOf("=");
438
+ return unquote((separator < 0 ? body : body.slice(0, separator)).trim());
439
+ }
440
+ function assignmentValue(body) {
441
+ const separator = body.indexOf("=");
442
+ if (separator < 0) return "";
443
+ const raw = body.slice(separator + 1).trim();
444
+ const unquoted = unquote(raw);
445
+ return unquoted === raw ? raw.replace(/\s[;#].*$/, "").trim() : unquoted;
446
+ }
447
+ function isPublicRegistry(value) {
448
+ return value.replace(/\/+$/, "") === STANDARD_AGENTS_NPM_REGISTRY.replace(/\/+$/, "");
449
+ }
450
+ function topLevelLength(lines) {
451
+ const firstSection = lines.findIndex((line) => isSectionHeader(line.body));
452
+ return firstSection < 0 ? lines.length : firstSection;
453
+ }
454
+ function hasOtherNpmrcSettings(text) {
455
+ return splitLines(text).some((line) => !isCommentOrBlank(line.body) && (isSectionHeader(line.body) || assignmentKey(line.body) !== SCOPE_REGISTRY_KEY));
456
+ }
457
+ function pinScopeRegistryInNpmrc(text) {
458
+ const lines = splitLines(text);
459
+ const topLevel = topLevelLength(lines);
460
+ const effective = lines.map((line, index) => ({ line, index })).filter(({ line, index }) => index < topLevel && !isCommentOrBlank(line.body) && assignmentKey(line.body) === SCOPE_REGISTRY_KEY);
461
+ if (effective.length === 1 && isPublicRegistry(assignmentValue(effective[0].line.body))) {
462
+ return { text, changed: false };
463
+ }
464
+ const eol = lines.find((line) => line.eol.length > 0)?.eol ?? "\n";
465
+ if (effective.length > 0) {
466
+ const [first, ...duplicates] = effective;
467
+ const removed = new Set(duplicates.map(({ index }) => index));
468
+ const rewritten = lines.map((line, index) => index === first.index ? { body: SCOPE_REGISTRY_PIN, eol: line.eol } : line).filter((_, index) => !removed.has(index));
469
+ return { text: rewritten.map((line) => line.body + line.eol).join(""), changed: true };
470
+ }
471
+ const head = lines.slice(0, topLevel).map((line) => line.body + line.eol).join("");
472
+ const tail = lines.slice(topLevel).map((line) => line.body + line.eol).join("");
473
+ const separator = head.length === 0 || /[\r\n]$/.test(head) ? "" : eol;
474
+ return { text: `${head}${separator}${SCOPE_REGISTRY_PIN}${eol}${tail}`, changed: true };
475
+ }
476
+ function withoutTrailingSlash(value) {
477
+ return value.replace(/\/+$/, "");
478
+ }
479
+ function yamlKey(key) {
480
+ return /^[A-Za-z0-9_-]+$/.test(key) ? key : JSON.stringify(key);
481
+ }
482
+ function block(keys, value, indent, eol) {
483
+ return keys.map((key, depth) => {
484
+ const prefix = depth === 0 ? "" : `${indent}${" ".repeat(depth)}`;
485
+ const suffix = depth === keys.length - 1 ? ` ${JSON.stringify(value)}` : "";
486
+ return `${prefix}${yamlKey(key)}:${suffix}`;
487
+ }).join(eol);
488
+ }
489
+ function findPair(map, key) {
490
+ return map.items.find((pair) => isScalar(pair.key) && pair.key.value === key);
491
+ }
492
+ function spliceYamlPath(text, keyPath, value) {
493
+ const document = parseDocument(text);
494
+ const eol = text.includes("\r\n") ? "\r\n" : "\n";
495
+ if (document.contents === null) {
496
+ const separator = text.length === 0 || text.endsWith("\n") ? "" : eol;
497
+ return `${text}${separator}${block(keyPath, value, "", eol)}${eol}`;
498
+ }
499
+ if (!isMap(document.contents)) return null;
500
+ let map = document.contents;
501
+ for (let depth = 0; depth < keyPath.length; depth += 1) {
502
+ const pair = findPair(map, keyPath[depth]);
503
+ if (!pair) {
504
+ if (map.flow) return null;
505
+ if (depth === 0 && !/^(---|\.\.\.)/m.test(text)) {
506
+ const separator = text.endsWith("\n") ? "" : eol;
507
+ return `${text}${separator}${block(keyPath, value, "", eol)}${eol}`;
508
+ }
509
+ const firstKey = map.items[0]?.key;
510
+ const start = isScalar(firstKey) ? firstKey.range?.[0] : void 0;
511
+ if (start === void 0) return null;
512
+ const indent = text.slice(text.lastIndexOf("\n", start - 1) + 1, start);
513
+ if (indent.trim().length > 0) return null;
514
+ return `${text.slice(0, start)}${block(keyPath.slice(depth), value, indent, eol)}${eol}${indent}${text.slice(start)}`;
515
+ }
516
+ if (depth === keyPath.length - 1) {
517
+ const range = isScalar(pair.value) ? pair.value.range : void 0;
518
+ if (!range) return null;
519
+ return `${text.slice(0, range[0])}${JSON.stringify(value)}${text.slice(range[1])}`;
520
+ }
521
+ if (!isMap(pair.value)) return null;
522
+ map = pair.value;
523
+ }
524
+ return null;
525
+ }
526
+ function isRecord(value) {
527
+ return typeof value === "object" && value !== null && !Array.isArray(value);
528
+ }
529
+ function sameValue(left, right) {
530
+ if (Array.isArray(left) && Array.isArray(right)) {
531
+ return left.length === right.length && left.every((item, index) => sameValue(item, right[index]));
532
+ }
533
+ if (isRecord(left) && isRecord(right)) {
534
+ const keys = Object.keys(left);
535
+ return keys.length === Object.keys(right).length && keys.every((key) => Object.hasOwn(right, key) && sameValue(left[key], right[key]));
536
+ }
537
+ return left === right;
538
+ }
539
+ function withTarget(before, keyPath, value) {
540
+ if (before !== null && before !== void 0 && !isRecord(before)) return null;
541
+ const root = { ...before ?? {} };
542
+ let cursor = root;
543
+ for (const key of keyPath.slice(0, -1)) {
544
+ const child = cursor[key];
545
+ if (child !== null && child !== void 0 && !isRecord(child)) return null;
546
+ const copy = { ...child ?? {} };
547
+ cursor[key] = copy;
548
+ cursor = copy;
549
+ }
550
+ cursor[keyPath[keyPath.length - 1]] = value;
551
+ return root;
552
+ }
553
+ function sharesNodes(text) {
554
+ let shared = false;
555
+ visit(parseDocument(text), {
556
+ Alias: () => {
557
+ shared = true;
558
+ },
559
+ Node: (_key, node) => {
560
+ if (isNode(node) && node.anchor) shared = true;
561
+ },
562
+ Pair: (_key, pair) => {
563
+ if (isScalar(pair.key) && pair.key.value === "<<") shared = true;
564
+ }
565
+ });
566
+ return shared;
567
+ }
568
+ function setYamlString(text, keyPath, value, isAcceptable) {
569
+ const document = parseDocument(text);
570
+ if (document.errors.length > 0) return null;
571
+ const current = keyPath.reduce((value2, key) => isRecord(value2) ? value2[key] : void 0, document.toJS());
572
+ if (typeof current === "string" && isAcceptable(current)) return { text, changed: false };
573
+ if (sharesNodes(text)) return null;
574
+ const expected = withTarget(document.toJS(), keyPath, value);
575
+ if (expected === null) return null;
576
+ let next = spliceYamlPath(text, keyPath, value);
577
+ if (next === null) {
578
+ try {
579
+ document.setIn(keyPath, value);
580
+ next = String(document);
581
+ } catch {
582
+ return null;
583
+ }
584
+ }
585
+ const verified = parseDocument(next);
586
+ if (verified.errors.length > 0 || !sameValue(verified.toJS(), expected)) return null;
587
+ return { text: next, changed: true };
588
+ }
589
+ var PUBLIC_REGISTRY = withoutTrailingSlash(STANDARD_AGENTS_NPM_REGISTRY);
590
+ var PNPM_WORKSPACE_REGISTRY_PATH = ["registries", STANDARD_AGENTS_NPM_SCOPE];
591
+ function pinScopeRegistryInPnpmWorkspace(text) {
592
+ return setYamlString(
593
+ text,
594
+ PNPM_WORKSPACE_REGISTRY_PATH,
595
+ STANDARD_AGENTS_NPM_REGISTRY,
596
+ (current) => withoutTrailingSlash(current) === PUBLIC_REGISTRY
597
+ );
598
+ }
599
+ var YARNRC_REGISTRY_PATH = ["npmScopes", STANDARD_AGENTS_NPM_SCOPE.slice(1), "npmRegistryServer"];
600
+ function pinScopeRegistryInYarnrc(text) {
601
+ return setYamlString(
602
+ text,
603
+ YARNRC_REGISTRY_PATH,
604
+ PUBLIC_REGISTRY,
605
+ (current) => [PUBLIC_REGISTRY, "https://registry.yarnpkg.com"].includes(withoutTrailingSlash(current))
606
+ );
607
+ }
608
+ var AUTH_KEYS = ["npmAuthToken", "npmAuthIdent"];
609
+ var AUTH_ENVIRONMENT = ["YARN_NPM_AUTH_TOKEN", "YARN_NPM_AUTH_IDENT"];
610
+ var PUBLIC_REGISTRY_HOSTS = ["registry.npmjs.org", "registry.yarnpkg.com"];
611
+ var SCOPE_NAME = STANDARD_AGENTS_NPM_SCOPE.slice(1);
612
+ function isRecord2(value) {
613
+ return typeof value === "object" && value !== null && !Array.isArray(value);
614
+ }
615
+ function isSet(value) {
616
+ return value !== void 0 && value !== null && value !== "";
617
+ }
618
+ function isPrivateRegistry(value) {
619
+ if (!isSet(value)) return false;
620
+ try {
621
+ return !PUBLIC_REGISTRY_HOSTS.includes(new URL(String(value)).host);
622
+ } catch {
623
+ return true;
624
+ }
625
+ }
626
+ function yarnrcFiles(projectPath) {
627
+ const files = [];
628
+ for (let directory = path13.resolve(projectPath); ; directory = path13.dirname(directory)) {
629
+ files.push(path13.join(directory, ".yarnrc.yml"));
630
+ if (path13.dirname(directory) === directory) break;
631
+ }
632
+ const homeFile = path13.join(os4.homedir(), ".yarnrc.yml");
633
+ return files.includes(homeFile) ? files : [...files, homeFile];
634
+ }
635
+ function yarnCredentialsBoundToScope(projectPath, env = process.env) {
636
+ const scopeSources = [];
637
+ const topLevelSources = AUTH_ENVIRONMENT.filter((name) => isSet(env[name]));
638
+ let privateDefaultRegistry = isPrivateRegistry(env.YARN_NPM_REGISTRY_SERVER);
639
+ for (const file of yarnrcFiles(projectPath)) {
640
+ if (!fs12.existsSync(file)) continue;
641
+ let config;
642
+ try {
643
+ config = parse$1(fs12.readFileSync(file, "utf-8"), { merge: true });
644
+ } catch {
645
+ scopeSources.push(`${file} (unreadable)`);
646
+ continue;
647
+ }
648
+ if (!isRecord2(config)) continue;
649
+ const scopes = config.npmScopes;
650
+ const scope = isRecord2(scopes) ? scopes[SCOPE_NAME] : void 0;
651
+ for (const key of AUTH_KEYS) {
652
+ if (isRecord2(scope) && isSet(scope[key])) scopeSources.push(`${file} (npmScopes.${SCOPE_NAME}.${key})`);
653
+ if (isSet(config[key])) topLevelSources.push(`${file} (${key})`);
654
+ }
655
+ if (isPrivateRegistry(config.npmRegistryServer)) privateDefaultRegistry = true;
656
+ }
657
+ return privateDefaultRegistry ? [...scopeSources, ...topLevelSources] : scopeSources;
658
+ }
659
+
660
+ // src/utils/scope-registry/index.ts
661
+ function refuse(plan, step, required) {
662
+ plan.manual.push(step);
663
+ if (required) plan.blocked = true;
664
+ }
665
+ function planNpmrc(npmrcPath, plan) {
666
+ const stat = fs12.lstatSync(npmrcPath, { throwIfNoEntry: false });
667
+ if (!stat) {
668
+ plan.writes.push({ filePath: npmrcPath, text: `${SCOPE_REGISTRY_PIN}
669
+ ` });
670
+ return;
671
+ }
672
+ if (stat.isSymbolicLink()) {
673
+ const target = fs12.existsSync(npmrcPath) ? fs12.readFileSync(npmrcPath, "utf-8") : "";
674
+ if (!pinScopeRegistryInNpmrc(target).changed) return;
675
+ if (hasOtherNpmrcSettings(target)) {
676
+ refuse(plan, `${npmrcPath} is a symbolic link, so it is unchanged. Add this line to a project-owned .npmrc: ${SCOPE_REGISTRY_PIN}`, true);
677
+ return;
678
+ }
679
+ plan.writes.push({ filePath: npmrcPath, text: `${SCOPE_REGISTRY_PIN}
680
+ `, replacesLink: true });
681
+ return;
682
+ }
683
+ const pinned = pinScopeRegistryInNpmrc(fs12.readFileSync(npmrcPath, "utf-8"));
684
+ if (pinned.changed) plan.writes.push({ filePath: npmrcPath, text: pinned.text });
685
+ }
686
+ function planYaml(filePath, pin, keyPath, required, plan) {
687
+ const step = `Set ${keyPath.join(".")} to https://registry.npmjs.org/ in ${filePath}.`;
688
+ const stat = fs12.lstatSync(filePath, { throwIfNoEntry: false });
689
+ if (stat?.isSymbolicLink()) {
690
+ refuse(plan, `${filePath} is a symbolic link, so it is unchanged. ${step}`, required);
691
+ return;
692
+ }
693
+ const pinned = pin(stat ? fs12.readFileSync(filePath, "utf-8") : "");
694
+ if (pinned === null) {
695
+ refuse(plan, `The CLI cannot edit ${filePath} safely, so it is unchanged. ${step}`, required);
696
+ return;
697
+ }
698
+ if (pinned.changed) plan.writes.push({ filePath, text: pinned.text });
699
+ }
700
+ function planYarnrc(projectPath, required, plan) {
701
+ const filePath = path13.join(projectPath, ".yarnrc.yml");
702
+ const stat = fs12.lstatSync(filePath, { throwIfNoEntry: false });
703
+ const current = stat && !stat.isSymbolicLink() ? fs12.readFileSync(filePath, "utf-8") : "";
704
+ const credentials = pinScopeRegistryInYarnrc(current)?.changed ? yarnCredentialsBoundToScope(projectPath) : [];
705
+ if (credentials.length > 0) {
706
+ refuse(
707
+ plan,
708
+ `Yarn would send the credentials in ${credentials.join(", ")} to public npm for @standardagents packages, so ${filePath} is unchanged. Remove those credentials from the scope, then set ${YARNRC_REGISTRY_PATH.join(".")} to https://registry.npmjs.org in ${filePath}.`,
709
+ required
710
+ );
711
+ return;
712
+ }
713
+ planYaml(filePath, pinScopeRegistryInYarnrc, YARNRC_REGISTRY_PATH, required, plan);
714
+ }
715
+ function needsYarnrc(projectPath, packageManager, options) {
716
+ if (fs12.lstatSync(path13.join(projectPath, ".yarnrc.yml"), { throwIfNoEntry: false })) return true;
717
+ if (packageManager !== "yarn") return false;
718
+ const declared = declaredPackageManager(projectPath);
719
+ if (declared?.name === "yarn") return declared.major >= 2;
720
+ const invoked = /(?:^|\s)yarn\/(\d+)/.exec(options.userAgent ?? process.env.npm_config_user_agent ?? "");
721
+ return invoked ? Number(invoked[1]) >= 2 : true;
722
+ }
723
+ function migrateLockfiles(projectPath, changed) {
724
+ for (const [name, migrate] of Object.entries(LOCKFILE_MIGRATIONS)) {
725
+ const lockfilePath = path13.join(projectPath, name);
726
+ const stat = fs12.lstatSync(lockfilePath, { throwIfNoEntry: false });
727
+ if (!stat?.isFile()) continue;
728
+ const text = fs12.readFileSync(lockfilePath, "utf-8");
729
+ const migrated = migrate(text);
730
+ if (migrated === text) continue;
731
+ fs12.writeFileSync(lockfilePath, migrated, "utf-8");
732
+ changed.push(lockfilePath);
733
+ }
734
+ }
735
+ function pinStandardAgentsScopeRegistry(projectPath, options = {}) {
736
+ const packageManager = options.packageManager ?? inferProjectPackageManager(projectPath);
737
+ const configRoot = registryConfigRoot(projectPath, packageManager, options.isolateFromParent ?? false);
738
+ const plan = { writes: [], manual: [], blocked: false };
739
+ planNpmrc(path13.join(configRoot, ".npmrc"), plan);
740
+ const workspaceFile = path13.join(configRoot, "pnpm-workspace.yaml");
741
+ if (fs12.lstatSync(workspaceFile, { throwIfNoEntry: false })) {
742
+ planYaml(workspaceFile, pinScopeRegistryInPnpmWorkspace, PNPM_WORKSPACE_REGISTRY_PATH, packageManager === "pnpm", plan);
743
+ }
744
+ if (needsYarnrc(projectPath, packageManager, options)) {
745
+ planYarnrc(projectPath, packageManager === "yarn", plan);
746
+ }
747
+ if (plan.blocked) return { changed: [], manual: plan.manual, blocked: true };
748
+ const changed = [];
749
+ for (const write of plan.writes) {
750
+ if (write.replacesLink) fs12.unlinkSync(write.filePath);
751
+ fs12.writeFileSync(write.filePath, write.text, "utf-8");
752
+ changed.push(write.filePath);
753
+ }
754
+ migrateLockfiles(projectPath, changed);
755
+ return { changed, manual: plan.manual, blocked: false };
756
+ }
757
+ function pinProjectScopeRegistry(projectPath, options, log) {
758
+ const result = pinStandardAgentsScopeRegistry(projectPath, options);
759
+ if (result.changed.length > 0) {
760
+ const files = result.changed.map((file) => path13.relative(projectPath, file)).join(", ");
761
+ log.info(`Your project now installs @standardagents packages from npm (updated ${files}).`);
762
+ }
763
+ for (const step of result.manual) log.warning(step);
764
+ if (result.blocked) {
765
+ log.warning("No project file changed. Complete the step above before you install dependencies.");
766
+ }
767
+ return result;
768
+ }
769
+ var SCOPE_REGISTRY_PIN_BLOCKED_CAUSE = "your project cannot name public npm for @standardagents packages yet.";
770
+ var STATE_RELATIVE_PATH = path13.join(".agents", "bootstrap-session.json");
265
771
  function getBootstrapStatePath(projectPath) {
266
- return path9.join(projectPath, STATE_RELATIVE_PATH);
772
+ return path13.join(projectPath, STATE_RELATIVE_PATH);
267
773
  }
268
774
  function loadBootstrapState(projectPath) {
269
775
  const statePath = getBootstrapStatePath(projectPath);
270
- if (!fs8.existsSync(statePath)) return null;
776
+ if (!fs12.existsSync(statePath)) return null;
271
777
  try {
272
- const parsed = JSON.parse(fs8.readFileSync(statePath, "utf-8"));
778
+ const parsed = JSON.parse(fs12.readFileSync(statePath, "utf-8"));
273
779
  if (parsed.version !== 1) return null;
274
780
  if (!parsed.endpoint || !parsed.user?.id || !parsed.account?.id) return null;
275
781
  if (parsed.session_cookie !== void 0 && typeof parsed.session_cookie !== "string") return null;
@@ -280,13 +786,13 @@ function loadBootstrapState(projectPath) {
280
786
  }
281
787
  function persistBootstrapState(projectPath, state) {
282
788
  const statePath = getBootstrapStatePath(projectPath);
283
- fs8.mkdirSync(path9.dirname(statePath), { recursive: true });
789
+ fs12.mkdirSync(path13.dirname(statePath), { recursive: true });
284
790
  writePrivateFileSync(statePath, JSON.stringify(state, null, 2) + "\n");
285
791
  }
286
792
  function clearBootstrapState(projectPath) {
287
793
  const statePath = getBootstrapStatePath(projectPath);
288
- if (fs8.existsSync(statePath)) {
289
- fs8.unlinkSync(statePath);
794
+ if (fs12.existsSync(statePath)) {
795
+ fs12.unlinkSync(statePath);
290
796
  }
291
797
  }
292
798
  function getWebSocketCtor() {
@@ -467,13 +973,13 @@ function getScaffoldStandardAgentsVersion() {
467
973
  if (process.env.STANDARDAGENTS_WORKSPACE === "1") {
468
974
  return workspacePackageLink("@standardagents/builder");
469
975
  }
470
- return "0.45.3";
976
+ return "0.45.4";
471
977
  }
472
978
  function findViteConfig(cwd) {
473
979
  const candidates = ["vite.config.ts", "vite.config.js", "vite.config.mts", "vite.config.mjs"];
474
980
  for (const candidate of candidates) {
475
- const configPath = path9.join(cwd, candidate);
476
- if (fs8.existsSync(configPath)) {
981
+ const configPath = path13.join(cwd, candidate);
982
+ if (fs12.existsSync(configPath)) {
477
983
  return configPath;
478
984
  }
479
985
  }
@@ -491,13 +997,13 @@ function setPackageDependency(packageJsonText, section, packageName, version) {
491
997
  return applyEdits(packageJsonText, edits);
492
998
  }
493
999
  function updatePackageDependencies(cwd, versions = {}) {
494
- const packageJsonPath = path9.join(cwd, "package.json");
495
- if (!fs8.existsSync(packageJsonPath)) {
1000
+ const packageJsonPath = path13.join(cwd, "package.json");
1001
+ if (!fs12.existsSync(packageJsonPath)) {
496
1002
  logger.warning("No package.json found. Install @standardagents/builder manually.");
497
1003
  return false;
498
1004
  }
499
1005
  try {
500
- const text = fs8.readFileSync(packageJsonPath, "utf-8");
1006
+ const text = fs12.readFileSync(packageJsonPath, "utf-8");
501
1007
  const pkg = JSON.parse(text);
502
1008
  const desiredBuilderVersion = versions.standardAgents ?? getScaffoldStandardAgentsVersion();
503
1009
  const builderSection = dependencySectionFor(pkg, "@standardagents/builder", "dependencies");
@@ -511,7 +1017,7 @@ function updatePackageDependencies(cwd, versions = {}) {
511
1017
  logger.info("package.json already has current Standard Agents dependencies");
512
1018
  return true;
513
1019
  }
514
- fs8.writeFileSync(packageJsonPath, `${result.trimEnd()}
1020
+ fs12.writeFileSync(packageJsonPath, `${result.trimEnd()}
515
1021
  `, "utf-8");
516
1022
  logger.success("Updated package.json with current Standard Agents dependencies");
517
1023
  return true;
@@ -523,7 +1029,7 @@ function updatePackageDependencies(cwd, versions = {}) {
523
1029
  async function modifyViteConfig(configPath, force) {
524
1030
  try {
525
1031
  const mod = await loadFile(configPath);
526
- const code = fs8.readFileSync(configPath, "utf-8");
1032
+ const code = fs12.readFileSync(configPath, "utf-8");
527
1033
  const hasAgentBuilder = code.includes("@standardagents/builder") || code.includes("builder()") || code.includes("agentbuilder()");
528
1034
  if (hasAgentBuilder && !force) {
529
1035
  logger.info("Vite config already includes the Standard Agents Builder plugin");
@@ -553,34 +1059,34 @@ async function modifyViteConfig(configPath, force) {
553
1059
  }
554
1060
  function createDirectoriesAndDocs(cwd) {
555
1061
  function writeAgentsDocWithClaudeSymlink(dirPath, doc, label) {
556
- const agentsDocPath = path9.join(dirPath, "AGENTS.md");
557
- const claudeDocPath = path9.join(dirPath, "CLAUDE.md");
558
- if (!fs8.existsSync(agentsDocPath)) {
559
- fs8.writeFileSync(agentsDocPath, doc, "utf-8");
1062
+ const agentsDocPath = path13.join(dirPath, "AGENTS.md");
1063
+ const claudeDocPath = path13.join(dirPath, "CLAUDE.md");
1064
+ if (!fs12.existsSync(agentsDocPath)) {
1065
+ fs12.writeFileSync(agentsDocPath, doc, "utf-8");
560
1066
  logger.success(`Created ${label}/AGENTS.md`);
561
1067
  }
562
- if (!fs8.existsSync(claudeDocPath)) {
563
- fs8.symlinkSync("AGENTS.md", claudeDocPath);
1068
+ if (!fs12.existsSync(claudeDocPath)) {
1069
+ fs12.symlinkSync("AGENTS.md", claudeDocPath);
564
1070
  logger.success(`Created ${label}/CLAUDE.md symlink`);
565
1071
  }
566
1072
  }
567
1073
  for (const doc of AGENT_DOCS) {
568
- const dirPath = path9.join(cwd, doc.directory);
569
- if (!fs8.existsSync(dirPath)) {
570
- fs8.mkdirSync(dirPath, { recursive: true });
1074
+ const dirPath = path13.join(cwd, doc.directory);
1075
+ if (!fs12.existsSync(dirPath)) {
1076
+ fs12.mkdirSync(dirPath, { recursive: true });
571
1077
  logger.success(`Created ${doc.directory}`);
572
1078
  }
573
1079
  writeAgentsDocWithClaudeSymlink(dirPath, doc.content, doc.directory);
574
1080
  }
575
1081
  }
576
1082
  function updateTsConfig(cwd) {
577
- const tsconfigPath = path9.join(cwd, "tsconfig.json");
578
- if (!fs8.existsSync(tsconfigPath)) {
1083
+ const tsconfigPath = path13.join(cwd, "tsconfig.json");
1084
+ if (!fs12.existsSync(tsconfigPath)) {
579
1085
  logger.info("No tsconfig.json found, skipping TypeScript configuration");
580
1086
  return;
581
1087
  }
582
1088
  try {
583
- const text = fs8.readFileSync(tsconfigPath, "utf-8");
1089
+ const text = fs12.readFileSync(tsconfigPath, "utf-8");
584
1090
  const config = parse(text);
585
1091
  let result = text;
586
1092
  const types = config.compilerOptions?.types || [];
@@ -601,7 +1107,7 @@ function updateTsConfig(cwd) {
601
1107
  result = applyEdits(result, edits);
602
1108
  }
603
1109
  if (newTypes.length > 0 || newIncludes.length > 0) {
604
- fs8.writeFileSync(tsconfigPath, result, "utf-8");
1110
+ fs12.writeFileSync(tsconfigPath, result, "utf-8");
605
1111
  logger.success("Updated tsconfig.json with Standard Agents types");
606
1112
  } else {
607
1113
  logger.info("tsconfig.json already configured");
@@ -627,21 +1133,21 @@ function cleanupViteDefaults(cwd) {
627
1133
  ];
628
1134
  const dirsToRemove = ["src", "public", "worker"];
629
1135
  for (const file of filesToRemove) {
630
- const filePath = path9.join(cwd, file);
631
- if (fs8.existsSync(filePath)) {
1136
+ const filePath = path13.join(cwd, file);
1137
+ if (fs12.existsSync(filePath)) {
632
1138
  try {
633
- fs8.unlinkSync(filePath);
1139
+ fs12.unlinkSync(filePath);
634
1140
  } catch {
635
1141
  }
636
1142
  }
637
1143
  }
638
1144
  for (const dir of dirsToRemove) {
639
- const dirPath = path9.join(cwd, dir);
640
- if (fs8.existsSync(dirPath)) {
1145
+ const dirPath = path13.join(cwd, dir);
1146
+ if (fs12.existsSync(dirPath)) {
641
1147
  try {
642
- const files = fs8.readdirSync(dirPath);
1148
+ const files = fs12.readdirSync(dirPath);
643
1149
  if (files.length === 0) {
644
- fs8.rmdirSync(dirPath);
1150
+ fs12.rmdirSync(dirPath);
645
1151
  }
646
1152
  } catch {
647
1153
  }
@@ -660,6 +1166,9 @@ async function scaffold(options = {}) {
660
1166
  logger.warning("No vite.config found. Please create one with the Standard Agents Builder plugin.");
661
1167
  }
662
1168
  updatePackageDependencies(cwd, { standardAgents: options.standardAgents });
1169
+ if (!options.scopeRegistryPinned) {
1170
+ pinProjectScopeRegistry(cwd, { packageManager: inferProjectPackageManager(cwd) }, logger);
1171
+ }
663
1172
  createDirectoriesAndDocs(cwd);
664
1173
  updateTsConfig(cwd);
665
1174
  if (force) {
@@ -684,6 +1193,16 @@ async function scaffold(options = {}) {
684
1193
  logger.log(" \u2514\u2500\u2500 api/ # Thread API endpoints");
685
1194
  logger.log("");
686
1195
  }
1196
+ function writeBuildGuardScript(projectPath) {
1197
+ const manifestPath = path13.join(projectPath, "package.json");
1198
+ if (!fs12.existsSync(manifestPath)) return false;
1199
+ const manifest = JSON.parse(fs12.readFileSync(manifestPath, "utf-8"));
1200
+ if (manifest.scripts?.build === BUILD_GUARD_SCRIPT) return false;
1201
+ manifest.scripts = { ...manifest.scripts, build: BUILD_GUARD_SCRIPT };
1202
+ fs12.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}
1203
+ `, "utf-8");
1204
+ return true;
1205
+ }
687
1206
 
688
1207
  // src/utils/interrupt.ts
689
1208
  var SIGNAL_EXIT_CODES = { SIGINT: 130, SIGTERM: 143 };
@@ -752,7 +1271,7 @@ function signalAll(pids, signal) {
752
1271
  function readProcfsTable() {
753
1272
  let entries;
754
1273
  try {
755
- entries = fs8.readdirSync("/proc");
1274
+ entries = fs12.readdirSync("/proc");
756
1275
  } catch {
757
1276
  return null;
758
1277
  }
@@ -760,7 +1279,7 @@ function readProcfsTable() {
760
1279
  for (const entry of entries) {
761
1280
  if (!/^\d+$/.test(entry)) continue;
762
1281
  try {
763
- const stat = fs8.readFileSync(`/proc/${entry}/stat`, "utf8");
1282
+ const stat = fs12.readFileSync(`/proc/${entry}/stat`, "utf8");
764
1283
  const parent = Number.parseInt(stat.slice(stat.lastIndexOf(")") + 2).split(" ")[1], 10);
765
1284
  if (Number.isInteger(parent)) parents.set(Number(entry), parent);
766
1285
  } catch {
@@ -981,10 +1500,10 @@ function directoryExistsFailure(name) {
981
1500
  };
982
1501
  }
983
1502
  function resolveFreeDirectoryName(cwd, name) {
984
- if (!fs8.existsSync(path9.join(cwd, name))) return name;
1503
+ if (!fs12.existsSync(path13.join(cwd, name))) return name;
985
1504
  for (let suffix = 2; ; suffix += 1) {
986
1505
  const candidate = `${name}-${suffix}`;
987
- if (!fs8.existsSync(path9.join(cwd, candidate))) return candidate;
1506
+ if (!fs12.existsSync(path13.join(cwd, candidate))) return candidate;
988
1507
  }
989
1508
  }
990
1509
  function commandFailureCause(label, error) {
@@ -1449,7 +1968,7 @@ function renderInitCompleteFrame(input) {
1449
1968
  GENERATED_ADMIN_PASSWORD_NOTES.map((note) => /* @__PURE__ */ jsx(Text, { color: "yellow", children: note }, note)),
1450
1969
  /* @__PURE__ */ jsx(Text, { color: "whiteBright", children: ` ${input.generatedAdminPassword}` })
1451
1970
  ] }) : null,
1452
- /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { color: "gray", children: "Docs: https://standardagents.ai/docs" }) })
1971
+ /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { color: "gray", children: "Docs: https://docs.standardagents.ai" }) })
1453
1972
  ] })
1454
1973
  );
1455
1974
  }
@@ -1474,7 +1993,7 @@ var GENERATED_STANDARD_AGENTS_PACKAGES = [
1474
1993
  "@standardagents/spec",
1475
1994
  ...FIRST_PARTY_PROVIDER_PACKAGES
1476
1995
  ];
1477
- var PACKAGE_MANAGERS = ["npm", "pnpm", "yarn", "bun"];
1996
+ var PACKAGE_MANAGERS2 = ["npm", "pnpm", "yarn", "bun"];
1478
1997
  var MISSING_PLATFORM_PROJECT_NAME_MESSAGE = "The platform did not return a project name. Please run the init command again to start a new project setup.";
1479
1998
  var LEGACY_BOOTSTRAP_RESPONSE_MESSAGE = "The platform returned an older onboarding response. Please run the init command again to start a new project setup.";
1480
1999
  function parseBootstrapCodeInput(raw) {
@@ -1599,16 +2118,16 @@ function normalizeProjectName(raw) {
1599
2118
  return toKebabCase(raw.trim());
1600
2119
  }
1601
2120
  function isNonEmptyDirectory(targetPath) {
1602
- if (!fs8.existsSync(targetPath)) return false;
1603
- const stat = fs8.statSync(targetPath);
2121
+ if (!fs12.existsSync(targetPath)) return false;
2122
+ const stat = fs12.statSync(targetPath);
1604
2123
  if (!stat.isDirectory()) return false;
1605
- return fs8.readdirSync(targetPath).length > 0;
2124
+ return fs12.readdirSync(targetPath).length > 0;
1606
2125
  }
1607
2126
  function hasBuilderDependency(targetPath) {
1608
- const packageJsonPath = path9.join(targetPath, "package.json");
1609
- if (!fs8.existsSync(packageJsonPath)) return false;
2127
+ const packageJsonPath = path13.join(targetPath, "package.json");
2128
+ if (!fs12.existsSync(packageJsonPath)) return false;
1610
2129
  try {
1611
- const pkg = JSON.parse(fs8.readFileSync(packageJsonPath, "utf-8"));
2130
+ const pkg = JSON.parse(fs12.readFileSync(packageJsonPath, "utf-8"));
1612
2131
  if (pkg === null || typeof pkg !== "object") return false;
1613
2132
  const dependencies = "dependencies" in pkg ? pkg.dependencies : void 0;
1614
2133
  const devDependencies = "devDependencies" in pkg ? pkg.devDependencies : void 0;
@@ -1620,12 +2139,12 @@ function hasBuilderDependency(targetPath) {
1620
2139
  }
1621
2140
  }
1622
2141
  function isStandardAgentsProjectDir(targetPath) {
1623
- const agentsDir = path9.join(targetPath, "agents");
1624
- if (!fs8.existsSync(agentsDir) || !fs8.statSync(agentsDir).isDirectory()) {
2142
+ const agentsDir = path13.join(targetPath, "agents");
2143
+ if (!fs12.existsSync(agentsDir) || !fs12.statSync(agentsDir).isDirectory()) {
1625
2144
  return false;
1626
2145
  }
1627
2146
  if (hasBuilderDependency(targetPath)) return true;
1628
- return fs8.existsSync(path9.join(targetPath, "vite.config.ts")) && fs8.existsSync(path9.join(targetPath, "tsconfig.json"));
2147
+ return fs12.existsSync(path13.join(targetPath, "vite.config.ts")) && fs12.existsSync(path13.join(targetPath, "tsconfig.json"));
1629
2148
  }
1630
2149
  function resolveProjectTarget(cwd, candidate) {
1631
2150
  const requested = candidate?.trim() ?? "";
@@ -1633,7 +2152,7 @@ function resolveProjectTarget(cwd, candidate) {
1633
2152
  if (!isStandardAgentsProjectDir(cwd)) {
1634
2153
  return { ok: false, message: "Project name is required" };
1635
2154
  }
1636
- const dirName = path9.basename(cwd) || "standard-agents";
2155
+ const dirName = path13.basename(cwd) || "standard-agents";
1637
2156
  const existingBootstrapState2 = loadBootstrapState(cwd);
1638
2157
  return {
1639
2158
  ok: true,
@@ -1650,9 +2169,9 @@ function resolveProjectTarget(cwd, candidate) {
1650
2169
  if (!projectName) {
1651
2170
  return { ok: false, message: "Project name must include at least one letter or number" };
1652
2171
  }
1653
- const projectPath = path9.join(cwd, projectName);
1654
- const exists = fs8.existsSync(projectPath);
1655
- if (exists && !fs8.statSync(projectPath).isDirectory()) {
2172
+ const projectPath = path13.join(cwd, projectName);
2173
+ const exists = fs12.existsSync(projectPath);
2174
+ if (exists && !fs12.statSync(projectPath).isDirectory()) {
1656
2175
  return { ok: false, message: `Path "${projectName}" already exists and is not a directory` };
1657
2176
  }
1658
2177
  const existingBootstrapState = loadBootstrapState(projectPath);
@@ -1673,7 +2192,7 @@ function resolveProjectTarget(cwd, candidate) {
1673
2192
  };
1674
2193
  }
1675
2194
  function detectLockfilePackageManager(projectPath) {
1676
- const has = (file) => fs8.existsSync(path9.join(projectPath, file));
2195
+ const has = (file) => fs12.existsSync(path13.join(projectPath, file));
1677
2196
  if (has("pnpm-lock.yaml")) return "pnpm";
1678
2197
  if (has("yarn.lock")) return "yarn";
1679
2198
  if (has("bun.lockb") || has("bun.lock")) return "bun";
@@ -1692,7 +2211,7 @@ function detectPackageManager() {
1692
2211
  function resolvePackageManager(requested, detected) {
1693
2212
  if (!requested) return detected;
1694
2213
  const normalized = requested.trim();
1695
- if (PACKAGE_MANAGERS.includes(normalized)) {
2214
+ if (PACKAGE_MANAGERS2.includes(normalized)) {
1696
2215
  return normalized;
1697
2216
  }
1698
2217
  throw new Error("package-manager must be npm, pnpm, yarn, or bun");
@@ -1753,7 +2272,7 @@ function renderInitStepHeader(stage, title, subtitle, options) {
1753
2272
  logger.log("");
1754
2273
  }
1755
2274
  function getCliVersion() {
1756
- return "0.45.3";
2275
+ return "0.45.4";
1757
2276
  }
1758
2277
  function getSipVersion() {
1759
2278
  return "1.0.1";
@@ -1782,8 +2301,8 @@ function resolveStandardAgentsPackageSpecifier(packageName, packageSpecifier) {
1782
2301
  return packageSpecifier;
1783
2302
  }
1784
2303
  function rewriteStandardAgentsDependenciesForWorkspace(projectPath, workspaceRoot) {
1785
- const packageJsonPath = path9.join(projectPath, "package.json");
1786
- const packageJson = JSON.parse(fs8.readFileSync(packageJsonPath, "utf-8"));
2304
+ const packageJsonPath = path13.join(projectPath, "package.json");
2305
+ const packageJson = JSON.parse(fs12.readFileSync(packageJsonPath, "utf-8"));
1787
2306
  const dependencies = packageJson.dependencies ?? {};
1788
2307
  const linkedPackages = [];
1789
2308
  for (const packageName of GENERATED_STANDARD_AGENTS_PACKAGES) {
@@ -1795,7 +2314,7 @@ function rewriteStandardAgentsDependenciesForWorkspace(projectPath, workspaceRoo
1795
2314
  }
1796
2315
  if (linkedPackages.length > 0) {
1797
2316
  packageJson.dependencies = dependencies;
1798
- fs8.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
2317
+ fs12.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
1799
2318
  `, "utf-8");
1800
2319
  }
1801
2320
  return linkedPackages;
@@ -1816,7 +2335,7 @@ function preparePlatformProjectDependencies(projectPath, packageManager, options
1816
2335
  return linkedPackages;
1817
2336
  }
1818
2337
  function getPnpmWorkspaceCompatibilityArgs(packageManager, projectPath) {
1819
- if (packageManager !== "pnpm" || !fs8.existsSync(path9.join(projectPath, "pnpm-workspace.yaml"))) return [];
2338
+ if (packageManager !== "pnpm" || !fs12.existsSync(path13.join(projectPath, "pnpm-workspace.yaml"))) return [];
1820
2339
  try {
1821
2340
  childProcess.execFileSync("pnpm", ["config", "get", "registry"], {
1822
2341
  cwd: projectPath,
@@ -1834,8 +2353,8 @@ function getPnpmWorkspaceCompatibilityArgs(packageManager, projectPath) {
1834
2353
  }
1835
2354
  }
1836
2355
  function projectInstallArgs(packageManager, projectPath, command = "install", dependencies = [], options = {}) {
1837
- const hasProjectWorkspace = projectPath !== void 0 && fs8.existsSync(path9.join(projectPath, "pnpm-workspace.yaml"));
1838
- const inheritsWorkspace = !options.isolateFromParent && projectPath !== void 0 && findPnpmWorkspaceRoot(path9.dirname(projectPath)) !== null;
2356
+ const hasProjectWorkspace = projectPath !== void 0 && fs12.existsSync(path13.join(projectPath, "pnpm-workspace.yaml"));
2357
+ const inheritsWorkspace = !options.isolateFromParent && projectPath !== void 0 && findPnpmWorkspaceRoot(path13.dirname(projectPath)) !== null;
1839
2358
  const prefix = [];
1840
2359
  if (packageManager === "pnpm") {
1841
2360
  if (options.ignoreProjectWorkspace) prefix.push("--ignore-workspace");
@@ -1848,19 +2367,19 @@ function shellQuote(value) {
1848
2367
  return `"${value.replace(/(["\\$`])/g, "\\$1")}"`;
1849
2368
  }
1850
2369
  function findWorkspaceCommandRoot(projectPath) {
1851
- let current = path9.dirname(projectPath);
2370
+ let current = path13.dirname(projectPath);
1852
2371
  while (true) {
1853
- const packageJsonPath = path9.join(current, "package.json");
1854
- if (fs8.existsSync(packageJsonPath)) {
2372
+ const packageJsonPath = path13.join(current, "package.json");
2373
+ if (fs12.existsSync(packageJsonPath)) {
1855
2374
  try {
1856
- const packageJson = JSON.parse(fs8.readFileSync(packageJsonPath, "utf-8"));
2375
+ const packageJson = JSON.parse(fs12.readFileSync(packageJsonPath, "utf-8"));
1857
2376
  if (packageJson?.scripts && typeof packageJson.scripts["sandbox:hmr"] === "string") {
1858
2377
  return current;
1859
2378
  }
1860
2379
  } catch {
1861
2380
  }
1862
2381
  }
1863
- const parent = path9.dirname(current);
2382
+ const parent = path13.dirname(current);
1864
2383
  if (parent === current) {
1865
2384
  return null;
1866
2385
  }
@@ -1868,47 +2387,47 @@ function findWorkspaceCommandRoot(projectPath) {
1868
2387
  }
1869
2388
  }
1870
2389
  function linkWorkspaceProjectToolchain(projectPath, workspaceRoot) {
1871
- const packageJsonPath = path9.join(projectPath, "package.json");
1872
- const manifest = JSON.parse(fs8.readFileSync(packageJsonPath, "utf8"));
2390
+ const packageJsonPath = path13.join(projectPath, "package.json");
2391
+ const manifest = JSON.parse(fs12.readFileSync(packageJsonPath, "utf8"));
1873
2392
  for (const section of [manifest.dependencies, manifest.devDependencies]) {
1874
2393
  if (!section) continue;
1875
2394
  for (const name of ["vite", "typescript"]) {
1876
2395
  if (!(name in section)) continue;
1877
- const installedPath = path9.join(workspaceRoot, "node_modules", name);
1878
- if (!fs8.existsSync(path9.join(installedPath, "package.json"))) {
2396
+ const installedPath = path13.join(workspaceRoot, "node_modules", name);
2397
+ if (!fs12.existsSync(path13.join(installedPath, "package.json"))) {
1879
2398
  throw new Error(`Install the contributor workspace before linking ${name}`);
1880
2399
  }
1881
2400
  section[name] = `link:${installedPath}`;
1882
2401
  }
1883
2402
  }
1884
- fs8.writeFileSync(packageJsonPath, `${JSON.stringify(manifest, null, 2)}
2403
+ fs12.writeFileSync(packageJsonPath, `${JSON.stringify(manifest, null, 2)}
1885
2404
  `);
1886
2405
  }
1887
2406
  function configureWorkspaceProjectScripts(projectPath, projectName) {
1888
- const packageJsonPath = path9.join(projectPath, "package.json");
1889
- if (!fs8.existsSync(packageJsonPath)) return false;
2407
+ const packageJsonPath = path13.join(projectPath, "package.json");
2408
+ if (!fs12.existsSync(packageJsonPath)) return false;
1890
2409
  const workspaceRoot = findWorkspaceCommandRoot(projectPath);
1891
2410
  if (!workspaceRoot) return false;
1892
- const workspacePackageJsonPath = path9.join(workspaceRoot, "package.json");
1893
- const workspacePackageJson = JSON.parse(fs8.readFileSync(workspacePackageJsonPath, "utf-8"));
1894
- const packageJson = JSON.parse(fs8.readFileSync(packageJsonPath, "utf-8"));
2411
+ const workspacePackageJsonPath = path13.join(workspaceRoot, "package.json");
2412
+ const workspacePackageJson = JSON.parse(fs12.readFileSync(workspacePackageJsonPath, "utf-8"));
2413
+ const packageJson = JSON.parse(fs12.readFileSync(packageJsonPath, "utf-8"));
1895
2414
  const scripts = packageJson.scripts && typeof packageJson.scripts === "object" ? packageJson.scripts : {};
1896
- const relativeRoot = path9.relative(projectPath, workspaceRoot) || ".";
2415
+ const relativeRoot = path13.relative(projectPath, workspaceRoot) || ".";
1897
2416
  scripts["sandbox:hmr"] = `pnpm -C ${shellQuote(relativeRoot)} sandbox:hmr -- ${shellQuote(projectName)}`;
1898
2417
  if (workspacePackageJson?.scripts && typeof workspacePackageJson.scripts["cli:login:workspace"] === "string") {
1899
2418
  scripts["cli:login:workspace"] = `pnpm -C ${shellQuote(relativeRoot)} cli:login:workspace -- ${shellQuote(projectName)}`;
1900
2419
  }
1901
2420
  packageJson.scripts = scripts;
1902
- fs8.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n", "utf-8");
2421
+ fs12.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n", "utf-8");
1903
2422
  return true;
1904
2423
  }
1905
2424
  function resolvePostInitRunCommand(packageManager, projectPath, workspacePackages, pnpmCompatibilityArgs = []) {
1906
2425
  const command = packageManager === "pnpm" ? [packageManager, ...pnpmCompatibilityArgs].join(" ") : packageManager;
1907
2426
  if (workspacePackages) {
1908
- const packageJsonPath = path9.join(projectPath, "package.json");
1909
- if (fs8.existsSync(packageJsonPath)) {
2427
+ const packageJsonPath = path13.join(projectPath, "package.json");
2428
+ if (fs12.existsSync(packageJsonPath)) {
1910
2429
  try {
1911
- const packageJson = JSON.parse(fs8.readFileSync(packageJsonPath, "utf-8"));
2430
+ const packageJson = JSON.parse(fs12.readFileSync(packageJsonPath, "utf-8"));
1912
2431
  if (packageJson?.scripts && typeof packageJson.scripts["sandbox:hmr"] === "string") {
1913
2432
  return packageManager === "npm" ? "npm run sandbox:hmr" : `${command} sandbox:hmr`;
1914
2433
  }
@@ -2030,7 +2549,7 @@ function networkErrorCode(error) {
2030
2549
  }
2031
2550
  async function startPlatformCliSession(params) {
2032
2551
  const body = {
2033
- machine_name: os3.hostname(),
2552
+ machine_name: os4.hostname(),
2034
2553
  package_manager: params.packageManager
2035
2554
  };
2036
2555
  const projectName = params.projectName?.trim();
@@ -2091,8 +2610,8 @@ function gitCloneArgs(project, projectName) {
2091
2610
  return args;
2092
2611
  }
2093
2612
  function platformGitCredentialHelperCommand(cliEntry = process.argv[1] ?? "") {
2094
- if (process.env.STANDARDAGENTS_WORKSPACE === "1" && cliEntry && fs8.existsSync(cliEntry)) {
2095
- return `!node ${shellQuote(path9.resolve(cliEntry))} git-credential`;
2613
+ if (process.env.STANDARDAGENTS_WORKSPACE === "1" && cliEntry && fs12.existsSync(cliEntry)) {
2614
+ return `!node ${shellQuote(path13.resolve(cliEntry))} git-credential`;
2096
2615
  }
2097
2616
  if (process.env.STANDARD_AGENTS_GIT_HELPER?.trim()) {
2098
2617
  return process.env.STANDARD_AGENTS_GIT_HELPER.trim();
@@ -2308,20 +2827,20 @@ async function waitForPlatformProject(session, onProgress, signal) {
2308
2827
  throw new Error(SESSION_EXPIRED_MESSAGE);
2309
2828
  }
2310
2829
  function appendGitignoreEntries(projectPath, heading, entries) {
2311
- const gitignorePath = path9.join(projectPath, ".gitignore");
2312
- const gitignoreContent = fs8.existsSync(gitignorePath) ? fs8.readFileSync(gitignorePath, "utf-8") : "";
2830
+ const gitignorePath = path13.join(projectPath, ".gitignore");
2831
+ const gitignoreContent = fs12.existsSync(gitignorePath) ? fs12.readFileSync(gitignorePath, "utf-8") : "";
2313
2832
  const existingEntries = new Set(gitignoreContent.split(/\r?\n/));
2314
2833
  const missingEntries = entries.filter((entry) => !existingEntries.has(entry));
2315
2834
  if (missingEntries.length === 0) return;
2316
2835
  const prefix = gitignoreContent.length === 0 ? "" : gitignoreContent.endsWith("\n") ? "\n" : "\n\n";
2317
- fs8.appendFileSync(gitignorePath, `${prefix}${heading}
2836
+ fs12.appendFileSync(gitignorePath, `${prefix}${heading}
2318
2837
  ${missingEntries.join("\n")}
2319
2838
  `);
2320
2839
  }
2321
2840
  function writeLocalPnpmBuildPolicy(projectPath, packageManager, options = {}) {
2322
2841
  if (packageManager !== "pnpm") return false;
2323
- const policyPath = path9.join(projectPath, "pnpm-workspace.yaml");
2324
- if (fs8.existsSync(policyPath)) return false;
2842
+ const policyPath = path13.join(projectPath, "pnpm-workspace.yaml");
2843
+ if (fs12.existsSync(policyPath)) return false;
2325
2844
  const buildPolicySettings = [
2326
2845
  "onlyBuiltDependencies",
2327
2846
  "onlyBuiltDependenciesFile",
@@ -2332,20 +2851,20 @@ function writeLocalPnpmBuildPolicy(projectPath, packageManager, options = {}) {
2332
2851
  "ignoreDepScripts",
2333
2852
  "ignoreScripts"
2334
2853
  ];
2335
- const npmrcPath = path9.join(projectPath, ".npmrc");
2336
- if (fs8.existsSync(npmrcPath)) {
2337
- const hasBuildPolicy = fs8.readFileSync(npmrcPath, "utf8").split(/\r?\n/).some((line) => {
2854
+ const npmrcPath = path13.join(projectPath, ".npmrc");
2855
+ if (fs12.existsSync(npmrcPath)) {
2856
+ const hasBuildPolicy = fs12.readFileSync(npmrcPath, "utf8").split(/\r?\n/).some((line) => {
2338
2857
  const separator = line.indexOf("=");
2339
2858
  const name = (separator < 0 ? line : line.slice(0, separator)).trim().replace(/[-_[\]]/g, "").toLowerCase();
2340
2859
  return buildPolicySettings.some((setting) => setting.toLowerCase() === name);
2341
2860
  });
2342
2861
  if (hasBuildPolicy) return false;
2343
2862
  }
2344
- if (!options.isolateFromParent && findPnpmWorkspaceRoot(path9.dirname(projectPath))) return false;
2863
+ if (!options.isolateFromParent && findPnpmWorkspaceRoot(path13.dirname(projectPath))) return false;
2345
2864
  const ignoredBuildScripts = options.ignoredBuildScripts ?? [];
2346
2865
  const approvedBuildScripts = ["esbuild", "workerd"].filter((name) => !ignoredBuildScripts.includes(name));
2347
- const manifestPath = path9.join(projectPath, "package.json");
2348
- const manifest = JSON.parse(fs8.readFileSync(manifestPath, "utf8"));
2866
+ const manifestPath = path13.join(projectPath, "package.json");
2867
+ const manifest = JSON.parse(fs12.readFileSync(manifestPath, "utf8"));
2349
2868
  const existingPnpm = manifest.pnpm ?? {};
2350
2869
  if (buildPolicySettings.some((name) => Object.hasOwn(existingPnpm, name))) return false;
2351
2870
  manifest.pnpm = {
@@ -2353,9 +2872,9 @@ function writeLocalPnpmBuildPolicy(projectPath, packageManager, options = {}) {
2353
2872
  onlyBuiltDependencies: approvedBuildScripts,
2354
2873
  ...ignoredBuildScripts.length > 0 ? { ignoredBuiltDependencies: ignoredBuildScripts } : {}
2355
2874
  };
2356
- fs8.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}
2875
+ fs12.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}
2357
2876
  `);
2358
- fs8.writeFileSync(policyPath, renderPnpmWorkspaceYaml(approvedBuildScripts, ignoredBuildScripts));
2877
+ fs12.writeFileSync(policyPath, renderPnpmWorkspaceYaml(approvedBuildScripts, ignoredBuildScripts));
2359
2878
  return true;
2360
2879
  }
2361
2880
  function writeStandardAgentsSupportFiles(projectPath, params) {
@@ -2368,10 +2887,10 @@ function writeStandardAgentsSupportFiles(projectPath, params) {
2368
2887
  sip: getSipVersion()
2369
2888
  }
2370
2889
  })) {
2371
- const targetPath = path9.join(projectPath, supportFile.path);
2372
- if (fs8.existsSync(targetPath)) continue;
2373
- fs8.mkdirSync(path9.dirname(targetPath), { recursive: true });
2374
- fs8.writeFileSync(targetPath, supportFile.content, "utf-8");
2890
+ const targetPath = path13.join(projectPath, supportFile.path);
2891
+ if (fs12.existsSync(targetPath)) continue;
2892
+ fs12.mkdirSync(path13.dirname(targetPath), { recursive: true });
2893
+ fs12.writeFileSync(targetPath, supportFile.content, "utf-8");
2375
2894
  written.push(supportFile.path);
2376
2895
  }
2377
2896
  appendGitignoreEntries(projectPath, "# Standard Agents local dev state", [
@@ -2392,11 +2911,12 @@ function supportFiles(options = {}) {
2392
2911
  process.exit(1);
2393
2912
  }
2394
2913
  const cwd = process.cwd();
2395
- const projectName = normalizeProjectName(options.projectName ?? path9.basename(cwd)) || "standard-agents";
2914
+ const projectName = normalizeProjectName(options.projectName ?? path13.basename(cwd)) || "standard-agents";
2396
2915
  const written = writeStandardAgentsSupportFiles(cwd, {
2397
2916
  projectName,
2398
2917
  packageManager
2399
2918
  });
2919
+ pinProjectScopeRegistry(cwd, { packageManager, isolateFromParent: true }, logger);
2400
2920
  if (written.length === 0) {
2401
2921
  logger.info("Standard Agents local support files already exist");
2402
2922
  return;
@@ -2555,7 +3075,7 @@ async function runPlatformInit(projectNameArg, options) {
2555
3075
  process.exit(1);
2556
3076
  }
2557
3077
  const requestedProjectName = projectNameArg?.trim() || void 0;
2558
- if (requestedProjectName && fs8.existsSync(path9.join(cwd, requestedProjectName))) {
3078
+ if (requestedProjectName && fs12.existsSync(path13.join(cwd, requestedProjectName))) {
2559
3079
  exitWithInitFailure(directoryExistsFailure(requestedProjectName));
2560
3080
  }
2561
3081
  const endpoint = normalizeApiUrl(options.apiUrl || options.endpoint);
@@ -2597,7 +3117,7 @@ async function runPlatformInit(projectNameArg, options) {
2597
3117
  exitWithInitFailure({ cause: error instanceof Error ? error.message : String(error), next: [] });
2598
3118
  }
2599
3119
  const projectName = resolveFreeDirectoryName(cwd, platformName);
2600
- const projectPath = path9.join(cwd, projectName);
3120
+ const projectPath = path13.join(cwd, projectName);
2601
3121
  const projectLabel = project.name || projectName;
2602
3122
  logger.success("Browser setup complete.");
2603
3123
  if (projectName !== platformName) {
@@ -2605,7 +3125,7 @@ async function runPlatformInit(projectNameArg, options) {
2605
3125
  }
2606
3126
  logger.info(`Cloning ${cloneDisplayUrl(project)}...`);
2607
3127
  const stopRemoveOnInterrupt = interrupts.onInterrupt(() => {
2608
- fs8.rmSync(projectPath, { recursive: true, force: true });
3128
+ fs12.rmSync(projectPath, { recursive: true, force: true });
2609
3129
  logger.log("");
2610
3130
  logger.info(`Setup interrupted. Removed the partial "${projectName}" directory.`);
2611
3131
  for (const line of finishExistingProjectSteps(projectLabel, dashboardUrl)) {
@@ -2638,7 +3158,7 @@ async function runPlatformInit(projectNameArg, options) {
2638
3158
  apiKey: project.api_key,
2639
3159
  platformEndpoint: endpoint
2640
3160
  });
2641
- logger.success(`Wrote Standard Agents credentials to ${path9.relative(cwd, envPath)}.`);
3161
+ logger.success(`Wrote Standard Agents credentials to ${path13.relative(cwd, envPath)}.`);
2642
3162
  if (project.git_extra_header) {
2643
3163
  await configurePlatformGitCredentialHelper(projectPath);
2644
3164
  logger.success("Configured git credentials for the platform repository.");
@@ -2665,6 +3185,14 @@ async function runPlatformInit(projectNameArg, options) {
2665
3185
  ignoreProjectWorkspace: pnpmCompatibilityArgs.length > 0
2666
3186
  });
2667
3187
  const installCommand = [projectPackageManager, ...installArgs].join(" ");
3188
+ if (pinProjectScopeRegistry(projectPath, { packageManager: projectPackageManager, isolateFromParent: true }, logger).blocked) {
3189
+ exitWithInitFailure(installFailure({
3190
+ directory: projectName,
3191
+ cause: SCOPE_REGISTRY_PIN_BLOCKED_CAUSE,
3192
+ installCommand,
3193
+ devCommand: devHint
3194
+ }));
3195
+ }
2668
3196
  const stopResumeHintOnInterrupt = interrupts.onInterrupt(() => {
2669
3197
  logger.log("");
2670
3198
  logger.info(`Setup interrupted. Your project is cloned and configured in "${projectName}". Finish with:`);
@@ -2685,7 +3213,7 @@ async function runPlatformInit(projectNameArg, options) {
2685
3213
  }
2686
3214
  stopResumeHintOnInterrupt();
2687
3215
  const repoUrl = project.repo_html_url ?? project.repo_clone_url;
2688
- const tokenLocation = path9.relative(cwd, envPath);
3216
+ const tokenLocation = path13.relative(cwd, envPath);
2689
3217
  if (options.dev === false) {
2690
3218
  logger.success("Your Standard Agents instance is ready.");
2691
3219
  logger.log(`Repository: ${repoUrl}`);
@@ -2793,8 +3321,8 @@ var MANAGED_PROVIDER_KEY_HINTS = [
2793
3321
  ""
2794
3322
  ].join("\n");
2795
3323
  function writeLocalDevVars(projectPath, input) {
2796
- const devVarsPath = path9.join(projectPath, DEV_VARS_FILENAME);
2797
- const existed = fs8.existsSync(devVarsPath);
3324
+ const devVarsPath = path13.join(projectPath, DEV_VARS_FILENAME);
3325
+ const existed = fs12.existsSync(devVarsPath);
2798
3326
  const existing = readDevVarsFile(projectPath);
2799
3327
  const wanted = [
2800
3328
  {
@@ -2825,7 +3353,7 @@ function writeLocalDevVars(projectPath, input) {
2825
3353
  }
2826
3354
  const missing = wanted.filter(({ key }) => !readDevVar(existing, key));
2827
3355
  if (existed && missing.length === 0) {
2828
- fs8.chmodSync(devVarsPath, 384);
3356
+ fs12.chmodSync(devVarsPath, 384);
2829
3357
  } else {
2830
3358
  let devVars = existed ? existing : LOCAL_DEV_VARS_HEADER;
2831
3359
  for (const { heading, key, value } of missing) {
@@ -2880,7 +3408,7 @@ async function init(projectNameArg, options = {}) {
2880
3408
  }
2881
3409
  }
2882
3410
  const providedBootstrap = options.bootstrap?.trim() ?? "";
2883
- const needsLocalEnv = (candidate) => !providedBootstrap && candidate.existingBootstrapState === null && !fs8.existsSync(path9.join(candidate.projectPath, ".dev.vars"));
3411
+ const needsLocalEnv = (candidate) => !providedBootstrap && candidate.existingBootstrapState === null && !fs12.existsSync(path13.join(candidate.projectPath, ".dev.vars"));
2884
3412
  const existingProjectPackageManager = (candidate) => candidate.useExistingProject ? detectLockfilePackageManager(candidate.projectPath) : void 0;
2885
3413
  const initialTarget = resolveProjectTarget(cwd, projectNameArg);
2886
3414
  let target;
@@ -2954,8 +3482,8 @@ async function init(projectNameArg, options = {}) {
2954
3482
  "Installing dependencies and applying Standard Agents project structure.",
2955
3483
  headerOptions
2956
3484
  );
2957
- const stopRemoveOnInterrupt = !useExistingProject && !fs8.existsSync(projectPath) ? interrupts.onInterrupt(() => {
2958
- fs8.rmSync(projectPath, { recursive: true, force: true });
3485
+ const stopRemoveOnInterrupt = !useExistingProject && !fs12.existsSync(projectPath) ? interrupts.onInterrupt(() => {
3486
+ fs12.rmSync(projectPath, { recursive: true, force: true });
2959
3487
  logger.log("");
2960
3488
  logger.info(`Setup interrupted. Removed the partial "${projectName}" directory.`);
2961
3489
  }) : () => {
@@ -2991,29 +3519,30 @@ async function init(projectNameArg, options = {}) {
2991
3519
  );
2992
3520
  process.exit(1);
2993
3521
  }
2994
- const viteConfigPath = path9.join(projectPath, "vite.config.ts");
2995
- if (!fs8.existsSync(viteConfigPath)) {
3522
+ const viteConfigPath = path13.join(projectPath, "vite.config.ts");
3523
+ if (!fs12.existsSync(viteConfigPath)) {
2996
3524
  const viteConfigContent = `import { defineConfig } from 'vite'
2997
3525
 
2998
3526
  export default defineConfig({
2999
3527
  plugins: [],
3000
3528
  })
3001
3529
  `;
3002
- fs8.writeFileSync(viteConfigPath, viteConfigContent, "utf-8");
3530
+ fs12.writeFileSync(viteConfigPath, viteConfigContent, "utf-8");
3003
3531
  logSuccess("Created vite.config.ts");
3004
3532
  }
3533
+ writeBuildGuardScript(projectPath);
3005
3534
  } else if (resumeBootstrap) {
3006
3535
  logInfo(`Resuming bootstrap-authenticated init in existing directory "${projectName}"...`);
3007
3536
  } else {
3008
3537
  logInfo(`Detected existing Standard Agents project in "${projectName}".`);
3009
3538
  }
3010
- const packageJsonPath = path9.join(projectPath, "package.json");
3011
- if (fs8.existsSync(packageJsonPath)) {
3012
- const packageJson = JSON.parse(fs8.readFileSync(packageJsonPath, "utf-8"));
3539
+ const packageJsonPath = path13.join(projectPath, "package.json");
3540
+ if (fs12.existsSync(packageJsonPath)) {
3541
+ const packageJson = JSON.parse(fs12.readFileSync(packageJsonPath, "utf-8"));
3013
3542
  const kebabName = toKebabCase(projectName);
3014
3543
  if (packageJson.name !== kebabName) {
3015
3544
  packageJson.name = kebabName;
3016
- fs8.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n", "utf-8");
3545
+ fs12.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n", "utf-8");
3017
3546
  }
3018
3547
  if (packageSpecifier === "workspace:*") {
3019
3548
  const workspaceRoot = resolveStandardAgentsWorkspaceRoot();
@@ -3046,7 +3575,7 @@ export default defineConfig({
3046
3575
  let projectPnpmCompatibilityArgs = [];
3047
3576
  try {
3048
3577
  const installBoundary = { isolateFromParent: packageSpecifier === "workspace:*" };
3049
- if (pm === "pnpm" && !installBoundary.isolateFromParent && !fs8.existsSync(path9.join(projectPath, "pnpm-workspace.yaml")) && findPnpmWorkspaceRoot(path9.dirname(projectPath))) {
3578
+ if (pm === "pnpm" && !installBoundary.isolateFromParent && !fs12.existsSync(path13.join(projectPath, "pnpm-workspace.yaml")) && findPnpmWorkspaceRoot(path13.dirname(projectPath))) {
3050
3579
  logInfo("The enclosing pnpm workspace controls esbuild and workerd build approvals.");
3051
3580
  }
3052
3581
  writeLocalPnpmBuildPolicy(projectPath, pm, {
@@ -3054,6 +3583,11 @@ export default defineConfig({
3054
3583
  // The SDK postinstall only warns about stale model types; runtime files ship built.
3055
3584
  ignoredBuildScripts: openrouterKey ? ["@openrouter/sdk"] : []
3056
3585
  });
3586
+ const scopePin = pinProjectScopeRegistry(projectPath, { packageManager: pm, ...installBoundary }, { info: logInfo, warning: logger.warning });
3587
+ if (scopePin.blocked) {
3588
+ logger.error(`Dependencies are not installed: ${SCOPE_REGISTRY_PIN_BLOCKED_CAUSE}`);
3589
+ process.exit(1);
3590
+ }
3057
3591
  projectPnpmCompatibilityArgs = getPnpmWorkspaceCompatibilityArgs(pm, projectPath);
3058
3592
  const installCmd = pm === "npm" ? "install" : "add";
3059
3593
  if (packageSpecifier === "workspace:*") {
@@ -3092,6 +3626,7 @@ export default defineConfig({
3092
3626
  await withTuiSpinner(initTuiMode, "Scaffolding project files...", async () => {
3093
3627
  await scaffold({
3094
3628
  force: true,
3629
+ scopeRegistryPinned: true,
3095
3630
  standardAgents: packageSpecifier === "workspace:*" ? resolveStandardAgentsPackageSpecifier("@standardagents/builder", packageSpecifier) : void 0
3096
3631
  });
3097
3632
  });
@@ -3119,11 +3654,11 @@ export default defineConfig({
3119
3654
  bootstrapSession
3120
3655
  });
3121
3656
  logSuccess(devVarsResult.status === "created" ? "Created .dev.vars with encryption key" : "Kept existing .dev.vars values and added missing keys");
3122
- const gitignorePath = path9.join(projectPath, ".gitignore");
3123
- if (fs8.existsSync(gitignorePath)) {
3124
- const gitignoreContent = fs8.readFileSync(gitignorePath, "utf-8");
3657
+ const gitignorePath = path13.join(projectPath, ".gitignore");
3658
+ if (fs12.existsSync(gitignorePath)) {
3659
+ const gitignoreContent = fs12.readFileSync(gitignorePath, "utf-8");
3125
3660
  if (!gitignoreContent.includes(".dev.vars")) {
3126
- fs8.appendFileSync(gitignorePath, "\n# Local environment variables\n.dev.vars\n");
3661
+ fs12.appendFileSync(gitignorePath, "\n# Local environment variables\n.dev.vars\n");
3127
3662
  logSuccess("Added .dev.vars to .gitignore");
3128
3663
  }
3129
3664
  }
@@ -3165,7 +3700,7 @@ export default defineConfig({
3165
3700
  logger.log(` ${devVarsResult.generatedAdminPassword}`);
3166
3701
  logger.log("");
3167
3702
  }
3168
- logger.log("For more information, visit: https://standardagents.ai/docs");
3703
+ logger.log("For more information, visit: https://docs.standardagents.ai");
3169
3704
  }
3170
3705
  function registerInitCommand(program2, action = init) {
3171
3706
  program2.command("init [project-name]").description(
@@ -3398,17 +3933,17 @@ var KEYCHAIN_SERVICE = "standardagents-cli";
3398
3933
  function configDir() {
3399
3934
  if (process.platform === "win32") {
3400
3935
  const appData = process.env.APPDATA;
3401
- if (appData) return path9.join(appData, "standardagents");
3936
+ if (appData) return path13.join(appData, "standardagents");
3402
3937
  }
3403
3938
  const xdgConfig = process.env.XDG_CONFIG_HOME;
3404
- if (xdgConfig) return path9.join(xdgConfig, "standardagents");
3405
- return path9.join(os3.homedir(), ".config", "standardagents");
3939
+ if (xdgConfig) return path13.join(xdgConfig, "standardagents");
3940
+ return path13.join(os4.homedir(), ".config", "standardagents");
3406
3941
  }
3407
3942
  function stateFilePath() {
3408
- return path9.join(configDir(), "auth-state.json");
3943
+ return path13.join(configDir(), "auth-state.json");
3409
3944
  }
3410
3945
  function ensureStateDir() {
3411
- fs8.mkdirSync(path9.dirname(stateFilePath()), { recursive: true });
3946
+ fs12.mkdirSync(path13.dirname(stateFilePath()), { recursive: true });
3412
3947
  }
3413
3948
  function securityCommand(args) {
3414
3949
  const result = spawnSync("security", args, { encoding: "utf8" });
@@ -3451,11 +3986,11 @@ function readFromKeychain(orgId) {
3451
3986
  }
3452
3987
  function readCliAuthState() {
3453
3988
  const file = stateFilePath();
3454
- if (!fs8.existsSync(file)) {
3989
+ if (!fs12.existsSync(file)) {
3455
3990
  return { active_org_id: null, orgs: {} };
3456
3991
  }
3457
3992
  try {
3458
- const parsed = JSON.parse(fs8.readFileSync(file, "utf8"));
3993
+ const parsed = JSON.parse(fs12.readFileSync(file, "utf8"));
3459
3994
  return {
3460
3995
  active_org_id: parsed.active_org_id ?? null,
3461
3996
  orgs: parsed.orgs ?? {},
@@ -3600,18 +4135,18 @@ function stripOrgContextFromDevVars(content) {
3600
4135
  }
3601
4136
  function clearLocalOrgContext(projectPath) {
3602
4137
  const statePath = getBootstrapStatePath(projectPath);
3603
- const stateCleared = fs8.existsSync(statePath);
4138
+ const stateCleared = fs12.existsSync(statePath);
3604
4139
  clearBootstrapState(projectPath);
3605
- const devVarsPath = path9.join(projectPath, DEV_VARS_FILENAME2);
3606
- if (!fs8.existsSync(devVarsPath)) {
4140
+ const devVarsPath = path13.join(projectPath, DEV_VARS_FILENAME2);
4141
+ if (!fs12.existsSync(devVarsPath)) {
3607
4142
  return { stateCleared, envCleared: false };
3608
4143
  }
3609
- const content = fs8.readFileSync(devVarsPath, "utf-8");
4144
+ const content = fs12.readFileSync(devVarsPath, "utf-8");
3610
4145
  const stripped = stripOrgContextFromDevVars(content);
3611
4146
  if (!stripped.removed) {
3612
4147
  return { stateCleared, envCleared: false };
3613
4148
  }
3614
- fs8.writeFileSync(devVarsPath, stripped.updated, "utf-8");
4149
+ fs12.writeFileSync(devVarsPath, stripped.updated, "utf-8");
3615
4150
  return { stateCleared, envCleared: true };
3616
4151
  }
3617
4152
  function logLocalClearResult(result) {
@@ -3703,9 +4238,9 @@ export default defineConfig(({ mode }) => {
3703
4238
  }
3704
4239
  function getReactPackageVersion() {
3705
4240
  try {
3706
- const __dirname = path9.dirname(fileURLToPath(import.meta.url));
3707
- const pkgPath = path9.resolve(__dirname, "../package.json");
3708
- const pkg = JSON.parse(fs8.readFileSync(pkgPath, "utf-8"));
4241
+ const __dirname = path13.dirname(fileURLToPath(import.meta.url));
4242
+ const pkgPath = path13.resolve(__dirname, "../package.json");
4243
+ const pkg = JSON.parse(fs12.readFileSync(pkgPath, "utf-8"));
3709
4244
  const version = pkg.version;
3710
4245
  const prereleaseMatch = version.match(/-([a-z]+)\./i);
3711
4246
  if (prereleaseMatch) {
@@ -3717,8 +4252,8 @@ function getReactPackageVersion() {
3717
4252
  }
3718
4253
  }
3719
4254
  function getChatSourceDir() {
3720
- const __dirname = path9.dirname(fileURLToPath(import.meta.url));
3721
- return path9.resolve(__dirname, "../chat");
4255
+ const __dirname = path13.dirname(fileURLToPath(import.meta.url));
4256
+ return path13.resolve(__dirname, "../chat");
3722
4257
  }
3723
4258
  async function prompt2(question) {
3724
4259
  const rl = readline.createInterface({
@@ -3759,10 +4294,10 @@ function detectPackageManager2() {
3759
4294
  if (userAgent.includes("yarn")) return "yarn";
3760
4295
  if (userAgent.includes("bun")) return "bun";
3761
4296
  }
3762
- if (fs8.existsSync("pnpm-lock.yaml")) return "pnpm";
3763
- if (fs8.existsSync("yarn.lock")) return "yarn";
3764
- if (fs8.existsSync("bun.lockb")) return "bun";
3765
- if (fs8.existsSync("package-lock.json")) return "npm";
4297
+ if (fs12.existsSync("pnpm-lock.yaml")) return "pnpm";
4298
+ if (fs12.existsSync("yarn.lock")) return "yarn";
4299
+ if (fs12.existsSync("bun.lockb")) return "bun";
4300
+ if (fs12.existsSync("package-lock.json")) return "npm";
3766
4301
  return "npm";
3767
4302
  }
3768
4303
  async function selectPackageManager(detected) {
@@ -3991,25 +4526,25 @@ minimumReleaseAgeExclude:
3991
4526
  `;
3992
4527
  }
3993
4528
  function copyDir(src, dest, skip = []) {
3994
- if (!fs8.existsSync(dest)) {
3995
- fs8.mkdirSync(dest, { recursive: true });
4529
+ if (!fs12.existsSync(dest)) {
4530
+ fs12.mkdirSync(dest, { recursive: true });
3996
4531
  }
3997
- const entries = fs8.readdirSync(src, { withFileTypes: true });
4532
+ const entries = fs12.readdirSync(src, { withFileTypes: true });
3998
4533
  for (const entry of entries) {
3999
4534
  if (skip.includes(entry.name) || /\.test\.tsx?$/.test(entry.name)) continue;
4000
- const srcPath = path9.join(src, entry.name);
4001
- const destPath = path9.join(dest, entry.name);
4535
+ const srcPath = path13.join(src, entry.name);
4536
+ const destPath = path13.join(dest, entry.name);
4002
4537
  if (entry.isDirectory()) {
4003
4538
  copyDir(srcPath, destPath, skip);
4004
4539
  } else {
4005
- fs8.copyFileSync(srcPath, destPath);
4540
+ fs12.copyFileSync(srcPath, destPath);
4006
4541
  }
4007
4542
  }
4008
4543
  }
4009
4544
  async function initChat(projectNameArg, options = {}) {
4010
4545
  const cwd = process.cwd();
4011
4546
  const chatSourceDir = getChatSourceDir();
4012
- if (!fs8.existsSync(chatSourceDir)) {
4547
+ if (!fs12.existsSync(chatSourceDir)) {
4013
4548
  logger.error("Chat source files not found. This CLI installation may be corrupted.");
4014
4549
  process.exit(1);
4015
4550
  }
@@ -4024,8 +4559,8 @@ async function initChat(projectNameArg, options = {}) {
4024
4559
  logger.error("Project name is required");
4025
4560
  process.exit(1);
4026
4561
  }
4027
- const projectPath = path9.join(cwd, projectName);
4028
- if (fs8.existsSync(projectPath)) {
4562
+ const projectPath = path13.join(cwd, projectName);
4563
+ if (fs12.existsSync(projectPath)) {
4029
4564
  logger.error(`Directory "${projectName}" already exists`);
4030
4565
  process.exit(1);
4031
4566
  }
@@ -4068,13 +4603,17 @@ async function initChat(projectNameArg, options = {}) {
4068
4603
  logger.log("");
4069
4604
  logger.info(`Creating ${framework === "vite" ? "Vite" : "Next.js"} project...`);
4070
4605
  logger.log("");
4071
- fs8.mkdirSync(projectPath, { recursive: true });
4606
+ fs12.mkdirSync(projectPath, { recursive: true });
4072
4607
  const reactVersion = getReactPackageVersion();
4073
4608
  if (framework === "vite") {
4074
4609
  await scaffoldVite(projectPath, chatSourceDir, projectName, serverUrl, reactVersion);
4075
4610
  } else {
4076
4611
  await scaffoldNextjs(projectPath, chatSourceDir, projectName, serverUrl, reactVersion);
4077
4612
  }
4613
+ if (pinProjectScopeRegistry(projectPath, { packageManager: pm }, logger).blocked) {
4614
+ logger.error(`Dependencies are not installed: ${SCOPE_REGISTRY_PIN_BLOCKED_CAUSE}`);
4615
+ process.exit(1);
4616
+ }
4078
4617
  logger.log("");
4079
4618
  logger.info("Installing dependencies...");
4080
4619
  logger.log("");
@@ -4119,25 +4658,25 @@ async function initChat(projectNameArg, options = {}) {
4119
4658
  });
4120
4659
  }
4121
4660
  async function scaffoldVite(projectPath, chatSourceDir, projectName, serverUrl, reactVersion) {
4122
- copyDir(path9.join(chatSourceDir, "src"), path9.join(projectPath, "src"), []);
4661
+ copyDir(path13.join(chatSourceDir, "src"), path13.join(projectPath, "src"), []);
4123
4662
  logger.success("Copied src/");
4124
- const viteDir = path9.join(chatSourceDir, "vite");
4125
- let indexHtml = fs8.readFileSync(path9.join(viteDir, "index.html"), "utf-8");
4663
+ const viteDir = path13.join(chatSourceDir, "vite");
4664
+ let indexHtml = fs12.readFileSync(path13.join(viteDir, "index.html"), "utf-8");
4126
4665
  indexHtml = indexHtml.replace('src="/main.tsx"', 'src="/src/main.tsx"');
4127
- fs8.writeFileSync(path9.join(projectPath, "index.html"), indexHtml, "utf-8");
4666
+ fs12.writeFileSync(path13.join(projectPath, "index.html"), indexHtml, "utf-8");
4128
4667
  logger.success("Created index.html");
4129
- fs8.copyFileSync(path9.join(viteDir, "main.tsx"), path9.join(projectPath, "src", "main.tsx"));
4668
+ fs12.copyFileSync(path13.join(viteDir, "main.tsx"), path13.join(projectPath, "src", "main.tsx"));
4130
4669
  logger.success("Created src/main.tsx");
4131
- fs8.writeFileSync(path9.join(projectPath, "vite.config.ts"), renderChatViteConfig(), "utf-8");
4670
+ fs12.writeFileSync(path13.join(projectPath, "vite.config.ts"), renderChatViteConfig(), "utf-8");
4132
4671
  logger.success("Created vite.config.ts");
4133
- fs8.copyFileSync(path9.join(chatSourceDir, "tsconfig.json"), path9.join(projectPath, "tsconfig.json"));
4134
- const tsconfig = JSON.parse(fs8.readFileSync(path9.join(projectPath, "tsconfig.json"), "utf-8"));
4672
+ fs12.copyFileSync(path13.join(chatSourceDir, "tsconfig.json"), path13.join(projectPath, "tsconfig.json"));
4673
+ const tsconfig = JSON.parse(fs12.readFileSync(path13.join(projectPath, "tsconfig.json"), "utf-8"));
4135
4674
  tsconfig.include = ["src"];
4136
4675
  delete tsconfig.compilerOptions?.paths;
4137
- fs8.writeFileSync(path9.join(projectPath, "tsconfig.json"), JSON.stringify(tsconfig, null, 2) + "\n", "utf-8");
4676
+ fs12.writeFileSync(path13.join(projectPath, "tsconfig.json"), JSON.stringify(tsconfig, null, 2) + "\n", "utf-8");
4138
4677
  logger.success("Created tsconfig.json");
4139
- fs8.copyFileSync(path9.join(chatSourceDir, "package.json"), path9.join(projectPath, "package.json"));
4140
- const pkg = JSON.parse(fs8.readFileSync(path9.join(projectPath, "package.json"), "utf-8"));
4678
+ fs12.copyFileSync(path13.join(chatSourceDir, "package.json"), path13.join(projectPath, "package.json"));
4679
+ const pkg = JSON.parse(fs12.readFileSync(path13.join(projectPath, "package.json"), "utf-8"));
4141
4680
  pkg.name = projectName;
4142
4681
  pkg.scripts = { ...CHAT_SCRIPTS.vite };
4143
4682
  delete pkg.private;
@@ -4148,36 +4687,36 @@ async function scaffoldVite(projectPath, chatSourceDir, projectName, serverUrl,
4148
4687
  delete pkg.devDependencies?.["@tailwindcss/postcss"];
4149
4688
  delete pkg.devDependencies?.["postcss"];
4150
4689
  delete pkg.devDependencies?.["vitest"];
4151
- fs8.writeFileSync(path9.join(projectPath, "package.json"), JSON.stringify(applyChatBuildApprovals(pkg), null, 2) + "\n", "utf-8");
4152
- fs8.writeFileSync(path9.join(projectPath, "pnpm-workspace.yaml"), renderChatPnpmWorkspaceYaml(), "utf-8");
4690
+ fs12.writeFileSync(path13.join(projectPath, "package.json"), JSON.stringify(applyChatBuildApprovals(pkg), null, 2) + "\n", "utf-8");
4691
+ fs12.writeFileSync(path13.join(projectPath, "pnpm-workspace.yaml"), renderChatPnpmWorkspaceYaml(), "utf-8");
4153
4692
  logger.success("Created package.json");
4154
4693
  const envContent = `# Standard Agents Builder connection
4155
4694
  VITE_AGENTBUILDER_URL=${serverUrl}
4156
4695
  `;
4157
- fs8.writeFileSync(path9.join(projectPath, ".env"), envContent, "utf-8");
4696
+ fs12.writeFileSync(path13.join(projectPath, ".env"), envContent, "utf-8");
4158
4697
  logger.success("Created .env");
4159
- fs8.writeFileSync(path9.join(projectPath, ".gitignore"), `node_modules
4698
+ fs12.writeFileSync(path13.join(projectPath, ".gitignore"), `node_modules
4160
4699
  dist
4161
4700
  .env
4162
4701
  `, "utf-8");
4163
4702
  logger.success("Created .gitignore");
4164
- let mainTsx = fs8.readFileSync(path9.join(projectPath, "src", "main.tsx"), "utf-8");
4703
+ let mainTsx = fs12.readFileSync(path13.join(projectPath, "src", "main.tsx"), "utf-8");
4165
4704
  mainTsx = mainTsx.replace(/from '\.\.\/src\//g, "from './").replace(/import '\.\.\/src\//g, "import './");
4166
- fs8.writeFileSync(path9.join(projectPath, "src", "main.tsx"), mainTsx, "utf-8");
4167
- if (fs8.existsSync(path9.join(viteDir, "favicon.svg"))) {
4168
- fs8.copyFileSync(path9.join(viteDir, "favicon.svg"), path9.join(projectPath, "favicon.svg"));
4705
+ fs12.writeFileSync(path13.join(projectPath, "src", "main.tsx"), mainTsx, "utf-8");
4706
+ if (fs12.existsSync(path13.join(viteDir, "favicon.svg"))) {
4707
+ fs12.copyFileSync(path13.join(viteDir, "favicon.svg"), path13.join(projectPath, "favicon.svg"));
4169
4708
  logger.success("Created favicon.svg");
4170
4709
  }
4171
4710
  }
4172
4711
  async function scaffoldNextjs(projectPath, chatSourceDir, projectName, serverUrl, reactVersion) {
4173
- copyDir(path9.join(chatSourceDir, "src"), path9.join(projectPath, "src"), []);
4712
+ copyDir(path13.join(chatSourceDir, "src"), path13.join(projectPath, "src"), []);
4174
4713
  logger.success("Copied src/");
4175
- const nextDir = path9.join(chatSourceDir, "next");
4176
- copyDir(path9.join(nextDir, "app"), path9.join(projectPath, "app"), []);
4714
+ const nextDir = path13.join(chatSourceDir, "next");
4715
+ copyDir(path13.join(nextDir, "app"), path13.join(projectPath, "app"), []);
4177
4716
  logger.success("Copied app/");
4178
- fs8.copyFileSync(path9.join(nextDir, "next.config.ts"), path9.join(projectPath, "next.config.ts"));
4717
+ fs12.copyFileSync(path13.join(nextDir, "next.config.ts"), path13.join(projectPath, "next.config.ts"));
4179
4718
  logger.success("Created next.config.ts");
4180
- fs8.copyFileSync(path9.join(nextDir, "postcss.config.mjs"), path9.join(projectPath, "postcss.config.mjs"));
4719
+ fs12.copyFileSync(path13.join(nextDir, "postcss.config.mjs"), path13.join(projectPath, "postcss.config.mjs"));
4181
4720
  logger.success("Created postcss.config.mjs");
4182
4721
  const tsconfig = {
4183
4722
  compilerOptions: {
@@ -4202,9 +4741,9 @@ async function scaffoldNextjs(projectPath, chatSourceDir, projectName, serverUrl
4202
4741
  include: ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
4203
4742
  exclude: ["node_modules"]
4204
4743
  };
4205
- fs8.writeFileSync(path9.join(projectPath, "tsconfig.json"), JSON.stringify(tsconfig, null, 2) + "\n", "utf-8");
4744
+ fs12.writeFileSync(path13.join(projectPath, "tsconfig.json"), JSON.stringify(tsconfig, null, 2) + "\n", "utf-8");
4206
4745
  logger.success("Created tsconfig.json");
4207
- const pkg = JSON.parse(fs8.readFileSync(path9.join(chatSourceDir, "package.json"), "utf-8"));
4746
+ const pkg = JSON.parse(fs12.readFileSync(path13.join(chatSourceDir, "package.json"), "utf-8"));
4208
4747
  pkg.name = projectName;
4209
4748
  pkg.scripts = { ...CHAT_SCRIPTS.nextjs };
4210
4749
  delete pkg.private;
@@ -4215,26 +4754,26 @@ async function scaffoldNextjs(projectPath, chatSourceDir, projectName, serverUrl
4215
4754
  delete pkg.devDependencies?.["@vitejs/plugin-react"];
4216
4755
  delete pkg.devDependencies?.["vite"];
4217
4756
  delete pkg.devDependencies?.["vitest"];
4218
- fs8.writeFileSync(path9.join(projectPath, "package.json"), JSON.stringify(applyChatBuildApprovals(pkg), null, 2) + "\n", "utf-8");
4219
- fs8.writeFileSync(path9.join(projectPath, "pnpm-workspace.yaml"), renderChatPnpmWorkspaceYaml(), "utf-8");
4757
+ fs12.writeFileSync(path13.join(projectPath, "package.json"), JSON.stringify(applyChatBuildApprovals(pkg), null, 2) + "\n", "utf-8");
4758
+ fs12.writeFileSync(path13.join(projectPath, "pnpm-workspace.yaml"), renderChatPnpmWorkspaceYaml(), "utf-8");
4220
4759
  logger.success("Created package.json");
4221
4760
  const envContent = `# Standard Agents Builder connection
4222
4761
  NEXT_PUBLIC_AGENTBUILDER_URL=${serverUrl}
4223
4762
  `;
4224
- fs8.writeFileSync(path9.join(projectPath, ".env.local"), envContent, "utf-8");
4763
+ fs12.writeFileSync(path13.join(projectPath, ".env.local"), envContent, "utf-8");
4225
4764
  logger.success("Created .env.local");
4226
- fs8.writeFileSync(path9.join(projectPath, ".gitignore"), `node_modules
4765
+ fs12.writeFileSync(path13.join(projectPath, ".gitignore"), `node_modules
4227
4766
  .next
4228
4767
  out
4229
4768
  .env.local
4230
4769
  `, "utf-8");
4231
4770
  logger.success("Created .gitignore");
4232
- let layoutTsx = fs8.readFileSync(path9.join(projectPath, "app", "layout.tsx"), "utf-8");
4771
+ let layoutTsx = fs12.readFileSync(path13.join(projectPath, "app", "layout.tsx"), "utf-8");
4233
4772
  layoutTsx = layoutTsx.replace(/from '\.\.\/\.\.\/src\//g, "from '../src/");
4234
- fs8.writeFileSync(path9.join(projectPath, "app", "layout.tsx"), layoutTsx, "utf-8");
4235
- let pageTsx = fs8.readFileSync(path9.join(projectPath, "app", "page.tsx"), "utf-8");
4773
+ fs12.writeFileSync(path13.join(projectPath, "app", "layout.tsx"), layoutTsx, "utf-8");
4774
+ let pageTsx = fs12.readFileSync(path13.join(projectPath, "app", "page.tsx"), "utf-8");
4236
4775
  pageTsx = pageTsx.replace(/from '\.\.\/\.\.\/src\//g, "from '../src/");
4237
- fs8.writeFileSync(path9.join(projectPath, "app", "page.tsx"), pageTsx, "utf-8");
4776
+ fs12.writeFileSync(path13.join(projectPath, "app", "page.tsx"), pageTsx, "utf-8");
4238
4777
  }
4239
4778
  async function selectAgent(agents) {
4240
4779
  return new Promise((resolve) => {
@@ -4356,11 +4895,11 @@ async function selectItemModes(items, _agentName) {
4356
4895
  });
4357
4896
  }
4358
4897
  function isStandardAgentsProject() {
4359
- if (!fs8.existsSync("agents")) {
4898
+ if (!fs12.existsSync("agents")) {
4360
4899
  return false;
4361
4900
  }
4362
4901
  try {
4363
- const pkgJson = JSON.parse(fs8.readFileSync("package.json", "utf-8"));
4902
+ const pkgJson = JSON.parse(fs12.readFileSync("package.json", "utf-8"));
4364
4903
  const deps = { ...pkgJson.dependencies, ...pkgJson.devDependencies };
4365
4904
  return "@standardagents/builder" in deps;
4366
4905
  } catch {
@@ -4504,7 +5043,7 @@ async function pack(agentName, options) {
4504
5043
  }));
4505
5044
  console.log("");
4506
5045
  }
4507
- const outputDir = options.output || path9.join(rootDir, "agents", "packed");
5046
+ const outputDir = options.output || path13.join(rootDir, "agents", "packed");
4508
5047
  logger.info(`Packing to: ${outputDir}`);
4509
5048
  const result = await packingService.pack({
4510
5049
  agentName: selectedAgent,
@@ -4547,11 +5086,11 @@ function registerPackCommand(program2) {
4547
5086
  program2.command("pack [agent-name]").description("Pack an agent with all its dependencies").option("--output <dir>", "Output directory (default: agents/packed)").option("--npm", "Generate npm-ready package structure").option("--version <version>", "Package version (default: 1.0.0)").option("--no-remove", "Keep original files after packing").option("--no-interactive", "Skip interactive item mode selector").action(pack);
4548
5087
  }
4549
5088
  function isStandardAgentsProject2() {
4550
- if (!fs8.existsSync("agents")) {
5089
+ if (!fs12.existsSync("agents")) {
4551
5090
  return false;
4552
5091
  }
4553
5092
  try {
4554
- const pkgJson = JSON.parse(fs8.readFileSync("package.json", "utf-8"));
5093
+ const pkgJson = JSON.parse(fs12.readFileSync("package.json", "utf-8"));
4555
5094
  const deps = { ...pkgJson.dependencies, ...pkgJson.devDependencies };
4556
5095
  return "@standardagents/builder" in deps;
4557
5096
  } catch {
@@ -4612,7 +5151,7 @@ async function unpack(pkgIdentifier) {
4612
5151
  console.log("");
4613
5152
  logger.info("Created files:");
4614
5153
  for (const file of result.filesGenerated) {
4615
- const relPath = path9.relative(rootDir, file);
5154
+ const relPath = path13.relative(rootDir, file);
4616
5155
  console.log(` - ${relPath}`);
4617
5156
  }
4618
5157
  }
@@ -4722,8 +5261,8 @@ var PROJECT_SIGNAL_PATHS = [
4722
5261
  "vite.config.mjs"
4723
5262
  ];
4724
5263
  function hasProjectSignals(cwd) {
4725
- const hits = PROJECT_SIGNAL_PATHS.filter((signal) => fs8.existsSync(path9.join(cwd, signal))).length;
4726
- return hits >= 2 || fs8.existsSync(path9.join(cwd, ".agents"));
5264
+ const hits = PROJECT_SIGNAL_PATHS.filter((signal) => fs12.existsSync(path13.join(cwd, signal))).length;
5265
+ return hits >= 2 || fs12.existsSync(path13.join(cwd, ".agents"));
4727
5266
  }
4728
5267
  function detectCliDirectoryContext(cwd = process.cwd()) {
4729
5268
  if (!hasProjectSignals(cwd)) {
@@ -4895,14 +5434,14 @@ async function runHomeTui(cwd = process.cwd()) {
4895
5434
  return selection;
4896
5435
  }
4897
5436
  var DEFAULT_SKILL_NAME = "agentbuilder";
4898
- function resolveCodexHome(env = process.env, homeDir = os3.homedir()) {
4899
- return env.CODEX_HOME || path9.join(homeDir, ".codex");
5437
+ function resolveCodexHome(env = process.env, homeDir = os4.homedir()) {
5438
+ return env.CODEX_HOME || path13.join(homeDir, ".codex");
4900
5439
  }
4901
- function resolveClaudeHome(homeDir = os3.homedir()) {
4902
- return path9.join(homeDir, ".claude");
5440
+ function resolveClaudeHome(homeDir = os4.homedir()) {
5441
+ return path13.join(homeDir, ".claude");
4903
5442
  }
4904
- function resolveAgentsHome(homeDir = os3.homedir()) {
4905
- return path9.join(homeDir, ".agents");
5443
+ function resolveAgentsHome(homeDir = os4.homedir()) {
5444
+ return path13.join(homeDir, ".agents");
4906
5445
  }
4907
5446
  function normalizeTargetId(target) {
4908
5447
  if (target === "codex" || target === "agents") {
@@ -4910,17 +5449,17 @@ function normalizeTargetId(target) {
4910
5449
  }
4911
5450
  return target === "claude" ? "claude" : null;
4912
5451
  }
4913
- function expandHomePath(inputPath, homeDir = os3.homedir()) {
5452
+ function expandHomePath(inputPath, homeDir = os4.homedir()) {
4914
5453
  if (inputPath === "~") {
4915
5454
  return homeDir;
4916
5455
  }
4917
5456
  if (inputPath.startsWith("~/")) {
4918
- return path9.join(homeDir, inputPath.slice(2));
5457
+ return path13.join(homeDir, inputPath.slice(2));
4919
5458
  }
4920
5459
  return inputPath;
4921
5460
  }
4922
- function buildInstallTargets(options = {}, env = process.env, homeDir = os3.homedir()) {
4923
- const customRoot = options.dir ? path9.resolve(expandHomePath(options.dir, homeDir)) : null;
5461
+ function buildInstallTargets(options = {}, env = process.env, homeDir = os4.homedir()) {
5462
+ const customRoot = options.dir ? path13.resolve(expandHomePath(options.dir, homeDir)) : null;
4924
5463
  const agentsHome = resolveAgentsHome(homeDir);
4925
5464
  const claudeHome = resolveClaudeHome(homeDir);
4926
5465
  return [
@@ -4928,19 +5467,19 @@ function buildInstallTargets(options = {}, env = process.env, homeDir = os3.home
4928
5467
  id: "agents",
4929
5468
  label: "Codex and other coding agents",
4930
5469
  summary: "Agent Skills folder read by Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, and others",
4931
- detected: fs8.existsSync(agentsHome) || fs8.existsSync(resolveCodexHome(env, homeDir)),
4932
- installPath: customRoot ?? path9.join(agentsHome, "skills")
5470
+ detected: fs12.existsSync(agentsHome) || fs12.existsSync(resolveCodexHome(env, homeDir)),
5471
+ installPath: customRoot ?? path13.join(agentsHome, "skills")
4933
5472
  },
4934
5473
  {
4935
5474
  id: "claude",
4936
5475
  label: "Claude Code",
4937
5476
  summary: "Agent Skills folder read by Claude Code",
4938
- detected: fs8.existsSync(claudeHome),
4939
- installPath: customRoot ?? path9.join(claudeHome, "skills")
5477
+ detected: fs12.existsSync(claudeHome),
5478
+ installPath: customRoot ?? path13.join(claudeHome, "skills")
4940
5479
  }
4941
5480
  ];
4942
5481
  }
4943
- function resolveSelectedTarget(targetId, options = {}, env = process.env, homeDir = os3.homedir()) {
5482
+ function resolveSelectedTarget(targetId, options = {}, env = process.env, homeDir = os4.homedir()) {
4944
5483
  const normalizedId = normalizeTargetId(targetId);
4945
5484
  const target = buildInstallTargets(options, env, homeDir).find(
4946
5485
  (candidate) => candidate.id === normalizedId
@@ -4952,12 +5491,12 @@ function resolveSelectedTarget(targetId, options = {}, env = process.env, homeDi
4952
5491
  }
4953
5492
  return target;
4954
5493
  }
4955
- function findSupersededInstalls(targetId, skillName = DEFAULT_SKILL_NAME, options = {}, env = process.env, homeDir = os3.homedir()) {
5494
+ function findSupersededInstalls(targetId, skillName = DEFAULT_SKILL_NAME, options = {}, env = process.env, homeDir = os4.homedir()) {
4956
5495
  if (options.dir) {
4957
5496
  return [];
4958
5497
  }
4959
- const superseded = normalizeTargetId(targetId) === "claude" ? path9.join(resolveClaudeHome(homeDir), "agents", `${skillName}.md`) : path9.join(resolveCodexHome(env, homeDir), "skills", skillName);
4960
- return fs8.existsSync(superseded) ? [superseded] : [];
5498
+ const superseded = normalizeTargetId(targetId) === "claude" ? path13.join(resolveClaudeHome(homeDir), "agents", `${skillName}.md`) : path13.join(resolveCodexHome(env, homeDir), "skills", skillName);
5499
+ return fs12.existsSync(superseded) ? [superseded] : [];
4961
5500
  }
4962
5501
  async function selectInstallTarget(targets) {
4963
5502
  return new Promise((resolve) => {
@@ -5021,8 +5560,8 @@ async function selectInstallTarget(targets) {
5021
5560
  }
5022
5561
  async function installBundledSkill(targetId, skillName = DEFAULT_SKILL_NAME, options = {}) {
5023
5562
  const target = resolveSelectedTarget(targetId, options);
5024
- const targetDir = path9.join(target.installPath, skillName);
5025
- if (fs8.existsSync(targetDir) && !options.force) {
5563
+ const targetDir = path13.join(target.installPath, skillName);
5564
+ if (fs12.existsSync(targetDir) && !options.force) {
5026
5565
  throw new Error(
5027
5566
  `Skill already exists at ${targetDir}. Re-run with --force to overwrite it.`
5028
5567
  );
@@ -5050,7 +5589,7 @@ async function skill(options = {}) {
5050
5589
  logger.log("");
5051
5590
  logger.log("Next steps:");
5052
5591
  logger.log(` Restart ${selectedTarget.id === "claude" ? "Claude Code" : "your coding agent"} if it is already running`);
5053
- logger.log(` Edit ${path9.join(installedPath, "SKILL.md")} to continue customizing the skill`);
5592
+ logger.log(` Edit ${path13.join(installedPath, "SKILL.md")} to continue customizing the skill`);
5054
5593
  for (const superseded of findSupersededInstalls(
5055
5594
  selectedTarget.id,
5056
5595
  DEFAULT_SKILL_NAME,
@@ -5178,24 +5717,24 @@ function parseEnvFile(content) {
5178
5717
  return result;
5179
5718
  }
5180
5719
  function findProjectRoot(startDir = process.cwd()) {
5181
- let currentDir = path9.resolve(startDir);
5720
+ let currentDir = path13.resolve(startDir);
5182
5721
  while (true) {
5183
- if (fs8.existsSync(path9.join(currentDir, "package.json"))) {
5722
+ if (fs12.existsSync(path13.join(currentDir, "package.json"))) {
5184
5723
  return currentDir;
5185
5724
  }
5186
- const parentDir = path9.dirname(currentDir);
5725
+ const parentDir = path13.dirname(currentDir);
5187
5726
  if (parentDir === currentDir) {
5188
- return path9.resolve(startDir);
5727
+ return path13.resolve(startDir);
5189
5728
  }
5190
5729
  currentDir = parentDir;
5191
5730
  }
5192
5731
  }
5193
5732
  function readProjectPackageJson(projectRoot) {
5194
- const packagePath = path9.join(projectRoot, "package.json");
5195
- if (!fs8.existsSync(packagePath)) {
5733
+ const packagePath = path13.join(projectRoot, "package.json");
5734
+ if (!fs12.existsSync(packagePath)) {
5196
5735
  return {};
5197
5736
  }
5198
- return JSON.parse(fs8.readFileSync(packagePath, "utf8"));
5737
+ return JSON.parse(fs12.readFileSync(packagePath, "utf8"));
5199
5738
  }
5200
5739
  function getDeclaredProviderPackages(projectRoot) {
5201
5740
  const pkg = readProjectPackageJson(projectRoot);
@@ -5212,23 +5751,23 @@ function resolvePackageEntry(packageName, projectRoot) {
5212
5751
  if (!packageDir) {
5213
5752
  return null;
5214
5753
  }
5215
- const packageJsonPath = path9.join(packageDir, "package.json");
5754
+ const packageJsonPath = path13.join(packageDir, "package.json");
5216
5755
  try {
5217
- const packageJson = JSON.parse(fs8.readFileSync(packageJsonPath, "utf8"));
5756
+ const packageJson = JSON.parse(fs12.readFileSync(packageJsonPath, "utf8"));
5218
5757
  const exportPath = resolvePackageExportPath(packageJson.exports) || packageJson.main || "index.js";
5219
- return path9.join(packageDir, exportPath);
5758
+ return path13.join(packageDir, exportPath);
5220
5759
  } catch {
5221
5760
  return null;
5222
5761
  }
5223
5762
  }
5224
5763
  function findInstalledPackageDir(packageName, projectRoot) {
5225
- let currentDir = path9.resolve(projectRoot);
5764
+ let currentDir = path13.resolve(projectRoot);
5226
5765
  while (true) {
5227
- const candidate = path9.join(currentDir, "node_modules", ...packageName.split("/"));
5228
- if (fs8.existsSync(candidate)) {
5766
+ const candidate = path13.join(currentDir, "node_modules", ...packageName.split("/"));
5767
+ if (fs12.existsSync(candidate)) {
5229
5768
  return candidate;
5230
5769
  }
5231
- const parentDir = path9.dirname(currentDir);
5770
+ const parentDir = path13.dirname(currentDir);
5232
5771
  if (parentDir === currentDir) {
5233
5772
  return null;
5234
5773
  }
@@ -5260,9 +5799,9 @@ function loadProjectEnv(projectRoot, processEnv = process.env) {
5260
5799
  const result = {};
5261
5800
  const envFiles = [".env", ".env.local", ".dev.vars", ".dev.vars.local"];
5262
5801
  for (const fileName of envFiles) {
5263
- const filePath = path9.join(projectRoot, fileName);
5264
- if (!fs8.existsSync(filePath)) continue;
5265
- Object.assign(result, parseEnvFile(fs8.readFileSync(filePath, "utf8")));
5802
+ const filePath = path13.join(projectRoot, fileName);
5803
+ if (!fs12.existsSync(filePath)) continue;
5804
+ Object.assign(result, parseEnvFile(fs12.readFileSync(filePath, "utf8")));
5266
5805
  }
5267
5806
  for (const [key, value] of Object.entries(processEnv)) {
5268
5807
  if (typeof value === "string") {
@@ -5536,11 +6075,11 @@ function parseKeyValueLines(input) {
5536
6075
  return result;
5537
6076
  }
5538
6077
  function findDotDevVars(startDir = process.cwd()) {
5539
- let current = path9.resolve(startDir);
6078
+ let current = path13.resolve(startDir);
5540
6079
  while (true) {
5541
- const candidate = path9.join(current, ".dev.vars");
5542
- if (fs8.existsSync(candidate)) return candidate;
5543
- const parent = path9.dirname(current);
6080
+ const candidate = path13.join(current, ".dev.vars");
6081
+ if (fs12.existsSync(candidate)) return candidate;
6082
+ const parent = path13.dirname(current);
5544
6083
  if (parent === current) return null;
5545
6084
  current = parent;
5546
6085
  }
@@ -5550,7 +6089,7 @@ function normalizeEndpoint(value) {
5550
6089
  }
5551
6090
  function loadLocalConfig(options) {
5552
6091
  const envPath = findDotDevVars(options.startDir);
5553
- const fileVars = envPath ? parseKeyValueLines(fs8.readFileSync(envPath, "utf-8")) : {};
6092
+ const fileVars = envPath ? parseKeyValueLines(fs12.readFileSync(envPath, "utf-8")) : {};
5554
6093
  const endpoint = normalizeEndpoint(
5555
6094
  options.endpoint || process.env.STANDARD_AGENTS_API_URL || process.env.PLATFORM_ENDPOINT || fileVars.STANDARD_AGENTS_API_URL || fileVars.PLATFORM_ENDPOINT || ""
5556
6095
  );
@@ -5825,7 +6364,7 @@ async function gitLogin(options = {}) {
5825
6364
  }
5826
6365
  async function mintGitAccessApiKey(endpoint, sessionCookie, fetchImpl = fetch) {
5827
6366
  try {
5828
- const label = `git (${os3.hostname()})`;
6367
+ const label = `git (${os4.hostname()})`;
5829
6368
  const response = await fetchImpl(`${endpoint}/api-keys`, {
5830
6369
  method: "POST",
5831
6370
  headers: {
@@ -5849,14 +6388,14 @@ function resolveDiagConfig(options, env = process.env, fetchImpl) {
5849
6388
  const resolvedFetch = typeof fetchImpl === "function" ? fetchImpl : fetch;
5850
6389
  return { endpoint, token, json: Boolean(options.json), fetchImpl: resolvedFetch };
5851
6390
  }
5852
- async function apiGet(config, path16) {
5853
- return apiRequest(config, path16, "GET");
6391
+ async function apiGet(config, path20) {
6392
+ return apiRequest(config, path20, "GET");
5854
6393
  }
5855
- async function apiRequest(config, path16, method, body) {
6394
+ async function apiRequest(config, path20, method, body) {
5856
6395
  const headers = { Accept: "application/json" };
5857
6396
  if (config.token) headers.Authorization = `Bearer ${config.token}`;
5858
6397
  if (body !== void 0) headers["Content-Type"] = "application/json";
5859
- const response = await config.fetchImpl(`${config.endpoint}${path16}`, {
6398
+ const response = await config.fetchImpl(`${config.endpoint}${path20}`, {
5860
6399
  method,
5861
6400
  headers,
5862
6401
  body: body === void 0 ? void 0 : JSON.stringify(body)
@@ -5869,13 +6408,13 @@ async function apiRequest(config, path16, method, body) {
5869
6408
  if (parsed.error) detail = parsed.error;
5870
6409
  } catch {
5871
6410
  }
5872
- throw new Error(`${method} ${path16} \u2192 HTTP ${response.status}: ${detail}`);
6411
+ throw new Error(`${method} ${path20} \u2192 HTTP ${response.status}: ${detail}`);
5873
6412
  }
5874
6413
  try {
5875
6414
  return JSON.parse(text);
5876
6415
  } catch {
5877
6416
  throw new Error(
5878
- `${method} ${path16} returned non-JSON (is this a Standard Agents Builder instance URL?): ${text.slice(0, 120)}`
6417
+ `${method} ${path20} returned non-JSON (is this a Standard Agents Builder instance URL?): ${text.slice(0, 120)}`
5879
6418
  );
5880
6419
  }
5881
6420
  }
@@ -6242,7 +6781,7 @@ async function settleStdinForInitHandoff(stdin = process.stdin) {
6242
6781
  }
6243
6782
  }
6244
6783
  var program = new Command();
6245
- program.name("agents").description("CLI tool for Standard Agents Builder").version("0.45.3");
6784
+ program.name("agents").description("CLI tool for Standard Agents Builder").version("0.45.4");
6246
6785
  registerInitCommand(program);
6247
6786
  program.command("login").description("Link this project to your Standard Agents account (opens the browser, or use --bootstrap)").option("--bootstrap <code>", "Setup code from the project Overview page in the Standard Agents dashboard").option("--endpoint <url>", "Platform API endpoint (default: https://api.standardagents.ai)").option("--no-open", "Do not auto-open browser URL").action(login);
6248
6787
  program.command("logout").description("Clear stored Standard Agents auth and local org-scoped project auth").option("--org <org-id-or-slug>", "Org ID or slug to logout (defaults to active org)").option("--endpoint <url>", "Platform API endpoint (default: https://api.standardagents.ai)").action(logout);