advisers 0.3.2 → 0.4.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.
Files changed (44) hide show
  1. package/README-zh.md +13 -14
  2. package/README.md +32 -23
  3. package/THIRD-PARTY-NOTICES.md +1 -1
  4. package/bin/advisers.js +2180 -92
  5. package/index.js +1 -1
  6. package/lib/brief-archive.js +267 -0
  7. package/lib/client-pack.js +1016 -0
  8. package/lib/consent.js +390 -0
  9. package/lib/credentials.js +195 -0
  10. package/lib/error-codes.js +516 -7
  11. package/lib/evidence.js +697 -113
  12. package/lib/kb-extract.js +626 -0
  13. package/lib/kb-facts.js +429 -0
  14. package/lib/kb-pages.js +1084 -0
  15. package/lib/kb.js +1036 -0
  16. package/lib/mail-errors.js +46 -0
  17. package/lib/mail-extract.js +351 -0
  18. package/lib/mail-imap.js +446 -0
  19. package/lib/mail-import.js +176 -0
  20. package/lib/mail-parse.js +223 -0
  21. package/lib/mail-store.js +731 -0
  22. package/lib/mail.js +506 -0
  23. package/lib/mcp-server.js +196 -10
  24. package/lib/notify.js +265 -7
  25. package/lib/policy/decision.js +315 -0
  26. package/lib/policy/egress.js +268 -0
  27. package/lib/policy/errors.js +71 -0
  28. package/lib/policy/index.js +99 -0
  29. package/lib/policy/rules.js +468 -0
  30. package/lib/policy/surfaces.js +141 -0
  31. package/lib/receipt-verify.js +199 -19
  32. package/lib/receivables.js +1653 -0
  33. package/lib/scheduler.js +453 -9
  34. package/lib/shell.js +1406 -0
  35. package/lib/source.js +98 -3
  36. package/lib/sqlite.js +366 -49
  37. package/lib/tos/index.js +2 -2
  38. package/lib/tos/manifest.json +6 -6
  39. package/lib/tos/privacy.zh-CN.md +33 -20
  40. package/lib/tos/safety.zh-CN.md +7 -6
  41. package/lib/tos/summary.zh-CN.md +3 -2
  42. package/lib/tos/terms.zh-CN.md +31 -16
  43. package/lib/urgency.js +467 -0
  44. package/package.json +4 -4
package/README-zh.md CHANGED
@@ -5,12 +5,12 @@
5
5
  ## 安装
6
6
 
7
7
  ```sh
8
- # 0.3.1 已于 2026-11-20 发布;npm @latest 现为 0.3.1(稳定渠道 = 默认 `latest`):
8
+ # 0.4.0 已于 2026-11-21 发布;npm @latest 现为 0.4.0(稳定渠道 = 默认 `latest`):
9
9
  # npm i -g --registry=https://registry.npmjs.org advisers@latest advisers-office@latest
10
10
  # 从 checkout 运行:
11
11
  # corepack pnpm install && corepack pnpm -r build
12
12
  # ADVISERS_OFFICE_LOCAL=1 node packages/advisers/bin/advisers.js status
13
- # `next` 渠道也指向 0.3.1:
13
+ # `next` 渠道也指向 0.4.0:
14
14
  # npm i -g --registry=https://registry.npmjs.org advisers@next advisers-office@next
15
15
  advisers soul init
16
16
  advisers brief "做一份 Q4 预算 Excel,周五前给老板"
@@ -24,7 +24,7 @@ advisers export
24
24
  > 金融等专业意见;AI 输出可能出错,使用前请自行核验。禁止用于违法、侵权、欺诈、骚扰、
25
25
  > 伪造或未标识合成内容等用途;未成年人须经监护人同意。
26
26
  > 软件许可:PolyForm Noncommercial 1.0.0(源码可见、非 OSI 开源;商业使用须另行取得许可)。
27
- > 使用前请阅读[服务条款](https://github.com/PerryLink/advisers/blob/main/docs/TOS.md)(v2026.11.3)、
27
+ > 使用前请阅读[服务条款](https://github.com/PerryLink/advisers/blob/main/docs/TOS.md)(v2026.11.4)、
28
28
  > [免责声明](https://github.com/PerryLink/advisers/blob/main/docs/DISCLAIMER.md)、
29
29
  > [安全与内容审核说明](https://github.com/PerryLink/advisers/blob/main/docs/SAFETY.md) 与
30
30
  > [隐私与数据流说明](https://github.com/PerryLink/advisers/blob/main/docs/PRIVACY.md)。
@@ -36,18 +36,9 @@ CLI 是**本地秘书运行时**:一个 REPL、用户账/承诺账/流程账
36
36
 
37
37
  ## 状态
38
38
 
39
- `0.3.2` 已于 2026-11-21 发布(npm `latest` = `0.3.2`;`next` 也为 `0.3.2`)。
40
- 0.3.2 是**功能版本**:交付面向客户的闭环(subject 回执包、`client export` 客户状态包、MCP/DSH 只读客户投影)
41
- 与性能收尾(`today --json --limit`、MCP 窄承诺读模型),契约只做加法、无 schema 迁移。`0.3.1` 是 0.3.0 的
42
- 发布面修复版(运行时不变),两者仍可按版本号安装但已被取代。运行时基线是「可信交付」feature line:所有出网面逐 item secrecy clearance、本地审计尾锚、备份轮换/可验证恢复与
43
- `doctor --repair`、200k 读路径消除 TEMP B-TREE 写放大、MCP 输出上限 + legacy 协议协商、DSH 只读账本门面、
44
- 机器可读契约、无 key 的确定性评测套件与 SBOM 门禁;被该 line 取代的 0.2.4 candidate 从未发布。0.3.2 tarball 由 GitHub Actions OIDC/Trusted Publishing 发布,
45
- 带 SLSA provenance;可用 `scripts/verify-release.mjs --version 0.3.2 --tag latest --sbom artifacts/sbom.cdx.json --require-sbom`
46
- 校验(SBOM 由 `pnpm run sbom` 生成)。Release notes:
47
- <https://github.com/PerryLink/advisers/releases/tag/v0.3.2>。完整 TUI 壳、邮件入口、PolicyGrant、MCP
48
- modern 与 DSH 写账本不在 0.3.2;未交付清单见仓库 CHANGELOG。
39
+ `0.4.0` 已于 2026-11-21 发布(npm `latest` = `0.4.0`;`next` 也为 `0.4.0`)。0.4.0 是单版本 0.4 功能发布:本地知识库(schema v22)、TLS-only IMAP 邮件入口、交互式壳、可解释的主动式晨报、Policy/Evidence 2.0 子集、回款/对账与客户状态包 v2、MCP modern dual-era、Windows CI 与便携 ZIP,以及 v2026.11.4 法务修订。所有新命令都不需要模型调用,也没有后台常驻进程,`mail sync` 是唯一新增的显式网络路径(TLS-only、只读、用户主动触发)。**schema v22 是单向迁移**:升级前 CLI 会写 `state.db.before-migrate-v*` 备份,0.3.2 打开 v22 数据库会报 `E_SCHEMA_NEWER`,降级需要恢复该备份。`0.3.2`/`0.3.1`/`0.3.0` 仍可按版本号安装但已被取代。运行时基线仍是「可信交付」feature line:所有出网面逐 item secrecy clearance、本地审计尾锚、备份轮换/可验证恢复与 `doctor --repair`、200k 读路径、MCP 输出上限 + legacy 协议协商、DSH 只读账本门面、机器可读契约、无 key 的确定性评测套件与 SBOM 门禁。0.4.0 tarball 由 GitHub Actions OIDC/Trusted Publishing 发布,带 SLSA provenance;可用 `scripts/verify-release.mjs --version 0.4.0 --tag latest --sbom artifacts/sbom.cdx.json --require-sbom` 校验(SBOM 由 `pnpm run sbom` 生成)。Release notes:<https://github.com/PerryLink/advisers/releases/tag/v0.4.0>。模型化 `kb compile`/`kb ask`、embedding、完整 PolicyGrant/exit 4–6 与 DSH 写账本仍属后续版本;未交付清单见仓库 CHANGELOG。
49
40
 
50
- - SQLite 账本 `~/.advisers/state.db`(JSON fallback;schema v21 —— v21 增量加入客户/项目实体、无锁只读快照、增量写);
41
+ - SQLite 账本 `~/.advisers/state.db`(JSON fallback;schema v22 —— 0.4.0 一次迁移加入 KB/邮件/回款对象、无锁只读快照、增量写);
51
42
  - soul 位于 `~/.advisers/soul.md`,人类独占;
52
43
  - turns + 摘要 + FTS 检索;开场协议;`/resume`;
53
44
  - 承诺账 + `commit add/ls/done`、`tick`、`snooze`、nudge outcome;
@@ -57,6 +48,14 @@ modern 与 DSH 写账本不在 0.3.2;未交付清单见仓库 CHANGELOG。
57
48
  - `advisers pet-brief`:只读脱敏 Pet Brief 投影(契约 v0.2:`schemaVersion: 2` + `displayPolicy`,默认 `private`;`--json`/`--out`/`--check [--strict]`/`--print-schema`/`--display-policy`;`secrecy >= 2` 全排除;5 分钟 TTL;v0.1 brief 按 legacy 可读;未接桌宠 UI);
58
49
  - `matter add|ls|show|rename|archive|use`(客户/项目最小闭环,`--matter` 校验);`agenda --days 1..31 --json` + 确定性 `morning` 晨报;确定性 `template quote|proposal`(DOCX/XLSX,`verify --content --template` 可复核);操作者手工证据标记为不可外部核验而非缺失;
59
50
  - 真实 IM/Office 打开验证仍未完成。
51
+ - **0.4.0 知识库**:`kb add|ls|show|rm|purge|reindex|link`、`search --scope turns|kb|pages|facts|all`(默认仍为 turns)、确定性编译页(`kb page ls|show|rebuild|diff`,带 stale 检测)与 `fact show|history|as-of`;无模型、无 embedding、无网络;
52
+ - **0.4.0 邮件入口**:`mail account add|ls|show|test|remove`、TLS-only 只读 `mail sync`(`UIDVALIDITY`/UID 游标)、`mail ls|show|extract|link|dismiss|purge`、`.eml` 导入、`0600` 凭据文件、正文默认保留 30 天;
53
+ - **0.4.0 交互壳**:补全、确认、有限队列、粘贴保护、Ctrl+C/Esc 处理与整行净化;非 TTY 仍是 plain/一次性行为,`tui --once/--json` 逐字节不变;
54
+ - **0.4.0 主动式**:确定性 `urgency` v1(`terms`/`whyNow`/`modelVersion`)、`morning` 晨报归档、v2 scheduler plan/status、可选提醒 webhook 的 Standard Webhooks HMAC 签名(payload 字节不变);
55
+ - **0.4.0 Policy/Evidence**:决策引擎、一次性 decision token、egress 注册表、独立 TOS/模型同意存储(`consent.json`,0600 原子写)、四态 evidence resolver + `mail`/`kb_chunk`/`kb_page` 来源与回执包 v2 `verificationBasis`;
56
+ - **0.4.0 回款**:`receivable add|ls|show|edit|void` + `payment add|ls|void`(整数分、四币种、部分/多笔/超额/void、同事务自动完成承诺)、逐币种合计与账龄、`client export --pack`(manifest + `SHA256SUMS` + 离线校验器);金额不进回执、MCP、DSH 与 Pet Brief;
57
+ - **0.4.0 MCP modern dual-era**:`server/discover`、modern 方法 allowlist 与 `resultType`/`ttlMs`/`cacheScope` envelope;legacy 响应逐字节不变,`ADVISERS_MCP_MODERN=off` 可回退;8 tools / 5 resources,DSH 6 tools;
58
+ - **0.4.0 Windows/法务**:`windows-full` CI 与便携 ZIP 构建/校验(npm 仍是正式渠道,`docs/WINDOWS.md` 限定支持范围);TOS/PRIVACY/SAFETY/DISCLAIMER 升级到 v2026.11.4。
60
59
 
61
60
  核心与架构:
62
61
 
package/README.md CHANGED
@@ -7,12 +7,12 @@ routines.
7
7
  ## Install
8
8
 
9
9
  ```sh
10
- # 0.3.2 was published on 2026-11-21; npm @latest is now 0.3.2:
10
+ # 0.4.0 was published on 2026-11-21; npm @latest is now 0.4.0:
11
11
  # npm i -g --registry=https://registry.npmjs.org advisers@latest advisers-office@latest
12
12
  # From checkout:
13
13
  # corepack pnpm install && corepack pnpm -r build
14
14
  # ADVISERS_OFFICE_LOCAL=1 node packages/advisers/bin/advisers.js status
15
- # The `next` channel also points at 0.3.2:
15
+ # The `next` channel also points at 0.4.0:
16
16
  # npm i -g --registry=https://registry.npmjs.org advisers@next advisers-office@next
17
17
  advisers soul init
18
18
  advisers brief "做一份 Q4 预算 Excel,周五前给老板"
@@ -28,7 +28,7 @@ advisers export
28
28
  > AI-generated content only with the required labels. Minors need guardian consent.
29
29
  > Software licence: PolyForm Noncommercial 1.0.0 (source-available, not OSI open source;
30
30
  > commercial use requires a separate licence). Terms:
31
- > <https://github.com/PerryLink/advisers/blob/main/docs/TOS.md> (v2026.11.3) · Disclaimer:
31
+ > <https://github.com/PerryLink/advisers/blob/main/docs/TOS.md> (v2026.11.4) · Disclaimer:
32
32
  > <https://github.com/PerryLink/advisers/blob/main/docs/DISCLAIMER.md> · Safety:
33
33
  > <https://github.com/PerryLink/advisers/blob/main/docs/SAFETY.md> · Privacy & data-flow:
34
34
  > <https://github.com/PerryLink/advisers/blob/main/docs/PRIVACY.md>. The local database is
@@ -43,27 +43,28 @@ turn natural language into commitments or artifacts.
43
43
 
44
44
  ## Status
45
45
 
46
- `0.3.2` was published on 2026-11-21 (npm `latest` = `0.3.2`; `next` is also `0.3.2`). It
47
- is a **feature release**: it adds the external customer loop (subject receipt packs,
48
- `client export` status sheets, read-only MCP/DSH customer projections) and the
49
- performance closeout (`today --json --limit`, a narrow MCP read model), with additive
50
- contract changes and no schema migration. `0.3.1` was a release-metadata correction for
51
- `0.3.0` with the same runtime; both remain installable by pinning but are superseded.
52
- The runtime baseline is the "trustworthy delivery" feature line:
53
- per-item secrecy clearance on every egress surface, a local audit tail anchor, backup
54
- rotation/verified restore and `doctor --repair`, 200k-row read paths without the TEMP
55
- B-TREE write amplification, MCP output caps plus legacy protocol negotiation, a read-only
56
- ledger facade for the DSH adapter, machine-readable contracts, a deterministic no-key
57
- eval suite and an SBOM gate. The 0.2.4 candidate superseded by that line was never
58
- published. The 0.3.2 tarballs are published from GitHub Actions OIDC/Trusted Publishing
59
- with SLSA provenance; verify with
60
- `scripts/verify-release.mjs --version 0.3.2 --tag latest --sbom artifacts/sbom.cdx.json --require-sbom`
61
- (the SBOM is generated by `pnpm run sbom`).
62
- Release notes: <https://github.com/PerryLink/advisers/releases/tag/v0.3.2>. The full
63
- interactive TUI shell, mail entry, PolicyGrant, MCP modern and DSH writes are not in
64
- 0.3.2; see the repository CHANGELOG for the full not-delivered list.
46
+ `0.4.0` was published on 2026-11-21 (npm `latest` = `0.4.0`; `next` is also `0.4.0`). It
47
+ is the single 0.4 feature release: the local knowledge base (schema v22), TLS-only IMAP
48
+ mail entry, the interactive shell, proactive urgent-first briefs, the policy/evidence 2.0
49
+ subset, receivables/payments with client pack v2, MCP modern dual-era, Windows CI plus a
50
+ portable ZIP, and the v2026.11.4 legal revision. No new command requires a model call,
51
+ there is no background daemon, and `mail sync` is the one new explicit network path
52
+ (TLS-only, read-only, user-invoked). **Schema v22 is a one-way migration**: the CLI writes
53
+ `state.db.before-migrate-v*` before upgrading, a 0.3.2 binary opening a v22 database fails
54
+ with `E_SCHEMA_NEWER`, and downgrading means restoring that backup. `0.3.2`/`0.3.1`/`0.3.0`
55
+ remain installable by pinning but are superseded. The runtime baseline remains the
56
+ "trustworthy delivery" line: per-item secrecy clearance on every egress surface, a local
57
+ audit tail anchor, backup rotation/verified restore and `doctor --repair`, 200k-row read
58
+ paths, MCP output caps plus legacy protocol negotiation, a read-only ledger facade, machine
59
+ readable contracts, a deterministic no-key eval suite and an SBOM gate. The 0.4.0 tarballs
60
+ are published from GitHub Actions OIDC/Trusted Publishing with SLSA provenance; verify with
61
+ `scripts/verify-release.mjs --version 0.4.0 --tag latest --sbom artifacts/sbom.cdx.json
62
+ --require-sbom` (the SBOM is generated by `pnpm run sbom`).
63
+ Release notes: <https://github.com/PerryLink/advisers/releases/tag/v0.4.0>. Model-backed KB
64
+ compile/ask, embeddings, the full PolicyGrant/exit 4–6 and DSH writes remain future work;
65
+ see the repository CHANGELOG for the full not-delivered list.
65
66
 
66
- - SQLite ledger at `~/.advisers/state.db` (JSON fallback with `ADVISERS_STORE=json`; schema v21 — v21 adds the additive customer/project entities — lock-free read snapshot, incremental writes);
67
+ - SQLite ledger at `~/.advisers/state.db` (JSON fallback with `ADVISERS_STORE=json`; schema v22 — one 0.4.0 migration adds the KB/mail/receivable/payment objects — lock-free read snapshot, incremental writes);
67
68
  - soul at `~/.advisers/soul.md`, human-owned;
68
69
  - local REPL, `chat`, `office`, `template`, `routine`, `link`, `bridge`, `soul`, `ls`, `why`, `forget`, `export`;
69
70
  - IntentBrief + clarification policy + readback;
@@ -77,6 +78,14 @@ interactive TUI shell, mail entry, PolicyGrant, MCP modern and DSH writes are no
77
78
  - `matter add|ls|show|rename|archive|use` (client/project loop, `--matter` validation); `agenda --days 1..31 --json` + deterministic `morning` brief; deterministic `template quote|proposal` (DOCX/XLSX) with `verify --content --template` re-check; operator-entered evidence typed as unverifiable instead of missing;
78
79
  - DSH bundle, email IMAP/draft, Feishu webhook, Hermes bridge; strict policy pack;
79
80
  - real-account/WS/Office-L3 validation still pending.
81
+ - **0.4.0 knowledge base**: `kb add|ls|show|rm|purge|reindex|link`, `search --scope turns|kb|pages|facts|all` (legacy default unchanged), deterministic compiled pages (`kb page ls|show|rebuild|diff`) with stale checks, and `fact show|history|as-of`; no model, no embedding, no network;
82
+ - **0.4.0 mail entry**: `mail account add|ls|show|test|remove`, TLS-only read-only `mail sync` with a `UIDVALIDITY`/UID cursor, `mail ls|show|extract|link|dismiss|purge`, `.eml` import, `0600` credentials, 30-day default body retention;
83
+ - **0.4.0 interactive shell**: completion, confirmations, bounded queue, paste protection, Ctrl+C/Esc handling and whole-line sanitization; non-TTY stays plain/one-shot and `tui --once/--json` is byte-identical;
84
+ - **0.4.0 proactive briefs**: deterministic `urgency` v1 (`terms`/`whyNow`/`modelVersion`), archived `morning` briefs, v2 scheduler plan/status, Standard Webhooks HMAC signing for the opt-in reminder webhook (payload bytes unchanged);
85
+ - **0.4.0 policy/evidence**: decision engine, one-shot decision tokens, egress registry, separate TOS/model consent store (`consent.json`, 0600 atomic), four-state evidence resolver with `mail`/`kb_chunk`/`kb_page` sources and pack v2 `verificationBasis`;
86
+ - **0.4.0 receivables**: `receivable add|ls|show|edit|void` + `payment add|ls|void` (integer minor units, CNY/USD/EUR/HKD, partial/over/void, auto-complete the linked commitment), per-currency totals and aging, `client export --pack` status packs with `SHA256SUMS` and an offline verifier; amounts stay out of receipt packs, MCP, DSH and Pet Brief;
87
+ - **0.4.0 MCP modern dual-era**: `server/discover`, modern method allowlist and `resultType`/`ttlMs`/`cacheScope` envelopes with byte-identical legacy responses and `ADVISERS_MCP_MODERN=off` rollback; 8 tools / 5 resources, DSH 6 tools;
88
+ - **0.4.0 Windows/legal**: `windows-full` CI and a portable-ZIP builder/verifier (npm stays the official channel; `docs/WINDOWS.md` scopes support), and TOS/PRIVACY/SAFETY/DISCLAIMER v2026.11.4 for the new data planes.
80
89
 
81
90
  Shared core and architecture:
82
91
 
@@ -11,7 +11,7 @@ dependency closure of the published packages ("pnpm list --prod --depth 100";
11
11
  devDependencies and workspace packages excluded). Do not edit by hand; CI runs
12
12
  "node scripts/check-licenses.mjs".
13
13
 
14
- This file is shipped with the advisers@0.3.2 npm package and covers the third-party production dependencies of that package only. Each dependency keeps its own license.
14
+ This file is shipped with the advisers@0.4.0 npm package and covers the third-party production dependencies of that package only. Each dependency keeps its own license.
15
15
 
16
16
  Optional platform-specific binaries (for example the @napi-rs/canvas builds for
17
17
  other operating systems and CPU architectures) are installed only on a matching