vibedgames 0.6.3 → 0.8.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/README.md +14 -9
- package/dist/THIRD_PARTY_NOTICES.txt +383 -0
- package/dist/chunk-2QBYTIMH.js +511 -0
- package/dist/chunk-6FZPPUQH.js +107 -0
- package/dist/chunk-AZGENOOR.js +22 -0
- package/dist/chunk-CAKBGDCY.js +47 -0
- package/dist/chunk-CU7UY5YJ.js +1108 -0
- package/dist/chunk-CZPKN32Z.js +257 -0
- package/dist/chunk-FL6IFBUF.js +22 -0
- package/dist/chunk-FNYBZNW2.js +165 -0
- package/dist/chunk-GUF6ADBF.js +273 -0
- package/dist/chunk-H4NBRFBY.js +79 -0
- package/dist/chunk-HASKWB6B.js +111 -0
- package/dist/chunk-I6O4HIDY.js +1063 -0
- package/dist/chunk-IO6OM6WM.js +466 -0
- package/dist/chunk-J6PKNPI2.js +26 -0
- package/dist/chunk-JT2AU24K.js +759 -0
- package/dist/chunk-K5SC6SXO.js +172 -0
- package/dist/chunk-MBXCVCC4.js +478 -0
- package/dist/chunk-PEUP4MZR.js +59 -0
- package/dist/chunk-PQDBCZRT.js +2017 -0
- package/dist/chunk-RIGKOLNN.js +1360 -0
- package/dist/chunk-RNBUX5VF.js +68 -0
- package/dist/chunk-RYFO3ZPO.js +71 -0
- package/dist/chunk-RZ4DIJQW.js +68 -0
- package/dist/chunk-SAANBZ25.js +118 -0
- package/dist/chunk-TMK6V5FV.js +395 -0
- package/dist/chunk-TYVYWBY6.js +69 -0
- package/dist/chunk-VFFOT7KD.js +2980 -0
- package/dist/chunk-W5XP4ZVU.js +159 -0
- package/dist/chunk-X4ZABSCN.js +415 -0
- package/dist/chunk-XDC7QGOF.js +32 -0
- package/dist/chunk-XK5RZQMX.js +1780 -0
- package/dist/chunk-Y552BNFZ.js +41 -0
- package/dist/chunk-Z4Z24FWO.js +39 -0
- package/dist/chunk-ZI6PKVXG.js +64 -0
- package/dist/chunk-ZYCSYJWX.js +87 -0
- package/dist/index.js +67 -60
- package/package.json +13 -16
- package/templates/none/_gitignore +3 -0
- package/templates/none/index.html +29 -0
- package/templates/none/package.json +16 -0
- package/templates/none/src/main.ts +16 -0
- package/templates/none/tsconfig.json +18 -0
- package/templates/none/vite.config.ts +8 -0
- package/templates/phaser/_gitignore +3 -0
- package/templates/phaser/index.html +24 -0
- package/templates/phaser/package.json +19 -0
- package/templates/phaser/src/main.ts +16 -0
- package/templates/phaser/src/scenes/game-scene.ts +65 -0
- package/templates/phaser/tsconfig.json +18 -0
- package/templates/phaser/vite.config.ts +8 -0
- package/templates/react-r3f/_gitignore +3 -0
- package/templates/react-r3f/index.html +24 -0
- package/templates/react-r3f/package.json +27 -0
- package/templates/react-r3f/src/app.tsx +33 -0
- package/templates/react-r3f/src/main.tsx +15 -0
- package/templates/react-r3f/tsconfig.json +19 -0
- package/templates/react-r3f/vite.config.ts +10 -0
- package/templates/threejs/_gitignore +3 -0
- package/templates/threejs/index.html +36 -0
- package/templates/threejs/package.json +20 -0
- package/templates/threejs/src/main.ts +44 -0
- package/templates/threejs/tsconfig.json +18 -0
- package/templates/threejs/vite.config.ts +8 -0
- package/dist/commands/completions.d.ts +0 -7
- package/dist/commands/completions.js +0 -145
- package/dist/commands/credits.d.ts +0 -10
- package/dist/commands/credits.js +0 -136
- package/dist/commands/deploy.d.ts +0 -26
- package/dist/commands/deploy.js +0 -257
- package/dist/commands/factory.d.ts +0 -3
- package/dist/commands/factory.js +0 -73
- package/dist/commands/fork.d.ts +0 -29
- package/dist/commands/fork.js +0 -124
- package/dist/commands/generate.d.ts +0 -1
- package/dist/commands/generate.js +0 -565
- package/dist/commands/init.d.ts +0 -20
- package/dist/commands/init.js +0 -105
- package/dist/commands/login.d.ts +0 -1
- package/dist/commands/login.js +0 -45
- package/dist/commands/logout.d.ts +0 -1
- package/dist/commands/logout.js +0 -13
- package/dist/commands/new.d.ts +0 -26
- package/dist/commands/new.js +0 -318
- package/dist/commands/playtest-run.d.ts +0 -66
- package/dist/commands/playtest-run.js +0 -268
- package/dist/commands/playtest.d.ts +0 -76
- package/dist/commands/playtest.js +0 -372
- package/dist/commands/update.d.ts +0 -13
- package/dist/commands/update.js +0 -82
- package/dist/commands/whoami.d.ts +0 -10
- package/dist/commands/whoami.js +0 -44
- package/dist/index.d.ts +0 -2
- package/dist/lib/api.d.ts +0 -18
- package/dist/lib/api.js +0 -27
- package/dist/lib/archive.d.ts +0 -17
- package/dist/lib/archive.js +0 -228
- package/dist/lib/codex.d.ts +0 -117
- package/dist/lib/codex.js +0 -426
- package/dist/lib/config-file.d.ts +0 -16
- package/dist/lib/config-file.js +0 -54
- package/dist/lib/config.d.ts +0 -11
- package/dist/lib/config.js +0 -54
- package/dist/lib/manifest.d.ts +0 -10
- package/dist/lib/manifest.js +0 -91
- package/dist/lib/media-args.d.ts +0 -30
- package/dist/lib/media-args.js +0 -219
- package/dist/lib/media-download.d.ts +0 -37
- package/dist/lib/media-download.js +0 -268
- package/dist/lib/media-poll.d.ts +0 -18
- package/dist/lib/media-poll.js +0 -86
- package/dist/lib/media-upload.d.ts +0 -12
- package/dist/lib/media-upload.js +0 -52
- package/dist/lib/output.d.ts +0 -68
- package/dist/lib/output.js +0 -102
- package/dist/lib/package-manager.d.ts +0 -25
- package/dist/lib/package-manager.js +0 -77
- package/dist/lib/playtest/agent.d.ts +0 -192
- package/dist/lib/playtest/agent.js +0 -652
- package/dist/lib/playtest/browser.d.ts +0 -109
- package/dist/lib/playtest/browser.js +0 -219
- package/dist/lib/playtest/controls.d.ts +0 -47
- package/dist/lib/playtest/controls.js +0 -218
- package/dist/lib/playtest/errors.d.ts +0 -9
- package/dist/lib/playtest/errors.js +0 -12
- package/dist/lib/playtest/keys.d.ts +0 -41
- package/dist/lib/playtest/keys.js +0 -157
- package/dist/lib/playtest/run.d.ts +0 -195
- package/dist/lib/playtest/run.js +0 -409
- package/dist/lib/run.d.ts +0 -19
- package/dist/lib/run.js +0 -23
- package/dist/lib/strict-args.d.ts +0 -27
- package/dist/lib/strict-args.js +0 -78
- package/dist/lib/types.d.ts +0 -16
- package/dist/lib/types.js +0 -10
- package/dist/lib/update.d.ts +0 -10
- package/dist/lib/update.js +0 -110
- package/dist/lib/upload.d.ts +0 -16
- package/dist/lib/upload.js +0 -41
|
@@ -0,0 +1,273 @@
|
|
|
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
|
+
authErrorCode,
|
|
9
|
+
createClient
|
|
10
|
+
} from "./chunk-PQDBCZRT.js";
|
|
11
|
+
import "./chunk-Z4Z24FWO.js";
|
|
12
|
+
import "./chunk-PEUP4MZR.js";
|
|
13
|
+
import {
|
|
14
|
+
outputArgs,
|
|
15
|
+
writeStructured
|
|
16
|
+
} from "./chunk-ZYCSYJWX.js";
|
|
17
|
+
import {
|
|
18
|
+
assertKnownFlags
|
|
19
|
+
} from "./chunk-RZ4DIJQW.js";
|
|
20
|
+
import {
|
|
21
|
+
getToken
|
|
22
|
+
} from "./chunk-RYFO3ZPO.js";
|
|
23
|
+
import "./chunk-J6PKNPI2.js";
|
|
24
|
+
import {
|
|
25
|
+
consola
|
|
26
|
+
} from "./chunk-CU7UY5YJ.js";
|
|
27
|
+
import {
|
|
28
|
+
defineCommand
|
|
29
|
+
} from "./chunk-MBXCVCC4.js";
|
|
30
|
+
import "./chunk-CAKBGDCY.js";
|
|
31
|
+
|
|
32
|
+
// src/commands/credits.ts
|
|
33
|
+
var creditsArgs = { ...outputArgs };
|
|
34
|
+
var MICRO_PER_USD = 1e6;
|
|
35
|
+
var SUB_CENT_MICRO = MICRO_PER_USD / 100;
|
|
36
|
+
var MAX_ENTRIES_SHOWN = 15;
|
|
37
|
+
var MIN_PURCHASE_USD = 5;
|
|
38
|
+
var MAX_PURCHASE_USD = 500;
|
|
39
|
+
var formatUsd = (micro) => {
|
|
40
|
+
const abs = Math.abs(micro);
|
|
41
|
+
const decimals = abs > 0 && abs < SUB_CENT_MICRO ? 4 : 2;
|
|
42
|
+
const base = `$${(abs / MICRO_PER_USD).toFixed(decimals)}`;
|
|
43
|
+
return micro < 0 ? `-${base}` : base;
|
|
44
|
+
};
|
|
45
|
+
var formatSignedUsd = (micro) => micro < 0 ? formatUsd(micro) : `+${formatUsd(micro)}`;
|
|
46
|
+
var kindLabel = (kind, deltaMicro) => {
|
|
47
|
+
switch (kind) {
|
|
48
|
+
case "signup_grant": {
|
|
49
|
+
return "Welcome credits";
|
|
50
|
+
}
|
|
51
|
+
case "admin_grant": {
|
|
52
|
+
return deltaMicro < 0 ? "Adjustment" : "Credit grant";
|
|
53
|
+
}
|
|
54
|
+
case "code_redeem": {
|
|
55
|
+
return "Code redeemed";
|
|
56
|
+
}
|
|
57
|
+
case "purchase": {
|
|
58
|
+
return "Credit purchase";
|
|
59
|
+
}
|
|
60
|
+
case "generation_hold": {
|
|
61
|
+
return "Generation";
|
|
62
|
+
}
|
|
63
|
+
case "generation_settle": {
|
|
64
|
+
return "Usage adjustment";
|
|
65
|
+
}
|
|
66
|
+
case "generation_release": {
|
|
67
|
+
return "Refund \u2014 failed generation";
|
|
68
|
+
}
|
|
69
|
+
default: {
|
|
70
|
+
return kind;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var formatWhen = (date, now) => {
|
|
75
|
+
const minutes = Math.floor((now.getTime() - date.getTime()) / 6e4);
|
|
76
|
+
if (minutes < 1) {
|
|
77
|
+
return "just now";
|
|
78
|
+
}
|
|
79
|
+
if (minutes < 60) {
|
|
80
|
+
return `${minutes}m ago`;
|
|
81
|
+
}
|
|
82
|
+
const hours = Math.floor(minutes / 60);
|
|
83
|
+
if (hours < 24) {
|
|
84
|
+
return `${hours}h ago`;
|
|
85
|
+
}
|
|
86
|
+
const days = Math.floor(hours / 24);
|
|
87
|
+
if (days < 7) {
|
|
88
|
+
return `${days}d ago`;
|
|
89
|
+
}
|
|
90
|
+
const opts = { day: "numeric", month: "short" };
|
|
91
|
+
if (date.getFullYear() !== now.getFullYear()) {
|
|
92
|
+
opts.year = "numeric";
|
|
93
|
+
}
|
|
94
|
+
return date.toLocaleDateString("en-US", opts);
|
|
95
|
+
};
|
|
96
|
+
var requireLogin = () => {
|
|
97
|
+
if (!getToken()) {
|
|
98
|
+
consola.warn("Not logged in. Run `vg login` to authenticate.");
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var balanceCommand = defineCommand({
|
|
103
|
+
args: creditsArgs,
|
|
104
|
+
meta: {
|
|
105
|
+
description: "Show your credit balance and recent usage (the default).",
|
|
106
|
+
name: "balance"
|
|
107
|
+
},
|
|
108
|
+
run: async ({ args, rawArgs }) => {
|
|
109
|
+
assertKnownFlags(rawArgs, creditsArgs);
|
|
110
|
+
requireLogin();
|
|
111
|
+
const client = createClient();
|
|
112
|
+
try {
|
|
113
|
+
const { balanceMicro, entries, purchasesEnabled } = await client.credits.me();
|
|
114
|
+
const payload = {
|
|
115
|
+
balance_micro: balanceMicro,
|
|
116
|
+
balance_usd: balanceMicro / MICRO_PER_USD,
|
|
117
|
+
entries: entries.map((e) => ({
|
|
118
|
+
created_at: e.createdAt.toISOString(),
|
|
119
|
+
delta_micro: e.deltaMicro,
|
|
120
|
+
endpoint_id: e.endpointId,
|
|
121
|
+
id: e.id,
|
|
122
|
+
kind: e.kind,
|
|
123
|
+
note: e.note,
|
|
124
|
+
request_id: e.requestId
|
|
125
|
+
})),
|
|
126
|
+
// Whether `vg credits buy` can take a card payment; false means codes only.
|
|
127
|
+
purchases_enabled: purchasesEnabled
|
|
128
|
+
};
|
|
129
|
+
if (writeStructured(payload, args)) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
consola.log(`Balance: ${formatUsd(balanceMicro)}`);
|
|
133
|
+
if (entries.length === 0) {
|
|
134
|
+
consola.log("No activity yet.");
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const now = /* @__PURE__ */ new Date();
|
|
138
|
+
const rows = entries.slice(0, MAX_ENTRIES_SHOWN).map((e) => ({
|
|
139
|
+
amount: formatSignedUsd(e.deltaMicro),
|
|
140
|
+
endpoint: e.endpointId ?? "",
|
|
141
|
+
label: kindLabel(e.kind, e.deltaMicro),
|
|
142
|
+
when: formatWhen(e.createdAt, now)
|
|
143
|
+
}));
|
|
144
|
+
const amountWidth = Math.max(...rows.map((r) => r.amount.length));
|
|
145
|
+
const labelWidth = Math.max(...rows.map((r) => r.label.length));
|
|
146
|
+
const endpointWidth = Math.max(...rows.map((r) => r.endpoint.length));
|
|
147
|
+
consola.log("");
|
|
148
|
+
for (const r of rows) {
|
|
149
|
+
const line = [
|
|
150
|
+
` ${r.amount.padStart(amountWidth)}`,
|
|
151
|
+
r.label.padEnd(labelWidth),
|
|
152
|
+
r.endpoint.padEnd(endpointWidth),
|
|
153
|
+
r.when
|
|
154
|
+
].join(" ");
|
|
155
|
+
consola.log(line.trimEnd());
|
|
156
|
+
}
|
|
157
|
+
} catch (error) {
|
|
158
|
+
const code = authErrorCode(error);
|
|
159
|
+
if (code === "UNAUTHORIZED" || code === "FORBIDDEN") {
|
|
160
|
+
consola.warn("Not authenticated. Run `vg login`, or check your VG_TOKEN / API key.");
|
|
161
|
+
} else {
|
|
162
|
+
consola.error(
|
|
163
|
+
`Failed to fetch credits: ${error instanceof Error ? error.message : String(error)}`
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
process.exit(1);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
var redeemArgs = {
|
|
171
|
+
...outputArgs,
|
|
172
|
+
code: { description: "The credit code to redeem.", required: true, type: "positional" }
|
|
173
|
+
};
|
|
174
|
+
var redeemCommand = defineCommand({
|
|
175
|
+
args: redeemArgs,
|
|
176
|
+
meta: {
|
|
177
|
+
description: "Redeem a credit code for generation credit (once per account per code).",
|
|
178
|
+
name: "redeem"
|
|
179
|
+
},
|
|
180
|
+
run: async ({ args, rawArgs }) => {
|
|
181
|
+
assertKnownFlags(rawArgs, redeemArgs);
|
|
182
|
+
requireLogin();
|
|
183
|
+
try {
|
|
184
|
+
const { balanceMicro, creditedMicro } = await createClient().credits.redeem({
|
|
185
|
+
code: args.code
|
|
186
|
+
});
|
|
187
|
+
const payload = {
|
|
188
|
+
balance_micro: balanceMicro,
|
|
189
|
+
balance_usd: balanceMicro / MICRO_PER_USD,
|
|
190
|
+
credited_micro: creditedMicro,
|
|
191
|
+
credited_usd: creditedMicro / MICRO_PER_USD
|
|
192
|
+
};
|
|
193
|
+
if (!writeStructured(payload, args)) {
|
|
194
|
+
consola.success(`Added ${formatUsd(creditedMicro)}. Balance: ${formatUsd(balanceMicro)}`);
|
|
195
|
+
}
|
|
196
|
+
} catch (error) {
|
|
197
|
+
if (authErrorCode(error) === "UNAUTHORIZED") {
|
|
198
|
+
consola.warn("Not authenticated. Run `vg login`, or check your VG_TOKEN / API key.");
|
|
199
|
+
} else {
|
|
200
|
+
consola.error(
|
|
201
|
+
`Could not redeem ${args.code}: ${error instanceof Error ? error.message : String(error)}`
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
process.exit(1);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
var buyArgs = {
|
|
209
|
+
...outputArgs,
|
|
210
|
+
amount: {
|
|
211
|
+
description: `Whole US dollars of credit to buy (${MIN_PURCHASE_USD}\u2013${MAX_PURCHASE_USD}).`,
|
|
212
|
+
required: true,
|
|
213
|
+
type: "positional"
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
var buyCommand = defineCommand({
|
|
217
|
+
args: buyArgs,
|
|
218
|
+
meta: {
|
|
219
|
+
description: "Start a card payment for credits and print the checkout URL. A person opens it to pay; the credit lands once the payment clears.",
|
|
220
|
+
name: "buy"
|
|
221
|
+
},
|
|
222
|
+
run: async ({ args, rawArgs }) => {
|
|
223
|
+
assertKnownFlags(rawArgs, buyArgs);
|
|
224
|
+
const amountUsd = Number(args.amount.replace(/^\$/u, ""));
|
|
225
|
+
if (!Number.isInteger(amountUsd) || amountUsd < MIN_PURCHASE_USD || amountUsd > MAX_PURCHASE_USD) {
|
|
226
|
+
consola.error(
|
|
227
|
+
`Amount must be whole dollars from ${MIN_PURCHASE_USD} to ${MAX_PURCHASE_USD}, e.g. \`vg credits buy 25\`; got "${args.amount}".`
|
|
228
|
+
);
|
|
229
|
+
process.exit(2);
|
|
230
|
+
}
|
|
231
|
+
requireLogin();
|
|
232
|
+
try {
|
|
233
|
+
const { url } = await createClient().credits.checkout({ amountUsd });
|
|
234
|
+
if (writeStructured({ amount_usd: amountUsd, url }, args)) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
consola.log(`Open this link to pay $${amountUsd} by card:
|
|
238
|
+
|
|
239
|
+
${url}
|
|
240
|
+
`);
|
|
241
|
+
consola.log("Credits are added once the payment clears \u2014 check with `vg credits`.");
|
|
242
|
+
} catch (error) {
|
|
243
|
+
const code = authErrorCode(error);
|
|
244
|
+
if (code === "UNAUTHORIZED") {
|
|
245
|
+
consola.warn("Not authenticated. Run `vg login`, or check your VG_TOKEN / API key.");
|
|
246
|
+
} else if (code === "PRECONDITION_FAILED" && error instanceof Error) {
|
|
247
|
+
consola.error(error.message);
|
|
248
|
+
} else {
|
|
249
|
+
consola.error(
|
|
250
|
+
`Could not start checkout: ${error instanceof Error ? error.message : String(error)}`
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
process.exit(1);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
var creditsCommand = defineCommand({
|
|
258
|
+
// Declared so citty skips `--field <value>` when looking for a subcommand.
|
|
259
|
+
args: outputArgs,
|
|
260
|
+
default: "balance",
|
|
261
|
+
meta: {
|
|
262
|
+
description: "Show your credit balance, redeem a code, or buy credits.",
|
|
263
|
+
name: "credits"
|
|
264
|
+
},
|
|
265
|
+
subCommands: {
|
|
266
|
+
balance: balanceCommand,
|
|
267
|
+
buy: buyCommand,
|
|
268
|
+
redeem: redeemCommand
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
export {
|
|
272
|
+
creditsCommand
|
|
273
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
consola
|
|
9
|
+
} from "./chunk-CU7UY5YJ.js";
|
|
10
|
+
import {
|
|
11
|
+
defineCommand
|
|
12
|
+
} from "./chunk-MBXCVCC4.js";
|
|
13
|
+
import "./chunk-CAKBGDCY.js";
|
|
14
|
+
|
|
15
|
+
// src/commands/factory.ts
|
|
16
|
+
import { spawnSync } from "node:child_process";
|
|
17
|
+
import { existsSync } from "node:fs";
|
|
18
|
+
import path from "node:path";
|
|
19
|
+
var FACTORY_PACKAGE = "@vibedgames/factory";
|
|
20
|
+
var npmGlobalRoot = () => {
|
|
21
|
+
try {
|
|
22
|
+
const res = spawnSync("npm", ["root", "-g"], { encoding: "utf-8", timeout: 3e4 });
|
|
23
|
+
if (res.status !== 0 || res.error !== void 0) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const root = res.stdout.trim();
|
|
27
|
+
return root || null;
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var findEntry = () => {
|
|
33
|
+
const override = process.env.VG_FACTORY_BIN;
|
|
34
|
+
if (override) {
|
|
35
|
+
return existsSync(override) ? override : null;
|
|
36
|
+
}
|
|
37
|
+
const root = npmGlobalRoot();
|
|
38
|
+
if (!root) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const entry = path.join(root, FACTORY_PACKAGE, "bin", "vg-factory.js");
|
|
42
|
+
return existsSync(entry) ? entry : null;
|
|
43
|
+
};
|
|
44
|
+
var runFactory = (args) => {
|
|
45
|
+
let entry = findEntry();
|
|
46
|
+
if (!entry) {
|
|
47
|
+
consola.start(`Installing the factory (${FACTORY_PACKAGE})\u2026`);
|
|
48
|
+
const install = spawnSync("npm", ["install", "-g", FACTORY_PACKAGE], { stdio: "inherit" });
|
|
49
|
+
if (install.status !== 0 || install.error !== void 0) {
|
|
50
|
+
consola.error(
|
|
51
|
+
`Couldn't install the factory. Try manually: npm install -g ${FACTORY_PACKAGE}`
|
|
52
|
+
);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
entry = findEntry();
|
|
56
|
+
if (!entry) {
|
|
57
|
+
consola.error(
|
|
58
|
+
`Installed ${FACTORY_PACKAGE} but couldn't find its entry under npm's global root. Check \`npm root -g\`.`
|
|
59
|
+
);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
consola.success("Factory installed.");
|
|
63
|
+
}
|
|
64
|
+
const result = spawnSync(process.execPath, [entry, ...args], { stdio: "inherit" });
|
|
65
|
+
process.exit(result.status ?? 1);
|
|
66
|
+
};
|
|
67
|
+
var factoryCommand = defineCommand({
|
|
68
|
+
meta: {
|
|
69
|
+
description: "Run the vibedgames factory \u2014 an autonomous agent that builds a browser game and evolves it like a studio (optional plugin; installs on first use). All arguments are passed through: `vg factory` opens the dashboard, `vg factory start <slug>` resumes a game.",
|
|
70
|
+
name: "factory"
|
|
71
|
+
},
|
|
72
|
+
run: ({ rawArgs }) => {
|
|
73
|
+
runFactory(rawArgs);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
export {
|
|
77
|
+
factoryCommand,
|
|
78
|
+
runFactory
|
|
79
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
findInstall,
|
|
9
|
+
isMissingCommand,
|
|
10
|
+
reportSkills,
|
|
11
|
+
run,
|
|
12
|
+
settleSync,
|
|
13
|
+
syncSkills
|
|
14
|
+
} from "./chunk-IO6OM6WM.js";
|
|
15
|
+
import "./chunk-2QBYTIMH.js";
|
|
16
|
+
import {
|
|
17
|
+
fetchLatestVersion,
|
|
18
|
+
isNewerVersion
|
|
19
|
+
} from "./chunk-SAANBZ25.js";
|
|
20
|
+
import "./chunk-6FZPPUQH.js";
|
|
21
|
+
import "./chunk-VFFOT7KD.js";
|
|
22
|
+
import {
|
|
23
|
+
PACKAGE_VERSION
|
|
24
|
+
} from "./chunk-Z4Z24FWO.js";
|
|
25
|
+
import {
|
|
26
|
+
detectPackageManager,
|
|
27
|
+
globalInstallArgs,
|
|
28
|
+
globalInstallCommand
|
|
29
|
+
} from "./chunk-PEUP4MZR.js";
|
|
30
|
+
import {
|
|
31
|
+
assertKnownFlags
|
|
32
|
+
} from "./chunk-RZ4DIJQW.js";
|
|
33
|
+
import "./chunk-RYFO3ZPO.js";
|
|
34
|
+
import "./chunk-J6PKNPI2.js";
|
|
35
|
+
import {
|
|
36
|
+
consola
|
|
37
|
+
} from "./chunk-CU7UY5YJ.js";
|
|
38
|
+
import {
|
|
39
|
+
defineCommand
|
|
40
|
+
} from "./chunk-MBXCVCC4.js";
|
|
41
|
+
import "./chunk-CAKBGDCY.js";
|
|
42
|
+
|
|
43
|
+
// src/commands/update.ts
|
|
44
|
+
var updateInstalledSkills = async (global) => {
|
|
45
|
+
const found = findInstall(global ? ["global"] : ["project", "global"]);
|
|
46
|
+
return found ? await syncSkills(found.target, found.agents) : null;
|
|
47
|
+
};
|
|
48
|
+
var updateArgs = {
|
|
49
|
+
auto: {
|
|
50
|
+
default: false,
|
|
51
|
+
description: "(internal) silent background mode: only update when the registry has a newer version",
|
|
52
|
+
type: "boolean"
|
|
53
|
+
},
|
|
54
|
+
global: {
|
|
55
|
+
alias: "g",
|
|
56
|
+
default: false,
|
|
57
|
+
description: "Update skills installed in the user directory instead of the project",
|
|
58
|
+
type: "boolean"
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var updateCommand = defineCommand({
|
|
62
|
+
args: updateArgs,
|
|
63
|
+
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`)",
|
|
65
|
+
name: "update"
|
|
66
|
+
},
|
|
67
|
+
run: async ({ args, rawArgs }) => {
|
|
68
|
+
assertKnownFlags(rawArgs, updateArgs);
|
|
69
|
+
const manager = detectPackageManager(import.meta.filename);
|
|
70
|
+
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
|
+
]);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
consola.start("Updating the vg CLI and vibedgames skills...");
|
|
83
|
+
const [cli, skills] = await Promise.all([
|
|
84
|
+
run(manager, globalInstallArgs(manager)),
|
|
85
|
+
settleSync(updateInstalledSkills(args.global))
|
|
86
|
+
]);
|
|
87
|
+
if (cli.code === 0) {
|
|
88
|
+
consola.success(`vg CLI updated to latest with ${manager}`);
|
|
89
|
+
} else {
|
|
90
|
+
if (cli.output.trim() && !isMissingCommand(cli)) {
|
|
91
|
+
consola.warn(cli.output.trim());
|
|
92
|
+
}
|
|
93
|
+
consola.warn(
|
|
94
|
+
isMissingCommand(cli) ? `Couldn't find ${manager} to update the vg CLI. Update manually: ${globalInstallCommand(manager)}` : `Couldn't update the vg CLI (${manager} exit ${cli.code}). Update manually: ${globalInstallCommand(manager)}`
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
if (!skills.ok) {
|
|
98
|
+
consola.warn(`Couldn't update the skills: ${skills.message}`);
|
|
99
|
+
} else if (skills.value) {
|
|
100
|
+
reportSkills(skills.value);
|
|
101
|
+
} else {
|
|
102
|
+
consola.info("No vibedgames skills installed here or in your home directory: run vg init");
|
|
103
|
+
}
|
|
104
|
+
if (cli.code !== 0 && !skills.ok) {
|
|
105
|
+
throw new Error("update failed for both the CLI and skills");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
export {
|
|
110
|
+
updateCommand
|
|
111
|
+
};
|