@sanqianx/project-knowledge 5.0.19 → 5.0.20
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/.agents/plugins/marketplace.json +3 -3
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +5 -0
- package/LICENSE +201 -201
- package/NOTICE +5 -5
- package/README.md +349 -349
- package/_modules/knowledge-engine/README.md +4 -0
- package/_modules/knowledge-engine/src/analysis-failures.js +39 -0
- package/_modules/knowledge-engine/src/analysis-worker.js +6 -2
- package/_modules/knowledge-engine/src/coordinator.js +7 -0
- package/_modules/knowledge-engine/src/headless-analyzer.js +2 -1
- package/_modules/knowledge-engine/src/server.js +1 -1
- package/_site/_test/agent-capture-mcp-ui-test.js +67 -67
- package/_site/_test/ai-profile-test.js +75 -75
- package/_site/_test/ai-vendor-presets-test.js +91 -91
- package/_site/_test/automatic-context-test.js +70 -70
- package/_site/_test/bin-cli-test.js +230 -230
- package/_site/_test/bridge-adapter-test.js +95 -95
- package/_site/_test/bridge-consumer-service-test.js +310 -310
- package/_site/_test/candidate-bin-content-test.js +35 -35
- package/_site/_test/candidate-product-assets-test.js +13 -13
- package/_site/_test/candidate-release-contract-test.js +14 -14
- package/_site/_test/capture-hook-dedup-test.js +158 -158
- package/_site/_test/claude-executable-discovery-test.js +28 -28
- package/_site/_test/claude-session-lifecycle-sweep-test.js +252 -252
- package/_site/_test/cli-instance-management-test.js +62 -62
- package/_site/_test/client-capture-restart-e2e-test.js +189 -189
- package/_site/_test/codex-conversation-projection-test.js +60 -60
- package/_site/_test/codex-marketplace-scoped-path-test.js +186 -186
- package/_site/_test/codex-notify-capture-e2e-test.js +101 -101
- package/_site/_test/codex-notify-fanout-test.js +134 -134
- package/_site/_test/codex-notify-upgrade-test.js +253 -253
- package/_site/_test/commit-boundary-freeze-test.js +147 -147
- package/_site/_test/commit-conversation-binding-test.js +4 -4
- package/_site/_test/configuration-generation-test.js +22 -22
- package/_site/_test/context-pack-test.js +200 -200
- package/_site/_test/conversation-api-test.js +10 -10
- package/_site/_test/conversation-origin-test.js +15 -15
- package/_site/_test/cross-repo-isolation-e2e-test.js +187 -187
- package/_site/_test/embedding-config-test.js +32 -32
- package/_site/_test/fixtures/fake-browser-exit.js +10 -10
- package/_site/_test/fixtures/fake-browser-hang.js +10 -10
- package/_site/_test/fixtures/integration-busy-worker.cjs +6 -6
- package/_site/_test/fixtures/make-git-repos.js +92 -92
- package/_site/_test/fixtures/retrieval-gold-queries.json +32 -32
- package/_site/_test/fresh-hook-reimport-test.js +53 -53
- package/_site/_test/fresh-product-data-test.js +56 -56
- package/_site/_test/git-path-compatibility-test.js +80 -80
- package/_site/_test/git-validation-test.js +81 -81
- package/_site/_test/hook-worktree-test.js +42 -42
- package/_site/_test/index-builder-test.js +41 -41
- package/_site/_test/index-error-display-contract-test.js +10 -10
- package/_site/_test/integration-adapters-test.js +67 -67
- package/_site/_test/integration-capture-setup-test.js +118 -118
- package/_site/_test/integration-runtime-binding-a2-test.js +566 -566
- package/_site/_test/integration-runtime-binding-a3-test.js +227 -227
- package/_site/_test/integration-runtime-binding-test.js +473 -473
- package/_site/_test/integration-status-scan-test.js +29 -29
- package/_site/_test/kb-framework-test.js +57 -57
- package/_site/_test/kbpath-follow-test.js +63 -63
- package/_site/_test/knowledge-db-test.js +144 -144
- package/_site/_test/knowledge-engine-client-test.js +109 -109
- package/_site/_test/knowledge-maintenance-test.js +40 -40
- package/_site/_test/knowledge-panel-ui-contract-test.js +112 -0
- package/_site/_test/knowledge-scopes-test.js +37 -37
- package/_site/_test/knowledge-storage-location-test.js +28 -28
- package/_site/_test/launcher-readiness-test.js +80 -80
- package/_site/_test/legacy-claude-session-alias-test.js +106 -106
- package/_site/_test/legacy-routes-removed-test.js +47 -47
- package/_site/_test/legacy-workbench-exclusion-test.js +92 -92
- package/_site/_test/live-gateway-test.js +48 -48
- package/_site/_test/local-marketplace-test.js +16 -16
- package/_site/_test/log-redaction-test.js +58 -58
- package/_site/_test/markdown-maintenance-test.js +11 -11
- package/_site/_test/model-context-windows-test.js +89 -89
- package/_site/_test/module-agent-start-proxy-test.js +65 -65
- package/_site/_test/module-artifact-integrity-test.js +27 -27
- package/_site/_test/module-boundary-test.js +30 -30
- package/_site/_test/module-bridge-eventbridge-test.js +202 -202
- package/_site/_test/module-dynamic-port-test.js +118 -118
- package/_site/_test/module-index-proxy-test.js +33 -33
- package/_site/_test/module-model-configuration-test.js +44 -44
- package/_site/_test/module-process-lifecycle-test.js +35 -35
- package/_site/_test/module-stream-proxy-test.js +34 -34
- package/_site/_test/module-terminal-restart-test.js +63 -63
- package/_site/_test/module-wiring-unbind-race-test.js +59 -59
- package/_site/_test/native-context-integrations-test.js +86 -86
- package/_site/_test/orphaned-claim-recovery-test.js +80 -80
- package/_site/_test/package-boundary-test.js +43 -42
- package/_site/_test/package-startup-test.js +56 -56
- package/_site/_test/packaged-ui-smoke-test.js +88 -88
- package/_site/_test/pr-consumer-contract-test.js +55 -55
- package/_site/_test/product-brand-contract-test.js +25 -25
- package/_site/_test/product-diagnostics-ui-test.js +93 -93
- package/_site/_test/product-import-ui-test.js +104 -104
- package/_site/_test/product-progress-status-test.js +12 -1
- package/_site/_test/project-remove-running-guard-test.js +79 -79
- package/_site/_test/project-store-test.js +90 -90
- package/_site/_test/registry-events-test.js +38 -38
- package/_site/_test/release-version-sync-test.js +115 -115
- package/_site/_test/requirement-binding-test.js +113 -113
- package/_site/_test/runtime-endpoint-test.js +64 -64
- package/_site/_test/scanner-test.js +83 -83
- package/_site/_test/server-security-test.js +96 -96
- package/_site/_test/sessions-stream-test.js +93 -93
- package/_site/_test/shared-scope-root-binding-test.js +67 -67
- package/_site/_test/simple-import-test.js +98 -98
- package/_site/_test/startup-analysis-disabled-test.js +6 -6
- package/_site/_test/team-knowledge-store-sparse-checkout-test.js +196 -196
- package/_site/_test/team-knowledge-store-test.js +132 -132
- package/_site/_test/test-server-cleanup-test.js +35 -35
- package/_site/_test/test-server-module-isolation-test.js +37 -37
- package/_site/_test/tracking-start-test.js +35 -35
- package/_site/_test/workbench-context-receipts-test.js +22 -22
- package/_site/_test/workspace-ui-contract-test.js +31 -31
- package/_site/_test/zcode-capture-integration-test.js +108 -108
- package/_site/lib/ai-vendor-presets.js +83 -83
- package/_site/lib/ai-workspace.js +3 -3
- package/_site/lib/atomic-file.js +204 -204
- package/_site/lib/bridge-adapter.js +260 -260
- package/_site/lib/capture-hook-config.js +108 -108
- package/_site/lib/claude-cli-runner.js +89 -89
- package/_site/lib/cli-instances.js +43 -43
- package/_site/lib/codex-context-status.js +17 -17
- package/_site/lib/codex-notify-config.js +193 -193
- package/_site/lib/commit-conversation-binder.js +12 -12
- package/_site/lib/commit-reconciler.js +38 -38
- package/_site/lib/context-pack-builder.js +299 -299
- package/_site/lib/conversation-exclusions.js +204 -204
- package/_site/lib/conversation-query-service.js +17 -17
- package/_site/lib/data-dir.js +13 -13
- package/_site/lib/embedding-service.js +85 -85
- package/_site/lib/engine-connection.js +93 -93
- package/_site/lib/engine-knowledge-client.js +72 -72
- package/_site/lib/folder-picker-output.js +3 -3
- package/_site/lib/git-path.js +14 -14
- package/_site/lib/github-team-store.js +3 -3
- package/_site/lib/index-builder.js +157 -157
- package/_site/lib/integration-status-scan.js +99 -99
- package/_site/lib/integration-status-worker.js +14 -14
- package/_site/lib/kb-framework.js +15 -15
- package/_site/lib/knowledge-db.js +363 -363
- package/_site/lib/knowledge-schema.js +121 -121
- package/_site/lib/live-gateway.js +78 -78
- package/_site/lib/llm-client.js +12 -12
- package/_site/lib/model-context-windows.js +82 -82
- package/_site/lib/module-bridge.js +874 -874
- package/_site/lib/module-port-resolver.js +57 -57
- package/_site/lib/post-commit-automation.js +54 -54
- package/_site/lib/product-data.js +35 -35
- package/_site/lib/project-lifecycle-service.js +14 -14
- package/_site/lib/project-registry-store.js +129 -129
- package/_site/lib/prompt-registry.js +148 -148
- package/_site/lib/registry-events.js +16 -16
- package/_site/lib/requirement-adapters.js +10 -10
- package/_site/lib/requirement-binder.js +112 -112
- package/_site/lib/runtime-control.js +89 -89
- package/_site/lib/runtime-endpoint.js +5 -5
- package/_site/lib/zcode-context-integration.js +60 -60
- package/_site/scripts/codex-notify-fanout.cjs +95 -95
- package/_site/scripts/install-module-candidates.js +69 -69
- package/_site/scripts/pack-module-candidates.js +89 -89
- package/_site/scripts/sync-product-content.js +28 -28
- package/_site/scripts/sync-release-version.js +164 -164
- package/_site/scripts/vendor-modules.js +49 -49
- package/_site/scripts/verify-module-runtime.js +50 -50
- package/_site/scripts/verify-product-runtime.js +36 -36
- package/_site/scripts/verify-retrieval-gold.js +83 -83
- package/_site/server.js +15 -15
- package/_site/start.bat +26 -26
- package/_site/stop.bat +11 -11
- package/bin/project-knowledge-integrations.js +254 -254
- package/bin/project-knowledge-kb.js +67 -67
- package/bin/project-knowledge-mcp.js +8 -8
- package/bin/project-knowledge.js +170 -170
- package/claude-prompts.json +21 -21
- package/docs/README.zh-CN.md +205 -205
- package/docs/assets/architecture.svg +181 -181
- package/docs/assets/logo.svg +49 -49
- package/docs/fresh-v5-start.md +42 -42
- package/docs/leader-glm-workbench-playbook.md +122 -122
- package/docs/project-registry-schema.md +11 -11
- package/docs/release-5.0.16-acceptance.md +176 -176
- package/docs/release-5.0.17-acceptance.md +117 -117
- package/docs/release-5.0.19-acceptance.md +39 -25
- package/docs/team-knowledge-mode-a-plan.md +73 -73
- package/module-runtime-manifest.json +53 -33
- package/package.json +3 -2
- 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/plugins/project-knowledge/opencode/project-knowledge.md +3 -3
- package/plugins/project-knowledge/skills/project-knowledge/SKILL.md +28 -28
- package/templates/change.md +30 -30
- package/templates/project-readme.md +18 -18
- package/ui/index.html +1 -1
- package/ui/knowledge-panel.html +118 -0
- package/ui/product.css +8 -0
- package/ui/product.js +146 -4
- package/vendor-manifest.json +55 -54
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
// Run: node _site/_test/requirement-binding-test.js
|
|
2
|
-
|
|
3
|
-
const assert = require('assert');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const os = require('os');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
const { SCHEMAS } = require('../lib/contracts');
|
|
8
|
-
const { StorageLayout } = require('../lib/storage-layout');
|
|
9
|
-
const { ProjectRegistryStore } = require('../lib/project-registry-store');
|
|
10
|
-
const { ProjectStore } = require('../lib/project-store');
|
|
11
|
-
const { RequirementBinder } = require('../lib/requirement-binder');
|
|
12
|
-
|
|
13
|
-
const temp = fs.mkdtempSync(path.join(os.tmpdir(), `kb-requirement-binding-${process.pid}-`));
|
|
14
|
-
const layout = new StorageLayout({ dataDir: path.join(temp, 'data') });
|
|
15
|
-
const registry = new ProjectRegistryStore({ layout });
|
|
16
|
-
const projects = new ProjectStore({ layout });
|
|
17
|
-
const commit = 'c'.repeat(40);
|
|
18
|
-
|
|
19
|
-
function record(id, projectId, sessionId, head, options = {}) {
|
|
20
|
-
return {
|
|
21
|
-
schema: SCHEMAS.requirement,
|
|
22
|
-
id,
|
|
23
|
-
ts: options.ts || '2026-08-17T00:00:00.000Z',
|
|
24
|
-
projectId,
|
|
25
|
-
client: options.client || 'codex',
|
|
26
|
-
sessionId,
|
|
27
|
-
conversationId: null,
|
|
28
|
-
branch: options.branch || 'main',
|
|
29
|
-
headAtRecord: head,
|
|
30
|
-
requirement: `Requirement ${id}`,
|
|
31
|
-
requirementHash: `sha256:${id}`,
|
|
32
|
-
explicitCommit: options.explicitCommit || null,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
(async () => {
|
|
37
|
-
await registry.initialize();
|
|
38
|
-
for (const projectId of ['project-a', 'project-b']) {
|
|
39
|
-
const repoPath = path.join(temp, projectId);
|
|
40
|
-
fs.mkdirSync(repoPath, { recursive: true });
|
|
41
|
-
await projects.create(projectId, {
|
|
42
|
-
storageName: projectId,
|
|
43
|
-
displayName: projectId,
|
|
44
|
-
repoPath,
|
|
45
|
-
knowledgePath: path.join(temp, 'knowledge', projectId),
|
|
46
|
-
});
|
|
47
|
-
await registry.add(projectId, { displayName: projectId });
|
|
48
|
-
}
|
|
49
|
-
await projects.appendRequirement('project-a', record('req-a1', 'project-a', 'session-one', 'a'.repeat(40), { ts: '2026-08-17T00:00:01.000Z' }));
|
|
50
|
-
await projects.appendRequirement('project-a', record('req-a2', 'project-a', 'session-one', 'b'.repeat(40), { ts: '2026-08-17T00:00:02.000Z' }));
|
|
51
|
-
await projects.appendRequirement('project-a', record('req-a3', 'project-a', 'session-two', 'd'.repeat(40)));
|
|
52
|
-
await projects.appendRequirement('project-a', record('req-branch', 'project-a', 'session-one', 'e'.repeat(40), { branch: 'feature' }));
|
|
53
|
-
await projects.appendRequirement('project-a', record('req-future', 'project-a', 'session-one', 'f'.repeat(40)));
|
|
54
|
-
await projects.appendRequirement('project-a', record('req-explicit-commit', 'project-a', 'session-three', '9'.repeat(40), { explicitCommit: '8'.repeat(40) }));
|
|
55
|
-
await projects.appendRequirement('project-b', record('req-other-project', 'project-b', 'session-one', 'a'.repeat(40)));
|
|
56
|
-
|
|
57
|
-
const ancestry = new Set(['a'.repeat(40), 'b'.repeat(40), 'd'.repeat(40), 'e'.repeat(40)]);
|
|
58
|
-
const binder = new RequirementBinder({
|
|
59
|
-
layout,
|
|
60
|
-
registryStore: registry,
|
|
61
|
-
projectStore: projects,
|
|
62
|
-
gitReader: { isAncestor: async (_repoPath, headAtRecord, target) => target === commit && ancestry.has(headAtRecord) },
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const sameSession = await binder.bind({ projectId: 'project-a', commitSha: commit, branch: 'main', client: 'codex', sessionId: 'session-one' });
|
|
66
|
-
assert.deepStrictEqual(sameSession.requirementIds, ['req-a1', 'req-a2'], 'same session and ancestry should bind its ordered unclaimed sequence');
|
|
67
|
-
assert.strictEqual(sameSession.requirementBinding, 'session-ancestry');
|
|
68
|
-
|
|
69
|
-
const ambiguous = await binder.bind({ projectId: 'project-a', commitSha: commit, branch: 'main' });
|
|
70
|
-
assert.strictEqual(ambiguous.requirementBinding, 'unavailable');
|
|
71
|
-
assert.strictEqual(ambiguous.reason, 'ambiguous-sessions', 'multiple candidate sessions must never use most-recent guessing');
|
|
72
|
-
|
|
73
|
-
const wrongSession = await binder.bind({ projectId: 'project-a', commitSha: commit, branch: 'main', client: 'codex', sessionId: 'unknown' });
|
|
74
|
-
assert.strictEqual(wrongSession.reason, 'no-reliable-requirement');
|
|
75
|
-
const changedBranch = await binder.bind({ projectId: 'project-a', commitSha: commit, branch: 'release', client: 'codex', sessionId: 'session-one' });
|
|
76
|
-
assert.strictEqual(changedBranch.requirementBinding, 'unavailable', 'branch changes should lower confidence to unavailable');
|
|
77
|
-
|
|
78
|
-
const explicit = await binder.bind({ projectId: 'project-a', commitSha: commit, requirementId: 'req-a1' });
|
|
79
|
-
assert.deepStrictEqual(explicit.requirementIds, ['req-a1']);
|
|
80
|
-
assert.strictEqual(explicit.requirementBinding, 'explicit');
|
|
81
|
-
await assert.rejects(
|
|
82
|
-
binder.bind({ projectId: 'project-a', commitSha: commit, requirementId: 'req-other-project' }),
|
|
83
|
-
error => error.code === 'INVALID_ARGUMENT' && /different project/.test(error.message),
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
const unclaimed = await binder.bind({
|
|
87
|
-
projectId: 'project-a', commitSha: commit, branch: 'main', client: 'codex', sessionId: 'session-one', claimedRequirementIds: ['req-a1'],
|
|
88
|
-
});
|
|
89
|
-
assert.deepStrictEqual(unclaimed.requirementIds, ['req-a2'], 'already advanced requirements should be excluded from a later claim');
|
|
90
|
-
|
|
91
|
-
const explicitCommit = await binder.bind({ projectId: 'project-a', commitSha: '8'.repeat(40), branch: 'main' });
|
|
92
|
-
assert.deepStrictEqual(explicitCommit.requirementIds, ['req-explicit-commit']);
|
|
93
|
-
assert.strictEqual(explicitCommit.reason, 'explicit-commit');
|
|
94
|
-
|
|
95
|
-
const claim = {
|
|
96
|
-
schema: SCHEMAS.commitClaim,
|
|
97
|
-
projectId: 'project-a',
|
|
98
|
-
commitSha: commit,
|
|
99
|
-
requirementIds: ['req-a1'],
|
|
100
|
-
requirementBinding: 'session-ancestry',
|
|
101
|
-
};
|
|
102
|
-
await projects.appendRequirement('project-a', record('req-recorded-after-claim', 'project-a', 'session-one', 'a'.repeat(40), { ts: '2026-08-17T00:00:03.000Z' }));
|
|
103
|
-
const retry = await binder.bind({ projectId: 'project-a', commitSha: commit, claim });
|
|
104
|
-
assert.deepStrictEqual(retry.requirementIds, ['req-a1'], 'retry must reuse frozen IDs and ignore future records');
|
|
105
|
-
assert.strictEqual(retry.frozen, true);
|
|
106
|
-
|
|
107
|
-
console.log('requirement-binding-test PASS');
|
|
108
|
-
})().catch(error => {
|
|
109
|
-
console.error(error.stack || error.message);
|
|
110
|
-
process.exitCode = 1;
|
|
111
|
-
}).finally(() => {
|
|
112
|
-
fs.rmSync(temp, { recursive: true, force: true });
|
|
113
|
-
});
|
|
1
|
+
// Run: node _site/_test/requirement-binding-test.js
|
|
2
|
+
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { SCHEMAS } = require('../lib/contracts');
|
|
8
|
+
const { StorageLayout } = require('../lib/storage-layout');
|
|
9
|
+
const { ProjectRegistryStore } = require('../lib/project-registry-store');
|
|
10
|
+
const { ProjectStore } = require('../lib/project-store');
|
|
11
|
+
const { RequirementBinder } = require('../lib/requirement-binder');
|
|
12
|
+
|
|
13
|
+
const temp = fs.mkdtempSync(path.join(os.tmpdir(), `kb-requirement-binding-${process.pid}-`));
|
|
14
|
+
const layout = new StorageLayout({ dataDir: path.join(temp, 'data') });
|
|
15
|
+
const registry = new ProjectRegistryStore({ layout });
|
|
16
|
+
const projects = new ProjectStore({ layout });
|
|
17
|
+
const commit = 'c'.repeat(40);
|
|
18
|
+
|
|
19
|
+
function record(id, projectId, sessionId, head, options = {}) {
|
|
20
|
+
return {
|
|
21
|
+
schema: SCHEMAS.requirement,
|
|
22
|
+
id,
|
|
23
|
+
ts: options.ts || '2026-08-17T00:00:00.000Z',
|
|
24
|
+
projectId,
|
|
25
|
+
client: options.client || 'codex',
|
|
26
|
+
sessionId,
|
|
27
|
+
conversationId: null,
|
|
28
|
+
branch: options.branch || 'main',
|
|
29
|
+
headAtRecord: head,
|
|
30
|
+
requirement: `Requirement ${id}`,
|
|
31
|
+
requirementHash: `sha256:${id}`,
|
|
32
|
+
explicitCommit: options.explicitCommit || null,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
(async () => {
|
|
37
|
+
await registry.initialize();
|
|
38
|
+
for (const projectId of ['project-a', 'project-b']) {
|
|
39
|
+
const repoPath = path.join(temp, projectId);
|
|
40
|
+
fs.mkdirSync(repoPath, { recursive: true });
|
|
41
|
+
await projects.create(projectId, {
|
|
42
|
+
storageName: projectId,
|
|
43
|
+
displayName: projectId,
|
|
44
|
+
repoPath,
|
|
45
|
+
knowledgePath: path.join(temp, 'knowledge', projectId),
|
|
46
|
+
});
|
|
47
|
+
await registry.add(projectId, { displayName: projectId });
|
|
48
|
+
}
|
|
49
|
+
await projects.appendRequirement('project-a', record('req-a1', 'project-a', 'session-one', 'a'.repeat(40), { ts: '2026-08-17T00:00:01.000Z' }));
|
|
50
|
+
await projects.appendRequirement('project-a', record('req-a2', 'project-a', 'session-one', 'b'.repeat(40), { ts: '2026-08-17T00:00:02.000Z' }));
|
|
51
|
+
await projects.appendRequirement('project-a', record('req-a3', 'project-a', 'session-two', 'd'.repeat(40)));
|
|
52
|
+
await projects.appendRequirement('project-a', record('req-branch', 'project-a', 'session-one', 'e'.repeat(40), { branch: 'feature' }));
|
|
53
|
+
await projects.appendRequirement('project-a', record('req-future', 'project-a', 'session-one', 'f'.repeat(40)));
|
|
54
|
+
await projects.appendRequirement('project-a', record('req-explicit-commit', 'project-a', 'session-three', '9'.repeat(40), { explicitCommit: '8'.repeat(40) }));
|
|
55
|
+
await projects.appendRequirement('project-b', record('req-other-project', 'project-b', 'session-one', 'a'.repeat(40)));
|
|
56
|
+
|
|
57
|
+
const ancestry = new Set(['a'.repeat(40), 'b'.repeat(40), 'd'.repeat(40), 'e'.repeat(40)]);
|
|
58
|
+
const binder = new RequirementBinder({
|
|
59
|
+
layout,
|
|
60
|
+
registryStore: registry,
|
|
61
|
+
projectStore: projects,
|
|
62
|
+
gitReader: { isAncestor: async (_repoPath, headAtRecord, target) => target === commit && ancestry.has(headAtRecord) },
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const sameSession = await binder.bind({ projectId: 'project-a', commitSha: commit, branch: 'main', client: 'codex', sessionId: 'session-one' });
|
|
66
|
+
assert.deepStrictEqual(sameSession.requirementIds, ['req-a1', 'req-a2'], 'same session and ancestry should bind its ordered unclaimed sequence');
|
|
67
|
+
assert.strictEqual(sameSession.requirementBinding, 'session-ancestry');
|
|
68
|
+
|
|
69
|
+
const ambiguous = await binder.bind({ projectId: 'project-a', commitSha: commit, branch: 'main' });
|
|
70
|
+
assert.strictEqual(ambiguous.requirementBinding, 'unavailable');
|
|
71
|
+
assert.strictEqual(ambiguous.reason, 'ambiguous-sessions', 'multiple candidate sessions must never use most-recent guessing');
|
|
72
|
+
|
|
73
|
+
const wrongSession = await binder.bind({ projectId: 'project-a', commitSha: commit, branch: 'main', client: 'codex', sessionId: 'unknown' });
|
|
74
|
+
assert.strictEqual(wrongSession.reason, 'no-reliable-requirement');
|
|
75
|
+
const changedBranch = await binder.bind({ projectId: 'project-a', commitSha: commit, branch: 'release', client: 'codex', sessionId: 'session-one' });
|
|
76
|
+
assert.strictEqual(changedBranch.requirementBinding, 'unavailable', 'branch changes should lower confidence to unavailable');
|
|
77
|
+
|
|
78
|
+
const explicit = await binder.bind({ projectId: 'project-a', commitSha: commit, requirementId: 'req-a1' });
|
|
79
|
+
assert.deepStrictEqual(explicit.requirementIds, ['req-a1']);
|
|
80
|
+
assert.strictEqual(explicit.requirementBinding, 'explicit');
|
|
81
|
+
await assert.rejects(
|
|
82
|
+
binder.bind({ projectId: 'project-a', commitSha: commit, requirementId: 'req-other-project' }),
|
|
83
|
+
error => error.code === 'INVALID_ARGUMENT' && /different project/.test(error.message),
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const unclaimed = await binder.bind({
|
|
87
|
+
projectId: 'project-a', commitSha: commit, branch: 'main', client: 'codex', sessionId: 'session-one', claimedRequirementIds: ['req-a1'],
|
|
88
|
+
});
|
|
89
|
+
assert.deepStrictEqual(unclaimed.requirementIds, ['req-a2'], 'already advanced requirements should be excluded from a later claim');
|
|
90
|
+
|
|
91
|
+
const explicitCommit = await binder.bind({ projectId: 'project-a', commitSha: '8'.repeat(40), branch: 'main' });
|
|
92
|
+
assert.deepStrictEqual(explicitCommit.requirementIds, ['req-explicit-commit']);
|
|
93
|
+
assert.strictEqual(explicitCommit.reason, 'explicit-commit');
|
|
94
|
+
|
|
95
|
+
const claim = {
|
|
96
|
+
schema: SCHEMAS.commitClaim,
|
|
97
|
+
projectId: 'project-a',
|
|
98
|
+
commitSha: commit,
|
|
99
|
+
requirementIds: ['req-a1'],
|
|
100
|
+
requirementBinding: 'session-ancestry',
|
|
101
|
+
};
|
|
102
|
+
await projects.appendRequirement('project-a', record('req-recorded-after-claim', 'project-a', 'session-one', 'a'.repeat(40), { ts: '2026-08-17T00:00:03.000Z' }));
|
|
103
|
+
const retry = await binder.bind({ projectId: 'project-a', commitSha: commit, claim });
|
|
104
|
+
assert.deepStrictEqual(retry.requirementIds, ['req-a1'], 'retry must reuse frozen IDs and ignore future records');
|
|
105
|
+
assert.strictEqual(retry.frozen, true);
|
|
106
|
+
|
|
107
|
+
console.log('requirement-binding-test PASS');
|
|
108
|
+
})().catch(error => {
|
|
109
|
+
console.error(error.stack || error.message);
|
|
110
|
+
process.exitCode = 1;
|
|
111
|
+
}).finally(() => {
|
|
112
|
+
fs.rmSync(temp, { recursive: true, force: true });
|
|
113
|
+
});
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
// Run: node _site/_test/runtime-endpoint-test.js
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const os = require('os');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
const runtime = require('../lib/runtime-endpoint');
|
|
7
|
-
|
|
8
|
-
function assert(condition, message) {
|
|
9
|
-
if (!condition) throw new Error(message);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), `kb-runtime-endpoint-${process.pid}-`));
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
assert(runtime.readEndpoint(dataDir) === null, 'missing endpoint should read as null');
|
|
16
|
-
|
|
17
|
-
const written = runtime.writeEndpoint(dataDir, {
|
|
18
|
-
pid: process.pid,
|
|
19
|
-
host: '127.0.0.1',
|
|
20
|
-
port: 5761,
|
|
21
|
-
mode: 'desktop',
|
|
22
|
-
});
|
|
23
|
-
assert(written.schema === runtime.SCHEMA, 'endpoint schema should be current');
|
|
24
|
-
assert(written.mode === 'desktop', 'endpoint should preserve runtime mode');
|
|
25
|
-
assert(runtime.readLiveEndpoint(dataDir).pid === process.pid, 'current process endpoint should be live');
|
|
26
|
-
|
|
27
|
-
runtime.clearEndpoint(dataDir, { pid: process.pid + 1 });
|
|
28
|
-
assert(runtime.readEndpoint(dataDir) !== null, 'a different process must not clear the endpoint');
|
|
29
|
-
runtime.clearEndpoint(dataDir, { pid: process.pid });
|
|
30
|
-
assert(runtime.readEndpoint(dataDir) === null, 'owner should clear the endpoint');
|
|
31
|
-
|
|
32
|
-
const claim = runtime.claimEndpoint(dataDir, {
|
|
33
|
-
pid: process.pid,
|
|
34
|
-
host: '127.0.0.1',
|
|
35
|
-
port: 5762,
|
|
36
|
-
mode: 'cli',
|
|
37
|
-
});
|
|
38
|
-
assert(claim.claimed === true, 'first process should claim an empty endpoint');
|
|
39
|
-
const duplicate = runtime.claimEndpoint(dataDir, {
|
|
40
|
-
pid: process.pid + 1,
|
|
41
|
-
host: '127.0.0.1',
|
|
42
|
-
port: 5763,
|
|
43
|
-
mode: 'desktop',
|
|
44
|
-
});
|
|
45
|
-
assert(duplicate.claimed === false, 'second process must not replace a live endpoint');
|
|
46
|
-
assert(duplicate.endpoint.pid === process.pid, 'duplicate should discover the owner');
|
|
47
|
-
runtime.clearEndpoint(dataDir, { pid: process.pid });
|
|
48
|
-
|
|
49
|
-
runtime.writeEndpoint(dataDir, { pid: 2147483646, host: 'localhost', port: 5757 });
|
|
50
|
-
assert(runtime.readLiveEndpoint(dataDir) === null, 'dead process endpoint should be rejected');
|
|
51
|
-
assert(!fs.existsSync(runtime.endpointPath(dataDir)), 'dead process endpoint should be removed');
|
|
52
|
-
|
|
53
|
-
fs.writeFileSync(runtime.endpointPath(dataDir), JSON.stringify({
|
|
54
|
-
schema: runtime.SCHEMA,
|
|
55
|
-
pid: process.pid,
|
|
56
|
-
host: 'example.com',
|
|
57
|
-
port: 5757,
|
|
58
|
-
}), 'utf-8');
|
|
59
|
-
assert(runtime.readEndpoint(dataDir) === null, 'remote hosts must never be accepted');
|
|
60
|
-
|
|
61
|
-
console.log('runtime-endpoint-test PASS');
|
|
62
|
-
} finally {
|
|
63
|
-
fs.rmSync(dataDir, { recursive: true, force: true });
|
|
64
|
-
}
|
|
1
|
+
// Run: node _site/_test/runtime-endpoint-test.js
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const runtime = require('../lib/runtime-endpoint');
|
|
7
|
+
|
|
8
|
+
function assert(condition, message) {
|
|
9
|
+
if (!condition) throw new Error(message);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), `kb-runtime-endpoint-${process.pid}-`));
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
assert(runtime.readEndpoint(dataDir) === null, 'missing endpoint should read as null');
|
|
16
|
+
|
|
17
|
+
const written = runtime.writeEndpoint(dataDir, {
|
|
18
|
+
pid: process.pid,
|
|
19
|
+
host: '127.0.0.1',
|
|
20
|
+
port: 5761,
|
|
21
|
+
mode: 'desktop',
|
|
22
|
+
});
|
|
23
|
+
assert(written.schema === runtime.SCHEMA, 'endpoint schema should be current');
|
|
24
|
+
assert(written.mode === 'desktop', 'endpoint should preserve runtime mode');
|
|
25
|
+
assert(runtime.readLiveEndpoint(dataDir).pid === process.pid, 'current process endpoint should be live');
|
|
26
|
+
|
|
27
|
+
runtime.clearEndpoint(dataDir, { pid: process.pid + 1 });
|
|
28
|
+
assert(runtime.readEndpoint(dataDir) !== null, 'a different process must not clear the endpoint');
|
|
29
|
+
runtime.clearEndpoint(dataDir, { pid: process.pid });
|
|
30
|
+
assert(runtime.readEndpoint(dataDir) === null, 'owner should clear the endpoint');
|
|
31
|
+
|
|
32
|
+
const claim = runtime.claimEndpoint(dataDir, {
|
|
33
|
+
pid: process.pid,
|
|
34
|
+
host: '127.0.0.1',
|
|
35
|
+
port: 5762,
|
|
36
|
+
mode: 'cli',
|
|
37
|
+
});
|
|
38
|
+
assert(claim.claimed === true, 'first process should claim an empty endpoint');
|
|
39
|
+
const duplicate = runtime.claimEndpoint(dataDir, {
|
|
40
|
+
pid: process.pid + 1,
|
|
41
|
+
host: '127.0.0.1',
|
|
42
|
+
port: 5763,
|
|
43
|
+
mode: 'desktop',
|
|
44
|
+
});
|
|
45
|
+
assert(duplicate.claimed === false, 'second process must not replace a live endpoint');
|
|
46
|
+
assert(duplicate.endpoint.pid === process.pid, 'duplicate should discover the owner');
|
|
47
|
+
runtime.clearEndpoint(dataDir, { pid: process.pid });
|
|
48
|
+
|
|
49
|
+
runtime.writeEndpoint(dataDir, { pid: 2147483646, host: 'localhost', port: 5757 });
|
|
50
|
+
assert(runtime.readLiveEndpoint(dataDir) === null, 'dead process endpoint should be rejected');
|
|
51
|
+
assert(!fs.existsSync(runtime.endpointPath(dataDir)), 'dead process endpoint should be removed');
|
|
52
|
+
|
|
53
|
+
fs.writeFileSync(runtime.endpointPath(dataDir), JSON.stringify({
|
|
54
|
+
schema: runtime.SCHEMA,
|
|
55
|
+
pid: process.pid,
|
|
56
|
+
host: 'example.com',
|
|
57
|
+
port: 5757,
|
|
58
|
+
}), 'utf-8');
|
|
59
|
+
assert(runtime.readEndpoint(dataDir) === null, 'remote hosts must never be accepted');
|
|
60
|
+
|
|
61
|
+
console.log('runtime-endpoint-test PASS');
|
|
62
|
+
} finally {
|
|
63
|
+
fs.rmSync(dataDir, { recursive: true, force: true });
|
|
64
|
+
}
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
// Run: node _site/_test/scanner-test.js
|
|
2
|
-
|
|
3
|
-
const assert = require('assert');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const os = require('os');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
const { spawnSync } = require('child_process');
|
|
8
|
-
const { CommitScanner, scanProject } = require('../lib/scanner');
|
|
9
|
-
|
|
10
|
-
const temp = fs.mkdtempSync(path.join(os.tmpdir(), `kb-scanner-${process.pid}-`));
|
|
11
|
-
|
|
12
|
-
function git(repo, args) {
|
|
13
|
-
const result = spawnSync('git', ['-C', repo, ...args], { encoding: 'utf8', windowsHide: true });
|
|
14
|
-
if (result.status !== 0) throw new Error(result.stderr || `git ${args.join(' ')} failed`);
|
|
15
|
-
return String(result.stdout || '').trim();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function initRepo(name) {
|
|
19
|
-
const repo = path.join(temp, name);
|
|
20
|
-
fs.mkdirSync(repo, { recursive: true });
|
|
21
|
-
git(repo, ['init', '--initial-branch=main']);
|
|
22
|
-
git(repo, ['config', 'user.email', 'scanner@example.test']);
|
|
23
|
-
git(repo, ['config', 'user.name', 'Scanner Test']);
|
|
24
|
-
return repo;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function commit(repo, index) {
|
|
28
|
-
fs.writeFileSync(path.join(repo, `${index}.txt`), `${index}\n`, 'utf8');
|
|
29
|
-
git(repo, ['add', `${index}.txt`]);
|
|
30
|
-
git(repo, ['commit', '-m', `commit ${index}`]);
|
|
31
|
-
return git(repo, ['rev-parse', 'HEAD']);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
(async () => {
|
|
35
|
-
const scanner = new CommitScanner({ batchSize: 2 });
|
|
36
|
-
const emptyRepo = initRepo('empty');
|
|
37
|
-
const empty = await scanner.scan({ repoPath: emptyRepo }, { trackingMode: 'normal', trackingStartCommit: null, lastAnalyzedCommit: null });
|
|
38
|
-
assert.strictEqual(empty.status, 'empty-repo');
|
|
39
|
-
assert.deepStrictEqual(empty.commits, []);
|
|
40
|
-
|
|
41
|
-
const repo = initRepo('multi');
|
|
42
|
-
const importedHead = commit(repo, 1);
|
|
43
|
-
const initial = await scanner.scan({ repoPath: repo }, { trackingMode: 'normal', trackingStartCommit: null, lastAnalyzedCommit: null });
|
|
44
|
-
assert.strictEqual(initial.status, 'establish-tracking');
|
|
45
|
-
assert.strictEqual(initial.head, importedHead);
|
|
46
|
-
assert.strictEqual(initial.commits.length, 0, 'pre-import history must not be analyzed');
|
|
47
|
-
|
|
48
|
-
const second = commit(repo, 2);
|
|
49
|
-
const third = commit(repo, 3);
|
|
50
|
-
const fourth = commit(repo, 4);
|
|
51
|
-
const pending = await scanner.scan({ repoPath: repo }, { trackingMode: 'normal', trackingStartCommit: importedHead, lastAnalyzedCommit: null });
|
|
52
|
-
assert.deepStrictEqual(pending.commits, [second, third]);
|
|
53
|
-
assert.strictEqual(pending.pendingCount, 3);
|
|
54
|
-
assert.deepStrictEqual(pending.continuation, { remaining: 1, after: third });
|
|
55
|
-
|
|
56
|
-
const next = await scanner.scan({ repoPath: repo }, { trackingMode: 'normal', trackingStartCommit: importedHead, lastAnalyzedCommit: third });
|
|
57
|
-
assert.deepStrictEqual(next.commits, [fourth], 'lastAnalyzedCommit must take priority over trackingStartCommit');
|
|
58
|
-
assert.strictEqual(next.continuation, null);
|
|
59
|
-
|
|
60
|
-
const firstAfterEmpty = await scanner.scan({ repoPath: repo }, { trackingMode: 'empty-repo', trackingStartCommit: null, lastAnalyzedCommit: null });
|
|
61
|
-
assert.deepStrictEqual(firstAfterEmpty.commits, [importedHead, second], 'empty-repo mode should start with the root commit and expose continuation');
|
|
62
|
-
|
|
63
|
-
const legacyView = await scanProject({ slug: 'legacy-view', gitPath: repo, trackingStartCommit: importedHead }, { batchSize: 10 });
|
|
64
|
-
assert.strictEqual(legacyView.repoStatus, 'ok');
|
|
65
|
-
assert.deepStrictEqual(legacyView.commits.map(item => item.hash), [second, third, fourth]);
|
|
66
|
-
|
|
67
|
-
const tree = git(repo, ['write-tree']);
|
|
68
|
-
const rewritten = git(repo, ['commit-tree', tree, '-m', 'rewritten']);
|
|
69
|
-
git(repo, ['update-ref', 'refs/heads/main', rewritten]);
|
|
70
|
-
const diverged = await scanner.scan({ repoPath: repo }, { trackingMode: 'normal', trackingStartCommit: importedHead, lastAnalyzedCommit: null });
|
|
71
|
-
assert.strictEqual(diverged.status, 'history-diverged');
|
|
72
|
-
assert.strictEqual(diverged.head, rewritten);
|
|
73
|
-
assert.deepStrictEqual(diverged.commits, []);
|
|
74
|
-
|
|
75
|
-
const missing = await scanner.scan({ repoPath: path.join(temp, 'missing') }, { trackingMode: 'normal' });
|
|
76
|
-
assert.strictEqual(missing.status, 'not-git');
|
|
77
|
-
console.log('scanner-test PASS');
|
|
78
|
-
})().catch(error => {
|
|
79
|
-
console.error(error.stack || error.message);
|
|
80
|
-
process.exitCode = 1;
|
|
81
|
-
}).finally(() => {
|
|
82
|
-
fs.rmSync(temp, { recursive: true, force: true });
|
|
83
|
-
});
|
|
1
|
+
// Run: node _site/_test/scanner-test.js
|
|
2
|
+
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { spawnSync } = require('child_process');
|
|
8
|
+
const { CommitScanner, scanProject } = require('../lib/scanner');
|
|
9
|
+
|
|
10
|
+
const temp = fs.mkdtempSync(path.join(os.tmpdir(), `kb-scanner-${process.pid}-`));
|
|
11
|
+
|
|
12
|
+
function git(repo, args) {
|
|
13
|
+
const result = spawnSync('git', ['-C', repo, ...args], { encoding: 'utf8', windowsHide: true });
|
|
14
|
+
if (result.status !== 0) throw new Error(result.stderr || `git ${args.join(' ')} failed`);
|
|
15
|
+
return String(result.stdout || '').trim();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function initRepo(name) {
|
|
19
|
+
const repo = path.join(temp, name);
|
|
20
|
+
fs.mkdirSync(repo, { recursive: true });
|
|
21
|
+
git(repo, ['init', '--initial-branch=main']);
|
|
22
|
+
git(repo, ['config', 'user.email', 'scanner@example.test']);
|
|
23
|
+
git(repo, ['config', 'user.name', 'Scanner Test']);
|
|
24
|
+
return repo;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function commit(repo, index) {
|
|
28
|
+
fs.writeFileSync(path.join(repo, `${index}.txt`), `${index}\n`, 'utf8');
|
|
29
|
+
git(repo, ['add', `${index}.txt`]);
|
|
30
|
+
git(repo, ['commit', '-m', `commit ${index}`]);
|
|
31
|
+
return git(repo, ['rev-parse', 'HEAD']);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
(async () => {
|
|
35
|
+
const scanner = new CommitScanner({ batchSize: 2 });
|
|
36
|
+
const emptyRepo = initRepo('empty');
|
|
37
|
+
const empty = await scanner.scan({ repoPath: emptyRepo }, { trackingMode: 'normal', trackingStartCommit: null, lastAnalyzedCommit: null });
|
|
38
|
+
assert.strictEqual(empty.status, 'empty-repo');
|
|
39
|
+
assert.deepStrictEqual(empty.commits, []);
|
|
40
|
+
|
|
41
|
+
const repo = initRepo('multi');
|
|
42
|
+
const importedHead = commit(repo, 1);
|
|
43
|
+
const initial = await scanner.scan({ repoPath: repo }, { trackingMode: 'normal', trackingStartCommit: null, lastAnalyzedCommit: null });
|
|
44
|
+
assert.strictEqual(initial.status, 'establish-tracking');
|
|
45
|
+
assert.strictEqual(initial.head, importedHead);
|
|
46
|
+
assert.strictEqual(initial.commits.length, 0, 'pre-import history must not be analyzed');
|
|
47
|
+
|
|
48
|
+
const second = commit(repo, 2);
|
|
49
|
+
const third = commit(repo, 3);
|
|
50
|
+
const fourth = commit(repo, 4);
|
|
51
|
+
const pending = await scanner.scan({ repoPath: repo }, { trackingMode: 'normal', trackingStartCommit: importedHead, lastAnalyzedCommit: null });
|
|
52
|
+
assert.deepStrictEqual(pending.commits, [second, third]);
|
|
53
|
+
assert.strictEqual(pending.pendingCount, 3);
|
|
54
|
+
assert.deepStrictEqual(pending.continuation, { remaining: 1, after: third });
|
|
55
|
+
|
|
56
|
+
const next = await scanner.scan({ repoPath: repo }, { trackingMode: 'normal', trackingStartCommit: importedHead, lastAnalyzedCommit: third });
|
|
57
|
+
assert.deepStrictEqual(next.commits, [fourth], 'lastAnalyzedCommit must take priority over trackingStartCommit');
|
|
58
|
+
assert.strictEqual(next.continuation, null);
|
|
59
|
+
|
|
60
|
+
const firstAfterEmpty = await scanner.scan({ repoPath: repo }, { trackingMode: 'empty-repo', trackingStartCommit: null, lastAnalyzedCommit: null });
|
|
61
|
+
assert.deepStrictEqual(firstAfterEmpty.commits, [importedHead, second], 'empty-repo mode should start with the root commit and expose continuation');
|
|
62
|
+
|
|
63
|
+
const legacyView = await scanProject({ slug: 'legacy-view', gitPath: repo, trackingStartCommit: importedHead }, { batchSize: 10 });
|
|
64
|
+
assert.strictEqual(legacyView.repoStatus, 'ok');
|
|
65
|
+
assert.deepStrictEqual(legacyView.commits.map(item => item.hash), [second, third, fourth]);
|
|
66
|
+
|
|
67
|
+
const tree = git(repo, ['write-tree']);
|
|
68
|
+
const rewritten = git(repo, ['commit-tree', tree, '-m', 'rewritten']);
|
|
69
|
+
git(repo, ['update-ref', 'refs/heads/main', rewritten]);
|
|
70
|
+
const diverged = await scanner.scan({ repoPath: repo }, { trackingMode: 'normal', trackingStartCommit: importedHead, lastAnalyzedCommit: null });
|
|
71
|
+
assert.strictEqual(diverged.status, 'history-diverged');
|
|
72
|
+
assert.strictEqual(diverged.head, rewritten);
|
|
73
|
+
assert.deepStrictEqual(diverged.commits, []);
|
|
74
|
+
|
|
75
|
+
const missing = await scanner.scan({ repoPath: path.join(temp, 'missing') }, { trackingMode: 'normal' });
|
|
76
|
+
assert.strictEqual(missing.status, 'not-git');
|
|
77
|
+
console.log('scanner-test PASS');
|
|
78
|
+
})().catch(error => {
|
|
79
|
+
console.error(error.stack || error.message);
|
|
80
|
+
process.exitCode = 1;
|
|
81
|
+
}).finally(() => {
|
|
82
|
+
fs.rmSync(temp, { recursive: true, force: true });
|
|
83
|
+
});
|