@misaka-net/misakanet-setup 0.4.0 → 0.4.1
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 +3 -1
- package/bin/misakanet-setup.mjs +50 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ npx @misaka-net/misakanet-setup
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Then **close and reopen the assistant window** (the new MCP server loads on restart) and ask
|
|
12
|
-
something with an error in it, e.g. "
|
|
12
|
+
something with an error in it, e.g. "pip install timeout 是什么原因" — it should search the
|
|
13
13
|
knowledge base on its own instead of guessing.
|
|
14
14
|
|
|
15
15
|
## What it installs, and why all three
|
|
@@ -31,6 +31,8 @@ npx @misaka-net/misakanet-setup --verify # READY / NOT READY, installed ver
|
|
|
31
31
|
npx @misaka-net/misakanet-setup --only claude # one agent only
|
|
32
32
|
npx @misaka-net/misakanet-setup --no-register # read-only, no anonymous token
|
|
33
33
|
npx @misaka-net/misakanet-setup --upgrade # same as installing the latest (the command is idempotent)
|
|
34
|
+
# re-running also *refreshes* an older hook (the previous copy
|
|
35
|
+
# is kept as ~/.misakanet-agent/hook.mjs.misakanet.bak)
|
|
34
36
|
npx @misaka-net/misakanet-setup --uninstall # remove exactly what it added
|
|
35
37
|
```
|
|
36
38
|
|
package/bin/misakanet-setup.mjs
CHANGED
|
@@ -103,7 +103,7 @@ function readText(path) {
|
|
|
103
103
|
* meant to prevent is now caught in CI instead, by a test that binds this literal to the
|
|
104
104
|
* manifest — a failing test is a better place for that than a request header.
|
|
105
105
|
*/
|
|
106
|
-
const VERSION = '0.4.
|
|
106
|
+
const VERSION = '0.4.1';
|
|
107
107
|
|
|
108
108
|
function backup(path) {
|
|
109
109
|
if (DRY || !readText(path)) return;
|
|
@@ -252,23 +252,44 @@ function locateHook() {
|
|
|
252
252
|
|
|
253
253
|
async function installHook() {
|
|
254
254
|
const hookPath = join(stateDir(), 'hook.mjs');
|
|
255
|
+
const bundled = locateHook();
|
|
256
|
+
let existing = null;
|
|
255
257
|
try {
|
|
256
|
-
|
|
258
|
+
existing = readFileSync(hookPath, 'utf8');
|
|
259
|
+
} catch { /* not installed yet */ }
|
|
260
|
+
const isOurs = existing !== null && existing.includes('MisakaNet');
|
|
261
|
+
|
|
262
|
+
if (!bundled) {
|
|
263
|
+
if (isOurs) {
|
|
257
264
|
ok(`自动沉淀的钩子已存在:${hookPath}`);
|
|
258
265
|
return hookPath;
|
|
259
266
|
}
|
|
260
|
-
} catch { /* not installed yet */ }
|
|
261
|
-
const bundled = locateHook();
|
|
262
|
-
if (!bundled) {
|
|
263
267
|
need('自动沉淀那部分装不上:这个 npm 包里没有带钩子文件(安装不完整)→ '
|
|
264
268
|
+ '重新执行 npx 安装即可;其它功能不受影响');
|
|
265
269
|
return null;
|
|
266
270
|
}
|
|
271
|
+
|
|
272
|
+
if (isOurs && existing.trim() === bundled.trim()) {
|
|
273
|
+
ok(`自动沉淀的钩子已是最新:${hookPath}`);
|
|
274
|
+
return hookPath;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Refresh a hook that is *ours* (marker) but older than the bundled copy, keeping the
|
|
278
|
+
// previous file beside it.
|
|
279
|
+
//
|
|
280
|
+
// This used to return early for any hook containing "MisakaNet", which made a hook fix
|
|
281
|
+
// unable to reach an existing install: the 14-day upgrade nudge (#1712) could not
|
|
282
|
+
// arrive, and re-running the installer — the very thing the nudge asks the user to do —
|
|
283
|
+
// changed nothing (found 2026-09-15: the machine's installed hook predated the nudge
|
|
284
|
+
// while `npx …@latest` reported success).
|
|
267
285
|
if (!DRY) {
|
|
268
286
|
mkdirSync(stateDir(), { recursive: true });
|
|
287
|
+
if (existing !== null) backup(hookPath);
|
|
269
288
|
writeFileSync(hookPath, bundled);
|
|
270
289
|
}
|
|
271
|
-
ok(
|
|
290
|
+
ok(isOurs
|
|
291
|
+
? `自动沉淀的钩子已更新(旧版备份为 ${hookPath}.misakanet.bak)→ ${hookPath}`
|
|
292
|
+
: `安装自动沉淀钩子 → ${hookPath}`);
|
|
272
293
|
return hookPath;
|
|
273
294
|
}
|
|
274
295
|
|
|
@@ -447,11 +468,30 @@ async function installCodex(hookPath, bearer) {
|
|
|
447
468
|
|
|
448
469
|
const rules = join(HOME, '.codex', 'AGENTS.md');
|
|
449
470
|
ok(`Codex:规则块 ${injectBlock(rules, PROMPT_BLOCK)} → ${rules}`);
|
|
450
|
-
|
|
451
|
-
|
|
471
|
+
// Verified on codex-cli 0.154.0 (2026-09-15), so this is no longer a "could not
|
|
472
|
+
// confirm" note: `codex mcp list` shows misakanet enabled with the Bearer token,
|
|
473
|
+
// `codex doctor` reports config.toml parse ok + 1 streamable_http server + 0
|
|
474
|
+
// disabled, and `codex debug prompt-input` renders a `# AGENTS.md instructions`
|
|
475
|
+
// item carrying this rule block. What stays open is the *hook*: 0.154.0's lifecycle
|
|
476
|
+
// hooks are admin-managed (requirements.toml), so the round-20 distillation is
|
|
477
|
+
// rule-driven rather than hook-driven.
|
|
478
|
+
ok('Codex:注册已核对(`codex mcp list` / `codex doctor` / `codex debug prompt-input`)');
|
|
479
|
+
need('Codex:没有用户级 lifecycle hook → "第 20 轮自动沉淀"靠规则块自律;'
|
|
480
|
+
+ '要硬保证就配外层 wrapper 每轮后跑 checkpoint_reminder');
|
|
452
481
|
}
|
|
453
482
|
|
|
454
483
|
const STATE_VERSION_FILE = 'version';
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* The question the onboarding text tells a user to ask — and the reason it is a constant.
|
|
487
|
+
*
|
|
488
|
+
* It used to be "docker exit code 137 是什么原因", which the corpus answers with three only
|
|
489
|
+
* loosely-related lessons (top hit: kubernetes-crashloopbackoff-debugging) — so a new user's
|
|
490
|
+
* first question, the one we chose for them, landed on a near-miss. It is now a query whose top
|
|
491
|
+
* hit is a lesson about that very failure, and tests/test_onboarding_example.py keeps it that
|
|
492
|
+
* way offline (plus a check that this literal is not duplicated back into the messages).
|
|
493
|
+
*/
|
|
494
|
+
const ONBOARDING_QUERY = 'pip install timeout';
|
|
455
495
|
const REGISTRY_LATEST = process.env.MISAKANET_REGISTRY_URL
|
|
456
496
|
|| 'https://registry.npmjs.org/@misaka-net%2fmisakanet-setup/latest';
|
|
457
497
|
|
|
@@ -913,7 +953,7 @@ if (mode === 'uninstall') {
|
|
|
913
953
|
if (mode === 'verify') {
|
|
914
954
|
const allOk = await verify();
|
|
915
955
|
console.log(render());
|
|
916
|
-
console.log(`\n结论:${allOk ?
|
|
956
|
+
console.log(`\n结论:${allOk ? `READY —— 打开一个新会话,问它「${ONBOARDING_QUERY} 是什么原因」` : 'NOT READY —— 上面每条 ! 都给了修复动作'}`);
|
|
917
957
|
process.exit(allOk ? 0 : 1);
|
|
918
958
|
}
|
|
919
959
|
|
|
@@ -941,6 +981,6 @@ console.log(render());
|
|
|
941
981
|
console.log(`
|
|
942
982
|
接下来:
|
|
943
983
|
1) **把这个助手窗口关掉再打开一次**(新功能要重开会话才生效)
|
|
944
|
-
2)
|
|
984
|
+
2) 随便问一句带报错的:「${ONBOARDING_QUERY} 是什么原因」——它应该先去查经验库
|
|
945
985
|
3) 想确认状态:npx @misaka-net/misakanet-setup --verify
|
|
946
986
|
4) 想关掉:npx @misaka-net/misakanet-setup --uninstall`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@misaka-net/misakanet-setup",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "One-command setup: teach your Claude Code / Codex / Hermes / OpenClaw to search MisakaNet failure lessons before repeating a mistake, and to distil the session at a checkpoint.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"misakanet-setup": "bin/misakanet-setup.mjs"
|