@pome-sh/cli 0.45.1 → 0.46.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/assets/dashboard/app.css +3 -0
- package/assets/dashboard/app.js +9 -0
- package/assets/dashboard/index.html +15 -0
- package/dist/build-info.json +3 -3
- package/dist/{checks-RDU56OGI.js → checks-FMIUVJ73.js} +2 -2
- package/dist/{twinTape-5P3HQ27N.js → chunk-4EPQF6CR.js} +261 -31
- package/dist/{chunk-IZFM7W2V.js → chunk-GBMPR32X.js} +34 -10
- package/dist/{chunk-DX2KCFJM.js → chunk-GTLGXFLQ.js} +1 -1
- package/dist/{chunk-HEEFOMSZ.js → chunk-J5IF4T3C.js} +7 -4
- package/dist/{chunk-BXYPNEJY.js → chunk-LDDR6XRN.js} +45 -22
- package/dist/{chunk-EZYVICDB.js → chunk-QO6QJ6MN.js} +3 -1
- package/dist/chunk-TG6GFWA3.js +48 -0
- package/dist/{runTrialGroup-MMTTTDWY.js → runTrialGroup-FZWKPVI5.js} +6 -6
- package/dist/src/cli/main.js +121 -154
- package/dist/{src-STAXYPD3.js → src-F5FHPGJP.js} +1 -1
- package/dist/{src-46YGR2WY.js → src-L54OSFDK.js} +1 -1
- package/dist/{src-LPTWNBO5.js → src-LYV6LLKW.js} +1 -1
- package/dist/{src-D3PKLT54.js → src-MRJ73S46.js} +1 -1
- package/dist/{src-CV7QDV5E.js → src-PQ35TNOF.js} +1 -1
- package/dist/twinHarness-VEIXQJ4Y.js +6 -0
- package/dist/{twinSeed-ZFZO7BL7.js → twinSeed-LDKR3NPY.js} +1 -1
- package/dist/{twinStart-XN3BYOUF.js → twinStart-44W63TRH.js} +379 -93
- package/dist/twinTape-433A4IC4.js +10 -0
- package/package.json +2 -1
- package/dist/chunk-AGZOWSLG.js +0 -142
- package/dist/twinHarness-I2JGKQYD.js +0 -6
- package/dist/{run-WONFTZS3.js → run-CFA4LZWQ.js} +1 -1
package/dist/chunk-AGZOWSLG.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { mkdir, writeFile, rename, chmod, readFile, unlink, open, stat } from 'node:fs/promises';
|
|
2
|
-
import { dirname, join, basename } from 'node:path';
|
|
3
|
-
|
|
4
|
-
// src/twin/twinStatusFile.ts
|
|
5
|
-
var STANDALONE_STATUS_PATH = ".pome/twin-status.json";
|
|
6
|
-
async function writeStandaloneStatusFile(status, path = STANDALONE_STATUS_PATH) {
|
|
7
|
-
await mkdir(dirname(path), { recursive: true, mode: 448 });
|
|
8
|
-
const tmp = `${path}.${process.pid}.${Date.now()}.tmp`;
|
|
9
|
-
await writeFile(tmp, JSON.stringify(status, null, 2), { mode: 384 });
|
|
10
|
-
await rename(tmp, path);
|
|
11
|
-
await chmod(path, 384);
|
|
12
|
-
}
|
|
13
|
-
async function ensureSelfIgnoring(dir) {
|
|
14
|
-
if (basename(dir) !== ".pome") return;
|
|
15
|
-
const path = join(dir, ".gitignore");
|
|
16
|
-
try {
|
|
17
|
-
await writeFile(path, "*\n", { flag: "wx", mode: 384 });
|
|
18
|
-
} catch (err) {
|
|
19
|
-
if (err.code !== "EEXIST") throw err;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
var STALE_LOCK_MS = 1e4;
|
|
23
|
-
async function withStatusLock(path, fn) {
|
|
24
|
-
const lockPath = `${path}.lock`;
|
|
25
|
-
const deadline = Date.now() + 5e3;
|
|
26
|
-
for (; ; ) {
|
|
27
|
-
try {
|
|
28
|
-
const handle = await open(lockPath, "wx", 384);
|
|
29
|
-
try {
|
|
30
|
-
await handle.writeFile(String(process.pid));
|
|
31
|
-
} finally {
|
|
32
|
-
await handle.close();
|
|
33
|
-
}
|
|
34
|
-
break;
|
|
35
|
-
} catch (err) {
|
|
36
|
-
if (err.code !== "EEXIST") throw err;
|
|
37
|
-
const age = await stat(lockPath).then((s) => Date.now() - s.mtimeMs, () => 0);
|
|
38
|
-
if (age > STALE_LOCK_MS) {
|
|
39
|
-
await unlink(lockPath).catch(() => void 0);
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (Date.now() > deadline) {
|
|
43
|
-
throw new Error(
|
|
44
|
-
`pome twin start: ${lockPath} is held by another pome process \u2014 if none is running, delete it.`
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
try {
|
|
51
|
-
return await fn();
|
|
52
|
-
} finally {
|
|
53
|
-
await unlink(lockPath).catch(() => void 0);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
async function updateStandaloneStatusFile(entries, path = STANDALONE_STATUS_PATH) {
|
|
57
|
-
await mkdir(dirname(path), { recursive: true, mode: 448 });
|
|
58
|
-
await ensureSelfIgnoring(dirname(path));
|
|
59
|
-
return await withStatusLock(path, async () => {
|
|
60
|
-
const merged = mergeStandaloneStatus(await readStandaloneStatusFile(path), entries);
|
|
61
|
-
await writeStandaloneStatusFile(merged, path);
|
|
62
|
-
return merged;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
function isStatusEntry(value) {
|
|
66
|
-
if (value === null || typeof value !== "object") return false;
|
|
67
|
-
const entry = value;
|
|
68
|
-
return typeof entry.name === "string" && typeof entry.url === "string" && typeof entry.rest_url === "string" && typeof entry.mcp_url === "string" && typeof entry.auth_token === "string";
|
|
69
|
-
}
|
|
70
|
-
function standaloneStatusEntries(contents) {
|
|
71
|
-
if (contents === null || typeof contents !== "object") return [];
|
|
72
|
-
const file = contents;
|
|
73
|
-
if (file.twins !== null && typeof file.twins === "object") {
|
|
74
|
-
return Object.values(file.twins).filter(isStatusEntry);
|
|
75
|
-
}
|
|
76
|
-
return isStatusEntry(file) ? [pick(file)] : [];
|
|
77
|
-
}
|
|
78
|
-
function pick(entry) {
|
|
79
|
-
return {
|
|
80
|
-
name: entry.name,
|
|
81
|
-
url: entry.url,
|
|
82
|
-
rest_url: entry.rest_url,
|
|
83
|
-
mcp_url: entry.mcp_url,
|
|
84
|
-
auth_token: entry.auth_token
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function mergeStandaloneStatus(existing, entries) {
|
|
88
|
-
const twins = {};
|
|
89
|
-
for (const entry of standaloneStatusEntries(existing)) twins[entry.name] = pick(entry);
|
|
90
|
-
for (const entry of entries) twins[entry.name] = pick(entry);
|
|
91
|
-
const first = entries[0];
|
|
92
|
-
if (first === void 0) throw new Error("mergeStandaloneStatus: no entries to write");
|
|
93
|
-
return { ...pick(first), twins };
|
|
94
|
-
}
|
|
95
|
-
async function readStandaloneStatusFile(path = STANDALONE_STATUS_PATH) {
|
|
96
|
-
try {
|
|
97
|
-
return JSON.parse(await readFile(path, "utf8"));
|
|
98
|
-
} catch {
|
|
99
|
-
return void 0;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
var STANDALONE_STATE_DIR = ".pome/twin-state";
|
|
103
|
-
function standaloneInitialStatePath(name, dir = STANDALONE_STATE_DIR) {
|
|
104
|
-
return join(dir, `${name}.initial.json`);
|
|
105
|
-
}
|
|
106
|
-
async function writeStandaloneInitialState(name, state, dir = STANDALONE_STATE_DIR) {
|
|
107
|
-
const path = standaloneInitialStatePath(name, dir);
|
|
108
|
-
await mkdir(dir, { recursive: true, mode: 448 });
|
|
109
|
-
const tmp = `${path}.${process.pid}.tmp`;
|
|
110
|
-
await writeFile(tmp, JSON.stringify(state), { mode: 384 });
|
|
111
|
-
await rename(tmp, path);
|
|
112
|
-
await chmod(path, 384);
|
|
113
|
-
}
|
|
114
|
-
async function readStandaloneInitialState(name, dir = STANDALONE_STATE_DIR) {
|
|
115
|
-
const path = standaloneInitialStatePath(name, dir);
|
|
116
|
-
let raw;
|
|
117
|
-
try {
|
|
118
|
-
raw = await readFile(path, "utf8");
|
|
119
|
-
} catch (err) {
|
|
120
|
-
if (err.code === "ENOENT") return void 0;
|
|
121
|
-
throw err;
|
|
122
|
-
}
|
|
123
|
-
try {
|
|
124
|
-
return JSON.parse(raw);
|
|
125
|
-
} catch {
|
|
126
|
-
throw new Error(`pome twin tape: ${path} is not valid JSON \u2014 restart the twin to rewrite it.`);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
async function snapshotStandaloneInitialState(name, exportState, dir = STANDALONE_STATE_DIR) {
|
|
130
|
-
await unlink(standaloneInitialStatePath(name, dir)).catch((err) => {
|
|
131
|
-
if (err.code !== "ENOENT") throw err;
|
|
132
|
-
});
|
|
133
|
-
try {
|
|
134
|
-
await writeStandaloneInitialState(name, await exportState(), dir);
|
|
135
|
-
} catch (err) {
|
|
136
|
-
console.error(
|
|
137
|
-
`pome twin start: could not snapshot the ${name} twin's state for \`pome twin tape --diff\`: ${err.message}`
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export { STANDALONE_STATUS_PATH, mergeStandaloneStatus, readStandaloneInitialState, readStandaloneStatusFile, snapshotStandaloneInitialState, standaloneInitialStatePath, standaloneStatusEntries, updateStandaloneStatusFile, writeStandaloneStatusFile };
|