gipity 1.1.29 → 1.1.31
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/dist/commands/deploy.js +1 -2
- package/dist/commands/email.js +2 -0
- package/dist/commands/page-eval.js +25 -0
- package/dist/commands/page-test.js +24 -10
- package/dist/commands/sandbox.js +9 -0
- package/dist/commands/update.js +8 -2
- package/dist/index.js +151 -86
- package/dist/updater/bootstrap.js +4 -9
- package/dist/updater/check.js +29 -3
- package/dist/updater/install.js +13 -0
- package/dist/updater/shim.js +45 -25
- package/dist/updater/state.js +27 -1
- package/package.json +1 -1
package/dist/commands/deploy.js
CHANGED
|
@@ -53,8 +53,7 @@ export const deployCommand = new Command('deploy')
|
|
|
53
53
|
.option('--only <phases>', 'Run only specific phases, comma-separated, matched by gipity.yaml phase name or type: files/static, database/sql, functions, workflows, services, jobs, records, realtime, env, auth_branding')
|
|
54
54
|
.option('--force', 'Re-run all phases (ignore checksums) and bypass the sync bulk-deletion guard')
|
|
55
55
|
.option('--no-sync', 'Skip sync-up before deploy')
|
|
56
|
-
.option('--optimize', '
|
|
57
|
-
.option('--no-optimize', 'Skip build optimization and upload files as-is - the escape hatch for plain-HTML apps whose <script src> tags are not type="module"')
|
|
56
|
+
.option('--optimize', 'Bundle and minify the JS/CSS with Vite (off by default: files upload as-is, so prod serves what you verified). Only bundles <script type="module"> references, and page eval import() of an app module then loads a separate copy')
|
|
58
57
|
.option('--json', 'Output as JSON')
|
|
59
58
|
.option('--inspect [path]', 'After a successful deploy, run `page inspect` on the deployed URL (or URL + path) in the same command - one build-loop step instead of two. With --json, emits two JSON lines: deploy, then inspect.')
|
|
60
59
|
// The settle knobs `page inspect` already has. An app whose first paint is behind
|
package/dist/commands/email.js
CHANGED
|
@@ -71,6 +71,8 @@ emailCommand
|
|
|
71
71
|
const subj = r.detail?.subject ? ` · ${r.detail.subject}` : '';
|
|
72
72
|
const status = r.detail?.status ? ` [skipped: ${r.detail.status}]` : '';
|
|
73
73
|
console.log(` ${muted(when)} ${to}${status ? warning(status) : ''}${muted(subj)}`);
|
|
74
|
+
if (r.detail?.reason)
|
|
75
|
+
console.log(` ${muted(r.detail.reason)}`);
|
|
74
76
|
}
|
|
75
77
|
}));
|
|
76
78
|
//# sourceMappingURL=email.js.map
|
|
@@ -325,6 +325,22 @@ export function slowRenderMessage(fps, o) {
|
|
|
325
325
|
+ `Step the app's own loop deterministically instead (3D templates: ${bold('core.advance(seconds)')}; `
|
|
326
326
|
+ `2D/Phaser template: ${bold("(await import('./js/config.js')).advance(seconds)")}).`;
|
|
327
327
|
}
|
|
328
|
+
/** A slow eval should say which leg was slow, instead of leaving the caller to
|
|
329
|
+
* guess a longer --wait. Silent under SLOW_EVAL_MS. Exported for tests. */
|
|
330
|
+
const SLOW_EVAL_MS = 20_000;
|
|
331
|
+
export function evalTimingLine(t) {
|
|
332
|
+
const total = t.hostMs + t.submitMs + t.pollMs;
|
|
333
|
+
if (total < SLOW_EVAL_MS)
|
|
334
|
+
return null;
|
|
335
|
+
const s = (ms) => `${(ms / 1000).toFixed(1)}s`;
|
|
336
|
+
const parts = [
|
|
337
|
+
t.hostMs >= 500 ? `hosting files ${s(t.hostMs)}` : null,
|
|
338
|
+
t.submitMs >= 500 ? `camera/feed setup ${s(t.submitMs)}` : null,
|
|
339
|
+
t.browserMs !== undefined ? `browser ${s(t.browserMs)} (launch, page load, waits, script)` : `browser ${s(t.pollMs)}`,
|
|
340
|
+
t.browserMs !== undefined && t.pollMs - t.browserMs >= 2000 ? `queue + cleanup ${s(t.pollMs - t.browserMs)}` : null,
|
|
341
|
+
].filter(Boolean);
|
|
342
|
+
return `timing: ${s(total)} = ${parts.join(' + ')}`;
|
|
343
|
+
}
|
|
328
344
|
/** Poll the async eval job until it finishes. Eval runs server-side as a
|
|
329
345
|
* short-lived job (so a long --wait can't trip the gateway idle timeout);
|
|
330
346
|
* we submit, then poll the result out of the job store. `expectedWorkMs` is
|
|
@@ -600,6 +616,7 @@ export const pageEvalCommand = new Command('eval')
|
|
|
600
616
|
const { config } = await resolveProjectContext({});
|
|
601
617
|
projectGuid = config.projectGuid;
|
|
602
618
|
}
|
|
619
|
+
const hostStart = Date.now();
|
|
603
620
|
if (opts.camera) {
|
|
604
621
|
console.log(muted(`Hosting camera feed ${opts.camera}...`));
|
|
605
622
|
camera = await uploadCameraFeed(projectGuid, opts.camera);
|
|
@@ -621,6 +638,7 @@ export const pageEvalCommand = new Command('eval')
|
|
|
621
638
|
if (settleAfterGateMs > 0) {
|
|
622
639
|
sentExpr = withPrelude(sentExpr, `await new Promise((r) => setTimeout(r, ${settleAfterGateMs}));`);
|
|
623
640
|
}
|
|
641
|
+
const submitStart = Date.now();
|
|
624
642
|
const kickoff = await post('/tools/browser/eval', {
|
|
625
643
|
url, expr: sentExpr, waitMs: sentWaitMs,
|
|
626
644
|
steps: sentSteps.length ? sentSteps : undefined,
|
|
@@ -634,6 +652,7 @@ export const pageEvalCommand = new Command('eval')
|
|
|
634
652
|
fakeMedia: opts.fakeMedia || !!camera || undefined,
|
|
635
653
|
cameraUrl: camera?.url,
|
|
636
654
|
});
|
|
655
|
+
const pollStart = Date.now();
|
|
637
656
|
let d;
|
|
638
657
|
try {
|
|
639
658
|
d = await pollEvalResult(kickoff.data.evalJobId, evalWorkBudgetMs({
|
|
@@ -658,6 +677,12 @@ export const pageEvalCommand = new Command('eval')
|
|
|
658
677
|
throw err;
|
|
659
678
|
throw new Error(`${msg}\n${hint}`);
|
|
660
679
|
}
|
|
680
|
+
const timing = evalTimingLine({
|
|
681
|
+
hostMs: submitStart - hostStart, submitMs: pollStart - submitStart,
|
|
682
|
+
pollMs: Date.now() - pollStart, browserMs: d.browserMs,
|
|
683
|
+
});
|
|
684
|
+
if (timing)
|
|
685
|
+
console.error(muted(timing));
|
|
661
686
|
const { result, noValue } = normalizeEvalResult(d.result);
|
|
662
687
|
const reload = d.reloadResult !== undefined ? normalizeEvalResult(d.reloadResult) : undefined;
|
|
663
688
|
const execTimeout = evalExecTimeoutMessage(d.result, scriptBudgetMs);
|
|
@@ -18,6 +18,12 @@ async function inspectClient(url, waitMs, i) {
|
|
|
18
18
|
}
|
|
19
19
|
const MAX_HOLD_MS = 15_000; // keep each in-page await under the ~20s browser action timeout
|
|
20
20
|
const MIN_HOLD_MS = 1_000;
|
|
21
|
+
// Clients start on separate browser containers, and a cold one can take longer
|
|
22
|
+
// to load than a whole --hold, so "each client holds from its own load" left a
|
|
23
|
+
// late client sampling after the early one had closed its page (a false
|
|
24
|
+
// "did NOT overlap" even with --stagger 0). Every client instead waits, page
|
|
25
|
+
// open, until a shared start time this far after its launch, then holds.
|
|
26
|
+
export const JOIN_ALLOWANCE_MS = 12_000;
|
|
21
27
|
// ── lifecycle actions (--at) ───────────────────────────────────────────────
|
|
22
28
|
// Freeze, hide, or take one client offline partway through the hold window, so
|
|
23
29
|
// an app can test what its peers do when a phone locks (host handoff) instead
|
|
@@ -146,13 +152,15 @@ function warnUnknownTokens(unknown) {
|
|
|
146
152
|
/** Build the statement-body script one client runs: do the one-time action,
|
|
147
153
|
* then sample `observe` `samples` times across `holdMs`, stamping in-page
|
|
148
154
|
* start/end so the caller can confirm the clients overlapped. */
|
|
149
|
-
export function buildHarness(action, observe, label, holdMs, samples) {
|
|
155
|
+
export function buildHarness(action, observe, label, holdMs, samples, startAt) {
|
|
150
156
|
const n = Math.max(2, samples);
|
|
151
157
|
const interval = Math.max(0, Math.floor(holdMs / (n - 1)));
|
|
152
|
-
const lines = [
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
158
|
+
const lines = [`const __label=${JSON.stringify(label)};`];
|
|
159
|
+
// Shared start (see JOIN_ALLOWANCE_MS). Capped so a skewed clock can't eat the budget.
|
|
160
|
+
if (startAt !== undefined) {
|
|
161
|
+
lines.push(`{ const __bw=Math.min(${startAt}-Date.now(),${JOIN_ALLOWANCE_MS}); if(__bw>0) await new Promise(function(r){setTimeout(r,__bw);}); }`);
|
|
162
|
+
}
|
|
163
|
+
lines.push(`const __t0=Date.now();`);
|
|
156
164
|
if (action && action.trim()) {
|
|
157
165
|
lines.push(`try{ ${action} }catch(__e){ return {label:__label,startedAt:__t0,endedAt:Date.now(),samples:[],actionError:String((__e&&__e.message)||__e)}; }`);
|
|
158
166
|
}
|
|
@@ -166,7 +174,7 @@ export function buildHarness(action, observe, label, holdMs, samples) {
|
|
|
166
174
|
return lines.join('\n');
|
|
167
175
|
}
|
|
168
176
|
/** Kick off and poll one client's eval job, then parse the harness payload. */
|
|
169
|
-
async function observeClient(url, expr, i, label, settleMs, holdMs, waitForSelector, lifecycle) {
|
|
177
|
+
async function observeClient(url, expr, i, label, settleMs, holdMs, waitForSelector, lifecycle, barrier = false) {
|
|
170
178
|
const base = { i, label, samples: [], startedAt: 0, endedAt: 0 };
|
|
171
179
|
try {
|
|
172
180
|
const kickoff = await post('/tools/browser/eval', {
|
|
@@ -175,12 +183,14 @@ async function observeClient(url, expr, i, label, settleMs, holdMs, waitForSelec
|
|
|
175
183
|
waitMs: settleMs,
|
|
176
184
|
waitForSelector: waitForSelector || undefined,
|
|
177
185
|
waitForTimeoutMs: waitForSelector ? 5000 : undefined,
|
|
186
|
+
// The shared-start wait runs inside the script, so the script needs room for it.
|
|
187
|
+
timeoutMs: barrier ? JOIN_ALLOWANCE_MS + holdMs + 10_000 : undefined,
|
|
178
188
|
// Timed from the start of the observe window; the server restores
|
|
179
189
|
// anything still applied at the end of the hold so the harness finishes.
|
|
180
190
|
lifecycle: lifecycle?.length ? { steps: lifecycle, untilMs: holdMs } : undefined,
|
|
181
191
|
});
|
|
182
192
|
// Server work ≈ nav + settle + the in-page hold; pollEvalResult adds 60s headroom.
|
|
183
|
-
const d = await pollEvalResult(kickoff.data.evalJobId, settleMs + holdMs);
|
|
193
|
+
const d = await pollEvalResult(kickoff.data.evalJobId, settleMs + holdMs + (barrier ? JOIN_ALLOWANCE_MS : 0));
|
|
184
194
|
const raw = d.result?.trim() ?? '';
|
|
185
195
|
if (raw.startsWith('EvalError:') || raw.startsWith('ObserveError:')) {
|
|
186
196
|
return { ...base, error: raw };
|
|
@@ -287,6 +297,10 @@ async function runInteractive(url, observe, opts) {
|
|
|
287
297
|
if (atSpecs.length)
|
|
288
298
|
console.log(muted(`lifecycle (ms into each client's hold): ${atSpecs.map((s) => s.trim()).join(', ')}`));
|
|
289
299
|
}
|
|
300
|
+
// Shared start for multi-client runs. Not with --at: its steps are timed from
|
|
301
|
+
// the script's start on the server, and a variable wait would shift them.
|
|
302
|
+
const barrier = clients > 1 && atSpecs.length === 0;
|
|
303
|
+
const t0 = Date.now();
|
|
290
304
|
const runs = [];
|
|
291
305
|
for (let i = 0; i < clients; i++) {
|
|
292
306
|
runs.push((async () => {
|
|
@@ -297,8 +311,8 @@ async function runInteractive(url, observe, opts) {
|
|
|
297
311
|
// asymmetric roles concurrently (e.g. ?role={{label}} with --labels host,join)
|
|
298
312
|
// and the overlap check still confirms they coexisted.
|
|
299
313
|
const clientUrl = subst(url, labelFor(i), i);
|
|
300
|
-
const expr = buildHarness(opts.action ? subst(opts.action, labelFor(i), i) : undefined, subst(observe, labelFor(i), i), labelFor(i), hold, samples);
|
|
301
|
-
return observeClient(clientUrl, expr, i, labelFor(i), settle, hold, opts.waitFor, lifecycle[i]);
|
|
314
|
+
const expr = buildHarness(opts.action ? subst(opts.action, labelFor(i), i) : undefined, subst(observe, labelFor(i), i), labelFor(i), hold, samples, barrier ? t0 + i * stagger * 1000 + JOIN_ALLOWANCE_MS : undefined);
|
|
315
|
+
return observeClient(clientUrl, expr, i, labelFor(i), settle, hold, opts.waitFor, lifecycle[i], barrier);
|
|
302
316
|
})());
|
|
303
317
|
}
|
|
304
318
|
const results = (await Promise.all(runs)).sort((a, b) => a.i - b.i);
|
|
@@ -340,7 +354,7 @@ async function runInteractive(url, observe, opts) {
|
|
|
340
354
|
}
|
|
341
355
|
else {
|
|
342
356
|
console.log(clrError('⚠ clients did NOT overlap in time: each ran in isolation, so any shared-state reading here is a FALSE NEGATIVE, not proof the app is broken.'));
|
|
343
|
-
console.log(muted(
|
|
357
|
+
console.log(muted(` Each client waits up to ${JOIN_ALLOWANCE_MS / 1000}s after launch for the others to load, then holds. Likely causes: --stagger ≥ --hold, or a client queued for a browser (more --clients than free slots). Lower --stagger / raise --hold / fewer --clients and retry.`));
|
|
344
358
|
}
|
|
345
359
|
if (errored.length > 0 || (clients > 1 && !overlapped))
|
|
346
360
|
process.exitCode = 1;
|
package/dist/commands/sandbox.js
CHANGED
|
@@ -383,6 +383,15 @@ GCC/Rust).
|
|
|
383
383
|
process.exit(1);
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
|
+
// Empty code is never what the caller meant: usually `"$(cat missing.py)"`
|
|
387
|
+
// expanded to nothing, or an empty file. Say so here, before the server
|
|
388
|
+
// rejects it with a bare schema message.
|
|
389
|
+
if (!source?.trim()) {
|
|
390
|
+
console.error(clrError(filePath
|
|
391
|
+
? `${filePath} is empty: nothing to run.`
|
|
392
|
+
: 'The inline code is empty: nothing to run. If it came from "$(cat <file>)", that file is missing or empty; pass --file <path> instead.'));
|
|
393
|
+
process.exit(1);
|
|
394
|
+
}
|
|
386
395
|
// Language precedence: interpreter token > --language > file extension >
|
|
387
396
|
// unambiguous-command-line heuristic (bash). resolveLanguage() exits when
|
|
388
397
|
// nothing pins one and the input isn't command-shaped, rather than guessing.
|
package/dist/commands/update.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { runCheck } from '../updater/check.js';
|
|
3
|
+
import { PKG_ROOT } from '../updater/state.js';
|
|
3
4
|
import { success, warning, info, dim } from '../colors.js';
|
|
4
5
|
export const updateCommand = new Command('update')
|
|
5
6
|
.description('Update the CLI')
|
|
@@ -15,9 +16,10 @@ export const updateCommand = new Command('update')
|
|
|
15
16
|
upToDate: result.reason === 'up-to-date',
|
|
16
17
|
from: result.from ?? null,
|
|
17
18
|
to: result.to ?? null,
|
|
18
|
-
|
|
19
|
+
devLink: result.reason === 'dev-link',
|
|
20
|
+
reason: result.updated || result.reason === 'up-to-date' || result.reason === 'dev-link' ? null : result.reason ?? null,
|
|
19
21
|
}));
|
|
20
|
-
if (!result.updated && result.reason !== 'up-to-date')
|
|
22
|
+
if (!result.updated && result.reason !== 'up-to-date' && result.reason !== 'dev-link')
|
|
21
23
|
process.exitCode = 1;
|
|
22
24
|
return;
|
|
23
25
|
}
|
|
@@ -26,6 +28,10 @@ export const updateCommand = new Command('update')
|
|
|
26
28
|
console.log(success(`Updated ${result.from} → ${result.to}`));
|
|
27
29
|
console.log(dim(`Installed. This command ran on ${result.from}; everything from here on uses ${result.to}.`));
|
|
28
30
|
}
|
|
31
|
+
else if (result.reason === 'dev-link') {
|
|
32
|
+
console.log(info(`This gipity is linked to a source checkout (${PKG_ROOT}) and runs its build, so it never auto-updates.`));
|
|
33
|
+
console.log(dim('To update it, pull that checkout and run `just cli-link` there.'));
|
|
34
|
+
}
|
|
29
35
|
else if (result.reason === 'up-to-date') {
|
|
30
36
|
console.log(success('Already on the latest version.'));
|
|
31
37
|
}
|
package/dist/index.js
CHANGED
|
@@ -3979,10 +3979,10 @@ function prompt(question, output = process.stdout) {
|
|
|
3979
3979
|
return Promise.reject(new Error(`prompt() called without a TTY: ${question.trim()}`));
|
|
3980
3980
|
}
|
|
3981
3981
|
const rl2 = createInterface({ input: process.stdin, output });
|
|
3982
|
-
return new Promise((
|
|
3982
|
+
return new Promise((resolve21) => {
|
|
3983
3983
|
rl2.question(question, (answer) => {
|
|
3984
3984
|
rl2.close();
|
|
3985
|
-
|
|
3985
|
+
resolve21(answer.trim());
|
|
3986
3986
|
});
|
|
3987
3987
|
});
|
|
3988
3988
|
}
|
|
@@ -4013,7 +4013,7 @@ async function confirm(question, opts = {}) {
|
|
|
4013
4013
|
const wasRaw = stdin.isRaw ?? false;
|
|
4014
4014
|
stdin.setRawMode(true);
|
|
4015
4015
|
stdin.resume();
|
|
4016
|
-
return new Promise((
|
|
4016
|
+
return new Promise((resolve21) => {
|
|
4017
4017
|
stdin.once("data", (key) => {
|
|
4018
4018
|
stdin.setRawMode(wasRaw);
|
|
4019
4019
|
stdin.pause();
|
|
@@ -4028,12 +4028,12 @@ async function confirm(question, opts = {}) {
|
|
|
4028
4028
|
else if (k7 === "n") answer = false;
|
|
4029
4029
|
else answer = defaultYes;
|
|
4030
4030
|
console.log(answer ? "y" : "n");
|
|
4031
|
-
|
|
4031
|
+
resolve21(answer);
|
|
4032
4032
|
});
|
|
4033
4033
|
});
|
|
4034
4034
|
}
|
|
4035
4035
|
function pickOne(label2, max, defaultIdx = 1) {
|
|
4036
|
-
return new Promise((
|
|
4036
|
+
return new Promise((resolve21, reject) => {
|
|
4037
4037
|
process.stdout.write(` ${bold(label2)} (1-${max}) [${bold(String(defaultIdx))}]: `);
|
|
4038
4038
|
const { stdin } = process;
|
|
4039
4039
|
const wasRaw = stdin.isRaw ?? false;
|
|
@@ -4055,13 +4055,13 @@ function pickOne(label2, max, defaultIdx = 1) {
|
|
|
4055
4055
|
if (ch === "\r" || ch === "\n") {
|
|
4056
4056
|
cleanup();
|
|
4057
4057
|
console.log(String(defaultIdx));
|
|
4058
|
-
return
|
|
4058
|
+
return resolve21(defaultIdx);
|
|
4059
4059
|
}
|
|
4060
4060
|
const n = parseInt(ch, 10);
|
|
4061
4061
|
if (n >= 1 && n <= max) {
|
|
4062
4062
|
cleanup();
|
|
4063
4063
|
console.log(String(n));
|
|
4064
|
-
return
|
|
4064
|
+
return resolve21(n);
|
|
4065
4065
|
}
|
|
4066
4066
|
};
|
|
4067
4067
|
const onEnd = () => {
|
|
@@ -5420,8 +5420,8 @@ var require_streamx = __commonJS({
|
|
|
5420
5420
|
return this;
|
|
5421
5421
|
},
|
|
5422
5422
|
next() {
|
|
5423
|
-
return new Promise(function(
|
|
5424
|
-
promiseResolve =
|
|
5423
|
+
return new Promise(function(resolve21, reject) {
|
|
5424
|
+
promiseResolve = resolve21;
|
|
5425
5425
|
promiseReject = reject;
|
|
5426
5426
|
const data = stream.read();
|
|
5427
5427
|
if (data !== null) ondata(data);
|
|
@@ -5451,11 +5451,11 @@ var require_streamx = __commonJS({
|
|
|
5451
5451
|
}
|
|
5452
5452
|
function destroy(err) {
|
|
5453
5453
|
stream.destroy(err);
|
|
5454
|
-
return new Promise((
|
|
5455
|
-
if (stream._duplexState & DESTROYED) return
|
|
5454
|
+
return new Promise((resolve21, reject) => {
|
|
5455
|
+
if (stream._duplexState & DESTROYED) return resolve21({ value: void 0, done: true });
|
|
5456
5456
|
stream.once("close", function() {
|
|
5457
5457
|
if (err) reject(err);
|
|
5458
|
-
else
|
|
5458
|
+
else resolve21({ value: void 0, done: true });
|
|
5459
5459
|
});
|
|
5460
5460
|
});
|
|
5461
5461
|
}
|
|
@@ -5499,8 +5499,8 @@ var require_streamx = __commonJS({
|
|
|
5499
5499
|
const writes = pending + (ws2._duplexState & WRITE_WRITING ? 1 : 0);
|
|
5500
5500
|
if (writes === 0) return Promise.resolve(true);
|
|
5501
5501
|
if (state.drains === null) state.drains = [];
|
|
5502
|
-
return new Promise((
|
|
5503
|
-
state.drains.push({ writes, resolve:
|
|
5502
|
+
return new Promise((resolve21) => {
|
|
5503
|
+
state.drains.push({ writes, resolve: resolve21 });
|
|
5504
5504
|
});
|
|
5505
5505
|
}
|
|
5506
5506
|
write(data) {
|
|
@@ -5605,10 +5605,10 @@ var require_streamx = __commonJS({
|
|
|
5605
5605
|
cb2(null);
|
|
5606
5606
|
}
|
|
5607
5607
|
function pipelinePromise(...streams) {
|
|
5608
|
-
return new Promise((
|
|
5608
|
+
return new Promise((resolve21, reject) => {
|
|
5609
5609
|
return pipeline(...streams, (err) => {
|
|
5610
5610
|
if (err) return reject(err);
|
|
5611
|
-
|
|
5611
|
+
resolve21();
|
|
5612
5612
|
});
|
|
5613
5613
|
});
|
|
5614
5614
|
}
|
|
@@ -6263,16 +6263,16 @@ var require_extract = __commonJS({
|
|
|
6263
6263
|
entryCallback = null;
|
|
6264
6264
|
cb2(err);
|
|
6265
6265
|
}
|
|
6266
|
-
function onnext(
|
|
6266
|
+
function onnext(resolve21, reject) {
|
|
6267
6267
|
if (error2) {
|
|
6268
6268
|
return reject(error2);
|
|
6269
6269
|
}
|
|
6270
6270
|
if (entryStream) {
|
|
6271
|
-
|
|
6271
|
+
resolve21({ value: entryStream, done: false });
|
|
6272
6272
|
entryStream = null;
|
|
6273
6273
|
return;
|
|
6274
6274
|
}
|
|
6275
|
-
promiseResolve =
|
|
6275
|
+
promiseResolve = resolve21;
|
|
6276
6276
|
promiseReject = reject;
|
|
6277
6277
|
consumeCallback(null);
|
|
6278
6278
|
if (extract3._finished && promiseResolve) {
|
|
@@ -6300,11 +6300,11 @@ var require_extract = __commonJS({
|
|
|
6300
6300
|
function destroy(err) {
|
|
6301
6301
|
extract3.destroy(err);
|
|
6302
6302
|
consumeCallback(err);
|
|
6303
|
-
return new Promise((
|
|
6304
|
-
if (extract3.destroyed) return
|
|
6303
|
+
return new Promise((resolve21, reject) => {
|
|
6304
|
+
if (extract3.destroyed) return resolve21({ value: void 0, done: true });
|
|
6305
6305
|
extract3.once("close", function() {
|
|
6306
6306
|
if (err) reject(err);
|
|
6307
|
-
else
|
|
6307
|
+
else resolve21({ value: void 0, done: true });
|
|
6308
6308
|
});
|
|
6309
6309
|
});
|
|
6310
6310
|
}
|
|
@@ -6705,13 +6705,13 @@ function claudeAuthStatus() {
|
|
|
6705
6705
|
}
|
|
6706
6706
|
}
|
|
6707
6707
|
function claudeAuthStatusAsync() {
|
|
6708
|
-
return new Promise((
|
|
6708
|
+
return new Promise((resolve21) => {
|
|
6709
6709
|
let out = "";
|
|
6710
6710
|
let settled = false;
|
|
6711
6711
|
const done = (v7) => {
|
|
6712
6712
|
if (!settled) {
|
|
6713
6713
|
settled = true;
|
|
6714
|
-
|
|
6714
|
+
resolve21(v7);
|
|
6715
6715
|
}
|
|
6716
6716
|
};
|
|
6717
6717
|
let child;
|
|
@@ -9232,7 +9232,7 @@ async function postForTarEntries(path5, body, retried = false) {
|
|
|
9232
9232
|
}
|
|
9233
9233
|
const extract3 = tar.extract();
|
|
9234
9234
|
const entries = [];
|
|
9235
|
-
const done = new Promise((
|
|
9235
|
+
const done = new Promise((resolve21, reject) => {
|
|
9236
9236
|
extract3.on("entry", (header, stream, next) => {
|
|
9237
9237
|
const chunks = [];
|
|
9238
9238
|
stream.on("data", (c) => chunks.push(c));
|
|
@@ -9243,7 +9243,7 @@ async function postForTarEntries(path5, body, retried = false) {
|
|
|
9243
9243
|
stream.on("error", reject);
|
|
9244
9244
|
stream.resume();
|
|
9245
9245
|
});
|
|
9246
|
-
extract3.on("finish", () =>
|
|
9246
|
+
extract3.on("finish", () => resolve21());
|
|
9247
9247
|
extract3.on("error", reject);
|
|
9248
9248
|
});
|
|
9249
9249
|
return read(async () => {
|
|
@@ -34369,8 +34369,8 @@ init_config();
|
|
|
34369
34369
|
init_setup();
|
|
34370
34370
|
init_utils();
|
|
34371
34371
|
import { readFileSync as readFileSync32 } from "fs";
|
|
34372
|
-
import { fileURLToPath as
|
|
34373
|
-
import { dirname as
|
|
34372
|
+
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
34373
|
+
import { dirname as dirname17, resolve as resolve20 } from "path";
|
|
34374
34374
|
|
|
34375
34375
|
// src/helpers/output.ts
|
|
34376
34376
|
var frameOpen = false;
|
|
@@ -34798,25 +34798,25 @@ async function hashFile(path5) {
|
|
|
34798
34798
|
const hash = createHash("sha256");
|
|
34799
34799
|
let size = 0;
|
|
34800
34800
|
const stream = createReadStream(path5);
|
|
34801
|
-
await new Promise((
|
|
34801
|
+
await new Promise((resolve21, reject) => {
|
|
34802
34802
|
stream.on("data", (chunk) => {
|
|
34803
34803
|
const buf = chunk;
|
|
34804
34804
|
hash.update(buf);
|
|
34805
34805
|
size += buf.length;
|
|
34806
34806
|
});
|
|
34807
|
-
stream.on("end", () =>
|
|
34807
|
+
stream.on("end", () => resolve21());
|
|
34808
34808
|
stream.on("error", reject);
|
|
34809
34809
|
});
|
|
34810
34810
|
return { sha256: hash.digest("hex"), size };
|
|
34811
34811
|
}
|
|
34812
34812
|
function readRange(path5, start, end) {
|
|
34813
|
-
return new Promise((
|
|
34813
|
+
return new Promise((resolve21, reject) => {
|
|
34814
34814
|
const chunks = [];
|
|
34815
34815
|
const stream = createReadStream(path5, { start, end });
|
|
34816
34816
|
stream.on("data", (c) => {
|
|
34817
34817
|
chunks.push(c);
|
|
34818
34818
|
});
|
|
34819
|
-
stream.on("end", () =>
|
|
34819
|
+
stream.on("end", () => resolve21(Buffer.concat(chunks)));
|
|
34820
34820
|
stream.on("error", reject);
|
|
34821
34821
|
});
|
|
34822
34822
|
}
|
|
@@ -35207,7 +35207,7 @@ async function fetchRemote(projectGuid2) {
|
|
|
35207
35207
|
function extractTarToMap(stream, idleMs, onBytes, keep) {
|
|
35208
35208
|
const extract3 = tar2.extract();
|
|
35209
35209
|
const files = /* @__PURE__ */ new Map();
|
|
35210
|
-
return new Promise((
|
|
35210
|
+
return new Promise((resolve21, reject) => {
|
|
35211
35211
|
let settled = false;
|
|
35212
35212
|
let idle;
|
|
35213
35213
|
const arm = () => {
|
|
@@ -35243,7 +35243,7 @@ function extractTarToMap(stream, idleMs, onBytes, keep) {
|
|
|
35243
35243
|
});
|
|
35244
35244
|
entryStream.resume();
|
|
35245
35245
|
});
|
|
35246
|
-
extract3.on("finish", () => done(
|
|
35246
|
+
extract3.on("finish", () => done(resolve21, files));
|
|
35247
35247
|
extract3.on("error", (e) => done(reject, e));
|
|
35248
35248
|
stream.on("error", (e) => done(reject, e));
|
|
35249
35249
|
arm();
|
|
@@ -38185,6 +38185,19 @@ function slowRenderMessage(fps, o) {
|
|
|
38185
38185
|
}
|
|
38186
38186
|
return `${warning("\u26A0 Slow render:")} page painted at ${fps} fps. Waiting on real time (setTimeout) advances animation/physics time far slower than it looks: assertions after a wall-clock wait can report a false negative. Step the app's own loop deterministically instead (3D templates: ${bold("core.advance(seconds)")}; 2D/Phaser template: ${bold("(await import('./js/config.js')).advance(seconds)")}).`;
|
|
38187
38187
|
}
|
|
38188
|
+
var SLOW_EVAL_MS = 2e4;
|
|
38189
|
+
function evalTimingLine(t) {
|
|
38190
|
+
const total = t.hostMs + t.submitMs + t.pollMs;
|
|
38191
|
+
if (total < SLOW_EVAL_MS) return null;
|
|
38192
|
+
const s = (ms2) => `${(ms2 / 1e3).toFixed(1)}s`;
|
|
38193
|
+
const parts = [
|
|
38194
|
+
t.hostMs >= 500 ? `hosting files ${s(t.hostMs)}` : null,
|
|
38195
|
+
t.submitMs >= 500 ? `camera/feed setup ${s(t.submitMs)}` : null,
|
|
38196
|
+
t.browserMs !== void 0 ? `browser ${s(t.browserMs)} (launch, page load, waits, script)` : `browser ${s(t.pollMs)}`,
|
|
38197
|
+
t.browserMs !== void 0 && t.pollMs - t.browserMs >= 2e3 ? `queue + cleanup ${s(t.pollMs - t.browserMs)}` : null
|
|
38198
|
+
].filter(Boolean);
|
|
38199
|
+
return `timing: ${s(total)} = ${parts.join(" + ")}`;
|
|
38200
|
+
}
|
|
38188
38201
|
async function pollEvalResult(evalJobId, expectedWorkMs) {
|
|
38189
38202
|
const deadline = Date.now() + expectedWorkMs + 6e4;
|
|
38190
38203
|
let missCount = 0;
|
|
@@ -38346,6 +38359,7 @@ var pageEvalCommand = new Command("eval").description("Evaluate JS in a real bro
|
|
|
38346
38359
|
const { config } = await resolveProjectContext({});
|
|
38347
38360
|
projectGuid2 = config.projectGuid;
|
|
38348
38361
|
}
|
|
38362
|
+
const hostStart = Date.now();
|
|
38349
38363
|
if (opts.camera) {
|
|
38350
38364
|
console.log(muted(`Hosting camera feed ${opts.camera}...`));
|
|
38351
38365
|
camera = await uploadCameraFeed(projectGuid2, opts.camera);
|
|
@@ -38364,6 +38378,7 @@ var pageEvalCommand = new Command("eval").description("Evaluate JS in a real bro
|
|
|
38364
38378
|
if (settleAfterGateMs > 0) {
|
|
38365
38379
|
sentExpr = withPrelude(sentExpr, `await new Promise((r) => setTimeout(r, ${settleAfterGateMs}));`);
|
|
38366
38380
|
}
|
|
38381
|
+
const submitStart = Date.now();
|
|
38367
38382
|
const kickoff = await post("/tools/browser/eval", {
|
|
38368
38383
|
url,
|
|
38369
38384
|
expr: sentExpr,
|
|
@@ -38379,6 +38394,7 @@ var pageEvalCommand = new Command("eval").description("Evaluate JS in a real bro
|
|
|
38379
38394
|
fakeMedia: opts.fakeMedia || !!camera || void 0,
|
|
38380
38395
|
cameraUrl: camera?.url
|
|
38381
38396
|
});
|
|
38397
|
+
const pollStart = Date.now();
|
|
38382
38398
|
let d;
|
|
38383
38399
|
try {
|
|
38384
38400
|
d = await pollEvalResult(kickoff.data.evalJobId, evalWorkBudgetMs({
|
|
@@ -38396,6 +38412,13 @@ var pageEvalCommand = new Command("eval").description("Evaluate JS in a real bro
|
|
|
38396
38412
|
throw new Error(`${msg}
|
|
38397
38413
|
${hint}`);
|
|
38398
38414
|
}
|
|
38415
|
+
const timing = evalTimingLine({
|
|
38416
|
+
hostMs: submitStart - hostStart,
|
|
38417
|
+
submitMs: pollStart - submitStart,
|
|
38418
|
+
pollMs: Date.now() - pollStart,
|
|
38419
|
+
browserMs: d.browserMs
|
|
38420
|
+
});
|
|
38421
|
+
if (timing) console.error(muted(timing));
|
|
38399
38422
|
const { result, noValue } = normalizeEvalResult(d.result);
|
|
38400
38423
|
const reload = d.reloadResult !== void 0 ? normalizeEvalResult(d.reloadResult) : void 0;
|
|
38401
38424
|
const execTimeout = evalExecTimeoutMessage(d.result, scriptBudgetMs);
|
|
@@ -39202,7 +39225,7 @@ async function printPlan(appGuid2, env, json) {
|
|
|
39202
39225
|
console.log(warning("A prod deploy stops on the destructive statements above until you pass --yes-destructive."));
|
|
39203
39226
|
}
|
|
39204
39227
|
}
|
|
39205
|
-
var deployCommand = new Command("deploy").description("Deploy the app to prod, or to an environment (created on first deploy)").argument("[env]", "prod, or an environment name (dev, staging, ...). Omitted: prod while the app has no environments; once it has any, name one").option("--yes-destructive", "Allow pending prod migrations that destroy data (DROP TABLE/COLUMN, TRUNCATE, DELETE without WHERE, column type changes)").option("--plan", "Show the pending migrations this deploy would run (and where each already ran), without deploying").option("--source-dir <dir>", "Source directory to deploy from").option("--only <phases>", "Run only specific phases, comma-separated, matched by gipity.yaml phase name or type: files/static, database/sql, functions, workflows, services, jobs, records, realtime, env, auth_branding").option("--force", "Re-run all phases (ignore checksums) and bypass the sync bulk-deletion guard").option("--no-sync", "Skip sync-up before deploy").option("--optimize",
|
|
39228
|
+
var deployCommand = new Command("deploy").description("Deploy the app to prod, or to an environment (created on first deploy)").argument("[env]", "prod, or an environment name (dev, staging, ...). Omitted: prod while the app has no environments; once it has any, name one").option("--yes-destructive", "Allow pending prod migrations that destroy data (DROP TABLE/COLUMN, TRUNCATE, DELETE without WHERE, column type changes)").option("--plan", "Show the pending migrations this deploy would run (and where each already ran), without deploying").option("--source-dir <dir>", "Source directory to deploy from").option("--only <phases>", "Run only specific phases, comma-separated, matched by gipity.yaml phase name or type: files/static, database/sql, functions, workflows, services, jobs, records, realtime, env, auth_branding").option("--force", "Re-run all phases (ignore checksums) and bypass the sync bulk-deletion guard").option("--no-sync", "Skip sync-up before deploy").option("--optimize", 'Bundle and minify the JS/CSS with Vite (off by default: files upload as-is, so prod serves what you verified). Only bundles <script type="module"> references, and page eval import() of an app module then loads a separate copy').option("--json", "Output as JSON").option("--inspect [path]", "After a successful deploy, run `page inspect` on the deployed URL (or URL + path) in the same command - one build-loop step instead of two. With --json, emits two JSON lines: deploy, then inspect.").option("--wait <ms>", "With --inspect: sleep this many ms before capturing (max 30000)").option("--wait-for <selector>", "With --inspect: wait until this CSS selector appears before capturing (deterministic; the app's own ready signal)").option("--wait-timeout <ms>", "With --inspect: max ms to wait for --wait-for before giving up", "5000").action((envArg, opts) => run("Deploy", async () => {
|
|
39206
39229
|
const env = envArg ?? getEnvOption();
|
|
39207
39230
|
if (opts.plan) {
|
|
39208
39231
|
await printPlan(requireConfig2().projectGuid, env ?? "prod", !!opts.json);
|
|
@@ -39919,6 +39942,10 @@ GCC/Rust).
|
|
|
39919
39942
|
process.exit(1);
|
|
39920
39943
|
}
|
|
39921
39944
|
}
|
|
39945
|
+
if (!source?.trim()) {
|
|
39946
|
+
console.error(error(filePath ? `${filePath} is empty: nothing to run.` : 'The inline code is empty: nothing to run. If it came from "$(cat <file>)", that file is missing or empty; pass --file <path> instead.'));
|
|
39947
|
+
process.exit(1);
|
|
39948
|
+
}
|
|
39922
39949
|
const language = resolveLanguage({ langFromInterp, langOpt: opts.language, filePath, inlineCode });
|
|
39923
39950
|
const discardOutput = opts.discardOutput ?? [];
|
|
39924
39951
|
if (discardOutput.some((g) => !g.trim())) {
|
|
@@ -40536,7 +40563,7 @@ function printStepRuns(steps, emptyNote) {
|
|
|
40536
40563
|
}
|
|
40537
40564
|
}
|
|
40538
40565
|
var TERMINAL_RUN_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
|
|
40539
|
-
var sleep2 = (ms2) => new Promise((
|
|
40566
|
+
var sleep2 = (ms2) => new Promise((resolve21) => setTimeout(resolve21, ms2));
|
|
40540
40567
|
async function waitForRun(wfGuid, prevGuid, timeoutSec) {
|
|
40541
40568
|
const deadline = Date.now() + timeoutSec * 1e3;
|
|
40542
40569
|
let runGuid;
|
|
@@ -43358,6 +43385,7 @@ async function inspectClient(url, waitMs, i) {
|
|
|
43358
43385
|
}
|
|
43359
43386
|
var MAX_HOLD_MS = 15e3;
|
|
43360
43387
|
var MIN_HOLD_MS = 1e3;
|
|
43388
|
+
var JOIN_ALLOWANCE_MS = 12e3;
|
|
43361
43389
|
var LIFECYCLE_ACTIONS = ["freeze", "wake", "hide", "show", "offline", "online"];
|
|
43362
43390
|
var PAUSED_SAMPLE = "(paused)";
|
|
43363
43391
|
var PAUSE_SLACK_MS = 1500;
|
|
@@ -43442,13 +43470,14 @@ function warnUnknownTokens(unknown) {
|
|
|
43442
43470
|
`\u26A0 Unrecognized placeholder ${unknown.join(", ")} left as-is: only {{i}} (0-based client index) and {{label}} are substituted per client. Set per-client values with --labels and reference them as {{label}}.`
|
|
43443
43471
|
));
|
|
43444
43472
|
}
|
|
43445
|
-
function buildHarness(action, observe, label2, holdMs, samples) {
|
|
43473
|
+
function buildHarness(action, observe, label2, holdMs, samples, startAt) {
|
|
43446
43474
|
const n = Math.max(2, samples);
|
|
43447
43475
|
const interval = Math.max(0, Math.floor(holdMs / (n - 1)));
|
|
43448
|
-
const lines = [
|
|
43449
|
-
|
|
43450
|
-
`const
|
|
43451
|
-
|
|
43476
|
+
const lines = [`const __label=${JSON.stringify(label2)};`];
|
|
43477
|
+
if (startAt !== void 0) {
|
|
43478
|
+
lines.push(`{ const __bw=Math.min(${startAt}-Date.now(),${JOIN_ALLOWANCE_MS}); if(__bw>0) await new Promise(function(r){setTimeout(r,__bw);}); }`);
|
|
43479
|
+
}
|
|
43480
|
+
lines.push(`const __t0=Date.now();`);
|
|
43452
43481
|
if (action && action.trim()) {
|
|
43453
43482
|
lines.push(
|
|
43454
43483
|
`try{ ${action} }catch(__e){ return {label:__label,startedAt:__t0,endedAt:Date.now(),samples:[],actionError:String((__e&&__e.message)||__e)}; }`
|
|
@@ -43467,7 +43496,7 @@ function buildHarness(action, observe, label2, holdMs, samples) {
|
|
|
43467
43496
|
);
|
|
43468
43497
|
return lines.join("\n");
|
|
43469
43498
|
}
|
|
43470
|
-
async function observeClient(url, expr, i, label2, settleMs, holdMs, waitForSelector, lifecycle) {
|
|
43499
|
+
async function observeClient(url, expr, i, label2, settleMs, holdMs, waitForSelector, lifecycle, barrier = false) {
|
|
43471
43500
|
const base = { i, label: label2, samples: [], startedAt: 0, endedAt: 0 };
|
|
43472
43501
|
try {
|
|
43473
43502
|
const kickoff = await post("/tools/browser/eval", {
|
|
@@ -43476,11 +43505,13 @@ async function observeClient(url, expr, i, label2, settleMs, holdMs, waitForSele
|
|
|
43476
43505
|
waitMs: settleMs,
|
|
43477
43506
|
waitForSelector: waitForSelector || void 0,
|
|
43478
43507
|
waitForTimeoutMs: waitForSelector ? 5e3 : void 0,
|
|
43508
|
+
// The shared-start wait runs inside the script, so the script needs room for it.
|
|
43509
|
+
timeoutMs: barrier ? JOIN_ALLOWANCE_MS + holdMs + 1e4 : void 0,
|
|
43479
43510
|
// Timed from the start of the observe window; the server restores
|
|
43480
43511
|
// anything still applied at the end of the hold so the harness finishes.
|
|
43481
43512
|
lifecycle: lifecycle?.length ? { steps: lifecycle, untilMs: holdMs } : void 0
|
|
43482
43513
|
});
|
|
43483
|
-
const d = await pollEvalResult(kickoff.data.evalJobId, settleMs + holdMs);
|
|
43514
|
+
const d = await pollEvalResult(kickoff.data.evalJobId, settleMs + holdMs + (barrier ? JOIN_ALLOWANCE_MS : 0));
|
|
43484
43515
|
const raw = d.result?.trim() ?? "";
|
|
43485
43516
|
if (raw.startsWith("EvalError:") || raw.startsWith("ObserveError:")) {
|
|
43486
43517
|
return { ...base, error: raw };
|
|
@@ -43560,6 +43591,8 @@ async function runInteractive(url, observe, opts) {
|
|
|
43560
43591
|
console.log(muted(`${clients} client(s), stagger ${stagger}s, hold ${hold}ms, ${samples} samples each`));
|
|
43561
43592
|
if (atSpecs.length) console.log(muted(`lifecycle (ms into each client's hold): ${atSpecs.map((s) => s.trim()).join(", ")}`));
|
|
43562
43593
|
}
|
|
43594
|
+
const barrier = clients > 1 && atSpecs.length === 0;
|
|
43595
|
+
const t0 = Date.now();
|
|
43563
43596
|
const runs = [];
|
|
43564
43597
|
for (let i = 0; i < clients; i++) {
|
|
43565
43598
|
runs.push((async () => {
|
|
@@ -43571,9 +43604,10 @@ async function runInteractive(url, observe, opts) {
|
|
|
43571
43604
|
subst(observe, labelFor2(i), i),
|
|
43572
43605
|
labelFor2(i),
|
|
43573
43606
|
hold,
|
|
43574
|
-
samples
|
|
43607
|
+
samples,
|
|
43608
|
+
barrier ? t0 + i * stagger * 1e3 + JOIN_ALLOWANCE_MS : void 0
|
|
43575
43609
|
);
|
|
43576
|
-
return observeClient(clientUrl, expr, i, labelFor2(i), settle, hold, opts.waitFor, lifecycle[i]);
|
|
43610
|
+
return observeClient(clientUrl, expr, i, labelFor2(i), settle, hold, opts.waitFor, lifecycle[i], barrier);
|
|
43577
43611
|
})());
|
|
43578
43612
|
}
|
|
43579
43613
|
const results = (await Promise.all(runs)).sort((a, b7) => a.i - b7.i);
|
|
@@ -43622,7 +43656,7 @@ ${warning(observeHint)}`);
|
|
|
43622
43656
|
"\u26A0 clients did NOT overlap in time: each ran in isolation, so any shared-state reading here is a FALSE NEGATIVE, not proof the app is broken."
|
|
43623
43657
|
));
|
|
43624
43658
|
console.log(muted(
|
|
43625
|
-
|
|
43659
|
+
` Each client waits up to ${JOIN_ALLOWANCE_MS / 1e3}s after launch for the others to load, then holds. Likely causes: --stagger \u2265 --hold, or a client queued for a browser (more --clients than free slots). Lower --stagger / raise --hold / fewer --clients and retry.`
|
|
43626
43660
|
));
|
|
43627
43661
|
}
|
|
43628
43662
|
if (errored.length > 0 || clients > 1 && !overlapped) process.exitCode = 1;
|
|
@@ -44675,9 +44709,9 @@ jobCommand.command("cancel <runGuid>").description("Cancel a queued or running j
|
|
|
44675
44709
|
}));
|
|
44676
44710
|
jobCommand.command("run-local <name>").description("Run the job in a local Docker container against your local filesystem (no platform round-trip)").option("--image <image>", "Docker image to run inside", "easyclaw/sandbox:latest").option("--no-deps", "Skip pip/npm install even if a deps file is present").option("--json", "Capture the job's output and print one JSON result (exitCode, stdout, stderr) instead of streaming it").action(async (name, opts) => {
|
|
44677
44711
|
const { existsSync: existsSync27, statSync: statSync12 } = await import("node:fs");
|
|
44678
|
-
const { resolve:
|
|
44712
|
+
const { resolve: resolve21, join: join32 } = await import("node:path");
|
|
44679
44713
|
const { spawnCommand: spawnCommand2, spawnSyncCommand: spawnSyncCommand2 } = await Promise.resolve().then(() => (init_platform(), platform_exports));
|
|
44680
|
-
const jobDir =
|
|
44714
|
+
const jobDir = resolve21(process.cwd(), "jobs", name);
|
|
44681
44715
|
if (!existsSync27(jobDir) || !statSync12(jobDir).isDirectory()) {
|
|
44682
44716
|
console.error(error(`jobs/${name}/ not found in current directory`));
|
|
44683
44717
|
process.exit(1);
|
|
@@ -44890,6 +44924,7 @@ emailCommand.command("log").description("Recent email() sends and skipped attemp
|
|
|
44890
44924
|
const subj = r.detail?.subject ? ` \xB7 ${r.detail.subject}` : "";
|
|
44891
44925
|
const status = r.detail?.status ? ` [skipped: ${r.detail.status}]` : "";
|
|
44892
44926
|
console.log(` ${muted(when)} ${to2}${status ? warning(status) : ""}${muted(subj)}`);
|
|
44927
|
+
if (r.detail?.reason) console.log(` ${muted(r.detail.reason)}`);
|
|
44893
44928
|
}
|
|
44894
44929
|
}));
|
|
44895
44930
|
|
|
@@ -45013,10 +45048,10 @@ async function waitForGenerations(projectGuid2, initial, opts = {}) {
|
|
|
45013
45048
|
return gens;
|
|
45014
45049
|
}
|
|
45015
45050
|
function sleepUnlessInterrupted(ms2, stop) {
|
|
45016
|
-
return new Promise((
|
|
45051
|
+
return new Promise((resolve21) => {
|
|
45017
45052
|
const started = Date.now();
|
|
45018
45053
|
const tick = () => {
|
|
45019
|
-
if (stop() || Date.now() - started >= ms2) return
|
|
45054
|
+
if (stop() || Date.now() - started >= ms2) return resolve21();
|
|
45020
45055
|
setTimeout(tick, Math.min(100, ms2));
|
|
45021
45056
|
};
|
|
45022
45057
|
tick();
|
|
@@ -46271,7 +46306,7 @@ async function pollTestStatus(projectGuid2, runGuid, opts) {
|
|
|
46271
46306
|
}
|
|
46272
46307
|
}
|
|
46273
46308
|
}
|
|
46274
|
-
await new Promise((
|
|
46309
|
+
await new Promise((resolve21) => setTimeout(resolve21, getPollInterval()));
|
|
46275
46310
|
}
|
|
46276
46311
|
}
|
|
46277
46312
|
var testCommand = new Command("test").description("Run tests").argument("[path]", 'Test path filter (e.g. "api", "e2e/portal")').option("--filter <path>", "Alias for the positional test path filter").option("--timeout <ms>", "Per-test timeout in ms", "30000").option("--retry <n>", "Retry failed tests N times", "0").option("--no-sync", "Skip sync-up before tests").option("--json", "Output as JSON").action((pathFilter, opts) => run("Test", async () => {
|
|
@@ -46500,13 +46535,14 @@ var locationCommand = new Command("location").description("Show location").argum
|
|
|
46500
46535
|
|
|
46501
46536
|
// src/commands/doctor.ts
|
|
46502
46537
|
import { existsSync as existsSync21, readFileSync as readFileSync26, statSync as statSync9 } from "fs";
|
|
46503
|
-
import { join as join25, resolve as
|
|
46538
|
+
import { join as join25, resolve as resolve17 } from "path";
|
|
46504
46539
|
import { homedir as homedir17 } from "os";
|
|
46505
46540
|
|
|
46506
46541
|
// src/updater/state.ts
|
|
46507
46542
|
import { readFileSync as readFileSync25, writeFileSync as writeFileSync17, mkdirSync as mkdirSync16, existsSync as existsSync20 } from "fs";
|
|
46508
|
-
import { join as join24 } from "path";
|
|
46543
|
+
import { dirname as dirname15, join as join24, resolve as resolve16 } from "path";
|
|
46509
46544
|
import { homedir as homedir16 } from "os";
|
|
46545
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
46510
46546
|
var GIPITY_DIR = join24(homedir16(), ".gipity");
|
|
46511
46547
|
var LOCAL_DIR = join24(GIPITY_DIR, "local");
|
|
46512
46548
|
var LOCAL_PKG_DIR = join24(LOCAL_DIR, "node_modules", "gipity");
|
|
@@ -46514,6 +46550,22 @@ var LOCAL_ENTRY = join24(LOCAL_PKG_DIR, "dist", "index.js");
|
|
|
46514
46550
|
var STATE_FILE = join24(GIPITY_DIR, "update-state.json");
|
|
46515
46551
|
var SETTINGS_FILE = join24(GIPITY_DIR, "settings.json");
|
|
46516
46552
|
var UPDATE_LOG = join24(GIPITY_DIR, "update.log");
|
|
46553
|
+
function findPkgRoot() {
|
|
46554
|
+
let dir = dirname15(fileURLToPath4(import.meta.url));
|
|
46555
|
+
for (; ; ) {
|
|
46556
|
+
try {
|
|
46557
|
+
if (JSON.parse(readFileSync25(join24(dir, "package.json"), "utf-8")).name === "gipity") return dir;
|
|
46558
|
+
} catch {
|
|
46559
|
+
}
|
|
46560
|
+
const up2 = dirname15(dir);
|
|
46561
|
+
if (up2 === dir) return resolve16(dirname15(fileURLToPath4(import.meta.url)), "..", "..");
|
|
46562
|
+
dir = up2;
|
|
46563
|
+
}
|
|
46564
|
+
}
|
|
46565
|
+
var PKG_ROOT = findPkgRoot();
|
|
46566
|
+
function isDevLink() {
|
|
46567
|
+
return existsSync20(join24(PKG_ROOT, "src"));
|
|
46568
|
+
}
|
|
46517
46569
|
var DEFAULT_STATE = {
|
|
46518
46570
|
installedVersion: null,
|
|
46519
46571
|
lastCheckAt: 0,
|
|
@@ -46676,7 +46728,7 @@ var doctorCommand = new Command("doctor").description("Check install + environme
|
|
|
46676
46728
|
if (env.claude.installed && !env.claude.authenticated) {
|
|
46677
46729
|
console.log(`${muted(" ")} ${warning("Claude Code is not logged in. Run `claude auth login` and sign in.")}`);
|
|
46678
46730
|
}
|
|
46679
|
-
if (existsSync21(
|
|
46731
|
+
if (existsSync21(resolve17(process.cwd(), ".codex", "hooks.json"))) {
|
|
46680
46732
|
console.log(`${muted("codex hooks ")} ${warning("written")} - session capture needs a one-time approval: run /hooks inside Codex in this project`);
|
|
46681
46733
|
}
|
|
46682
46734
|
const buildReady = env.node.ok && env.gipity.logged_in;
|
|
@@ -46707,11 +46759,12 @@ import { appendFileSync } from "fs";
|
|
|
46707
46759
|
|
|
46708
46760
|
// src/updater/install.ts
|
|
46709
46761
|
import { existsSync as existsSync22, mkdirSync as mkdirSync17, rmSync as rmSync2, statSync as statSync10, unlinkSync as unlinkSync6, writeFileSync as writeFileSync18 } from "fs";
|
|
46710
|
-
import { dirname as
|
|
46762
|
+
import { dirname as dirname16, join as join26 } from "path";
|
|
46711
46763
|
init_platform();
|
|
46712
46764
|
var UPDATE_LOCK = join26(GIPITY_DIR, "update.lock");
|
|
46713
46765
|
var LOCK_STALE_MS2 = 10 * 60 * 1e3;
|
|
46714
46766
|
function npmInstallGipity(version) {
|
|
46767
|
+
ensureLocalTree();
|
|
46715
46768
|
const res = spawnSyncCommand(resolveCommand("npm"), ["install", "--no-audit", "--no-fund", "--ignore-scripts", `gipity@${version}`], {
|
|
46716
46769
|
cwd: LOCAL_DIR,
|
|
46717
46770
|
stdio: ["ignore", "ignore", "pipe"],
|
|
@@ -46728,6 +46781,13 @@ var WEDGE_CODES = /\b(ENOTEMPTY|EEXIST|ENOTDIR|EISDIR|EJSONPARSE)\b/;
|
|
|
46728
46781
|
function isWedged(stderr) {
|
|
46729
46782
|
return WEDGE_CODES.test(stderr);
|
|
46730
46783
|
}
|
|
46784
|
+
function ensureLocalTree(dir = LOCAL_DIR) {
|
|
46785
|
+
mkdirSync17(dir, { recursive: true });
|
|
46786
|
+
const pkgJson = join26(dir, "package.json");
|
|
46787
|
+
if (!existsSync22(pkgJson)) {
|
|
46788
|
+
writeFileSync18(pkgJson, JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
|
|
46789
|
+
}
|
|
46790
|
+
}
|
|
46731
46791
|
function resetLocalTree(dir = LOCAL_DIR) {
|
|
46732
46792
|
mkdirSync17(dir, { recursive: true });
|
|
46733
46793
|
rmSync2(join26(dir, "node_modules"), { recursive: true, force: true });
|
|
@@ -46735,7 +46795,7 @@ function resetLocalTree(dir = LOCAL_DIR) {
|
|
|
46735
46795
|
writeFileSync18(join26(dir, "package.json"), JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
|
|
46736
46796
|
}
|
|
46737
46797
|
function acquireUpdateLock(lockPath2 = UPDATE_LOCK) {
|
|
46738
|
-
mkdirSync17(
|
|
46798
|
+
mkdirSync17(dirname16(lockPath2), { recursive: true });
|
|
46739
46799
|
try {
|
|
46740
46800
|
writeFileSync18(lockPath2, String(process.pid), { flag: "wx" });
|
|
46741
46801
|
return true;
|
|
@@ -46807,6 +46867,7 @@ ${res.stderr.trim().slice(-2e3)}`);
|
|
|
46807
46867
|
return { ok: false, detail: firstLine.length > 160 ? firstLine.slice(0, 157) + "..." : firstLine };
|
|
46808
46868
|
}
|
|
46809
46869
|
async function runCheck(opts = {}) {
|
|
46870
|
+
if (isDevLink()) return { updated: false, reason: "dev-link" };
|
|
46810
46871
|
const state = readState();
|
|
46811
46872
|
if (!opts.force) {
|
|
46812
46873
|
const dis = updatesDisabled();
|
|
@@ -46879,15 +46940,19 @@ var updateCommand = new Command("update").description("Update the CLI").option("
|
|
|
46879
46940
|
upToDate: result.reason === "up-to-date",
|
|
46880
46941
|
from: result.from ?? null,
|
|
46881
46942
|
to: result.to ?? null,
|
|
46882
|
-
|
|
46943
|
+
devLink: result.reason === "dev-link",
|
|
46944
|
+
reason: result.updated || result.reason === "up-to-date" || result.reason === "dev-link" ? null : result.reason ?? null
|
|
46883
46945
|
}));
|
|
46884
|
-
if (!result.updated && result.reason !== "up-to-date") process.exitCode = 1;
|
|
46946
|
+
if (!result.updated && result.reason !== "up-to-date" && result.reason !== "dev-link") process.exitCode = 1;
|
|
46885
46947
|
return;
|
|
46886
46948
|
}
|
|
46887
46949
|
console.log("");
|
|
46888
46950
|
if (result.updated) {
|
|
46889
46951
|
console.log(success(`Updated ${result.from} \u2192 ${result.to}`));
|
|
46890
46952
|
console.log(dim(`Installed. This command ran on ${result.from}; everything from here on uses ${result.to}.`));
|
|
46953
|
+
} else if (result.reason === "dev-link") {
|
|
46954
|
+
console.log(info(`This gipity is linked to a source checkout (${PKG_ROOT}) and runs its build, so it never auto-updates.`));
|
|
46955
|
+
console.log(dim("To update it, pull that checkout and run `just cli-link` there."));
|
|
46891
46956
|
} else if (result.reason === "up-to-date") {
|
|
46892
46957
|
console.log(success("Already on the latest version."));
|
|
46893
46958
|
} else {
|
|
@@ -47680,13 +47745,13 @@ function parseVersion(out) {
|
|
|
47680
47745
|
return m ? m[0] : void 0;
|
|
47681
47746
|
}
|
|
47682
47747
|
function runProbe(cmd, args) {
|
|
47683
|
-
return new Promise((
|
|
47748
|
+
return new Promise((resolve21) => {
|
|
47684
47749
|
let out = "";
|
|
47685
47750
|
let settled = false;
|
|
47686
47751
|
const done = (s) => {
|
|
47687
47752
|
if (!settled) {
|
|
47688
47753
|
settled = true;
|
|
47689
|
-
|
|
47754
|
+
resolve21(s);
|
|
47690
47755
|
}
|
|
47691
47756
|
};
|
|
47692
47757
|
let child;
|
|
@@ -47825,13 +47890,13 @@ function agentUpdateInProgress() {
|
|
|
47825
47890
|
return inProgress;
|
|
47826
47891
|
}
|
|
47827
47892
|
function execCapture(argv2, timeoutMs, signal) {
|
|
47828
|
-
return new Promise((
|
|
47893
|
+
return new Promise((resolve21) => {
|
|
47829
47894
|
let output = "";
|
|
47830
47895
|
let settled = false;
|
|
47831
47896
|
const done = (ok) => {
|
|
47832
47897
|
if (!settled) {
|
|
47833
47898
|
settled = true;
|
|
47834
|
-
|
|
47899
|
+
resolve21({ ok, output });
|
|
47835
47900
|
}
|
|
47836
47901
|
};
|
|
47837
47902
|
let child;
|
|
@@ -48032,8 +48097,8 @@ var SessionPool = class {
|
|
|
48032
48097
|
const done = new Promise((r) => {
|
|
48033
48098
|
markDone = r;
|
|
48034
48099
|
});
|
|
48035
|
-
return new Promise((
|
|
48036
|
-
const turn = { onMessage: p.onMessage, resolve:
|
|
48100
|
+
return new Promise((resolve21, reject) => {
|
|
48101
|
+
const turn = { onMessage: p.onMessage, resolve: resolve21, reject, interruptRequested: false, wasHot, done, markDone };
|
|
48037
48102
|
session.current = turn;
|
|
48038
48103
|
session.state = "running";
|
|
48039
48104
|
session.lastActivityAt = Date.now();
|
|
@@ -48488,10 +48553,10 @@ async function heartbeatLoop(ctx) {
|
|
|
48488
48553
|
}
|
|
48489
48554
|
await Promise.race([
|
|
48490
48555
|
sleep4(HEARTBEAT_INTERVAL_MS, ctx.abort.signal),
|
|
48491
|
-
new Promise((
|
|
48556
|
+
new Promise((resolve21) => {
|
|
48492
48557
|
heartbeatPoke = () => {
|
|
48493
48558
|
heartbeatPoke = null;
|
|
48494
|
-
|
|
48559
|
+
resolve21();
|
|
48495
48560
|
};
|
|
48496
48561
|
})
|
|
48497
48562
|
]);
|
|
@@ -48535,9 +48600,9 @@ async function dispatchLoop(ctx, opts) {
|
|
|
48535
48600
|
while (inflight.size >= MAX_CONCURRENT_DISPATCHES && !ctx.abort.signal.aborted) {
|
|
48536
48601
|
await Promise.race([
|
|
48537
48602
|
...inflight,
|
|
48538
|
-
new Promise((
|
|
48539
|
-
if (ctx.abort.signal.aborted) return
|
|
48540
|
-
ctx.abort.signal.addEventListener("abort", () =>
|
|
48603
|
+
new Promise((resolve21) => {
|
|
48604
|
+
if (ctx.abort.signal.aborted) return resolve21();
|
|
48605
|
+
ctx.abort.signal.addEventListener("abort", () => resolve21(), { once: true });
|
|
48541
48606
|
})
|
|
48542
48607
|
]);
|
|
48543
48608
|
}
|
|
@@ -49326,7 +49391,7 @@ async function killRunningForConv(convGuid) {
|
|
|
49326
49391
|
}
|
|
49327
49392
|
}
|
|
49328
49393
|
const graceTimers = [];
|
|
49329
|
-
const escalate = new Promise((
|
|
49394
|
+
const escalate = new Promise((resolve21) => {
|
|
49330
49395
|
const t = setTimeout(() => {
|
|
49331
49396
|
for (const e of matches) {
|
|
49332
49397
|
log2("warn", "previous dispatch ignored SIGTERM - escalating to SIGKILL", { conv: convGuid });
|
|
@@ -49335,7 +49400,7 @@ async function killRunningForConv(convGuid) {
|
|
|
49335
49400
|
} catch {
|
|
49336
49401
|
}
|
|
49337
49402
|
}
|
|
49338
|
-
|
|
49403
|
+
resolve21();
|
|
49339
49404
|
}, KILL_GRACE_MS);
|
|
49340
49405
|
graceTimers.push(t);
|
|
49341
49406
|
});
|
|
@@ -49346,7 +49411,7 @@ async function killRunningForConv(convGuid) {
|
|
|
49346
49411
|
}
|
|
49347
49412
|
async function spawnSync2(cwd, timeoutMs, onSpawn) {
|
|
49348
49413
|
const cmd = process.env.GIPITY_RELAY_CLAUDE_CMD || resolveCommand("gipity");
|
|
49349
|
-
return new Promise((
|
|
49414
|
+
return new Promise((resolve21, reject) => {
|
|
49350
49415
|
const child = spawnCommand(cmd, ["sync", "--json"], {
|
|
49351
49416
|
cwd,
|
|
49352
49417
|
env: childEnv(),
|
|
@@ -49386,7 +49451,7 @@ async function spawnSync2(cwd, timeoutMs, onSpawn) {
|
|
|
49386
49451
|
child.on("exit", (code) => finish(() => {
|
|
49387
49452
|
if (code === 0) {
|
|
49388
49453
|
log2("info", "sync done", { cwd, stdoutLen });
|
|
49389
|
-
|
|
49454
|
+
resolve21();
|
|
49390
49455
|
} else {
|
|
49391
49456
|
reject(new Error(`gipity sync exited ${code}${stderrBuf ? `: ${stderrBuf.trim().slice(0, 300)}` : ""}`));
|
|
49392
49457
|
}
|
|
@@ -49398,7 +49463,7 @@ async function spawnGipityClaude(args, cwd, d, queue, meta) {
|
|
|
49398
49463
|
const cmd = process.env.GIPITY_RELAY_CLAUDE_CMD || resolveCommand("gipity");
|
|
49399
49464
|
const fullArgs = streamJson ? [...args, "--output-format", "stream-json", "--verbose", "--include-partial-messages"] : [...args];
|
|
49400
49465
|
const env = streamJson ? childEnv({ GIPITY_CONVERSATION_GUID: d.conversation_guid, GIPITY_CAPTURE: "off" }) : childEnv({ GIPITY_CONVERSATION_GUID: d.conversation_guid });
|
|
49401
|
-
return new Promise((
|
|
49466
|
+
return new Promise((resolve21, reject) => {
|
|
49402
49467
|
const child = spawnCommand(cmd, fullArgs, { cwd, env, stdio: ["ignore", "pipe", "pipe"] });
|
|
49403
49468
|
let resolveExited = () => {
|
|
49404
49469
|
};
|
|
@@ -49585,7 +49650,7 @@ async function spawnGipityClaude(args, cwd, d, queue, meta) {
|
|
|
49585
49650
|
void postProgress(d.conversation_guid, buildProgressPayload(false));
|
|
49586
49651
|
if (ownQueue) await q.close();
|
|
49587
49652
|
cleanup();
|
|
49588
|
-
|
|
49653
|
+
resolve21({
|
|
49589
49654
|
exitCode: code ?? 1,
|
|
49590
49655
|
killed,
|
|
49591
49656
|
runtimeLimit,
|
|
@@ -49600,10 +49665,10 @@ async function runDispatchSync(d, cwd) {
|
|
|
49600
49665
|
let killed = false;
|
|
49601
49666
|
try {
|
|
49602
49667
|
await spawnSync2(cwd, PROJECT_SYNC_TIMEOUT_MS, (child) => {
|
|
49603
|
-
const exited = new Promise((
|
|
49668
|
+
const exited = new Promise((resolve21) => {
|
|
49604
49669
|
child.once("exit", (_code, signal) => {
|
|
49605
49670
|
if (signal === "SIGTERM") killed = true;
|
|
49606
|
-
|
|
49671
|
+
resolve21();
|
|
49607
49672
|
});
|
|
49608
49673
|
});
|
|
49609
49674
|
running.set(d.short_guid, { child, convGuid: d.conversation_guid, exited });
|
|
@@ -49634,18 +49699,18 @@ function killDispatch(shortGuid) {
|
|
|
49634
49699
|
return false;
|
|
49635
49700
|
}
|
|
49636
49701
|
function sleep4(ms2, signal) {
|
|
49637
|
-
return new Promise((
|
|
49638
|
-
if (signal?.aborted) return
|
|
49702
|
+
return new Promise((resolve21) => {
|
|
49703
|
+
if (signal?.aborted) return resolve21();
|
|
49639
49704
|
let onAbort = null;
|
|
49640
49705
|
const t = setTimeout(() => {
|
|
49641
49706
|
if (onAbort && signal) signal.removeEventListener("abort", onAbort);
|
|
49642
|
-
|
|
49707
|
+
resolve21();
|
|
49643
49708
|
}, ms2);
|
|
49644
49709
|
if (signal) {
|
|
49645
49710
|
onAbort = () => {
|
|
49646
49711
|
clearTimeout(t);
|
|
49647
49712
|
signal.removeEventListener("abort", onAbort);
|
|
49648
|
-
|
|
49713
|
+
resolve21();
|
|
49649
49714
|
};
|
|
49650
49715
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
49651
49716
|
}
|
|
@@ -50165,7 +50230,7 @@ init_utils();
|
|
|
50165
50230
|
init_colors();
|
|
50166
50231
|
import { existsSync as existsSync26, rmSync as rmSync4, unlinkSync as unlinkSync10, readFileSync as readFileSync30, writeFileSync as writeFileSync20 } from "fs";
|
|
50167
50232
|
import { homedir as homedir20, platform as osPlatform4 } from "os";
|
|
50168
|
-
import { join as join30, resolve as
|
|
50233
|
+
import { join as join30, resolve as resolve19 } from "path";
|
|
50169
50234
|
init_agents();
|
|
50170
50235
|
function removeInstallerPathLines() {
|
|
50171
50236
|
if (osPlatform4() === "win32") return [];
|
|
@@ -50198,7 +50263,7 @@ function tildify2(p) {
|
|
|
50198
50263
|
return p === home || p.startsWith(home + "/") ? "~" + p.slice(home.length) : p;
|
|
50199
50264
|
}
|
|
50200
50265
|
function resolveCliPath2() {
|
|
50201
|
-
return
|
|
50266
|
+
return resolve19(process.argv[1] ?? "gipity");
|
|
50202
50267
|
}
|
|
50203
50268
|
async function stopDaemon() {
|
|
50204
50269
|
if (!isDaemonRunning()) return;
|
|
@@ -50934,13 +50999,13 @@ function installOutputTrace(label2) {
|
|
|
50934
50999
|
|
|
50935
51000
|
// src/index.ts
|
|
50936
51001
|
installOutputTrace("index");
|
|
50937
|
-
var __dirname =
|
|
51002
|
+
var __dirname = dirname17(fileURLToPath5(import.meta.url));
|
|
50938
51003
|
installNetworking();
|
|
50939
|
-
var pkg = JSON.parse(readFileSync32(
|
|
51004
|
+
var pkg = JSON.parse(readFileSync32(resolve20(__dirname, "../package.json"), "utf-8"));
|
|
50940
51005
|
function versionLabel() {
|
|
50941
51006
|
const base = `v${pkg.version}`;
|
|
50942
51007
|
try {
|
|
50943
|
-
const info2 = JSON.parse(readFileSync32(
|
|
51008
|
+
const info2 = JSON.parse(readFileSync32(resolve20(__dirname, "build-info.json"), "utf-8"));
|
|
50944
51009
|
if (info2?.sha) return `${base} (dev ${info2.sha}${info2.dirty ? ", modified" : ""})`;
|
|
50945
51010
|
} catch {
|
|
50946
51011
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { existsSync
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { npmInstallGipity, isWedged, resetLocalTree, acquireUpdateLock, releaseUpdateLock } from './install.js';
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
import { LOCAL_ENTRY, LOCAL_PKG_DIR, writeState, readState } from './state.js';
|
|
3
|
+
import { ensureLocalTree, npmInstallGipity, isWedged, resetLocalTree, acquireUpdateLock, releaseUpdateLock } from './install.js';
|
|
5
4
|
export function isBootstrapped() {
|
|
6
5
|
return existsSync(LOCAL_ENTRY);
|
|
7
6
|
}
|
|
@@ -15,11 +14,7 @@ export function isBootstrapped() {
|
|
|
15
14
|
* `gipity`, `gipity claude`, and `gipity --version`.
|
|
16
15
|
*/
|
|
17
16
|
export function bootstrap(version, quiet = false) {
|
|
18
|
-
|
|
19
|
-
const pkgJsonPath = join(LOCAL_DIR, 'package.json');
|
|
20
|
-
if (!existsSync(pkgJsonPath)) {
|
|
21
|
-
writeFileSync(pkgJsonPath, JSON.stringify({ name: 'gipity-local', private: true, version: '0.0.0' }, null, 2));
|
|
22
|
-
}
|
|
17
|
+
ensureLocalTree();
|
|
23
18
|
if (!acquireUpdateLock()) {
|
|
24
19
|
// A background updater is mid-install; run from the current build now and
|
|
25
20
|
// pick up the local install on a later invocation.
|
package/dist/updater/check.js
CHANGED
|
@@ -7,8 +7,9 @@ import { appendFileSync } from "fs";
|
|
|
7
7
|
|
|
8
8
|
// src/updater/state.ts
|
|
9
9
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
|
10
|
-
import { join } from "path";
|
|
10
|
+
import { dirname, join, resolve } from "path";
|
|
11
11
|
import { homedir } from "os";
|
|
12
|
+
import { fileURLToPath } from "url";
|
|
12
13
|
var GIPITY_DIR = join(homedir(), ".gipity");
|
|
13
14
|
var LOCAL_DIR = join(GIPITY_DIR, "local");
|
|
14
15
|
var LOCAL_PKG_DIR = join(LOCAL_DIR, "node_modules", "gipity");
|
|
@@ -16,6 +17,22 @@ var LOCAL_ENTRY = join(LOCAL_PKG_DIR, "dist", "index.js");
|
|
|
16
17
|
var STATE_FILE = join(GIPITY_DIR, "update-state.json");
|
|
17
18
|
var SETTINGS_FILE = join(GIPITY_DIR, "settings.json");
|
|
18
19
|
var UPDATE_LOG = join(GIPITY_DIR, "update.log");
|
|
20
|
+
function findPkgRoot() {
|
|
21
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
22
|
+
for (; ; ) {
|
|
23
|
+
try {
|
|
24
|
+
if (JSON.parse(readFileSync(join(dir, "package.json"), "utf-8")).name === "gipity") return dir;
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
const up = dirname(dir);
|
|
28
|
+
if (up === dir) return resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
29
|
+
dir = up;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
var PKG_ROOT = findPkgRoot();
|
|
33
|
+
function isDevLink() {
|
|
34
|
+
return existsSync(join(PKG_ROOT, "src"));
|
|
35
|
+
}
|
|
19
36
|
var DEFAULT_STATE = {
|
|
20
37
|
installedVersion: null,
|
|
21
38
|
lastCheckAt: 0,
|
|
@@ -57,7 +74,7 @@ function updatesDisabled() {
|
|
|
57
74
|
|
|
58
75
|
// src/updater/install.ts
|
|
59
76
|
import { existsSync as existsSync2, mkdirSync as mkdirSync2, rmSync, statSync, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
|
|
60
|
-
import { dirname, join as join2 } from "path";
|
|
77
|
+
import { dirname as dirname2, join as join2 } from "path";
|
|
61
78
|
|
|
62
79
|
// src/platform.ts
|
|
63
80
|
import { execSync, spawn, spawnSync } from "child_process";
|
|
@@ -91,6 +108,7 @@ function spawnSyncCommand(cmd, args = [], options = {}) {
|
|
|
91
108
|
var UPDATE_LOCK = join2(GIPITY_DIR, "update.lock");
|
|
92
109
|
var LOCK_STALE_MS = 10 * 60 * 1e3;
|
|
93
110
|
function npmInstallGipity(version) {
|
|
111
|
+
ensureLocalTree();
|
|
94
112
|
const res = spawnSyncCommand(resolveCommand("npm"), ["install", "--no-audit", "--no-fund", "--ignore-scripts", `gipity@${version}`], {
|
|
95
113
|
cwd: LOCAL_DIR,
|
|
96
114
|
stdio: ["ignore", "ignore", "pipe"],
|
|
@@ -107,6 +125,13 @@ var WEDGE_CODES = /\b(ENOTEMPTY|EEXIST|ENOTDIR|EISDIR|EJSONPARSE)\b/;
|
|
|
107
125
|
function isWedged(stderr) {
|
|
108
126
|
return WEDGE_CODES.test(stderr);
|
|
109
127
|
}
|
|
128
|
+
function ensureLocalTree(dir = LOCAL_DIR) {
|
|
129
|
+
mkdirSync2(dir, { recursive: true });
|
|
130
|
+
const pkgJson = join2(dir, "package.json");
|
|
131
|
+
if (!existsSync2(pkgJson)) {
|
|
132
|
+
writeFileSync2(pkgJson, JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
110
135
|
function resetLocalTree(dir = LOCAL_DIR) {
|
|
111
136
|
mkdirSync2(dir, { recursive: true });
|
|
112
137
|
rmSync(join2(dir, "node_modules"), { recursive: true, force: true });
|
|
@@ -114,7 +139,7 @@ function resetLocalTree(dir = LOCAL_DIR) {
|
|
|
114
139
|
writeFileSync2(join2(dir, "package.json"), JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
|
|
115
140
|
}
|
|
116
141
|
function acquireUpdateLock(lockPath = UPDATE_LOCK) {
|
|
117
|
-
mkdirSync2(
|
|
142
|
+
mkdirSync2(dirname2(lockPath), { recursive: true });
|
|
118
143
|
try {
|
|
119
144
|
writeFileSync2(lockPath, String(process.pid), { flag: "wx" });
|
|
120
145
|
return true;
|
|
@@ -186,6 +211,7 @@ ${res.stderr.trim().slice(-2e3)}`);
|
|
|
186
211
|
return { ok: false, detail: firstLine.length > 160 ? firstLine.slice(0, 157) + "..." : firstLine };
|
|
187
212
|
}
|
|
188
213
|
async function runCheck(opts = {}) {
|
|
214
|
+
if (isDevLink()) return { updated: false, reason: "dev-link" };
|
|
189
215
|
const state = readState();
|
|
190
216
|
if (!opts.force) {
|
|
191
217
|
const dis = updatesDisabled();
|
package/dist/updater/install.js
CHANGED
|
@@ -17,6 +17,10 @@ const LOCK_STALE_MS = 10 * 60 * 1000;
|
|
|
17
17
|
* precompiled (dist/) and its deps need no build step, so nothing is lost.
|
|
18
18
|
*/
|
|
19
19
|
export function npmInstallGipity(version) {
|
|
20
|
+
// A missing cwd makes spawnSync fail with "spawnSync npm ENOENT", which reads
|
|
21
|
+
// as "npm is not installed". The tree can be gone because the user deleted it
|
|
22
|
+
// (our own recovery hint says to), so create it rather than mislead.
|
|
23
|
+
ensureLocalTree();
|
|
20
24
|
const res = spawnSyncCommand(resolveCommand('npm'), ['install', '--no-audit', '--no-fund', '--ignore-scripts', `gipity@${version}`], {
|
|
21
25
|
cwd: LOCAL_DIR,
|
|
22
26
|
stdio: ['ignore', 'ignore', 'pipe'],
|
|
@@ -39,6 +43,15 @@ const WEDGE_CODES = /\b(ENOTEMPTY|EEXIST|ENOTDIR|EISDIR|EJSONPARSE)\b/;
|
|
|
39
43
|
export function isWedged(stderr) {
|
|
40
44
|
return WEDGE_CODES.test(stderr);
|
|
41
45
|
}
|
|
46
|
+
/** Make sure the local install dir and its package.json exist.
|
|
47
|
+
* `dir` is overridable for tests only. */
|
|
48
|
+
export function ensureLocalTree(dir = LOCAL_DIR) {
|
|
49
|
+
mkdirSync(dir, { recursive: true });
|
|
50
|
+
const pkgJson = join(dir, 'package.json');
|
|
51
|
+
if (!existsSync(pkgJson)) {
|
|
52
|
+
writeFileSync(pkgJson, JSON.stringify({ name: 'gipity-local', private: true, version: '0.0.0' }, null, 2));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
42
55
|
/** Wipe the local install tree back to a pristine, installable state.
|
|
43
56
|
* `dir` is overridable for tests only. */
|
|
44
57
|
export function resetLocalTree(dir = LOCAL_DIR) {
|
package/dist/updater/shim.js
CHANGED
|
@@ -38,14 +38,15 @@ function spawnSyncCommand(cmd, args = [], options = {}) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// src/updater/shim.ts
|
|
41
|
-
import {
|
|
42
|
-
import { fileURLToPath, pathToFileURL } from "url";
|
|
43
|
-
import { dirname as
|
|
41
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
42
|
+
import { fileURLToPath as fileURLToPath2, pathToFileURL } from "url";
|
|
43
|
+
import { dirname as dirname3, resolve as resolve2, join as join4 } from "path";
|
|
44
44
|
|
|
45
45
|
// src/updater/state.ts
|
|
46
46
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
|
47
|
-
import { join } from "path";
|
|
47
|
+
import { dirname, join, resolve } from "path";
|
|
48
48
|
import { homedir } from "os";
|
|
49
|
+
import { fileURLToPath } from "url";
|
|
49
50
|
var GIPITY_DIR = join(homedir(), ".gipity");
|
|
50
51
|
var LOCAL_DIR = join(GIPITY_DIR, "local");
|
|
51
52
|
var LOCAL_PKG_DIR = join(LOCAL_DIR, "node_modules", "gipity");
|
|
@@ -53,6 +54,22 @@ var LOCAL_ENTRY = join(LOCAL_PKG_DIR, "dist", "index.js");
|
|
|
53
54
|
var STATE_FILE = join(GIPITY_DIR, "update-state.json");
|
|
54
55
|
var SETTINGS_FILE = join(GIPITY_DIR, "settings.json");
|
|
55
56
|
var UPDATE_LOG = join(GIPITY_DIR, "update.log");
|
|
57
|
+
function findPkgRoot() {
|
|
58
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
59
|
+
for (; ; ) {
|
|
60
|
+
try {
|
|
61
|
+
if (JSON.parse(readFileSync(join(dir, "package.json"), "utf-8")).name === "gipity") return dir;
|
|
62
|
+
} catch {
|
|
63
|
+
}
|
|
64
|
+
const up = dirname(dir);
|
|
65
|
+
if (up === dir) return resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
66
|
+
dir = up;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
var PKG_ROOT = findPkgRoot();
|
|
70
|
+
function isDevLink() {
|
|
71
|
+
return existsSync(join(PKG_ROOT, "src"));
|
|
72
|
+
}
|
|
56
73
|
var DEFAULT_STATE = {
|
|
57
74
|
installedVersion: null,
|
|
58
75
|
lastCheckAt: 0,
|
|
@@ -76,15 +93,15 @@ function writeState(state) {
|
|
|
76
93
|
}
|
|
77
94
|
|
|
78
95
|
// src/updater/bootstrap.ts
|
|
79
|
-
import { existsSync as existsSync3
|
|
80
|
-
import { join as join3 } from "path";
|
|
96
|
+
import { existsSync as existsSync3 } from "fs";
|
|
81
97
|
|
|
82
98
|
// src/updater/install.ts
|
|
83
99
|
import { existsSync as existsSync2, mkdirSync as mkdirSync2, rmSync, statSync, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
|
|
84
|
-
import { dirname, join as join2 } from "path";
|
|
100
|
+
import { dirname as dirname2, join as join2 } from "path";
|
|
85
101
|
var UPDATE_LOCK = join2(GIPITY_DIR, "update.lock");
|
|
86
102
|
var LOCK_STALE_MS = 10 * 60 * 1e3;
|
|
87
103
|
function npmInstallGipity(version) {
|
|
104
|
+
ensureLocalTree();
|
|
88
105
|
const res = spawnSyncCommand(resolveCommand("npm"), ["install", "--no-audit", "--no-fund", "--ignore-scripts", `gipity@${version}`], {
|
|
89
106
|
cwd: LOCAL_DIR,
|
|
90
107
|
stdio: ["ignore", "ignore", "pipe"],
|
|
@@ -101,6 +118,13 @@ var WEDGE_CODES = /\b(ENOTEMPTY|EEXIST|ENOTDIR|EISDIR|EJSONPARSE)\b/;
|
|
|
101
118
|
function isWedged(stderr) {
|
|
102
119
|
return WEDGE_CODES.test(stderr);
|
|
103
120
|
}
|
|
121
|
+
function ensureLocalTree(dir = LOCAL_DIR) {
|
|
122
|
+
mkdirSync2(dir, { recursive: true });
|
|
123
|
+
const pkgJson = join2(dir, "package.json");
|
|
124
|
+
if (!existsSync2(pkgJson)) {
|
|
125
|
+
writeFileSync2(pkgJson, JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
104
128
|
function resetLocalTree(dir = LOCAL_DIR) {
|
|
105
129
|
mkdirSync2(dir, { recursive: true });
|
|
106
130
|
rmSync(join2(dir, "node_modules"), { recursive: true, force: true });
|
|
@@ -108,7 +132,7 @@ function resetLocalTree(dir = LOCAL_DIR) {
|
|
|
108
132
|
writeFileSync2(join2(dir, "package.json"), JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
|
|
109
133
|
}
|
|
110
134
|
function acquireUpdateLock(lockPath = UPDATE_LOCK) {
|
|
111
|
-
mkdirSync2(
|
|
135
|
+
mkdirSync2(dirname2(lockPath), { recursive: true });
|
|
112
136
|
try {
|
|
113
137
|
writeFileSync2(lockPath, String(process.pid), { flag: "wx" });
|
|
114
138
|
return true;
|
|
@@ -136,11 +160,7 @@ function isBootstrapped() {
|
|
|
136
160
|
return existsSync3(LOCAL_ENTRY);
|
|
137
161
|
}
|
|
138
162
|
function bootstrap(version, quiet = false) {
|
|
139
|
-
|
|
140
|
-
const pkgJsonPath = join3(LOCAL_DIR, "package.json");
|
|
141
|
-
if (!existsSync3(pkgJsonPath)) {
|
|
142
|
-
writeFileSync3(pkgJsonPath, JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
|
|
143
|
-
}
|
|
163
|
+
ensureLocalTree();
|
|
144
164
|
if (!acquireUpdateLock()) {
|
|
145
165
|
if (!quiet) process.stderr.write(`gipity: another update is in progress - using the currently installed build.
|
|
146
166
|
`);
|
|
@@ -182,8 +202,8 @@ function bootstrap(version, quiet = false) {
|
|
|
182
202
|
}
|
|
183
203
|
|
|
184
204
|
// src/trace.ts
|
|
185
|
-
import { openSync, writeSync, mkdirSync as
|
|
186
|
-
import { join as
|
|
205
|
+
import { openSync, writeSync, mkdirSync as mkdirSync3 } from "fs";
|
|
206
|
+
import { join as join3 } from "path";
|
|
187
207
|
import { homedir as homedir2 } from "os";
|
|
188
208
|
var TRACE_KEY = /* @__PURE__ */ Symbol.for("gipity.traceOutput");
|
|
189
209
|
function installOutputTrace(label) {
|
|
@@ -195,10 +215,10 @@ function installOutputTrace(label) {
|
|
|
195
215
|
existing.emit({ event: "reenter", label });
|
|
196
216
|
return;
|
|
197
217
|
}
|
|
198
|
-
const dir =
|
|
199
|
-
|
|
218
|
+
const dir = join3(process.env.GIPITY_DIR || join3(homedir2(), ".gipity"), "trace");
|
|
219
|
+
mkdirSync3(dir, { recursive: true });
|
|
200
220
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", "_").replace(/:/g, "-");
|
|
201
|
-
const fd = openSync(
|
|
221
|
+
const fd = openSync(join3(dir, `${stamp}-pid${process.pid}.jsonl`), "a");
|
|
202
222
|
const emit = (rec) => {
|
|
203
223
|
try {
|
|
204
224
|
writeSync(fd, JSON.stringify({ t: (/* @__PURE__ */ new Date()).toISOString(), ...rec }) + "\n");
|
|
@@ -233,12 +253,12 @@ function installOutputTrace(label) {
|
|
|
233
253
|
|
|
234
254
|
// src/updater/shim.ts
|
|
235
255
|
installOutputTrace("shim");
|
|
236
|
-
var __dirname =
|
|
237
|
-
var pkgRoot =
|
|
238
|
-
var shimPkg = JSON.parse(readFileSync2(
|
|
239
|
-
var
|
|
256
|
+
var __dirname = dirname3(fileURLToPath2(import.meta.url));
|
|
257
|
+
var pkgRoot = resolve2(__dirname, "..", "..");
|
|
258
|
+
var shimPkg = JSON.parse(readFileSync2(join4(pkgRoot, "package.json"), "utf-8"));
|
|
259
|
+
var devLink = isDevLink();
|
|
240
260
|
function startBackgroundUpdater() {
|
|
241
|
-
const checkScript =
|
|
261
|
+
const checkScript = join4(__dirname, "check.js");
|
|
242
262
|
try {
|
|
243
263
|
const child = spawnCommand(process.execPath, [checkScript], {
|
|
244
264
|
detached: true,
|
|
@@ -260,11 +280,11 @@ async function runEntry(entry) {
|
|
|
260
280
|
}
|
|
261
281
|
}
|
|
262
282
|
var execLocal = () => runEntry(LOCAL_ENTRY);
|
|
263
|
-
var execSelf = () => runEntry(
|
|
283
|
+
var execSelf = () => runEntry(resolve2(__dirname, "..", "index.js"));
|
|
264
284
|
var rawArgs = process.argv.slice(2);
|
|
265
285
|
var firstArg = rawArgs[0];
|
|
266
286
|
var isLoud = rawArgs.length === 0 || firstArg === "claude" || firstArg === "--version" || firstArg === "-v" || firstArg === "version";
|
|
267
|
-
if (
|
|
287
|
+
if (devLink) {
|
|
268
288
|
await execSelf();
|
|
269
289
|
} else if (!isBootstrapped() && !bootstrap(shimPkg.version, !isLoud)) {
|
|
270
290
|
await execSelf();
|
package/dist/updater/state.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';
|
|
2
|
-
import { join } from 'path';
|
|
2
|
+
import { dirname, join, resolve } from 'path';
|
|
3
3
|
import { homedir } from 'os';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
4
5
|
export const GIPITY_DIR = join(homedir(), '.gipity');
|
|
5
6
|
export const LOCAL_DIR = join(GIPITY_DIR, 'local');
|
|
6
7
|
export const LOCAL_PKG_DIR = join(LOCAL_DIR, 'node_modules', 'gipity');
|
|
@@ -8,6 +9,31 @@ export const LOCAL_ENTRY = join(LOCAL_PKG_DIR, 'dist', 'index.js');
|
|
|
8
9
|
export const STATE_FILE = join(GIPITY_DIR, 'update-state.json');
|
|
9
10
|
export const SETTINGS_FILE = join(GIPITY_DIR, 'settings.json');
|
|
10
11
|
export const UPDATE_LOG = join(GIPITY_DIR, 'update.log');
|
|
12
|
+
/** Root of the gipity package this code runs from. Walks up to its
|
|
13
|
+
* package.json because the depth differs: dist/updater/*.js are separate
|
|
14
|
+
* files, while dist/index.js is a bundle that inlines this module. */
|
|
15
|
+
function findPkgRoot() {
|
|
16
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
for (;;) {
|
|
18
|
+
try {
|
|
19
|
+
if (JSON.parse(readFileSync(join(dir, 'package.json'), 'utf-8')).name === 'gipity')
|
|
20
|
+
return dir;
|
|
21
|
+
}
|
|
22
|
+
catch { /* no package.json here */ }
|
|
23
|
+
const up = dirname(dir);
|
|
24
|
+
if (up === dir)
|
|
25
|
+
return resolve(dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
26
|
+
dir = up;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export const PKG_ROOT = findPkgRoot();
|
|
30
|
+
/** Published tarballs ship `dist/**` only (package.json `files`), so a sibling
|
|
31
|
+
* `src/` means `gipity` was `npm link`ed from a source checkout. A dev link
|
|
32
|
+
* runs that checkout's own build and never auto-updates: installing a
|
|
33
|
+
* published copy into ~/.gipity/local would be pointless (nothing runs it). */
|
|
34
|
+
export function isDevLink() {
|
|
35
|
+
return existsSync(join(PKG_ROOT, 'src'));
|
|
36
|
+
}
|
|
11
37
|
const DEFAULT_STATE = {
|
|
12
38
|
installedVersion: null,
|
|
13
39
|
lastCheckAt: 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gipity",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.31",
|
|
4
4
|
"description": "The full-stack platform tuned for AI agents. Database, storage, auth, functions, deploy, and drop-in kits - all agent-tuned. Pair with Claude Code or use standalone.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"gipity": "dist/updater/shim.js",
|