wkappbot-code 0.3.5 → 0.3.7
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 +1 -1
- package/bin/postinstall.js +72 -0
- package/bin/wkappbot-code.js +3 -1
- package/lib/wk-hook.js +4 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ wkappbot-code uninstall # undo it (see below)
|
|
|
36
36
|
wkappbot-code --version
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
Other roads to the CLI: `npm i -g https://kiexpert.github.io/wkappbot-kih/wkappbot-code/wkappbot-code.tgz` (the scrub-gated tgz with `SHA256SUMS` and `version.json` beside it), or `npm pack ./wkappbot-code && npm i -g ./wkappbot-code-0.3.
|
|
39
|
+
Other roads to the CLI: `npm i -g https://kiexpert.github.io/wkappbot-kih/wkappbot-code/wkappbot-code.tgz` (the scrub-gated tgz with `SHA256SUMS` and `version.json` beside it), or `npm pack ./wkappbot-code && npm i -g ./wkappbot-code-0.3.6.tgz` from a checkout (`bash wkappbot-code/install.sh` wraps the same `install`). The old command name `wk-appbot-code` (0.2.x) still works.
|
|
40
40
|
|
|
41
41
|
| part | what `install` lays down | skip with |
|
|
42
42
|
|---|---|---|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// wkappbot-code postinstall -- npm runs this after `npm install wkappbot-code` (local or -g).
|
|
3
|
+
// Owner order 2026-11-06: the Default cloud environment's setup script is `npm install wkappbot-code`, and new cloud
|
|
4
|
+
// ROOTs still started with no hooks, because the package had no install script and npm only copied files.
|
|
5
|
+
// CONTRACT: (a) ALWAYS exits 0 and returns within a moment -- the real work runs DETACHED and logs to
|
|
6
|
+
// ~/.wkappbot-code/postinstall.log, then writes ~/.wkappbot-code/postinstall.done; (b) on a Claude Code cloud VM
|
|
7
|
+
// (CLAUDE_CODE_REMOTE set, or a Linux HOME of /root that holds .claude) it runs `wkappbot-code install --no-npm`,
|
|
8
|
+
// which lays the web harness, wires ~/.claude/settings.json (PreToolUse, Stop, UserPromptSubmit, SessionStart through
|
|
9
|
+
// the lite harness), the global git hooks, the wkskill/wk-verify shims and the public skills, keeping every user
|
|
10
|
+
// setting; idempotent: a done marker of the same version skips it; (c) on any other machine it only prints the one
|
|
11
|
+
// command to run. WKAPPBOT_CODE_NO_POSTINSTALL=1 skips it (the selftest sets it so npm-installs in its cases never
|
|
12
|
+
// touch the machine running it). WKAPPBOT_CODE_DEV_SEAT=1 adds --dev-seat (the full pwsh harness instead of lite);
|
|
13
|
+
// WKAPPBOT_CODE_INSTALL_ARGS adds install flags. A user install takes the lite harness: on a stranger's cloud VM the
|
|
14
|
+
// owner's full fleet harness (busy-fleet, letter gates, emergency-edit) would be the wrong default.
|
|
15
|
+
// Spec: wkappbot skill read agent-harness-landscape-2026-howto
|
|
16
|
+
import { spawn } from "node:child_process";
|
|
17
|
+
import { existsSync, mkdirSync, openSync, readFileSync, writeFileSync } from "node:fs";
|
|
18
|
+
import { homedir } from "node:os";
|
|
19
|
+
import { dirname, join } from "node:path";
|
|
20
|
+
import { fileURLToPath } from "node:url";
|
|
21
|
+
|
|
22
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
23
|
+
const CLI = join(HERE, "wkappbot-code.js");
|
|
24
|
+
const STATE = join(homedir(), ".wkappbot-code");
|
|
25
|
+
const LOG = join(STATE, "postinstall.log");
|
|
26
|
+
const DONE = join(STATE, "postinstall.done");
|
|
27
|
+
|
|
28
|
+
function version() {
|
|
29
|
+
try { return JSON.parse(readFileSync(join(HERE, "..", "package.json"), "utf8")).version || "?"; } catch { return "?"; }
|
|
30
|
+
}
|
|
31
|
+
export function isCloudVm(env = process.env, home = homedir(), platform = process.platform) {
|
|
32
|
+
if (env.CLAUDE_CODE_REMOTE) return true;
|
|
33
|
+
return platform === "linux" && home === "/root" && existsSync(join(home, ".claude"));
|
|
34
|
+
}
|
|
35
|
+
function stamp(msg) { try { mkdirSync(STATE, { recursive: true }); writeFileSync(LOG, new Date().toISOString() + " " + msg + "\n", { flag: "a" }); } catch {} }
|
|
36
|
+
|
|
37
|
+
// --run: the detached worker. Runs the installer to the end, then records the done marker with its exit code.
|
|
38
|
+
async function runWorker() {
|
|
39
|
+
const args = [CLI, "install", "--no-npm"];
|
|
40
|
+
if (process.env.WKAPPBOT_CODE_DEV_SEAT === "1") args.push("--dev-seat");
|
|
41
|
+
// extra install flags, e.g. "--no-bin --no-skills" (the selftest; a seat without the SDK release assets)
|
|
42
|
+
args.push(...String(process.env.WKAPPBOT_CODE_INSTALL_ARGS || "").split(/\s+/).filter((a) => /^--[a-z-]+$/.test(a)));
|
|
43
|
+
stamp("worker start: node " + args.join(" "));
|
|
44
|
+
const out = openSync(LOG, "a");
|
|
45
|
+
const rc = await new Promise((res) => {
|
|
46
|
+
const c = spawn(process.execPath, args, { stdio: ["ignore", out, out], env: { ...process.env, WKAPPBOT_CODE_NO_UPDATE_CHECK: "1" } });
|
|
47
|
+
c.on("error", () => res(-1));
|
|
48
|
+
c.on("close", (code) => res(code ?? -1));
|
|
49
|
+
});
|
|
50
|
+
try { writeFileSync(DONE, JSON.stringify({ version: version(), rc, at: new Date().toISOString() }) + "\n"); } catch {}
|
|
51
|
+
stamp("worker done rc " + rc);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function main() {
|
|
55
|
+
if (process.argv[2] === "--run") return runWorker().catch(() => {}).finally(() => process.exit(0));
|
|
56
|
+
if (process.env.WKAPPBOT_CODE_NO_POSTINSTALL === "1") return;
|
|
57
|
+
if (!isCloudVm()) {
|
|
58
|
+
console.log("[wkappbot-code] installed. To wire the harness and OpenCode on this machine run: npx wkappbot-code install (then: wkappbot-code doctor)");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const d = JSON.parse(readFileSync(DONE, "utf8"));
|
|
63
|
+
if (d.version === version() && d.rc === 0) { console.log("[wkappbot-code] cloud VM: harness already wired by " + d.version + " (" + DONE + ")"); return; }
|
|
64
|
+
} catch {}
|
|
65
|
+
mkdirSync(STATE, { recursive: true });
|
|
66
|
+
const out = openSync(LOG, "a");
|
|
67
|
+
const c = spawn(process.execPath, [fileURLToPath(import.meta.url), "--run"], { detached: true, stdio: ["ignore", out, out], env: process.env });
|
|
68
|
+
c.unref();
|
|
69
|
+
console.log("[wkappbot-code] cloud VM detected: wiring the Claude Code harness in the background (log: " + LOG + ", done marker: " + DONE + ")");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
try { main(); } catch (e) { try { stamp("postinstall error: " + e); } catch {} }
|
package/bin/wkappbot-code.js
CHANGED
|
@@ -567,7 +567,9 @@ function doctor(o) {
|
|
|
567
567
|
if (!printed) why = " skill read on-load rc " + r.status;
|
|
568
568
|
rmSync(cwd, { recursive: true, force: true });
|
|
569
569
|
} else why = " (no core to read with)";
|
|
570
|
-
|
|
570
|
+
// Without a core (--no-bin, or win-x64 where no single core asset exists yet) the skills cannot be read back:
|
|
571
|
+
// that is a WARN about the missing core, not a FAIL of the skills that did install (SDK all-OS QA 2026-11-06).
|
|
572
|
+
add("skills", n > 0 && printed, n + " skills in " + hq + (printed ? "; wkappbot skill read on-load prints" : why), !!(st.skills && !st.skills.skipped) && !!core);
|
|
571
573
|
}
|
|
572
574
|
// push-gate: the global core.hooksPath runs the push-owner gate (directly, or through the global dispatcher).
|
|
573
575
|
const ghp = globalHooksPath() || "";
|
package/lib/wk-hook.js
CHANGED
|
@@ -109,7 +109,10 @@ export function runHook(arm, payload, opts = {}) {
|
|
|
109
109
|
const W = process.platform === "win32";
|
|
110
110
|
const sp = (p) => (W && /^[A-Za-z]:[\\/]/.test(p) ? "/" + p[0].toLowerCase() + p.slice(2).replace(/\\/g, "/") : p);
|
|
111
111
|
child = spawn("bash", [sp(hook), arm], {
|
|
112
|
-
|
|
112
|
+
// The plugin's harness wins: wkharness-run.sh prefers WKHARNESS_KIH_DIR over CLAUDE_PROJECT_DIR, so an ambient
|
|
113
|
+
// WKHARNESS_KIH_DIR (a dev seat's shell profile, a CI job) sent every arm to ANOTHER tree, whose lite and ledger
|
|
114
|
+
// then ran or did not run (SDK QA 2026-11-06: x8 null|null|null on Linux and macOS). Both point at kihDir.
|
|
115
|
+
env: { ...process.env, ...(W ? { HOME: sp(homedir()) } : {}), ...(kih ? { CLAUDE_PROJECT_DIR: sp(kih), WKHARNESS_KIH_DIR: sp(kih) } : {}) },
|
|
113
116
|
stdio: ["pipe", "pipe", "pipe"],
|
|
114
117
|
});
|
|
115
118
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wkappbot-code",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "wkappbot-code -- Wisdom Kernel: the pinned OpenCode bridge plus the reflex harness plugin, the wkappbot core, the web harness and the latest public skills in one install",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"postinstall": "node bin/postinstall.js"
|
|
8
|
+
},
|
|
6
9
|
"bin": {
|
|
7
10
|
"wkappbot-code": "bin/wkappbot-code.js",
|
|
8
11
|
"wk-appbot-code": "bin/wkappbot-code.js"
|