@nice-code/commander 0.81.0 → 0.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/build/cli.cjs +14 -7
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +14 -7
- package/build/cli.mjs.map +1 -1
- package/build/client/assets/index-Bl7iM1Ei.js +23 -0
- package/build/client/assets/index-Bl7iM1Ei.js.map +1 -0
- package/build/client/assets/index-DnkKT_BD.css +1 -0
- package/build/client/index.html +7 -1
- package/build/{main-CecRz_2L.cjs → main-BXxko_iD.cjs} +53 -7
- package/build/main-BXxko_iD.cjs.map +1 -0
- package/build/{main-DyR1LyM-.mjs → main-BegwVMLM.mjs} +53 -7
- package/build/main-BegwVMLM.mjs.map +1 -0
- package/package.json +9 -8
- package/build/client/assets/index-BaHIV1eO.js +0 -19
- package/build/client/assets/index-BaHIV1eO.js.map +0 -1
- package/build/main-CecRz_2L.cjs.map +0 -1
- package/build/main-DyR1LyM-.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -64,6 +64,19 @@ terms). `up --dry-run` and `explain` show exactly what would be touched, without
|
|
|
64
64
|
Node ≥ 22 or Bun. The web UI is pre-built into the package; Vite and React are not installed on
|
|
65
65
|
your machine. Built on [`@nice-code/process`](https://www.npmjs.com/package/@nice-code/process).
|
|
66
66
|
|
|
67
|
+
## Developing the web UI (`bun run dev`)
|
|
68
|
+
|
|
69
|
+
Editing the UI needs a fast loop, so the package ships a dev harness: `bun run dev` (from
|
|
70
|
+
`packages/nice-commander`) serves the client **source** with Vite hot reload and proxies its
|
|
71
|
+
auth/websocket lanes to a throwaway daemon running the `dev/showroom.config.ts` demo. Open the
|
|
72
|
+
printed URL, edit `src/client/**`, and watch it hot-reload live against a real backend.
|
|
73
|
+
|
|
74
|
+
- `NICE_COMMANDER_DEV_PORT` changes the vite port (default 5196). The daemon runs on its own
|
|
75
|
+
`showroom` data dir and port range, so it never touches your real environment.
|
|
76
|
+
- `NICE_COMMANDER_DEV_OPEN=0` skips auto-opening a browser (headless runs).
|
|
77
|
+
- Ctrl+C (or closing the vite server) stops the showroom daemon and its processes too.
|
|
78
|
+
- The demo needs `build/cli.mjs`; the harness runs `bun run build:server` itself if it is missing.
|
|
79
|
+
|
|
67
80
|
## Security posture
|
|
68
81
|
|
|
69
82
|
Loopback only. The browser takes a capability from a same-origin bootstrap and keeps it in memory —
|
package/build/cli.cjs
CHANGED
|
@@ -148,7 +148,7 @@ function validStartStamp(value) {
|
|
|
148
148
|
function isInstanceRecord(value) {
|
|
149
149
|
if (value == null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
150
150
|
const record = value;
|
|
151
|
-
return record.service === "nice-commander" && boundedString(record.instanceId) && boundedInt(record.generation, 0, Number.MAX_SAFE_INTEGER) && boundedInt(record.pid, 1, Number.MAX_SAFE_INTEGER) && boundedInt(record.port, 1, 65535) && boundedString(record.token) && boundedString(record.configKey) && boundedString(record.configRevisionHash) && boundedString(record.configPath) && boundedString(record.packageVersion) && boundedString(record.realmSchemaHash) && validStartStamp(record.startStamp) && record.protocolVersion ===
|
|
151
|
+
return record.service === "nice-commander" && boundedString(record.instanceId) && boundedInt(record.generation, 0, Number.MAX_SAFE_INTEGER) && boundedInt(record.pid, 1, Number.MAX_SAFE_INTEGER) && boundedInt(record.port, 1, 65535) && boundedString(record.token) && boundedString(record.configKey) && boundedString(record.configRevisionHash) && boundedString(record.configPath) && boundedString(record.packageVersion) && boundedString(record.realmSchemaHash) && validStartStamp(record.startStamp) && record.protocolVersion === 4;
|
|
152
152
|
}
|
|
153
153
|
async function writeInstanceRecord(path, record) {
|
|
154
154
|
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(path), {
|
|
@@ -198,7 +198,7 @@ async function readSkewedInstanceRecord(path, expectedRealmSchemaHash) {
|
|
|
198
198
|
if (!boundedInt(record["protocolVersion"], 0, Number.MAX_SAFE_INTEGER)) return null;
|
|
199
199
|
if (!boundedInt(record["pid"], 1, Number.MAX_SAFE_INTEGER)) return null;
|
|
200
200
|
if (!boundedInt(record["port"], 1, 65535)) return null;
|
|
201
|
-
const sameProtocol = record["protocolVersion"] ===
|
|
201
|
+
const sameProtocol = record["protocolVersion"] === 4;
|
|
202
202
|
const sameRealm = boundedString(record["realmSchemaHash"]) && record["realmSchemaHash"] === expectedRealmSchemaHash;
|
|
203
203
|
if (sameProtocol && sameRealm) return null;
|
|
204
204
|
return {
|
|
@@ -23092,6 +23092,7 @@ const commanderStatusRealm = defineRealm({
|
|
|
23092
23092
|
avatars: { viewer: { persistentId: t.string() } },
|
|
23093
23093
|
state: {
|
|
23094
23094
|
generation: t.number(),
|
|
23095
|
+
configName: t.string(),
|
|
23095
23096
|
configRevisionHash: t.string(),
|
|
23096
23097
|
configError: t.array(t.string()),
|
|
23097
23098
|
processes: t.record(t.id("processId"), t.object({
|
|
@@ -23107,6 +23108,11 @@ const commanderStatusRealm = defineRealm({
|
|
|
23107
23108
|
endedAt: t.number(),
|
|
23108
23109
|
durationMs: t.optional(t.number())
|
|
23109
23110
|
})),
|
|
23111
|
+
recentRuns: t.array(t.object({
|
|
23112
|
+
startedAt: t.number(),
|
|
23113
|
+
endedAt: t.optional(t.number()),
|
|
23114
|
+
outcome: t.optional(t.union(t.literal("succeeded"), t.literal("failed"), t.literal("stopped"), t.literal("crashed"), t.literal("timedOut")))
|
|
23115
|
+
})),
|
|
23110
23116
|
restarts: t.number(),
|
|
23111
23117
|
lastExit: t.optional(t.object({
|
|
23112
23118
|
code: t.optional(t.number()),
|
|
@@ -23130,6 +23136,7 @@ const commanderStatusRealm = defineRealm({
|
|
|
23130
23136
|
cwd: t.string(),
|
|
23131
23137
|
dependsOn: t.array(t.string()),
|
|
23132
23138
|
ready: t.optional(t.string()),
|
|
23139
|
+
timeoutMs: t.optional(t.number()),
|
|
23133
23140
|
endpoints: t.array(t.object({
|
|
23134
23141
|
name: t.string(),
|
|
23135
23142
|
protocol: t.string(),
|
|
@@ -23282,7 +23289,7 @@ var CommanderDaemonBootError = class extends Error {
|
|
|
23282
23289
|
* a live dev environment, and an upgrade must never be the thing that kills one.
|
|
23283
23290
|
*/
|
|
23284
23291
|
async function replaceSkewedDaemon(paths, skewed) {
|
|
23285
|
-
const daemonLabel = `the daemon for this config (pid ${skewed.pid}, build ${skewed.packageVersion}, protocol v${skewed.protocolVersion}) predates this CLI (protocol
|
|
23292
|
+
const daemonLabel = `the daemon for this config (pid ${skewed.pid}, build ${skewed.packageVersion}, protocol v${skewed.protocolVersion}) predates this CLI (protocol v4${skewed.skew === "realm-schema" ? ", different status schema" : ""})`;
|
|
23286
23293
|
let liveIds = [];
|
|
23287
23294
|
try {
|
|
23288
23295
|
liveIds = (await (0, _nice_code_process.openProcessLedger)({
|
|
@@ -23602,7 +23609,7 @@ async function findDaemon(config) {
|
|
|
23602
23609
|
async function findSkewedDaemon(config) {
|
|
23603
23610
|
const skewed = await readSkewedInstanceRecord(commanderStatePaths(resolveCommanderDataDir(), config.configKey).instanceRecordPath, commanderStatusRealm.schemaHash);
|
|
23604
23611
|
if (skewed == null || !pidAlive$1(skewed.pid)) return null;
|
|
23605
|
-
const difference = skewed.skew === "protocol" ? `speaks protocol v${skewed.protocolVersion}; this build speaks
|
|
23612
|
+
const difference = skewed.skew === "protocol" ? `speaks protocol v${skewed.protocolVersion}; this build speaks v4` : "was started before an upgrade changed the status schema";
|
|
23606
23613
|
return {
|
|
23607
23614
|
message: `the daemon for this config (pid ${skewed.pid}, port ${skewed.port}, build ${skewed.packageVersion}) ${difference} — this CLI (build ${await commanderPackageVersion()}) cannot talk to it. Run \`nice-commander shutdown\` (it stops a daemon from any build), then retry.`,
|
|
23608
23615
|
pid: skewed.pid,
|
|
@@ -23698,7 +23705,7 @@ async function connectDaemon(handle) {
|
|
|
23698
23705
|
const payload = await (await runtime.handleActionPayload(request)).waitForResultPayload();
|
|
23699
23706
|
if (!payload.result.ok) throw new CliExit(EXIT.failure, `action "${action}" rejected by the daemon`);
|
|
23700
23707
|
const report = parseActionReport(payload.result.output);
|
|
23701
|
-
if (report == null) throw new CliExit(EXIT.failure, `the daemon answered "${action}" with something this CLI does not recognise — protocol ${record.protocolVersion} vs
|
|
23708
|
+
if (report == null) throw new CliExit(EXIT.failure, `the daemon answered "${action}" with something this CLI does not recognise — protocol ${record.protocolVersion} vs 4`);
|
|
23702
23709
|
return report;
|
|
23703
23710
|
},
|
|
23704
23711
|
setEnv: async (input) => {
|
|
@@ -25058,7 +25065,7 @@ function renderTable(out, state) {
|
|
|
25058
25065
|
String(proc.restarts),
|
|
25059
25066
|
notesFor(proc, now)
|
|
25060
25067
|
]);
|
|
25061
|
-
const head =
|
|
25068
|
+
const head = `${state.configName} · generation ${state.generation} · revision ${state.configRevisionHash}`;
|
|
25062
25069
|
const configError = state.configError.length > 0 ? `\nconfig error (last-good kept): ${state.configError[0]}` : "";
|
|
25063
25070
|
return `${out.paint("gray", head)}\n${out.table([
|
|
25064
25071
|
"ID",
|
|
@@ -25267,7 +25274,7 @@ async function withTimeout(ctx, run) {
|
|
|
25267
25274
|
async function main() {
|
|
25268
25275
|
const argv = process.argv.slice(2);
|
|
25269
25276
|
if (argv[0] === "daemon") {
|
|
25270
|
-
const { runCommanderDaemon } = await Promise.resolve().then(() => require("./main-
|
|
25277
|
+
const { runCommanderDaemon } = await Promise.resolve().then(() => require("./main-BXxko_iD.cjs"));
|
|
25271
25278
|
return runCommanderDaemon(argv.slice(1));
|
|
25272
25279
|
}
|
|
25273
25280
|
const parsed = parseCliArgs(argv);
|