@nodii/dev 0.6.102 → 0.6.103
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/core.js +1 -1
- package/dist/harness.js +18 -7
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
|
4
4
|
import { homedir, platform } from "node:os";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
|
|
7
|
-
export const VERSION = "0.6.
|
|
7
|
+
export const VERSION = "0.6.103";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/harness.js
CHANGED
|
@@ -358,6 +358,8 @@ export function sourceChanges(before = [], after = []) {
|
|
|
358
358
|
const execFileAsync = promisify(execFile);
|
|
359
359
|
|
|
360
360
|
/** The repository root and Dev's `repo` key: the git remote's name, else the folder's. */
|
|
361
|
+
const MACHINE_ONLY_REPO = "machine";
|
|
362
|
+
|
|
361
363
|
export async function repoContext(cwd = process.cwd()) {
|
|
362
364
|
let root;
|
|
363
365
|
try { root = (await execFileAsync("git", ["rev-parse", "--show-toplevel"], { cwd, encoding: "utf8" })).stdout.trim(); }
|
|
@@ -468,10 +470,18 @@ export async function harnessCommand(action, flags, { request = devRequest, cont
|
|
|
468
470
|
if (!["install", "update", "check"].includes(action)) throw new CliError("USAGE", "harness install|update|check [--repo NAME] [--service ID] [--include-drafts[=false]] [--adopt PATH,...] [--dry-run] [--check] [--system]", 2);
|
|
469
471
|
if (flags.fleet || flags.all) throw new CliError("USAGE", "The harness is installed one service at a time, in that service's repository. There is no fleet mode.", 2);
|
|
470
472
|
if (flags.root === true || flags.repo === true) throw new CliError("USAGE", "--root and --repo need a value.", 2);
|
|
471
|
-
|
|
472
|
-
|
|
473
|
+
// `update --system` is about this machine, so a coordinator can run it
|
|
474
|
+
// anywhere: with no checkout or no harness here it refreshes the managed
|
|
475
|
+
// hooks and writes no repository files. Dev's hooks don't depend on the repo.
|
|
476
|
+
const machineWide = action === "update" && Boolean(flags.system) && !flags.check;
|
|
477
|
+
const ctx = flags.root ? { root: flags.root, repo: flags.repo } : await context().catch((error) => {
|
|
478
|
+
if (machineWide && error?.code === "GIT_REQUIRED") return null;
|
|
479
|
+
throw error;
|
|
480
|
+
});
|
|
481
|
+
const repo = flags.repo && flags.repo !== true ? String(flags.repo) : (ctx?.repo ?? (machineWide ? MACHINE_ONLY_REPO : undefined));
|
|
473
482
|
if (!repo) throw new CliError("USAGE", "Pass --repo NAME.", 2);
|
|
474
|
-
const state = await readState(ctx.root);
|
|
483
|
+
const state = ctx ? await readState(ctx.root) : null;
|
|
484
|
+
const machineOnly = machineWide && !state;
|
|
475
485
|
// Update and check ask Dev for what install asked for, unless told otherwise.
|
|
476
486
|
const saved = action === "install" ? {} : (state?.request ?? {});
|
|
477
487
|
const serviceId = flags.service && flags.service !== true ? String(flags.service) : (saved.serviceId ?? undefined);
|
|
@@ -502,7 +512,7 @@ export async function harnessCommand(action, flags, { request = devRequest, cont
|
|
|
502
512
|
if (action === "check" || (action === "update" && flags.check)) return checkCommand(ctx.root, repo, state, fetchHarness);
|
|
503
513
|
|
|
504
514
|
const harness = (await fetchHarness({ draftFallback: true })).data;
|
|
505
|
-
const plan = await planHarness(ctx.root, harness, { install: action === "install", adopt: flagList(flags.adopt), request: { ...(serviceId ? { serviceId } : {}), includeDrafts: effectiveIncludeDrafts } });
|
|
515
|
+
const plan = machineOnly ? { changes: [], conflicts: [] } : await planHarness(ctx.root, harness, { install: action === "install", adopt: flagList(flags.adopt), request: { ...(serviceId ? { serviceId } : {}), includeDrafts: effectiveIncludeDrafts } });
|
|
506
516
|
const summary = {
|
|
507
517
|
repo: harness.repo, serviceId: harness.serviceId ?? null,
|
|
508
518
|
from: state?.methodologyVersion ?? null, to: harness.methodologyVersion,
|
|
@@ -510,6 +520,7 @@ export async function harnessCommand(action, flags, { request = devRequest, cont
|
|
|
510
520
|
changes: plan.changes.map(({ path, action: a, mode }) => ({ path, action: a, mode })),
|
|
511
521
|
conflicts: plan.conflicts, warnings: harness.warnings ?? [],
|
|
512
522
|
};
|
|
523
|
+
if (machineOnly) summary.machineOnly = true;
|
|
513
524
|
const lines = [
|
|
514
525
|
`${harness.repo}${harness.serviceId ? ` (${harness.serviceId})` : ""}: methodology ${summary.from ? `${summary.from} → ` : ""}${summary.to}`,
|
|
515
526
|
...summary.sources.map((x) => ` source ${x}`),
|
|
@@ -528,7 +539,7 @@ export async function harnessCommand(action, flags, { request = devRequest, cont
|
|
|
528
539
|
const systemCli = managedCli?.cliPath ?? managedCliPath;
|
|
529
540
|
const systemCliVersion = managedCli?.version;
|
|
530
541
|
const codexChange = plan.changes.find((change) => change.path === ".codex/hooks.json");
|
|
531
|
-
const codexText = codexChange?.text ?? await optional(join(ctx.root, ".codex/hooks.json"));
|
|
542
|
+
const codexText = codexChange?.text ?? (machineOnly ? harness.files.find((file) => file.path === ".codex/hooks.json")?.content : await optional(join(ctx.root, ".codex/hooks.json")));
|
|
532
543
|
const managedBundle = flags.system ? managedHookBundle(codexText, { home: managedHome, cliPath: systemCli, cliVersion: systemCliVersion }) : null;
|
|
533
544
|
// Claude's managed layer carries only Dev's generated hooks, never the user
|
|
534
545
|
// entries a merged settings file on disk may also hold.
|
|
@@ -553,7 +564,7 @@ export async function harnessCommand(action, flags, { request = devRequest, cont
|
|
|
553
564
|
const systemText = systemCommands.length
|
|
554
565
|
? `\nManaged Codex hooks are staged in ${managedBundle.dir}. One operator install covers codex-personal and codex-work; review ${join(managedBundle.dir, "requirements.toml")}, then run:\n${systemCommands.join("\n")}${claudeText}\nNo privileged command was run. Later --system updates refresh the user-owned managed directories without sudo.`
|
|
555
566
|
: "";
|
|
556
|
-
await applyHarness(ctx.root, plan);
|
|
567
|
+
if (!machineOnly) await applyHarness(ctx.root, plan);
|
|
557
568
|
if (managedBundle) await writeManaged(managedBundle);
|
|
558
569
|
if (claudeBundle) await writeManagedClaude(claudeBundle);
|
|
559
570
|
// Without --system, a machine that already has managed hooks still gets the
|
|
@@ -565,5 +576,5 @@ export async function harnessCommand(action, flags, { request = devRequest, cont
|
|
|
565
576
|
: managedCli.current ? `\nThe managed nodii-dev is at the latest release, ${managedCli.version}.`
|
|
566
577
|
: `\nInstalled the managed nodii-dev ${managedCli.version}${managedCli.previous ? ` over ${managedCli.previous}` : ""} at ${managedCli.cliPath}.`;
|
|
567
578
|
const claudeData = claudePlan ? { claudeManagedDir: claudeBundle.dir, claudeManaged: { state: claudePlan.state, target: claudePlan.target, systemCommands: claudePlan.commands } } : {};
|
|
568
|
-
return { payload: { data: { ...summary, applied: true, ...(systemCommands.length ? { systemCommands: [...systemCommands, ...(claudePlan?.commands ?? [])], managedDir: managedBundle.dir } : {}), ...claudeData, ...(refreshed.length ? { managedDispatchRefreshed: refreshed } : {}), ...(managedCli ? { managedCli } : {}) } }, human: `${lines.join("\n")}\n${plan.changes.length ? `${action === "install" ? "Installed" : "Updated"}: ${plan.changes.length} change${plan.changes.length === 1 ? "" : "s"}.` : "Harness already current."}${systemText}${refreshText}${managedCliText}` };
|
|
579
|
+
return { payload: { data: { ...summary, applied: true, ...(systemCommands.length ? { systemCommands: [...systemCommands, ...(claudePlan?.commands ?? [])], managedDir: managedBundle.dir } : {}), ...claudeData, ...(refreshed.length ? { managedDispatchRefreshed: refreshed } : {}), ...(managedCli ? { managedCli } : {}) } }, human: `${lines.join("\n")}\n${machineOnly ? "No harness in this directory: refreshed this machine's managed hooks only, and wrote no repository files." : plan.changes.length ? `${action === "install" ? "Installed" : "Updated"}: ${plan.changes.length} change${plan.changes.length === 1 ? "" : "s"}.` : "Harness already current."}${systemText}${refreshText}${managedCliText}` };
|
|
569
580
|
}
|