@vm0/cli 4.33.0 → 4.35.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 +75 -38
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -984,10 +984,10 @@ function mergeDefs(...defs) {
984
984
  function cloneDef(schema) {
985
985
  return mergeDefs(schema._zod.def);
986
986
  }
987
- function getElementAtPath(obj, path14) {
988
- if (!path14)
987
+ function getElementAtPath(obj, path15) {
988
+ if (!path15)
989
989
  return obj;
990
- return path14.reduce((acc, key) => acc?.[key], obj);
990
+ return path15.reduce((acc, key) => acc?.[key], obj);
991
991
  }
992
992
  function promiseAllObject(promisesObj) {
993
993
  const keys = Object.keys(promisesObj);
@@ -1346,11 +1346,11 @@ function aborted(x, startIndex = 0) {
1346
1346
  }
1347
1347
  return false;
1348
1348
  }
1349
- function prefixIssues(path14, issues) {
1349
+ function prefixIssues(path15, issues) {
1350
1350
  return issues.map((iss) => {
1351
1351
  var _a;
1352
1352
  (_a = iss).path ?? (_a.path = []);
1353
- iss.path.unshift(path14);
1353
+ iss.path.unshift(path15);
1354
1354
  return iss;
1355
1355
  });
1356
1356
  }
@@ -1518,7 +1518,7 @@ function treeifyError(error43, _mapper) {
1518
1518
  return issue2.message;
1519
1519
  };
1520
1520
  const result = { errors: [] };
1521
- const processError = (error44, path14 = []) => {
1521
+ const processError = (error44, path15 = []) => {
1522
1522
  var _a, _b;
1523
1523
  for (const issue2 of error44.issues) {
1524
1524
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -1528,7 +1528,7 @@ function treeifyError(error43, _mapper) {
1528
1528
  } else if (issue2.code === "invalid_element") {
1529
1529
  processError({ issues: issue2.issues }, issue2.path);
1530
1530
  } else {
1531
- const fullpath = [...path14, ...issue2.path];
1531
+ const fullpath = [...path15, ...issue2.path];
1532
1532
  if (fullpath.length === 0) {
1533
1533
  result.errors.push(mapper(issue2));
1534
1534
  continue;
@@ -1560,8 +1560,8 @@ function treeifyError(error43, _mapper) {
1560
1560
  }
1561
1561
  function toDotPath(_path) {
1562
1562
  const segs = [];
1563
- const path14 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1564
- for (const seg of path14) {
1563
+ const path15 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1564
+ for (const seg of path15) {
1565
1565
  if (typeof seg === "number")
1566
1566
  segs.push(`[${seg}]`);
1567
1567
  else if (typeof seg === "symbol")
@@ -14050,7 +14050,7 @@ var ApiClient = class {
14050
14050
  /**
14051
14051
  * Generic GET request
14052
14052
  */
14053
- async get(path14) {
14053
+ async get(path15) {
14054
14054
  const baseUrl = await this.getBaseUrl();
14055
14055
  const token = await getToken();
14056
14056
  if (!token) {
@@ -14063,7 +14063,7 @@ var ApiClient = class {
14063
14063
  if (bypassSecret) {
14064
14064
  headers["x-vercel-protection-bypass"] = bypassSecret;
14065
14065
  }
14066
- return fetch(`${baseUrl}${path14}`, {
14066
+ return fetch(`${baseUrl}${path15}`, {
14067
14067
  method: "GET",
14068
14068
  headers
14069
14069
  });
@@ -14071,7 +14071,7 @@ var ApiClient = class {
14071
14071
  /**
14072
14072
  * Generic POST request
14073
14073
  */
14074
- async post(path14, options) {
14074
+ async post(path15, options) {
14075
14075
  const baseUrl = await this.getBaseUrl();
14076
14076
  const token = await getToken();
14077
14077
  if (!token) {
@@ -14087,7 +14087,7 @@ var ApiClient = class {
14087
14087
  if (bypassSecret) {
14088
14088
  headers["x-vercel-protection-bypass"] = bypassSecret;
14089
14089
  }
14090
- return fetch(`${baseUrl}${path14}`, {
14090
+ return fetch(`${baseUrl}${path15}`, {
14091
14091
  method: "POST",
14092
14092
  headers,
14093
14093
  body: options?.body
@@ -14096,7 +14096,7 @@ var ApiClient = class {
14096
14096
  /**
14097
14097
  * Generic DELETE request
14098
14098
  */
14099
- async delete(path14) {
14099
+ async delete(path15) {
14100
14100
  const baseUrl = await this.getBaseUrl();
14101
14101
  const token = await getToken();
14102
14102
  if (!token) {
@@ -14109,7 +14109,7 @@ var ApiClient = class {
14109
14109
  if (bypassSecret) {
14110
14110
  headers["x-vercel-protection-bypass"] = bypassSecret;
14111
14111
  }
14112
- return fetch(`${baseUrl}${path14}`, {
14112
+ return fetch(`${baseUrl}${path15}`, {
14113
14113
  method: "DELETE",
14114
14114
  headers
14115
14115
  });
@@ -15830,7 +15830,7 @@ async function pollEvents(runId, options) {
15830
15830
  let nextSequence = 0;
15831
15831
  let complete = false;
15832
15832
  let result = { succeeded: true, runId };
15833
- const pollIntervalMs = 500;
15833
+ const pollIntervalMs = 1e3;
15834
15834
  const startTimestamp = options.startTimestamp;
15835
15835
  let previousTimestamp = startTimestamp;
15836
15836
  const verbose = options.verbose;
@@ -17623,8 +17623,8 @@ async function autoPullArtifact(runOutput, artifactDir) {
17623
17623
  }
17624
17624
  }
17625
17625
  var cookCmd = new Command17().name("cook").description("One-click agent preparation and execution from vm0.yaml");
17626
- cookCmd.argument("[prompt]", "Prompt for the agent").action(async (prompt) => {
17627
- const shouldExit = await checkAndUpgrade("4.33.0", prompt);
17626
+ cookCmd.argument("[prompt]", "Prompt for the agent").option("-y, --yes", "Skip confirmation prompts").action(async (prompt, options) => {
17627
+ const shouldExit = await checkAndUpgrade("4.35.0", prompt);
17628
17628
  if (shouldExit) {
17629
17629
  process.exit(0);
17630
17630
  }
@@ -17747,9 +17747,10 @@ cookCmd.argument("[prompt]", "Prompt for the agent").action(async (prompt) => {
17747
17747
  }
17748
17748
  console.log();
17749
17749
  console.log(chalk21.bold("Composing agent:"));
17750
- printCommand(`vm0 compose ${CONFIG_FILE3}`);
17750
+ const composeArgs = options.yes ? ["compose", "--yes", CONFIG_FILE3] : ["compose", CONFIG_FILE3];
17751
+ printCommand(`vm0 ${composeArgs.join(" ")}`);
17751
17752
  try {
17752
- await execVm0Command(["compose", CONFIG_FILE3], {
17753
+ await execVm0Command(composeArgs, {
17753
17754
  cwd
17754
17755
  });
17755
17756
  } catch (error43) {
@@ -18772,6 +18773,7 @@ import chalk30 from "chalk";
18772
18773
  import { existsSync as existsSync11 } from "fs";
18773
18774
  import { mkdir as mkdir7, readFile as readFile9, writeFile as writeFile8 } from "fs/promises";
18774
18775
  import { execSync, spawnSync } from "child_process";
18776
+ import path14 from "path";
18775
18777
  import { parse as parseYaml5 } from "yaml";
18776
18778
  function isGhInstalled() {
18777
18779
  try {
@@ -18789,8 +18791,36 @@ function isGhAuthenticated() {
18789
18791
  return false;
18790
18792
  }
18791
18793
  }
18794
+ function getGitRoot() {
18795
+ try {
18796
+ return execSync("git rev-parse --show-toplevel", {
18797
+ encoding: "utf8"
18798
+ }).trim();
18799
+ } catch {
18800
+ return null;
18801
+ }
18802
+ }
18803
+ function getRelativeWorkingDir(gitRoot) {
18804
+ const cwd = process.cwd();
18805
+ if (cwd === gitRoot) {
18806
+ return null;
18807
+ }
18808
+ const relativePath = path14.relative(gitRoot, cwd);
18809
+ return relativePath.replace(/\\/g, "/");
18810
+ }
18792
18811
  async function checkPrerequisites() {
18793
18812
  console.log("Checking prerequisites...");
18813
+ const gitRoot = getGitRoot();
18814
+ if (!gitRoot) {
18815
+ console.log(chalk30.red("\u2717 Not in a git repository"));
18816
+ console.log();
18817
+ console.log("This command must be run from within a git repository.");
18818
+ console.log();
18819
+ console.log("To initialize a git repository, run:");
18820
+ console.log(` ${chalk30.cyan("git init")}`);
18821
+ process.exit(1);
18822
+ }
18823
+ console.log(chalk30.green("\u2713 Git repository detected"));
18794
18824
  if (!isGhInstalled()) {
18795
18825
  console.log(chalk30.red("\u2717 GitHub CLI (gh) is not installed"));
18796
18826
  console.log();
@@ -18843,17 +18873,20 @@ async function checkPrerequisites() {
18843
18873
  process.exit(1);
18844
18874
  }
18845
18875
  console.log(chalk30.green("\u2713 vm0.yaml found"));
18846
- return token;
18876
+ return { token, gitRoot };
18847
18877
  }
18848
- function generatePublishYaml() {
18878
+ function generatePublishYaml(workingDir) {
18879
+ const pathPrefix = workingDir ? `${workingDir}/` : "";
18880
+ const workingDirYaml = workingDir ? ` working-directory: ${workingDir}
18881
+ ` : "";
18849
18882
  return `name: Publish Agent
18850
18883
 
18851
18884
  on:
18852
18885
  push:
18853
18886
  branches: [main]
18854
18887
  paths:
18855
- - 'vm0.yaml'
18856
- - 'AGENTS.md'
18888
+ - '${pathPrefix}vm0.yaml'
18889
+ - '${pathPrefix}AGENTS.md'
18857
18890
 
18858
18891
  jobs:
18859
18892
  publish:
@@ -18866,7 +18899,7 @@ jobs:
18866
18899
  id: compose
18867
18900
  with:
18868
18901
  vm0-token: \${{ secrets.VM0_TOKEN }}
18869
-
18902
+ ${workingDirYaml}
18870
18903
  - name: Show Results
18871
18904
  run: |
18872
18905
  echo "Agent: \${{ steps.compose.outputs.name }}"
@@ -19072,10 +19105,12 @@ function showWorkflowsCreatedMessage() {
19072
19105
  }
19073
19106
  var setupGithubCommand = new Command28().name("setup-github").description("Initialize GitHub Actions workflows for agent deployment").option("-f, --force", "Overwrite existing workflow files").option("-y, --yes", "Auto-confirm all prompts").option("--skip-secrets", "Skip automatic secrets/variables setup").action(
19074
19107
  async (options) => {
19075
- const vm0Token = await checkPrerequisites();
19076
- if (!vm0Token) {
19108
+ const prereqs = await checkPrerequisites();
19109
+ if (!prereqs) {
19077
19110
  process.exit(1);
19078
19111
  }
19112
+ const { token: vm0Token, gitRoot } = prereqs;
19113
+ const workingDir = getRelativeWorkingDir(gitRoot);
19079
19114
  console.log();
19080
19115
  console.log("Analyzing vm0.yaml...");
19081
19116
  const content = await readFile9("vm0.yaml", "utf8");
@@ -19090,11 +19125,13 @@ var setupGithubCommand = new Command28().name("setup-github").description("Initi
19090
19125
  )
19091
19126
  );
19092
19127
  console.log();
19093
- const publishPath = ".github/workflows/publish.yml";
19094
- const runPath = ".github/workflows/run.yml";
19128
+ const publishPath = path14.join(gitRoot, ".github/workflows/publish.yml");
19129
+ const runPath = path14.join(gitRoot, ".github/workflows/run.yml");
19130
+ const displayPublishPath = ".github/workflows/publish.yml";
19131
+ const displayRunPath = ".github/workflows/run.yml";
19095
19132
  const existingFiles = [];
19096
- if (existsSync11(publishPath)) existingFiles.push(publishPath);
19097
- if (existsSync11(runPath)) existingFiles.push(runPath);
19133
+ if (existsSync11(publishPath)) existingFiles.push(displayPublishPath);
19134
+ if (existsSync11(runPath)) existingFiles.push(displayRunPath);
19098
19135
  if (existingFiles.length > 0 && !options.force) {
19099
19136
  console.log(chalk30.yellow("\u26A0 Existing workflow files detected:"));
19100
19137
  for (const file2 of existingFiles) {
@@ -19116,13 +19153,13 @@ var setupGithubCommand = new Command28().name("setup-github").description("Initi
19116
19153
  console.log();
19117
19154
  }
19118
19155
  console.log("Creating workflow files...");
19119
- await mkdir7(".github/workflows", { recursive: true });
19120
- await writeFile8(publishPath, generatePublishYaml());
19121
- const publishStatus = existingFiles.includes(publishPath) ? "Overwrote" : "Created";
19122
- console.log(chalk30.green(`\u2713 ${publishStatus} ${publishPath}`));
19156
+ await mkdir7(path14.join(gitRoot, ".github/workflows"), { recursive: true });
19157
+ await writeFile8(publishPath, generatePublishYaml(workingDir));
19158
+ const publishStatus = existingFiles.includes(displayPublishPath) ? "Overwrote" : "Created";
19159
+ console.log(chalk30.green(`\u2713 ${publishStatus} ${displayPublishPath}`));
19123
19160
  await writeFile8(runPath, generateRunYaml(agentName, secrets, vars));
19124
- const runStatus = existingFiles.includes(runPath) ? "Overwrote" : "Created";
19125
- console.log(chalk30.green(`\u2713 ${runStatus} ${runPath}`));
19161
+ const runStatus = existingFiles.includes(displayRunPath) ? "Overwrote" : "Created";
19162
+ console.log(chalk30.green(`\u2713 ${runStatus} ${displayRunPath}`));
19126
19163
  console.log();
19127
19164
  if (options.skipSecrets) {
19128
19165
  console.log(chalk30.green("\u2713 Done (secrets setup skipped)"));
@@ -19215,7 +19252,7 @@ var setupGithubCommand = new Command28().name("setup-github").description("Initi
19215
19252
 
19216
19253
  // src/index.ts
19217
19254
  var program = new Command29();
19218
- program.name("vm0").description("VM0 CLI - A modern build tool").version("4.33.0");
19255
+ program.name("vm0").description("VM0 CLI - A modern build tool").version("4.35.0");
19219
19256
  program.command("info").description("Display environment information").action(async () => {
19220
19257
  console.log(chalk31.bold("System Information:"));
19221
19258
  console.log(`Node Version: ${process.version}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vm0/cli",
3
- "version": "4.33.0",
3
+ "version": "4.35.0",
4
4
  "description": "CLI application",
5
5
  "repository": {
6
6
  "type": "git",