vibedgames 0.7.0 → 0.8.1

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.
@@ -4,12 +4,12 @@ import { fileURLToPath as __fileURLToPath } from "node:url";
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
+ import {
8
+ isNewerVersion
9
+ } from "./chunk-GCX5KQ6A.js";
7
10
  import {
8
11
  require_cross_spawn
9
12
  } from "./chunk-2QBYTIMH.js";
10
- import {
11
- isNewerVersion
12
- } from "./chunk-SAANBZ25.js";
13
13
  import {
14
14
  SLUG_RE,
15
15
  findProjectRoot,
@@ -8,10 +8,10 @@ import {
8
8
  ensureAgentBrowser,
9
9
  projectSessionId,
10
10
  resolveGameUrl
11
- } from "./chunk-CZPKN32Z.js";
12
- import "./chunk-2QBYTIMH.js";
13
- import "./chunk-SAANBZ25.js";
11
+ } from "./chunk-4BGCA3W7.js";
12
+ import "./chunk-GCX5KQ6A.js";
14
13
  import "./chunk-6FZPPUQH.js";
14
+ import "./chunk-2QBYTIMH.js";
15
15
  import "./chunk-ZI6PKVXG.js";
16
16
  import {
17
17
  authErrorCode,
@@ -0,0 +1,39 @@
1
+ import { createRequire as __createRequire } from "node:module";
2
+ import { dirname as __pathDirname } from "node:path";
3
+ import { fileURLToPath as __fileURLToPath } from "node:url";
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import {
8
+ require_cross_spawn
9
+ } from "./chunk-2QBYTIMH.js";
10
+ import {
11
+ __toESM
12
+ } from "./chunk-CAKBGDCY.js";
13
+
14
+ // src/lib/run.ts
15
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
16
+ var isMissingCommand = (result) => result.code !== 0 && /ENOENT|not found|not recognized/iu.test(result.output);
17
+ var run = (cmd, args) => (
18
+ // oxlint-disable-next-line promise/avoid-new -- child_process.spawn is event-based
19
+ new Promise((resolve) => {
20
+ const chunks = [];
21
+ const child = (0, import_cross_spawn.default)(cmd, args, { stdio: ["ignore", "pipe", "pipe"] });
22
+ const collect = (c) => {
23
+ chunks.push(c);
24
+ };
25
+ child.stdout?.on("data", collect);
26
+ child.stderr?.on("data", collect);
27
+ child.on("error", (err) => resolve({ code: 1, output: `${err.message}
28
+ ` }));
29
+ child.on(
30
+ "close",
31
+ (code) => resolve({ code: code ?? 1, output: Buffer.concat(chunks).toString("utf-8") })
32
+ );
33
+ })
34
+ );
35
+
36
+ export {
37
+ isMissingCommand,
38
+ run
39
+ };
@@ -4,6 +4,9 @@ import { fileURLToPath as __fileURLToPath } from "node:url";
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
+ import {
8
+ run
9
+ } from "./chunk-AYJQVZXY.js";
7
10
  import {
8
11
  consola
9
12
  } from "./chunk-CU7UY5YJ.js";
@@ -14,29 +17,12 @@ import {
14
17
  import {
15
18
  defineCommand
16
19
  } from "./chunk-MBXCVCC4.js";
17
- import "./chunk-CAKBGDCY.js";
18
20
 
19
21
  // src/commands/factory.ts
20
22
  import { spawnSync } from "node:child_process";
21
- import { existsSync } from "node:fs";
23
+ import { existsSync, readFileSync } from "node:fs";
22
24
  import path from "node:path";
23
- var factoryPackageFor = (platform, arch, report) => {
24
- const name = `@vibedgames/factory-${platform}-${arch}`;
25
- if (platform !== "linux") {
26
- return name;
27
- }
28
- const header = isJsonObject(report) ? report.header : void 0;
29
- return isJsonObject(header) && isJsonString(header.glibcVersionRuntime) ? name : `${name}-musl`;
30
- };
31
- var factoryPackage = () => {
32
- if (process.platform !== "linux") {
33
- return factoryPackageFor(process.platform, process.arch, null);
34
- }
35
- const reportText = JSON.stringify(process.report.getReport());
36
- const report = JSON.parse(reportText);
37
- return factoryPackageFor(process.platform, process.arch, report);
38
- };
39
- var BIN = process.platform === "win32" ? "vg-factory.exe" : "vg-factory";
25
+ var FACTORY_PACKAGE = "@vibedgames/factory";
40
26
  var npmGlobalRoot = () => {
41
27
  try {
42
28
  const res = spawnSync("npm", ["root", "-g"], { encoding: "utf-8", timeout: 3e4 });
@@ -49,7 +35,7 @@ var npmGlobalRoot = () => {
49
35
  return null;
50
36
  }
51
37
  };
52
- var findBinary = (pkg) => {
38
+ var findEntry = () => {
53
39
  const override = process.env.VG_FACTORY_BIN;
54
40
  if (override) {
55
41
  return existsSync(override) ? override : null;
@@ -58,29 +44,45 @@ var findBinary = (pkg) => {
58
44
  if (!root) {
59
45
  return null;
60
46
  }
61
- const bin = path.join(root, pkg, "bin", BIN);
62
- return existsSync(bin) ? bin : null;
47
+ const entry = path.join(root, FACTORY_PACKAGE, "bin", "vg-factory.js");
48
+ return existsSync(entry) ? entry : null;
63
49
  };
50
+ var installedFactoryVersion = () => {
51
+ const root = npmGlobalRoot();
52
+ if (!root) {
53
+ return null;
54
+ }
55
+ try {
56
+ const manifest = JSON.parse(
57
+ readFileSync(path.join(root, FACTORY_PACKAGE, "package.json"), "utf-8")
58
+ );
59
+ return isJsonObject(manifest) && isJsonString(manifest.version) ? manifest.version : null;
60
+ } catch {
61
+ return null;
62
+ }
63
+ };
64
+ var updateFactory = () => run("npm", ["install", "-g", `${FACTORY_PACKAGE}@latest`]);
64
65
  var runFactory = (args) => {
65
- const pkg = factoryPackage();
66
- let bin = findBinary(pkg);
67
- if (!bin) {
68
- consola.start(`Installing the factory (${pkg})\u2026`);
69
- const install = spawnSync("npm", ["install", "-g", pkg], { stdio: "inherit" });
66
+ let entry = findEntry();
67
+ if (!entry) {
68
+ consola.start(`Installing the factory (${FACTORY_PACKAGE})\u2026`);
69
+ const install = spawnSync("npm", ["install", "-g", FACTORY_PACKAGE], { stdio: "inherit" });
70
70
  if (install.status !== 0 || install.error !== void 0) {
71
- consola.error(`Couldn't install the factory. Try manually: npm install -g ${pkg}`);
71
+ consola.error(
72
+ `Couldn't install the factory. Try manually: npm install -g ${FACTORY_PACKAGE}`
73
+ );
72
74
  process.exit(1);
73
75
  }
74
- bin = findBinary(pkg);
75
- if (!bin) {
76
+ entry = findEntry();
77
+ if (!entry) {
76
78
  consola.error(
77
- `Installed ${pkg} but couldn't find its binary under npm's global root. Check \`npm root -g\`.`
79
+ `Installed ${FACTORY_PACKAGE} but couldn't find its entry under npm's global root. Check \`npm root -g\`.`
78
80
  );
79
81
  process.exit(1);
80
82
  }
81
83
  consola.success("Factory installed.");
82
84
  }
83
- const result = spawnSync(bin, args, { stdio: "inherit" });
85
+ const result = spawnSync(process.execPath, [entry, ...args], { stdio: "inherit" });
84
86
  process.exit(result.status ?? 1);
85
87
  };
86
88
  var factoryCommand = defineCommand({
@@ -92,8 +94,11 @@ var factoryCommand = defineCommand({
92
94
  runFactory(rawArgs);
93
95
  }
94
96
  });
97
+
95
98
  export {
96
- factoryCommand,
97
- factoryPackageFor,
98
- runFactory
99
+ FACTORY_PACKAGE,
100
+ installedFactoryVersion,
101
+ updateFactory,
102
+ runFactory,
103
+ factoryCommand
99
104
  };
@@ -68,10 +68,10 @@ var isNewerVersion = (latest, current) => {
68
68
  }
69
69
  return false;
70
70
  };
71
- var fetchLatestVersion = async () => {
71
+ var fetchLatestVersion = async (packageName) => {
72
72
  const registry = process.env.VG_REGISTRY_URL ?? "https://registry.npmjs.org";
73
73
  try {
74
- const res = await fetch(`${registry}/vibedgames/latest`, {
74
+ const res = await fetch(`${registry}/${packageName}/latest`, {
75
75
  signal: AbortSignal.timeout(5e3)
76
76
  });
77
77
  if (!res.ok) {
@@ -7,7 +7,8 @@ var __dirname = __pathDirname(__filename);
7
7
  import {
8
8
  initCommand,
9
9
  reportSkills
10
- } from "./chunk-34AHIMX7.js";
10
+ } from "./chunk-RAUJA3OY.js";
11
+ import "./chunk-AYJQVZXY.js";
11
12
  import "./chunk-2QBYTIMH.js";
12
13
  import "./chunk-VFFOT7KD.js";
13
14
  import "./chunk-PEUP4MZR.js";
@@ -9,7 +9,7 @@ import {
9
9
  isNewerVersion,
10
10
  markUpdateChecked,
11
11
  maybeScheduleAutoUpdate
12
- } from "./chunk-SAANBZ25.js";
12
+ } from "./chunk-GCX5KQ6A.js";
13
13
  import "./chunk-6FZPPUQH.js";
14
14
  import "./chunk-RYFO3ZPO.js";
15
15
  import "./chunk-J6PKNPI2.js";
@@ -6,18 +6,25 @@ var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
7
  import {
8
8
  findInstall,
9
- isMissingCommand,
10
9
  reportSkills,
11
- run,
12
10
  settleSync,
13
11
  syncSkills
14
- } from "./chunk-34AHIMX7.js";
15
- import "./chunk-2QBYTIMH.js";
12
+ } from "./chunk-RAUJA3OY.js";
16
13
  import {
17
14
  fetchLatestVersion,
18
15
  isNewerVersion
19
- } from "./chunk-SAANBZ25.js";
16
+ } from "./chunk-GCX5KQ6A.js";
20
17
  import "./chunk-6FZPPUQH.js";
18
+ import {
19
+ FACTORY_PACKAGE,
20
+ installedFactoryVersion,
21
+ updateFactory
22
+ } from "./chunk-C2IRIRAA.js";
23
+ import {
24
+ isMissingCommand,
25
+ run
26
+ } from "./chunk-AYJQVZXY.js";
27
+ import "./chunk-2QBYTIMH.js";
21
28
  import "./chunk-VFFOT7KD.js";
22
29
  import {
23
30
  PACKAGE_VERSION
@@ -45,6 +52,28 @@ var updateInstalledSkills = async (global) => {
45
52
  const found = findInstall(global ? ["global"] : ["project", "global"]);
46
53
  return found ? await syncSkills(found.target, found.agents) : null;
47
54
  };
55
+ var autoUpdate = async (manager, global, factoryVersion) => {
56
+ const [latest, latestFactory] = await Promise.all([
57
+ fetchLatestVersion("vibedgames"),
58
+ factoryVersion === null ? null : fetchLatestVersion(FACTORY_PACKAGE)
59
+ ]);
60
+ const cliNewer = latest !== null && isNewerVersion(latest, PACKAGE_VERSION);
61
+ const factoryNewer = factoryVersion !== null && latestFactory !== null && isNewerVersion(latestFactory, factoryVersion);
62
+ await Promise.all([
63
+ cliNewer && run(manager, globalInstallArgs(manager)),
64
+ cliNewer && settleSync(updateInstalledSkills(global)),
65
+ factoryNewer && updateFactory()
66
+ ]);
67
+ };
68
+ var reportFactory = (result) => {
69
+ if (result.code === 0) {
70
+ consola.success(`${FACTORY_PACKAGE} updated to latest`);
71
+ return;
72
+ }
73
+ consola.warn(
74
+ `Couldn't update the factory (npm exit ${result.code}). Update manually: npm install -g ${FACTORY_PACKAGE}@latest`
75
+ );
76
+ };
48
77
  var updateArgs = {
49
78
  auto: {
50
79
  default: false,
@@ -61,28 +90,22 @@ var updateArgs = {
61
90
  var updateCommand = defineCommand({
62
91
  args: updateArgs,
63
92
  meta: {
64
- description: "Update the vg CLI and vibedgames skills to latest (runs automatically once a day; turn that off with `vg config set update.auto false`)",
93
+ description: "Update the vg CLI, vibedgames skills and, if installed, the factory to latest (runs automatically once a day; turn that off with `vg config set update.auto false`)",
65
94
  name: "update"
66
95
  },
67
96
  run: async ({ args, rawArgs }) => {
68
97
  assertKnownFlags(rawArgs, updateArgs);
69
98
  const manager = detectPackageManager(import.meta.filename);
99
+ const factoryVersion = installedFactoryVersion();
70
100
  if (args.auto) {
71
- const latest = await fetchLatestVersion();
72
- if (!latest || !isNewerVersion(latest, PACKAGE_VERSION)) {
73
- return;
74
- }
75
- await Promise.all([
76
- run(manager, globalInstallArgs(manager)),
77
- // Silent background mode: a failed skills sync waits for the next run.
78
- settleSync(updateInstalledSkills(args.global))
79
- ]);
101
+ await autoUpdate(manager, args.global, factoryVersion);
80
102
  return;
81
103
  }
82
104
  consola.start("Updating the vg CLI and vibedgames skills...");
83
- const [cli, skills] = await Promise.all([
105
+ const [cli, skills, factory] = await Promise.all([
84
106
  run(manager, globalInstallArgs(manager)),
85
- settleSync(updateInstalledSkills(args.global))
107
+ settleSync(updateInstalledSkills(args.global)),
108
+ factoryVersion === null ? null : updateFactory()
86
109
  ]);
87
110
  if (cli.code === 0) {
88
111
  consola.success(`vg CLI updated to latest with ${manager}`);
@@ -101,6 +124,9 @@ var updateCommand = defineCommand({
101
124
  } else {
102
125
  consola.info("No vibedgames skills installed here or in your home directory: run vg init");
103
126
  }
127
+ if (factory) {
128
+ reportFactory(factory);
129
+ }
104
130
  if (cli.code !== 0 && !skills.ok) {
105
131
  throw new Error("update failed for both the CLI and skills");
106
132
  }
@@ -0,0 +1,26 @@
1
+ import { createRequire as __createRequire } from "node:module";
2
+ import { dirname as __pathDirname } from "node:path";
3
+ import { fileURLToPath as __fileURLToPath } from "node:url";
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import {
8
+ FACTORY_PACKAGE,
9
+ factoryCommand,
10
+ installedFactoryVersion,
11
+ runFactory,
12
+ updateFactory
13
+ } from "./chunk-C2IRIRAA.js";
14
+ import "./chunk-AYJQVZXY.js";
15
+ import "./chunk-2QBYTIMH.js";
16
+ import "./chunk-CU7UY5YJ.js";
17
+ import "./chunk-J6PKNPI2.js";
18
+ import "./chunk-MBXCVCC4.js";
19
+ import "./chunk-CAKBGDCY.js";
20
+ export {
21
+ FACTORY_PACKAGE,
22
+ factoryCommand,
23
+ installedFactoryVersion,
24
+ runFactory,
25
+ updateFactory
26
+ };
@@ -5,8 +5,9 @@ const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
7
  import {
8
- require_cross_spawn
9
- } from "./chunk-2QBYTIMH.js";
8
+ isMissingCommand,
9
+ run
10
+ } from "./chunk-AYJQVZXY.js";
10
11
  import {
11
12
  So
12
13
  } from "./chunk-VFFOT7KD.js";
@@ -29,35 +30,10 @@ import {
29
30
  import {
30
31
  defineCommand
31
32
  } from "./chunk-MBXCVCC4.js";
32
- import {
33
- __toESM
34
- } from "./chunk-CAKBGDCY.js";
35
33
 
36
34
  // src/commands/init.ts
37
35
  import path2 from "node:path";
38
36
 
39
- // src/lib/run.ts
40
- var import_cross_spawn = __toESM(require_cross_spawn(), 1);
41
- var isMissingCommand = (result) => result.code !== 0 && /ENOENT|not found|not recognized/iu.test(result.output);
42
- var run = (cmd, args) => (
43
- // oxlint-disable-next-line promise/avoid-new -- child_process.spawn is event-based
44
- new Promise((resolve) => {
45
- const chunks = [];
46
- const child = (0, import_cross_spawn.default)(cmd, args, { stdio: ["ignore", "pipe", "pipe"] });
47
- const collect = (c) => {
48
- chunks.push(c);
49
- };
50
- child.stdout?.on("data", collect);
51
- child.stderr?.on("data", collect);
52
- child.on("error", (err) => resolve({ code: 1, output: `${err.message}
53
- ` }));
54
- child.on(
55
- "close",
56
- (code) => resolve({ code: code ?? 1, output: Buffer.concat(chunks).toString("utf-8") })
57
- );
58
- })
59
- );
60
-
61
37
  // src/lib/skills-install.ts
62
38
  import {
63
39
  cpSync,
@@ -456,8 +432,6 @@ var initCommand = defineCommand({
456
432
  });
457
433
 
458
434
  export {
459
- isMissingCommand,
460
- run,
461
435
  syncSkills,
462
436
  settleSync,
463
437
  findInstall,
@@ -16,10 +16,10 @@ import {
16
16
  resolveGameUrl,
17
17
  runPlaytest,
18
18
  withScopedSession
19
- } from "./chunk-CZPKN32Z.js";
20
- import "./chunk-2QBYTIMH.js";
21
- import "./chunk-SAANBZ25.js";
19
+ } from "./chunk-4BGCA3W7.js";
20
+ import "./chunk-GCX5KQ6A.js";
22
21
  import "./chunk-6FZPPUQH.js";
22
+ import "./chunk-2QBYTIMH.js";
23
23
  import "./chunk-ZI6PKVXG.js";
24
24
  import "./chunk-RYFO3ZPO.js";
25
25
  import "./chunk-CU7UY5YJ.js";
package/dist/index.js CHANGED
@@ -34,10 +34,10 @@ var main = defineCommand({
34
34
  config: lazy(() => import("./chunk-2GL2WJZX.js"), "configCommand"),
35
35
  credits: lazy(() => import("./chunk-QIVCBUYD.js"), "creditsCommand"),
36
36
  deploy: lazy(() => import("./chunk-MJQSHP3Y.js"), "deployCommand"),
37
- factory: lazy(() => import("./chunk-BVVYDSFJ.js"), "factoryCommand"),
37
+ factory: lazy(() => import("./chunk-QJZ72MSY.js"), "factoryCommand"),
38
38
  fork: lazy(() => import("./chunk-HKA5LBYW.js"), "forkCommand"),
39
- generate: lazy(() => import("./chunk-FLUXEHMU.js"), "generateCommand"),
40
- init: lazy(() => import("./chunk-G5FRIFA3.js"), "initCommand"),
39
+ generate: lazy(() => import("./chunk-N3XAUFKH.js"), "generateCommand"),
40
+ init: lazy(() => import("./chunk-MGIASPED.js"), "initCommand"),
41
41
  login: lazy(() => import("./chunk-MYFLYNPO.js"), "loginCommand"),
42
42
  logout: lazy(() => import("./chunk-PHEDW6C7.js"), "logoutCommand"),
43
43
  new: lazy(() => import("./chunk-QGEITHUP.js"), "newCommand"),
@@ -48,29 +48,29 @@ var main = defineCommand({
48
48
  // passthrough here would forward `run …` to agent-browser once the
49
49
  // playtest had finished and turn every passing run into an exit 1.
50
50
  playtest: async () => {
51
- const { playtestCommand } = await import("./chunk-Y552BNFZ.js");
51
+ const { playtestCommand } = await import("./chunk-TLRL6FHW.js");
52
52
  return defineCommand({
53
53
  meta: playtestCommand.meta,
54
54
  subCommands: {
55
- run: lazy(() => import("./chunk-CBKOPVU6.js"), "playtestRunCommand")
55
+ run: lazy(() => import("./chunk-7MKUR7Y3.js"), "playtestRunCommand")
56
56
  }
57
57
  });
58
58
  },
59
- update: lazy(() => import("./chunk-DHEXGWJY.js"), "updateCommand"),
59
+ update: lazy(() => import("./chunk-PM5UOIKR.js"), "updateCommand"),
60
60
  whoami: lazy(() => import("./chunk-HCMTSR7E.js"), "whoamiCommand")
61
61
  }
62
62
  });
63
63
  var subcommand = process.argv.at(2);
64
64
  if (subcommand && !["update", "init", "completions"].includes(subcommand)) {
65
- const { maybeScheduleAutoUpdate } = await import("./chunk-FL6IFBUF.js");
65
+ const { maybeScheduleAutoUpdate } = await import("./chunk-NC5XCGYU.js");
66
66
  maybeScheduleAutoUpdate();
67
67
  }
68
68
  if (subcommand === "factory") {
69
- const { runFactory } = await import("./chunk-BVVYDSFJ.js");
69
+ const { runFactory } = await import("./chunk-QJZ72MSY.js");
70
70
  runFactory(process.argv.slice(3));
71
71
  }
72
72
  if (subcommand === "playtest" && process.argv.at(3) !== "run") {
73
- const { runPlaytest } = await import("./chunk-Y552BNFZ.js");
73
+ const { runPlaytest } = await import("./chunk-TLRL6FHW.js");
74
74
  runPlaytest(process.argv.slice(3));
75
75
  }
76
76
  await runMain(main);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibedgames",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "vg": "./dist/index.js"
@@ -4,12 +4,12 @@ import { fileURLToPath as __fileURLToPath } from "node:url";
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import {
8
- require_cross_spawn
9
- } from "./chunk-2QBYTIMH.js";
10
7
  import {
11
8
  resolveSetting
12
9
  } from "./chunk-6FZPPUQH.js";
10
+ import {
11
+ require_cross_spawn
12
+ } from "./chunk-2QBYTIMH.js";
13
13
  import {
14
14
  createClient,
15
15
  forwardJson