@standardagents/cli 0.11.0-next.56def20 → 0.11.0-next.5d2e71b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from 'commander';
3
- import path3 from 'path';
4
- import fs3 from 'fs';
3
+ import fs3, { readFileSync } from 'fs';
4
+ import path3, { dirname, resolve } from 'path';
5
+ import { fileURLToPath } from 'url';
5
6
  import crypto from 'crypto';
6
7
  import readline from 'readline';
7
8
  import { spawn } from 'child_process';
@@ -10,7 +11,6 @@ import { parse, modify, applyEdits } from 'jsonc-parser';
10
11
  import { loadFile, writeFile, generateCode } from 'magicast';
11
12
  import { addVitePlugin } from 'magicast/helpers';
12
13
  import net from 'net';
13
- import { fileURLToPath } from 'url';
14
14
 
15
15
  var logger = {
16
16
  success: (message) => {
@@ -116,32 +116,30 @@ agents/
116
116
 
117
117
  Files are **auto-discovered** at runtime. No manual registration needed.
118
118
 
119
- ## ThreadState
119
+ ## FlowState
120
120
 
121
- \`ThreadState\` is the state object available in tools and hooks:
121
+ \`FlowState\` is the central state object available in tools and hooks:
122
122
 
123
123
  \`\`\`typescript
124
- interface ThreadState {
125
- // Identity (readonly)
126
- threadId: string; // Thread identifier
127
- agentId: string; // Agent identifier
128
- userId: string | null; // User identifier (if set)
129
- createdAt: number; // Creation timestamp
130
-
131
- // Methods
132
- getMessages(options?): Promise<MessagesResult>; // Get conversation history
133
- injectMessage(input): Promise<Message>; // Add message to thread
134
- loadModel(name): Promise<ModelConfig>; // Load model definition
135
- loadPrompt(name): Promise<PromptConfig>; // Load prompt definition
136
- loadAgent(name): Promise<AgentConfig>; // Load agent definition
124
+ interface FlowState {
125
+ thread: {
126
+ id: string; // Thread identifier
127
+ instance: DurableThread; // Durable Object instance
128
+ };
129
+ agent: AgentConfig; // Current agent configuration
130
+ prompt: PromptConfig; // Current prompt configuration
131
+ model: ModelConfig; // Current model configuration
132
+ messages: Message[]; // Conversation history
133
+ env: Env; // Cloudflare Worker environment
134
+ rootState: FlowState; // Parent state (for sub-prompts)
137
135
  }
138
136
  \`\`\`
139
137
 
140
138
  Access in tools:
141
139
  \`\`\`typescript
142
140
  export default defineTool('...', schema, async (flow, args) => {
143
- const threadId = flow.threadId;
144
- const { messages } = await flow.getMessages();
141
+ const threadId = flow.thread.id;
142
+ const messages = flow.messages;
145
143
  // ...
146
144
  });
147
145
  \`\`\`
@@ -527,12 +525,12 @@ Tools extend agent capabilities beyond text generation. They allow LLMs to fetch
527
525
  ## Function Signature
528
526
 
529
527
  \`\`\`typescript
530
- defineTool({
528
+ defineTool(
531
529
  description: string, // What the tool does (shown to LLM)
532
- args?: z.ZodObject, // Input validation schema (optional)
533
- execute: (state, args) => ToolResult, // Implementation
534
- tenvs?: z.ZodObject, // Thread environment variables (optional)
535
- })
530
+ args: z.ZodObject, // Input validation schema
531
+ handler: (flow, args) => ToolResult, // Implementation
532
+ returnSchema?: z.ZodObject // Optional output schema
533
+ )
536
534
  \`\`\`
537
535
 
538
536
  ## Basic Example
@@ -541,20 +539,20 @@ defineTool({
541
539
  import { defineTool } from '@standardagents/builder';
542
540
  import { z } from 'zod';
543
541
 
544
- export default defineTool({
545
- description: 'Search the knowledge base for articles matching a query',
546
- args: z.object({
542
+ export default defineTool(
543
+ 'Search the knowledge base for articles matching a query',
544
+ z.object({
547
545
  query: z.string().describe('Search query'),
548
546
  limit: z.number().optional().default(10).describe('Max results'),
549
547
  }),
550
- execute: async (state, args) => {
548
+ async (flow, args) => {
551
549
  const results = await searchKB(args.query, args.limit);
552
550
  return {
553
551
  status: 'success',
554
552
  result: JSON.stringify(results),
555
553
  };
556
- },
557
- });
554
+ }
555
+ );
558
556
  \`\`\`
559
557
 
560
558
  ## ToolResult Interface
@@ -564,45 +562,44 @@ export default defineTool({
564
562
  | \`status\` | \`'success' \\| 'error'\` | Whether the tool succeeded |
565
563
  | \`result\` | \`string\` | Tool output (required for success) |
566
564
  | \`error\` | \`string\` | Error message (for error status) |
567
- | \`attachments\` | \`ToolAttachment[]\` | Files to attach (images, etc.) |
568
565
 
569
- ## ThreadState Access
566
+ ## FlowState Access
570
567
 
571
- The \`state\` parameter provides access to:
568
+ The \`flow\` parameter provides access to:
572
569
 
573
570
  \`\`\`typescript
574
- execute: async (state, args) => {
571
+ async (flow, args) => {
575
572
  // Thread information
576
- const threadId = state.thread.id;
577
- const thread = state.thread.instance;
573
+ const threadId = flow.thread.id;
574
+ const thread = flow.thread.instance;
578
575
 
579
576
  // Configuration
580
- const agentName = state.agent.name;
581
- const modelName = state.model.name;
577
+ const agentName = flow.agent.name;
578
+ const modelName = flow.model.name;
582
579
 
583
580
  // Message history
584
- const messages = state.messages;
581
+ const messages = flow.messages;
585
582
 
586
583
  // Environment bindings
587
- const env = state.env;
584
+ const env = flow.env;
588
585
 
589
586
  // Parent state (for sub-prompts)
590
- const root = state.rootState;
587
+ const root = flow.rootState;
591
588
  }
592
589
  \`\`\`
593
590
 
594
591
  ## Tool Without Arguments
595
592
 
596
593
  \`\`\`typescript
597
- export default defineTool({
598
- description: 'Get current server time',
599
- execute: async (state) => {
594
+ export default defineTool(
595
+ 'Get current server time',
596
+ async (flow) => {
600
597
  return {
601
598
  status: 'success',
602
599
  result: new Date().toISOString(),
603
600
  };
604
- },
605
- });
601
+ }
602
+ );
606
603
  \`\`\`
607
604
 
608
605
  ## Error Handling
@@ -610,10 +607,10 @@ export default defineTool({
610
607
  Return errors gracefully instead of throwing:
611
608
 
612
609
  \`\`\`typescript
613
- export default defineTool({
614
- description: 'Fetch user data',
615
- args: z.object({ userId: z.string() }),
616
- execute: async (state, args) => {
610
+ export default defineTool(
611
+ 'Fetch user data',
612
+ z.object({ userId: z.string() }),
613
+ async (flow, args) => {
617
614
  try {
618
615
  const user = await fetchUser(args.userId);
619
616
  return { status: 'success', result: JSON.stringify(user) };
@@ -623,8 +620,8 @@ export default defineTool({
623
620
  error: \`Failed to fetch user: \${error.message}\`,
624
621
  };
625
622
  }
626
- },
627
- });
623
+ }
624
+ );
628
625
  \`\`\`
629
626
 
630
627
  ## Queueing Additional Tools
@@ -634,21 +631,21 @@ Queue another tool to run after the current one:
634
631
  \`\`\`typescript
635
632
  import { queueTool } from '@standardagents/builder';
636
633
 
637
- export default defineTool({
638
- description: 'Create order and send confirmation',
639
- args: z.object({ items: z.array(z.string()) }),
640
- execute: async (state, args) => {
634
+ export default defineTool(
635
+ 'Create order and send confirmation',
636
+ z.object({ items: z.array(z.string()) }),
637
+ async (flow, args) => {
641
638
  const order = await createOrder(args.items);
642
639
 
643
640
  // Queue email tool to run next
644
- queueTool(state, 'send_confirmation_email', {
641
+ queueTool(flow, 'send_confirmation_email', {
645
642
  orderId: order.id,
646
- email: state.thread.metadata.userEmail,
643
+ email: flow.thread.metadata.userEmail,
647
644
  });
648
645
 
649
646
  return { status: 'success', result: JSON.stringify(order) };
650
- },
651
- });
647
+ }
648
+ );
652
649
  \`\`\`
653
650
 
654
651
  ## Injecting Messages
@@ -658,61 +655,17 @@ Add messages without triggering re-execution:
658
655
  \`\`\`typescript
659
656
  import { injectMessage } from '@standardagents/builder';
660
657
 
661
- export default defineTool({
662
- description: 'Log audit event',
663
- args: z.object({ event: z.string() }),
664
- execute: async (state, args) => {
665
- await injectMessage(state, {
658
+ export default defineTool(
659
+ 'Log audit event',
660
+ z.object({ event: z.string() }),
661
+ async (flow, args) => {
662
+ await injectMessage(flow, {
666
663
  role: 'system',
667
664
  content: \`[AUDIT] \${args.event}\`,
668
665
  });
669
666
  return { status: 'success', result: 'Logged' };
670
- },
671
- });
672
- \`\`\`
673
-
674
- ## Thread Environment Variables (tenvs)
675
-
676
- Tools can declare required thread environment variables:
677
-
678
- \`\`\`typescript
679
- export default defineTool({
680
- description: 'Search uploaded documents',
681
- args: z.object({ query: z.string() }),
682
- execute: async (state, args) => {
683
- const vectorStoreId = state.tenvs.vectorStoreId;
684
- const results = await searchVectorStore(vectorStoreId, args.query);
685
- return { status: 'success', result: JSON.stringify(results) };
686
- },
687
- tenvs: z.object({
688
- vectorStoreId: z.string().describe('OpenAI Vector Store ID'),
689
- }),
690
- });
691
- \`\`\`
692
-
693
- ## Returning Attachments
694
-
695
- Tools can return file attachments (e.g., generated images):
696
-
697
- \`\`\`typescript
698
- export default defineTool({
699
- description: 'Generate a chart from data',
700
- args: z.object({ data: z.array(z.number()) }),
701
- execute: async (state, args) => {
702
- const chartImage = await generateChart(args.data);
703
- return {
704
- status: 'success',
705
- result: 'Chart generated successfully',
706
- attachments: [{
707
- name: 'chart.png',
708
- mimeType: 'image/png',
709
- data: chartImage.base64,
710
- width: 800,
711
- height: 600,
712
- }],
713
- };
714
- },
715
- });
667
+ }
668
+ );
716
669
  \`\`\`
717
670
 
718
671
  ## Best Practices
@@ -722,7 +675,7 @@ export default defineTool({
722
675
  - **Handle errors gracefully** - return error status, don't throw
723
676
  - **Use snake_case** for file names (\`search_knowledge_base.ts\`)
724
677
  - **Keep tools focused** - one task per tool
725
- - **Use \`state.rootState\`** when queueing from sub-prompts
678
+ - **Use \`flow.rootState\`** when queueing from sub-prompts
726
679
 
727
680
  ## Supported Zod Types
728
681
 
@@ -1093,9 +1046,9 @@ function getProjectName(cwd) {
1093
1046
  const packageJsonPath = path3.join(cwd, "package.json");
1094
1047
  if (fs3.existsSync(packageJsonPath)) {
1095
1048
  try {
1096
- const pkg = JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8"));
1097
- if (pkg.name) {
1098
- return pkg.name.replace(/^@[^/]+\//, "");
1049
+ const pkg2 = JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8"));
1050
+ if (pkg2.name) {
1051
+ return pkg2.name.replace(/^@[^/]+\//, "");
1099
1052
  }
1100
1053
  } catch {
1101
1054
  }
@@ -1480,15 +1433,15 @@ async function prompt(question) {
1480
1433
  input: process.stdin,
1481
1434
  output: process.stdout
1482
1435
  });
1483
- return new Promise((resolve) => {
1436
+ return new Promise((resolve2) => {
1484
1437
  rl.question(question, (answer) => {
1485
1438
  rl.close();
1486
- resolve(answer.trim());
1439
+ resolve2(answer.trim());
1487
1440
  });
1488
1441
  });
1489
1442
  }
1490
1443
  async function promptPassword(question) {
1491
- return new Promise((resolve) => {
1444
+ return new Promise((resolve2) => {
1492
1445
  const stdin = process.stdin;
1493
1446
  const stdout = process.stdout;
1494
1447
  stdout.write(question);
@@ -1509,7 +1462,7 @@ async function promptPassword(question) {
1509
1462
  stdin.pause();
1510
1463
  stdin.removeListener("data", onData);
1511
1464
  stdout.write("\n");
1512
- resolve(password);
1465
+ resolve2(password);
1513
1466
  break;
1514
1467
  case "":
1515
1468
  stdout.write("\n");
@@ -1535,7 +1488,7 @@ async function promptPassword(question) {
1535
1488
  });
1536
1489
  }
1537
1490
  function runCommand(command, args, cwd) {
1538
- return new Promise((resolve, reject) => {
1491
+ return new Promise((resolve2, reject) => {
1539
1492
  const child = spawn(command, args, {
1540
1493
  cwd,
1541
1494
  stdio: "inherit",
@@ -1543,7 +1496,7 @@ function runCommand(command, args, cwd) {
1543
1496
  });
1544
1497
  child.on("close", (code) => {
1545
1498
  if (code === 0) {
1546
- resolve();
1499
+ resolve2();
1547
1500
  } else {
1548
1501
  reject(new Error(`Command failed with exit code ${code}`));
1549
1502
  }
@@ -1567,16 +1520,25 @@ function detectPackageManager() {
1567
1520
  if (fs3.existsSync("package-lock.json")) return "npm";
1568
1521
  return "npm";
1569
1522
  }
1570
- function getPackageVersion() {
1571
- if (process.env.STANDARDAGENTS_WORKSPACE === "1") {
1572
- return "workspace:*";
1523
+ function getBuilderPackageVersion() {
1524
+ try {
1525
+ const __dirname2 = path3.dirname(fileURLToPath(import.meta.url));
1526
+ const pkgPath = path3.resolve(__dirname2, "../../package.json");
1527
+ const pkg2 = JSON.parse(fs3.readFileSync(pkgPath, "utf-8"));
1528
+ const version = pkg2.version;
1529
+ const prereleaseMatch = version.match(/-([a-z]+)\./i);
1530
+ if (prereleaseMatch) {
1531
+ return `@${prereleaseMatch[1]}`;
1532
+ }
1533
+ return `@^${version}`;
1534
+ } catch {
1535
+ return "";
1573
1536
  }
1574
- return "0.11.0-next.56def20";
1575
1537
  }
1576
1538
  async function selectPackageManager(detected) {
1577
1539
  const options = ["npm", "pnpm", "yarn", "bun"];
1578
1540
  const detectedIndex = options.indexOf(detected);
1579
- return new Promise((resolve) => {
1541
+ return new Promise((resolve2) => {
1580
1542
  const stdin = process.stdin;
1581
1543
  const stdout = process.stdout;
1582
1544
  let selectedIndex = detectedIndex;
@@ -1622,7 +1584,7 @@ async function selectPackageManager(detected) {
1622
1584
  renderOptions();
1623
1585
  } else if (key === "\r" || key === "\n") {
1624
1586
  cleanup();
1625
- resolve(options[selectedIndex]);
1587
+ resolve2(options[selectedIndex]);
1626
1588
  } else if (key === "") {
1627
1589
  cleanup();
1628
1590
  stdout.write("\n");
@@ -1708,7 +1670,34 @@ export default defineConfig({
1708
1670
  }
1709
1671
  }
1710
1672
  logger.log("");
1711
- logger.info("Step 2: Configuring environment variables...");
1673
+ logger.info("Step 2: Installing Standard Agents dependencies...");
1674
+ logger.log("");
1675
+ try {
1676
+ const installCmd = pm === "npm" ? "install" : "add";
1677
+ const devFlag = pm === "npm" ? "--save-dev" : "-D";
1678
+ const builderVersion = getBuilderPackageVersion();
1679
+ await runCommand(pm, [
1680
+ installCmd,
1681
+ devFlag,
1682
+ "@cloudflare/vite-plugin",
1683
+ "wrangler"
1684
+ ], projectPath);
1685
+ await runCommand(pm, [
1686
+ installCmd,
1687
+ `@standardagents/builder${builderVersion}`,
1688
+ "zod"
1689
+ ], projectPath);
1690
+ } catch (error) {
1691
+ logger.error("Failed to install dependencies");
1692
+ process.exit(1);
1693
+ }
1694
+ logger.log("");
1695
+ logger.info("Step 3: Configuring Standard Agents...");
1696
+ logger.log("");
1697
+ process.chdir(projectPath);
1698
+ await scaffold({ force: true });
1699
+ logger.log("");
1700
+ logger.info("Step 4: Configuring environment variables...");
1712
1701
  logger.log("");
1713
1702
  const encryptionKey = crypto.randomBytes(32).toString("hex");
1714
1703
  let openrouterKey = "";
@@ -1743,44 +1732,6 @@ export default defineConfig({
1743
1732
  if (!adminPassword) {
1744
1733
  adminPassword = "admin";
1745
1734
  }
1746
- logger.log("");
1747
- logger.info("Step 3: Installing Standard Agents dependencies...");
1748
- logger.log("");
1749
- try {
1750
- const installCmd = pm === "npm" ? "install" : "add";
1751
- const devFlag = pm === "npm" ? "--save-dev" : "-D";
1752
- const packageVersion = getPackageVersion();
1753
- await runCommand(pm, [
1754
- installCmd,
1755
- devFlag,
1756
- "@cloudflare/vite-plugin",
1757
- "wrangler"
1758
- ], projectPath);
1759
- const deps = [
1760
- `@standardagents/builder@${packageVersion}`,
1761
- `@standardagents/spec@${packageVersion}`,
1762
- `@standardagents/sip@${packageVersion}`,
1763
- "zod"
1764
- ];
1765
- if (openaiKey) {
1766
- deps.push(`@standardagents/openai@${packageVersion}`);
1767
- }
1768
- if (openrouterKey) {
1769
- deps.push(`@standardagents/openrouter@${packageVersion}`);
1770
- }
1771
- await runCommand(pm, [installCmd, ...deps], projectPath);
1772
- } catch (error) {
1773
- logger.error("Failed to install dependencies");
1774
- process.exit(1);
1775
- }
1776
- logger.log("");
1777
- logger.info("Step 4: Configuring Standard Agents...");
1778
- logger.log("");
1779
- process.chdir(projectPath);
1780
- await scaffold({ force: true });
1781
- logger.log("");
1782
- logger.info("Writing environment configuration...");
1783
- logger.log("");
1784
1735
  const devVarsLines = [
1785
1736
  "# Standard Agents Environment Variables",
1786
1737
  "# This file contains secrets for local development only",
@@ -1837,10 +1788,10 @@ export default defineConfig({
1837
1788
  }
1838
1789
  function getReactPackageVersion() {
1839
1790
  try {
1840
- const __dirname = path3.dirname(fileURLToPath(import.meta.url));
1841
- const pkgPath = path3.resolve(__dirname, "../package.json");
1842
- const pkg = JSON.parse(fs3.readFileSync(pkgPath, "utf-8"));
1843
- const version = pkg.version;
1791
+ const __dirname2 = path3.dirname(fileURLToPath(import.meta.url));
1792
+ const pkgPath = path3.resolve(__dirname2, "../package.json");
1793
+ const pkg2 = JSON.parse(fs3.readFileSync(pkgPath, "utf-8"));
1794
+ const version = pkg2.version;
1844
1795
  const prereleaseMatch = version.match(/-([a-z]+)\./i);
1845
1796
  if (prereleaseMatch) {
1846
1797
  return prereleaseMatch[1];
@@ -1851,23 +1802,23 @@ function getReactPackageVersion() {
1851
1802
  }
1852
1803
  }
1853
1804
  function getChatSourceDir() {
1854
- const __dirname = path3.dirname(fileURLToPath(import.meta.url));
1855
- return path3.resolve(__dirname, "../chat");
1805
+ const __dirname2 = path3.dirname(fileURLToPath(import.meta.url));
1806
+ return path3.resolve(__dirname2, "../chat");
1856
1807
  }
1857
1808
  async function prompt2(question) {
1858
1809
  const rl = readline.createInterface({
1859
1810
  input: process.stdin,
1860
1811
  output: process.stdout
1861
1812
  });
1862
- return new Promise((resolve) => {
1813
+ return new Promise((resolve2) => {
1863
1814
  rl.question(question, (answer) => {
1864
1815
  rl.close();
1865
- resolve(answer.trim());
1816
+ resolve2(answer.trim());
1866
1817
  });
1867
1818
  });
1868
1819
  }
1869
1820
  function runCommand2(command, args, cwd) {
1870
- return new Promise((resolve, reject) => {
1821
+ return new Promise((resolve2, reject) => {
1871
1822
  const child = spawn(command, args, {
1872
1823
  cwd,
1873
1824
  stdio: "inherit",
@@ -1875,7 +1826,7 @@ function runCommand2(command, args, cwd) {
1875
1826
  });
1876
1827
  child.on("close", (code) => {
1877
1828
  if (code === 0) {
1878
- resolve();
1829
+ resolve2();
1879
1830
  } else {
1880
1831
  reject(new Error(`Command failed with exit code ${code}`));
1881
1832
  }
@@ -1899,7 +1850,7 @@ function detectPackageManager2() {
1899
1850
  async function selectPackageManager2(detected) {
1900
1851
  const options = ["npm", "pnpm", "yarn", "bun"];
1901
1852
  const detectedIndex = options.indexOf(detected);
1902
- return new Promise((resolve) => {
1853
+ return new Promise((resolve2) => {
1903
1854
  const stdin = process.stdin;
1904
1855
  const stdout = process.stdout;
1905
1856
  let selectedIndex = detectedIndex;
@@ -1945,7 +1896,7 @@ async function selectPackageManager2(detected) {
1945
1896
  renderOptions();
1946
1897
  } else if (key === "\r" || key === "\n") {
1947
1898
  cleanup();
1948
- resolve(options[selectedIndex]);
1899
+ resolve2(options[selectedIndex]);
1949
1900
  } else if (key === "") {
1950
1901
  cleanup();
1951
1902
  stdout.write("\n");
@@ -1960,7 +1911,7 @@ async function selectFramework() {
1960
1911
  { value: "vite", label: "Vite (React + TypeScript)" },
1961
1912
  { value: "nextjs", label: "Next.js (App Router)" }
1962
1913
  ];
1963
- return new Promise((resolve) => {
1914
+ return new Promise((resolve2) => {
1964
1915
  const stdin = process.stdin;
1965
1916
  const stdout = process.stdout;
1966
1917
  let selectedIndex = 0;
@@ -2004,7 +1955,7 @@ async function selectFramework() {
2004
1955
  renderOptions();
2005
1956
  } else if (key === "\r" || key === "\n") {
2006
1957
  cleanup();
2007
- resolve(options[selectedIndex].value);
1958
+ resolve2(options[selectedIndex].value);
2008
1959
  } else if (key === "") {
2009
1960
  cleanup();
2010
1961
  stdout.write("\n");
@@ -2024,20 +1975,20 @@ function isValidUrl(url) {
2024
1975
  }
2025
1976
  async function isPortOpen(port) {
2026
1977
  const tryConnect = (host) => {
2027
- return new Promise((resolve) => {
1978
+ return new Promise((resolve2) => {
2028
1979
  const socket = new net.Socket();
2029
1980
  socket.setTimeout(200);
2030
1981
  socket.on("connect", () => {
2031
1982
  socket.destroy();
2032
- resolve(true);
1983
+ resolve2(true);
2033
1984
  });
2034
1985
  socket.on("timeout", () => {
2035
1986
  socket.destroy();
2036
- resolve(false);
1987
+ resolve2(false);
2037
1988
  });
2038
1989
  socket.on("error", () => {
2039
1990
  socket.destroy();
2040
- resolve(false);
1991
+ resolve2(false);
2041
1992
  });
2042
1993
  socket.connect(port, host);
2043
1994
  });
@@ -2261,21 +2212,21 @@ export default defineConfig({
2261
2212
  fs3.writeFileSync(path3.join(projectPath, "tsconfig.json"), JSON.stringify(tsconfig, null, 2) + "\n", "utf-8");
2262
2213
  logger.success("Created tsconfig.json");
2263
2214
  fs3.copyFileSync(path3.join(chatSourceDir, "package.json"), path3.join(projectPath, "package.json"));
2264
- const pkg = JSON.parse(fs3.readFileSync(path3.join(projectPath, "package.json"), "utf-8"));
2265
- pkg.name = projectName;
2266
- pkg.scripts = {
2215
+ const pkg2 = JSON.parse(fs3.readFileSync(path3.join(projectPath, "package.json"), "utf-8"));
2216
+ pkg2.name = projectName;
2217
+ pkg2.scripts = {
2267
2218
  dev: "vite",
2268
2219
  build: "vite build",
2269
2220
  preview: "vite preview"
2270
2221
  };
2271
- delete pkg.private;
2272
- if (pkg.dependencies?.["@standardagents/react"]) {
2273
- pkg.dependencies["@standardagents/react"] = reactVersion;
2274
- }
2275
- delete pkg.dependencies?.["next"];
2276
- delete pkg.devDependencies?.["@tailwindcss/postcss"];
2277
- delete pkg.devDependencies?.["postcss"];
2278
- fs3.writeFileSync(path3.join(projectPath, "package.json"), JSON.stringify(pkg, null, 2) + "\n", "utf-8");
2222
+ delete pkg2.private;
2223
+ if (pkg2.dependencies?.["@standardagents/react"]) {
2224
+ pkg2.dependencies["@standardagents/react"] = reactVersion;
2225
+ }
2226
+ delete pkg2.dependencies?.["next"];
2227
+ delete pkg2.devDependencies?.["@tailwindcss/postcss"];
2228
+ delete pkg2.devDependencies?.["postcss"];
2229
+ fs3.writeFileSync(path3.join(projectPath, "package.json"), JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
2279
2230
  logger.success("Created package.json");
2280
2231
  const envContent = `# Agentbuilder connection
2281
2232
  VITE_AGENTBUILDER_URL=${serverUrl}
@@ -2330,21 +2281,21 @@ async function scaffoldNextjs(projectPath, chatSourceDir, projectName, serverUrl
2330
2281
  };
2331
2282
  fs3.writeFileSync(path3.join(projectPath, "tsconfig.json"), JSON.stringify(tsconfig, null, 2) + "\n", "utf-8");
2332
2283
  logger.success("Created tsconfig.json");
2333
- const pkg = JSON.parse(fs3.readFileSync(path3.join(chatSourceDir, "package.json"), "utf-8"));
2334
- pkg.name = projectName;
2335
- pkg.scripts = {
2284
+ const pkg2 = JSON.parse(fs3.readFileSync(path3.join(chatSourceDir, "package.json"), "utf-8"));
2285
+ pkg2.name = projectName;
2286
+ pkg2.scripts = {
2336
2287
  dev: "next dev",
2337
2288
  build: "next build",
2338
2289
  start: "next start"
2339
2290
  };
2340
- delete pkg.private;
2341
- if (pkg.dependencies?.["@standardagents/react"]) {
2342
- pkg.dependencies["@standardagents/react"] = reactVersion;
2343
- }
2344
- delete pkg.devDependencies?.["@tailwindcss/vite"];
2345
- delete pkg.devDependencies?.["@vitejs/plugin-react"];
2346
- delete pkg.devDependencies?.["vite"];
2347
- fs3.writeFileSync(path3.join(projectPath, "package.json"), JSON.stringify(pkg, null, 2) + "\n", "utf-8");
2291
+ delete pkg2.private;
2292
+ if (pkg2.dependencies?.["@standardagents/react"]) {
2293
+ pkg2.dependencies["@standardagents/react"] = reactVersion;
2294
+ }
2295
+ delete pkg2.devDependencies?.["@tailwindcss/vite"];
2296
+ delete pkg2.devDependencies?.["@vitejs/plugin-react"];
2297
+ delete pkg2.devDependencies?.["vite"];
2298
+ fs3.writeFileSync(path3.join(projectPath, "package.json"), JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
2348
2299
  logger.success("Created package.json");
2349
2300
  const envContent = `# Agentbuilder connection
2350
2301
  NEXT_PUBLIC_AGENTBUILDER_URL=${serverUrl}
@@ -2366,8 +2317,10 @@ out
2366
2317
  }
2367
2318
 
2368
2319
  // src/index.ts
2320
+ var __dirname$1 = dirname(fileURLToPath(import.meta.url));
2321
+ var pkg = JSON.parse(readFileSync(resolve(__dirname$1, "../package.json"), "utf-8"));
2369
2322
  var program = new Command();
2370
- program.name("agents").description("CLI tool for Standard Agents / AgentBuilder").version("0.11.0-next.56def20");
2323
+ program.name("agents").description("CLI tool for Standard Agents / AgentBuilder").version(pkg.version);
2371
2324
  program.command("init [project-name]").description("Create a new Standard Agents project (runs create vite, then scaffold)").option("-y, --yes", "Skip prompts and use defaults").option("--template <template>", "Vite template to use", "vanilla-ts").action(init);
2372
2325
  program.command("scaffold").description("Add Standard Agents to an existing Vite project").option("--force", "Overwrite existing configuration").action(scaffold);
2373
2326
  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);