@sanqianx/project-knowledge 5.1.2 → 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/README.md +2 -2
- package/_site/_test/bin-cli-test.js +3 -2
- package/_site/_test/capture-hook-dedup-test.js +42 -2
- package/_site/_test/cli-version-report-test.js +22 -0
- package/_site/_test/codex-notify-upgrade-test.js +7 -0
- package/_site/_test/fresh-product-data-test.js +1 -1
- package/_site/_test/helpers/parallel-dock-acceptance-r2-env.js +1 -1
- package/_site/_test/helpers/parallel-dock-isolation-r3-fixture.js +1 -1
- package/_site/_test/helpers/parallel-memory-injection-shell.js +1 -1
- package/_site/_test/helpers/parallel-retrieval-followup-r2-shell.js +1 -1
- package/_site/_test/helpers/parallel-workbench-drafts-r5-fixture.js +1 -1
- package/_site/_test/helpers/parallel-workbench-fixture.js +1 -1
- package/_site/_test/helpers/parallel-workbench-integration-5025-fixture.js +1 -1
- package/_site/_test/helpers/qa-r44-env.js +2 -2
- package/_site/_test/integration-runtime-binding-a2-test.js +2 -2
- package/_site/_test/integration-runtime-binding-test.js +3 -3
- package/_site/_test/launcher-readiness-test.js +1 -1
- package/_site/lib/capture-hook-config.js +9 -2
- package/_site/lib/data-dir.js +1 -1
- package/_site/lib/module-bridge.js +1 -1
- package/bin/project-knowledge.js +52 -2
- package/module-runtime-manifest.json +5 -5
- 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 +2 -2
- package/plugins/project-knowledge/scripts/context-hook.cjs +1 -1
- package/plugins/project-knowledge/scripts/mcp-launcher.cjs +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)。
|
package/README.md
CHANGED
|
@@ -200,7 +200,7 @@ new empty knowledge directories. Old files remain untouched but are not read.
|
|
|
200
200
|
See [fresh v5 setup](docs/fresh-v5-start.md). Queued tasks can be cancelled by
|
|
201
201
|
unbinding; only an active knowledge/index writer blocks removal.
|
|
202
202
|
|
|
203
|
-
Default internal data directory: `~/.project-knowledge
|
|
203
|
+
Default internal data directory: `~/.project-knowledge/`
|
|
204
204
|
|
|
205
205
|
Override it with `KB_DATA_DIR`:
|
|
206
206
|
|
|
@@ -224,7 +224,7 @@ Settings, registration metadata, caches, runtime state, logs, and recovery
|
|
|
224
224
|
assets remain in the internal data directory; vector payloads do not:
|
|
225
225
|
|
|
226
226
|
```text
|
|
227
|
-
~/.project-knowledge
|
|
227
|
+
~/.project-knowledge/
|
|
228
228
|
├── settings.json
|
|
229
229
|
├── projects.json # minimal project ID/order index
|
|
230
230
|
├── projects/<projectId>/
|
|
@@ -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,7 +13,8 @@ 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
|
|
16
|
+
const OLD_V5 = path.join(HOME, '.project-knowledge-v5/events');
|
|
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');
|
|
19
20
|
const cmd = home => ({ type: 'command', command: `node "${shim(home)}"` });
|
|
@@ -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));
|
|
@@ -8,7 +8,7 @@ const { connectEngine } = require('../lib/engine-connection');
|
|
|
8
8
|
|
|
9
9
|
(async () => {
|
|
10
10
|
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'kb-fresh-product-'));
|
|
11
|
-
assert.equal(resolveDataDirPath({ dataDir: '', homeDir: root }), path.join(root, '.project-knowledge
|
|
11
|
+
assert.equal(resolveDataDirPath({ dataDir: '', homeDir: root }), path.join(root, '.project-knowledge'));
|
|
12
12
|
const old = path.join(root, 'old'); fs.mkdirSync(old);
|
|
13
13
|
const bytes = JSON.stringify({ projects: ['old-project'], activeClaim: 'old-claim' });
|
|
14
14
|
fs.writeFileSync(path.join(old, 'projects.json'), bytes);
|
|
@@ -42,7 +42,7 @@ const MODULE_API_PREFIX = '/api/claude-workbench/v1';
|
|
|
42
42
|
// fixture data dir. The live desktop core 5.0.24 installation is never
|
|
43
43
|
// written to, restarted or replaced.
|
|
44
44
|
const REAL_PROFILE_STORES = [
|
|
45
|
-
path.join(os.homedir(), '.project-knowledge
|
|
45
|
+
path.join(os.homedir(), '.project-knowledge', 'workbench'),
|
|
46
46
|
path.join(os.homedir(), '.agent-terminal'),
|
|
47
47
|
];
|
|
48
48
|
|
|
@@ -102,7 +102,7 @@ const REAL_USERPROFILE = process.env.USERPROFILE || REAL_HOME;
|
|
|
102
102
|
// a time, and the secret that is read there never leaves the server process
|
|
103
103
|
// memory: it is handed over through a pipe, never written to a file.
|
|
104
104
|
const REAL_PROFILE_STORES = [
|
|
105
|
-
path.join(REAL_HOME, '.project-knowledge
|
|
105
|
+
path.join(REAL_HOME, '.project-knowledge', 'workbench'),
|
|
106
106
|
path.join(REAL_HOME, '.agent-terminal'),
|
|
107
107
|
];
|
|
108
108
|
|
|
@@ -273,7 +273,7 @@ function hostEnv(layout, extra = {}) {
|
|
|
273
273
|
function realWorkbenchProfileDir() {
|
|
274
274
|
const override = String(process.env.PK_WB_REAL_PROFILE_DIR || '').trim();
|
|
275
275
|
if (override) return path.resolve(override);
|
|
276
|
-
return path.join(REAL_HOME, '.project-knowledge
|
|
276
|
+
return path.join(REAL_HOME, '.project-knowledge', 'workbench');
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
// Byte-level snapshot of a flat directory. The SHA-256 digests stay in the
|
|
@@ -280,7 +280,7 @@ function hostEnv(layout, extra = {}) {
|
|
|
280
280
|
function realWorkbenchProfileDir() {
|
|
281
281
|
const override = String(process.env.PK_WB_REAL_PROFILE_DIR || '').trim();
|
|
282
282
|
if (override) return path.resolve(override);
|
|
283
|
-
return path.join(REAL_HOME, '.project-knowledge
|
|
283
|
+
return path.join(REAL_HOME, '.project-knowledge', 'workbench');
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
// Byte-level snapshot of a flat directory. The SHA-256 digests stay in the
|
|
@@ -250,7 +250,7 @@ function hostEnv(layout, extra = {}) {
|
|
|
250
250
|
// captured at module load. R5 uses this string exclusively to prove that no
|
|
251
251
|
// isolated env value points there; this helper never touches the filesystem.
|
|
252
252
|
function realWorkbenchProfileDir() {
|
|
253
|
-
return path.join(REAL_HOME, '.project-knowledge
|
|
253
|
+
return path.join(REAL_HOME, '.project-knowledge', 'workbench');
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
// The module that is hosted: the copy the installed product ships, unless
|
|
@@ -214,7 +214,7 @@ function hostEnv(layout, extra = {}) {
|
|
|
214
214
|
function realWorkbenchProfileDir() {
|
|
215
215
|
const override = String(process.env.PK_WB_REAL_PROFILE_DIR || '').trim();
|
|
216
216
|
if (override) return path.resolve(override);
|
|
217
|
-
return path.join(REAL_HOME, '.project-knowledge
|
|
217
|
+
return path.join(REAL_HOME, '.project-knowledge', 'workbench');
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
// Byte-level snapshot of a flat directory. The SHA256 digests stay in the
|
|
@@ -309,7 +309,7 @@ function hostEnv(layout, extra = {}) {
|
|
|
309
309
|
// no isolated env value points there; this helper never touches the
|
|
310
310
|
// filesystem.
|
|
311
311
|
function realWorkbenchProfileDir() {
|
|
312
|
-
return path.join(REAL_HOME, '.project-knowledge
|
|
312
|
+
return path.join(REAL_HOME, '.project-knowledge', 'workbench');
|
|
313
313
|
}
|
|
314
314
|
|
|
315
315
|
// The module that is hosted: the copy the installed product ships, unless
|
|
@@ -105,7 +105,7 @@ function isInside(candidate, parent) {
|
|
|
105
105
|
// hardens its own environment, and os.homedir() reads the REDIRECTED
|
|
106
106
|
// USERPROFILE once the isolation is applied. The value is therefore captured
|
|
107
107
|
// at load time and refreshed by the capture, never re-derived later.
|
|
108
|
-
let REAL_PROFILE_DIR = path.join(os.homedir(), '.project-knowledge
|
|
108
|
+
let REAL_PROFILE_DIR = path.join(os.homedir(), '.project-knowledge', 'workbench');
|
|
109
109
|
function realProfileDir() { return REAL_PROFILE_DIR; }
|
|
110
110
|
|
|
111
111
|
// The lane's own temp root, outside the repository and outside the real
|
|
@@ -190,7 +190,7 @@ function captureRealEnvironment() {
|
|
|
190
190
|
const chrome = findChromeDetailed();
|
|
191
191
|
const claude = findClaudeExecutable();
|
|
192
192
|
const present = (name) => Object.keys(process.env).some(key => key.toUpperCase() === name && String(process.env[key] || '').trim() !== '');
|
|
193
|
-
REAL_PROFILE_DIR = path.join(realHome, '.project-knowledge
|
|
193
|
+
REAL_PROFILE_DIR = path.join(realHome, '.project-knowledge', 'workbench');
|
|
194
194
|
return {
|
|
195
195
|
realHome,
|
|
196
196
|
realUserProfile,
|
|
@@ -508,8 +508,8 @@ async function testProbeEnvUsesManagerDataDir() {
|
|
|
508
508
|
// not leak into the probe: the manager's own home-based binding wins.
|
|
509
509
|
const goodData = stubServerPackage('ok-env');
|
|
510
510
|
const goodHome = dir('env-good-home');
|
|
511
|
-
fs.mkdirSync(path.join(goodHome, '.project-knowledge
|
|
512
|
-
fs.copyFileSync(bindingPathOf(goodData), path.join(goodHome, '.project-knowledge
|
|
511
|
+
fs.mkdirSync(path.join(goodHome, '.project-knowledge'), { recursive: true });
|
|
512
|
+
fs.copyFileSync(bindingPathOf(goodData), path.join(goodHome, '.project-knowledge', 'integration-runtime.json'));
|
|
513
513
|
const evilPkg = dir('env-evil-pkg');
|
|
514
514
|
fakePackage(evilPkg, { version: '5.0.15' });
|
|
515
515
|
const evilData = dir('env-evil-data');
|
|
@@ -230,7 +230,7 @@ async function testBootstrapResolvesForBothNativeForms() {
|
|
|
230
230
|
|
|
231
231
|
async function testInstallerBindingLifecycle() {
|
|
232
232
|
const home = path.join(TEMP, 'installer-home');
|
|
233
|
-
const dataDir = path.join(home, '.project-knowledge
|
|
233
|
+
const dataDir = path.join(home, '.project-knowledge');
|
|
234
234
|
const bindingPath = path.join(dataDir, 'integration-runtime.json');
|
|
235
235
|
const manager = new IntegrationManager({
|
|
236
236
|
rootDir: ROOT,
|
|
@@ -274,7 +274,7 @@ async function testInstallerBindingLifecycle() {
|
|
|
274
274
|
|
|
275
275
|
async function testInstallAllCaptureOnlySkipsBinding() {
|
|
276
276
|
const home = path.join(TEMP, 'install-all-home');
|
|
277
|
-
const dataDir = path.join(home, '.project-knowledge
|
|
277
|
+
const dataDir = path.join(home, '.project-knowledge');
|
|
278
278
|
const bridgeStub = {
|
|
279
279
|
createBridge: () => ({
|
|
280
280
|
registerConsumer: async () => ({}),
|
|
@@ -303,7 +303,7 @@ async function testInstallAllCaptureOnlySkipsBinding() {
|
|
|
303
303
|
|
|
304
304
|
async function testMcpStartupProbe() {
|
|
305
305
|
const home = path.join(TEMP, 'probe-home');
|
|
306
|
-
const dataDir = path.join(home, '.project-knowledge
|
|
306
|
+
const dataDir = path.join(home, '.project-knowledge');
|
|
307
307
|
const packageInfo = readJson(path.join(ROOT, 'package.json'));
|
|
308
308
|
writeBinding(dataDir, { schema: RUNTIME_SCHEMA, packageName: packageInfo.name, packageRoot: ROOT, version: packageInfo.version, updatedAt: new Date().toISOString() });
|
|
309
309
|
const manager = new IntegrationManager({
|
|
@@ -10,7 +10,7 @@ const endpoint = require('../lib/runtime-endpoint');
|
|
|
10
10
|
const packageRoot = process.env.KB_LAUNCHER_TEST_PACKAGE || path.resolve(__dirname, '../..');
|
|
11
11
|
const bin = path.join(packageRoot, 'bin/project-knowledge.js');
|
|
12
12
|
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'kb-launcher-readiness-'));
|
|
13
|
-
const data = path.join(root, '.project-knowledge
|
|
13
|
+
const data = path.join(root, '.project-knowledge');
|
|
14
14
|
const record = path.join(data, 'runtime/claude-sessions/project-a/session.json');
|
|
15
15
|
const recordBytes = JSON.stringify({ schema: 'claude-workbench-session/v1', sessionId: 'old-test', projectSlug: 'project-a', state: 'running', metadata: { automation: true } });
|
|
16
16
|
fs.mkdirSync(path.dirname(record), { recursive: true });
|
|
@@ -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) {
|
package/_site/lib/data-dir.js
CHANGED
|
@@ -5,7 +5,7 @@ const os = require('os');
|
|
|
5
5
|
let resolved = null;
|
|
6
6
|
function resolveDataDirPath(options = {}) {
|
|
7
7
|
const configured = options.dataDir === undefined ? process.env.KB_DATA_DIR : options.dataDir;
|
|
8
|
-
return path.resolve(configured || path.join(options.homeDir || os.homedir(), '.project-knowledge
|
|
8
|
+
return path.resolve(configured || path.join(options.homeDir || os.homedir(), '.project-knowledge'));
|
|
9
9
|
}
|
|
10
10
|
function ensureDataDir(dataDir = resolveDataDirPath()) { fs.mkdirSync(dataDir, { recursive: true }); return path.resolve(dataDir); }
|
|
11
11
|
function getDataDir() { if (!resolved) resolved = resolveDataDirPath(); return resolved; }
|
|
@@ -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
|
@@ -25,7 +25,7 @@ Usage:
|
|
|
25
25
|
|
|
26
26
|
Options:
|
|
27
27
|
-p, --port <port> Port (default: 5757, startup auto-fallback +19)
|
|
28
|
-
--data <dir> Select data directory (default: ~/.project-knowledge
|
|
28
|
+
--data <dir> Select data directory (default: ~/.project-knowledge)
|
|
29
29
|
--host <host> Bind host (default: 127.0.0.1)
|
|
30
30
|
--no-open Do not open browser
|
|
31
31
|
--fg Run in foreground
|
|
@@ -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 });
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"ui/favicon.svg": "c48be946b224112ebb0238b44263f7a61bda31e531afa895c2e9801c0ff24f32",
|
|
10
10
|
"plugins/project-knowledge/hooks/claude.json": "d61510327e3e1facbb4c645228e9f50cad05a88b33d80c4c22e5ba9f8b9f5359",
|
|
11
11
|
"plugins/project-knowledge/hooks/codex.json": "216e03c07295606ef6ebb2c4f669ad0d790b5e7c4f3f34600488033db75e4239",
|
|
12
|
-
"plugins/project-knowledge/scripts/context-hook.cjs": "
|
|
13
|
-
"plugins/project-knowledge/scripts/mcp-launcher.cjs": "
|
|
14
|
-
"plugins/project-knowledge/.claude-plugin/plugin.json": "
|
|
15
|
-
"plugins/project-knowledge/.codex-plugin/plugin.json": "
|
|
16
|
-
"plugins/project-knowledge/.mcp.json": "
|
|
12
|
+
"plugins/project-knowledge/scripts/context-hook.cjs": "12f9120a4503193042eff109da3688e909ef8a0f8409bf38c7f47f6e36941d86",
|
|
13
|
+
"plugins/project-knowledge/scripts/mcp-launcher.cjs": "c9235eaf722ad011ce42d7a8416a77bef8e2a65e174f27b3d183f4b8f811f293",
|
|
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",
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
"command": "node",
|
|
6
6
|
"args": [
|
|
7
7
|
"-e",
|
|
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
|
|
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
|
}
|
|
@@ -29,7 +29,7 @@ function log(dataDir, event, input) {
|
|
|
29
29
|
async function run(payload, { env = process.env, argv = process.argv.slice(2), fetchImpl = fetch, timeoutMs = 10000 } = {}) {
|
|
30
30
|
if (env.KB_KNOWLEDGE_CONTEXT === '0' || !payload || payload.hook_event_name !== 'UserPromptSubmit') return {};
|
|
31
31
|
const client = clientFrom(argv), requestId = `context-${crypto.randomUUID()}`, started = Date.now();
|
|
32
|
-
const dataDir = path.resolve(env.KB_DATA_DIR || path.join(os.homedir(), '.project-knowledge
|
|
32
|
+
const dataDir = path.resolve(env.KB_DATA_DIR || path.join(os.homedir(), '.project-knowledge'));
|
|
33
33
|
if (typeof payload.cwd !== 'string' || !path.isAbsolute(payload.cwd) || typeof payload.prompt !== 'string' || !payload.prompt.trim() || payload.prompt.length > 131072) return {};
|
|
34
34
|
const controller = new AbortController(), timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
35
35
|
let result;
|
|
@@ -32,7 +32,7 @@ function fail(code) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function bindingPath() {
|
|
35
|
-
return path.join(process.env.KB_DATA_DIR || path.join(os.homedir(), '.project-knowledge
|
|
35
|
+
return path.join(process.env.KB_DATA_DIR || path.join(os.homedir(), '.project-knowledge'), 'integration-runtime.json');
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function loadBinding() {
|