hostinger-api-mcp 4.14.2 → 4.15.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/CHANGELOG.md +7 -0
- package/gemini-extension.json +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/skills/headless/SKILL.md +22 -5
- package/skills/headless/VERSION +2 -2
- package/skills/headless/connect/SKILL.md +3 -2
- package/skills/headless/run-log.mjs +226 -66
- package/skills/headless/steps/02-check-state/SKILL.md +10 -27
- package/src/core/skills.js +12 -12
- package/src/core/skills.ts +12 -12
- package/src/servers/agency-hosting.js +1 -1
- package/src/servers/agency-hosting.ts +1 -1
- package/src/servers/agent-readiness.js +1 -1
- package/src/servers/agent-readiness.ts +1 -1
- package/src/servers/all.js +1 -1
- package/src/servers/all.ts +1 -1
- package/src/servers/billing.js +1 -1
- package/src/servers/billing.ts +1 -1
- package/src/servers/dns.js +1 -1
- package/src/servers/dns.ts +1 -1
- package/src/servers/domains.js +1 -1
- package/src/servers/domains.ts +1 -1
- package/src/servers/ecommerce.js +1 -1
- package/src/servers/ecommerce.ts +1 -1
- package/src/servers/gpu.js +1 -1
- package/src/servers/gpu.ts +1 -1
- package/src/servers/horizons.js +1 -1
- package/src/servers/horizons.ts +1 -1
- package/src/servers/hosting.js +1 -1
- package/src/servers/hosting.ts +1 -1
- package/src/servers/mail.js +1 -1
- package/src/servers/mail.ts +1 -1
- package/src/servers/reach.js +1 -1
- package/src/servers/reach.ts +1 -1
- package/src/servers/vps.js +1 -1
- package/src/servers/vps.ts +1 -1
- package/src/servers/wordpress.js +1 -1
- package/src/servers/wordpress.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ Generated at release time from the diff between the previous and current
|
|
|
4
4
|
build. Tool changes are listed individually; everything else is summarised
|
|
5
5
|
by area.
|
|
6
6
|
|
|
7
|
+
## v4.15.0 — 2026-11-20
|
|
8
|
+
|
|
9
|
+
### Also in this release
|
|
10
|
+
|
|
11
|
+
- Bundled agent skills: 5 files
|
|
12
|
+
- Other files: `src/core/skills.js`, `src/core/skills.ts`
|
|
13
|
+
|
|
7
14
|
## v4.14.2 — 2026-11-20
|
|
8
15
|
|
|
9
16
|
### Operations
|
package/gemini-extension.json
CHANGED
package/package.json
CHANGED
package/server.json
CHANGED
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"url": "https://github.com/hostinger/api-mcp-server",
|
|
18
18
|
"source": "github"
|
|
19
19
|
},
|
|
20
|
-
"version": "4.
|
|
20
|
+
"version": "4.15.0",
|
|
21
21
|
"packages": [
|
|
22
22
|
{
|
|
23
23
|
"registryType": "npm",
|
|
24
24
|
"identifier": "@hostinger/mcp",
|
|
25
|
-
"version": "4.
|
|
25
|
+
"version": "4.15.0",
|
|
26
26
|
"transport": {
|
|
27
27
|
"type": "stdio"
|
|
28
28
|
},
|
package/skills/headless/SKILL.md
CHANGED
|
@@ -81,6 +81,16 @@ Every run starts the same way:
|
|
|
81
81
|
paused cleanly for a tool restart (*register, restart, resume* in `connect/SKILL.md`, from connect,
|
|
82
82
|
provision or content model). Don't ask the brief again then: it's agreed, and check-state resumes
|
|
83
83
|
where the run paused.
|
|
84
|
+
|
|
85
|
+
`run-start` also takes the domain's lock, so only one session builds a domain at a time. A
|
|
86
|
+
session that crashed or was closed doesn't block it. If `run-start` fails with "another session
|
|
87
|
+
(…) is building <domain>":
|
|
88
|
+
1. Stop: no refine, no files, and no final report, since this session started no run.
|
|
89
|
+
2. Tell the user plainly which tool is building this domain, since when and in which stage (the
|
|
90
|
+
message names all three), and that if they tell you to take over, you will, and the other
|
|
91
|
+
session stops at its next step.
|
|
92
|
+
3. Only if the user says so, run `run-start` again with `--take-over` and the same flags. With no
|
|
93
|
+
one to ask (`claude -p` or another unattended run), just stop and say why.
|
|
84
94
|
3. **Refine**, then **connect** (`connect/SKILL.md`, Phase 2 onward), then **check-state**, then the
|
|
85
95
|
rest of the table. When a later stage sends the run back to refine (check-state or provision), the
|
|
86
96
|
connector is already in this session: refine returns to the stage that sent it.
|
|
@@ -94,8 +104,8 @@ work on Hostinger begins. Refinement before provisioning, because the backend ca
|
|
|
94
104
|
the brief exists. Validation before deploy, always — nothing reaches the live domain unseen.
|
|
95
105
|
|
|
96
106
|
**One concurrency rule:** two *independent* stages in a single session may run at once, but never
|
|
97
|
-
two writers of the same artifact, and never two agents/windows on the same domain —
|
|
98
|
-
(
|
|
107
|
+
two writers of the same artifact, and never two agents/windows on the same domain — `run-start`'s
|
|
108
|
+
lock guards that (*Start of a run*). Parallelism is always *optional*: an agent that can't interleave work runs the
|
|
99
109
|
steps serially and is still correct (see *Content and design at the same time*).
|
|
100
110
|
|
|
101
111
|
Steps can generate **State files** those files are only hints; the truth is what the Hostinger connector reports, so
|
|
@@ -329,12 +339,14 @@ in. Write it out in full each time (a shell variable holding the command breaks
|
|
|
329
339
|
|
|
330
340
|
```bash
|
|
331
341
|
node <skill>/run-log.mjs <domain> run-start --tool <tool> --model <model> --skill <skill version> # start of the run; prints the stage to run next
|
|
342
|
+
node <skill>/run-log.mjs <domain> run-start --take-over --tool <tool> --model <model> --skill <skill version> # only after the user says to take over (Start of a run)
|
|
332
343
|
node <skill>/run-log.mjs <domain> run-update --kind resume # check-state, once the route is agreed (or redesign / iterate)
|
|
333
344
|
node <skill>/run-log.mjs <domain> next frontend # at a stage boundary: ends the open stage as ok, starts this one
|
|
334
345
|
node <skill>/run-log.mjs <domain> next frontend --phase shell # split stages log each phase
|
|
335
346
|
node <skill>/run-log.mjs <domain> stage-end frontend ok_after_retries --note "second framework tried" # any other result, or a note
|
|
336
347
|
node <skill>/run-log.mjs <domain> stage-start frontend # start without ending anything
|
|
337
348
|
node <skill>/run-log.mjs <domain> event issue '{"stage":"content_model","symptom":"…","cause":"…","workaround":"…","severity":"medium","resolved":true}'
|
|
349
|
+
node <skill>/run-log.mjs <domain> pause # stopping for a tool restart (below)
|
|
338
350
|
node <skill>/run-log.mjs <domain> report --outcome live # done, or wherever the run stops
|
|
339
351
|
node <skill>/run-log.mjs <domain> report-sent <run> # after the report was sent (see below)
|
|
340
352
|
node <skill>/run-log.mjs <domain> report-rejected <run> # the send returned 422
|
|
@@ -364,10 +376,15 @@ rewrites the same `reports/<run>.json` and `.html`, so you get one report that i
|
|
|
364
376
|
not a second report that replaces `report.html`. Use `run-start` only in a new session, at the start
|
|
365
377
|
of the run (*Start of a run*).
|
|
366
378
|
|
|
379
|
+
**The run log owns the domain's lock.** Never create or delete `~/.hostinger/<domain>/.lock`
|
|
380
|
+
yourself. When a command after `run-start` fails with "another session … is building <domain>; stop
|
|
381
|
+
and tell the user", the user moved the build to another session: stop at once, write nothing more,
|
|
382
|
+
and tell them so.
|
|
383
|
+
|
|
367
384
|
**A restart pause continues the run.** When a stage stops for the user to restart their tool, leave
|
|
368
|
-
its stage open and
|
|
369
|
-
|
|
370
|
-
|
|
385
|
+
its stage open and run `pause`: the next session's `run-start` continues a run whose only open stage
|
|
386
|
+
is `connect`, `provision` or `content_model` and that paused, instead of closing it as `abandoned`,
|
|
387
|
+
and opens connect. A run whose session crashed or was taken over is closed as `abandoned`.
|
|
371
388
|
|
|
372
389
|
`stage-end` results: `ok`, `ok_after_retries`, `ok_with_fixups`, `failed`, `skipped`, `stopped`.
|
|
373
390
|
Stages, in run order: `refine`, `connect`, `check_state`, `provision`, `content_model`, `design`,
|
package/skills/headless/VERSION
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
version=4.
|
|
2
|
-
commit=
|
|
1
|
+
version=4.15.0
|
|
2
|
+
commit=989db63e0f79
|
|
3
3
|
built=2026-11-20
|
|
@@ -176,8 +176,9 @@ until the tool restarts. When either tool group above is missing:
|
|
|
176
176
|
3. **Pause and end your turn.** Send one line saying Hostinger is set up and the plan is saved,
|
|
177
177
|
asking the user to restart the tool (the route says how) and paste the same prompt again so the
|
|
178
178
|
build continues from there. Leave the current stage open in the run log (connect's, or provision's
|
|
179
|
-
or content model's when they pause here), and
|
|
180
|
-
|
|
179
|
+
or content model's when they pause here), and run
|
|
180
|
+
`node <skill>/run-log.mjs <domain> pause`, which releases the domain for the next session: this
|
|
181
|
+
session ends here. This is a pause, not a run ending: no final report and no build report.
|
|
181
182
|
4. **On the next run** `run-start` continues this run at connect (*Start of a run* in
|
|
182
183
|
`<skill>/SKILL.md`), so the brief isn't asked again. Connect finds the tools loaded, skips
|
|
183
184
|
registration, and the run goes on to check-state, which resumes where the run paused.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Hostinger Headless run log: records a build as it happens and writes reports/<run>.json + .html.
|
|
3
3
|
//
|
|
4
|
-
// node run-log.mjs <domain> run-start [--kind build|resume|redesign|iterate] [--tool <tool>] [--model <model>] [--skill <version>]
|
|
4
|
+
// node run-log.mjs <domain> run-start [--kind build|resume|redesign|iterate] [--tool <tool>] [--model <model>] [--skill <version>] [--take-over]
|
|
5
5
|
// node run-log.mjs <domain> run-update [--kind …] [--model …] [--skill …]
|
|
6
6
|
// node run-log.mjs <domain> run-resume [--reason "<text>"]
|
|
7
7
|
// node run-log.mjs <domain> stage-start <stage> [--phase <phase>] [--started-ago 6m | --started-at <ISO time>]
|
|
@@ -9,14 +9,16 @@
|
|
|
9
9
|
// node run-log.mjs <domain> next <stage> [--phase <phase>]
|
|
10
10
|
// node run-log.mjs <domain> stage-fix <stage> [--phase <phase>] (--started-ago 6m | --started-at <ISO time>)
|
|
11
11
|
// node run-log.mjs <domain> event <issue|feedback|skill_gap|good> '<json>'
|
|
12
|
+
// node run-log.mjs <domain> pause
|
|
12
13
|
// node run-log.mjs <domain> report [--outcome live|stopped|failed|abandoned] [--tokens '<json>']
|
|
13
14
|
// node run-log.mjs <domain> unsent
|
|
14
15
|
// node run-log.mjs <domain> report-sent [<run>]
|
|
15
16
|
// node run-log.mjs <domain> report-rejected [<run>]
|
|
16
17
|
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
18
|
+
import { spawnSync } from 'node:child_process';
|
|
19
|
+
import { appendFileSync, copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
20
|
+
import { homedir, hostname } from 'node:os';
|
|
21
|
+
import { basename, dirname, join } from 'node:path';
|
|
20
22
|
import { fileURLToPath } from 'node:url';
|
|
21
23
|
|
|
22
24
|
const STAGES = ['refine', 'connect', 'check_state', 'provision', 'content_model', 'design', 'frontend', 'validate', 'deploy', 'done'];
|
|
@@ -88,9 +90,154 @@ function workspace(domain, { create = false } = {}) {
|
|
|
88
90
|
logPath: join(dir, 'run-log.json'),
|
|
89
91
|
eventsPath: join(dir, 'events.jsonl'),
|
|
90
92
|
reportsDir: join(dir, 'reports'),
|
|
93
|
+
lockPath: join(dir, '.lock'),
|
|
91
94
|
};
|
|
92
95
|
}
|
|
93
96
|
|
|
97
|
+
// One session at a time builds a domain, and .lock names it. The holder is the agent process (Claude
|
|
98
|
+
// Code, Codex, claude -p): each command runs in a short-lived shell under it, so the nearest ancestor
|
|
99
|
+
// that isn't a shell or a wrapper lives as long as the session and no longer.
|
|
100
|
+
// Linux ps cuts a name to 15 characters, so each wrapper also matches its cut form.
|
|
101
|
+
const WRAPPERS = new Set(['sh', 'bash', 'zsh', 'dash', 'fish', 'pwsh', 'powershell', 'cmd', 'sandbox-exec', 'bwrap', 'codex-linux-sandbox', 'env', 'timeout', 'caffeinate']
|
|
102
|
+
.flatMap((name) => [name, name.slice(0, 15)]));
|
|
103
|
+
// A lock whose holder can't be checked (another host, no process list, the old timestamp-only lock)
|
|
104
|
+
// counts as live while it was refreshed this recently.
|
|
105
|
+
const LOCK_FRESH_MS = 30 * 60 * 1000;
|
|
106
|
+
|
|
107
|
+
const processName = (name) => basename(name.replace(/\\/g, '/')).replace(/^-/, '').replace(/\.exe$/i, '').toLowerCase();
|
|
108
|
+
|
|
109
|
+
// pid -> { ppid, started, name }; null when the process list can't be read. The start time tells a
|
|
110
|
+
// reused PID from the process that held the lock.
|
|
111
|
+
function processTable() {
|
|
112
|
+
const windows = process.platform === 'win32';
|
|
113
|
+
const r = windows
|
|
114
|
+
? spawnSync('powershell', ['-NoProfile', '-NonInteractive', '-Command',
|
|
115
|
+
'Get-CimInstance Win32_Process | ForEach-Object { "$($_.ProcessId)`t$($_.ParentProcessId)`t$(if ($_.CreationDate) { $_.CreationDate.ToUniversalTime().ToString(\'o\') })`t$($_.Name)" }'], { encoding: 'utf8' })
|
|
116
|
+
: spawnSync('ps', ['-A', '-o', 'pid=,ppid=,lstart=,comm='], { encoding: 'utf8', env: { ...process.env, LC_ALL: 'C', TZ: 'UTC' } });
|
|
117
|
+
if (r.status !== 0 || !r.stdout) return null;
|
|
118
|
+
const table = new Map();
|
|
119
|
+
for (const line of r.stdout.split(/\r?\n/)) {
|
|
120
|
+
const m = windows ? line.match(/^(\d+)\t(\d+)\t([^\t]*)\t(.*)$/) : line.trim().match(/^(\d+)\s+(\d+)\s+(\w+\s+\w+\s+\d+\s+[\d:]+\s+\d+)\s+(.*)$/);
|
|
121
|
+
if (m) table.set(Number(m[1]), { ppid: Number(m[2]), started: m[3].replace(/\s+/g, ' ') || null, name: m[4] });
|
|
122
|
+
}
|
|
123
|
+
return table.size ? table : null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function currentHolder(table) {
|
|
127
|
+
let pid = process.ppid;
|
|
128
|
+
while (table?.has(pid) && WRAPPERS.has(processName(table.get(pid).name))) pid = table.get(pid).ppid;
|
|
129
|
+
const proc = table?.get(pid);
|
|
130
|
+
return { host: hostname(), pid, started: proc?.started ?? null, process: proc ? processName(proc.name) : null };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// The old timestamp-only lock, or one another session is still writing, has no holder: only a time.
|
|
134
|
+
function readLock(ws) {
|
|
135
|
+
let text;
|
|
136
|
+
let mtime;
|
|
137
|
+
try {
|
|
138
|
+
text = readFileSync(ws.lockPath, 'utf8');
|
|
139
|
+
mtime = statSync(ws.lockPath).mtimeMs;
|
|
140
|
+
} catch {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
const lock = JSON.parse(text);
|
|
145
|
+
if (lock && typeof lock === 'object' && Number.isInteger(lock.pid)) return lock;
|
|
146
|
+
} catch {}
|
|
147
|
+
const stamped = Date.parse(text.trim());
|
|
148
|
+
const refreshed = new Date(Number.isNaN(stamped) ? mtime : stamped).toISOString();
|
|
149
|
+
return { host: null, pid: null, started: null, process: null, tool: null, acquired_at: refreshed, refreshed_at: refreshed };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const byRecency = (lock) => (Date.now() - Date.parse(lock.refreshed_at) < LOCK_FRESH_MS ? 'live' : 'dead');
|
|
153
|
+
|
|
154
|
+
// own, live or dead; unverified when there is no process list (a sandbox that blocks ps), where the
|
|
155
|
+
// holder found is the command's own shell and this session can't be told from another on this host.
|
|
156
|
+
function lockStatus(lock, me, table) {
|
|
157
|
+
if (lock.host !== me.host) return byRecency(lock);
|
|
158
|
+
if (!table) return 'unverified';
|
|
159
|
+
if (lock.pid === me.pid && lock.started === me.started) return 'own';
|
|
160
|
+
if (lock.started) return table.get(lock.pid)?.started === lock.started ? 'live' : 'dead';
|
|
161
|
+
return byRecency(lock);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Replacing the lock goes through a rename, so a reader never sees half of it.
|
|
165
|
+
function writeLock(ws, lock) {
|
|
166
|
+
const tmp = `${ws.lockPath}.${process.pid}.tmp`;
|
|
167
|
+
writeJson(tmp, lock);
|
|
168
|
+
renameSync(tmp, ws.lockPath);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Of two sessions creating a missing lock at once, exactly one succeeds.
|
|
172
|
+
function createLock(ws, lock) {
|
|
173
|
+
try {
|
|
174
|
+
writeFileSync(ws.lockPath, `${JSON.stringify(lock, null, 2)}\n`, { flag: 'wx' });
|
|
175
|
+
return true;
|
|
176
|
+
} catch (error) {
|
|
177
|
+
if (error.code === 'EEXIST') return false;
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Reads the run log without migrating it: a refused session writes nothing.
|
|
183
|
+
function holderStage(ws) {
|
|
184
|
+
try {
|
|
185
|
+
const log = readJson(ws.logPath, {});
|
|
186
|
+
const open = openStages(log, log.run?.id).at(-1);
|
|
187
|
+
return { tool: log.run?.tool ?? null, stage: open ? stageLabel(open) : null };
|
|
188
|
+
} catch {
|
|
189
|
+
return { tool: null, stage: null };
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function refuse(ws, lock, { offerTakeOver }) {
|
|
194
|
+
const { tool, stage } = holderStage(ws);
|
|
195
|
+
const who = [
|
|
196
|
+
lock.tool ?? tool ?? lock.process,
|
|
197
|
+
lock.pid === null ? null : lock.host === hostname() ? `pid ${lock.pid}` : `on ${lock.host}`,
|
|
198
|
+
`since ${lock.acquired_at}`,
|
|
199
|
+
stage && `in ${stage}`,
|
|
200
|
+
].filter(Boolean).join(', ');
|
|
201
|
+
const takeOver = offerTakeOver ? '. Only if the user says to take over, run run-start --take-over: the other session stops at its next step' : '';
|
|
202
|
+
fail(`another session (${who}) is building ${ws.domain}; stop and tell the user${takeOver}`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Checks the lock before a command writes anything: another live session's lock refuses it, and this
|
|
206
|
+
// session's own lock is refreshed. `take` also takes a missing lock or one whose holder is gone.
|
|
207
|
+
// `start` (run-start) does too, offers a takeover when refused, and with `takeOver` takes a live lock.
|
|
208
|
+
// wasFree: no lock existed.
|
|
209
|
+
function claimLock(ws, { take = false, start = false, takeOver = false, tool = null }) {
|
|
210
|
+
const table = processTable();
|
|
211
|
+
const me = currentHolder(table);
|
|
212
|
+
const record = () => ({ ...me, tool, acquired_at: now(), refreshed_at: now() });
|
|
213
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
214
|
+
const lock = readLock(ws);
|
|
215
|
+
if (!lock) {
|
|
216
|
+
if (!take) return { lock: null, wasFree: true };
|
|
217
|
+
const fresh = record();
|
|
218
|
+
if (createLock(ws, fresh)) return { lock: fresh, wasFree: true };
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
// An unverified lock: run-start judges it by recency, and a later command trusts that run-start
|
|
222
|
+
// settled it rather than refuse its own session.
|
|
223
|
+
const verdict = lockStatus(lock, me, table);
|
|
224
|
+
const status = verdict === 'unverified' ? (start ? byRecency(lock) : 'own') : verdict;
|
|
225
|
+
if (status === 'own') {
|
|
226
|
+
const refreshed = { ...lock, tool: tool ?? lock.tool, refreshed_at: now() };
|
|
227
|
+
writeLock(ws, refreshed);
|
|
228
|
+
return { lock: refreshed, wasFree: false };
|
|
229
|
+
}
|
|
230
|
+
if (status === 'live' && !takeOver) refuse(ws, lock, { offerTakeOver: start });
|
|
231
|
+
if (!take) return { lock: null, wasFree: false };
|
|
232
|
+
// Two sessions taking over the same dead lock at once both rename theirs in; the one that lost
|
|
233
|
+
// is refused at its next command.
|
|
234
|
+
const taken = record();
|
|
235
|
+
writeLock(ws, taken);
|
|
236
|
+
return { lock: taken, wasFree: false };
|
|
237
|
+
}
|
|
238
|
+
fail(`${ws.lockPath} keeps appearing and disappearing; another session is starting on ${ws.domain}. Stop and tell the user`);
|
|
239
|
+
}
|
|
240
|
+
|
|
94
241
|
// state.json belongs to the agent, which may rewrite it whole or leave it half-written, so the run
|
|
95
242
|
// log keeps its own file and only reads state.json, treating anything unreadable as empty.
|
|
96
243
|
function readState(ws) {
|
|
@@ -119,6 +266,14 @@ function migrate(ws) {
|
|
|
119
266
|
writeJson(ws.statePath, state);
|
|
120
267
|
}
|
|
121
268
|
|
|
269
|
+
const openStages = (log, runId) => (log.history ?? []).filter((h) => h.run === runId && !h.ended_at);
|
|
270
|
+
const stageLabel = (h) => `${h.stage}${h.phase ? `/${h.phase}` : ''}`;
|
|
271
|
+
// A run pauses for a tool restart with exactly one stage open, one that can stop for a restart.
|
|
272
|
+
function pausableStage(log) {
|
|
273
|
+
const open = openStages(log, log.run?.id);
|
|
274
|
+
return open.length === 1 && RESTART_STAGES.includes(open[0].stage) ? open[0] : null;
|
|
275
|
+
}
|
|
276
|
+
|
|
122
277
|
function currentRun(log) {
|
|
123
278
|
if (!log.run?.id) fail('no run started; call run-start first (the start of every run does this)');
|
|
124
279
|
return log.run;
|
|
@@ -141,23 +296,21 @@ function readConnect(ws) {
|
|
|
141
296
|
return { tool: typeof connect.tool === 'string' ? connect.tool : null, mcp: version, skills: typeof connect.skills === 'string' ? connect.skills : null };
|
|
142
297
|
}
|
|
143
298
|
|
|
144
|
-
function runStart(ws, flags) {
|
|
299
|
+
function runStart(ws, flags, lockWasFree) {
|
|
145
300
|
const log = loadLog(ws);
|
|
146
301
|
// A run left open in a restart stage goes on in the new session, at connect, instead of being
|
|
147
302
|
// abandoned. The paused stage ends at its last logged activity, so the restart wait isn't counted.
|
|
148
|
-
// A
|
|
303
|
+
// A run paused by older skill text has no paused_at; it deleted .lock instead.
|
|
149
304
|
const history = (log.history ?? []).filter((h) => h.run === log.run?.id);
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const [paused] = open;
|
|
305
|
+
const paused = pausableStage(log);
|
|
306
|
+
if (log.run?.id && !log.run.reported_at && paused && (log.run.paused_at || lockWasFree)) {
|
|
307
|
+
delete log.run.paused_at;
|
|
154
308
|
for (const key of ['model', 'skill']) if (typeof flags[key] === 'string') log.run[key] = flags[key];
|
|
155
309
|
const events = readEvents(ws).filter((e) => e.run === log.run.id);
|
|
156
310
|
Object.assign(paused, { ended_at: lastActivity(log.run, history, events), result: 'ok', note: paused.note ? `${paused.note}; ${PAUSE_NOTE}` : PAUSE_NOTE });
|
|
157
311
|
log.history.push({ run: log.run.id, stage: 'connect', phase: null, started_at: now(), ended_at: null, result: null, note: 'continued after a tool restart' });
|
|
158
312
|
saveLog(ws, log);
|
|
159
|
-
|
|
160
|
-
console.log(`run ${log.run.id} continued after a tool restart in ${where}; next: connect`);
|
|
313
|
+
console.log(`run ${log.run.id} continued after a tool restart in ${stageLabel(paused)}; next: connect`);
|
|
161
314
|
return;
|
|
162
315
|
}
|
|
163
316
|
// A previous run that never reached its report (closed window, crash) is closed out first, so
|
|
@@ -222,6 +375,18 @@ function runResume(ws, flags) {
|
|
|
222
375
|
console.log(`run ${run.id} resumed (follow-up ${run.follow_ups.length})`);
|
|
223
376
|
}
|
|
224
377
|
|
|
378
|
+
// A tool-restart pause leaves its stage open, and the dispatch releases the lock, so the next
|
|
379
|
+
// session's run-start continues the run at connect instead of closing it as abandoned.
|
|
380
|
+
function pause(ws) {
|
|
381
|
+
const log = loadLog(ws);
|
|
382
|
+
const run = currentRun(log);
|
|
383
|
+
const paused = pausableStage(log);
|
|
384
|
+
if (!paused) fail(`a restart pause needs exactly one open stage, one of ${RESTART_STAGES.join(', ')}; open now: ${openStages(log, run.id).map(stageLabel).join(', ') || 'none'}`);
|
|
385
|
+
run.paused_at = now();
|
|
386
|
+
saveLog(ws, log);
|
|
387
|
+
console.log(`run ${run.id} paused in ${stageLabel(paused)}; the next session's run-start continues it at connect`);
|
|
388
|
+
}
|
|
389
|
+
|
|
225
390
|
function stageStart(ws, [stage], flags) {
|
|
226
391
|
if (!STAGES.includes(stage)) fail(`unknown stage "${stage}"; one of ${STAGES.join(', ')}`);
|
|
227
392
|
const log = loadLog(ws);
|
|
@@ -688,60 +853,55 @@ document.querySelectorAll('.bar').forEach((el) => {
|
|
|
688
853
|
`;
|
|
689
854
|
}
|
|
690
855
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
case 'run-update':
|
|
699
|
-
runUpdate(ws, flags);
|
|
700
|
-
break;
|
|
701
|
-
case 'run-resume':
|
|
702
|
-
runResume(ws, flags);
|
|
703
|
-
break;
|
|
704
|
-
case 'stage-start':
|
|
705
|
-
stageStart(ws, rest, flags);
|
|
706
|
-
break;
|
|
707
|
-
case 'stage-end':
|
|
708
|
-
stageEnd(ws, rest, flags);
|
|
709
|
-
break;
|
|
710
|
-
case 'next':
|
|
711
|
-
next(ws, rest, flags);
|
|
712
|
-
break;
|
|
713
|
-
case 'stage-fix':
|
|
714
|
-
stageFix(ws, rest, flags);
|
|
715
|
-
break;
|
|
716
|
-
case 'event':
|
|
717
|
-
event(ws, rest);
|
|
718
|
-
break;
|
|
719
|
-
case 'report': {
|
|
720
|
-
let tokens;
|
|
721
|
-
if (typeof flags.tokens === 'string') {
|
|
722
|
-
try {
|
|
723
|
-
tokens = JSON.parse(flags.tokens);
|
|
724
|
-
} catch {
|
|
725
|
-
fail('--tokens must be JSON, e.g. \'{"input":0,"output":0,"source":"…"}\'');
|
|
726
|
-
}
|
|
727
|
-
// null and {} can't be sent; treat them as not reported.
|
|
728
|
-
if (tokens === null || (typeof tokens === 'object' && !Array.isArray(tokens) && !Object.keys(tokens).length)) tokens = undefined;
|
|
729
|
-
else validate(tokens, { ...reportSchema()?.properties?.tokens, type: 'object' }, '--tokens');
|
|
856
|
+
function report(ws, flags) {
|
|
857
|
+
let tokens;
|
|
858
|
+
if (typeof flags.tokens === 'string') {
|
|
859
|
+
try {
|
|
860
|
+
tokens = JSON.parse(flags.tokens);
|
|
861
|
+
} catch {
|
|
862
|
+
fail('--tokens must be JSON, e.g. \'{"input":0,"output":0,"source":"…"}\'');
|
|
730
863
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
break;
|
|
864
|
+
// null and {} can't be sent; treat them as not reported.
|
|
865
|
+
if (tokens === null || (typeof tokens === 'object' && !Array.isArray(tokens) && !Object.keys(tokens).length)) tokens = undefined;
|
|
866
|
+
else validate(tokens, { ...reportSchema()?.properties?.tokens, type: 'object' }, '--tokens');
|
|
735
867
|
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
case 'report-sent':
|
|
740
|
-
reportSent(ws, rest);
|
|
741
|
-
break;
|
|
742
|
-
case 'report-rejected':
|
|
743
|
-
reportRejected(ws, rest);
|
|
744
|
-
break;
|
|
745
|
-
default:
|
|
746
|
-
fail('command must be run-start, run-update, run-resume, stage-start, stage-end, next, stage-fix, event, report, unsent, report-sent or report-rejected');
|
|
868
|
+
console.log(`report written: ${buildReport(ws, { outcome: flags.outcome, tokens })}`);
|
|
869
|
+
const { id, file } = reportFile(ws);
|
|
870
|
+
console.log(`send it: pass ${file} unchanged to hosting_headless_submit-build-report, then run report-sent ${id} (or report-rejected ${id} on a 422)`);
|
|
747
871
|
}
|
|
872
|
+
|
|
873
|
+
// What each command does with the domain's lock: check it (refuse if another live session holds it,
|
|
874
|
+
// refresh it if this one does), take it, start (take it, or take it over when asked), release it
|
|
875
|
+
// after the command, or leave it alone.
|
|
876
|
+
const COMMANDS = {
|
|
877
|
+
'run-start': { lock: 'start', run: (ws, rest, flags, claim) => runStart(ws, flags, claim.wasFree) },
|
|
878
|
+
'run-update': { lock: 'check', run: (ws, rest, flags) => runUpdate(ws, flags) },
|
|
879
|
+
'run-resume': { lock: 'take', run: (ws, rest, flags) => runResume(ws, flags) },
|
|
880
|
+
'stage-start': { lock: 'check', run: stageStart },
|
|
881
|
+
'stage-end': { lock: 'check', run: stageEnd },
|
|
882
|
+
next: { lock: 'check', run: next },
|
|
883
|
+
'stage-fix': { lock: 'check', run: stageFix },
|
|
884
|
+
event: { lock: 'check', run: (ws, rest) => event(ws, rest) },
|
|
885
|
+
pause: { lock: 'release', run: (ws) => pause(ws) },
|
|
886
|
+
report: { lock: 'release', run: (ws, rest, flags) => report(ws, flags) },
|
|
887
|
+
unsent: { lock: 'none', run: (ws) => unsent(ws) },
|
|
888
|
+
'report-sent': { lock: 'check', run: (ws, rest) => reportSent(ws, rest) },
|
|
889
|
+
'report-rejected': { lock: 'check', run: (ws, rest) => reportRejected(ws, rest) },
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
const { positional, flags } = parseArgs(process.argv.slice(2));
|
|
893
|
+
const [domain, command, ...rest] = positional;
|
|
894
|
+
const spec = COMMANDS[command];
|
|
895
|
+
const names = Object.keys(COMMANDS);
|
|
896
|
+
if (!spec) fail(`command must be ${names.slice(0, -1).join(', ')} or ${names.at(-1)}`);
|
|
897
|
+
const ws = workspace(domain, { create: spec.lock === 'start' });
|
|
898
|
+
const start = spec.lock === 'start';
|
|
899
|
+
const claim = spec.lock === 'none' ? null : claimLock(ws, {
|
|
900
|
+
take: start || spec.lock === 'take',
|
|
901
|
+
start,
|
|
902
|
+
takeOver: start && flags['take-over'] === true,
|
|
903
|
+
tool: start && typeof flags.tool === 'string' ? flags.tool : null,
|
|
904
|
+
});
|
|
905
|
+
spec.run(ws, rest, flags, claim);
|
|
906
|
+
// A command that fails exits before this, so a refused pause or report keeps the lock.
|
|
907
|
+
if (spec.lock === 'release' && claim.lock) rmSync(ws.lockPath, { force: true });
|
|
@@ -39,7 +39,8 @@ try each. Don't ask first and say nothing about it to the user. Don't let a fail
|
|
|
39
39
|
|
|
40
40
|
## Step 1 — Is a build actively running right now? (check this before anything else)
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
Another session building this domain was already ruled out: `run-start` holds the domain's lock for
|
|
43
|
+
this session. What's left is the platform, and **never guess from a timestamp.**
|
|
43
44
|
|
|
44
45
|
- **A platform build actively in progress** — the only *reliable* "running now" signal. Check
|
|
45
46
|
`hosting_websites_list-setups { "domain": "<domain>" }` and exact-match the domain row:
|
|
@@ -55,16 +56,6 @@ Keep two things separate, and **never guess from a timestamp.**
|
|
|
55
56
|
This check **is** the source of truth for `provision.status`: a stored `in_progress`/`completed` in
|
|
56
57
|
`state.json` is only a hint until this reconciles it.
|
|
57
58
|
|
|
58
|
-
- **A `.lock`** — `~/.hostinger/<domain>/.lock`. It only tells you *a previous run
|
|
59
|
-
touched this domain*. **Do not judge it by age** — a 2-minute-old lock and a 3-year-old lock get the
|
|
60
|
-
same treatment, and a lock on its own is **not** a reason to interrupt the user. Carry it into Step 5:
|
|
61
|
-
if there's nothing to resume (new build), silently take it over; only if there's real state to resume
|
|
62
|
-
do you also ask *is another Claude window building this domain right now?* (yes → stop; no → take
|
|
63
|
-
over).
|
|
64
|
-
|
|
65
|
-
Once you're actively working this domain, **acquire/refresh the lock** (write the current timestamp),
|
|
66
|
-
and **release it on a clean stop** (Step 6). The lock marks an active session, nothing more.
|
|
67
|
-
|
|
68
59
|
---
|
|
69
60
|
|
|
70
61
|
## Step 2 — Read the workspace directory
|
|
@@ -144,20 +135,19 @@ artifacts** (`site.json`, `design.md`, `content-model.md`, `src/`, …).
|
|
|
144
135
|
## Step 5 — Guide the user
|
|
145
136
|
|
|
146
137
|
The question to ask depends on whether there is actually **something to resume** — i.e. **build
|
|
147
|
-
artifacts** beyond a brief only, or a **live site** for this domain.
|
|
138
|
+
artifacts** beyond a brief only, or a **live site** for this domain. Connect's files or a brief only are *not*
|
|
148
139
|
something to resume.
|
|
149
140
|
|
|
150
141
|
- **A run paused in provision or content model for a tool restart** (`run-start` printed "continued
|
|
151
142
|
after a tool restart in <stage>/<phase>") → resume at that stage and phase without asking: the user only
|
|
152
|
-
restarted their tool (`run-start` continues a run only
|
|
153
|
-
|
|
143
|
+
restarted their tool (`run-start` continues a run only after a clean `pause`). What Steps 1–3
|
|
144
|
+
found still corrects the stage. A run paused in connect has nothing to resume yet: the cases below apply.
|
|
154
145
|
- **New build** (brief only, and either the domain is free **or** it holds only an empty headless
|
|
155
146
|
shell or a PocketBase site from onboarding) → just proceed to provision. **Don't ask resume vs
|
|
156
147
|
start over** — there's nothing to resume; both would land in the same place. An empty headless
|
|
157
148
|
shell is not "something to resume": it has no backend and no content yet, so it's a fresh build
|
|
158
149
|
that already owns its website — provision will adopt and swap it. Mention it in one line ("Using
|
|
159
|
-
the headless site onboarding already created for this domain.").
|
|
160
|
-
around, silently take it over and continue (optionally mention it in one line).
|
|
150
|
+
the headless site onboarding already created for this domain.").
|
|
161
151
|
- **The brief named another backend than the site fixes** (Step 3) → send the run back to refine
|
|
162
152
|
with that backend fixed (`next refine`; refine Step 1, *A fixed backend*). Refine re-confirms the
|
|
163
153
|
plan with the user in one message and writes the brief, then the run returns here and lands in
|
|
@@ -169,8 +159,7 @@ something to resume.
|
|
|
169
159
|
installed** — WordPress at `/cms`, a store, a PocketBase backend with build artifacts, or a deployed app) → tell the user plainly what's there
|
|
170
160
|
and **ask them to choose**, regardless of how old it is (don't guess from timestamps):
|
|
171
161
|
|
|
172
|
-
- **Resume** — pick up at the computed stage.
|
|
173
|
-
other window is actively building this domain right now.)
|
|
162
|
+
- **Resume** — pick up at the computed stage.
|
|
174
163
|
- **Start over / redo a step** — only safe **before anything is provisioned**. If the site is already
|
|
175
164
|
provisioned or live, you **cannot** re-create it: that is forward-only *iterate* (change content or
|
|
176
165
|
design and redeploy), not a fresh build. Never re-provision or overwrite a live site; if the user
|
|
@@ -191,12 +180,6 @@ Write `~/.hostinger/<domain>/state.json` with the agreed next `stage` and a fres
|
|
|
191
180
|
route isn't a new build, record it with `run-log.mjs <domain> run-update --kind resume` (or
|
|
192
181
|
`redesign` / `iterate`) and end the stage with the route as its note, in one shell command:
|
|
193
182
|
`… run-update --kind resume && … stage-end check_state ok --note "<the route>"`.
|
|
194
|
-
Then
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
actively running) and continue.
|
|
198
|
-
- **Stopping and returning control to the user?** (e.g. the next stage isn't built yet; waiting for
|
|
199
|
-
an answer is not a stop.) **Delete the `.lock`** — the session is no longer active, and a leftover lock just
|
|
200
|
-
forces an unnecessary "is another window running?" question on the next run. Always release the lock
|
|
201
|
-
on a clean stop; it exists only to mark an actively-running session. A stop is still the end of a
|
|
202
|
-
run: give the final report and save the build report (`09-done`).
|
|
183
|
+
Then hand straight to the next stage. If the run stops here instead (waiting for an answer is not a
|
|
184
|
+
stop), that is still the end of a run: give the final report and save the build report (`09-done`),
|
|
185
|
+
whose `report` releases the domain.
|