@standardagents/cli 0.44.1 → 0.45.0
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/chat/package.json +1 -1
- package/dist/index.js +499 -379
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command, Option } from 'commander';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import path8 from 'path';
|
|
4
|
+
import fs5 from 'fs';
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
5
6
|
import crypto from 'crypto';
|
|
6
7
|
import os3 from 'os';
|
|
7
8
|
import net from 'net';
|
|
8
9
|
import readline from 'readline';
|
|
9
|
-
import { spawn, execFileSync, spawnSync } from 'child_process';
|
|
10
|
-
import {
|
|
11
|
-
import { FIRST_PARTY_PROVIDER_PACKAGES, AGENT_DEFINITIONS_AGENTS_MD, PROMPTS_AGENTS_MD, HANDLERS_AGENTS_MD, MODELS_AGENTS_MD, TOOLS_AGENTS_MD, HOOKS_AGENTS_MD, API_AGENTS_MD, renderAgentBuilderSupportFiles, ROOT_AGENTS_MD } from '@standardagents/agentbuilder-template';
|
|
10
|
+
import childProcess, { spawn, execFileSync, spawnSync } from 'child_process';
|
|
11
|
+
import { FIRST_PARTY_PROVIDER_PACKAGES, renderPnpmWorkspaceYaml, AGENT_DEFINITIONS_AGENTS_MD, PROMPTS_AGENTS_MD, HANDLERS_AGENTS_MD, MODELS_AGENTS_MD, TOOLS_AGENTS_MD, HOOKS_AGENTS_MD, API_AGENTS_MD, renderAgentBuilderSupportFiles, ROOT_AGENTS_MD } from '@standardagents/agentbuilder-template';
|
|
12
12
|
import chalk from 'chalk';
|
|
13
13
|
import { parse, modify, applyEdits } from 'jsonc-parser';
|
|
14
14
|
import { loadFile, writeFile } from 'magicast';
|
|
@@ -19,6 +19,77 @@ import { TextInput } from '@inkjs/ui';
|
|
|
19
19
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
20
20
|
import { copySkill, readSkillFile } from '@standardagents/skill';
|
|
21
21
|
|
|
22
|
+
function findPnpmWorkspaceRoot(startDir) {
|
|
23
|
+
let currentDir = startDir;
|
|
24
|
+
while (true) {
|
|
25
|
+
if (fs5.existsSync(path8.join(currentDir, "pnpm-workspace.yaml"))) {
|
|
26
|
+
return currentDir;
|
|
27
|
+
}
|
|
28
|
+
const parentDir = path8.dirname(currentDir);
|
|
29
|
+
if (parentDir === currentDir) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
currentDir = parentDir;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function findStandardAgentsWorkspaceRoot(startDir = path8.dirname(fileURLToPath(import.meta.url))) {
|
|
36
|
+
let currentDir = startDir;
|
|
37
|
+
for (; ; ) {
|
|
38
|
+
const workspaceRoot = findPnpmWorkspaceRoot(currentDir);
|
|
39
|
+
if (!workspaceRoot) return null;
|
|
40
|
+
const manifestPath = path8.join(workspaceRoot, "package.json");
|
|
41
|
+
try {
|
|
42
|
+
const manifest = JSON.parse(fs5.readFileSync(manifestPath, "utf8"));
|
|
43
|
+
if (manifest && typeof manifest === "object" && "name" in manifest && manifest.name === "standardagents") {
|
|
44
|
+
return workspaceRoot;
|
|
45
|
+
}
|
|
46
|
+
} catch {
|
|
47
|
+
}
|
|
48
|
+
const parent = path8.dirname(workspaceRoot);
|
|
49
|
+
if (parent === workspaceRoot) return null;
|
|
50
|
+
currentDir = parent;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function resolveStandardAgentsWorkspaceRoot(startDirs = [
|
|
54
|
+
path8.dirname(fileURLToPath(import.meta.url)),
|
|
55
|
+
process.cwd()
|
|
56
|
+
]) {
|
|
57
|
+
const explicitRoot = process.env.STANDARDAGENTS_WORKSPACE_ROOT?.trim();
|
|
58
|
+
if (explicitRoot) {
|
|
59
|
+
const workspaceRoot = findStandardAgentsWorkspaceRoot(path8.resolve(explicitRoot));
|
|
60
|
+
if (workspaceRoot) return workspaceRoot;
|
|
61
|
+
throw new Error(
|
|
62
|
+
`STANDARDAGENTS_WORKSPACE_ROOT=${path8.resolve(explicitRoot)} is not a Standard Agents workspace root`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
for (const startDir of startDirs) {
|
|
66
|
+
const workspaceRoot = findStandardAgentsWorkspaceRoot(startDir);
|
|
67
|
+
if (workspaceRoot) return workspaceRoot;
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
function workspacePackageDir(workspaceRoot, packageName) {
|
|
72
|
+
return path8.join(workspaceRoot, "packages", packageName.replace("@standardagents/", ""));
|
|
73
|
+
}
|
|
74
|
+
function validateWorkspacePackageDir(packageName, packageDir) {
|
|
75
|
+
const dependencyPackageJsonPath = path8.join(packageDir, "package.json");
|
|
76
|
+
if (!fs5.existsSync(dependencyPackageJsonPath)) {
|
|
77
|
+
throw new Error(`Could not find workspace package for ${packageName} at ${packageDir}`);
|
|
78
|
+
}
|
|
79
|
+
const manifest = JSON.parse(fs5.readFileSync(dependencyPackageJsonPath, "utf8"));
|
|
80
|
+
const name = manifest && typeof manifest === "object" && "name" in manifest ? manifest.name : void 0;
|
|
81
|
+
if (name !== packageName) {
|
|
82
|
+
throw new Error(`Expected ${packageDir} to contain ${packageName}, found ${String(name ?? "unknown package")}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function workspacePackageLink(packageName) {
|
|
86
|
+
const root = resolveStandardAgentsWorkspaceRoot();
|
|
87
|
+
if (!root) throw new Error("Workspace package linking requires a Standard Agents workspace root");
|
|
88
|
+
const packageDir = workspacePackageDir(root, packageName);
|
|
89
|
+
validateWorkspacePackageDir(packageName, packageDir);
|
|
90
|
+
return `link:${packageDir}`;
|
|
91
|
+
}
|
|
92
|
+
|
|
22
93
|
// src/utils/spawn-env.ts
|
|
23
94
|
function packageManagerEnv(base = process.env) {
|
|
24
95
|
const env = {};
|
|
@@ -49,25 +120,25 @@ var logger = {
|
|
|
49
120
|
}
|
|
50
121
|
};
|
|
51
122
|
function writePrivateFileSync(filePath, content) {
|
|
52
|
-
const descriptor =
|
|
123
|
+
const descriptor = fs5.openSync(filePath, "w", 384);
|
|
53
124
|
try {
|
|
54
|
-
|
|
55
|
-
|
|
125
|
+
fs5.fchmodSync(descriptor, 384);
|
|
126
|
+
fs5.writeFileSync(descriptor, content, "utf8");
|
|
56
127
|
} finally {
|
|
57
|
-
|
|
128
|
+
fs5.closeSync(descriptor);
|
|
58
129
|
}
|
|
59
130
|
}
|
|
60
131
|
|
|
61
132
|
// src/utils/bootstrap-state.ts
|
|
62
|
-
var STATE_RELATIVE_PATH =
|
|
133
|
+
var STATE_RELATIVE_PATH = path8.join(".agents", "bootstrap-session.json");
|
|
63
134
|
function getBootstrapStatePath(projectPath) {
|
|
64
|
-
return
|
|
135
|
+
return path8.join(projectPath, STATE_RELATIVE_PATH);
|
|
65
136
|
}
|
|
66
137
|
function loadBootstrapState(projectPath) {
|
|
67
138
|
const statePath = getBootstrapStatePath(projectPath);
|
|
68
|
-
if (!
|
|
139
|
+
if (!fs5.existsSync(statePath)) return null;
|
|
69
140
|
try {
|
|
70
|
-
const parsed = JSON.parse(
|
|
141
|
+
const parsed = JSON.parse(fs5.readFileSync(statePath, "utf-8"));
|
|
71
142
|
if (parsed.version !== 1) return null;
|
|
72
143
|
if (!parsed.endpoint || !parsed.user?.id || !parsed.account?.id) return null;
|
|
73
144
|
if (parsed.session_cookie !== void 0 && typeof parsed.session_cookie !== "string") return null;
|
|
@@ -78,13 +149,13 @@ function loadBootstrapState(projectPath) {
|
|
|
78
149
|
}
|
|
79
150
|
function persistBootstrapState(projectPath, state) {
|
|
80
151
|
const statePath = getBootstrapStatePath(projectPath);
|
|
81
|
-
|
|
152
|
+
fs5.mkdirSync(path8.dirname(statePath), { recursive: true });
|
|
82
153
|
writePrivateFileSync(statePath, JSON.stringify(state, null, 2) + "\n");
|
|
83
154
|
}
|
|
84
155
|
function clearBootstrapState(projectPath) {
|
|
85
156
|
const statePath = getBootstrapStatePath(projectPath);
|
|
86
|
-
if (
|
|
87
|
-
|
|
157
|
+
if (fs5.existsSync(statePath)) {
|
|
158
|
+
fs5.unlinkSync(statePath);
|
|
88
159
|
}
|
|
89
160
|
}
|
|
90
161
|
function getWebSocketCtor() {
|
|
@@ -263,15 +334,15 @@ function openBrowser(url) {
|
|
|
263
334
|
}
|
|
264
335
|
function getScaffoldStandardAgentsVersion() {
|
|
265
336
|
if (process.env.STANDARDAGENTS_WORKSPACE === "1") {
|
|
266
|
-
return "
|
|
337
|
+
return workspacePackageLink("@standardagents/builder");
|
|
267
338
|
}
|
|
268
|
-
return "0.
|
|
339
|
+
return "0.45.0";
|
|
269
340
|
}
|
|
270
341
|
function findViteConfig(cwd) {
|
|
271
342
|
const candidates = ["vite.config.ts", "vite.config.js", "vite.config.mts", "vite.config.mjs"];
|
|
272
343
|
for (const candidate of candidates) {
|
|
273
|
-
const configPath =
|
|
274
|
-
if (
|
|
344
|
+
const configPath = path8.join(cwd, candidate);
|
|
345
|
+
if (fs5.existsSync(configPath)) {
|
|
275
346
|
return configPath;
|
|
276
347
|
}
|
|
277
348
|
}
|
|
@@ -289,13 +360,13 @@ function setPackageDependency(packageJsonText, section, packageName, version) {
|
|
|
289
360
|
return applyEdits(packageJsonText, edits);
|
|
290
361
|
}
|
|
291
362
|
function updatePackageDependencies(cwd, versions = {}) {
|
|
292
|
-
const packageJsonPath =
|
|
293
|
-
if (!
|
|
363
|
+
const packageJsonPath = path8.join(cwd, "package.json");
|
|
364
|
+
if (!fs5.existsSync(packageJsonPath)) {
|
|
294
365
|
logger.warning("No package.json found. Install @standardagents/builder manually.");
|
|
295
366
|
return false;
|
|
296
367
|
}
|
|
297
368
|
try {
|
|
298
|
-
const text =
|
|
369
|
+
const text = fs5.readFileSync(packageJsonPath, "utf-8");
|
|
299
370
|
const pkg = JSON.parse(text);
|
|
300
371
|
const desiredBuilderVersion = versions.standardAgents ?? getScaffoldStandardAgentsVersion();
|
|
301
372
|
const builderSection = dependencySectionFor(pkg, "@standardagents/builder", "dependencies");
|
|
@@ -309,7 +380,7 @@ function updatePackageDependencies(cwd, versions = {}) {
|
|
|
309
380
|
logger.info("package.json already has current Standard Agents dependencies");
|
|
310
381
|
return true;
|
|
311
382
|
}
|
|
312
|
-
|
|
383
|
+
fs5.writeFileSync(packageJsonPath, `${result.trimEnd()}
|
|
313
384
|
`, "utf-8");
|
|
314
385
|
logger.success("Updated package.json with current Standard Agents dependencies");
|
|
315
386
|
return true;
|
|
@@ -321,7 +392,7 @@ function updatePackageDependencies(cwd, versions = {}) {
|
|
|
321
392
|
async function modifyViteConfig(configPath, force) {
|
|
322
393
|
try {
|
|
323
394
|
const mod = await loadFile(configPath);
|
|
324
|
-
const code =
|
|
395
|
+
const code = fs5.readFileSync(configPath, "utf-8");
|
|
325
396
|
const hasAgentBuilder = code.includes("@standardagents/builder") || code.includes("builder()") || code.includes("agentbuilder()");
|
|
326
397
|
if (hasAgentBuilder && !force) {
|
|
327
398
|
logger.info("Vite config already includes builder plugin");
|
|
@@ -351,14 +422,14 @@ async function modifyViteConfig(configPath, force) {
|
|
|
351
422
|
}
|
|
352
423
|
function createDirectoriesAndDocs(cwd) {
|
|
353
424
|
function writeAgentsDocWithClaudeSymlink(dirPath, doc, label) {
|
|
354
|
-
const agentsDocPath =
|
|
355
|
-
const claudeDocPath =
|
|
356
|
-
if (!
|
|
357
|
-
|
|
425
|
+
const agentsDocPath = path8.join(dirPath, "AGENTS.md");
|
|
426
|
+
const claudeDocPath = path8.join(dirPath, "CLAUDE.md");
|
|
427
|
+
if (!fs5.existsSync(agentsDocPath)) {
|
|
428
|
+
fs5.writeFileSync(agentsDocPath, doc, "utf-8");
|
|
358
429
|
logger.success(`Created ${label}/AGENTS.md`);
|
|
359
430
|
}
|
|
360
|
-
if (!
|
|
361
|
-
|
|
431
|
+
if (!fs5.existsSync(claudeDocPath)) {
|
|
432
|
+
fs5.symlinkSync("AGENTS.md", claudeDocPath);
|
|
362
433
|
logger.success(`Created ${label}/CLAUDE.md symlink`);
|
|
363
434
|
}
|
|
364
435
|
}
|
|
@@ -373,22 +444,22 @@ function createDirectoriesAndDocs(cwd) {
|
|
|
373
444
|
{ path: "agents/api", doc: API_AGENTS_MD }
|
|
374
445
|
];
|
|
375
446
|
for (const dir of directories) {
|
|
376
|
-
const dirPath =
|
|
377
|
-
if (!
|
|
378
|
-
|
|
447
|
+
const dirPath = path8.join(cwd, dir.path);
|
|
448
|
+
if (!fs5.existsSync(dirPath)) {
|
|
449
|
+
fs5.mkdirSync(dirPath, { recursive: true });
|
|
379
450
|
logger.success(`Created ${dir.path}`);
|
|
380
451
|
}
|
|
381
452
|
writeAgentsDocWithClaudeSymlink(dirPath, dir.doc, dir.path);
|
|
382
453
|
}
|
|
383
454
|
}
|
|
384
455
|
function updateTsConfig(cwd) {
|
|
385
|
-
const tsconfigPath =
|
|
386
|
-
if (!
|
|
456
|
+
const tsconfigPath = path8.join(cwd, "tsconfig.json");
|
|
457
|
+
if (!fs5.existsSync(tsconfigPath)) {
|
|
387
458
|
logger.info("No tsconfig.json found, skipping TypeScript configuration");
|
|
388
459
|
return;
|
|
389
460
|
}
|
|
390
461
|
try {
|
|
391
|
-
const text =
|
|
462
|
+
const text = fs5.readFileSync(tsconfigPath, "utf-8");
|
|
392
463
|
const config = parse(text);
|
|
393
464
|
let result = text;
|
|
394
465
|
const types = config.compilerOptions?.types || [];
|
|
@@ -409,12 +480,12 @@ function updateTsConfig(cwd) {
|
|
|
409
480
|
result = applyEdits(result, edits);
|
|
410
481
|
}
|
|
411
482
|
if (newTypes.length > 0 || newIncludes.length > 0) {
|
|
412
|
-
|
|
483
|
+
fs5.writeFileSync(tsconfigPath, result, "utf-8");
|
|
413
484
|
logger.success("Updated tsconfig.json with Standard Agents types");
|
|
414
485
|
} else {
|
|
415
486
|
logger.info("tsconfig.json already configured");
|
|
416
487
|
}
|
|
417
|
-
} catch
|
|
488
|
+
} catch {
|
|
418
489
|
logger.warning("Could not update tsconfig.json, you may need to add types manually");
|
|
419
490
|
}
|
|
420
491
|
}
|
|
@@ -435,21 +506,21 @@ function cleanupViteDefaults(cwd) {
|
|
|
435
506
|
];
|
|
436
507
|
const dirsToRemove = ["src", "public", "worker"];
|
|
437
508
|
for (const file of filesToRemove) {
|
|
438
|
-
const filePath =
|
|
439
|
-
if (
|
|
509
|
+
const filePath = path8.join(cwd, file);
|
|
510
|
+
if (fs5.existsSync(filePath)) {
|
|
440
511
|
try {
|
|
441
|
-
|
|
512
|
+
fs5.unlinkSync(filePath);
|
|
442
513
|
} catch {
|
|
443
514
|
}
|
|
444
515
|
}
|
|
445
516
|
}
|
|
446
517
|
for (const dir of dirsToRemove) {
|
|
447
|
-
const dirPath =
|
|
448
|
-
if (
|
|
518
|
+
const dirPath = path8.join(cwd, dir);
|
|
519
|
+
if (fs5.existsSync(dirPath)) {
|
|
449
520
|
try {
|
|
450
|
-
const files =
|
|
521
|
+
const files = fs5.readdirSync(dirPath);
|
|
451
522
|
if (files.length === 0) {
|
|
452
|
-
|
|
523
|
+
fs5.rmdirSync(dirPath);
|
|
453
524
|
}
|
|
454
525
|
} catch {
|
|
455
526
|
}
|
|
@@ -467,7 +538,7 @@ async function scaffold(options = {}) {
|
|
|
467
538
|
} else {
|
|
468
539
|
logger.warning("No vite.config found. Please create one with the agentbuilder plugin.");
|
|
469
540
|
}
|
|
470
|
-
updatePackageDependencies(cwd);
|
|
541
|
+
updatePackageDependencies(cwd, { standardAgents: options.standardAgents });
|
|
471
542
|
createDirectoriesAndDocs(cwd);
|
|
472
543
|
updateTsConfig(cwd);
|
|
473
544
|
if (force) {
|
|
@@ -562,19 +633,19 @@ function InitStepFrame(props) {
|
|
|
562
633
|
items.push({
|
|
563
634
|
id: "mode",
|
|
564
635
|
label: "Mode",
|
|
565
|
-
value: props.authMode === "standardagents" ? "
|
|
636
|
+
value: props.authMode === "standardagents" ? "Standard Agents" : "Local"
|
|
566
637
|
});
|
|
567
638
|
}
|
|
568
639
|
return items;
|
|
569
640
|
}, [props.authMode, props.packageManager, props.projectName]);
|
|
570
641
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", paddingX: 1, children: [
|
|
571
642
|
/* @__PURE__ */ jsxs(Box, { borderStyle: "round", borderColor: "cyan", paddingX: 1, flexDirection: "column", children: [
|
|
572
|
-
/* @__PURE__ */ jsx(Text, { color: "cyanBright", bold: true, children: "
|
|
643
|
+
/* @__PURE__ */ jsx(Text, { color: "cyanBright", bold: true, children: "Standard Agents CLI" }),
|
|
573
644
|
/* @__PURE__ */ jsx(Text, { color: "gray", children: "Init Wizard" })
|
|
574
645
|
] }),
|
|
575
646
|
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Stepper, { activeStage: props.stage, authMode: mode }) }),
|
|
576
647
|
metadata.length > 0 && /* @__PURE__ */ jsx(Box, { marginBottom: 1, flexDirection: "row", children: metadata.map((item, index) => {
|
|
577
|
-
const valueColor = item.id === "project" ? "whiteBright" : item.id === "pm" ? "magentaBright" : item.value === "
|
|
648
|
+
const valueColor = item.id === "project" ? "whiteBright" : item.id === "pm" ? "magentaBright" : item.value === "Standard Agents" ? "greenBright" : "yellowBright";
|
|
578
649
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
|
|
579
650
|
/* @__PURE__ */ jsxs(Text, { color: "gray", children: [
|
|
580
651
|
item.label,
|
|
@@ -930,7 +1001,7 @@ function AuthModePrompt({ projectName, packageManager, onCancel, onSubmit }) {
|
|
|
930
1001
|
const options = [
|
|
931
1002
|
{
|
|
932
1003
|
value: "standardagents",
|
|
933
|
-
label: "
|
|
1004
|
+
label: "Standard Agents",
|
|
934
1005
|
bullets: ["Free account", "$2 starting credit", "Zero-config setup", "Production deployments"]
|
|
935
1006
|
},
|
|
936
1007
|
{
|
|
@@ -1274,9 +1345,9 @@ async function findAvailablePort(startPort) {
|
|
|
1274
1345
|
}
|
|
1275
1346
|
throw new Error(`No available local dev port found near ${startPort}`);
|
|
1276
1347
|
}
|
|
1277
|
-
function buildDevServerCommand(packageManager, port) {
|
|
1348
|
+
function buildDevServerCommand(packageManager, port, pnpmCompatibilityArgs = []) {
|
|
1278
1349
|
const viteArgs = ["--host", "127.0.0.1", "--port", String(port), "--strictPort"];
|
|
1279
|
-
return packageManager === "npm" ? ["run", "dev", "--", ...viteArgs] : ["dev", ...viteArgs];
|
|
1350
|
+
return packageManager === "npm" ? ["run", "dev", "--", ...viteArgs] : [...packageManager === "pnpm" ? pnpmCompatibilityArgs : [], "dev", ...viteArgs];
|
|
1280
1351
|
}
|
|
1281
1352
|
async function waitForLocalDevServer(url, timeoutMs = 6e4) {
|
|
1282
1353
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -1300,33 +1371,37 @@ function normalizeProjectName(raw) {
|
|
|
1300
1371
|
return toKebabCase(raw.trim());
|
|
1301
1372
|
}
|
|
1302
1373
|
function isNonEmptyDirectory(targetPath) {
|
|
1303
|
-
if (!
|
|
1304
|
-
const stat =
|
|
1374
|
+
if (!fs5.existsSync(targetPath)) return false;
|
|
1375
|
+
const stat = fs5.statSync(targetPath);
|
|
1305
1376
|
if (!stat.isDirectory()) return false;
|
|
1306
|
-
return
|
|
1377
|
+
return fs5.readdirSync(targetPath).length > 0;
|
|
1307
1378
|
}
|
|
1308
1379
|
function hasBuilderDependency(targetPath) {
|
|
1309
|
-
const packageJsonPath =
|
|
1310
|
-
if (!
|
|
1380
|
+
const packageJsonPath = path8.join(targetPath, "package.json");
|
|
1381
|
+
if (!fs5.existsSync(packageJsonPath)) return false;
|
|
1311
1382
|
try {
|
|
1312
|
-
const pkg = JSON.parse(
|
|
1313
|
-
|
|
1314
|
-
|
|
1383
|
+
const pkg = JSON.parse(fs5.readFileSync(packageJsonPath, "utf-8"));
|
|
1384
|
+
if (pkg === null || typeof pkg !== "object") return false;
|
|
1385
|
+
const dependencies = "dependencies" in pkg ? pkg.dependencies : void 0;
|
|
1386
|
+
const devDependencies = "devDependencies" in pkg ? pkg.devDependencies : void 0;
|
|
1387
|
+
return [dependencies, devDependencies].some(
|
|
1388
|
+
(deps) => deps !== null && typeof deps === "object" && Object.prototype.hasOwnProperty.call(deps, "@standardagents/builder")
|
|
1389
|
+
);
|
|
1315
1390
|
} catch {
|
|
1316
1391
|
return false;
|
|
1317
1392
|
}
|
|
1318
1393
|
}
|
|
1319
1394
|
function isStandardAgentsProjectDir(targetPath) {
|
|
1320
|
-
const agentsDir =
|
|
1321
|
-
if (!
|
|
1395
|
+
const agentsDir = path8.join(targetPath, "agents");
|
|
1396
|
+
if (!fs5.existsSync(agentsDir) || !fs5.statSync(agentsDir).isDirectory()) {
|
|
1322
1397
|
return false;
|
|
1323
1398
|
}
|
|
1324
1399
|
if (hasBuilderDependency(targetPath)) return true;
|
|
1325
|
-
return
|
|
1400
|
+
return fs5.existsSync(path8.join(targetPath, "vite.config.ts")) && fs5.existsSync(path8.join(targetPath, "tsconfig.json"));
|
|
1326
1401
|
}
|
|
1327
1402
|
async function resolveProjectTarget(cwd, initialProjectName, options, promptProjectName = prompt) {
|
|
1328
1403
|
if (!initialProjectName && isStandardAgentsProjectDir(cwd)) {
|
|
1329
|
-
const dirName =
|
|
1404
|
+
const dirName = path8.basename(cwd) || "standard-agents";
|
|
1330
1405
|
const projectName = normalizeProjectName(dirName) || dirName;
|
|
1331
1406
|
const existingBootstrapState = loadBootstrapState(cwd);
|
|
1332
1407
|
return {
|
|
@@ -1360,9 +1435,9 @@ async function resolveProjectTarget(cwd, initialProjectName, options, promptProj
|
|
|
1360
1435
|
if (projectName !== candidate) {
|
|
1361
1436
|
logger.info(`Using project directory "${projectName}"`);
|
|
1362
1437
|
}
|
|
1363
|
-
const projectPath =
|
|
1364
|
-
const exists =
|
|
1365
|
-
if (exists && !
|
|
1438
|
+
const projectPath = path8.join(cwd, projectName);
|
|
1439
|
+
const exists = fs5.existsSync(projectPath);
|
|
1440
|
+
if (exists && !fs5.statSync(projectPath).isDirectory()) {
|
|
1366
1441
|
if (options.yes) {
|
|
1367
1442
|
throw new Error(`Path "${projectName}" already exists and is not a directory`);
|
|
1368
1443
|
}
|
|
@@ -1397,10 +1472,10 @@ function detectPackageManager() {
|
|
|
1397
1472
|
if (userAgent.includes("yarn")) return "yarn";
|
|
1398
1473
|
if (userAgent.includes("bun")) return "bun";
|
|
1399
1474
|
}
|
|
1400
|
-
if (
|
|
1401
|
-
if (
|
|
1402
|
-
if (
|
|
1403
|
-
if (
|
|
1475
|
+
if (fs5.existsSync("pnpm-lock.yaml")) return "pnpm";
|
|
1476
|
+
if (fs5.existsSync("yarn.lock")) return "yarn";
|
|
1477
|
+
if (fs5.existsSync("bun.lockb")) return "bun";
|
|
1478
|
+
if (fs5.existsSync("package-lock.json")) return "npm";
|
|
1404
1479
|
return "npm";
|
|
1405
1480
|
}
|
|
1406
1481
|
function resolvePackageManager(requested, detected) {
|
|
@@ -1478,7 +1553,7 @@ function renderInitStepHeader(stage, title, subtitle, options = {}) {
|
|
|
1478
1553
|
}
|
|
1479
1554
|
async function selectInitAuthMode(context = {}) {
|
|
1480
1555
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
1481
|
-
const answer = (await prompt("Setup mode: [S]
|
|
1556
|
+
const answer = (await prompt("Setup mode: [S]tandard Agents or [L]ocal? (default: Standard Agents): ")).toLowerCase();
|
|
1482
1557
|
if (answer === "l" || answer === "local") return "local";
|
|
1483
1558
|
return "standardagents";
|
|
1484
1559
|
}
|
|
@@ -1518,7 +1593,7 @@ async function ensurePlatformAuth(options, quietLogs = false, context = {}) {
|
|
|
1518
1593
|
let authAppUrl = resolvePlatformAuthBrowserUrl(endpoint);
|
|
1519
1594
|
let sessionId = null;
|
|
1520
1595
|
logLine("");
|
|
1521
|
-
logInfo("Starting
|
|
1596
|
+
logInfo("Starting Standard Agents account setup...");
|
|
1522
1597
|
logLine(`Platform API: ${endpoint}`);
|
|
1523
1598
|
try {
|
|
1524
1599
|
const started = await startCliAuthSession(endpoint);
|
|
@@ -1567,7 +1642,7 @@ async function ensurePlatformAuth(options, quietLogs = false, context = {}) {
|
|
|
1567
1642
|
return { connected: true, mode: "standardagents" };
|
|
1568
1643
|
}
|
|
1569
1644
|
function getCliVersion() {
|
|
1570
|
-
return "0.
|
|
1645
|
+
return "0.45.0";
|
|
1571
1646
|
}
|
|
1572
1647
|
function getSipVersion() {
|
|
1573
1648
|
return "1.0.1";
|
|
@@ -1590,69 +1665,14 @@ function resolveStandardAgentsPackageSpecifier(packageName, packageSpecifier) {
|
|
|
1590
1665
|
if (packageName === "@standardagents/sip") {
|
|
1591
1666
|
return getSipVersion();
|
|
1592
1667
|
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
function findWorkspaceRoot(startDir) {
|
|
1596
|
-
let currentDir = startDir;
|
|
1597
|
-
while (true) {
|
|
1598
|
-
if (fs4.existsSync(path7.join(currentDir, "pnpm-workspace.yaml"))) {
|
|
1599
|
-
return currentDir;
|
|
1600
|
-
}
|
|
1601
|
-
const parentDir = path7.dirname(currentDir);
|
|
1602
|
-
if (parentDir === currentDir) {
|
|
1603
|
-
return null;
|
|
1604
|
-
}
|
|
1605
|
-
currentDir = parentDir;
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
function findStandardAgentsWorkspaceRoot(startDir = path7.dirname(fileURLToPath(import.meta.url))) {
|
|
1609
|
-
const workspaceRoot = findWorkspaceRoot(startDir);
|
|
1610
|
-
if (!workspaceRoot) return null;
|
|
1611
|
-
const rootPackageJsonPath = path7.join(workspaceRoot, "package.json");
|
|
1612
|
-
if (!fs4.existsSync(rootPackageJsonPath)) return null;
|
|
1613
|
-
try {
|
|
1614
|
-
const rootPackageJson = JSON.parse(fs4.readFileSync(rootPackageJsonPath, "utf-8"));
|
|
1615
|
-
return rootPackageJson.name === "standardagents" ? workspaceRoot : null;
|
|
1616
|
-
} catch {
|
|
1617
|
-
return null;
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
function resolveStandardAgentsWorkspaceRoot(startDirs = [
|
|
1621
|
-
path7.dirname(fileURLToPath(import.meta.url)),
|
|
1622
|
-
process.cwd()
|
|
1623
|
-
]) {
|
|
1624
|
-
const explicitRoot = process.env.STANDARDAGENTS_WORKSPACE_ROOT?.trim();
|
|
1625
|
-
if (explicitRoot) {
|
|
1626
|
-
const workspaceRoot = findStandardAgentsWorkspaceRoot(path7.resolve(explicitRoot));
|
|
1627
|
-
if (workspaceRoot) return workspaceRoot;
|
|
1628
|
-
throw new Error(
|
|
1629
|
-
`STANDARDAGENTS_WORKSPACE_ROOT=${path7.resolve(explicitRoot)} is not a Standard Agents workspace root`
|
|
1630
|
-
);
|
|
1631
|
-
}
|
|
1632
|
-
for (const startDir of startDirs) {
|
|
1633
|
-
const workspaceRoot = findStandardAgentsWorkspaceRoot(startDir);
|
|
1634
|
-
if (workspaceRoot) return workspaceRoot;
|
|
1635
|
-
}
|
|
1636
|
-
return null;
|
|
1637
|
-
}
|
|
1638
|
-
function workspacePackageDir(workspaceRoot, packageName) {
|
|
1639
|
-
return path7.join(workspaceRoot, "packages", packageName.replace("@standardagents/", ""));
|
|
1640
|
-
}
|
|
1641
|
-
function validateWorkspacePackageDir(packageName, packageDir) {
|
|
1642
|
-
const dependencyPackageJsonPath = path7.join(packageDir, "package.json");
|
|
1643
|
-
if (!fs4.existsSync(dependencyPackageJsonPath)) {
|
|
1644
|
-
throw new Error(`Could not find workspace package for ${packageName} at ${packageDir}`);
|
|
1645
|
-
}
|
|
1646
|
-
const dependencyPackageJson = JSON.parse(fs4.readFileSync(dependencyPackageJsonPath, "utf-8"));
|
|
1647
|
-
if (dependencyPackageJson.name !== packageName) {
|
|
1648
|
-
throw new Error(
|
|
1649
|
-
`Expected ${packageDir} to contain ${packageName}, found ${dependencyPackageJson.name ?? "unknown package"}`
|
|
1650
|
-
);
|
|
1668
|
+
if (packageSpecifier === "workspace:*") {
|
|
1669
|
+
return workspacePackageLink(packageName);
|
|
1651
1670
|
}
|
|
1671
|
+
return packageSpecifier;
|
|
1652
1672
|
}
|
|
1653
1673
|
function rewriteStandardAgentsDependenciesForWorkspace(projectPath, workspaceRoot) {
|
|
1654
|
-
const packageJsonPath =
|
|
1655
|
-
const packageJson = JSON.parse(
|
|
1674
|
+
const packageJsonPath = path8.join(projectPath, "package.json");
|
|
1675
|
+
const packageJson = JSON.parse(fs5.readFileSync(packageJsonPath, "utf-8"));
|
|
1656
1676
|
const dependencies = packageJson.dependencies ?? {};
|
|
1657
1677
|
const linkedPackages = [];
|
|
1658
1678
|
for (const packageName of GENERATED_STANDARD_AGENTS_PACKAGES) {
|
|
@@ -1664,79 +1684,128 @@ function rewriteStandardAgentsDependenciesForWorkspace(projectPath, workspaceRoo
|
|
|
1664
1684
|
}
|
|
1665
1685
|
if (linkedPackages.length > 0) {
|
|
1666
1686
|
packageJson.dependencies = dependencies;
|
|
1667
|
-
|
|
1687
|
+
fs5.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
|
|
1668
1688
|
`, "utf-8");
|
|
1669
1689
|
}
|
|
1670
1690
|
return linkedPackages;
|
|
1671
1691
|
}
|
|
1672
|
-
function preparePlatformProjectDependencies(projectPath, packageManager) {
|
|
1673
|
-
if (
|
|
1692
|
+
function preparePlatformProjectDependencies(projectPath, packageManager, options = {}) {
|
|
1693
|
+
if (!shouldUseWorkspacePackages(options)) {
|
|
1674
1694
|
return [];
|
|
1675
1695
|
}
|
|
1676
1696
|
if (packageManager !== "pnpm") {
|
|
1677
|
-
throw new Error("
|
|
1697
|
+
throw new Error("Workspace package linking requires pnpm");
|
|
1678
1698
|
}
|
|
1679
1699
|
const workspaceRoot = resolveStandardAgentsWorkspaceRoot();
|
|
1680
1700
|
if (!workspaceRoot) {
|
|
1681
|
-
throw new Error("
|
|
1701
|
+
throw new Error("Workspace mode requires a Standard Agents workspace root");
|
|
1702
|
+
}
|
|
1703
|
+
const linkedPackages = rewriteStandardAgentsDependenciesForWorkspace(projectPath, workspaceRoot);
|
|
1704
|
+
linkWorkspaceProjectToolchain(projectPath, workspaceRoot);
|
|
1705
|
+
return linkedPackages;
|
|
1706
|
+
}
|
|
1707
|
+
function getPnpmWorkspaceCompatibilityArgs(packageManager, projectPath) {
|
|
1708
|
+
if (packageManager !== "pnpm" || !fs5.existsSync(path8.join(projectPath, "pnpm-workspace.yaml"))) return [];
|
|
1709
|
+
try {
|
|
1710
|
+
childProcess.execFileSync("pnpm", ["config", "get", "registry"], {
|
|
1711
|
+
cwd: projectPath,
|
|
1712
|
+
encoding: "utf8",
|
|
1713
|
+
env: packageManagerEnv(),
|
|
1714
|
+
stdio: "pipe",
|
|
1715
|
+
timeout: 3e4
|
|
1716
|
+
});
|
|
1717
|
+
return [];
|
|
1718
|
+
} catch (error) {
|
|
1719
|
+
if (error instanceof Error && error.message.includes("packages field missing or empty")) {
|
|
1720
|
+
return ["--ignore-workspace"];
|
|
1721
|
+
}
|
|
1722
|
+
throw error;
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
function projectInstallArgs(packageManager, projectPath, command = "install", dependencies = [], options = {}) {
|
|
1726
|
+
const hasProjectWorkspace = projectPath !== void 0 && fs5.existsSync(path8.join(projectPath, "pnpm-workspace.yaml"));
|
|
1727
|
+
const inheritsWorkspace = !options.isolateFromParent && projectPath !== void 0 && findPnpmWorkspaceRoot(path8.dirname(projectPath)) !== null;
|
|
1728
|
+
const prefix = [];
|
|
1729
|
+
if (packageManager === "pnpm") {
|
|
1730
|
+
if (options.ignoreProjectWorkspace) prefix.push("--ignore-workspace");
|
|
1731
|
+
else if (hasProjectWorkspace && command === "add") prefix.push("--workspace-root");
|
|
1732
|
+
else if (!hasProjectWorkspace && !inheritsWorkspace) prefix.push("--ignore-workspace");
|
|
1682
1733
|
}
|
|
1683
|
-
return
|
|
1734
|
+
return [...prefix, command, ...dependencies];
|
|
1684
1735
|
}
|
|
1685
1736
|
function shellQuote(value) {
|
|
1686
1737
|
return `"${value.replace(/(["\\$`])/g, "\\$1")}"`;
|
|
1687
1738
|
}
|
|
1688
1739
|
function findWorkspaceCommandRoot(projectPath) {
|
|
1689
|
-
let current =
|
|
1740
|
+
let current = path8.dirname(projectPath);
|
|
1690
1741
|
while (true) {
|
|
1691
|
-
const packageJsonPath =
|
|
1692
|
-
if (
|
|
1742
|
+
const packageJsonPath = path8.join(current, "package.json");
|
|
1743
|
+
if (fs5.existsSync(packageJsonPath)) {
|
|
1693
1744
|
try {
|
|
1694
|
-
const packageJson = JSON.parse(
|
|
1745
|
+
const packageJson = JSON.parse(fs5.readFileSync(packageJsonPath, "utf-8"));
|
|
1695
1746
|
if (packageJson?.scripts && typeof packageJson.scripts["sandbox:hmr"] === "string") {
|
|
1696
1747
|
return current;
|
|
1697
1748
|
}
|
|
1698
1749
|
} catch {
|
|
1699
1750
|
}
|
|
1700
1751
|
}
|
|
1701
|
-
const parent =
|
|
1752
|
+
const parent = path8.dirname(current);
|
|
1702
1753
|
if (parent === current) {
|
|
1703
1754
|
return null;
|
|
1704
1755
|
}
|
|
1705
1756
|
current = parent;
|
|
1706
1757
|
}
|
|
1707
1758
|
}
|
|
1759
|
+
function linkWorkspaceProjectToolchain(projectPath, workspaceRoot) {
|
|
1760
|
+
const packageJsonPath = path8.join(projectPath, "package.json");
|
|
1761
|
+
const manifest = JSON.parse(fs5.readFileSync(packageJsonPath, "utf8"));
|
|
1762
|
+
for (const section of [manifest.dependencies, manifest.devDependencies]) {
|
|
1763
|
+
if (!section) continue;
|
|
1764
|
+
for (const name of ["vite", "typescript"]) {
|
|
1765
|
+
if (!(name in section)) continue;
|
|
1766
|
+
const installedPath = path8.join(workspaceRoot, "node_modules", name);
|
|
1767
|
+
if (!fs5.existsSync(path8.join(installedPath, "package.json"))) {
|
|
1768
|
+
throw new Error(`Install the contributor workspace before linking ${name}`);
|
|
1769
|
+
}
|
|
1770
|
+
section[name] = `link:${installedPath}`;
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
fs5.writeFileSync(packageJsonPath, `${JSON.stringify(manifest, null, 2)}
|
|
1774
|
+
`);
|
|
1775
|
+
}
|
|
1708
1776
|
function configureWorkspaceProjectScripts(projectPath, projectName) {
|
|
1709
|
-
const packageJsonPath =
|
|
1710
|
-
if (!
|
|
1777
|
+
const packageJsonPath = path8.join(projectPath, "package.json");
|
|
1778
|
+
if (!fs5.existsSync(packageJsonPath)) return false;
|
|
1711
1779
|
const workspaceRoot = findWorkspaceCommandRoot(projectPath);
|
|
1712
1780
|
if (!workspaceRoot) return false;
|
|
1713
|
-
const workspacePackageJsonPath =
|
|
1714
|
-
const workspacePackageJson = JSON.parse(
|
|
1715
|
-
const packageJson = JSON.parse(
|
|
1781
|
+
const workspacePackageJsonPath = path8.join(workspaceRoot, "package.json");
|
|
1782
|
+
const workspacePackageJson = JSON.parse(fs5.readFileSync(workspacePackageJsonPath, "utf-8"));
|
|
1783
|
+
const packageJson = JSON.parse(fs5.readFileSync(packageJsonPath, "utf-8"));
|
|
1716
1784
|
const scripts = packageJson.scripts && typeof packageJson.scripts === "object" ? packageJson.scripts : {};
|
|
1717
|
-
const relativeRoot =
|
|
1785
|
+
const relativeRoot = path8.relative(projectPath, workspaceRoot) || ".";
|
|
1718
1786
|
scripts["sandbox:hmr"] = `pnpm -C ${shellQuote(relativeRoot)} sandbox:hmr -- ${shellQuote(projectName)}`;
|
|
1719
1787
|
if (workspacePackageJson?.scripts && typeof workspacePackageJson.scripts["cli:login:workspace"] === "string") {
|
|
1720
1788
|
scripts["cli:login:workspace"] = `pnpm -C ${shellQuote(relativeRoot)} cli:login:workspace -- ${shellQuote(projectName)}`;
|
|
1721
1789
|
}
|
|
1722
1790
|
packageJson.scripts = scripts;
|
|
1723
|
-
|
|
1791
|
+
fs5.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n", "utf-8");
|
|
1724
1792
|
return true;
|
|
1725
1793
|
}
|
|
1726
|
-
function resolvePostInitRunCommand(packageManager, projectPath, workspacePackages) {
|
|
1794
|
+
function resolvePostInitRunCommand(packageManager, projectPath, workspacePackages, pnpmCompatibilityArgs = []) {
|
|
1795
|
+
const command = packageManager === "pnpm" ? [packageManager, ...pnpmCompatibilityArgs].join(" ") : packageManager;
|
|
1727
1796
|
if (workspacePackages) {
|
|
1728
|
-
const packageJsonPath =
|
|
1729
|
-
if (
|
|
1797
|
+
const packageJsonPath = path8.join(projectPath, "package.json");
|
|
1798
|
+
if (fs5.existsSync(packageJsonPath)) {
|
|
1730
1799
|
try {
|
|
1731
|
-
const packageJson = JSON.parse(
|
|
1800
|
+
const packageJson = JSON.parse(fs5.readFileSync(packageJsonPath, "utf-8"));
|
|
1732
1801
|
if (packageJson?.scripts && typeof packageJson.scripts["sandbox:hmr"] === "string") {
|
|
1733
|
-
return packageManager === "npm" ? "npm run sandbox:hmr" : `${
|
|
1802
|
+
return packageManager === "npm" ? "npm run sandbox:hmr" : `${command} sandbox:hmr`;
|
|
1734
1803
|
}
|
|
1735
1804
|
} catch {
|
|
1736
1805
|
}
|
|
1737
1806
|
}
|
|
1738
1807
|
}
|
|
1739
|
-
return packageManager === "npm" ? "npm run dev" : `${
|
|
1808
|
+
return packageManager === "npm" ? "npm run dev" : `${command} dev`;
|
|
1740
1809
|
}
|
|
1741
1810
|
async function selectPackageManager(detected, context = {}) {
|
|
1742
1811
|
if (!process.stdin.isTTY || !process.stdout.isTTY) return detected;
|
|
@@ -1910,8 +1979,8 @@ function gitCloneArgs(project, projectName) {
|
|
|
1910
1979
|
return args;
|
|
1911
1980
|
}
|
|
1912
1981
|
function platformGitCredentialHelperCommand(cliEntry = process.argv[1] ?? "") {
|
|
1913
|
-
if (process.env.STANDARDAGENTS_WORKSPACE === "1" && cliEntry &&
|
|
1914
|
-
return `!node ${shellQuote(
|
|
1982
|
+
if (process.env.STANDARDAGENTS_WORKSPACE === "1" && cliEntry && fs5.existsSync(cliEntry)) {
|
|
1983
|
+
return `!node ${shellQuote(path8.resolve(cliEntry))} git-credential`;
|
|
1915
1984
|
}
|
|
1916
1985
|
if (process.env.STANDARD_AGENTS_GIT_HELPER?.trim()) {
|
|
1917
1986
|
return process.env.STANDARD_AGENTS_GIT_HELPER.trim();
|
|
@@ -2069,16 +2138,56 @@ function hasEnvLine(lines, key) {
|
|
|
2069
2138
|
return lines.some((line) => line.startsWith(`${key}=`));
|
|
2070
2139
|
}
|
|
2071
2140
|
function appendGitignoreEntries(projectPath, heading, entries) {
|
|
2072
|
-
const gitignorePath =
|
|
2073
|
-
const gitignoreContent =
|
|
2141
|
+
const gitignorePath = path8.join(projectPath, ".gitignore");
|
|
2142
|
+
const gitignoreContent = fs5.existsSync(gitignorePath) ? fs5.readFileSync(gitignorePath, "utf-8") : "";
|
|
2074
2143
|
const existingEntries = new Set(gitignoreContent.split(/\r?\n/));
|
|
2075
2144
|
const missingEntries = entries.filter((entry) => !existingEntries.has(entry));
|
|
2076
2145
|
if (missingEntries.length === 0) return;
|
|
2077
2146
|
const prefix = gitignoreContent.length === 0 ? "" : gitignoreContent.endsWith("\n") ? "\n" : "\n\n";
|
|
2078
|
-
|
|
2147
|
+
fs5.appendFileSync(gitignorePath, `${prefix}${heading}
|
|
2079
2148
|
${missingEntries.join("\n")}
|
|
2080
2149
|
`);
|
|
2081
2150
|
}
|
|
2151
|
+
function writeLocalPnpmBuildPolicy(projectPath, packageManager, options = {}) {
|
|
2152
|
+
if (packageManager !== "pnpm") return false;
|
|
2153
|
+
const policyPath = path8.join(projectPath, "pnpm-workspace.yaml");
|
|
2154
|
+
if (fs5.existsSync(policyPath)) return false;
|
|
2155
|
+
const buildPolicySettings = [
|
|
2156
|
+
"onlyBuiltDependencies",
|
|
2157
|
+
"onlyBuiltDependenciesFile",
|
|
2158
|
+
"neverBuiltDependencies",
|
|
2159
|
+
"ignoredBuiltDependencies",
|
|
2160
|
+
"allowBuilds",
|
|
2161
|
+
"dangerouslyAllowAllBuilds",
|
|
2162
|
+
"ignoreDepScripts",
|
|
2163
|
+
"ignoreScripts"
|
|
2164
|
+
];
|
|
2165
|
+
const npmrcPath = path8.join(projectPath, ".npmrc");
|
|
2166
|
+
if (fs5.existsSync(npmrcPath)) {
|
|
2167
|
+
const hasBuildPolicy = fs5.readFileSync(npmrcPath, "utf8").split(/\r?\n/).some((line) => {
|
|
2168
|
+
const separator = line.indexOf("=");
|
|
2169
|
+
const name = (separator < 0 ? line : line.slice(0, separator)).trim().replace(/[-_[\]]/g, "").toLowerCase();
|
|
2170
|
+
return buildPolicySettings.some((setting) => setting.toLowerCase() === name);
|
|
2171
|
+
});
|
|
2172
|
+
if (hasBuildPolicy) return false;
|
|
2173
|
+
}
|
|
2174
|
+
if (!options.isolateFromParent && findPnpmWorkspaceRoot(path8.dirname(projectPath))) return false;
|
|
2175
|
+
const ignoredBuildScripts = options.ignoredBuildScripts ?? [];
|
|
2176
|
+
const approvedBuildScripts = ["esbuild", "workerd"].filter((name) => !ignoredBuildScripts.includes(name));
|
|
2177
|
+
const manifestPath = path8.join(projectPath, "package.json");
|
|
2178
|
+
const manifest = JSON.parse(fs5.readFileSync(manifestPath, "utf8"));
|
|
2179
|
+
const existingPnpm = manifest.pnpm ?? {};
|
|
2180
|
+
if (buildPolicySettings.some((name) => Object.hasOwn(existingPnpm, name))) return false;
|
|
2181
|
+
manifest.pnpm = {
|
|
2182
|
+
...existingPnpm,
|
|
2183
|
+
onlyBuiltDependencies: approvedBuildScripts,
|
|
2184
|
+
...ignoredBuildScripts.length > 0 ? { ignoredBuiltDependencies: ignoredBuildScripts } : {}
|
|
2185
|
+
};
|
|
2186
|
+
fs5.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
2187
|
+
`);
|
|
2188
|
+
fs5.writeFileSync(policyPath, renderPnpmWorkspaceYaml(approvedBuildScripts, ignoredBuildScripts));
|
|
2189
|
+
return true;
|
|
2190
|
+
}
|
|
2082
2191
|
function writeStandardAgentsSupportFiles(projectPath, params) {
|
|
2083
2192
|
const written = [];
|
|
2084
2193
|
for (const supportFile of renderAgentBuilderSupportFiles({
|
|
@@ -2089,10 +2198,10 @@ function writeStandardAgentsSupportFiles(projectPath, params) {
|
|
|
2089
2198
|
sip: getSipVersion()
|
|
2090
2199
|
}
|
|
2091
2200
|
})) {
|
|
2092
|
-
const targetPath =
|
|
2093
|
-
if (
|
|
2094
|
-
|
|
2095
|
-
|
|
2201
|
+
const targetPath = path8.join(projectPath, supportFile.path);
|
|
2202
|
+
if (fs5.existsSync(targetPath)) continue;
|
|
2203
|
+
fs5.mkdirSync(path8.dirname(targetPath), { recursive: true });
|
|
2204
|
+
fs5.writeFileSync(targetPath, supportFile.content, "utf-8");
|
|
2096
2205
|
written.push(supportFile.path);
|
|
2097
2206
|
}
|
|
2098
2207
|
appendGitignoreEntries(projectPath, "# Standard Agents local dev state", [
|
|
@@ -2113,7 +2222,7 @@ function supportFiles(options = {}) {
|
|
|
2113
2222
|
process.exit(1);
|
|
2114
2223
|
}
|
|
2115
2224
|
const cwd = process.cwd();
|
|
2116
|
-
const projectName = normalizeProjectName(options.projectName ??
|
|
2225
|
+
const projectName = normalizeProjectName(options.projectName ?? path8.basename(cwd)) || "standard-agents";
|
|
2117
2226
|
const written = writeStandardAgentsSupportFiles(cwd, {
|
|
2118
2227
|
projectName,
|
|
2119
2228
|
packageManager
|
|
@@ -2125,8 +2234,8 @@ function supportFiles(options = {}) {
|
|
|
2125
2234
|
logger.success(`Wrote Standard Agents local support files: ${written.join(", ")}`);
|
|
2126
2235
|
}
|
|
2127
2236
|
function writeStandardAgentsEnv(projectPath, params) {
|
|
2128
|
-
const envPath =
|
|
2129
|
-
const existing =
|
|
2237
|
+
const envPath = path8.join(projectPath, ".dev.vars");
|
|
2238
|
+
const existing = fs5.existsSync(envPath) ? fs5.readFileSync(envPath, "utf-8") : "";
|
|
2130
2239
|
let lines = existing.split(/\r?\n/).filter(
|
|
2131
2240
|
(line) => line.trim().length > 0 && !line.startsWith("STANDARD_AGENTS_API_KEY=") && !line.startsWith("PLATFORM_ENDPOINT=") && !line.startsWith("STANDARD_AGENTS_API_URL=")
|
|
2132
2241
|
);
|
|
@@ -2151,7 +2260,7 @@ function writeStandardAgentsEnv(projectPath, params) {
|
|
|
2151
2260
|
lines = upsertEnvLine(lines, "STANDARD_AGENTS_API_KEY", params.apiKey);
|
|
2152
2261
|
lines = upsertEnvLine(lines, "PLATFORM_ENDPOINT", params.platformEndpoint);
|
|
2153
2262
|
lines = upsertEnvLine(lines, "STANDARD_AGENTS_API_URL", params.platformEndpoint);
|
|
2154
|
-
|
|
2263
|
+
fs5.writeFileSync(envPath, lines.join("\n").replace(/\n{3,}/g, "\n\n").trim() + "\n", "utf-8");
|
|
2155
2264
|
appendGitignoreEntries(projectPath, "# Standard Agents local platform token", [".dev.vars"]);
|
|
2156
2265
|
return envPath;
|
|
2157
2266
|
}
|
|
@@ -2200,7 +2309,7 @@ async function runPlatformInit(projectNameArg, options) {
|
|
|
2200
2309
|
process.exit(1);
|
|
2201
2310
|
}
|
|
2202
2311
|
const requestedProjectName = projectNameArg?.trim() || void 0;
|
|
2203
|
-
if (requestedProjectName &&
|
|
2312
|
+
if (requestedProjectName && fs5.existsSync(path8.join(cwd, requestedProjectName))) {
|
|
2204
2313
|
logger.error(`Directory "${requestedProjectName}" already exists`);
|
|
2205
2314
|
process.exit(1);
|
|
2206
2315
|
}
|
|
@@ -2235,8 +2344,8 @@ async function runPlatformInit(projectNameArg, options) {
|
|
|
2235
2344
|
}
|
|
2236
2345
|
const projectName = resolvePlatformProjectDirectoryName(project, requestedProjectName);
|
|
2237
2346
|
const projectPackageManager = resolvePlatformProjectPackageManager(project.package_manager, pm);
|
|
2238
|
-
const projectPath =
|
|
2239
|
-
if (
|
|
2347
|
+
const projectPath = path8.join(cwd, projectName);
|
|
2348
|
+
if (fs5.existsSync(projectPath)) {
|
|
2240
2349
|
logger.error(`Directory "${projectName}" already exists`);
|
|
2241
2350
|
process.exit(1);
|
|
2242
2351
|
}
|
|
@@ -2257,19 +2366,24 @@ async function runPlatformInit(projectNameArg, options) {
|
|
|
2257
2366
|
apiKey: project.api_key,
|
|
2258
2367
|
platformEndpoint: endpoint
|
|
2259
2368
|
});
|
|
2260
|
-
logger.success(`Wrote Standard Agents credentials to ${
|
|
2369
|
+
logger.success(`Wrote Standard Agents credentials to ${path8.relative(cwd, envPath)}.`);
|
|
2261
2370
|
if (project.git_extra_header) {
|
|
2262
2371
|
await configurePlatformGitCredentialHelper(projectPath);
|
|
2263
2372
|
logger.success("Configured git credentials for the platform repository.");
|
|
2264
2373
|
}
|
|
2265
|
-
const linkedPackages = preparePlatformProjectDependencies(projectPath, projectPackageManager);
|
|
2374
|
+
const linkedPackages = preparePlatformProjectDependencies(projectPath, projectPackageManager, options);
|
|
2266
2375
|
if (linkedPackages.length > 0) {
|
|
2267
2376
|
logger.info(`Workspace mode detected: linked ${linkedPackages.length} Standard Agents packages locally.`);
|
|
2268
2377
|
}
|
|
2269
2378
|
logger.info(`Installing dependencies with ${projectPackageManager}...`);
|
|
2270
|
-
|
|
2379
|
+
const pnpmCompatibilityArgs = getPnpmWorkspaceCompatibilityArgs(projectPackageManager, projectPath);
|
|
2380
|
+
const devHint = pnpmCompatibilityArgs.length > 0 ? resolvePostInitRunCommand(projectPackageManager, projectPath, false, pnpmCompatibilityArgs) : devCommandHint(projectPackageManager);
|
|
2381
|
+
await runCommand(projectPackageManager, projectInstallArgs(projectPackageManager, projectPath, "install", [], {
|
|
2382
|
+
isolateFromParent: true,
|
|
2383
|
+
ignoreProjectWorkspace: pnpmCompatibilityArgs.length > 0
|
|
2384
|
+
}), projectPath);
|
|
2271
2385
|
const repoUrl = project.repo_html_url ?? project.repo_clone_url;
|
|
2272
|
-
const tokenLocation =
|
|
2386
|
+
const tokenLocation = path8.relative(cwd, envPath);
|
|
2273
2387
|
if (options.dev === false) {
|
|
2274
2388
|
logger.success("Your Standard Agents instance is ready.");
|
|
2275
2389
|
logger.log(`Repository: ${repoUrl}`);
|
|
@@ -2277,7 +2391,7 @@ async function runPlatformInit(projectNameArg, options) {
|
|
|
2277
2391
|
logger.log("");
|
|
2278
2392
|
logger.log("Start it whenever you like:");
|
|
2279
2393
|
logger.log(` cd ${projectName}`);
|
|
2280
|
-
logger.log(` ${
|
|
2394
|
+
logger.log(` ${devHint}`);
|
|
2281
2395
|
return;
|
|
2282
2396
|
}
|
|
2283
2397
|
const devPort = await findAvailablePort(5173);
|
|
@@ -2286,7 +2400,7 @@ async function runPlatformInit(projectNameArg, options) {
|
|
|
2286
2400
|
logger.info("The dev server will stay in this terminal. Press Ctrl-C to stop it.");
|
|
2287
2401
|
const devProcess = startForegroundDevServer(
|
|
2288
2402
|
projectPackageManager,
|
|
2289
|
-
buildDevServerCommand(projectPackageManager, devPort),
|
|
2403
|
+
buildDevServerCommand(projectPackageManager, devPort, pnpmCompatibilityArgs),
|
|
2290
2404
|
projectPath
|
|
2291
2405
|
);
|
|
2292
2406
|
const devExit = waitForDevServerExit(devProcess);
|
|
@@ -2306,7 +2420,7 @@ async function runPlatformInit(projectNameArg, options) {
|
|
|
2306
2420
|
logger.log("");
|
|
2307
2421
|
logger.log("Once any error above is resolved, start it with:");
|
|
2308
2422
|
logger.log(` cd ${projectName}`);
|
|
2309
|
-
logger.log(` ${
|
|
2423
|
+
logger.log(` ${devHint}`);
|
|
2310
2424
|
return;
|
|
2311
2425
|
}
|
|
2312
2426
|
if (startup.type === "ready" && startup.ready) {
|
|
@@ -2332,7 +2446,7 @@ async function runPlatformInit(projectNameArg, options) {
|
|
|
2332
2446
|
logger.log("");
|
|
2333
2447
|
logger.log("Once any error above is resolved, start it with:");
|
|
2334
2448
|
logger.log(` cd ${projectName}`);
|
|
2335
|
-
logger.log(` ${
|
|
2449
|
+
logger.log(` ${devHint}`);
|
|
2336
2450
|
return;
|
|
2337
2451
|
}
|
|
2338
2452
|
logger.warning(`The dev server didn't respond at ${devUrl} within 60s.`);
|
|
@@ -2459,9 +2573,9 @@ async function init(projectNameArg, options = {}) {
|
|
|
2459
2573
|
if (providedBootstrap) {
|
|
2460
2574
|
logInfo("Bootstrap code supplied.");
|
|
2461
2575
|
} else if (existingBootstrapState) {
|
|
2462
|
-
logInfo("Found existing
|
|
2576
|
+
logInfo("Found existing Standard Agents auth session for this project.");
|
|
2463
2577
|
} else {
|
|
2464
|
-
logInfo("No
|
|
2578
|
+
logInfo("No Standard Agents CLI auth session found.");
|
|
2465
2579
|
}
|
|
2466
2580
|
logLine("");
|
|
2467
2581
|
const willShowAuthCardPrompt = initTuiMode && !existingBootstrapState && !providedBootstrap && !options.yes;
|
|
@@ -2469,7 +2583,7 @@ async function init(projectNameArg, options = {}) {
|
|
|
2469
2583
|
renderInitStepHeader(
|
|
2470
2584
|
"auth",
|
|
2471
2585
|
"Account linking",
|
|
2472
|
-
existingBootstrapState ? "Reusing saved project auth session if compatible with endpoint." : "Choose
|
|
2586
|
+
existingBootstrapState ? "Reusing saved project auth session if compatible with endpoint." : "Choose Standard Agents or Local mode.",
|
|
2473
2587
|
headerOptions
|
|
2474
2588
|
);
|
|
2475
2589
|
}
|
|
@@ -2590,15 +2704,15 @@ async function init(projectNameArg, options = {}) {
|
|
|
2590
2704
|
);
|
|
2591
2705
|
process.exit(1);
|
|
2592
2706
|
}
|
|
2593
|
-
const viteConfigPath =
|
|
2594
|
-
if (!
|
|
2707
|
+
const viteConfigPath = path8.join(projectPath, "vite.config.ts");
|
|
2708
|
+
if (!fs5.existsSync(viteConfigPath)) {
|
|
2595
2709
|
const viteConfigContent = `import { defineConfig } from 'vite'
|
|
2596
2710
|
|
|
2597
2711
|
export default defineConfig({
|
|
2598
2712
|
plugins: [],
|
|
2599
2713
|
})
|
|
2600
2714
|
`;
|
|
2601
|
-
|
|
2715
|
+
fs5.writeFileSync(viteConfigPath, viteConfigContent, "utf-8");
|
|
2602
2716
|
logSuccess("Created vite.config.ts");
|
|
2603
2717
|
}
|
|
2604
2718
|
} else if (resumeBootstrap) {
|
|
@@ -2606,16 +2720,21 @@ export default defineConfig({
|
|
|
2606
2720
|
} else {
|
|
2607
2721
|
logInfo(`Detected existing Standard Agents project in "${projectName}".`);
|
|
2608
2722
|
}
|
|
2609
|
-
const packageJsonPath =
|
|
2610
|
-
if (
|
|
2611
|
-
const packageJson = JSON.parse(
|
|
2723
|
+
const packageJsonPath = path8.join(projectPath, "package.json");
|
|
2724
|
+
if (fs5.existsSync(packageJsonPath)) {
|
|
2725
|
+
const packageJson = JSON.parse(fs5.readFileSync(packageJsonPath, "utf-8"));
|
|
2612
2726
|
const kebabName = toKebabCase(projectName);
|
|
2613
2727
|
if (packageJson.name !== kebabName) {
|
|
2614
2728
|
packageJson.name = kebabName;
|
|
2615
|
-
|
|
2729
|
+
fs5.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n", "utf-8");
|
|
2616
2730
|
}
|
|
2617
|
-
if (packageSpecifier === "workspace:*"
|
|
2618
|
-
|
|
2731
|
+
if (packageSpecifier === "workspace:*") {
|
|
2732
|
+
const workspaceRoot = resolveStandardAgentsWorkspaceRoot();
|
|
2733
|
+
if (!workspaceRoot) throw new Error("Workspace package linking requires a Standard Agents workspace root");
|
|
2734
|
+
linkWorkspaceProjectToolchain(projectPath, workspaceRoot);
|
|
2735
|
+
if (configureWorkspaceProjectScripts(projectPath, projectName)) {
|
|
2736
|
+
logInfo("Configured local workspace helper scripts for sandbox HMR and re-auth.");
|
|
2737
|
+
}
|
|
2619
2738
|
}
|
|
2620
2739
|
}
|
|
2621
2740
|
if (bootstrapRequested) {
|
|
@@ -2637,10 +2756,21 @@ export default defineConfig({
|
|
|
2637
2756
|
process.exit(1);
|
|
2638
2757
|
}
|
|
2639
2758
|
}
|
|
2759
|
+
let projectPnpmCompatibilityArgs = [];
|
|
2640
2760
|
try {
|
|
2761
|
+
const installBoundary = { isolateFromParent: packageSpecifier === "workspace:*" };
|
|
2762
|
+
if (pm === "pnpm" && !installBoundary.isolateFromParent && !fs5.existsSync(path8.join(projectPath, "pnpm-workspace.yaml")) && findPnpmWorkspaceRoot(path8.dirname(projectPath))) {
|
|
2763
|
+
logInfo("The enclosing pnpm workspace controls esbuild and workerd build approvals.");
|
|
2764
|
+
}
|
|
2765
|
+
writeLocalPnpmBuildPolicy(projectPath, pm, {
|
|
2766
|
+
...installBoundary,
|
|
2767
|
+
// The SDK postinstall only warns about stale model types; runtime files ship built.
|
|
2768
|
+
ignoredBuildScripts: openrouterKey ? ["@openrouter/sdk"] : []
|
|
2769
|
+
});
|
|
2770
|
+
projectPnpmCompatibilityArgs = getPnpmWorkspaceCompatibilityArgs(pm, projectPath);
|
|
2641
2771
|
const installCmd = pm === "npm" ? "install" : "add";
|
|
2642
2772
|
if (packageSpecifier === "workspace:*") {
|
|
2643
|
-
logInfo("Using local workspace @standardagents/* packages (
|
|
2773
|
+
logInfo("Using local workspace @standardagents/* packages (link:).");
|
|
2644
2774
|
}
|
|
2645
2775
|
await withTuiSpinner(initTuiMode, "Installing dependencies...", async () => {
|
|
2646
2776
|
const standardAgentsPackage = (packageName) => `${packageName}@${resolveStandardAgentsPackageSpecifier(packageName, packageSpecifier)}`;
|
|
@@ -2656,7 +2786,11 @@ export default defineConfig({
|
|
|
2656
2786
|
if (openrouterKey) {
|
|
2657
2787
|
deps.push(standardAgentsPackage("@standardagents/openrouter"));
|
|
2658
2788
|
}
|
|
2659
|
-
|
|
2789
|
+
const installArgs = projectInstallArgs(pm, projectPath, installCmd, deps, {
|
|
2790
|
+
...installBoundary,
|
|
2791
|
+
ignoreProjectWorkspace: projectPnpmCompatibilityArgs.length > 0
|
|
2792
|
+
});
|
|
2793
|
+
await runCommand(pm, installArgs, projectPath, { quiet: initTuiMode });
|
|
2660
2794
|
});
|
|
2661
2795
|
} catch (error) {
|
|
2662
2796
|
logger.error(
|
|
@@ -2669,7 +2803,10 @@ export default defineConfig({
|
|
|
2669
2803
|
const restoreLogger = silenceLoggerOutput(initTuiMode);
|
|
2670
2804
|
try {
|
|
2671
2805
|
await withTuiSpinner(initTuiMode, "Scaffolding project files...", async () => {
|
|
2672
|
-
await scaffold({
|
|
2806
|
+
await scaffold({
|
|
2807
|
+
force: true,
|
|
2808
|
+
standardAgents: packageSpecifier === "workspace:*" ? resolveStandardAgentsPackageSpecifier("@standardagents/builder", packageSpecifier) : void 0
|
|
2809
|
+
});
|
|
2673
2810
|
});
|
|
2674
2811
|
} finally {
|
|
2675
2812
|
restoreLogger();
|
|
@@ -2748,18 +2885,18 @@ export default defineConfig({
|
|
|
2748
2885
|
}
|
|
2749
2886
|
}
|
|
2750
2887
|
devVarsLines.push("");
|
|
2751
|
-
const devVarsPath =
|
|
2752
|
-
|
|
2888
|
+
const devVarsPath = path8.join(projectPath, ".dev.vars");
|
|
2889
|
+
fs5.writeFileSync(devVarsPath, devVarsLines.join("\n"), "utf-8");
|
|
2753
2890
|
logSuccess("Created .dev.vars with encryption key");
|
|
2754
|
-
const gitignorePath =
|
|
2755
|
-
if (
|
|
2756
|
-
const gitignoreContent =
|
|
2891
|
+
const gitignorePath = path8.join(projectPath, ".gitignore");
|
|
2892
|
+
if (fs5.existsSync(gitignorePath)) {
|
|
2893
|
+
const gitignoreContent = fs5.readFileSync(gitignorePath, "utf-8");
|
|
2757
2894
|
if (!gitignoreContent.includes(".dev.vars")) {
|
|
2758
|
-
|
|
2895
|
+
fs5.appendFileSync(gitignorePath, "\n# Local environment variables\n.dev.vars\n");
|
|
2759
2896
|
logSuccess("Added .dev.vars to .gitignore");
|
|
2760
2897
|
}
|
|
2761
2898
|
}
|
|
2762
|
-
const nextRunCommand = resolvePostInitRunCommand(pm, projectPath, packageSpecifier === "workspace:*");
|
|
2899
|
+
const nextRunCommand = resolvePostInitRunCommand(pm, projectPath, packageSpecifier === "workspace:*", projectPnpmCompatibilityArgs);
|
|
2763
2900
|
if (initTuiMode) {
|
|
2764
2901
|
clearTerminalScreen();
|
|
2765
2902
|
process.stdout.write(
|
|
@@ -2808,8 +2945,8 @@ function upsertEnvLine2(lines, key, value) {
|
|
|
2808
2945
|
lines.push(nextLine);
|
|
2809
2946
|
}
|
|
2810
2947
|
function syncProjectAuthEnv(projectPath, endpoint, state) {
|
|
2811
|
-
const devVarsPath =
|
|
2812
|
-
const existing =
|
|
2948
|
+
const devVarsPath = path8.join(projectPath, DEV_VARS_FILENAME);
|
|
2949
|
+
const existing = fs5.existsSync(devVarsPath) ? fs5.readFileSync(devVarsPath, "utf-8") : "";
|
|
2813
2950
|
const lines = existing ? existing.split("\n") : [];
|
|
2814
2951
|
if (endpoint.trim()) {
|
|
2815
2952
|
upsertEnvLine2(lines, "PLATFORM_ENDPOINT", endpoint.trim());
|
|
@@ -2823,7 +2960,7 @@ function syncProjectAuthEnv(projectPath, endpoint, state) {
|
|
|
2823
2960
|
upsertEnvLine2(lines, "STANDARDAGENTS_BOOTSTRAP_SESSION_COOKIE", state.session_cookie);
|
|
2824
2961
|
}
|
|
2825
2962
|
const normalized = lines.join("\n").replace(/\n*$/, "\n");
|
|
2826
|
-
|
|
2963
|
+
fs5.writeFileSync(devVarsPath, normalized, "utf-8");
|
|
2827
2964
|
}
|
|
2828
2965
|
|
|
2829
2966
|
// src/commands/login.ts
|
|
@@ -2883,7 +3020,7 @@ async function loginWithPlatform(options) {
|
|
|
2883
3020
|
let wsUrl = null;
|
|
2884
3021
|
let wsExpiresAt = 0;
|
|
2885
3022
|
logger.log("");
|
|
2886
|
-
logger.info("Starting
|
|
3023
|
+
logger.info("Starting Standard Agents CLI authentication...");
|
|
2887
3024
|
logger.log(`Platform API: ${endpoint}`);
|
|
2888
3025
|
try {
|
|
2889
3026
|
const started = await startCliAuthSession(endpoint);
|
|
@@ -2997,17 +3134,17 @@ var KEYCHAIN_SERVICE = "standardagents-cli";
|
|
|
2997
3134
|
function configDir() {
|
|
2998
3135
|
if (process.platform === "win32") {
|
|
2999
3136
|
const appData = process.env.APPDATA;
|
|
3000
|
-
if (appData) return
|
|
3137
|
+
if (appData) return path8.join(appData, "standardagents");
|
|
3001
3138
|
}
|
|
3002
3139
|
const xdgConfig = process.env.XDG_CONFIG_HOME;
|
|
3003
|
-
if (xdgConfig) return
|
|
3004
|
-
return
|
|
3140
|
+
if (xdgConfig) return path8.join(xdgConfig, "standardagents");
|
|
3141
|
+
return path8.join(os3.homedir(), ".config", "standardagents");
|
|
3005
3142
|
}
|
|
3006
3143
|
function stateFilePath() {
|
|
3007
|
-
return
|
|
3144
|
+
return path8.join(configDir(), "auth-state.json");
|
|
3008
3145
|
}
|
|
3009
3146
|
function ensureStateDir() {
|
|
3010
|
-
|
|
3147
|
+
fs5.mkdirSync(path8.dirname(stateFilePath()), { recursive: true });
|
|
3011
3148
|
}
|
|
3012
3149
|
function securityCommand(args) {
|
|
3013
3150
|
const result = spawnSync("security", args, { encoding: "utf8" });
|
|
@@ -3050,11 +3187,11 @@ function readFromKeychain(orgId) {
|
|
|
3050
3187
|
}
|
|
3051
3188
|
function readCliAuthState() {
|
|
3052
3189
|
const file = stateFilePath();
|
|
3053
|
-
if (!
|
|
3190
|
+
if (!fs5.existsSync(file)) {
|
|
3054
3191
|
return { active_org_id: null, orgs: {} };
|
|
3055
3192
|
}
|
|
3056
3193
|
try {
|
|
3057
|
-
const parsed = JSON.parse(
|
|
3194
|
+
const parsed = JSON.parse(fs5.readFileSync(file, "utf8"));
|
|
3058
3195
|
return {
|
|
3059
3196
|
active_org_id: parsed.active_org_id ?? null,
|
|
3060
3197
|
orgs: parsed.orgs ?? {},
|
|
@@ -3199,18 +3336,18 @@ function stripOrgContextFromDevVars(content) {
|
|
|
3199
3336
|
}
|
|
3200
3337
|
function clearLocalOrgContext(projectPath) {
|
|
3201
3338
|
const statePath = getBootstrapStatePath(projectPath);
|
|
3202
|
-
const stateCleared =
|
|
3339
|
+
const stateCleared = fs5.existsSync(statePath);
|
|
3203
3340
|
clearBootstrapState(projectPath);
|
|
3204
|
-
const devVarsPath =
|
|
3205
|
-
if (!
|
|
3341
|
+
const devVarsPath = path8.join(projectPath, DEV_VARS_FILENAME2);
|
|
3342
|
+
if (!fs5.existsSync(devVarsPath)) {
|
|
3206
3343
|
return { stateCleared, envCleared: false };
|
|
3207
3344
|
}
|
|
3208
|
-
const content =
|
|
3345
|
+
const content = fs5.readFileSync(devVarsPath, "utf-8");
|
|
3209
3346
|
const stripped = stripOrgContextFromDevVars(content);
|
|
3210
3347
|
if (!stripped.removed) {
|
|
3211
3348
|
return { stateCleared, envCleared: false };
|
|
3212
3349
|
}
|
|
3213
|
-
|
|
3350
|
+
fs5.writeFileSync(devVarsPath, stripped.updated, "utf-8");
|
|
3214
3351
|
return { stateCleared, envCleared: true };
|
|
3215
3352
|
}
|
|
3216
3353
|
function logLocalClearResult(result) {
|
|
@@ -3262,9 +3399,9 @@ async function logout(options = {}) {
|
|
|
3262
3399
|
}
|
|
3263
3400
|
function getReactPackageVersion() {
|
|
3264
3401
|
try {
|
|
3265
|
-
const __dirname =
|
|
3266
|
-
const pkgPath =
|
|
3267
|
-
const pkg = JSON.parse(
|
|
3402
|
+
const __dirname = path8.dirname(fileURLToPath(import.meta.url));
|
|
3403
|
+
const pkgPath = path8.resolve(__dirname, "../package.json");
|
|
3404
|
+
const pkg = JSON.parse(fs5.readFileSync(pkgPath, "utf-8"));
|
|
3268
3405
|
const version = pkg.version;
|
|
3269
3406
|
const prereleaseMatch = version.match(/-([a-z]+)\./i);
|
|
3270
3407
|
if (prereleaseMatch) {
|
|
@@ -3276,8 +3413,8 @@ function getReactPackageVersion() {
|
|
|
3276
3413
|
}
|
|
3277
3414
|
}
|
|
3278
3415
|
function getChatSourceDir() {
|
|
3279
|
-
const __dirname =
|
|
3280
|
-
return
|
|
3416
|
+
const __dirname = path8.dirname(fileURLToPath(import.meta.url));
|
|
3417
|
+
return path8.resolve(__dirname, "../chat");
|
|
3281
3418
|
}
|
|
3282
3419
|
async function prompt3(question) {
|
|
3283
3420
|
const rl = readline.createInterface({
|
|
@@ -3318,10 +3455,10 @@ function detectPackageManager2() {
|
|
|
3318
3455
|
if (userAgent.includes("yarn")) return "yarn";
|
|
3319
3456
|
if (userAgent.includes("bun")) return "bun";
|
|
3320
3457
|
}
|
|
3321
|
-
if (
|
|
3322
|
-
if (
|
|
3323
|
-
if (
|
|
3324
|
-
if (
|
|
3458
|
+
if (fs5.existsSync("pnpm-lock.yaml")) return "pnpm";
|
|
3459
|
+
if (fs5.existsSync("yarn.lock")) return "yarn";
|
|
3460
|
+
if (fs5.existsSync("bun.lockb")) return "bun";
|
|
3461
|
+
if (fs5.existsSync("package-lock.json")) return "npm";
|
|
3325
3462
|
return "npm";
|
|
3326
3463
|
}
|
|
3327
3464
|
async function selectPackageManager2(detected) {
|
|
@@ -3550,25 +3687,25 @@ minimumReleaseAgeExclude:
|
|
|
3550
3687
|
`;
|
|
3551
3688
|
}
|
|
3552
3689
|
function copyDir(src, dest, skip = []) {
|
|
3553
|
-
if (!
|
|
3554
|
-
|
|
3690
|
+
if (!fs5.existsSync(dest)) {
|
|
3691
|
+
fs5.mkdirSync(dest, { recursive: true });
|
|
3555
3692
|
}
|
|
3556
|
-
const entries =
|
|
3693
|
+
const entries = fs5.readdirSync(src, { withFileTypes: true });
|
|
3557
3694
|
for (const entry of entries) {
|
|
3558
3695
|
if (skip.includes(entry.name) || /\.test\.tsx?$/.test(entry.name)) continue;
|
|
3559
|
-
const srcPath =
|
|
3560
|
-
const destPath =
|
|
3696
|
+
const srcPath = path8.join(src, entry.name);
|
|
3697
|
+
const destPath = path8.join(dest, entry.name);
|
|
3561
3698
|
if (entry.isDirectory()) {
|
|
3562
3699
|
copyDir(srcPath, destPath, skip);
|
|
3563
3700
|
} else {
|
|
3564
|
-
|
|
3701
|
+
fs5.copyFileSync(srcPath, destPath);
|
|
3565
3702
|
}
|
|
3566
3703
|
}
|
|
3567
3704
|
}
|
|
3568
3705
|
async function initChat(projectNameArg, options = {}) {
|
|
3569
3706
|
const cwd = process.cwd();
|
|
3570
3707
|
const chatSourceDir = getChatSourceDir();
|
|
3571
|
-
if (!
|
|
3708
|
+
if (!fs5.existsSync(chatSourceDir)) {
|
|
3572
3709
|
logger.error("Chat source files not found. This CLI installation may be corrupted.");
|
|
3573
3710
|
process.exit(1);
|
|
3574
3711
|
}
|
|
@@ -3583,8 +3720,8 @@ async function initChat(projectNameArg, options = {}) {
|
|
|
3583
3720
|
logger.error("Project name is required");
|
|
3584
3721
|
process.exit(1);
|
|
3585
3722
|
}
|
|
3586
|
-
const projectPath =
|
|
3587
|
-
if (
|
|
3723
|
+
const projectPath = path8.join(cwd, projectName);
|
|
3724
|
+
if (fs5.existsSync(projectPath)) {
|
|
3588
3725
|
logger.error(`Directory "${projectName}" already exists`);
|
|
3589
3726
|
process.exit(1);
|
|
3590
3727
|
}
|
|
@@ -3627,7 +3764,7 @@ async function initChat(projectNameArg, options = {}) {
|
|
|
3627
3764
|
logger.log("");
|
|
3628
3765
|
logger.info(`Creating ${framework === "vite" ? "Vite" : "Next.js"} project...`);
|
|
3629
3766
|
logger.log("");
|
|
3630
|
-
|
|
3767
|
+
fs5.mkdirSync(projectPath, { recursive: true });
|
|
3631
3768
|
const reactVersion = getReactPackageVersion();
|
|
3632
3769
|
if (framework === "vite") {
|
|
3633
3770
|
await scaffoldVite(projectPath, chatSourceDir, projectName, serverUrl, reactVersion);
|
|
@@ -3639,7 +3776,7 @@ async function initChat(projectNameArg, options = {}) {
|
|
|
3639
3776
|
logger.log("");
|
|
3640
3777
|
try {
|
|
3641
3778
|
await runCommand2(pm, pm === "npm" ? ["install"] : ["install"], projectPath);
|
|
3642
|
-
} catch
|
|
3779
|
+
} catch {
|
|
3643
3780
|
logger.error("Failed to install dependencies");
|
|
3644
3781
|
process.exit(1);
|
|
3645
3782
|
}
|
|
@@ -3678,14 +3815,14 @@ async function initChat(projectNameArg, options = {}) {
|
|
|
3678
3815
|
});
|
|
3679
3816
|
}
|
|
3680
3817
|
async function scaffoldVite(projectPath, chatSourceDir, projectName, serverUrl, reactVersion) {
|
|
3681
|
-
copyDir(
|
|
3818
|
+
copyDir(path8.join(chatSourceDir, "src"), path8.join(projectPath, "src"), []);
|
|
3682
3819
|
logger.success("Copied src/");
|
|
3683
|
-
const viteDir =
|
|
3684
|
-
let indexHtml =
|
|
3820
|
+
const viteDir = path8.join(chatSourceDir, "vite");
|
|
3821
|
+
let indexHtml = fs5.readFileSync(path8.join(viteDir, "index.html"), "utf-8");
|
|
3685
3822
|
indexHtml = indexHtml.replace('src="/main.tsx"', 'src="/src/main.tsx"');
|
|
3686
|
-
|
|
3823
|
+
fs5.writeFileSync(path8.join(projectPath, "index.html"), indexHtml, "utf-8");
|
|
3687
3824
|
logger.success("Created index.html");
|
|
3688
|
-
|
|
3825
|
+
fs5.copyFileSync(path8.join(viteDir, "main.tsx"), path8.join(projectPath, "src", "main.tsx"));
|
|
3689
3826
|
logger.success("Created src/main.tsx");
|
|
3690
3827
|
const viteConfig = `import { defineConfig, loadEnv } from 'vite'
|
|
3691
3828
|
import react from '@vitejs/plugin-react'
|
|
@@ -3711,16 +3848,16 @@ export default defineConfig(({ mode }) => {
|
|
|
3711
3848
|
}
|
|
3712
3849
|
})
|
|
3713
3850
|
`;
|
|
3714
|
-
|
|
3851
|
+
fs5.writeFileSync(path8.join(projectPath, "vite.config.ts"), viteConfig, "utf-8");
|
|
3715
3852
|
logger.success("Created vite.config.ts");
|
|
3716
|
-
|
|
3717
|
-
const tsconfig = JSON.parse(
|
|
3853
|
+
fs5.copyFileSync(path8.join(chatSourceDir, "tsconfig.json"), path8.join(projectPath, "tsconfig.json"));
|
|
3854
|
+
const tsconfig = JSON.parse(fs5.readFileSync(path8.join(projectPath, "tsconfig.json"), "utf-8"));
|
|
3718
3855
|
tsconfig.include = ["src"];
|
|
3719
3856
|
delete tsconfig.compilerOptions?.paths;
|
|
3720
|
-
|
|
3857
|
+
fs5.writeFileSync(path8.join(projectPath, "tsconfig.json"), JSON.stringify(tsconfig, null, 2) + "\n", "utf-8");
|
|
3721
3858
|
logger.success("Created tsconfig.json");
|
|
3722
|
-
|
|
3723
|
-
const pkg = JSON.parse(
|
|
3859
|
+
fs5.copyFileSync(path8.join(chatSourceDir, "package.json"), path8.join(projectPath, "package.json"));
|
|
3860
|
+
const pkg = JSON.parse(fs5.readFileSync(path8.join(projectPath, "package.json"), "utf-8"));
|
|
3724
3861
|
pkg.name = projectName;
|
|
3725
3862
|
pkg.scripts = {
|
|
3726
3863
|
dev: "vite",
|
|
@@ -3735,36 +3872,36 @@ export default defineConfig(({ mode }) => {
|
|
|
3735
3872
|
delete pkg.devDependencies?.["@tailwindcss/postcss"];
|
|
3736
3873
|
delete pkg.devDependencies?.["postcss"];
|
|
3737
3874
|
delete pkg.devDependencies?.["vitest"];
|
|
3738
|
-
|
|
3739
|
-
|
|
3875
|
+
fs5.writeFileSync(path8.join(projectPath, "package.json"), JSON.stringify(applyChatBuildApprovals(pkg), null, 2) + "\n", "utf-8");
|
|
3876
|
+
fs5.writeFileSync(path8.join(projectPath, "pnpm-workspace.yaml"), renderChatPnpmWorkspaceYaml(), "utf-8");
|
|
3740
3877
|
logger.success("Created package.json");
|
|
3741
3878
|
const envContent = `# Agentbuilder connection
|
|
3742
3879
|
VITE_AGENTBUILDER_URL=${serverUrl}
|
|
3743
3880
|
`;
|
|
3744
|
-
|
|
3881
|
+
fs5.writeFileSync(path8.join(projectPath, ".env"), envContent, "utf-8");
|
|
3745
3882
|
logger.success("Created .env");
|
|
3746
|
-
|
|
3883
|
+
fs5.writeFileSync(path8.join(projectPath, ".gitignore"), `node_modules
|
|
3747
3884
|
dist
|
|
3748
3885
|
.env
|
|
3749
3886
|
`, "utf-8");
|
|
3750
3887
|
logger.success("Created .gitignore");
|
|
3751
|
-
let mainTsx =
|
|
3888
|
+
let mainTsx = fs5.readFileSync(path8.join(projectPath, "src", "main.tsx"), "utf-8");
|
|
3752
3889
|
mainTsx = mainTsx.replace(/from '\.\.\/src\//g, "from './").replace(/import '\.\.\/src\//g, "import './");
|
|
3753
|
-
|
|
3754
|
-
if (
|
|
3755
|
-
|
|
3890
|
+
fs5.writeFileSync(path8.join(projectPath, "src", "main.tsx"), mainTsx, "utf-8");
|
|
3891
|
+
if (fs5.existsSync(path8.join(viteDir, "favicon.svg"))) {
|
|
3892
|
+
fs5.copyFileSync(path8.join(viteDir, "favicon.svg"), path8.join(projectPath, "favicon.svg"));
|
|
3756
3893
|
logger.success("Created favicon.svg");
|
|
3757
3894
|
}
|
|
3758
3895
|
}
|
|
3759
3896
|
async function scaffoldNextjs(projectPath, chatSourceDir, projectName, serverUrl, reactVersion) {
|
|
3760
|
-
copyDir(
|
|
3897
|
+
copyDir(path8.join(chatSourceDir, "src"), path8.join(projectPath, "src"), []);
|
|
3761
3898
|
logger.success("Copied src/");
|
|
3762
|
-
const nextDir =
|
|
3763
|
-
copyDir(
|
|
3899
|
+
const nextDir = path8.join(chatSourceDir, "next");
|
|
3900
|
+
copyDir(path8.join(nextDir, "app"), path8.join(projectPath, "app"), []);
|
|
3764
3901
|
logger.success("Copied app/");
|
|
3765
|
-
|
|
3902
|
+
fs5.copyFileSync(path8.join(nextDir, "next.config.ts"), path8.join(projectPath, "next.config.ts"));
|
|
3766
3903
|
logger.success("Created next.config.ts");
|
|
3767
|
-
|
|
3904
|
+
fs5.copyFileSync(path8.join(nextDir, "postcss.config.mjs"), path8.join(projectPath, "postcss.config.mjs"));
|
|
3768
3905
|
logger.success("Created postcss.config.mjs");
|
|
3769
3906
|
const tsconfig = {
|
|
3770
3907
|
compilerOptions: {
|
|
@@ -3789,9 +3926,9 @@ async function scaffoldNextjs(projectPath, chatSourceDir, projectName, serverUrl
|
|
|
3789
3926
|
include: ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
3790
3927
|
exclude: ["node_modules"]
|
|
3791
3928
|
};
|
|
3792
|
-
|
|
3929
|
+
fs5.writeFileSync(path8.join(projectPath, "tsconfig.json"), JSON.stringify(tsconfig, null, 2) + "\n", "utf-8");
|
|
3793
3930
|
logger.success("Created tsconfig.json");
|
|
3794
|
-
const pkg = JSON.parse(
|
|
3931
|
+
const pkg = JSON.parse(fs5.readFileSync(path8.join(chatSourceDir, "package.json"), "utf-8"));
|
|
3795
3932
|
pkg.name = projectName;
|
|
3796
3933
|
pkg.scripts = {
|
|
3797
3934
|
dev: "next dev",
|
|
@@ -3806,26 +3943,26 @@ async function scaffoldNextjs(projectPath, chatSourceDir, projectName, serverUrl
|
|
|
3806
3943
|
delete pkg.devDependencies?.["@vitejs/plugin-react"];
|
|
3807
3944
|
delete pkg.devDependencies?.["vite"];
|
|
3808
3945
|
delete pkg.devDependencies?.["vitest"];
|
|
3809
|
-
|
|
3810
|
-
|
|
3946
|
+
fs5.writeFileSync(path8.join(projectPath, "package.json"), JSON.stringify(applyChatBuildApprovals(pkg), null, 2) + "\n", "utf-8");
|
|
3947
|
+
fs5.writeFileSync(path8.join(projectPath, "pnpm-workspace.yaml"), renderChatPnpmWorkspaceYaml(), "utf-8");
|
|
3811
3948
|
logger.success("Created package.json");
|
|
3812
3949
|
const envContent = `# Agentbuilder connection
|
|
3813
3950
|
NEXT_PUBLIC_AGENTBUILDER_URL=${serverUrl}
|
|
3814
3951
|
`;
|
|
3815
|
-
|
|
3952
|
+
fs5.writeFileSync(path8.join(projectPath, ".env.local"), envContent, "utf-8");
|
|
3816
3953
|
logger.success("Created .env.local");
|
|
3817
|
-
|
|
3954
|
+
fs5.writeFileSync(path8.join(projectPath, ".gitignore"), `node_modules
|
|
3818
3955
|
.next
|
|
3819
3956
|
out
|
|
3820
3957
|
.env.local
|
|
3821
3958
|
`, "utf-8");
|
|
3822
3959
|
logger.success("Created .gitignore");
|
|
3823
|
-
let layoutTsx =
|
|
3960
|
+
let layoutTsx = fs5.readFileSync(path8.join(projectPath, "app", "layout.tsx"), "utf-8");
|
|
3824
3961
|
layoutTsx = layoutTsx.replace(/from '\.\.\/\.\.\/src\//g, "from '../src/");
|
|
3825
|
-
|
|
3826
|
-
let pageTsx =
|
|
3962
|
+
fs5.writeFileSync(path8.join(projectPath, "app", "layout.tsx"), layoutTsx, "utf-8");
|
|
3963
|
+
let pageTsx = fs5.readFileSync(path8.join(projectPath, "app", "page.tsx"), "utf-8");
|
|
3827
3964
|
pageTsx = pageTsx.replace(/from '\.\.\/\.\.\/src\//g, "from '../src/");
|
|
3828
|
-
|
|
3965
|
+
fs5.writeFileSync(path8.join(projectPath, "app", "page.tsx"), pageTsx, "utf-8");
|
|
3829
3966
|
}
|
|
3830
3967
|
async function selectAgent(agents) {
|
|
3831
3968
|
return new Promise((resolve) => {
|
|
@@ -3947,11 +4084,11 @@ async function selectItemModes(items, _agentName) {
|
|
|
3947
4084
|
});
|
|
3948
4085
|
}
|
|
3949
4086
|
function isStandardAgentsProject() {
|
|
3950
|
-
if (!
|
|
4087
|
+
if (!fs5.existsSync("agents")) {
|
|
3951
4088
|
return false;
|
|
3952
4089
|
}
|
|
3953
4090
|
try {
|
|
3954
|
-
const pkgJson = JSON.parse(
|
|
4091
|
+
const pkgJson = JSON.parse(fs5.readFileSync("package.json", "utf-8"));
|
|
3955
4092
|
const deps = { ...pkgJson.dependencies, ...pkgJson.devDependencies };
|
|
3956
4093
|
return "@standardagents/builder" in deps;
|
|
3957
4094
|
} catch {
|
|
@@ -3980,7 +4117,7 @@ async function pack(agentName, options) {
|
|
|
3980
4117
|
}
|
|
3981
4118
|
const packingService = new PackingService();
|
|
3982
4119
|
if (!agentName) {
|
|
3983
|
-
const agents = packingService.listAgents(rootDir);
|
|
4120
|
+
const agents = await packingService.listAgents(rootDir);
|
|
3984
4121
|
if (agents.length === 0) {
|
|
3985
4122
|
logger.error("No agents found in agents/agents/");
|
|
3986
4123
|
process.exit(1);
|
|
@@ -4095,7 +4232,7 @@ async function pack(agentName, options) {
|
|
|
4095
4232
|
}));
|
|
4096
4233
|
console.log("");
|
|
4097
4234
|
}
|
|
4098
|
-
const outputDir = options.output ||
|
|
4235
|
+
const outputDir = options.output || path8.join(rootDir, "agents", "packed");
|
|
4099
4236
|
logger.info(`Packing to: ${outputDir}`);
|
|
4100
4237
|
const result = await packingService.pack({
|
|
4101
4238
|
agentName: selectedAgent,
|
|
@@ -4138,18 +4275,28 @@ function registerPackCommand(program2) {
|
|
|
4138
4275
|
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);
|
|
4139
4276
|
}
|
|
4140
4277
|
function isStandardAgentsProject2() {
|
|
4141
|
-
if (!
|
|
4278
|
+
if (!fs5.existsSync("agents")) {
|
|
4142
4279
|
return false;
|
|
4143
4280
|
}
|
|
4144
4281
|
try {
|
|
4145
|
-
const pkgJson = JSON.parse(
|
|
4282
|
+
const pkgJson = JSON.parse(fs5.readFileSync("package.json", "utf-8"));
|
|
4146
4283
|
const deps = { ...pkgJson.dependencies, ...pkgJson.devDependencies };
|
|
4147
4284
|
return "@standardagents/builder" in deps;
|
|
4148
4285
|
} catch {
|
|
4149
4286
|
return false;
|
|
4150
4287
|
}
|
|
4151
4288
|
}
|
|
4152
|
-
async function
|
|
4289
|
+
async function loadUnpackingService() {
|
|
4290
|
+
try {
|
|
4291
|
+
const { UnpackingService } = await import('@standardagents/builder/packing');
|
|
4292
|
+
return UnpackingService;
|
|
4293
|
+
} catch {
|
|
4294
|
+
logger.error("Failed to load unpacking service from @standardagents/builder");
|
|
4295
|
+
logger.info("Make sure @standardagents/builder is installed.");
|
|
4296
|
+
process.exit(1);
|
|
4297
|
+
}
|
|
4298
|
+
}
|
|
4299
|
+
async function unpack(pkgIdentifier) {
|
|
4153
4300
|
logger.info("Unpacking agent...\n");
|
|
4154
4301
|
if (!isStandardAgentsProject2()) {
|
|
4155
4302
|
logger.error("This does not appear to be a Standard Agents project.");
|
|
@@ -4157,19 +4304,7 @@ async function unpack(pkgIdentifier, options) {
|
|
|
4157
4304
|
process.exit(1);
|
|
4158
4305
|
}
|
|
4159
4306
|
const rootDir = process.cwd();
|
|
4160
|
-
|
|
4161
|
-
try {
|
|
4162
|
-
const builder = await import('@standardagents/builder/runtime');
|
|
4163
|
-
UnpackingService = builder.UnpackingService;
|
|
4164
|
-
if (!UnpackingService) {
|
|
4165
|
-
const packing = await import('@standardagents/builder');
|
|
4166
|
-
UnpackingService = packing.UnpackingService;
|
|
4167
|
-
}
|
|
4168
|
-
} catch (err) {
|
|
4169
|
-
logger.error("Failed to load unpacking service from @standardagents/builder");
|
|
4170
|
-
logger.info("Make sure @standardagents/builder is installed.");
|
|
4171
|
-
process.exit(1);
|
|
4172
|
-
}
|
|
4307
|
+
const UnpackingService = await loadUnpackingService();
|
|
4173
4308
|
const unpackingService = new UnpackingService();
|
|
4174
4309
|
if (!pkgIdentifier) {
|
|
4175
4310
|
const packages = await unpackingService.listPackages(rootDir);
|
|
@@ -4181,7 +4316,7 @@ async function unpack(pkgIdentifier, options) {
|
|
|
4181
4316
|
logger.info("Available packed agents:");
|
|
4182
4317
|
for (const pkg of packages) {
|
|
4183
4318
|
console.log(` - ${pkg.packageId} (${pkg.version}) [${pkg.source}]`);
|
|
4184
|
-
console.log(` Entry: ${pkg.
|
|
4319
|
+
console.log(` Entry: ${pkg.entryAgents.join(", ")}`);
|
|
4185
4320
|
console.log(` Path: ${pkg.path}`);
|
|
4186
4321
|
console.log("");
|
|
4187
4322
|
}
|
|
@@ -4190,9 +4325,8 @@ async function unpack(pkgIdentifier, options) {
|
|
|
4190
4325
|
}
|
|
4191
4326
|
logger.info(`Unpacking: ${pkgIdentifier}`);
|
|
4192
4327
|
const result = await unpackingService.unpack({
|
|
4193
|
-
|
|
4194
|
-
rootDir
|
|
4195
|
-
keepSignatures: !options.noSignatures
|
|
4328
|
+
packageId: pkgIdentifier,
|
|
4329
|
+
rootDir
|
|
4196
4330
|
});
|
|
4197
4331
|
if (!result.success) {
|
|
4198
4332
|
logger.error(`Unpacking failed: ${result.error}`);
|
|
@@ -4201,12 +4335,12 @@ async function unpack(pkgIdentifier, options) {
|
|
|
4201
4335
|
console.log("");
|
|
4202
4336
|
logger.success("Unpacking complete!");
|
|
4203
4337
|
console.log(` Package: ${result.packageId}`);
|
|
4204
|
-
console.log(` Files: ${result.
|
|
4205
|
-
if (result.
|
|
4338
|
+
console.log(` Files: ${result.filesGenerated.length} created`);
|
|
4339
|
+
if (result.filesGenerated.length > 0) {
|
|
4206
4340
|
console.log("");
|
|
4207
4341
|
logger.info("Created files:");
|
|
4208
|
-
for (const file of result.
|
|
4209
|
-
const relPath =
|
|
4342
|
+
for (const file of result.filesGenerated) {
|
|
4343
|
+
const relPath = path8.relative(rootDir, file);
|
|
4210
4344
|
console.log(` - ${relPath}`);
|
|
4211
4345
|
}
|
|
4212
4346
|
}
|
|
@@ -4217,13 +4351,6 @@ async function unpack(pkgIdentifier, options) {
|
|
|
4217
4351
|
console.log(` - ${warning}`);
|
|
4218
4352
|
}
|
|
4219
4353
|
}
|
|
4220
|
-
if (options.noSignatures) {
|
|
4221
|
-
console.log("");
|
|
4222
|
-
logger.info("Package signatures removed - files are fully editable.");
|
|
4223
|
-
} else {
|
|
4224
|
-
console.log("");
|
|
4225
|
-
logger.info("Package signatures preserved - files are editable but marked as packed.");
|
|
4226
|
-
}
|
|
4227
4354
|
}
|
|
4228
4355
|
async function listPacked() {
|
|
4229
4356
|
if (!isStandardAgentsProject2()) {
|
|
@@ -4232,19 +4359,7 @@ async function listPacked() {
|
|
|
4232
4359
|
process.exit(1);
|
|
4233
4360
|
}
|
|
4234
4361
|
const rootDir = process.cwd();
|
|
4235
|
-
|
|
4236
|
-
try {
|
|
4237
|
-
const builder = await import('@standardagents/builder/runtime');
|
|
4238
|
-
UnpackingService = builder.UnpackingService;
|
|
4239
|
-
if (!UnpackingService) {
|
|
4240
|
-
const packing = await import('@standardagents/builder');
|
|
4241
|
-
UnpackingService = packing.UnpackingService;
|
|
4242
|
-
}
|
|
4243
|
-
} catch (err) {
|
|
4244
|
-
logger.error("Failed to load unpacking service from @standardagents/builder");
|
|
4245
|
-
logger.info("Make sure @standardagents/builder is installed.");
|
|
4246
|
-
process.exit(1);
|
|
4247
|
-
}
|
|
4362
|
+
const UnpackingService = await loadUnpackingService();
|
|
4248
4363
|
const unpackingService = new UnpackingService();
|
|
4249
4364
|
const packages = await unpackingService.listPackages(rootDir);
|
|
4250
4365
|
if (packages.length === 0) {
|
|
@@ -4256,11 +4371,15 @@ async function listPacked() {
|
|
|
4256
4371
|
for (const pkg of packages) {
|
|
4257
4372
|
console.log(`${pkg.packageId} (${pkg.version})`);
|
|
4258
4373
|
console.log(` Source: ${pkg.source}`);
|
|
4259
|
-
console.log(` Entry: ${pkg.
|
|
4374
|
+
console.log(` Entry: ${pkg.entryAgents.join(", ")}`);
|
|
4260
4375
|
console.log(` Path: ${pkg.path}`);
|
|
4261
4376
|
console.log("");
|
|
4262
4377
|
}
|
|
4263
4378
|
}
|
|
4379
|
+
function registerUnpackCommands(program2) {
|
|
4380
|
+
program2.command("unpack [package]").description("Unpack a packed agent to the local agents directory").action(unpack);
|
|
4381
|
+
program2.command("list-packed").description("List all discovered packed agents").action(listPacked);
|
|
4382
|
+
}
|
|
4264
4383
|
var ARTIFACT_DEPLOY_REMOTE_NAME = "origin";
|
|
4265
4384
|
function normalizeGitRemoteHost(remote) {
|
|
4266
4385
|
try {
|
|
@@ -4331,8 +4450,8 @@ var PROJECT_SIGNAL_PATHS = [
|
|
|
4331
4450
|
"vite.config.mjs"
|
|
4332
4451
|
];
|
|
4333
4452
|
function hasProjectSignals(cwd) {
|
|
4334
|
-
const hits = PROJECT_SIGNAL_PATHS.filter((signal) =>
|
|
4335
|
-
return hits >= 2 ||
|
|
4453
|
+
const hits = PROJECT_SIGNAL_PATHS.filter((signal) => fs5.existsSync(path8.join(cwd, signal))).length;
|
|
4454
|
+
return hits >= 2 || fs5.existsSync(path8.join(cwd, ".agents"));
|
|
4336
4455
|
}
|
|
4337
4456
|
function detectCliDirectoryContext(cwd = process.cwd()) {
|
|
4338
4457
|
if (!hasProjectSignals(cwd)) {
|
|
@@ -4351,7 +4470,7 @@ function getContextLabel(context) {
|
|
|
4351
4470
|
case "inside_project_unlinked":
|
|
4352
4471
|
return "Project detected (unlinked)";
|
|
4353
4472
|
case "inside_project_linked":
|
|
4354
|
-
return "Linked
|
|
4473
|
+
return "Linked Standard Agents project";
|
|
4355
4474
|
default:
|
|
4356
4475
|
return "Unknown context";
|
|
4357
4476
|
}
|
|
@@ -4381,7 +4500,7 @@ function getHomeActions(context) {
|
|
|
4381
4500
|
{
|
|
4382
4501
|
id: "login",
|
|
4383
4502
|
label: "Link this project",
|
|
4384
|
-
description: "Authenticate and link this local project to a
|
|
4503
|
+
description: "Authenticate and link this local project to a Standard Agents org.",
|
|
4385
4504
|
argv: ["login"]
|
|
4386
4505
|
},
|
|
4387
4506
|
...shared
|
|
@@ -4391,7 +4510,7 @@ function getHomeActions(context) {
|
|
|
4391
4510
|
{
|
|
4392
4511
|
id: "deploy",
|
|
4393
4512
|
label: "Deploy",
|
|
4394
|
-
description: "Push this linked project to
|
|
4513
|
+
description: "Push this linked project to Standard Agents for a platform build.",
|
|
4395
4514
|
argv: ["deploy"]
|
|
4396
4515
|
},
|
|
4397
4516
|
{
|
|
@@ -4505,22 +4624,22 @@ async function runHomeTui(cwd = process.cwd()) {
|
|
|
4505
4624
|
}
|
|
4506
4625
|
var DEFAULT_SKILL_NAME = "agentbuilder";
|
|
4507
4626
|
function resolveCodexHome(env = process.env, homeDir = os3.homedir()) {
|
|
4508
|
-
return env.CODEX_HOME ||
|
|
4627
|
+
return env.CODEX_HOME || path8.join(homeDir, ".codex");
|
|
4509
4628
|
}
|
|
4510
4629
|
function resolveClaudeHome(homeDir = os3.homedir()) {
|
|
4511
|
-
return
|
|
4630
|
+
return path8.join(homeDir, ".claude");
|
|
4512
4631
|
}
|
|
4513
4632
|
function expandHomePath(inputPath, homeDir = os3.homedir()) {
|
|
4514
4633
|
if (inputPath === "~") {
|
|
4515
4634
|
return homeDir;
|
|
4516
4635
|
}
|
|
4517
4636
|
if (inputPath.startsWith("~/")) {
|
|
4518
|
-
return
|
|
4637
|
+
return path8.join(homeDir, inputPath.slice(2));
|
|
4519
4638
|
}
|
|
4520
4639
|
return inputPath;
|
|
4521
4640
|
}
|
|
4522
4641
|
function buildInstallTargets(options = {}, env = process.env, homeDir = os3.homedir()) {
|
|
4523
|
-
const customRoot = options.dir ?
|
|
4642
|
+
const customRoot = options.dir ? path8.resolve(expandHomePath(options.dir, homeDir)) : null;
|
|
4524
4643
|
const codexHome = resolveCodexHome(env, homeDir);
|
|
4525
4644
|
const claudeHome = resolveClaudeHome(homeDir);
|
|
4526
4645
|
return [
|
|
@@ -4528,15 +4647,15 @@ function buildInstallTargets(options = {}, env = process.env, homeDir = os3.home
|
|
|
4528
4647
|
id: "codex",
|
|
4529
4648
|
label: "Codex",
|
|
4530
4649
|
summary: "Install as a Codex skill folder",
|
|
4531
|
-
detected:
|
|
4532
|
-
installPath: customRoot ??
|
|
4650
|
+
detected: fs5.existsSync(codexHome),
|
|
4651
|
+
installPath: customRoot ?? path8.join(codexHome, "skills")
|
|
4533
4652
|
},
|
|
4534
4653
|
{
|
|
4535
4654
|
id: "claude",
|
|
4536
4655
|
label: "Claude Code",
|
|
4537
4656
|
summary: "Install as a Claude Code user subagent",
|
|
4538
|
-
detected:
|
|
4539
|
-
installPath: customRoot ??
|
|
4657
|
+
detected: fs5.existsSync(claudeHome),
|
|
4658
|
+
installPath: customRoot ?? path8.join(claudeHome, "agents")
|
|
4540
4659
|
}
|
|
4541
4660
|
];
|
|
4542
4661
|
}
|
|
@@ -4624,8 +4743,8 @@ async function selectInstallTarget(targets) {
|
|
|
4624
4743
|
async function installBundledSkill(targetId, skillName = DEFAULT_SKILL_NAME, options = {}) {
|
|
4625
4744
|
const target = resolveSelectedTarget(targetId, options);
|
|
4626
4745
|
if (target.id === "codex") {
|
|
4627
|
-
const targetDir =
|
|
4628
|
-
if (
|
|
4746
|
+
const targetDir = path8.join(target.installPath, skillName);
|
|
4747
|
+
if (fs5.existsSync(targetDir) && !options.force) {
|
|
4629
4748
|
throw new Error(
|
|
4630
4749
|
`Skill already exists at ${targetDir}. Re-run with --force to overwrite it.`
|
|
4631
4750
|
);
|
|
@@ -4634,8 +4753,8 @@ async function installBundledSkill(targetId, skillName = DEFAULT_SKILL_NAME, opt
|
|
|
4634
4753
|
overwrite: options.force ?? false
|
|
4635
4754
|
});
|
|
4636
4755
|
}
|
|
4637
|
-
const targetFile =
|
|
4638
|
-
if (
|
|
4756
|
+
const targetFile = path8.join(target.installPath, `${skillName}.md`);
|
|
4757
|
+
if (fs5.existsSync(targetFile) && !options.force) {
|
|
4639
4758
|
throw new Error(
|
|
4640
4759
|
`Claude subagent already exists at ${targetFile}. Re-run with --force to overwrite it.`
|
|
4641
4760
|
);
|
|
@@ -4646,8 +4765,8 @@ async function installBundledSkill(targetId, skillName = DEFAULT_SKILL_NAME, opt
|
|
|
4646
4765
|
"Use for Standard Agents and AgentBuilder architecture, composition, subagent design, and implementation work.",
|
|
4647
4766
|
skillBody
|
|
4648
4767
|
);
|
|
4649
|
-
|
|
4650
|
-
|
|
4768
|
+
fs5.mkdirSync(target.installPath, { recursive: true });
|
|
4769
|
+
fs5.writeFileSync(targetFile, subagentMarkdown, "utf8");
|
|
4651
4770
|
return targetFile;
|
|
4652
4771
|
}
|
|
4653
4772
|
function isInteractiveTerminal() {
|
|
@@ -4670,7 +4789,7 @@ async function skill(options = {}) {
|
|
|
4670
4789
|
logger.log("Next steps:");
|
|
4671
4790
|
if (selectedTarget.id === "codex") {
|
|
4672
4791
|
logger.log(" Restart Codex if it is already running");
|
|
4673
|
-
logger.log(` Edit ${
|
|
4792
|
+
logger.log(` Edit ${path8.join(installedPath, "SKILL.md")} to continue customizing the skill`);
|
|
4674
4793
|
} else {
|
|
4675
4794
|
logger.log(" Restart Claude Code if it is already running");
|
|
4676
4795
|
logger.log(` Edit ${installedPath} to continue customizing the subagent`);
|
|
@@ -4796,24 +4915,24 @@ function parseEnvFile(content) {
|
|
|
4796
4915
|
return result;
|
|
4797
4916
|
}
|
|
4798
4917
|
function findProjectRoot(startDir = process.cwd()) {
|
|
4799
|
-
let currentDir =
|
|
4918
|
+
let currentDir = path8.resolve(startDir);
|
|
4800
4919
|
while (true) {
|
|
4801
|
-
if (
|
|
4920
|
+
if (fs5.existsSync(path8.join(currentDir, "package.json"))) {
|
|
4802
4921
|
return currentDir;
|
|
4803
4922
|
}
|
|
4804
|
-
const parentDir =
|
|
4923
|
+
const parentDir = path8.dirname(currentDir);
|
|
4805
4924
|
if (parentDir === currentDir) {
|
|
4806
|
-
return
|
|
4925
|
+
return path8.resolve(startDir);
|
|
4807
4926
|
}
|
|
4808
4927
|
currentDir = parentDir;
|
|
4809
4928
|
}
|
|
4810
4929
|
}
|
|
4811
4930
|
function readProjectPackageJson(projectRoot) {
|
|
4812
|
-
const packagePath =
|
|
4813
|
-
if (!
|
|
4931
|
+
const packagePath = path8.join(projectRoot, "package.json");
|
|
4932
|
+
if (!fs5.existsSync(packagePath)) {
|
|
4814
4933
|
return {};
|
|
4815
4934
|
}
|
|
4816
|
-
return JSON.parse(
|
|
4935
|
+
return JSON.parse(fs5.readFileSync(packagePath, "utf8"));
|
|
4817
4936
|
}
|
|
4818
4937
|
function getDeclaredProviderPackages(projectRoot) {
|
|
4819
4938
|
const pkg = readProjectPackageJson(projectRoot);
|
|
@@ -4830,23 +4949,23 @@ function resolvePackageEntry(packageName, projectRoot) {
|
|
|
4830
4949
|
if (!packageDir) {
|
|
4831
4950
|
return null;
|
|
4832
4951
|
}
|
|
4833
|
-
const packageJsonPath =
|
|
4952
|
+
const packageJsonPath = path8.join(packageDir, "package.json");
|
|
4834
4953
|
try {
|
|
4835
|
-
const packageJson = JSON.parse(
|
|
4954
|
+
const packageJson = JSON.parse(fs5.readFileSync(packageJsonPath, "utf8"));
|
|
4836
4955
|
const exportPath = resolvePackageExportPath(packageJson.exports) || packageJson.main || "index.js";
|
|
4837
|
-
return
|
|
4956
|
+
return path8.join(packageDir, exportPath);
|
|
4838
4957
|
} catch {
|
|
4839
4958
|
return null;
|
|
4840
4959
|
}
|
|
4841
4960
|
}
|
|
4842
4961
|
function findInstalledPackageDir(packageName, projectRoot) {
|
|
4843
|
-
let currentDir =
|
|
4962
|
+
let currentDir = path8.resolve(projectRoot);
|
|
4844
4963
|
while (true) {
|
|
4845
|
-
const candidate =
|
|
4846
|
-
if (
|
|
4964
|
+
const candidate = path8.join(currentDir, "node_modules", ...packageName.split("/"));
|
|
4965
|
+
if (fs5.existsSync(candidate)) {
|
|
4847
4966
|
return candidate;
|
|
4848
4967
|
}
|
|
4849
|
-
const parentDir =
|
|
4968
|
+
const parentDir = path8.dirname(currentDir);
|
|
4850
4969
|
if (parentDir === currentDir) {
|
|
4851
4970
|
return null;
|
|
4852
4971
|
}
|
|
@@ -4878,9 +4997,9 @@ function loadProjectEnv(projectRoot, processEnv = process.env) {
|
|
|
4878
4997
|
const result = {};
|
|
4879
4998
|
const envFiles = [".env", ".env.local", ".dev.vars", ".dev.vars.local"];
|
|
4880
4999
|
for (const fileName of envFiles) {
|
|
4881
|
-
const filePath =
|
|
4882
|
-
if (!
|
|
4883
|
-
Object.assign(result, parseEnvFile(
|
|
5000
|
+
const filePath = path8.join(projectRoot, fileName);
|
|
5001
|
+
if (!fs5.existsSync(filePath)) continue;
|
|
5002
|
+
Object.assign(result, parseEnvFile(fs5.readFileSync(filePath, "utf8")));
|
|
4884
5003
|
}
|
|
4885
5004
|
for (const [key, value] of Object.entries(processEnv)) {
|
|
4886
5005
|
if (typeof value === "string") {
|
|
@@ -5143,11 +5262,11 @@ function parseKeyValueLines(input) {
|
|
|
5143
5262
|
return result;
|
|
5144
5263
|
}
|
|
5145
5264
|
function findDotDevVars(startDir = process.cwd()) {
|
|
5146
|
-
let current =
|
|
5265
|
+
let current = path8.resolve(startDir);
|
|
5147
5266
|
while (true) {
|
|
5148
|
-
const candidate =
|
|
5149
|
-
if (
|
|
5150
|
-
const parent =
|
|
5267
|
+
const candidate = path8.join(current, ".dev.vars");
|
|
5268
|
+
if (fs5.existsSync(candidate)) return candidate;
|
|
5269
|
+
const parent = path8.dirname(current);
|
|
5151
5270
|
if (parent === current) return null;
|
|
5152
5271
|
current = parent;
|
|
5153
5272
|
}
|
|
@@ -5164,7 +5283,7 @@ function isStandardAgentsGitHost(host) {
|
|
|
5164
5283
|
}
|
|
5165
5284
|
function loadLocalConfig(options) {
|
|
5166
5285
|
const envPath = findDotDevVars(options.startDir);
|
|
5167
|
-
const fileVars = envPath ? parseKeyValueLines(
|
|
5286
|
+
const fileVars = envPath ? parseKeyValueLines(fs5.readFileSync(envPath, "utf-8")) : {};
|
|
5168
5287
|
const endpoint = normalizeEndpoint(
|
|
5169
5288
|
options.endpoint || process.env.STANDARD_AGENTS_API_URL || process.env.PLATFORM_ENDPOINT || fileVars.STANDARD_AGENTS_API_URL || fileVars.PLATFORM_ENDPOINT || ""
|
|
5170
5289
|
);
|
|
@@ -5450,14 +5569,14 @@ function resolveDiagConfig(options, env = process.env, fetchImpl) {
|
|
|
5450
5569
|
const resolvedFetch = typeof fetchImpl === "function" ? fetchImpl : fetch;
|
|
5451
5570
|
return { endpoint, token, json: Boolean(options.json), fetchImpl: resolvedFetch };
|
|
5452
5571
|
}
|
|
5453
|
-
async function apiGet(config,
|
|
5454
|
-
return apiRequest(config,
|
|
5572
|
+
async function apiGet(config, path15) {
|
|
5573
|
+
return apiRequest(config, path15, "GET");
|
|
5455
5574
|
}
|
|
5456
|
-
async function apiRequest(config,
|
|
5575
|
+
async function apiRequest(config, path15, method, body) {
|
|
5457
5576
|
const headers = { Accept: "application/json" };
|
|
5458
5577
|
if (config.token) headers.Authorization = `Bearer ${config.token}`;
|
|
5459
5578
|
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
5460
|
-
const response = await config.fetchImpl(`${config.endpoint}${
|
|
5579
|
+
const response = await config.fetchImpl(`${config.endpoint}${path15}`, {
|
|
5461
5580
|
method,
|
|
5462
5581
|
headers,
|
|
5463
5582
|
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
@@ -5470,13 +5589,13 @@ async function apiRequest(config, path14, method, body) {
|
|
|
5470
5589
|
if (parsed.error) detail = parsed.error;
|
|
5471
5590
|
} catch {
|
|
5472
5591
|
}
|
|
5473
|
-
throw new Error(`${method} ${
|
|
5592
|
+
throw new Error(`${method} ${path15} \u2192 HTTP ${response.status}: ${detail}`);
|
|
5474
5593
|
}
|
|
5475
5594
|
try {
|
|
5476
5595
|
return JSON.parse(text);
|
|
5477
5596
|
} catch {
|
|
5478
5597
|
throw new Error(
|
|
5479
|
-
`${method} ${
|
|
5598
|
+
`${method} ${path15} returned non-JSON (is this an AgentBuilder instance URL?): ${text.slice(0, 120)}`
|
|
5480
5599
|
);
|
|
5481
5600
|
}
|
|
5482
5601
|
}
|
|
@@ -5825,9 +5944,11 @@ function wrapDiagAction(action) {
|
|
|
5825
5944
|
// src/index.ts
|
|
5826
5945
|
async function settleStdinForInitHandoff(stdin = process.stdin) {
|
|
5827
5946
|
if (!stdin.isTTY) return;
|
|
5828
|
-
|
|
5947
|
+
const listenerRemover = stdin;
|
|
5948
|
+
const inputEvents = ["data", "readable", "keypress"];
|
|
5949
|
+
for (const eventName of inputEvents) {
|
|
5829
5950
|
for (const listener of stdin.listeners(eventName)) {
|
|
5830
|
-
|
|
5951
|
+
listenerRemover.removeListener(eventName, listener);
|
|
5831
5952
|
}
|
|
5832
5953
|
}
|
|
5833
5954
|
if (stdin.isRaw) {
|
|
@@ -5841,15 +5962,14 @@ async function settleStdinForInitHandoff(stdin = process.stdin) {
|
|
|
5841
5962
|
}
|
|
5842
5963
|
}
|
|
5843
5964
|
var program = new Command();
|
|
5844
|
-
program.name("agents").description("CLI tool for Standard Agents / AgentBuilder").version("0.
|
|
5845
|
-
program.command("init [project-name]").description("Create a new Standard Agents project").option("-y, --yes", "Skip prompts and use defaults").option("--local", "Use local project scaffolding instead of browser platform onboarding").option("--cli", "Use classic line-by-line CLI prompts instead of the TUI wizard").option("--api-url <url>", "Standard Agents platform API URL").option("--endpoint <url>", "Platform API endpoint for auth/bootstrap exchange").option("--package-manager <manager>", "Package manager for generated project: npm, pnpm, yarn, or bun").option("--template <template>", "Vite template to use", "vanilla-ts").option("--workspace", "
|
|
5965
|
+
program.name("agents").description("CLI tool for Standard Agents / AgentBuilder").version("0.45.0");
|
|
5966
|
+
program.command("init [project-name]").description("Create a new Standard Agents project").option("-y, --yes", "Skip prompts and use defaults").option("--local", "Use local project scaffolding instead of browser platform onboarding").option("--cli", "Use classic line-by-line CLI prompts instead of the TUI wizard").option("--api-url <url>", "Standard Agents platform API URL").option("--endpoint <url>", "Platform API endpoint for auth/bootstrap exchange").option("--package-manager <manager>", "Package manager for generated project: npm, pnpm, yarn, or bun").option("--template <template>", "Vite template to use", "vanilla-ts").option("--workspace", "Link local @standardagents packages with pnpm outside workspace membership").option("--no-dev", "Clone and configure the project without starting the dev server").addOption(new Option("--bootstrap <code>", "Exchange a web onboarding bootstrap code")).action(init);
|
|
5846
5967
|
program.command("login").description("Authenticate this machine (or use --bootstrap for project bootstrap auth)").option("--bootstrap <code>", "Bootstrap code from web onboarding").option("--endpoint <url>", "Platform API endpoint (default: https://api.standardagents.ai)").option("--no-open", "Do not auto-open browser URL").action(login);
|
|
5847
|
-
program.command("logout").description("Clear stored
|
|
5968
|
+
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);
|
|
5848
5969
|
program.command("scaffold").description("Add Standard Agents to an existing Vite project").option("--force", "Overwrite existing configuration").action(scaffold);
|
|
5849
5970
|
program.command("init-chat [project-name]").description("Scaffold a frontend chat application").option("-y, --yes", "Skip prompts and use defaults").option("--framework <framework>", "Framework to use (vite or nextjs)").action(initChat);
|
|
5850
5971
|
registerPackCommand(program);
|
|
5851
|
-
program
|
|
5852
|
-
program.command("list-packed").description("List all discovered packed agents").action(listPacked);
|
|
5972
|
+
registerUnpackCommands(program);
|
|
5853
5973
|
program.command("deploy").description("Push the current branch to the Standard Agents Artifacts remote").action(deploy);
|
|
5854
5974
|
program.command("git-credential <operation>").description("Git credential helper for Standard Agents platform repositories").option("--endpoint <url>", "Platform API endpoint").action(gitCredential);
|
|
5855
5975
|
program.command("git-login").description("Authenticate Git for Standard Agents platform repositories").option("--bootstrap <code>", "Bootstrap code from web onboarding").option("--endpoint <url>", "Platform API endpoint (default: https://api.standardagents.ai)").option("--helper-command <command>", "Credential helper command to add to global git config").option("--no-config", "Store Git auth but do not update global git config").option("--no-open", "Do not auto-open browser URL").action(gitLogin);
|