@sanqianx/project-knowledge 4.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/.agents/plugins/marketplace.json +20 -0
  2. package/.claude-plugin/marketplace.json +17 -0
  3. package/CHANGELOG.md +780 -0
  4. package/LICENSE +201 -0
  5. package/NOTICE +5 -0
  6. package/README.md +266 -0
  7. package/_site/README.md +30 -0
  8. package/_site/_test/ai-profile-resolver-test.js +137 -0
  9. package/_site/_test/ai-profile-test.js +75 -0
  10. package/_site/_test/ai-vendor-presets-test.js +91 -0
  11. package/_site/_test/automation-queue-test.js +14 -0
  12. package/_site/_test/automation-ui-test.js +40 -0
  13. package/_site/_test/background-task-registry-test.js +43 -0
  14. package/_site/_test/baseline-schema-test.js +91 -0
  15. package/_site/_test/bin-cli-test.js +218 -0
  16. package/_site/_test/bridge-adapter-test.js +95 -0
  17. package/_site/_test/bridge-consumer-service-test.js +310 -0
  18. package/_site/_test/cdp-browser-failure-test.js +100 -0
  19. package/_site/_test/chat-claudecodeui-match-test.js +92 -0
  20. package/_site/_test/claude-executable-discovery-test.js +90 -0
  21. package/_site/_test/claude-session-lifecycle-sweep-test.js +252 -0
  22. package/_site/_test/claude-workbench-test.js +170 -0
  23. package/_site/_test/client-capture-restart-e2e-test.js +189 -0
  24. package/_site/_test/codex-conversation-projection-test.js +59 -0
  25. package/_site/_test/codex-notify-fanout-test.js +45 -0
  26. package/_site/_test/commit-boundary-freeze-test.js +147 -0
  27. package/_site/_test/commit-conversation-binding-test.js +99 -0
  28. package/_site/_test/commit-evidence-test.js +110 -0
  29. package/_site/_test/context-pack-test.js +198 -0
  30. package/_site/_test/conversation-api-test.js +119 -0
  31. package/_site/_test/conversation-store-test.js +136 -0
  32. package/_site/_test/cross-repo-isolation-e2e-test.js +187 -0
  33. package/_site/_test/data-dir-migration-test.js +77 -0
  34. package/_site/_test/desktop-browser-compat-test.js +28 -0
  35. package/_site/_test/desktop-hook-runtime-regression-test.js +204 -0
  36. package/_site/_test/embedding-config-test.js +32 -0
  37. package/_site/_test/explicit-commit-processor-test.js +37 -0
  38. package/_site/_test/fixtures/fake-browser-exit.js +10 -0
  39. package/_site/_test/fixtures/fake-browser-hang.js +10 -0
  40. package/_site/_test/fixtures/make-git-repos.js +89 -0
  41. package/_site/_test/folder-picker-output-test.js +19 -0
  42. package/_site/_test/full-integration-e2e-test.js +165 -0
  43. package/_site/_test/git-validation-test.js +81 -0
  44. package/_site/_test/hook-runtime-endpoint-test.js +88 -0
  45. package/_site/_test/hook-status-repair-api-test.js +152 -0
  46. package/_site/_test/hook-trigger-test.js +85 -0
  47. package/_site/_test/hook-worktree-test.js +42 -0
  48. package/_site/_test/import-preflight-api-test.js +233 -0
  49. package/_site/_test/import-ui-flow-test.js +171 -0
  50. package/_site/_test/index-builder-test.js +41 -0
  51. package/_site/_test/index-writer-concurrency-test.js +135 -0
  52. package/_site/_test/integration-adapters-test.js +243 -0
  53. package/_site/_test/integration-capture-setup-test.js +108 -0
  54. package/_site/_test/integration-surface-coverage-test.js +165 -0
  55. package/_site/_test/kb-framework-test.js +57 -0
  56. package/_site/_test/kbpath-follow-test.js +63 -0
  57. package/_site/_test/knowledge-db-test.js +144 -0
  58. package/_site/_test/knowledge-language-control-test.js +170 -0
  59. package/_site/_test/knowledge-maintenance-test.js +40 -0
  60. package/_site/_test/knowledge-migration-test.js +75 -0
  61. package/_site/_test/knowledge-promotion-recovery-test.js +260 -0
  62. package/_site/_test/knowledge-query-test.js +54 -0
  63. package/_site/_test/knowledge-retrieval-service-test.js +77 -0
  64. package/_site/_test/knowledge-scopes-test.js +37 -0
  65. package/_site/_test/knowledge-storage-location-test.js +28 -0
  66. package/_site/_test/knowledge-storage-startup-test.js +52 -0
  67. package/_site/_test/knowledge-store-logs-supervision-test.js +89 -0
  68. package/_site/_test/legacy-claude-session-alias-test.js +106 -0
  69. package/_site/_test/legacy-forward-compat-test.js +257 -0
  70. package/_site/_test/legacy-project-upgrade-e2e-test.js +363 -0
  71. package/_site/_test/legacy-routes-removed-test.js +47 -0
  72. package/_site/_test/legacy-workbench-exclusion-test.js +92 -0
  73. package/_site/_test/log-redaction-test.js +58 -0
  74. package/_site/_test/logging-api-test.js +89 -0
  75. package/_site/_test/logging-sse-no-gap-test.js +88 -0
  76. package/_site/_test/logging-ui-test.js +104 -0
  77. package/_site/_test/markdown-delta-overlay-test.js +85 -0
  78. package/_site/_test/markdown-maintenance-api-test.js +75 -0
  79. package/_site/_test/markdown-maintenance-test.js +11 -0
  80. package/_site/_test/mcp-server-test.js +149 -0
  81. package/_site/_test/model-context-windows-test.js +89 -0
  82. package/_site/_test/module-bridge-eventbridge-test.js +193 -0
  83. package/_site/_test/non-release-ci-test.js +34 -0
  84. package/_site/_test/offline-boundary-isolation-test.js +32 -0
  85. package/_site/_test/orphaned-claim-recovery-test.js +80 -0
  86. package/_site/_test/p0-data-migration-characterization-test.js +37 -0
  87. package/_site/_test/p0-e2e-gate-test.js +347 -0
  88. package/_site/_test/package-boundary-test.js +42 -0
  89. package/_site/_test/package-startup-test.js +56 -0
  90. package/_site/_test/packaged-ui-smoke-test.js +79 -0
  91. package/_site/_test/path-consistency-test.js +151 -0
  92. package/_site/_test/pending-sweep-test.js +9 -0
  93. package/_site/_test/post-commit-automation-test.js +87 -0
  94. package/_site/_test/pr-consumer-contract-test.js +55 -0
  95. package/_site/_test/project-control-panel-task14-test.js +63 -0
  96. package/_site/_test/project-delete-recovery-test.js +64 -0
  97. package/_site/_test/project-goal-editor-test.js +145 -0
  98. package/_site/_test/project-layout-v2-migration-test.js +127 -0
  99. package/_site/_test/project-lifecycle-transaction-test.js +106 -0
  100. package/_site/_test/project-remove-running-guard-test.js +79 -0
  101. package/_site/_test/project-store-test.js +90 -0
  102. package/_site/_test/prompt-settings-test.js +115 -0
  103. package/_site/_test/protected-architecture-gate-test.js +123 -0
  104. package/_site/_test/refactor-characterization-test.js +36 -0
  105. package/_site/_test/release-version-sync-test.js +98 -0
  106. package/_site/_test/requirement-binding-test.js +113 -0
  107. package/_site/_test/requirement-recorder-test.js +173 -0
  108. package/_site/_test/run-all-tests.js +156 -0
  109. package/_site/_test/runtime-endpoint-test.js +64 -0
  110. package/_site/_test/scanner-test.js +83 -0
  111. package/_site/_test/server-runtime-migration-safety-test.js +27 -0
  112. package/_site/_test/server-security-test.js +96 -0
  113. package/_site/_test/sessions-stream-test.js +92 -0
  114. package/_site/_test/shared-contracts-test.js +58 -0
  115. package/_site/_test/simple-import-test.js +97 -0
  116. package/_site/_test/startup-analysis-disabled-test.js +16 -0
  117. package/_site/_test/storage-foundation-test.js +78 -0
  118. package/_site/_test/structured-logger-test.js +101 -0
  119. package/_site/_test/task15-20-ui-flow-test.js +148 -0
  120. package/_site/_test/team-knowledge-store-sparse-checkout-test.js +196 -0
  121. package/_site/_test/team-knowledge-store-test.js +131 -0
  122. package/_site/_test/tracking-start-test.js +143 -0
  123. package/_site/_test/ui-i18n-toggle-test.js +114 -0
  124. package/_site/_test/ui-smoke-test.js +73 -0
  125. package/_site/_test/v4122-upgrade-data-contract-test.js +56 -0
  126. package/_site/_test/workbench-permission-test.js +118 -0
  127. package/_site/_test/workspace-ui-contract-test.js +43 -0
  128. package/_site/lib/ai-profile-resolver.js +78 -0
  129. package/_site/lib/ai-vendor-presets.js +83 -0
  130. package/_site/lib/ai-workspace.js +104 -0
  131. package/_site/lib/atomic-file.js +204 -0
  132. package/_site/lib/automation-config.js +140 -0
  133. package/_site/lib/bridge-adapter.js +256 -0
  134. package/_site/lib/bridge-consumer-service.js +402 -0
  135. package/_site/lib/claude-cli-runner.js +1599 -0
  136. package/_site/lib/commit-conversation-binder.js +246 -0
  137. package/_site/lib/commit-processing-ledger.js +27 -0
  138. package/_site/lib/commit-prompt.js +202 -0
  139. package/_site/lib/commit-reconciler.js +444 -0
  140. package/_site/lib/context-pack-builder.js +299 -0
  141. package/_site/lib/contracts.js +279 -0
  142. package/_site/lib/conversation-exclusions.js +204 -0
  143. package/_site/lib/conversation-query-service.js +161 -0
  144. package/_site/lib/conversation-store.js +385 -0
  145. package/_site/lib/data-dir.js +81 -0
  146. package/_site/lib/data-state-classifier.js +40 -0
  147. package/_site/lib/embedding-service.js +85 -0
  148. package/_site/lib/evidence-bundle.js +228 -0
  149. package/_site/lib/folder-picker-output.js +24 -0
  150. package/_site/lib/git-runner.js +62 -0
  151. package/_site/lib/github-team-store.js +1175 -0
  152. package/_site/lib/hook-manager.js +202 -0
  153. package/_site/lib/index-builder.js +157 -0
  154. package/_site/lib/index-service.js +173 -0
  155. package/_site/lib/integration-installer.js +907 -0
  156. package/_site/lib/kb-framework.js +191 -0
  157. package/_site/lib/kb-validator.js +124 -0
  158. package/_site/lib/knowledge-db.js +363 -0
  159. package/_site/lib/knowledge-promotion.js +435 -0
  160. package/_site/lib/knowledge-retrieval-service.js +401 -0
  161. package/_site/lib/knowledge-schema.js +121 -0
  162. package/_site/lib/knowledge-tool-runtime.js +359 -0
  163. package/_site/lib/legacy-data-manifest.js +26 -0
  164. package/_site/lib/llm-client.js +173 -0
  165. package/_site/lib/markdown-knowledge-indexer.js +230 -0
  166. package/_site/lib/migration-service.js +442 -0
  167. package/_site/lib/model-context-windows.js +82 -0
  168. package/_site/lib/module-bridge.js +496 -0
  169. package/_site/lib/post-commit-automation.js +141 -0
  170. package/_site/lib/project-lifecycle-service.js +511 -0
  171. package/_site/lib/project-registry-store.js +129 -0
  172. package/_site/lib/project-store.js +262 -0
  173. package/_site/lib/prompt-registry.js +148 -0
  174. package/_site/lib/requirement-adapters.js +10 -0
  175. package/_site/lib/requirement-binder.js +112 -0
  176. package/_site/lib/requirement-recorder.js +278 -0
  177. package/_site/lib/runtime-endpoint.js +160 -0
  178. package/_site/lib/scanner.js +298 -0
  179. package/_site/lib/server-app.js +1520 -0
  180. package/_site/lib/settings-store.js +113 -0
  181. package/_site/lib/storage-layout.js +162 -0
  182. package/_site/lib/structured-logger.js +574 -0
  183. package/_site/scripts/codex-notify-fanout.cjs +51 -0
  184. package/_site/scripts/folder-picker.ps1 +156 -0
  185. package/_site/scripts/hook-trigger.js +156 -0
  186. package/_site/scripts/sync-release-version.js +158 -0
  187. package/_site/server.js +12 -0
  188. package/_site/start.bat +26 -0
  189. package/_site/stop.bat +11 -0
  190. package/bin/project-knowledge-integrations.js +241 -0
  191. package/bin/project-knowledge-kb.js +65 -0
  192. package/bin/project-knowledge-mcp.js +195 -0
  193. package/bin/project-knowledge.js +439 -0
  194. package/claude-prompts.json +21 -0
  195. package/docs/README.zh-CN.md +175 -0
  196. package/docs/assets/architecture.svg +182 -0
  197. package/docs/assets/dashboard.png +0 -0
  198. package/docs/assets/draft-review.png +0 -0
  199. package/docs/assets/logo.svg +50 -0
  200. package/docs/assets/runs-drafts.png +0 -0
  201. package/docs/assets/settings.png +0 -0
  202. package/docs/project-registry-schema.md +33 -0
  203. package/docs/team-knowledge-mode-a-plan.md +73 -0
  204. package/docs/testing-strategy.md +33 -0
  205. package/package.json +100 -0
  206. package/plugins/project-knowledge/.claude-plugin/plugin.json +19 -0
  207. package/plugins/project-knowledge/.codex-plugin/plugin.json +38 -0
  208. package/plugins/project-knowledge/.mcp.json +14 -0
  209. package/plugins/project-knowledge/opencode/project-knowledge.md +3 -0
  210. package/plugins/project-knowledge/skills/project-knowledge/SKILL.md +28 -0
  211. package/plugins/project-knowledge/skills/project-knowledge/agents/openai.yaml +11 -0
  212. package/templates/change.md +30 -0
  213. package/templates/project-readme.md +52 -0
  214. package/ui/app.css +58 -0
  215. package/ui/app.js +607 -0
  216. package/ui/favicon.svg +38 -0
  217. package/ui/i18n.js +146 -0
  218. package/ui/index.html +162 -0
@@ -0,0 +1,89 @@
1
+ const fs = require('fs');
2
+ const os = require('os');
3
+ const path = require('path');
4
+ const { execFileSync } = require('child_process');
5
+
6
+ function parseArgs(input) {
7
+ if (Array.isArray(input)) return input.map(String);
8
+ const out = [];
9
+ const re = /"([^"]*)"|'([^']*)'|(\S+)/g;
10
+ let match;
11
+ while ((match = re.exec(String(input || '')))) {
12
+ out.push(match[1] != null ? match[1] : match[2] != null ? match[2] : match[3]);
13
+ }
14
+ return out;
15
+ }
16
+
17
+ function git(cwd, args) {
18
+ const argv = ['-C', cwd, ...parseArgs(args)];
19
+ return execFileSync('git', argv, { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
20
+ }
21
+
22
+ function write(filePath, content) {
23
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
24
+ fs.writeFileSync(filePath, content);
25
+ }
26
+
27
+ function commit(repoPath, message) {
28
+ git(repoPath, ['add', '.']);
29
+ git(repoPath, ['commit', '-q', '-m', message]);
30
+ const hash = git(repoPath, ['rev-parse', 'HEAD']);
31
+ return {
32
+ hash,
33
+ short: hash.slice(0, 7),
34
+ date: git(repoPath, ['show', '-s', '--format=%ad', '--date=short', 'HEAD']),
35
+ author: git(repoPath, ['show', '-s', '--format=%an', 'HEAD']),
36
+ subject: message,
37
+ };
38
+ }
39
+
40
+ function initRepo(repoPath) {
41
+ git(repoPath, ['init', '-q', '-b', 'main']);
42
+ git(repoPath, ['config', 'user.name', 'Project Knowledge Test']);
43
+ git(repoPath, ['config', 'user.email', 'project-knowledge-test@example.local']);
44
+ git(repoPath, ['config', 'commit.gpgsign', 'false']);
45
+ }
46
+
47
+ function makeRepo({ kind = 'one-commit' } = {}) {
48
+ const repoPath = fs.mkdtempSync(path.join(os.tmpdir(), `kb-fixture-${kind}-${process.pid}-`));
49
+ const commits = [];
50
+ const cleanup = () => fs.rmSync(repoPath, { recursive: true, force: true });
51
+
52
+ if (kind === 'not-git') {
53
+ write(path.join(repoPath, 'README.md'), '# not git\n');
54
+ return { path: repoPath, commits, headCommit: null, cleanup };
55
+ }
56
+
57
+ initRepo(repoPath);
58
+
59
+ if (kind === 'empty') {
60
+ return { path: repoPath, commits, headCommit: null, cleanup };
61
+ }
62
+
63
+ write(path.join(repoPath, 'README.md'), `# ${kind}\n`);
64
+ commits.push(commit(repoPath, 'chore: initial commit'));
65
+
66
+ if (kind === 'one-commit') {
67
+ return { path: repoPath, commits, headCommit: commits[commits.length - 1].hash, cleanup };
68
+ }
69
+
70
+ if (kind === 'feature-commit') {
71
+ write(path.join(repoPath, 'src', 'feature.ts'), 'export const feature = true;\n');
72
+ commits.push(commit(repoPath, 'feat: add feature module'));
73
+ } else if (kind === 'multi-commit') {
74
+ write(path.join(repoPath, 'src', 'a.ts'), 'export const a = 1;\n');
75
+ commits.push(commit(repoPath, 'feat: add a module'));
76
+ write(path.join(repoPath, 'src', 'b.ts'), 'export const b = 2;\n');
77
+ commits.push(commit(repoPath, 'fix: add b module'));
78
+ } else if (kind === 'binary-commit') {
79
+ fs.writeFileSync(path.join(repoPath, 'big.bin'), Buffer.alloc(256 * 1024, 7));
80
+ commits.push(commit(repoPath, 'feat: add binary fixture'));
81
+ } else {
82
+ cleanup();
83
+ throw new Error(`unknown fixture kind: ${kind}`);
84
+ }
85
+
86
+ return { path: repoPath, commits, headCommit: commits[commits.length - 1].hash, cleanup };
87
+ }
88
+
89
+ module.exports = { makeRepo, git };
@@ -0,0 +1,19 @@
1
+ const assert = require('assert');
2
+ const { selectedDirectoryFromOutput } = require('../lib/folder-picker-output');
3
+
4
+ const banner = '������µĿ�ƽ̨ PowerShell https://aka.ms/pscore6';
5
+ assert.equal(selectedDirectoryFromOutput(banner, { exists: () => false }), '',
6
+ 'PowerShell banner text must never be accepted as a selected folder');
7
+
8
+ const folder = 'D:\\work\\project';
9
+ assert.equal(selectedDirectoryFromOutput(`${banner}\r\n${folder}\r\n`, {
10
+ exists: candidate => candidate === folder,
11
+ stat: () => ({ isDirectory: () => true }),
12
+ }), folder, 'the existing absolute directory should be selected from mixed output');
13
+
14
+ assert.equal(selectedDirectoryFromOutput('relative-folder', {
15
+ exists: () => true,
16
+ stat: () => ({ isDirectory: () => true }),
17
+ }), '', 'relative output must not be accepted');
18
+
19
+ console.log('folder-picker-output-test PASS');
@@ -0,0 +1,165 @@
1
+ const assert = require('assert');
2
+ const fs = require('fs');
3
+ const os = require('os');
4
+ const path = require('path');
5
+ const { spawnSync } = require('child_process');
6
+ const { spawnServer } = require('./helpers/spawn-server');
7
+ const { StorageLayout } = require('../lib/storage-layout');
8
+ const { ProjectRegistryStore } = require('../lib/project-registry-store');
9
+ const { ProjectStore } = require('../lib/project-store');
10
+ const { RequirementRecorder } = require('../lib/requirement-recorder');
11
+
12
+ const ROOT = path.resolve(__dirname, '..', '..');
13
+ const PORT = Number(process.env.KB_FULL_E2E_PORT || 7942);
14
+ const BASE_URL = `http://127.0.0.1:${PORT}`;
15
+ const TEMP = fs.mkdtempSync(path.join(os.tmpdir(), `project-knowledge-e2e-${process.pid}-`));
16
+ const DATA_DIR = path.join(TEMP, 'data');
17
+ const REPO = path.join(TEMP, 'repo with 空格');
18
+ const PROJECT_ID = 'project-full-e2e';
19
+ // Git commits fire the managed hook -> hook-trigger -> Bridge journal.
20
+ // Keep that journal inside the test sandbox, never the developer's home.
21
+ const BRIDGE_HOME = path.join(TEMP, 'bridge-home');
22
+
23
+ function git(args, allowFailure = false) {
24
+ const result = spawnSync('git', ['-C', REPO, ...args], {
25
+ encoding: 'utf8', windowsHide: true,
26
+ env: { ...process.env, KB_DATA_DIR: DATA_DIR, KB_SITE_PORT: String(PORT), AI_CODING_EVENT_BRIDGE_HOME: BRIDGE_HOME },
27
+ });
28
+ if (!allowFailure) assert.strictEqual(result.status, 0, result.stderr || result.stdout);
29
+ return { status: result.status, stdout: String(result.stdout || '').trim(), stderr: String(result.stderr || '').trim() };
30
+ }
31
+
32
+ function commit(name, content) {
33
+ fs.writeFileSync(path.join(REPO, `${name}.txt`), `${content}\n`, 'utf8');
34
+ git(['add', `${name}.txt`]);
35
+ git(['commit', '-m', name]);
36
+ return git(['rev-parse', 'HEAD']).stdout;
37
+ }
38
+
39
+ async function json(method, route, body) {
40
+ const response = await fetch(`${BASE_URL}${route}`, {
41
+ method,
42
+ headers: body ? { 'Content-Type': 'application/json' } : undefined,
43
+ body: body ? JSON.stringify(body) : undefined,
44
+ });
45
+ const text = await response.text();
46
+ return { response, body: text ? JSON.parse(text) : {} };
47
+ }
48
+
49
+ async function start() {
50
+ const spawned = spawnServer({
51
+ root: ROOT, port: PORT, dataDir: DATA_DIR, tag: 'full-e2e',
52
+ extraEnv: {
53
+ KB_AUTOMATION_FAKE_CLAUDE: '1', KB_EMBEDDING_FAKE: '1', KB_MAINTENANCE_INTERVAL_MS: '600000',
54
+ AI_CODING_EVENT_BRIDGE_HOME: BRIDGE_HOME,
55
+ },
56
+ });
57
+ let output = '';
58
+ spawned.child.stdout.on('data', chunk => { output += chunk; });
59
+ spawned.child.stderr.on('data', chunk => { output += chunk; });
60
+ for (let attempt = 0; attempt < 150; attempt += 1) {
61
+ try { if ((await fetch(`${BASE_URL}/api/health`)).ok) return { ...spawned, output: () => output }; } catch {}
62
+ if (spawned.child.exitCode != null) throw new Error(`server exited during startup (${spawned.child.exitCode})\n${output}`);
63
+ await new Promise(resolve => setTimeout(resolve, 100));
64
+ }
65
+ throw new Error(`server did not start\n${output}`);
66
+ }
67
+
68
+ async function stop(spawned) {
69
+ if (!spawned || spawned.child.exitCode != null) return;
70
+ const exited = new Promise(resolve => spawned.child.once('exit', resolve));
71
+ spawned.child.kill();
72
+ await Promise.race([exited, new Promise(resolve => setTimeout(resolve, 5000))]);
73
+ }
74
+
75
+ async function waitForState(predicate, label) {
76
+ let last;
77
+ for (let attempt = 0; attempt < 250; attempt += 1) {
78
+ const result = await json('GET', `/api/projects/${PROJECT_ID}`);
79
+ if (result.response.ok) {
80
+ last = result.body.project.state;
81
+ if (predicate(last)) return last;
82
+ }
83
+ await new Promise(resolve => setTimeout(resolve, 100));
84
+ }
85
+ throw new Error(`${label} timed out: ${JSON.stringify(last)}`);
86
+ }
87
+
88
+ (async () => {
89
+ let server;
90
+ fs.mkdirSync(REPO, { recursive: true });
91
+ git(['init', '--initial-branch=main']);
92
+ git(['config', 'user.name', 'Full E2E']);
93
+ git(['config', 'user.email', 'e2e@example.test']);
94
+ commit('baseline', 'baseline before import');
95
+ try {
96
+ server = await start();
97
+ let result = await json('PATCH', '/api/settings', { knowledge: { rootPath: path.join(TEMP, '用户知识') } });
98
+ assert(result.response.ok, JSON.stringify(result.body));
99
+ result = await json('PUT', '/api/ai-profiles', {
100
+ schema: 'ai-profiles/v1',
101
+ defaultProfileId: 'fake-profile',
102
+ profiles: [{ id: 'fake-profile', name: 'Fake', enabled: true, vendor: 'anthropic', model: 'fake', apiKeyUpdate: { mode: 'replace', value: 'fake-key-for-test' } }],
103
+ });
104
+ assert(result.response.ok, JSON.stringify(result.body));
105
+ result = await json('POST', '/api/projects/import', {
106
+ projectId: PROJECT_ID, localPath: REPO, displayName: 'Full E2E', aiProfileId: 'fake-profile', knowledgeLanguage: 'en-US',
107
+ });
108
+ assert.strictEqual(result.response.status, 201, `${JSON.stringify(result.body)}\n${server.output()}`);
109
+ const knowledgePath = result.body.config.knowledgePath;
110
+ assert.deepStrictEqual(fs.readdirSync(knowledgePath), [], 'import must not run AI or generate knowledge');
111
+ assert.strictEqual(result.body.state.lastAnalyzedCommit, null);
112
+ assert.strictEqual(result.body.project.state.hook.managedVersion, 2);
113
+
114
+ const layout = new StorageLayout({ dataDir: DATA_DIR });
115
+ const recorder = new RequirementRecorder({
116
+ layout,
117
+ registryStore: new ProjectRegistryStore({ layout }),
118
+ projectStore: new ProjectStore({ layout }),
119
+ });
120
+ const requirement = await recorder.recordRequirement({
121
+ projectId: PROJECT_ID, repoPath: REPO, client: 'codex', sessionId: 'full-e2e-session',
122
+ text: 'Record the actual post-commit behavior and keep Markdown as the source of truth.',
123
+ });
124
+ assert(requirement.id && fs.existsSync(layout.getProjectConversationEventsPath(PROJECT_ID)));
125
+ assert.strictEqual(fs.existsSync(layout.getProjectRequirementsPath(PROJECT_ID)), false);
126
+
127
+ const onlineCommit = commit('online-change', 'online hook evidence');
128
+ let state = await waitForState(current => current.lastAnalyzedCommit === onlineCommit && current.index.dirty === false, 'online Hook reconciliation');
129
+ assert.strictEqual(state.analysis.activeClaim, null);
130
+ assert(fs.existsSync(path.join(knowledgePath, 'changes', `${onlineCommit.slice(0, 12)}.md`)));
131
+ result = await json('POST', '/api/knowledge/search', { projectId: PROJECT_ID, query: onlineCommit.slice(0, 12), limit: 5 });
132
+ assert(result.response.ok && result.body.results.length > 0, JSON.stringify(result.body));
133
+
134
+ result = await json('GET', `/api/logs?projectId=${PROJECT_ID}&pageSize=500`);
135
+ const onlineEvents = result.body.entries.map(entry => entry.event);
136
+ for (const event of ['reconcile.claim_prepared', 'knowledge.promotion_completed', 'reconcile.commit_completed', 'index.project_applied']) {
137
+ assert(onlineEvents.includes(event), `missing online operation event: ${event}`);
138
+ }
139
+ assert.strictEqual(result.body.entries.filter(entry => entry.event === 'reconcile.claim_prepared' && entry.commitSha === onlineCommit).length, 1, 'Hook/startup overlap must not duplicate one Commit');
140
+
141
+ await stop(server);
142
+ server = null;
143
+ const offlineOne = commit('offline-one', 'first offline change');
144
+ const offlineTwo = commit('offline-two', 'second offline change');
145
+ assert.notStrictEqual(offlineOne, offlineTwo);
146
+ server = await start();
147
+ await new Promise(resolve => setTimeout(resolve, 500));
148
+ result = await json('GET', `/api/projects/${PROJECT_ID}`);
149
+ state = result.body.project.state;
150
+ assert.strictEqual(state.lastAnalyzedCommit, onlineCommit, 'restart must not analyze offline commits');
151
+ assert.strictEqual(fs.existsSync(path.join(knowledgePath, 'changes', `${offlineOne.slice(0, 12)}.md`)), false);
152
+ assert.strictEqual(fs.existsSync(path.join(knowledgePath, 'changes', `${offlineTwo.slice(0, 12)}.md`)), false);
153
+ const onlineAfterRestart = commit('online-after-restart', 'explicit hook after offline commits');
154
+ state = await waitForState(current => current.lastAnalyzedCommit === onlineAfterRestart && current.index.dirty === false, 'explicit online Hook after restart');
155
+ assert.strictEqual(state.analysis.activeClaim, null);
156
+ assert(fs.existsSync(path.join(knowledgePath, 'changes', `${onlineAfterRestart.slice(0, 12)}.md`)));
157
+ result = await json('GET', `/api/logs?projectId=${PROJECT_ID}&pageSize=500`);
158
+ assert.strictEqual(result.body.entries.filter(entry => entry.event === 'reconcile.commit_completed' && entry.commitSha === offlineOne).length, 0);
159
+ assert.strictEqual(result.body.entries.filter(entry => entry.event === 'reconcile.commit_completed' && entry.commitSha === offlineTwo).length, 0);
160
+ assert.strictEqual(result.body.entries.filter(entry => entry.event === 'reconcile.commit_completed' && entry.commitSha === onlineAfterRestart).length, 1);
161
+ console.log('full-integration-e2e-test PASS');
162
+ } finally {
163
+ await stop(server);
164
+ }
165
+ })().catch(error => { console.error(error.stack || error); process.exitCode = 1; });
@@ -0,0 +1,81 @@
1
+ // Git status remains a read-only v2 API; manual validation/state mutation is removed.
2
+ const assert = require('assert');
3
+ const fs = require('fs');
4
+ const os = require('os');
5
+ const path = require('path');
6
+ const { execFileSync } = require('child_process');
7
+ const { spawnServer } = require('./helpers/spawn-server');
8
+ const { makeRepo } = require('./fixtures/make-git-repos');
9
+
10
+ const ROOT = path.resolve(__dirname, '..', '..');
11
+ const DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), `kb-data-git-validation-${process.pid}-`));
12
+ const PORT = Number(process.env.KB_GIT_TEST_PORT || 7792);
13
+ const BASE_URL = `http://127.0.0.1:${PORT}`;
14
+ const PROJECT_ID = 'task-002-temp';
15
+
16
+ async function waitForServer() {
17
+ for (let attempt = 0; attempt < 100; attempt += 1) {
18
+ try { if ((await fetch(`${BASE_URL}/api/health`)).ok) return; } catch {}
19
+ await new Promise(resolve => setTimeout(resolve, 100));
20
+ }
21
+ throw new Error('server did not start');
22
+ }
23
+
24
+ async function json(method, route, body) {
25
+ const response = await fetch(`${BASE_URL}${route}`, {
26
+ method,
27
+ headers: body ? { 'Content-Type': 'application/json' } : undefined,
28
+ body: body ? JSON.stringify(body) : undefined,
29
+ });
30
+ return { response, body: await response.json() };
31
+ }
32
+
33
+ (async () => {
34
+ const repo = makeRepo({ kind: 'one-commit' });
35
+ const spawned = spawnServer({ root: ROOT, port: PORT, dataDir: DATA_DIR, tag: 'git-validation' });
36
+ let output = '';
37
+ spawned.child.stdout.on('data', chunk => { output += chunk; });
38
+ spawned.child.stderr.on('data', chunk => { output += chunk; });
39
+ try {
40
+ await waitForServer();
41
+ let result = await json('PATCH', '/api/settings', { knowledge: { rootPath: path.join(DATA_DIR, 'knowledge') } });
42
+ assert(result.response.ok, JSON.stringify(result.body));
43
+ result = await json('POST', '/api/projects/import', { projectId: PROJECT_ID, localPath: repo.path, displayName: 'Git status fixture' });
44
+ assert(result.response.status === 201, JSON.stringify(result.body));
45
+
46
+ const statePath = path.join(DATA_DIR, 'projects', PROJECT_ID, 'state.json');
47
+ const stateBefore = fs.readFileSync(statePath, 'utf8');
48
+ result = await json('GET', `/api/projects/${PROJECT_ID}/git-status`);
49
+ assert(result.response.ok, JSON.stringify(result.body));
50
+ assert.strictEqual(result.body.repoStatus, 'ok');
51
+ assert.strictEqual(result.body.branch, 'main');
52
+ assert.strictEqual(result.body.dirty, false);
53
+ assert.match(result.body.headCommit, /^[a-f0-9]{40}$/i);
54
+ assert.strictEqual(fs.readFileSync(statePath, 'utf8'), stateBefore, 'read-only status must not mutate project state');
55
+
56
+ fs.writeFileSync(path.join(repo.path, 'untracked.txt'), 'working tree change\n', 'utf8');
57
+ result = await json('GET', `/api/projects/${PROJECT_ID}/git-status`);
58
+ assert.strictEqual(result.body.dirty, true);
59
+ assert(result.body.changes.some(line => line.includes('untracked.txt')));
60
+
61
+ execFileSync('git', ['add', 'untracked.txt'], { cwd: repo.path });
62
+ execFileSync('git', ['commit', '-m', 'status fixture'], { cwd: repo.path });
63
+ result = await json('GET', `/api/projects/${PROJECT_ID}/git-status`);
64
+ assert.strictEqual(result.body.repoStatus, 'ok');
65
+ assert.strictEqual(result.body.dirty, false);
66
+
67
+ result = await json('POST', `/api/projects/${PROJECT_ID}/validate-git`, {});
68
+ assert.strictEqual(result.response.status, 404, 'manual validation route must remain deleted');
69
+ result = await json('GET', '/api/projects/%5Ebad/git-status');
70
+ assert.strictEqual(result.response.status, 400);
71
+ result = await json('GET', '/api/projects/project-missing/git-status');
72
+ assert.strictEqual(result.response.status, 404);
73
+ console.log('TASK-002 git validation test passed');
74
+ } catch (error) {
75
+ if (output) process.stderr.write(output);
76
+ throw error;
77
+ } finally {
78
+ spawned.child.kill();
79
+ repo.cleanup();
80
+ }
81
+ })().catch(error => { console.error(error); process.exitCode = 1; });
@@ -0,0 +1,88 @@
1
+ // Run: node _site/_test/hook-runtime-endpoint-test.js
2
+
3
+ const fs = require('fs');
4
+ const http = require('http');
5
+ const os = require('os');
6
+ const path = require('path');
7
+ const { spawn, spawnSync } = require('child_process');
8
+ const { writeEndpoint } = require('../lib/runtime-endpoint');
9
+
10
+ const ROOT = path.resolve(__dirname, '..', '..');
11
+ const TRIGGER = path.join(ROOT, '_site', 'scripts', 'hook-trigger.js');
12
+ const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), `kb-hook-runtime-${process.pid}-`));
13
+ const repo = fs.mkdtempSync(path.join(os.tmpdir(), `kb-hook-runtime-repo-${process.pid}-`));
14
+
15
+ function assert(condition, message) {
16
+ if (!condition) throw new Error(message);
17
+ }
18
+
19
+ function git(args) {
20
+ return spawnSync('git', ['-C', repo, ...args], { encoding: 'utf-8', windowsHide: true });
21
+ }
22
+
23
+ (async () => {
24
+ git(['init']);
25
+ fs.writeFileSync(path.join(repo, 'README.md'), '# runtime endpoint\n', 'utf-8');
26
+ git(['config', 'user.email', 'runtime@example.test']);
27
+ git(['config', 'user.name', 'Runtime Test']);
28
+ git(['add', 'README.md']);
29
+ git(['commit', '-m', 'test']);
30
+
31
+ let received = null;
32
+ const server = http.createServer((req, res) => {
33
+ let body = '';
34
+ req.setEncoding('utf-8');
35
+ req.on('data', chunk => { body += chunk; });
36
+ req.on('end', () => {
37
+ received = { method: req.method, url: req.url, body: JSON.parse(body) };
38
+ res.writeHead(200, { 'Content-Type': 'application/json' });
39
+ res.end('{}');
40
+ });
41
+ });
42
+ await new Promise((resolve, reject) => {
43
+ server.once('error', reject);
44
+ server.listen(0, '127.0.0.1', resolve);
45
+ });
46
+ const port = server.address().port;
47
+ writeEndpoint(dataDir, { pid: process.pid, host: '127.0.0.1', port, mode: 'desktop' });
48
+ const bridgeJournal = path.join(dataDir, 'bridge-journal.jsonl');
49
+ const bridgeModule = path.join(dataDir, 'bridge-fixture.cjs');
50
+ fs.writeFileSync(bridgeModule, `const fs = require('fs');\nmodule.exports = {\n appendCommitBoundary(input) {\n fs.appendFileSync(process.env.BRIDGE_TEST_JOURNAL, JSON.stringify(input) + '\\n');\n return { sequence: 17, bridgeCursorAtCommit: 17, openTurnIdsAtCommit: ['turn-runtime'] };\n }\n};\n`);
51
+
52
+ const child = spawn(process.execPath, [
53
+ TRIGGER,
54
+ '--project-id', 'project-runtime',
55
+ '--repo-root', repo,
56
+ '--host', '127.0.0.1',
57
+ '--port', '1',
58
+ ], {
59
+ cwd: ROOT,
60
+ windowsHide: true,
61
+ stdio: 'pipe',
62
+ env: { ...process.env, KB_DATA_DIR: dataDir, AI_CODING_EVENT_BRIDGE_MODULE: bridgeModule, BRIDGE_TEST_JOURNAL: bridgeJournal },
63
+ });
64
+ const exitCode = await new Promise(resolve => child.once('exit', resolve));
65
+ assert(exitCode === 0, `hook trigger should exit 0, got ${exitCode}`);
66
+ assert(received, 'hook trigger should use the live runtime endpoint instead of fallback port 1');
67
+ assert(received.method === 'POST' && received.url === '/api/hooks/post-commit', 'unexpected hook request');
68
+ assert(received.body.schema === 'hook-event/v2', 'hook request should use the v2 event schema');
69
+ assert(received.body.projectId === 'project-runtime', 'hook request should contain the stable project id');
70
+ assert(path.resolve(received.body.repoRoot) === path.resolve(repo), 'hook request should contain the runtime repo root');
71
+ assert(received.body.head, 'hook request should contain the current head');
72
+ assert(received.body.branch, 'hook request should contain the current branch');
73
+ assert(received.body.operationId && received.body.operationId.startsWith('op-'), 'Hook boundary operation id should propagate to notification');
74
+ assert(received.body.boundary && received.body.boundary.status === 'captured', 'Hook must append the Bridge boundary before notifying the server');
75
+ assert(received.body.boundary.boundary.bridgeCursorAtCommit === 17, 'Hook must forward the atomic Bridge cursor receipt');
76
+ const durableBoundary = JSON.parse(fs.readFileSync(bridgeJournal, 'utf8').trim());
77
+ assert(durableBoundary.commitSha === received.body.head, 'durable Bridge boundary and Hook payload must reference the same commit');
78
+
79
+ await new Promise(resolve => server.close(resolve));
80
+ fs.rmSync(dataDir, { recursive: true, force: true });
81
+ fs.rmSync(repo, { recursive: true, force: true });
82
+ console.log('hook-runtime-endpoint-test PASS');
83
+ })().catch(error => {
84
+ console.error(error && error.stack || error);
85
+ fs.rmSync(dataDir, { recursive: true, force: true });
86
+ fs.rmSync(repo, { recursive: true, force: true });
87
+ process.exit(1);
88
+ });
@@ -0,0 +1,152 @@
1
+ // _site/_test/hook-status-repair-api-test.js
2
+ //
3
+ // Integration tests for T04 — Hook status / verify / repair service API.
4
+ // Drives the live server through:
5
+ // GET /api/projects/:id/hook-status
6
+ // POST /api/projects/:id/hook-repair
7
+ //
8
+ // and verifies that:
9
+ // - the status payload carries all required fields;
10
+ // - repair works for missing / broken managed hooks;
11
+ // - repair refuses to overwrite third-party hooks;
12
+ // - lastConflict is surfaced from state.hook.
13
+
14
+ const assert = require('assert');
15
+ const fs = require('fs');
16
+ const os = require('os');
17
+ const path = require('path');
18
+ const { spawnSync } = require('child_process');
19
+ const { spawnServer } = require('./helpers/spawn-server');
20
+
21
+ const ROOT = path.resolve(__dirname, '..', '..');
22
+ const PORT = 7901;
23
+ const BASE = `http://127.0.0.1:${PORT}`;
24
+ const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), `pk-hook-api-${process.pid}-`));
25
+ const repo = fs.mkdtempSync(path.join(os.tmpdir(), `pk-hook-api-repo-${process.pid}-`));
26
+
27
+ function git(args) {
28
+ const result = spawnSync('git', ['-C', repo, ...args], {
29
+ encoding: 'utf8',
30
+ windowsHide: true,
31
+ env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
32
+ });
33
+ if (result.status !== 0) throw new Error(result.stderr || `git ${args.join(' ')} failed: ${result.status}`);
34
+ return String(result.stdout || '').trim();
35
+ }
36
+
37
+ function makeRepo() {
38
+ git(['init', '-q', '-b', 'main']);
39
+ git(['config', 'user.email', 'hook-api@example.local']);
40
+ git(['config', 'user.name', 'Hook API Test']);
41
+ fs.writeFileSync(path.join(repo, 'README.md'), '# hook api\n');
42
+ git(['add', 'README.md']);
43
+ git(['commit', '-q', '-m', 'initial']);
44
+ }
45
+
46
+ function requestJson(method, pathname, body) {
47
+ return fetch(`${BASE}${pathname}`, {
48
+ method,
49
+ headers: body === undefined ? undefined : { 'Content-Type': 'application/json' },
50
+ body: body === undefined ? undefined : JSON.stringify(body),
51
+ }).then(async response => ({ status: response.status, body: await response.json() }));
52
+ }
53
+ function postJson(pathname, body) { return requestJson('POST', pathname, body); }
54
+ function patchJson(pathname, body) { return requestJson('PATCH', pathname, body); }
55
+ function putJson(pathname, body) { return requestJson('PUT', pathname, body); }
56
+ function getJson(pathname) { return requestJson('GET', pathname); }
57
+
58
+ async function waitForServer() {
59
+ for (let attempt = 0; attempt < 100; attempt += 1) {
60
+ try { if ((await fetch(`${BASE}/api/health`)).ok) return; } catch {}
61
+ await new Promise(resolve => setTimeout(resolve, 100));
62
+ }
63
+ throw new Error('server did not start');
64
+ }
65
+
66
+ (async () => {
67
+ makeRepo();
68
+ const spawned = spawnServer({
69
+ root: ROOT, port: PORT, dataDir, tag: 'hook-api',
70
+ extraEnv: { KB_SKIP_MIGRATION: '1' },
71
+ });
72
+ try {
73
+ await waitForServer();
74
+ // Configure knowledge root + a fake AI profile so import succeeds.
75
+ let r = await patchJson('/api/settings', { knowledge: { rootPath: path.join(dataDir, 'knowledge') } });
76
+ assert.strictEqual(r.status, 200, JSON.stringify(r.body));
77
+ r = await putJson('/api/ai-profiles', {
78
+ schema: 'ai-profiles/v1', defaultProfileId: 'fake',
79
+ profiles: [{ id: 'fake', name: 'Fake', enabled: true, vendor: 'anthropic', model: 'fake', apiKeyUpdate: { mode: 'replace', value: 'k' } }],
80
+ });
81
+ assert.strictEqual(r.status, 200, JSON.stringify(r.body));
82
+ const PROJECT_ID = 'project-hook-api';
83
+ r = await postJson('/api/projects/import', {
84
+ projectId: PROJECT_ID, localPath: repo, displayName: 'Hook API', aiProfileId: 'fake',
85
+ });
86
+ assert.strictEqual(r.status, 201, JSON.stringify(r.body));
87
+
88
+ // Case 1: status payload after fresh import carries all required fields.
89
+ r = await getJson(`/api/projects/${PROJECT_ID}/hook-status`);
90
+ assert.strictEqual(r.status, 200);
91
+ assert.strictEqual(r.body.ok, true);
92
+ assert.strictEqual(r.body.projectId, PROJECT_ID);
93
+ assert.strictEqual(typeof r.body.hook.repoPath, 'string');
94
+ assert.strictEqual(typeof r.body.hook.hookPath, 'string');
95
+ assert.strictEqual(r.body.hook.installed, true);
96
+ assert.strictEqual(r.body.hook.managed, true);
97
+ assert.strictEqual(r.body.hook.managedVersion, 2);
98
+ assert.strictEqual(typeof r.body.hook.runtimeTarget, 'string');
99
+ assert(typeof r.body.hook.lastVerifiedAt === 'string' && r.body.hook.lastVerifiedAt.length > 0);
100
+ assert.strictEqual(r.body.hook.migrationVersion, 2);
101
+ assert.strictEqual(r.body.hook.repairAvailable, false, 'freshly-imported managed hook needs no repair');
102
+
103
+ // Case 2: missing managed hook is reported + repairable.
104
+ const hookPath = r.body.hook.hookPath;
105
+ fs.unlinkSync(hookPath);
106
+ r = await getJson(`/api/projects/${PROJECT_ID}/hook-status`);
107
+ assert.strictEqual(r.body.hook.installed, false);
108
+ assert.strictEqual(r.body.hook.managed, false);
109
+ assert.strictEqual(r.body.hook.repairAvailable, true, 'missing managed hook must be repairable');
110
+ r = await postJson(`/api/projects/${PROJECT_ID}/hook-repair`, {});
111
+ assert.strictEqual(r.status, 200, JSON.stringify(r.body));
112
+ assert.strictEqual(r.body.installed, true);
113
+ assert.strictEqual(r.body.managedVersion, 2);
114
+ r = await getJson(`/api/projects/${PROJECT_ID}/hook-status`);
115
+ assert.strictEqual(r.body.hook.installed, true, 'repair must re-install the managed hook');
116
+ assert.strictEqual(r.body.hook.managed, true);
117
+ assert.strictEqual(r.body.hook.repairAvailable, false);
118
+
119
+ // Case 3: third-party hook is reported as conflict + repair refuses.
120
+ const userHook = '#!/bin/sh\necho "user owned"\nexit 0\n';
121
+ fs.writeFileSync(hookPath, userHook, { mode: 0o755 });
122
+ r = await getJson(`/api/projects/${PROJECT_ID}/hook-status`);
123
+ assert.strictEqual(r.body.hook.installed, false, 'third-party hook must not be reported as installed');
124
+ assert.strictEqual(r.body.hook.managed, false, 'third-party hook must not be reported as managed');
125
+ assert.strictEqual(r.body.hook.repairAvailable, false, 'third-party hook must not be repairable');
126
+ assert(r.body.hook.reason && /third-party/i.test(r.body.hook.reason));
127
+ r = await postJson(`/api/projects/${PROJECT_ID}/hook-repair`, {});
128
+ assert.strictEqual(r.status, 409, `third-party repair must be rejected with 409; got ${r.status}`);
129
+ assert.strictEqual(r.body.error.code, 'HOOK_CONFLICT');
130
+ assert.strictEqual(fs.readFileSync(hookPath, 'utf8'), userHook, 'third-party hook body must remain untouched');
131
+
132
+ // Case 4: managed hook belonging to a different project is reported as conflict.
133
+ fs.writeFileSync(hookPath, '#!/bin/sh\n# PROJECT-KNOWLEDGE-HOOK ' + JSON.stringify({
134
+ schema: 'project-knowledge/hook/v2', managedVersion: 2, projectId: 'project-someone-else',
135
+ }) + '\nexit 0\n', { mode: 0o755 });
136
+ r = await getJson(`/api/projects/${PROJECT_ID}/hook-status`);
137
+ assert.strictEqual(r.body.hook.managed, true, 'managed hook body must be recognized as managed');
138
+ assert.strictEqual(r.body.hook.installed, false, 'wrong-project managed hook must not be installed for this project');
139
+ assert.strictEqual(r.body.hook.repairAvailable, false, 'wrong-project managed hook must not be auto-repaired');
140
+ r = await postJson(`/api/projects/${PROJECT_ID}/hook-repair`, {});
141
+ assert.strictEqual(r.status, 409, 'wrong-project repair must be rejected with 409');
142
+ } finally {
143
+ spawned.child.kill();
144
+ await new Promise(resolve => spawned.child.once('exit', resolve));
145
+ fs.rmSync(dataDir, { recursive: true, force: true });
146
+ fs.rmSync(repo, { recursive: true, force: true });
147
+ }
148
+ console.log('hook-status-repair-api-test PASS');
149
+ })().catch(error => {
150
+ console.error(error.stack || error.message);
151
+ process.exit(1);
152
+ });