opencode-wiki-historian 0.5.3 → 0.6.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.en.md ADDED
@@ -0,0 +1,46 @@
1
+ # opencode-historian (English)
2
+
3
+ > Bilingual wiki curator as an OpenCode plugin. 中文文档见 [README.md](README.md).
4
+
5
+ ## What it is
6
+ A plugin that gives an OpenCode agent a curated memory layer on top of a Wiki.js
7
+ instance: bilingual (en/zh) twin pages, genre skeletons (G1–G6), full-text
8
+ search, page map/timeline/maintenance sweeps, migration tooling, and a capture
9
+ loop. All mutations go through read-modify-write; evidence-tier pages
10
+ (`_meta/`, `_evidence/`) are machine-owned and hidden from anonymous readers.
11
+
12
+ ## Tools (11)
13
+ `historian_page_create / update / append / read / search / delete / move`,
14
+ `historian_map` (show/refresh/timeline/maintain), `historian_migrate`,
15
+ `historian_translate_snippet`, and `historian_anchor` (seal/verify human
16
+ orders against the engine session store — receipts land under
17
+ `_evidence/anchors/`, g12b-3).
18
+
19
+ ## Configuration (plugin options in opencode.jsonc)
20
+ | option | type | default | notes |
21
+ |---|---|---|---|
22
+ | `baseUrl` | string | `http://localhost:3000` | wiki.js root |
23
+ | `apiKeyPath` | string | `~/.wikijs-api-key` | token file path |
24
+ | `translate.endpoint` | string | unset | Anthropic-compatible messages endpoint; env leg: `HISTORIAN_TRANSLATE_ENDPOINT` |
25
+ | `translate.model` | string | unset | **no device model is shipped in the package** (L-MACHINE-LOCAL, owner ruling 2026-10-01); set your own; env leg: `HISTORIAN_TRANSLATE_MODEL`; an unset model fails loudly at first use |
26
+ | `translate.providerKey` | string | unset | jsonc fallback leg reading `provider[<key>].options.apiKey` |
27
+ | `sections` / `locales` / `readingLoop` / `capture.enabled` | — | see README.md table | mirrored in the Chinese doc |
28
+
29
+ Credential resolution order: `translate.apiKey` → `DASHSCOPE_API_KEY` →
30
+ provider leg. With the whole chain unset the translation-backed tools stay
31
+ disabled by design — the plugin never half-works.
32
+
33
+ ## Behavior notes
34
+ - Path segments must not look like locale codes; page ops take path+locale, no raw ids.
35
+ - Evidence tier (`_meta/`, `_evidence/`) writes are monolingual `en`, unpublished-friendly, machine-owned.
36
+ - Every tool result carries en/zh URLs; report them to the operator verbatim.
37
+
38
+ ## Development
39
+ `npm run build` → `npx vitest run` → `node tools/privacy-audit.mjs` →
40
+ `node tools/portable-binding-audit.mjs` (guards the no-device-pin rule on
41
+ portable surfaces). Releases: see `RELEASE.md` (npm trusted publishing via
42
+ GitHub Actions OIDC; no long-lived tokens).
43
+
44
+ ## Provenance
45
+ Clean-room implementation per the institutional-memory contract; incident
46
+ history and rulings live in the operator wiki (`infra/*`, `_evidence/*`).
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # opencode-historian
2
2
 
3
+ > 中文 ↓ | [English →](README.en.md)
4
+
3
5
  > OpenCode 插件:双语 wiki.js 知识库管理 / Bilingual wiki curator as an OpenCode plugin.
4
6
 
5
7
  opencode-historian 把 wiki.js 的读写、翻译、页型规范、迁移工具打包成一个 OpenCode 插件,让 AI agent 能直接管理双语知识库。它为什么存在、文风从哪里来、怎么一句话开始用,见下文「史官宣言」。
@@ -169,7 +171,7 @@ opencode run --command historian --message "historian_map show"
169
171
  "apiKeyPath": "~/.wiki-key",
170
172
  "translate": {
171
173
  "endpoint": "https://<your-anthropic-compatible-gateway>/v1",
172
- "model": "qwen3.7-plus",
174
+ "model": "<your-authorized-model>",
173
175
  "apiKey": "<YOUR_KEY>",
174
176
  "providerKey": "my-provider"
175
177
  },
@@ -189,7 +191,7 @@ opencode run --command historian --message "historian_map show"
189
191
  | `baseUrl` | string | `http://localhost:3000` | wiki.js GraphQL 端点 |
190
192
  | `apiKeyPath` | string | `~/.wikijs-api-key` | wiki API key 文件路径(tilde 在读取时展开) |
191
193
  | `translate.endpoint` | string | 未配置(见下方链) | 翻译 API 端点 |
192
- | `translate.model` | string | `qwen3.7-plus` | 翻译模型 |
194
+ | `translate.model` | string | 未配置(调用时响亮报错) | 翻译模型;包内不内置设备模型默认(L-MACHINE-LOCAL),可用 env `HISTORIAN_TRANSLATE_MODEL` 兜底腿 |
193
195
  | `translate.apiKey` | string | 见下方链 | 翻译 API 密钥 |
194
196
  | `translate.providerKey` | string | 未配置 | jsonc 兜底腿读取的 provider 名;须显式设置才会启用该腿 |
195
197
  | `sections` | string[] | `[]`(不限制) | 写入路径前缀白名单。v4 起强制生效:非空时 create/update/append/delete/move(目标路径) 在发出请求前做 `sectionGuard` 检查,越界返回 `ConfigError`;`home`、`wiki-index`、`_sandbox`、`_data`、`_meta`、`_evidence` 恒豁免;按首路径段匹配、区分大小写 |
package/dist/config.d.ts CHANGED
@@ -78,7 +78,11 @@ export declare const DEFAULT_BASE_URL = "http://localhost:3000";
78
78
  export declare const DEFAULT_API_KEY_PATH = "~/.wikijs-api-key";
79
79
  /** Env leg of the endpoint chain: raw option → this env var → unset (''). */
80
80
  export declare const ENV_TRANSLATE_ENDPOINT = "HISTORIAN_TRANSLATE_ENDPOINT";
81
- export declare const DEFAULT_TRANSLATE_MODEL = "qwen3.7-plus";
81
+ /** L-MACHINE-LOCAL (owner ruling 2026-10-01, 复核 2026-10-02): the portable
82
+ * package must NOT pin the operator's model choice. Resolution is
83
+ * explicit-option -> env leg -> unset (''), and an unset model fails loudly
84
+ * at first translate call (see translate.ts), never silently defaults. */
85
+ export declare const ENV_TRANSLATE_MODEL = "HISTORIAN_TRANSLATE_MODEL";
82
86
  /** Empty = no path-prefix restriction (see HistorianOptions.sections). */
83
87
  export declare const DEFAULT_SECTIONS: readonly string[];
84
88
  export declare const DEFAULT_LOCALES: readonly ["en", "zh"];
package/dist/config.js CHANGED
@@ -23,7 +23,11 @@ export const DEFAULT_BASE_URL = 'http://localhost:3000';
23
23
  export const DEFAULT_API_KEY_PATH = '~/.wikijs-api-key';
24
24
  /** Env leg of the endpoint chain: raw option → this env var → unset (''). */
25
25
  export const ENV_TRANSLATE_ENDPOINT = 'HISTORIAN_TRANSLATE_ENDPOINT';
26
- export const DEFAULT_TRANSLATE_MODEL = 'qwen3.7-plus';
26
+ /** L-MACHINE-LOCAL (owner ruling 2026-10-01, 复核 2026-10-02): the portable
27
+ * package must NOT pin the operator's model choice. Resolution is
28
+ * explicit-option -> env leg -> unset (''), and an unset model fails loudly
29
+ * at first translate call (see translate.ts), never silently defaults. */
30
+ export const ENV_TRANSLATE_MODEL = 'HISTORIAN_TRANSLATE_MODEL';
27
31
  /** Empty = no path-prefix restriction (see HistorianOptions.sections). */
28
32
  export const DEFAULT_SECTIONS = [];
29
33
  export const DEFAULT_LOCALES = ['en', 'zh'];
@@ -61,7 +65,7 @@ export function resolveOptions(raw, env = process.env, homeDir = homedir()) {
61
65
  apiKeyPath: raw.apiKeyPath ?? DEFAULT_API_KEY_PATH,
62
66
  translate: {
63
67
  endpoint: raw.translate?.endpoint ?? env[ENV_TRANSLATE_ENDPOINT] ?? '',
64
- model: raw.translate?.model ?? DEFAULT_TRANSLATE_MODEL,
68
+ model: raw.translate?.model ?? env[ENV_TRANSLATE_MODEL] ?? '',
65
69
  apiKey: translateApiKey,
66
70
  providerKey,
67
71
  },
package/dist/translate.js CHANGED
@@ -127,6 +127,11 @@ export async function callMessages(opts, deps, call) {
127
127
  throw new TranslateError('config', 'translate.endpoint not configured — set plugin option translate.endpoint ' +
128
128
  'or export HISTORIAN_TRANSLATE_ENDPOINT.');
129
129
  }
130
+ if (opts.translate.model.trim() === '') {
131
+ throw new TranslateError('config', 'translate.model not configured — set plugin option translate.model or ' +
132
+ 'env HISTORIAN_TRANSLATE_MODEL to a model YOUR device is authorized for ' +
133
+ '(L-MACHINE-LOCAL: the package ships no device model defaults).');
134
+ }
130
135
  const url = normalizeMessagesUrl(opts.translate.endpoint);
131
136
  const key = opts.translate.apiKey;
132
137
  const fetchImpl = deps?.fetchImpl ?? fetch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-wiki-historian",
3
- "version": "0.5.3",
3
+ "version": "0.6.1",
4
4
  "description": "opencode plugin that manages a wiki.js knowledge base with bilingual pages, genre templates, and migration tooling.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -31,6 +31,10 @@
31
31
  "scripts": {
32
32
  "build": "tsc",
33
33
  "test": "vitest run",
34
- "prepublishOnly": "npm run build && npx vitest run && node tools/privacy-audit.mjs"
34
+ "prepublishOnly": "npm run build && npx vitest run && node tools/privacy-audit.mjs && node tools/portable-binding-audit.mjs"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/TachikomaGundam/opencode-historian.git"
35
39
  }
36
40
  }