opencode-wiki-historian 0.6.2 → 0.6.3

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
@@ -133,7 +133,7 @@ Source repository is managed by the maintainer; the public distribution channel
133
133
 
134
134
  > 注:npm 包名为 opencode-wiki-historian(opencode-historian 已被注册表上一无关同名包占用);仓库与插件 id 仍为 opencode-historian。
135
135
 
136
- 发布状态:包已上架 npm(当前 0.6.2,走 GitHub Actions Trusted Publishing / OIDC,不再需要账号 2FA OTP)。方式一 `npm install` 与方式二 `file://` 两条安装路径均可用;方式二仍是开发态调试首选(改完即生效,无需发版)。
136
+ 发布状态:包已上架 npm(当前 0.6.3,走 GitHub Actions Trusted Publishing / OIDC,不再需要账号 2FA OTP)。方式一 `npm install` 与方式二 `file://` 两条安装路径均可用;方式二仍是开发态调试首选(改完即生效,无需发版)。
137
137
 
138
138
  ### 方式二:本地路径(开发用)
139
139
 
@@ -227,7 +227,7 @@ key 缺失时 `ConfigError` 记录一次日志,插件工具全部禁用,open
227
227
  | 现象 | 定性 | 说明 |
228
228
  |---|---|---|
229
229
  | 裸配置未传 `translate` 选项(三段 key 链 `translate.apiKey` → `DASHSCOPE_API_KEY` → `translate.providerKey` 全缺)时插件工具全部禁用 | by design | 翻译腿是写操作的前提,缺 key 时宁可整体禁用也不静默半成品;配置按上方选项全表补齐即恢复。缺配置时的部分降级(工具照常注册、仅翻译调用失败)在议 |
230
- | 自进化驱动(readingLoop + capture)默认关闭,作者本机也尚未点亮 | 状态如实 | 两个开关缺省均为 `false`(`src/config.ts:100` `DEFAULT_READING_LOOP`、`src/config.ts:102` `DEFAULT_CAPTURE_ENABLED`),readingLoop 还需配置+哨兵双确认。v0.4.0 时代的人工 2FA 发布流程已被 Trusted Publishing(OIDC)取代,npm 已上架至 0.6.2;回路本机启用仍待点亮;回路代码与测试已就绪,但在真正点亮之前本文档不假装它在跑 |
230
+ | 自进化驱动(readingLoop + capture)默认关闭,作者本机也尚未点亮 | 状态如实 | 两个开关缺省均为 `false`(`src/config.ts:100` `DEFAULT_READING_LOOP`、`src/config.ts:102` `DEFAULT_CAPTURE_ENABLED`),readingLoop 还需配置+哨兵双确认。v0.4.0 时代的人工 2FA 发布流程已被 Trusted Publishing(OIDC)取代,npm 已上架至 0.6.3;回路本机启用仍待点亮;回路代码与测试已就绪,但在真正点亮之前本文档不假装它在跑 |
231
231
 
232
232
  ## wiki.js 前置检查 / Prerequisites
233
233
 
package/dist/config.d.ts CHANGED
@@ -100,7 +100,11 @@ export declare const DEFAULT_CAPTURE_ENABLED = false;
100
100
  * 2. env DASHSCOPE_API_KEY
101
101
  * 3. jsonc provider[translate.providerKey].options.apiKey — only when
102
102
  * `translate.providerKey` is set explicitly (no default provider name)
103
- * 4. throw ConfigError('missing translation key')
103
+ * 4. unset ('') — deferred: the first translate call fails loudly as
104
+ * TranslateError('config') with the three-leg prescription (translate.ts).
105
+ * Absence NEVER disables the wiki tools at load time — an operator who
106
+ * binds no translation model still gets every other tool, with twins
107
+ * degrading to pending (the README config-table contract).
104
108
  *
105
109
  * Translation endpoint priority: raw.translate.endpoint →
106
110
  * env HISTORIAN_TRANSLATE_ENDPOINT → unset (''). There is no baked-in
package/dist/config.js CHANGED
@@ -46,7 +46,11 @@ export const DEFAULT_CAPTURE_ENABLED = false;
46
46
  * 2. env DASHSCOPE_API_KEY
47
47
  * 3. jsonc provider[translate.providerKey].options.apiKey — only when
48
48
  * `translate.providerKey` is set explicitly (no default provider name)
49
- * 4. throw ConfigError('missing translation key')
49
+ * 4. unset ('') — deferred: the first translate call fails loudly as
50
+ * TranslateError('config') with the three-leg prescription (translate.ts).
51
+ * Absence NEVER disables the wiki tools at load time — an operator who
52
+ * binds no translation model still gets every other tool, with twins
53
+ * degrading to pending (the README config-table contract).
50
54
  *
51
55
  * Translation endpoint priority: raw.translate.endpoint →
52
56
  * env HISTORIAN_TRANSLATE_ENDPOINT → unset (''). There is no baked-in
@@ -83,16 +87,11 @@ function resolveTranslationApiKey(raw, env, homeDir, providerKey) {
83
87
  if (isNonEmpty(envKey))
84
88
  return envKey;
85
89
  if (providerKey !== '') {
86
- const jsoncKey = readProviderApiKeyFromJsonc(homeDir, providerKey);
87
- if (isNonEmpty(jsoncKey))
88
- return jsoncKey;
90
+ return readProviderApiKeyFromJsonc(homeDir, providerKey) ?? '';
89
91
  }
90
- const jsoncHint = providerKey !== ''
91
- ? `add provider["${providerKey}"].options.apiKey`
92
- : `set translate.providerKey and add the key to provider["<name>"].options.apiKey`;
93
- throw new ConfigError('missing-translation-key', `Missing translation api key: set plugin option translate.apiKey, ` +
94
- `export DASHSCOPE_API_KEY, or ${jsoncHint} ` +
95
- `in ${opencodeJsoncPath(homeDir)}.`);
92
+ // No leg produced a key: yield '' (deferred). Load-time absence is a supported
93
+ // state (wiki tools alive, twins pending); the loud failure is at call time.
94
+ return '';
96
95
  }
97
96
  /**
98
97
  * Read the wiki.js api key. Priority: key file (path from options.apiKeyPath,
package/dist/translate.js CHANGED
@@ -102,9 +102,13 @@ export function pickResponseText(json) {
102
102
  const out = isRecord(content[0]) && content[0].type === 'text' && typeof content[0].text === 'string'
103
103
  ? content[0].text
104
104
  : texts.join('');
105
- if (out === '')
105
+ // Wrapping whitespace is transport residue, never translation content: some
106
+ // adaptor lanes pad text parts with leading blank lines, and chunk-rejoining
107
+ // ('.join('\n\n')) would bake that padding into page bodies.
108
+ const trimmed = out.trim();
109
+ if (trimmed === '')
106
110
  throw new TranslateError('malformed', 'response text is empty');
107
- return out;
111
+ return trimmed;
108
112
  }
109
113
  // --- System prompt ----------------------------------------------------------
110
114
  /** Machine-consumed routing tokens (DIRECTION, GLOSSARY table) plus the
@@ -132,6 +136,13 @@ export async function callMessages(opts, deps, call) {
132
136
  'env HISTORIAN_TRANSLATE_MODEL to a model YOUR device is authorized for ' +
133
137
  '(L-MACHINE-LOCAL: the package ships no device model defaults).');
134
138
  }
139
+ if (opts.translate.apiKey.trim() === '') {
140
+ const hint = opts.translate.providerKey !== ''
141
+ ? `or add provider["${opts.translate.providerKey}"].options.apiKey`
142
+ : 'or set translate.providerKey and add provider["<name>"].options.apiKey';
143
+ throw new TranslateError('config', 'Missing translation api key — set plugin option translate.apiKey, ' +
144
+ `export DASHSCOPE_API_KEY, ${hint} in ~/.config/opencode/opencode.jsonc.`);
145
+ }
135
146
  const url = normalizeMessagesUrl(opts.translate.endpoint);
136
147
  const key = opts.translate.apiKey;
137
148
  const fetchImpl = deps?.fetchImpl ?? fetch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-wiki-historian",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
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",