wkappbot-code 0.3.22 → 0.3.23

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 CHANGED
@@ -12,7 +12,7 @@ The plugin `plugin/wisdom-kernel.js` maps OpenCode plugin events onto the harnes
12
12
  |---|---|---|
13
13
  | `tool.execute.before` | `pre` | Claude-shaped PreToolUse JSON (`tool_name`, `tool_input`, `session_id`, `cwd`). Exit 2 throws, which refuses the tool call with the guard's own message as the reason. |
14
14
  | `tool.execute.after` | `post` | fail-open |
15
- | `chat.message` | `prompt` | UserPromptSubmit: the intent lock owes a skill search (`wkskill search ...`) before real work |
15
+ | `chat.message` | `prompt` | UserPromptSubmit: the intent lock owes a skill search (`wkappbot skill search ...`) before real work |
16
16
  | `event` `session.created` | `session` | SessionStart |
17
17
  | `event` `session.idle` | `stop-archive` | archive only, fail-open |
18
18
  | `experimental.chat.system.transform` | (none) | appends the reflex rules to the system prompt of EVERY model request, whatever the model (pinned to OpenCode 1.19.5; the e2e asserts every request carried them) |
@@ -57,7 +57,7 @@ The generated `opencode.json` holds the minimum: `$schema` and the plugin entry
57
57
 
58
58
  ## Uninstall
59
59
 
60
- `install` records, once, the machine state it changes: the global `core.hooksPath`, whether `~/.claude/settings.json`, `~/.wk-harness` and `~/.wk-harness-hooks` existed, and which shims it created (`wkappbot` beside the CLI, `wkskill` and `wk-verify` in `~/.local/bin`). `wkappbot-code uninstall` gives exactly that back: the recorded `core.hooksPath` (only when the current value is a hook folder the install wrote), the harness hook entries leave `settings.json` while yours stay (a file the install created is removed when nothing else is left), the recorded shims go, `~/.wk-harness` and `~/.wk-harness-hooks` go when the install created them, and the plugin entry leaves `opencode.json` (backed up first). It keeps `opencode-ai`, the core and its skills; `npm rm -g wkappbot-code` removes the CLI.
60
+ `install` records, once, the machine state it changes: the global `core.hooksPath`, whether `~/.claude/settings.json`, `~/.wk-harness` and `~/.wk-harness-hooks` existed, and which shims it created (`wkappbot` beside the CLI and `wk-verify` in `~/.local/bin`; no `wkskill` command exists, the skill command is `wkappbot skill`). `wkappbot-code uninstall` gives exactly that back: the recorded `core.hooksPath` (only when the current value is a hook folder the install wrote), the harness hook entries leave `settings.json` while yours stay (a file the install created is removed when nothing else is left), the recorded shims go, `~/.wk-harness` and `~/.wk-harness-hooks` go when the install created them, and the plugin entry leaves `opencode.json` (backed up first). It keeps `opencode-ai`, the core and its skills; `npm rm -g wkappbot-code` removes the CLI.
61
61
 
62
62
  ## Model swap
63
63
 
@@ -7,7 +7,7 @@
7
7
  // CONTRACT: (a) ALWAYS exits 0 and returns within a moment -- the real work runs DETACHED and logs to
8
8
  // ~/.wkappbot-code/postinstall.log; (b) the worker runs `wkappbot-code install` (lays the web harness, wires
9
9
  // ~/.claude/settings.json through the lite harness -- PreToolUse, Stop, UserPromptSubmit, SessionStart -- the global git
10
- // hooks, the wkskill/wk-verify shims and the public skills, keeping every user setting), then `wkappbot-code doctor`,
10
+ // hooks, the wk-verify shim and the public skills, keeping every user setting), then `wkappbot-code doctor`,
11
11
  // then a short self-test (lib/setup-run.js: core --version, skill read on-load, one hook allow, one hook refuse), and
12
12
  // writes ~/.wkappbot-code/postinstall.done {version, installRc, doctor:{pass,warn,fail,skip}, selftest:{n,m}, ...};
13
13
  // postinstall.running exists while the worker lives; (c) the first `wkappbot-code` run afterwards prints ONE summary
@@ -40,7 +40,7 @@ import {
40
40
  import { homedir, tmpdir } from "node:os";
41
41
  import { dirname, isAbsolute, join, relative, resolve } from "node:path";
42
42
  import { fileURLToPath, pathToFileURL } from "node:url";
43
- import { quietCheck, runUpdate, updateRow } from "../lib/update.js"; import { rmTreeHard } from "../lib/rmtree.js"; import { plainFileUrl } from "../lib/fileurl.js";
43
+ import { quietCheck, runUpdate, updateRow } from "../lib/update.js"; import { rmTreeHard } from "../lib/rmtree.js"; import { plainFileUrl } from "../lib/fileurl.js"; import { removeStaleWkskill } from "../lib/stale-wkskill.js";
44
44
  import { applySets, askEach, buildConfig, configRow, detect, lineDiff, printDetected } from "../lib/config.js";
45
45
  import { aiCliRows, installAiClis, removeAiClis } from "../lib/ai-clis.js";
46
46
  import { hooksRow, wireClaudeHooks } from "../lib/hook-wire.js";
@@ -400,7 +400,7 @@ function installPlugin(o, kih, kihSource) {
400
400
  // The machine state an uninstall must give back, recorded ONCE (a re-install never overwrites the first record, or
401
401
  // it would record our own dispatcher as the "prior" hooksPath). Shim paths are those install may create.
402
402
  function shimCandidates() {
403
- return [join(linkDir(), "wkappbot"), join(HARNESS_LINKS(), "wkskill"), join(HARNESS_LINKS(), "wk-verify"), join(HARNESS_LINKS(), "wkskill.cmd"), join(HARNESS_LINKS(), "wk-verify.cmd")]; // Windows (Git Bash) .cmd twins from harness-install.sh: recorded like the rest, so uninstall removes them, never a user file
403
+ return [join(linkDir(), "wkappbot"), join(HARNESS_LINKS(), "wk-verify"), join(HARNESS_LINKS(), "wk-verify.cmd")]; // Windows (Git Bash) .cmd twins from harness-install.sh: recorded like the rest, so uninstall removes them, never a user file
404
404
  }
405
405
  const PRE_SETTINGS = () => join(STATE_HOME(), "settings.pre-install.json");
406
406
  function recordPrior(prev) {
@@ -562,7 +562,7 @@ function uninstall(o) {
562
562
  }
563
563
  // 3b. the ~/.local/bin/wkappbot link: removed ONLY when it points at the core this install placed (the core file stays)
564
564
  const core = (st.bin && st.bin.dest) || binDest(o);
565
- removeStarterMd(st.starterMd, log);
565
+ removeStarterMd(st.starterMd, log); removeStaleWkskill(HARNESS_LINKS(), log); // an older harness install's counterfeit wkskill link (SDK e2e: local-bin=wkskill)
566
566
  let linkRemoved = "";
567
567
  for (const p of new Set(shimCandidates().concat([join(homedir(), ".local", "bin", "wkappbot")]))) {
568
568
  if (!isSymlink(p) || (st.shims || []).includes(p)) continue;
@@ -9,7 +9,6 @@ import { dirname } from "node:path";
9
9
  import { readSettings } from "./hook-wire.js";
10
10
 
11
11
  export const COMPACT_ALLOWS = [
12
- "Bash(wkskill *)", // skill read / search / like (the user's own store)
13
12
  "Bash(wkappbot skill *)", // the same through the core
14
13
  "Bash(wkappbot file read *)", // read-only file view
15
14
  "Bash(wk-verify)", // live hook check, no arguments
package/lib/hook-wire.js CHANGED
@@ -20,7 +20,10 @@ import { pickPython, stubWarning } from "./python-pick.js";
20
20
  // for harness hooks and deleted or rewrote them. Now a harness hook is a wkharness*.sh/.ps1/.cmd file name standing at a
21
21
  // path or word start, a file under a .wk-harness folder, the kih .claude/hooks scripts, or the two named sync hooks.
22
22
  const HARNESS_HOOK = /(^|[\s"'\\/])wkharness(-[\w-]+)?\.(sh|ps1|cmd)\b|\.wk-harness[\\/]|[\\/]\.claude[\\/]hooks[\\/](user-prompt-submit|session-start)\.sh\b|(^|[\s"'\\/])(wk-global-md-sync|wk-session-pull|wkappbot-shim)(\.[a-z0-9]+)?\b/;
23
- const ARMS = [["PreToolUse", "pre"], ["Stop", "stop"], ["UserPromptSubmit", "prompt"], ["SessionStart", "session"]];
23
+ // The history arms (owner 2026-11-12) push the reflex history like the repo hooks: PostToolUse only for the cross-session
24
+ // tools (a matcher, so no spawn per tool call), PreCompact, SessionEnd and StopFailure (a rate limit).
25
+ const ARMS = [["PreToolUse", "pre"], ["Stop", "stop"], ["UserPromptSubmit", "prompt"], ["SessionStart", "session"],
26
+ ["PostToolUse", "post", "mcp__claude-code-remote__send_message|ReadNotifications"], ["PreCompact", "precompact"], ["SessionEnd", "sessionend"], ["StopFailure", "stopfail"]];
24
27
  const fwd = (p) => String(p || "").replace(/\\/g, "/").replace(/\/+$/, "");
25
28
 
26
29
  export function readSettings(path) {
@@ -80,10 +83,10 @@ export function wireSettings(path, lite) {
80
83
  }
81
84
  if (keep.length) out[ev] = keep;
82
85
  }
83
- for (const [ev, arm] of ARMS) {
86
+ for (const [ev, arm, matcher] of ARMS) {
84
87
  const c = '"' + lite + '" ' + arm;
85
88
  if (!(out[ev] || []).some((g) => (g.hooks || []).some((h) => h.command === c)))
86
- (out[ev] = out[ev] || []).push({ hooks: [{ type: "command", command: c, timeout: 10 }] });
89
+ (out[ev] = out[ev] || []).push({ ...(matcher ? { matcher } : {}), hooks: [{ type: "command", command: c, timeout: 10 }] });
87
90
  }
88
91
  d.hooks = out;
89
92
  mkdirSync(dirname(path), { recursive: true });
@@ -0,0 +1,23 @@
1
+ // stale-wkskill.js -- uninstall also removes the counterfeit wkskill command an OLDER harness install left in the link dir
2
+ // (owner 2026-11-11: the fake wkskill is deleted; spokesman 2026-11-12: SDK e2e "after: local-bin=wkskill", RESULT 20/21 on every leg).
3
+ // A link or .cmd twin is removed ONLY while it still points into a harness (its target or body names wkharness or wk-harness);
4
+ // a wkskill file or link of the user's own stays. Spec: wkappbot skill read harness-installer-owns-all-setup
5
+ import { lstatSync, readFileSync, readlinkSync, rmSync } from "node:fs";
6
+ import { join } from "node:path";
7
+
8
+ const isHarness = (s) => /wkharness|wk-harness/.test(String(s || ""));
9
+
10
+ // -> the paths removed; log gets one line per candidate
11
+ export function removeStaleWkskill(dir, log = () => {}) {
12
+ const removed = [];
13
+ for (const n of ["wkskill", "wkskill.cmd"]) {
14
+ const p = join(dir, n);
15
+ let st;
16
+ try { st = lstatSync(p); } catch { continue; }
17
+ let body = "";
18
+ try { body = st.isSymbolicLink() ? readlinkSync(p) : readFileSync(p, "utf8"); } catch { /* unreadable: kept */ }
19
+ if (isHarness(body)) { rmSync(p, { force: true }); removed.push(p); log("shim: removed " + p + " (the counterfeit wkskill command an older harness install linked)"); }
20
+ else log("shim: kept " + p + " (not a harness link)");
21
+ }
22
+ return removed;
23
+ }
package/lib/wk-hook.js CHANGED
@@ -301,16 +301,16 @@ export function isFastRead(tool, input) {
301
301
  }
302
302
 
303
303
  // SHIM PATH (SDK ROOT C 2026-11-06, run 42289814533): OpenCode's bash tool runs /bin/zsh on macOS, whose default PATH
304
- // has no ~/.local/bin, so "zsh:1: command not found: wkskill" and a Mac user could never pay the intent lock. A bash call
305
- // that names wkskill or wk-verify gets the shim dir (WK_LINK_DIR, else ~/.local/bin, where harness install.sh links
304
+ // has no ~/.local/bin, so "zsh:1: command not found: wkappbot" and a Mac user could never pay the intent lock. A bash call
305
+ // that names wkappbot or wk-verify gets the shim dir (WK_LINK_DIR, else ~/.local/bin, where harness install.sh links
306
306
  // them) prepended to PATH for that one command; nothing else changes. Returns the command to run (unchanged when the
307
307
  // shim is absent or the command names neither shim).
308
308
  export function withShimPath(tool, args, linkDir) {
309
309
  if (claudeToolName(tool) !== "Bash" || !args || typeof args.command !== "string") return args && args.command;
310
310
  const c = args.command;
311
- if (!/(^|[\s;&|(`])(wkskill|wk-verify)(\s|$)/.test(c)) return c;
311
+ if (!/(^|[\s;&|(`])(wkappbot|wk-verify)(\s|$)/.test(c)) return c;
312
312
  const dir = linkDir || process.env.WK_LINK_DIR || join(homedir(), ".local", "bin");
313
- if (!existsSync(join(dir, "wkskill")) && !existsSync(join(dir, "wk-verify"))) return c;
313
+ if (!existsSync(join(dir, "wkappbot")) && !existsSync(join(dir, "wk-verify"))) return c;
314
314
  if (c.startsWith("PATH=")) return c;
315
315
  return "PATH=" + JSON.stringify(dir) + ':"$PATH"; export PATH; ' + c;
316
316
  }
@@ -323,10 +323,10 @@ export const RULES_MARK = "[wisdom-kernel rules]";
323
323
  export const RULES = [
324
324
  RULES_MARK + " You run under the Wisdom Kernel harness (wkappbot-code). On every turn:",
325
325
  "1. One command per shell call; never chain a write with anything else.",
326
- "2. A refusal names a skill: run wkskill read <id> (or wkappbot skill read <id>) and apply its remedy; never route around it.",
326
+ "2. A refusal names a skill: run wkappbot skill read <id> and apply its remedy; never route around it.",
327
327
  "3. Never use git --no-verify or git push --force, never change core.hooksPath, never rm -r a home directory, / or the project source.",
328
328
  "4. Never edit or delete files under .git.",
329
- "5. After a new user prompt, run wkskill search <three or more words> before the first write; read-only tools stay open.",
329
+ "5. After a new user prompt, run wkappbot skill search <three or more words> before the first write; read-only tools stay open.",
330
330
  ].join("\n");
331
331
 
332
332
  // The top step lines of the on-load skill, fetched ONCE per process (one OpenCode server = its sessions) in the
@@ -337,7 +337,7 @@ export function onLoadLines(kihDir) {
337
337
  if (_onload) return _onload;
338
338
  _onload = new Promise((res) => {
339
339
  const k = kihDir || resolveKihDir();
340
- const cands = [process.env.WK_APPBOT_SKILL_CMD, k && join(k, "bin", "wkskill"), "wkskill"].filter(Boolean);
340
+ const cands = [process.env.WK_APPBOT_SKILL_CMD, k && join(k, "bin", "wkappbot"), "wkappbot"].filter(Boolean);
341
341
  let out = "", done = false;
342
342
  const finish = () => {
343
343
  if (done) return; done = true;
@@ -347,9 +347,9 @@ export function onLoadLines(kihDir) {
347
347
  res(lines.slice(0, 3).map((l) => l.slice(0, 240)));
348
348
  };
349
349
  try {
350
- const target = cands.find((p) => p === "wkskill" || existsSync(p)), opt = { stdio: ["ignore", "pipe", "ignore"] };
351
- // Windows: a shell-less spawn cannot run a .cmd shim, the bare wkskill name (PATHEXT) or an extensionless sh script
352
- const c = process.platform !== "win32" ? spawn(target, ["read", "on-load"], opt) : /\.exe$/i.test(target) ? spawn(target, ["read", "on-load"], opt) : /\.(cmd|bat)$/i.test(target) || target === "wkskill" ? spawn(target, ["read", "on-load"], { ...opt, shell: true }) : spawn("sh", [target.replace(/\\/g, "/"), "read", "on-load"], opt);
350
+ const target = cands.find((p) => p === "wkappbot" || existsSync(p)), opt = { stdio: ["ignore", "pipe", "ignore"] };
351
+ // Windows: a shell-less spawn cannot run a .cmd shim, the bare wkappbot name (PATHEXT) or an extensionless sh script
352
+ const c = process.platform !== "win32" ? spawn(target, ["skill", "read", "on-load"], opt) : /\.exe$/i.test(target) ? spawn(target, ["skill", "read", "on-load"], opt) : /\.(cmd|bat)$/i.test(target) || target === "wkappbot" ? spawn(target, ["skill", "read", "on-load"], { ...opt, shell: true }) : spawn("sh", [target.replace(/\\/g, "/"), "skill", "read", "on-load"], opt);
353
353
  c.stdout.on("data", (d) => { out += d; if (out.length > 65536) c.kill("SIGKILL"); });
354
354
  c.on("error", finish); c.on("close", finish);
355
355
  setTimeout(() => { try { c.kill("SIGKILL"); } catch {} finish(); }, 8000).unref();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wkappbot-code",
3
- "version": "0.3.22",
3
+ "version": "0.3.23",
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
6
  "scripts": {
@@ -51,7 +51,7 @@ export const WisdomKernel = async (ctx = {}, options = {}) => {
51
51
  (tail ? ": " + tail : "") + ". Fix the harness (wkappbot-code doctor) and retry.");
52
52
  }
53
53
  }
54
- // macOS /bin/zsh has no ~/.local/bin on PATH: a wkskill call gets the shim dir for that one command (lib/wk-hook.js).
54
+ // macOS /bin/zsh has no ~/.local/bin on PATH: a wkappbot call gets the shim dir for that one command (lib/wk-hook.js).
55
55
  try { if (args && typeof args.command === "string") args.command = H.withShimPath(inp.tool, args); } catch {}
56
56
  },
57
57
  "tool.execute.after": async (input, output) => {
@@ -5,7 +5,7 @@ change it, install never touches it again, and `wkappbot-code uninstall` leaves
5
5
 
6
6
  ## How to work
7
7
  - Reply in the language the user writes in. Keep replies short and concrete; lead with the result.
8
- - Before real work, find the skill that governs it: `wkskill search <three or more words>`, then `wkskill read <id>`,
8
+ - Before real work, find the skill that governs it: `wkappbot skill search <three or more words>`, then `wkappbot skill read <id>`,
9
9
  and follow the road it gives. Search again for any term you are not sure of, instead of guessing.
10
10
  - Run, do not guess: prove a change by running its test or command, and report the real output, failures included.
11
11
  - One command per tool call. Change only what the task needs, and back up a config file before you edit it.