@vm0/cli 4.34.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.
- package/index.js +70 -34
- 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,
|
|
988
|
-
if (!
|
|
987
|
+
function getElementAtPath(obj, path15) {
|
|
988
|
+
if (!path15)
|
|
989
989
|
return obj;
|
|
990
|
-
return
|
|
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(
|
|
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(
|
|
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,
|
|
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 = [...
|
|
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
|
|
1564
|
-
for (const seg of
|
|
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(
|
|
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}${
|
|
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(
|
|
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}${
|
|
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(
|
|
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}${
|
|
14112
|
+
return fetch(`${baseUrl}${path15}`, {
|
|
14113
14113
|
method: "DELETE",
|
|
14114
14114
|
headers
|
|
14115
14115
|
});
|
|
@@ -17624,7 +17624,7 @@ async function autoPullArtifact(runOutput, artifactDir) {
|
|
|
17624
17624
|
}
|
|
17625
17625
|
var cookCmd = new Command17().name("cook").description("One-click agent preparation and execution from vm0.yaml");
|
|
17626
17626
|
cookCmd.argument("[prompt]", "Prompt for the agent").option("-y, --yes", "Skip confirmation prompts").action(async (prompt, options) => {
|
|
17627
|
-
const shouldExit = await checkAndUpgrade("4.
|
|
17627
|
+
const shouldExit = await checkAndUpgrade("4.35.0", prompt);
|
|
17628
17628
|
if (shouldExit) {
|
|
17629
17629
|
process.exit(0);
|
|
17630
17630
|
}
|
|
@@ -18773,6 +18773,7 @@ import chalk30 from "chalk";
|
|
|
18773
18773
|
import { existsSync as existsSync11 } from "fs";
|
|
18774
18774
|
import { mkdir as mkdir7, readFile as readFile9, writeFile as writeFile8 } from "fs/promises";
|
|
18775
18775
|
import { execSync, spawnSync } from "child_process";
|
|
18776
|
+
import path14 from "path";
|
|
18776
18777
|
import { parse as parseYaml5 } from "yaml";
|
|
18777
18778
|
function isGhInstalled() {
|
|
18778
18779
|
try {
|
|
@@ -18790,8 +18791,36 @@ function isGhAuthenticated() {
|
|
|
18790
18791
|
return false;
|
|
18791
18792
|
}
|
|
18792
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
|
+
}
|
|
18793
18811
|
async function checkPrerequisites() {
|
|
18794
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"));
|
|
18795
18824
|
if (!isGhInstalled()) {
|
|
18796
18825
|
console.log(chalk30.red("\u2717 GitHub CLI (gh) is not installed"));
|
|
18797
18826
|
console.log();
|
|
@@ -18844,17 +18873,20 @@ async function checkPrerequisites() {
|
|
|
18844
18873
|
process.exit(1);
|
|
18845
18874
|
}
|
|
18846
18875
|
console.log(chalk30.green("\u2713 vm0.yaml found"));
|
|
18847
|
-
return token;
|
|
18876
|
+
return { token, gitRoot };
|
|
18848
18877
|
}
|
|
18849
|
-
function generatePublishYaml() {
|
|
18878
|
+
function generatePublishYaml(workingDir) {
|
|
18879
|
+
const pathPrefix = workingDir ? `${workingDir}/` : "";
|
|
18880
|
+
const workingDirYaml = workingDir ? ` working-directory: ${workingDir}
|
|
18881
|
+
` : "";
|
|
18850
18882
|
return `name: Publish Agent
|
|
18851
18883
|
|
|
18852
18884
|
on:
|
|
18853
18885
|
push:
|
|
18854
18886
|
branches: [main]
|
|
18855
18887
|
paths:
|
|
18856
|
-
- 'vm0.yaml'
|
|
18857
|
-
- 'AGENTS.md'
|
|
18888
|
+
- '${pathPrefix}vm0.yaml'
|
|
18889
|
+
- '${pathPrefix}AGENTS.md'
|
|
18858
18890
|
|
|
18859
18891
|
jobs:
|
|
18860
18892
|
publish:
|
|
@@ -18867,7 +18899,7 @@ jobs:
|
|
|
18867
18899
|
id: compose
|
|
18868
18900
|
with:
|
|
18869
18901
|
vm0-token: \${{ secrets.VM0_TOKEN }}
|
|
18870
|
-
|
|
18902
|
+
${workingDirYaml}
|
|
18871
18903
|
- name: Show Results
|
|
18872
18904
|
run: |
|
|
18873
18905
|
echo "Agent: \${{ steps.compose.outputs.name }}"
|
|
@@ -19073,10 +19105,12 @@ function showWorkflowsCreatedMessage() {
|
|
|
19073
19105
|
}
|
|
19074
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(
|
|
19075
19107
|
async (options) => {
|
|
19076
|
-
const
|
|
19077
|
-
if (!
|
|
19108
|
+
const prereqs = await checkPrerequisites();
|
|
19109
|
+
if (!prereqs) {
|
|
19078
19110
|
process.exit(1);
|
|
19079
19111
|
}
|
|
19112
|
+
const { token: vm0Token, gitRoot } = prereqs;
|
|
19113
|
+
const workingDir = getRelativeWorkingDir(gitRoot);
|
|
19080
19114
|
console.log();
|
|
19081
19115
|
console.log("Analyzing vm0.yaml...");
|
|
19082
19116
|
const content = await readFile9("vm0.yaml", "utf8");
|
|
@@ -19091,11 +19125,13 @@ var setupGithubCommand = new Command28().name("setup-github").description("Initi
|
|
|
19091
19125
|
)
|
|
19092
19126
|
);
|
|
19093
19127
|
console.log();
|
|
19094
|
-
const publishPath = ".github/workflows/publish.yml";
|
|
19095
|
-
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";
|
|
19096
19132
|
const existingFiles = [];
|
|
19097
|
-
if (existsSync11(publishPath)) existingFiles.push(
|
|
19098
|
-
if (existsSync11(runPath)) existingFiles.push(
|
|
19133
|
+
if (existsSync11(publishPath)) existingFiles.push(displayPublishPath);
|
|
19134
|
+
if (existsSync11(runPath)) existingFiles.push(displayRunPath);
|
|
19099
19135
|
if (existingFiles.length > 0 && !options.force) {
|
|
19100
19136
|
console.log(chalk30.yellow("\u26A0 Existing workflow files detected:"));
|
|
19101
19137
|
for (const file2 of existingFiles) {
|
|
@@ -19117,13 +19153,13 @@ var setupGithubCommand = new Command28().name("setup-github").description("Initi
|
|
|
19117
19153
|
console.log();
|
|
19118
19154
|
}
|
|
19119
19155
|
console.log("Creating workflow files...");
|
|
19120
|
-
await mkdir7(".github/workflows", { recursive: true });
|
|
19121
|
-
await writeFile8(publishPath, generatePublishYaml());
|
|
19122
|
-
const publishStatus = existingFiles.includes(
|
|
19123
|
-
console.log(chalk30.green(`\u2713 ${publishStatus} ${
|
|
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}`));
|
|
19124
19160
|
await writeFile8(runPath, generateRunYaml(agentName, secrets, vars));
|
|
19125
|
-
const runStatus = existingFiles.includes(
|
|
19126
|
-
console.log(chalk30.green(`\u2713 ${runStatus} ${
|
|
19161
|
+
const runStatus = existingFiles.includes(displayRunPath) ? "Overwrote" : "Created";
|
|
19162
|
+
console.log(chalk30.green(`\u2713 ${runStatus} ${displayRunPath}`));
|
|
19127
19163
|
console.log();
|
|
19128
19164
|
if (options.skipSecrets) {
|
|
19129
19165
|
console.log(chalk30.green("\u2713 Done (secrets setup skipped)"));
|
|
@@ -19216,7 +19252,7 @@ var setupGithubCommand = new Command28().name("setup-github").description("Initi
|
|
|
19216
19252
|
|
|
19217
19253
|
// src/index.ts
|
|
19218
19254
|
var program = new Command29();
|
|
19219
|
-
program.name("vm0").description("VM0 CLI - A modern build tool").version("4.
|
|
19255
|
+
program.name("vm0").description("VM0 CLI - A modern build tool").version("4.35.0");
|
|
19220
19256
|
program.command("info").description("Display environment information").action(async () => {
|
|
19221
19257
|
console.log(chalk31.bold("System Information:"));
|
|
19222
19258
|
console.log(`Node Version: ${process.version}`);
|