@sanqianx/project-knowledge 5.1.3 → 5.1.4
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/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +5 -0
- package/_site/_test/bin-cli-test.js +3 -2
- package/_site/_test/capture-hook-dedup-test.js +41 -1
- package/_site/_test/cli-version-report-test.js +22 -0
- package/_site/_test/codex-notify-upgrade-test.js +7 -0
- package/_site/lib/capture-hook-config.js +9 -2
- package/_site/lib/module-bridge.js +1 -1
- package/bin/project-knowledge.js +51 -1
- package/module-runtime-manifest.json +3 -3
- package/package.json +1 -1
- package/plugins/project-knowledge/.claude-plugin/plugin.json +1 -1
- package/plugins/project-knowledge/.codex-plugin/plugin.json +1 -1
- package/plugins/project-knowledge/.mcp.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [5.1.4] - 2026-11-19
|
|
4
|
+
|
|
5
|
+
- 默认数据目录改为 `~/.project-knowledge`,仍可显式选择数据目录。重新接入 ZCode、Claude Code 或 Codex 时会清理指向旧默认目录 `~/.project-knowledge-v5` 的采集入口,避免旧脚本路径报错或重复采集。
|
|
6
|
+
- `project-knowledge --version` 现同时显示主程序和五个模块的版本。
|
|
7
|
+
|
|
3
8
|
## [5.0.35] - 2026-11-13
|
|
4
9
|
|
|
5
10
|
- 模块监督器退避计数在稳定运行后重置:连续健康运行 ≥60 秒的模块服务,其下一次退出按新事故计(计数归 1),只有持续快速崩溃才累计到放弃上限,快速崩溃循环的原有保护与退避节奏不变。消除「偶发退出的模块被监督器永久放弃、外壳持续向死端口反代、界面长时间 MODULE_UNREACHABLE 直到重启外壳」的故障模式(系统日志中 10-22→23、10-26→27 两波 24/20 小时级故障即此成因)。新增 `module-supervisor-backoff-reset-test.js` 回归(崩溃循环仍放弃 + 稳定退出必拉起且计数归 1)。
|
|
@@ -104,8 +104,9 @@ function canConnect(port) {
|
|
|
104
104
|
// --version
|
|
105
105
|
const versionResult = run(['--version']);
|
|
106
106
|
assert(versionResult.status === 0, `--version should exit 0, got ${versionResult.status}: ${versionResult.stderr}`);
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
const versionFirstLine = versionResult.stdout.split('\n')[0].trim();
|
|
108
|
+
assert(versionFirstLine === `project-knowledge ${require(path.join(ROOT, 'package.json')).version}`,
|
|
109
|
+
`--version first line (${versionFirstLine}) should be "project-knowledge <package.json version>"; the remaining lines are the module inventory`);
|
|
109
110
|
|
|
110
111
|
// --help mentions the new subcommands
|
|
111
112
|
const helpResult = run(['--help']);
|
|
@@ -13,6 +13,7 @@ const ROOT = path.resolve(__dirname, '../..');
|
|
|
13
13
|
const TEMP = fs.mkdtempSync(path.join(os.tmpdir(), 'pk-capture-dedup-'));
|
|
14
14
|
const HOME = path.join(TEMP, '用户 空格');
|
|
15
15
|
const OLD = path.join(HOME, '.ai-coding-event-bridge');
|
|
16
|
+
const OLD_V5 = path.join(HOME, '.project-knowledge-v5/events');
|
|
16
17
|
const CURRENT = path.join(HOME, '.project-knowledge/events');
|
|
17
18
|
const options = { homeDir: HOME, bridgeHomeDir: CURRENT };
|
|
18
19
|
const shim = home => path.join(home, 'bin/bridge-hook.cjs');
|
|
@@ -74,6 +75,45 @@ async function main() {
|
|
|
74
75
|
assert.deepEqual(read(zcode).env, unrelated.env);
|
|
75
76
|
assert.deepEqual(read(zcode).hooks.events.UserPromptSubmit[0].hooks, [third, zContext]);
|
|
76
77
|
|
|
78
|
+
// Renaming the default data directory leaves absolute hooks behind. The
|
|
79
|
+
// missing v5 shim must be retired even when the current hook already exists.
|
|
80
|
+
for (const client of ['claude', 'zcode']) {
|
|
81
|
+
const file = path.join(HOME, client, 'v5-migration.json');
|
|
82
|
+
const managed = client === 'zcode' ? processHook : cmd;
|
|
83
|
+
const eventMap = Object.fromEntries(events.map(event => [event, [
|
|
84
|
+
{ matcher: '*', hooks: [managed(OLD_V5), third, managed(CURRENT), managed(customHome), lookalike] },
|
|
85
|
+
]]));
|
|
86
|
+
write(file, { ...unrelated, hooks: client === 'zcode' ? { enabled: true, events: eventMap } : eventMap });
|
|
87
|
+
const migrated = manager(client === 'zcode' ? { zcodeConfigFile: file } : { claudeSettingsFile: file });
|
|
88
|
+
const status = () => client === 'zcode' ? migrated.statusCaptureZCode() : migrated.statusCaptureClaude();
|
|
89
|
+
const install = () => client === 'zcode' ? migrated.installCaptureZCode() : migrated.installCaptureClaude();
|
|
90
|
+
const original = fs.readFileSync(file, 'utf8');
|
|
91
|
+
assert(!fs.existsSync(shim(OLD_V5)), 'the retired v5 runtime is absent');
|
|
92
|
+
assert.equal((await status()).state, 'needs-repair', `${client}: stale v5 hooks cannot be reported healthy`);
|
|
93
|
+
assert.equal(fs.readFileSync(file, 'utf8'), original, 'migration status remains read-only');
|
|
94
|
+
const repaired = await install();
|
|
95
|
+
assert.equal(repaired.removedLegacy, 2);
|
|
96
|
+
assert.equal(repaired.removedDuplicates, 0);
|
|
97
|
+
const config = read(file), fixedEvents = client === 'zcode' ? config.hooks.events : config.hooks;
|
|
98
|
+
assert.deepEqual(config.env, unrelated.env);
|
|
99
|
+
for (const event of events) {
|
|
100
|
+
const hooks = fixedEvents[event].flatMap(group => group.hooks);
|
|
101
|
+
assert(!hooks.some(hook => JSON.stringify(hook) === JSON.stringify(managed(OLD_V5))));
|
|
102
|
+
assert.equal(hooks.filter(hook => JSON.stringify(hook) === JSON.stringify(managed(CURRENT))).length, 1);
|
|
103
|
+
for (const keep of [third, managed(customHome), lookalike]) assert(hooks.some(hook => JSON.stringify(hook) === JSON.stringify(keep)));
|
|
104
|
+
assert.equal(fixedEvents[event][0].matcher, '*');
|
|
105
|
+
}
|
|
106
|
+
assert.equal((await status()).state, 'installed');
|
|
107
|
+
const fixed = fs.readFileSync(file, 'utf8');
|
|
108
|
+
assert.equal((await install()).changed, false);
|
|
109
|
+
assert.equal(fs.readFileSync(file, 'utf8'), fixed, 'v5 migration is byte-idempotent');
|
|
110
|
+
}
|
|
111
|
+
assert.equal(bridgeBinding(['node', shim(OLD_V5)], options), 'legacy');
|
|
112
|
+
assert.equal(bridgeBinding(['node', shim(OLD_V5)], { ...options, bridgeHomeDir: OLD_V5 }), 'current', 'an explicitly selected v5 data directory remains current');
|
|
113
|
+
assert.equal(bridgeBinding(['node', shim(OLD_V5), '--custom-argument'], options), '');
|
|
114
|
+
assert.equal(bridgeBinding(['node', `${shim(OLD_V5)}.user-script`], options), '');
|
|
115
|
+
assert.equal(bridgeBinding(['node', shim(path.join(TEMP, 'another-user/.project-knowledge-v5/events'))], options), '', 'another account is not owned');
|
|
116
|
+
|
|
77
117
|
write(claude, { hooks: Object.fromEntries(events.map(event => [event, [{ hooks: [cmd(OLD)] }]])) });
|
|
78
118
|
const onlyLegacy = fs.readFileSync(claude, 'utf8');
|
|
79
119
|
assert.throws(() => repairCaptureHooks(claude, 'claude', options), /入口未完整/);
|
|
@@ -135,7 +175,7 @@ async function main() {
|
|
|
135
175
|
const captured = fs.readFileSync(journal, 'utf8').trim().split(/\r?\n/).map(line => JSON.parse(line));
|
|
136
176
|
assert.deepEqual(captured.map(row => row.eventType), ['user_prompt', 'assistant_response']);
|
|
137
177
|
assert(!fs.existsSync(obsoleteStore), 'the stale second directory is not recreated');
|
|
138
|
-
write(zcode, { hooks: { enabled: true, events: Object.fromEntries(events.map(event => [event, [{ hooks: [processHook(
|
|
178
|
+
write(zcode, { hooks: { enabled: true, events: Object.fromEntries(events.map(event => [event, [{ hooks: [processHook(OLD_V5), processHook(CURRENT), processHook(CURRENT)] }]])) } });
|
|
139
179
|
await item.installCaptureZCode();
|
|
140
180
|
for (const [event, payload] of [
|
|
141
181
|
['UserPromptSubmit', { prompt: 'isolated zcode dedup request' }],
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// `project-knowledge --version` is a one-shot inventory: the core version,
|
|
3
|
+
// the instance state, and one line per pinned runtime module with a live or
|
|
4
|
+
// installed version. Assertions keep the report complete even when no
|
|
5
|
+
// instance is running (CI).
|
|
6
|
+
|
|
7
|
+
const { spawnSync } = require('child_process');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const assert = require('assert/strict');
|
|
10
|
+
|
|
11
|
+
const result = spawnSync(process.execPath, [path.join(__dirname, '..', '..', 'bin', 'project-knowledge.js'), '--version'], { encoding: 'utf8', timeout: 30_000 });
|
|
12
|
+
assert.equal(result.status, 0, `--version exited ${result.status}: ${result.stderr}`);
|
|
13
|
+
const out = result.stdout;
|
|
14
|
+
assert.match(out, /^project-knowledge \d+\.\d+\.\d+/, 'core version line');
|
|
15
|
+
assert.match(out, /instance: (running at http|not running)/, 'instance line');
|
|
16
|
+
for (const label of ['Workbench (terminal)', 'vector-hub', 'event-bridge', 'knowledge-engine', 'workflow']) {
|
|
17
|
+
const line = out.split('\n').find(l => l.trim().startsWith(label));
|
|
18
|
+
assert.ok(line, `module line for ${label} present`);
|
|
19
|
+
assert.match(line, /\d+\.\d+\.\d+/, `${label} carries a version`);
|
|
20
|
+
assert.match(line, /\[(live|installed)\]/, `${label} carries a source tag`);
|
|
21
|
+
}
|
|
22
|
+
console.log('cli-version-report-test PASS');
|
|
@@ -172,6 +172,13 @@ async function main() {
|
|
|
172
172
|
await rawLegacy.manager.uninstallCaptureCodex();
|
|
173
173
|
assert.strictEqual(readNotify(rawLegacy.configFile), null, 'uninstall must not resurrect a retired Bridge home');
|
|
174
174
|
|
|
175
|
+
const v5Command = ['node', path.join(TEMP, 'legacy-v5-data-home', 'home', '.project-knowledge-v5', 'events', 'bin', 'bridge-hook.cjs')];
|
|
176
|
+
const rawV5 = fixture('legacy-v5-data-home', v5Command);
|
|
177
|
+
await assertInstallIdempotent(rawV5);
|
|
178
|
+
assert(!descendants(readNotify(rawV5.configFile)).some(command => command[1] === v5Command[1]), 'retire the old default data-directory hook rather than chaining its missing script');
|
|
179
|
+
await rawV5.manager.uninstallCaptureCodex();
|
|
180
|
+
assert.strictEqual(readNotify(rawV5.configFile), null, 'uninstall cannot resurrect the retired v5 data-directory hook');
|
|
181
|
+
|
|
175
182
|
const nestedLegacyCommand = defaultLegacy('nested-legacy-default-home');
|
|
176
183
|
const legacyRadar = [...radar, '--previous-notify', JSON.stringify(nestedLegacyCommand)];
|
|
177
184
|
const nestedLegacy = fixture('nested-legacy-default-home', oldFanout('old-with-legacy-next', legacyRadar, staleBridge));
|
|
@@ -20,8 +20,15 @@ function bridgeBinding(args, options) {
|
|
|
20
20
|
if (args.length !== 2 && !(args.length === 4 && args[2] === '--source' && ['claude-code', 'claude', 'zcode', 'codex', 'opencode'].includes(args[3]))) return '';
|
|
21
21
|
const actual = normalized(args[1]);
|
|
22
22
|
const current = normalized(path.join(options.bridgeHomeDir, 'bin', 'bridge-hook.cjs'));
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
const homeDir = options.homeDir || os.homedir();
|
|
24
|
+
// The default data-dir rename does not rewrite absolute client hooks.
|
|
25
|
+
// Match only our two historical defaults in this account; custom Bridge
|
|
26
|
+
// homes and other accounts remain untouched. An explicit v5 home is current.
|
|
27
|
+
const legacy = [
|
|
28
|
+
path.join(homeDir, '.ai-coding-event-bridge', 'bin', 'bridge-hook.cjs'),
|
|
29
|
+
path.join(homeDir, '.project-knowledge-v5', 'events', 'bin', 'bridge-hook.cjs'),
|
|
30
|
+
].map(normalized);
|
|
31
|
+
return actual === current ? 'current' : legacy.includes(actual) ? 'legacy' : '';
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
function hookArgs(hook) {
|
|
@@ -910,4 +910,4 @@ class ModuleBridge {
|
|
|
910
910
|
}
|
|
911
911
|
}
|
|
912
912
|
|
|
913
|
-
module.exports = { ModuleBridge, defaultTerminalUrl, defaultVectorHubUrl, defaultEventBridgeUrl, defaultEngineUrl };
|
|
913
|
+
module.exports = { ModuleBridge, defaultTerminalUrl, defaultVectorHubUrl, defaultEventBridgeUrl, defaultEngineUrl, MODULE_ENTRIES, resolveModuleEntry };
|
package/bin/project-knowledge.js
CHANGED
|
@@ -168,10 +168,60 @@ async function resolveExistingForStart(dataDir) {
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
+
// Full version report: the core package plus every pinned runtime module.
|
|
172
|
+
// Live versions come from the running instance's module health endpoints;
|
|
173
|
+
// anything not running (or not reporting a version) falls back to the
|
|
174
|
+
// installed tree, labeled accordingly.
|
|
175
|
+
async function versionReport() {
|
|
176
|
+
const { MODULE_ENTRIES, resolveModuleEntry } = require('../_site/lib/module-bridge');
|
|
177
|
+
const lines = [`project-knowledge ${pkg.version}`];
|
|
178
|
+
let instance = null;
|
|
179
|
+
try { instance = await instances.current(resolveDataDirPath({ dataDir: undefined })); } catch { /* not running */ }
|
|
180
|
+
if (instance) lines.push(`instance: running at ${instances.url(instance)} (data: ${instance.dataDir})`);
|
|
181
|
+
else lines.push('instance: not running (module versions below are from the installed tree)');
|
|
182
|
+
const liveHealth = {};
|
|
183
|
+
if (instance) {
|
|
184
|
+
const base = instances.url(instance);
|
|
185
|
+
try {
|
|
186
|
+
const aggregated = await (await fetch(`${base}/api/modules/health`, { signal: AbortSignal.timeout(4000) })).json();
|
|
187
|
+
// Aggregated keys are camelCase (vectorHub/eventBridge/engine); the
|
|
188
|
+
// entries table uses hyphenated keys — map before probing.
|
|
189
|
+
const kindByAggregatedKey = { terminal: 'terminal', vectorHub: 'vector-hub', eventBridge: 'event-bridge', engine: 'knowledge-engine', workflow: 'workflow' };
|
|
190
|
+
await Promise.all(Object.entries(aggregated.modules || {}).map(async ([aggregatedKey, module]) => {
|
|
191
|
+
const kind = kindByAggregatedKey[aggregatedKey];
|
|
192
|
+
if (!kind || !module?.up || !module.url) return;
|
|
193
|
+
const detail = await fetch(module.url + (kind === 'terminal' ? '/api/claude-workbench/v1/health' : '/api/health'), { signal: AbortSignal.timeout(4000) });
|
|
194
|
+
if (!detail.ok) return;
|
|
195
|
+
liveHealth[kind] = await detail.json().catch(() => null);
|
|
196
|
+
}));
|
|
197
|
+
} catch { /* shell unreachable: fall back to installed */ }
|
|
198
|
+
}
|
|
199
|
+
const labels = { terminal: 'Workbench (terminal)', 'vector-hub': 'vector-hub', 'event-bridge': 'event-bridge', 'knowledge-engine': 'knowledge-engine', workflow: 'workflow' };
|
|
200
|
+
for (const [kind, entry] of Object.entries(MODULE_ENTRIES)) {
|
|
201
|
+
const resolved = resolveModuleEntry(kind);
|
|
202
|
+
let installed = null;
|
|
203
|
+
if (resolved) {
|
|
204
|
+
// Walk up from the resolved entry file to the package's own package.json.
|
|
205
|
+
let dir = path.dirname(resolved);
|
|
206
|
+
for (let i = 0; i < 6 && dir; i++) {
|
|
207
|
+
const pkgPath = path.join(dir, 'package.json');
|
|
208
|
+
if (fs.existsSync(pkgPath)) {
|
|
209
|
+
try { const candidate = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); if (resolved.startsWith(dir)) { installed = candidate.version; break; } } catch { /* keep walking */ }
|
|
210
|
+
}
|
|
211
|
+
dir = path.dirname(dir);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const live = liveHealth[kind] && typeof liveHealth[kind].version === 'string' ? liveHealth[kind].version : null;
|
|
215
|
+
const shown = live || installed;
|
|
216
|
+
lines.push(` ${(labels[kind] || kind).padEnd(22)} ${shown || 'not installed'}${live ? ' [live]' : installed ? ' [installed]' : ''}`);
|
|
217
|
+
}
|
|
218
|
+
console.log(lines.join('\n'));
|
|
219
|
+
}
|
|
220
|
+
|
|
171
221
|
async function main() {
|
|
172
222
|
const options = parse(process.argv.slice(2));
|
|
173
223
|
if (options.help) { help(); return; }
|
|
174
|
-
if (options.version) {
|
|
224
|
+
if (options.version) { await versionReport(); return; }
|
|
175
225
|
if (options.forwarded) {
|
|
176
226
|
const args = options.command === 'integrations' ? (options.forwarded.length ? options.forwarded : ['status']) : [options.command, ...options.forwarded];
|
|
177
227
|
const result = spawnSync(process.execPath, [path.join(__dirname, 'project-knowledge-integrations.js'), ...args], { stdio: 'inherit', windowsHide: true });
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"plugins/project-knowledge/hooks/codex.json": "216e03c07295606ef6ebb2c4f669ad0d790b5e7c4f3f34600488033db75e4239",
|
|
12
12
|
"plugins/project-knowledge/scripts/context-hook.cjs": "12f9120a4503193042eff109da3688e909ef8a0f8409bf38c7f47f6e36941d86",
|
|
13
13
|
"plugins/project-knowledge/scripts/mcp-launcher.cjs": "c9235eaf722ad011ce42d7a8416a77bef8e2a65e174f27b3d183f4b8f811f293",
|
|
14
|
-
"plugins/project-knowledge/.claude-plugin/plugin.json": "
|
|
15
|
-
"plugins/project-knowledge/.codex-plugin/plugin.json": "
|
|
16
|
-
"plugins/project-knowledge/.mcp.json": "
|
|
14
|
+
"plugins/project-knowledge/.claude-plugin/plugin.json": "9f778828c7b4090da59c0d376b2b6a434b0099ab2476cdfba246ac440eecefbe",
|
|
15
|
+
"plugins/project-knowledge/.codex-plugin/plugin.json": "d1884301f743159d9ae807d22b37819247c3b8bd42cca9d4a8cfacb81723a47f",
|
|
16
|
+
"plugins/project-knowledge/.mcp.json": "9941bdac0f3bf03de1d6a1d43570658705621219764331334e192fed61a2391c",
|
|
17
17
|
"ui/version-info.js": "01a82217b031de54b80d6c7974da9c70888c4c90a046bd4248a808f7989ddce7",
|
|
18
18
|
"ui/version-info.css": "209fad8e42b661f72d2aba3280e1ca47768b5cefb776fe5459538d34fbad120f"
|
|
19
19
|
},
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json",
|
|
3
3
|
"name": "project-knowledge",
|
|
4
4
|
"hooks": "./hooks/claude.json",
|
|
5
|
-
"version": "5.1.
|
|
5
|
+
"version": "5.1.4",
|
|
6
6
|
"description": "Read durable project decisions and implementation history from Project Knowledge.",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "SanQianX",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"const fs=require('fs'),path=require('path'),os=require('os');const PKG='@sanqianx/project-knowledge',SC='project-knowledge/integration-runtime/v1';let f='';const root=process.env.CLAUDE_PLUGIN_ROOT||process.env.PLUGIN_ROOT;if(root){f=path.join(root,'scripts','mcp-launcher.cjs');if(!fs.existsSync(f))f=''}if(!f){const dd=process.env.KB_DATA_DIR||path.join(os.homedir(),'.project-knowledge');try{const bp=path.join(dd,'integration-runtime.json');const st=fs.statSync(bp);if(st.isFile()&&st.size<=32768){const b=JSON.parse(fs.readFileSync(bp,'utf8'));if(b&&b.schema===SC&&b.packageName===PKG&&typeof b.packageRoot==='string'&&path.isAbsolute(b.packageRoot)){const c=path.join(b.packageRoot,'plugins','project-knowledge','scripts','mcp-launcher.cjs');const rr=fs.realpathSync(b.packageRoot),cr=fs.realpathSync(c);const rel=path.relative(rr,cr);if(rel&&rel!=='..'&&!rel.startsWith('..'+path.sep)&&!path.isAbsolute(rel)&&fs.statSync(cr).isFile())f=cr}}}catch(e){}}if(!f){console.error('[project-knowledge-mcp] 未能通过受信任插件根或已验证的安装绑定定位启动器,已停止;不访问网络,也不加载工作目录源码。');process.exit(127)}require(f);"
|
|
9
9
|
],
|
|
10
10
|
"env": {
|
|
11
|
-
"KB_PLUGIN_VERSION": "5.1.
|
|
11
|
+
"KB_PLUGIN_VERSION": "5.1.4"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
}
|