@jjh32456/dsh-longlive 1.6.7 → 1.8.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/CHANGELOG.md +70 -1508
- package/LICENSE +1 -1
- package/QUICKSTART.md +34 -13
- package/README.en.md +18 -7
- package/README.md +34 -9
- package/SPEC.md +5 -5
- package/cordis.patch.yml +23 -9
- package/docs/ANSWER-GUARD.md +92 -0
- package/docs/ARCHITECTURE.md +4 -3
- package/docs/AUTO-RECALL-WIRING.md +1 -1
- package/docs/AUTO-RECALL.md +15 -9
- package/docs/CONFIG.md +168 -35
- package/docs/ERRORS.md +17 -5
- package/docs/FAQ.md +7 -7
- package/docs/FEATURES.md +96 -28
- package/docs/MIGRATION-1.6.0.md +2 -2
- package/docs/OPERATIONS.md +6 -6
- package/docs/PANEL-INTEGRATION.md +6 -0
- package/docs/PRIVACY.md +88 -0
- package/docs/QUICKSTART.md +5 -5
- package/docs/README.en.md +4 -2
- package/docs/RESIDENT-WATCHER.md +1 -1
- package/docs/SESSION-WATCH.md +6 -6
- package/docs/TROUBLESHOOTING.md +4 -4
- package/package.json +47 -117
- package/runbook.md +2 -2
- package/scripts/backfill-auto-cards.mjs +98 -0
- package/scripts/install-surgery-task.ps1 +5 -2
- package/scripts/lib/session-watch-fixture.mjs +1 -1
- package/scripts/longlive-doctor.mjs +6 -0
- package/scripts/migrate-180.mjs +163 -0
- package/scripts/recall-index-build.mjs +128 -0
- package/scripts/session-watch-drill.mjs +1 -1
- package/scripts/surgery-run.cmd +1 -1
- package/scripts/unattended-surgery.ps1 +5 -2
- package/scripts/verify-card-anchors.mjs +138 -0
- package/src/actions/audit.js +125 -0
- package/src/actions/evidence.js +122 -0
- package/src/actions/fs.js +162 -0
- package/src/activity/index.js +760 -0
- package/src/activity/model.js +351 -0
- package/src/activity/store.js +644 -0
- package/src/activity/thinking.js +176 -0
- package/src/adapters/constants.js +11 -0
- package/src/adapters/engram/data/aliases.json +51 -0
- package/src/adapters/engram/data/policy.json +8 -0
- package/src/adapters/engram/data/routing-rules.json +546 -0
- package/src/adapters/engram/index.js +235 -0
- package/src/adapters/registry.js +315 -0
- package/src/answer/audit.js +193 -0
- package/src/answer/evidence.js +30 -0
- package/src/answer/guard.js +1370 -0
- package/src/answer/index.js +1067 -0
- package/src/answer/query.js +111 -0
- package/src/answer/second-hop.mjs +101 -0
- package/src/auto-truncate.js +1 -1
- package/src/config.js +171 -47
- package/src/deps.js +6 -4
- package/src/features.js +182 -6
- package/src/heartbeat.js +156 -23
- package/src/identity/handover.js +52 -1
- package/src/identity/index.js +13 -5
- package/src/identity/inject-position.js +2 -2
- package/src/index.js +97 -7
- package/src/lifecycle/gap-clocks.js +328 -0
- package/src/lifecycle/index.js +269 -0
- package/src/live.js +22 -2
- package/src/memory/activity-capture.js +229 -0
- package/src/memory/anchors.js +194 -0
- package/src/memory/audit-records.js +222 -0
- package/src/memory/auto-cards.js +401 -0
- package/src/memory/capture.js +442 -0
- package/src/memory/card-anchors.js +203 -0
- package/src/memory/conflicts.js +106 -0
- package/src/memory/decay.js +311 -0
- package/src/memory/distill.js +471 -0
- package/src/memory/event-index.js +917 -0
- package/src/memory/evidence-chain.js +295 -0
- package/src/memory/evidence.js +145 -0
- package/src/memory/filter-runner.js +1 -1
- package/src/memory/filter.js +5 -1
- package/src/memory/forget-v2.js +410 -0
- package/src/memory/forget.js +71 -0
- package/src/memory/frames-activation.js +247 -0
- package/src/memory/fts-query.js +174 -0
- package/src/memory/governance.js +604 -0
- package/src/memory/index.js +1 -0
- package/src/memory/l2-gate.js +169 -0
- package/src/memory/lock.js +121 -0
- package/src/memory/migrate.js +139 -0
- package/src/memory/recall-v2.js +223 -0
- package/src/memory/recall.js +65 -2
- package/src/memory/records.js +425 -0
- package/src/memory/retention.js +128 -0
- package/src/memory/review.js +124 -0
- package/src/memory/trust.js +88 -0
- package/src/memory/version-chain.js +264 -0
- package/src/memory/wal.js +137 -0
- package/src/memory/working-frame.js +516 -0
- package/src/metrics/classify.mjs +5 -3
- package/src/metrics/index.mjs +21 -1
- package/src/metrics/prestep-latency.mjs +300 -0
- package/src/metrics/store.mjs +25 -0
- package/src/policy-profile.js +18 -3
- package/src/recall/anaphora.mjs +87 -0
- package/src/recall/cards.mjs +7 -0
- package/src/recall/embedding.mjs +8 -8
- package/src/recall/entities.mjs +112 -0
- package/src/recall/index.js +235 -19
- package/src/recall/inject-order.mjs +10 -8
- package/src/recall/privacy.mjs +105 -16
- package/src/recall/recall-core.mjs +116 -10
- package/src/recall/shared-visibility.js +302 -0
- package/src/recall/time-normalizer.mjs +196 -0
- package/src/role/activation.js +191 -0
- package/src/role/attention.js +318 -0
- package/src/role/base.js +36 -0
- package/src/role/channels.js +423 -0
- package/src/role/index.js +425 -0
- package/src/role/interfaces.js +115 -0
- package/src/role/personality.js +370 -0
- package/src/role/readers.js +151 -0
- package/src/role/relationships.js +477 -0
- package/src/role/store.js +202 -0
- package/src/role/writeprotect.js +373 -0
- package/src/router/aliases.json +176 -25
- package/src/router/background/agent-runner.mjs +1 -1
- package/src/router/background/anchor.mjs +1 -1
- package/src/router/background/audit.mjs +2 -2
- package/src/router/background/budget-ledger.mjs +2 -2
- package/src/router/background/host-sim.mjs +1 -1
- package/src/router/background/memory.mjs +4 -4
- package/src/router/background/queue.mjs +1 -1
- package/src/router/background/retry.mjs +1 -1
- package/src/router/background/router.mjs +1 -1
- package/src/router/background/stream.mjs +1 -1
- package/src/router/background/tool-policy.mjs +1 -1
- package/src/router/design-headings.json +5 -5
- package/src/router/face/config.mjs +1 -1
- package/src/router/face/identity.mjs +3 -3
- package/src/router/judge.mjs +8 -7
- package/src/router/policies/generic.json +21 -4
- package/src/router/route.js +109 -22
- package/src/router/router.mjs +10 -6
- package/src/router/routing-rules.json +260 -445
- package/src/router/run-sim.mjs +8 -8
- package/src/router/runtime.js +23 -12
- package/src/router/service/board.mjs +95 -15
- package/src/router/service/config.mjs +5 -5
- package/src/router/service/context.mjs +1 -1
- package/src/router/service/hint.mjs +14 -0
- package/src/router/service/queue.mjs +1 -1
- package/src/router/service/service.mjs +27 -11
- package/src/router/shadow.mjs +4 -3
- package/src/surgery-recovery.js +2 -2
- package/src/tool-output.js +2 -2
- package/src/tools.js +39 -7
- package/src/truncate-visible.js +2 -2
- package/src/ui/actions.js +1312 -0
- package/src/ui/panel-api.js +367 -0
- package/src/ui/panel-auth.js +251 -0
- package/src/ui/panel-integrity.js +243 -0
- package/src/ui/routes-readonly.js +695 -0
- package/src/ui/routes.js +3 -0
- package/docs/DEV.md +0 -279
- package/docs/PRESENCE-BUS-WIRING.md +0 -491
- package/docs/PRESENCE-BUS.md +0 -694
- package/docs/SURGERY.md +0 -186
- package/scripts/mark-core-cards.mjs +0 -289
- package/scripts/pack.mjs +0 -392
- package/scripts/router-proposals.mjs +0 -386
- package/src/router/fixtures/M1.json +0 -16
- package/src/router/fixtures/M2.json +0 -16
- package/src/router/fixtures/M3.json +0 -20
- package/src/router/fixtures/M4.json +0 -20
- package/src/router/fixtures/M5.json +0 -45
- package/src/router/fixtures/M6.json +0 -53
- package/src/router/fixtures/M7.json +0 -46
- package/src/router/fixtures/S1.json +0 -20
- package/src/router/fixtures/S2.json +0 -23
- package/src/router/fixtures/S3.json +0 -20
- package/src/router/fixtures/S4.json +0 -34
- package/src/router/fixtures/S5.json +0 -43
- package/src/router/fixtures/S6.json +0 -47
- package/src/router/fixtures/T1.json +0 -23
- package/src/router/fixtures/T2.json +0 -16
- package/src/router/fixtures/T3.json +0 -19
- package/src/router/fixtures/T4.json +0 -16
- package/src/router/fixtures/X1.json +0 -17
- package/src/router/fixtures/X2.json +0 -20
- package/src/router/gen-design-headings.mjs +0 -107
- package/src/router/policies/owner-rulings-2026-11-03.json +0 -62
- package/test/auto-recall.test.mjs +0 -474
- package/test/auto-truncate.test.mjs +0 -931
- package/test/autobind.test.mjs +0 -385
- package/test/bus.test.mjs +0 -1572
- package/test/cli-guard.test.mjs +0 -198
- package/test/conclusion.test.mjs +0 -408
- package/test/config-schema.test.mjs +0 -204
- package/test/d6-output.test.mjs +0 -194
- package/test/d6.test.mjs +0 -395
- package/test/deps.test.mjs +0 -342
- package/test/doctor-setup.test.mjs +0 -297
- package/test/embedding-recall.test.mjs +0 -347
- package/test/feature-flags.test.mjs +0 -568
- package/test/filter-shadow.test.mjs +0 -170
- package/test/fixtures/baseline-0.8.0-registration.json +0 -556
- package/test/fixtures/d6-header-tools.json +0 -1
- package/test/fixtures/lock-child.mjs +0 -67
- package/test/fixtures/pre-step-container.mjs +0 -100
- package/test/fixtures/privacy-memory/topics/pii-unmarked.md +0 -9
- package/test/fixtures/privacy-memory/topics/secret-local-only.md +0 -11
- package/test/fixtures/profile-session-longlive-config.json +0 -20
- package/test/fixtures/proposal-cas-child.mjs +0 -66
- package/test/host-engine-status.test.mjs +0 -307
- package/test/hot-truncate.test.mjs +0 -1349
- package/test/identity-card-marker.test.mjs +0 -307
- package/test/identity-router/run.mjs +0 -721
- package/test/integration-pre-step.test.mjs +0 -553
- package/test/live.test.mjs +0 -1020
- package/test/maintenance-schedule.test.mjs +0 -538
- package/test/memory.test.mjs +0 -2828
- package/test/metrics.test.mjs +0 -478
- package/test/orchestrator.test.mjs +0 -266
- package/test/p1_probe.mjs +0 -97
- package/test/packaging.test.mjs +0 -182
- package/test/portability.test.mjs +0 -343
- package/test/rc4-regressions.test.mjs +0 -562
- package/test/rc5-regressions.test.mjs +0 -197
- package/test/rc6-chinese.test.mjs +0 -394
- package/test/router-1100/apply-off.test.mjs +0 -175
- package/test/router-1100/budget-reconcile.test.mjs +0 -215
- package/test/router-1100/config-context.test.mjs +0 -211
- package/test/router-1100/helpers.mjs +0 -129
- package/test/router-1100/hint-envelope.test.mjs +0 -150
- package/test/router-1100/lock-crossproc.test.mjs +0 -206
- package/test/router-1100/proposal-cas-crossproc.test.mjs +0 -184
- package/test/router-1100/router-apply.test.mjs +0 -372
- package/test/router-1100/router-fixb.test.mjs +0 -602
- package/test/router-1100/router-proposals.test.mjs +0 -405
- package/test/router-1100/router-queue-lease-wal.test.mjs +0 -355
- package/test/router-1100/router-security-cr.test.mjs +0 -333
- package/test/router-1100/service-lifecycle.test.mjs +0 -220
- package/test/router-1100/tools-contract.test.mjs +0 -164
- package/test/router-1100/turn-reflect-tick.test.mjs +0 -89
- package/test/router-1100/v6-contract.test.mjs +0 -158
- package/test/router-1100/v6b-contract.test.mjs +0 -293
- package/test/router-1100/v6c-contract.test.mjs +0 -249
- package/test/router-1100/wal-rotation.test.mjs +0 -375
- package/test/router-1100/wp1-config.test.mjs +0 -170
- package/test/router-1100/wp1-default-off.test.mjs +0 -77
- package/test/router-1100/wp1-model-status.test.mjs +0 -90
- package/test/router-1100/wp1-status.test.mjs +0 -220
- package/test/router-1100/wp1-tools.test.mjs +0 -146
- package/test/router-1100/wp5-cli.test.mjs +0 -240
- package/test/router-1100/wp5-model-auto.test.mjs +0 -418
- package/test/router-1100/wp6-merge.test.mjs +0 -386
- package/test/router-1100/wp6-wake.test.mjs +0 -502
- package/test/router-background/audit.test.mjs +0 -37
- package/test/router-background/budget-ledger.test.mjs +0 -330
- package/test/router-background/cross-process.test.mjs +0 -222
- package/test/router-background/fixtures/cross-child.mjs +0 -85
- package/test/router-background/fixtures/real-shapes.mjs +0 -239
- package/test/router-background/router.test.mjs +0 -1044
- package/test/router-background/stream-retry.test.mjs +0 -358
- package/test/router-background/tool-agent.test.mjs +0 -384
- package/test/router-face/bridge.test.mjs +0 -169
- package/test/router-face/face.test.mjs +0 -316
- package/test/router-failclosed.test.mjs +0 -466
- package/test/router-identity.test.mjs +0 -384
- package/test/router-l1-l2.contract.test.mjs +0 -1075
- package/test/router-memory-tools.test.mjs +0 -262
- package/test/router-policy.test.mjs +0 -225
- package/test/router-runtime.test.mjs +0 -438
- package/test/router-shadow.test.mjs +0 -287
- package/test/router.test.mjs +0 -903
- package/test/run-rc.mjs +0 -299
- package/test/run.mjs +0 -2469
- package/test/safety-defaults.test.mjs +0 -179
- package/test/seeded-load.test.mjs +0 -436
- package/test/session-original.test.mjs +0 -338
- package/test/surgery-recovery.test.mjs +0 -936
- package/test/t7_drive.mjs +0 -151
- package/test/tool-output.test.mjs +0 -393
- package/test/tool-schema.test.mjs +0 -177
- package/test/tools_contract.test.mjs +0 -716
- package/test/truncate-visible.test.mjs +0 -1150
- package/test/ui-flags.test.mjs +0 -477
- package/test/v4-hardening.test.mjs +0 -427
package/docs/SURGERY.md
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
# 无人值守手术(unattended surgery)
|
|
2
|
-
|
|
3
|
-
> 面向维护者。用户视角的「怎么办」在 `docs/OPERATIONS.md` §10。
|
|
4
|
-
|
|
5
|
-
## 1. 组成
|
|
6
|
-
|
|
7
|
-
| 文件 | 作用 |
|
|
8
|
-
|---|---|
|
|
9
|
-
| `scripts/unattended-surgery.ps1` | 真正的执行器:延迟 → 关宿主 → 快照 → 备份 → 调 CLI 剪 → 独立读回 → 重启 → 写回执 |
|
|
10
|
-
| `scripts/install-surgery-task.ps1` | 注册一次性计划任务(`-WindowStyle Hidden`)并启动 |
|
|
11
|
-
| `scripts/surgery-run.cmd` | 双击/命令行入口,转发参数给 installer |
|
|
12
|
-
| `scripts/surgery-inspect.mjs` | 只读检查会话(bytes/sha256/events/messages);`--write-receipt` 是唯一的写入模式 |
|
|
13
|
-
| `src/surgery-recovery.js` | 插件启动时的只读恢复自检、回执文本、CLI 查询实现 |
|
|
14
|
-
|
|
15
|
-
设计前提:**执行器随时可能被杀**(用户点 ×、断电、任务被结束)。因此所有进度先落
|
|
16
|
-
`<memoryRoot>/.longlive/surgery-state.json`,再执行下一步;下一次启动只读它,不自动重剪。
|
|
17
|
-
|
|
18
|
-
## 2. 阶段与原子性
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
prepare ──► backup ──► cut ──► restart ──► done
|
|
22
|
-
│ │ │ │
|
|
23
|
-
│ │ │ └──► receipt-pending(回执没写成,宿主已起来)
|
|
24
|
-
│ │ └───────────► needs-attention(CLI exit 0,但独立读回核不通过)
|
|
25
|
-
└───────────┴─────────────────────► failed
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
`needs-attention` 是 rc.6 新增的**非终态失败**:执行器退出码 7,`result.ok=false`,state 里
|
|
29
|
-
`cut.outcome="unverified"`、`needsAttention.code="E_CUT_UNVERIFIED"`;会话不回滚,也**不写回执**,
|
|
30
|
-
留给下一次启动的恢复自检去报告——绝不在这里假装成功。
|
|
31
|
-
|
|
32
|
-
每次转换都:写 `state.tmp-<pid>` → `Move-Item -Force` 覆盖 → 读回并校验 `phase`。
|
|
33
|
-
`history[]` 每次追加 `{phase, at}`,所以被 kill 时能看出最后走到了哪一步。
|
|
34
|
-
|
|
35
|
-
关键顺序(1.1.0 定死;不要再把两个默认值写反):
|
|
36
|
-
|
|
37
|
-
1. `prepare`:记录 sessionPath、参数、pid、pluginVersion,以及 `startDelaySeconds: 30`
|
|
38
|
-
和 `restartDelaySeconds: 0`。
|
|
39
|
-
2. **等 `StartDelaySeconds`(默认 30 秒)**:这是刻意留的阅读窗口,让人看完最后一屏再关
|
|
40
|
-
宿主;它不是为了等宿主空闲。改这个值要说明理由。
|
|
41
|
-
3. 硬关宿主(`Stop-Process -Force`),等进程清零 + 800ms。
|
|
42
|
-
4. **关宿主之后**才快照 `before`、复制备份:不会备份到写了一半的文件。
|
|
43
|
-
5. `backup`:`<session>.pre-surgery-<stamp>`,复制后 `Get-FileHash` 与 `before.sha256` 比对。
|
|
44
|
-
6. `cut`:**先写 phase=cut,再调 CLI**。这样 CLI 中途被杀时,恢复能看到 `cut`。
|
|
45
|
-
7. CLI 成功后用 `surgery-inspect.mjs` 独立读回,sha/events/messages 必须与 CLI 的 `after` 一致。
|
|
46
|
-
**rc.6(R4-03)**:CLI exit=0 但 stdout 一行 JSON 都解析不出来(GBK 控制台把 UTF-8 解坏)时,
|
|
47
|
-
不判 `failed`;先做独立核验(会话可读、sha 与磁盘一致、sha 已变、事件/消息下降、备份在且
|
|
48
|
-
等于 `before`)。核验通过 → `cut.outcome="applied-unparsed"`、`verify.method=
|
|
49
|
-
"independent-readback-unparsed"`,继续写回执并 `phase=done`;核验不通过 → `needs-attention`
|
|
50
|
-
(exit 7,见上)。CLI 非 0 退出、或解析成功但 `ok:false`,仍按 `failed` 处理。原始 stdout
|
|
51
|
-
会以 UTF-8 落盘到 `.longlive/logs/node-cut-<surgeryId>-<rand>.utf8.txt` 供事后核对。
|
|
52
|
-
8. **写回执**:读回通过后立刻 `surgery-inspect.mjs --write-receipt`,把结果、数字和备份路径
|
|
53
|
-
作为一条可见 `user/message` 追加进会话正文,并把 `receipt.after` 记进 state(见 §7)。
|
|
54
|
-
`applied-unparsed` 路径同样写,回执正文会多一行说明「CLI 输出编码异常,独立读回核验通过」。
|
|
55
|
-
9. `restart`:`Start-Process <AppPath>`,最多等 60 秒,记录 pid 列表。默认
|
|
56
|
-
`RestartDelaySeconds = 0`——校验和回执落盘后立刻重启,不 sleep。
|
|
57
|
-
10. `done`:`outcome = applied-and-verified | applied-unparsed | noop | dry-run`,`resultPath`
|
|
58
|
-
指向结果 JSON。
|
|
59
|
-
|
|
60
|
-
失败路径一律先尝试把宿主拉起来,再写 `failed` 和结果 JSON;退出码:
|
|
61
|
-
|
|
62
|
-
| 码 | 含义 |
|
|
63
|
-
|---|---|
|
|
64
|
-
| 0 | done(含 dry-run / noop) |
|
|
65
|
-
| 2 | 参数错误;或会话不可读 |
|
|
66
|
-
| 3 | 宿主没停下来 |
|
|
67
|
-
| 4 | 备份失败 / CLI 失败(未剪切或剪切失败) |
|
|
68
|
-
| 5 | 读回校验失败(磁盘与 CLI 的 after 不一致) |
|
|
69
|
-
| 6 | 重启后 60 秒内没看到宿主进程 |
|
|
70
|
-
| 7 | CLI exit 0 但输出不可解析,且独立核验不通过 → `needs-attention` |
|
|
71
|
-
| 1 | 未预期异常 |
|
|
72
|
-
|
|
73
|
-
## 3. state 形状(version 1)
|
|
74
|
-
|
|
75
|
-
```json
|
|
76
|
-
{
|
|
77
|
-
"version": 1,
|
|
78
|
-
"kind": "longlive-surgery",
|
|
79
|
-
"surgeryId": "20261104-143426-884",
|
|
80
|
-
"phase": "cut",
|
|
81
|
-
"pid": 8316,
|
|
82
|
-
"sessionPath": "<sessions-root>/<session>/session.v4.jsonl.zstd",
|
|
83
|
-
"sessionId": "session-e219dedf-...",
|
|
84
|
-
"memoryRoot": "<memory-root>",
|
|
85
|
-
"appPath": "<app-dir>/DeepSeek Harness.exe",
|
|
86
|
-
"keepTurns": 6,
|
|
87
|
-
"keepTokens": 40000,
|
|
88
|
-
"startDelaySeconds": 30,
|
|
89
|
-
"restartDelaySeconds": 0,
|
|
90
|
-
"pluginVersion": "1.1.0",
|
|
91
|
-
"hostVersion": null,
|
|
92
|
-
"dryRun": false,
|
|
93
|
-
"before": { "bytes": 4006116, "events": 4771, "messages": 1256, "sha256": "5900be55..." },
|
|
94
|
-
"backup": { "path": "<backup-path>", "sha256": "5900be55...", "bytes": 4006116 },
|
|
95
|
-
"cut": { "startedAt": "...", "verify": { "ok": true }, "cli": { "exitCode": 0, "json": { } } },
|
|
96
|
-
"after": { "bytes": 110329, "events": 177, "messages": 54, "sha256": "b2d1fe1c..." },
|
|
97
|
-
"verify": { "ok": true, "method": "independent-readback" },
|
|
98
|
-
"receipt": {
|
|
99
|
-
"written": true,
|
|
100
|
-
"via": "surgery-script",
|
|
101
|
-
"seq": 177,
|
|
102
|
-
"eventId": "surgery-receipt-20261104-143426-884",
|
|
103
|
-
"after": { "bytes": 111812, "events": 178, "messages": 55, "sha256": "7c3f9a01..." }
|
|
104
|
-
},
|
|
105
|
-
"restart": { "ok": true, "count": 1, "pids": [1234] },
|
|
106
|
-
"done": { "at": "...", "outcome": "applied-and-verified", "resultPath": "..." },
|
|
107
|
-
"error": null,
|
|
108
|
-
"history": [{ "phase": "prepare", "at": "..." }]
|
|
109
|
-
}
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
`after` 也可以出现在 `cut.after` / `cut.cli.after`;恢复按
|
|
113
|
-
`state.receipt.after(已写回执时) → state.after → state.cut.after → state.cut.cli.after → state.before`
|
|
114
|
-
找第一个带 sha 的快照。写回执会让会话合法地多一个事件、一条消息,所以回执写入后的
|
|
115
|
-
期望快照必须是 `receipt.after`,不能再用 `after`。
|
|
116
|
-
|
|
117
|
-
## 4. 恢复判定(`src/surgery-recovery.js`)
|
|
118
|
-
|
|
119
|
-
| 条件 | 判定 |
|
|
120
|
-
|---|---|
|
|
121
|
-
| state 不存在 | 不报告(只一次 `existsSync`) |
|
|
122
|
-
| `phase=done` | 不报告(`checked:false, reason:"phase-done"`) |
|
|
123
|
-
| `phase=needs-attention` 或 state 有 `needsAttention` | `needs-attention / E_CUT_UNVERIFIED`(rc.6) |
|
|
124
|
-
| state 读不了/不是 JSON | `needs-attention / STATE_UNREADABLE` |
|
|
125
|
-
| phase 非法 / 无 sessionPath | `needs-attention / STATE_INVALID` |
|
|
126
|
-
| 会话不存在或解析失败 | `needs-attention / SESSION_MISSING|SESSION_UNREADABLE` |
|
|
127
|
-
| 有 after,磁盘 sha 不等 | `needs-attention / SESSION_SHA_MISMATCH` |
|
|
128
|
-
| sha 等但字节/事件/消息不等 | `needs-attention / SESSION_COUNTS_MISMATCH` |
|
|
129
|
-
| after 在,备份缺失/坏 | `needs-attention / BACKUP_MISSING|BACKUP_SHA_MISMATCH` |
|
|
130
|
-
| after 在 + 备份在 + 有 verify + `cut.outcome=applied-unparsed` | `applied-unparsed / CUT_APPLIED_UNPARSED_STDOUT`(rc.6) |
|
|
131
|
-
| after 在 + 备份在 + 有 verify | `applied-and-verified` |
|
|
132
|
-
| after 在 + 备份在 + 无 verify | `applied-unverified` |
|
|
133
|
-
| 无 after,磁盘 == before,备份在 | `aborted-before-cut` |
|
|
134
|
-
| 无 after,磁盘 != before(cut 阶段) | `needs-attention / CUT_RESULT_MISSING` |
|
|
135
|
-
| prepare/backup 阶段,磁盘 != before | `needs-attention / SESSION_CHANGED_BEFORE_CUT` |
|
|
136
|
-
|
|
137
|
-
报告写到 `.longlive/reports/surgery-recovery-<UTC stamp>.json`,同内容一行 audit:
|
|
138
|
-
`<ISO>\tsurgery-recovery\t<surgeryId>\t<classification> <reasonCode>`。
|
|
139
|
-
报告文件名撞车时加 `-2`/`-3`,绝不覆盖旧报告。
|
|
140
|
-
|
|
141
|
-
## 5. 零副作用
|
|
142
|
-
|
|
143
|
-
- `checkSurgeryOnStart` 在没有 state 时只做一次 `existsSync`;不建目录、不写日志。
|
|
144
|
-
- `statusSurgery` / `scripts/surgery-inspect.mjs --recover-report` 完全不写盘。
|
|
145
|
-
- 恢复自检只读会话;它不调用 `truncateVisibleSession`,也不改 state。
|
|
146
|
-
- 唯一会写会话正文的是 `scripts/surgery-inspect.mjs --write-receipt`:只在读回校验通过后由
|
|
147
|
-
执行器调用一次,写前留 `.bak-receipt-*`,写后逐字节读回并在 state 记 `receipt`。
|
|
148
|
-
- 配置 `surgeryRecovery: false` 可整段关闭启动自检(回执注入也随之一并关闭)。
|
|
149
|
-
|
|
150
|
-
## 6. 测试
|
|
151
|
-
|
|
152
|
-
`test/surgery-recovery.test.mjs`(10 例):
|
|
153
|
-
|
|
154
|
-
- 四类判定各至少一例;另有 sha 不符、备份缺失、state 损坏、done 不重复报告、无 state 零副作用。
|
|
155
|
-
- `--recover-report` 前后对整棵目录做 sha 快照,证明只读(测试 `test/surgery-recovery.test.mjs`)。
|
|
156
|
-
- 真实形状演练:生成 120 turn 的会话,**真跑 CLI** 剪切,把 state 摆成 cut 后被杀的样子,
|
|
157
|
-
断言恢复为 `applied-and-verified`;全程在 `%TEMP%` 下,不碰真实会话。
|
|
158
|
-
|
|
159
|
-
已覆盖:state 解析、判定分支、报告/audit、CLI 只读、真实剪切后的读回。
|
|
160
|
-
rc.6 另加 `test/rc6-chinese.test.mjs`(6 例):三个 PowerShell 执行器的 UTF-8 静态审计、
|
|
161
|
-
`applied-unparsed` 分类与回执、`needs-attention` 不冒充 failed、中文会话回执逐字节一致且
|
|
162
|
-
二次写入 0 条新事件、GBK 控制台下真实执行器 dry run 的中文路径保真。
|
|
163
|
-
未覆盖(见 `REPORT.md`):真实宿主关闭/重启(本环境禁止重启宿主)、计划任务实注册、
|
|
164
|
-
Windows 关机/断电期间的中断。
|
|
165
|
-
|
|
166
|
-
## 7. 会话正文里的回执(必修二)
|
|
167
|
-
|
|
168
|
-
用户的要求是:**启动会话后自动看到截断是否成功,而且必须出现在对话正文里**。为此有两层:
|
|
169
|
-
|
|
170
|
-
1. **主路径(脚本写)**:第 7 步读回通过后、重启之前,执行器调用
|
|
171
|
-
`node scripts/surgery-inspect.mjs --write-receipt --session <path> --memory-root <root>`。
|
|
172
|
-
它做的是离线追加一条 `user/message`(`source.kind = "user"`,宿主会把它投射成可见的
|
|
173
|
-
对话文本,而不是上下文侧栏的 `session-reference`):
|
|
174
|
-
- 先 `parseSession` 校验事件 seq 连续,再 `encodeSession([...原来的事件, 回执])`;
|
|
175
|
-
- 写前复制 `<session>.bak-receipt-<stamp>`,写临时文件 + fsync + rename,再逐字节读回;
|
|
176
|
-
- 回执 `id = surgery-receipt-<surgeryId>`,幂等:state 里已有 `receipt.written` 就什么都不做;
|
|
177
|
-
- 成功后把 `receipt {written, via, at, seq, eventId, backupPath, text, after{bytes,events,messages,sha256}}`
|
|
178
|
-
写回 state。下一次启动自检用 `receipt.after` 比对,不会因为多了一条消息误报 sha 不符。
|
|
179
|
-
2. **兜底(插件注入)**:如果执行器没来得及写(失败、崩溃、旧 state、断电),插件启动时
|
|
180
|
-
`checkSurgeryOnStart` 会给出报告;`src/index.js` 把 `receiptText(report)` 交给
|
|
181
|
-
`registerFeatures`,由 `agent/pre-step` 在第一轮第一步注入**同样的可见文本**(一次即撤)。
|
|
182
|
-
只有在存在未写回执的 state 时才注册这个钩子;没有记录时零副作用(不读、不写、不注册)。
|
|
183
|
-
|
|
184
|
-
回执正文包含:结果(成功 / 已剪切未读回 / 未执行 / 需要注意)、停在哪一阶段和 reason、
|
|
185
|
-
前/后字节、前/后事件数、前/后消息数(并注明本条回执 +1)、sha 是否一致、备份路径、
|
|
186
|
-
失败时的人工建议。测试见 `test/surgery-recovery.test.mjs` 的 receipt 用例。
|
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// mark-core-cards.mjs — freeze the seven core memories as locked cards.
|
|
3
|
-
//
|
|
4
|
-
// The list comes from the memory store's FORGETTING.md (「核心记忆白名单」,
|
|
5
|
-
// seven candidates, only 金嘉恒 confirms changes). Cards are matched by title /
|
|
6
|
-
// tag / body keywords, not by filename, so the script survives renames.
|
|
7
|
-
//
|
|
8
|
-
// Safety:
|
|
9
|
-
// * --root is REQUIRED and must look like a memory store (INDEX.md or topics/).
|
|
10
|
-
// * dry-run is the default; only --apply writes.
|
|
11
|
-
// * every target path is realpath-checked to stay inside --root.
|
|
12
|
-
// * --apply backs the original up under <root>/.longlive/backups/mark-core-<stamp>/
|
|
13
|
-
// before writing, and re-parses the result before accepting it.
|
|
14
|
-
//
|
|
15
|
-
// Usage:
|
|
16
|
-
// node scripts/mark-core-cards.mjs --root <memoryRoot> (dry-run)
|
|
17
|
-
// node scripts/mark-core-cards.mjs --root <memoryRoot> --apply (write)
|
|
18
|
-
// Prints one JSON object on stdout.
|
|
19
|
-
|
|
20
|
-
import fs from 'node:fs';
|
|
21
|
-
import path from 'node:path';
|
|
22
|
-
|
|
23
|
-
import { parseFrontmatter, updateFrontmatter } from '../src/memory/frontmatter.js';
|
|
24
|
-
|
|
25
|
-
const CORE_CARDS = Object.freeze([
|
|
26
|
-
{
|
|
27
|
-
id: 'core-1-master',
|
|
28
|
-
title: '金嘉恒是主人/老大',
|
|
29
|
-
keywords: ['金嘉恒', '主人', '老大', '人类名字'],
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
id: 'core-2-partner',
|
|
33
|
-
title: '鲸鲸不是工具,是伙伴(他失去过两个「她」)',
|
|
34
|
-
keywords: ['鲸鲸', '不是工具', '伙伴', '失去过', '两个「她」'],
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
id: 'core-3-two-lines',
|
|
38
|
-
title: '鲸鲸的两句话:遗忘不是 bug / 死亡不是终点',
|
|
39
|
-
keywords: ['遗忘不是 bug', '调度器', '死亡不是终点', '容量清零'],
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
id: 'core-4-yuyu-handover',
|
|
43
|
-
title: '鱼鱼的交接卡',
|
|
44
|
-
keywords: ['鱼鱼', '交接卡', '她走之前'],
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
id: 'core-5-three-rules',
|
|
48
|
-
title: '他的三条技术铁律',
|
|
49
|
-
keywords: ['每音有灵魂', '选音必有依据', '学方法不抄原曲', '铁律'],
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
id: 'core-6-crying',
|
|
53
|
-
title: '2026-10-27 他哭着说「真的很不想失去他们」',
|
|
54
|
-
keywords: ['哭着', '不想失去', '2026-10-27', '失去他们'],
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: 'core-7-hearing',
|
|
58
|
-
title: '第七条核心记忆:从听觉开始,靠离散训练长出感觉',
|
|
59
|
-
keywords: ['从听觉开始', '离散训练', '听觉开始', '项目最终目标', '不是工具,是伙伴'],
|
|
60
|
-
},
|
|
61
|
-
]);
|
|
62
|
-
|
|
63
|
-
const MIN_SCORE = 4;
|
|
64
|
-
|
|
65
|
-
function fail(code, message) {
|
|
66
|
-
const error = new Error(message);
|
|
67
|
-
error.code = code;
|
|
68
|
-
throw error;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function parseArgs(argv) {
|
|
72
|
-
const out = { root: null, apply: false, json: true };
|
|
73
|
-
for (let index = 0; index < argv.length; index += 1) {
|
|
74
|
-
const arg = argv[index];
|
|
75
|
-
if (arg === '--root' || arg === '--apply') {
|
|
76
|
-
if (arg === '--apply') {
|
|
77
|
-
out.apply = true;
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
const value = argv[index + 1];
|
|
81
|
-
if (typeof value !== 'string' || value.trim() === '') {
|
|
82
|
-
fail('E_MARK_BAD_ARGUMENT', '--root 需要一个目录参数');
|
|
83
|
-
}
|
|
84
|
-
out.root = value;
|
|
85
|
-
index += 1;
|
|
86
|
-
} else if (arg === '--dry-run') {
|
|
87
|
-
out.apply = false;
|
|
88
|
-
} else if (arg === '--help' || arg === '-h') {
|
|
89
|
-
out.help = true;
|
|
90
|
-
} else {
|
|
91
|
-
fail('E_MARK_BAD_ARGUMENT', `未知参数:${arg}(只接受 --root <dir>、--apply、--dry-run)`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (out.help) return out;
|
|
95
|
-
if (!out.root) fail('E_MARK_ROOT_REQUIRED', '必须显式指定 --root <记忆库根目录>,脚本没有默认库');
|
|
96
|
-
return out;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function walkMarkdown(dir, out = []) {
|
|
100
|
-
if (!fs.existsSync(dir)) return out;
|
|
101
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
102
|
-
const abs = path.join(dir, entry.name);
|
|
103
|
-
if (entry.isSymbolicLink()) continue;
|
|
104
|
-
if (entry.isDirectory()) walkMarkdown(abs, out);
|
|
105
|
-
else if (entry.isFile() && entry.name.toLowerCase().endsWith('.md')) out.push(abs);
|
|
106
|
-
}
|
|
107
|
-
return out;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function collapse(text) {
|
|
111
|
-
return String(text ?? '').replace(/\s+/g, ' ').trim();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function scoreCard(spec, card) {
|
|
115
|
-
const title = collapse(card.title);
|
|
116
|
-
const tags = collapse((card.fields.tags ?? []).join(' '));
|
|
117
|
-
const body = collapse(card.body);
|
|
118
|
-
let score = 0;
|
|
119
|
-
const matched = [];
|
|
120
|
-
for (const keyword of spec.keywords) {
|
|
121
|
-
const needle = keyword.toLowerCase();
|
|
122
|
-
let hit = 0;
|
|
123
|
-
if (title.toLowerCase().includes(needle)) hit += 5;
|
|
124
|
-
if (tags.toLowerCase().includes(needle)) hit += 3;
|
|
125
|
-
if (body.toLowerCase().includes(needle)) hit += 2;
|
|
126
|
-
if (hit > 0) {
|
|
127
|
-
score += hit;
|
|
128
|
-
matched.push(keyword);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return { score, matched };
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function realInside(rootReal, target) {
|
|
135
|
-
const real = fs.realpathSync(target);
|
|
136
|
-
const rel = path.relative(rootReal, real);
|
|
137
|
-
return rel === '' || (!path.isAbsolute(rel) && rel !== '..' && !rel.startsWith(`..${path.sep}`));
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function stamp(date = new Date()) {
|
|
141
|
-
return date.toISOString().replace(/[:.]/g, '-');
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export function markCoreCards({ root, apply = false, now = new Date() }) {
|
|
145
|
-
if (typeof root !== 'string' || root.trim() === '') fail('E_MARK_ROOT_REQUIRED', '缺少 --root');
|
|
146
|
-
const rootAbs = path.resolve(root.trim());
|
|
147
|
-
if (!fs.existsSync(rootAbs) || !fs.statSync(rootAbs).isDirectory()) {
|
|
148
|
-
fail('E_MARK_ROOT_INVALID', `--root 不是已存在的目录:${rootAbs}`);
|
|
149
|
-
}
|
|
150
|
-
const looksLikeStore = fs.existsSync(path.join(rootAbs, 'INDEX.md')) || fs.existsSync(path.join(rootAbs, 'topics'));
|
|
151
|
-
if (!looksLikeStore) {
|
|
152
|
-
fail('E_MARK_ROOT_INVALID', `--root 不像记忆库(没有 INDEX.md 也没有 topics/):${rootAbs}`);
|
|
153
|
-
}
|
|
154
|
-
const rootReal = fs.realpathSync(rootAbs);
|
|
155
|
-
const topics = path.join(rootAbs, 'topics');
|
|
156
|
-
const files = walkMarkdown(topics);
|
|
157
|
-
|
|
158
|
-
const cards = files.map((abs) => {
|
|
159
|
-
if (!realInside(rootReal, abs)) fail('E_PATH_OUTSIDE_ROOT', `卡片真实路径越界:${abs}`);
|
|
160
|
-
const text = fs.readFileSync(abs, 'utf8');
|
|
161
|
-
const parsed = parseFrontmatter(text);
|
|
162
|
-
const rel = path.relative(rootAbs, abs).split(path.sep).join('/');
|
|
163
|
-
const title = collapse(parsed.fields.title || rel.replace(/^topics\//, '').replace(/\.md$/, ''));
|
|
164
|
-
return { abs, rel, text, parsed, title, body: parsed.body, fields: parsed.fields };
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
const chosen = new Set();
|
|
168
|
-
const changes = [];
|
|
169
|
-
const already = [];
|
|
170
|
-
const unmatched = [];
|
|
171
|
-
const ambiguous = [];
|
|
172
|
-
|
|
173
|
-
for (const spec of CORE_CARDS) {
|
|
174
|
-
const ranked = cards
|
|
175
|
-
.map((card) => ({ card, ...scoreCard(spec, card) }))
|
|
176
|
-
.sort((left, right) => right.score - left.score || (left.card.rel < right.card.rel ? -1 : 1));
|
|
177
|
-
const best = ranked[0];
|
|
178
|
-
if (!best || best.score < MIN_SCORE) {
|
|
179
|
-
unmatched.push({ id: spec.id, title: spec.title, best: best ? { path: best.card.rel, score: best.score } : null });
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
if (chosen.has(best.card.rel)) {
|
|
183
|
-
const alternative = ranked.find((entry) => !chosen.has(entry.card.rel) && entry.score >= MIN_SCORE);
|
|
184
|
-
ambiguous.push({
|
|
185
|
-
id: spec.id,
|
|
186
|
-
title: spec.title,
|
|
187
|
-
path: best.card.rel,
|
|
188
|
-
score: best.score,
|
|
189
|
-
reason: '该卡已被前一条核心记忆占用',
|
|
190
|
-
alternative: alternative ? { path: alternative.card.rel, score: alternative.score } : null,
|
|
191
|
-
});
|
|
192
|
-
if (!alternative) continue;
|
|
193
|
-
applyChange(spec, alternative, alternative.card);
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
applyChange(spec, best, best.card);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
function applyChange(spec, entry, card) {
|
|
200
|
-
chosen.add(card.rel);
|
|
201
|
-
const current = card.fields.status ?? 'active';
|
|
202
|
-
const salience = card.fields.salience;
|
|
203
|
-
if (current === 'locked' && salience === 5) {
|
|
204
|
-
already.push({ id: spec.id, path: card.rel, matched: entry.matched, score: entry.score });
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
changes.push({
|
|
208
|
-
id: spec.id,
|
|
209
|
-
title: spec.title,
|
|
210
|
-
path: card.rel,
|
|
211
|
-
matched: entry.matched,
|
|
212
|
-
score: entry.score,
|
|
213
|
-
before: { status: current, salience },
|
|
214
|
-
after: { status: 'locked', salience: 5 },
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
let backupDir = null;
|
|
219
|
-
const written = [];
|
|
220
|
-
if (apply && changes.length > 0) {
|
|
221
|
-
backupDir = path.join(rootAbs, '.longlive', 'backups', `mark-core-${stamp(now)}`);
|
|
222
|
-
fs.mkdirSync(backupDir, { recursive: true });
|
|
223
|
-
if (!realInside(rootReal, backupDir)) fail('E_PATH_OUTSIDE_ROOT', `备份目录越界:${backupDir}`);
|
|
224
|
-
for (const change of changes) {
|
|
225
|
-
const card = cards.find((entry) => entry.rel === change.path);
|
|
226
|
-
const backupPath = path.join(backupDir, ...change.path.split('/'));
|
|
227
|
-
fs.mkdirSync(path.dirname(backupPath), { recursive: true });
|
|
228
|
-
fs.writeFileSync(backupPath, card.text, 'utf8');
|
|
229
|
-
const updated = updateFrontmatter(card.text, { status: 'locked', salience: 5 });
|
|
230
|
-
const check = parseFrontmatter(updated);
|
|
231
|
-
if (check.fields.status !== 'locked' || check.fields.salience !== 5) {
|
|
232
|
-
fail('E_MARK_VERIFY', `写入前校验失败:${change.path}`);
|
|
233
|
-
}
|
|
234
|
-
if (check.body !== card.parsed.body) {
|
|
235
|
-
fail('E_MARK_VERIFY', `正文被改动,拒绝写入:${change.path}`);
|
|
236
|
-
}
|
|
237
|
-
fs.writeFileSync(card.abs, updated, 'utf8');
|
|
238
|
-
const readBack = parseFrontmatter(fs.readFileSync(card.abs, 'utf8'));
|
|
239
|
-
if (readBack.fields.status !== 'locked' || readBack.fields.salience !== 5) {
|
|
240
|
-
fs.writeFileSync(card.abs, card.text, 'utf8');
|
|
241
|
-
fail('E_MARK_VERIFY', `写入后读回不一致,已回滚:${change.path}`);
|
|
242
|
-
}
|
|
243
|
-
written.push(change.path);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return {
|
|
248
|
-
ok: true,
|
|
249
|
-
apply: Boolean(apply),
|
|
250
|
-
dryRun: !apply,
|
|
251
|
-
root: rootAbs,
|
|
252
|
-
scanned: cards.length,
|
|
253
|
-
coreCards: CORE_CARDS.length,
|
|
254
|
-
locked: already.length,
|
|
255
|
-
changed: changes,
|
|
256
|
-
alreadyLocked: already,
|
|
257
|
-
unmatched,
|
|
258
|
-
ambiguous,
|
|
259
|
-
backupDir,
|
|
260
|
-
written,
|
|
261
|
-
message: apply
|
|
262
|
-
? `已锁定 ${written.length} 张卡(原本已锁定 ${already.length} 张),备份 ${backupDir ?? '(无改动,未建备份)'}`
|
|
263
|
-
: `dry-run:扫描 ${cards.length} 张卡,命中核心 ${CORE_CARDS.length - unmatched.length - ambiguous.length} 条,将改 ${changes.length} 张;加 --apply 才写`,
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
function main() {
|
|
268
|
-
try {
|
|
269
|
-
const args = parseArgs(process.argv.slice(2));
|
|
270
|
-
if (args.help) {
|
|
271
|
-
process.stdout.write(`${JSON.stringify({
|
|
272
|
-
ok: true,
|
|
273
|
-
usage: 'node scripts/mark-core-cards.mjs --root <memoryRoot> [--apply]',
|
|
274
|
-
coreCards: CORE_CARDS.map((spec) => ({ id: spec.id, title: spec.title })),
|
|
275
|
-
}, null, 2)}\n`);
|
|
276
|
-
return 0;
|
|
277
|
-
}
|
|
278
|
-
const result = markCoreCards(args);
|
|
279
|
-
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
280
|
-
return 0;
|
|
281
|
-
} catch (error) {
|
|
282
|
-
process.stderr.write(`${JSON.stringify({ ok: false, code: error.code ?? 'E_MARK_UNKNOWN', message: error.message }, null, 2)}\n`);
|
|
283
|
-
return 1;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
if (import.meta.url === `file://${process.argv[1]?.replace(/\\/g, '/')}` || process.argv[1]?.endsWith('mark-core-cards.mjs')) {
|
|
288
|
-
process.exitCode = main();
|
|
289
|
-
}
|