@vm0/cli 4.24.0 → 4.25.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.
Files changed (2) hide show
  1. package/index.js +111 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -6,8 +6,8 @@ var __export = (target, all) => {
6
6
  };
7
7
 
8
8
  // src/index.ts
9
- import { Command as Command23 } from "commander";
10
- import chalk24 from "chalk";
9
+ import { Command as Command24 } from "commander";
10
+ import chalk25 from "chalk";
11
11
 
12
12
  // src/lib/auth.ts
13
13
  import chalk from "chalk";
@@ -16697,7 +16697,7 @@ async function autoPullArtifact(runOutput, artifactDir) {
16697
16697
  }
16698
16698
  var cookCmd = new Command13().name("cook").description("One-click agent preparation and execution from vm0.yaml");
16699
16699
  cookCmd.argument("[prompt]", "Prompt for the agent").action(async (prompt) => {
16700
- const shouldExit = await checkAndUpgrade("4.24.0", prompt);
16700
+ const shouldExit = await checkAndUpgrade("4.25.0", prompt);
16701
16701
  if (shouldExit) {
16702
16702
  process.exit(0);
16703
16703
  }
@@ -17700,11 +17700,115 @@ var setCommand = new Command21().name("set").description("Set your scope slug").
17700
17700
  // src/commands/scope/index.ts
17701
17701
  var scopeCommand = new Command22().name("scope").description("Manage your scope (namespace for images)").addCommand(statusCommand3).addCommand(setCommand);
17702
17702
 
17703
+ // src/commands/init.ts
17704
+ import { Command as Command23 } from "commander";
17705
+ import chalk24 from "chalk";
17706
+ import * as readline2 from "readline";
17707
+ import { existsSync as existsSync9 } from "fs";
17708
+ import { writeFile as writeFile7 } from "fs/promises";
17709
+ var VM0_YAML_FILE = "vm0.yaml";
17710
+ var AGENTS_MD_FILE = "AGENTS.md";
17711
+ function generateVm0Yaml(agentName) {
17712
+ return `version: "1.0"
17713
+
17714
+ agents:
17715
+ ${agentName}:
17716
+ provider: claude-code
17717
+ # Build agentic workflow using natural language
17718
+ instructions: AGENTS.md
17719
+ # Agent skills - see https://github.com/vm0-ai/vm0-skills for available skills
17720
+ # skills:
17721
+ # - https://github.com/vm0-ai/vm0-skills/tree/main/github
17722
+ environment:
17723
+ # Get token using: claude setup-token, then add to .env file
17724
+ CLAUDE_CODE_OAUTH_TOKEN: \${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
17725
+ `;
17726
+ }
17727
+ function generateAgentsMd() {
17728
+ return `# Agent Instructions
17729
+
17730
+ You are a HackerNews AI content curator.
17731
+
17732
+ ## Workflow
17733
+
17734
+ 1. Go to HackerNews and read the top 10 articles
17735
+ 2. Find and extract AI-related content from these articles
17736
+ 3. Summarize the findings into a X (Twitter) post format
17737
+ 4. Write the summary to content.md
17738
+ `;
17739
+ }
17740
+ function checkExistingFiles() {
17741
+ const existingFiles = [];
17742
+ if (existsSync9(VM0_YAML_FILE)) existingFiles.push(VM0_YAML_FILE);
17743
+ if (existsSync9(AGENTS_MD_FILE)) existingFiles.push(AGENTS_MD_FILE);
17744
+ return existingFiles;
17745
+ }
17746
+ async function promptAgentName() {
17747
+ const rl = readline2.createInterface({
17748
+ input: process.stdin,
17749
+ output: process.stdout
17750
+ });
17751
+ return new Promise((resolve2, reject) => {
17752
+ rl.question(chalk24.cyan("? Enter agent name: "), (answer) => {
17753
+ rl.close();
17754
+ resolve2(answer.trim());
17755
+ });
17756
+ rl.on("SIGINT", () => {
17757
+ rl.close();
17758
+ console.log();
17759
+ reject(new Error("User cancelled"));
17760
+ });
17761
+ });
17762
+ }
17763
+ var initCommand3 = new Command23().name("init").description("Initialize a new VM0 project in the current directory").option("-f, --force", "Overwrite existing files").option("-n, --name <name>", "Agent name (skips interactive prompt)").action(async (options) => {
17764
+ const existingFiles = checkExistingFiles();
17765
+ if (existingFiles.length > 0 && !options.force) {
17766
+ for (const file2 of existingFiles) {
17767
+ console.log(chalk24.red(`\u2717 ${file2} already exists`));
17768
+ }
17769
+ console.log();
17770
+ console.log(`To overwrite: ${chalk24.cyan("vm0 init --force")}`);
17771
+ process.exit(1);
17772
+ }
17773
+ let agentName;
17774
+ if (options.name) {
17775
+ agentName = options.name.trim();
17776
+ } else {
17777
+ try {
17778
+ agentName = await promptAgentName();
17779
+ } catch {
17780
+ process.exit(0);
17781
+ }
17782
+ }
17783
+ if (!agentName || !validateAgentName(agentName)) {
17784
+ console.log(chalk24.red("\u2717 Invalid agent name"));
17785
+ console.log(
17786
+ chalk24.gray(" Must be 3-64 characters, alphanumeric and hyphens only")
17787
+ );
17788
+ console.log(chalk24.gray(" Must start and end with letter or number"));
17789
+ process.exit(1);
17790
+ }
17791
+ await writeFile7(VM0_YAML_FILE, generateVm0Yaml(agentName));
17792
+ const vm0Status = existingFiles.includes(VM0_YAML_FILE) ? " (overwritten)" : "";
17793
+ console.log(chalk24.green(`\u2713 Created ${VM0_YAML_FILE}${vm0Status}`));
17794
+ await writeFile7(AGENTS_MD_FILE, generateAgentsMd());
17795
+ const agentsStatus = existingFiles.includes(AGENTS_MD_FILE) ? " (overwritten)" : "";
17796
+ console.log(chalk24.green(`\u2713 Created ${AGENTS_MD_FILE}${agentsStatus}`));
17797
+ console.log();
17798
+ console.log("Next steps:");
17799
+ console.log(
17800
+ ` 1. Get your Claude Code token: ${chalk24.cyan("claude setup-token")}`
17801
+ );
17802
+ console.log(` 2. Set the environment variable (or add to .env file):`);
17803
+ console.log(chalk24.gray(` export CLAUDE_CODE_OAUTH_TOKEN=<your-token>`));
17804
+ console.log(` 3. Run your agent: ${chalk24.cyan('vm0 cook "your prompt"')}`);
17805
+ });
17806
+
17703
17807
  // src/index.ts
17704
- var program = new Command23();
17705
- program.name("vm0").description("VM0 CLI - A modern build tool").version("4.24.0");
17808
+ var program = new Command24();
17809
+ program.name("vm0").description("VM0 CLI - A modern build tool").version("4.25.0");
17706
17810
  program.command("info").description("Display environment information").action(async () => {
17707
- console.log(chalk24.cyan("System Information:"));
17811
+ console.log(chalk25.cyan("System Information:"));
17708
17812
  console.log(`Node Version: ${process.version}`);
17709
17813
  console.log(`Platform: ${process.platform}`);
17710
17814
  console.log(`Architecture: ${process.arch}`);
@@ -17732,6 +17836,7 @@ program.addCommand(cookCommand);
17732
17836
  program.addCommand(imageCommand);
17733
17837
  program.addCommand(logsCommand);
17734
17838
  program.addCommand(scopeCommand);
17839
+ program.addCommand(initCommand3);
17735
17840
  if (process.argv[1]?.endsWith("index.js") || process.argv[1]?.endsWith("index.ts") || process.argv[1]?.endsWith("vm0")) {
17736
17841
  program.parse();
17737
17842
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vm0/cli",
3
- "version": "4.24.0",
3
+ "version": "4.25.0",
4
4
  "description": "CLI application",
5
5
  "repository": {
6
6
  "type": "git",