@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
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ https://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ https://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ project-knowledge
2
+ Copyright 2026 SanQianX
3
+
4
+ This product includes software developed by SanQianX and distributed under
5
+ the Apache License, Version 2.0.
package/README.md ADDED
@@ -0,0 +1,266 @@
1
+ <p align="center">
2
+ <img src="docs/assets/logo.svg" alt="project-knowledge" width="540">
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>Local, Git-triggered knowledge for software projects.</strong><br>
7
+ Markdown is the source of truth; the local vector index is always derived and rebuildable.
8
+ </p>
9
+
10
+ ## Install
11
+
12
+ ### npm
13
+
14
+ Complete new-machine setup is two commands:
15
+
16
+ ```bash
17
+ npm install -g project-knowledge
18
+ project-knowledge-integrations install
19
+ project-knowledge
20
+ ```
21
+
22
+ 1. `npm install -g project-knowledge` installs the knowledge base CLI and its
23
+ bundled `ai-coding-event-bridge` dependency — nothing else to install.
24
+ 2. `project-knowledge-integrations install` is the one-time Integration Setup.
25
+ For every detected client (Claude Code / Codex / OpenCode) it installs two
26
+ independent capabilities, reported separately:
27
+ - **Knowledge Integration** — plugin / MCP / Skill so agents can query the
28
+ knowledge base;
29
+ - **Development Capture** — managed Bridge hooks / notify / plugin so the
30
+ agent conversations in real Git workspaces are captured into each
31
+ imported project's Development Conversation.
32
+ It also registers the host-level `project-knowledge` Bridge consumer.
33
+ No client UI needs to be opened; third-party hooks and configs are
34
+ preserved, and a Codex notify conflict is reported instead of overwritten.
35
+ 3. `project-knowledge` starts the local backend. Projects imported with older
36
+ versions are upgraded automatically on the first drain (canonical workspace
37
+ identity + conversation baseline — no manual migration).
38
+
39
+ Notes:
40
+
41
+ - Restart already-running Claude Code sessions once after installing
42
+ Development Capture — hooks load at session start. Only conversations after
43
+ setup are captured; history is never backfilled.
44
+ - To narrow the setup: `--ide claude`, `--capture-only`, `--knowledge-only`;
45
+ to remove capture per client: `uninstall --capture-only`; to disable
46
+ capture globally (including the Bridge consumer): `disable-capture`.
47
+
48
+ The local service listens on `127.0.0.1:5757` by default. The CLI can select a
49
+ nearby free port and records the active loopback endpoint so managed Git Hooks
50
+ do not depend on a hard-coded port.
51
+
52
+ ```bash
53
+ project-knowledge # start in the background and open the UI
54
+ project-knowledge --fg # run in the foreground
55
+ project-knowledge status # show the active local backend
56
+ project-knowledge stop # stop the background backend
57
+ project-knowledge --port 9000
58
+ project-knowledge --no-open
59
+ ```
60
+
61
+ Requires Node.js 18 or newer and Git on `PATH`.
62
+
63
+ ### Windows desktop
64
+
65
+ Install `Project-Knowledge-<version>-Setup.exe` from a project release. The
66
+ desktop app and npm CLI use the same data directory and endpoint-ownership
67
+ record, so only one backend owns a data directory at a time. Git and Claude
68
+ Code are not bundled.
69
+
70
+ ## Runtime model
71
+
72
+ There are exactly two public analysis triggers:
73
+
74
+ ```text
75
+ post-commit Hook ----+
76
+ +--> reconcileProjectCommits(projectId, trigger)
77
+ application startup -+ trigger: git-hook | startup
78
+ ```
79
+
80
+ Import establishes a Git tracking baseline, installs and verifies the managed
81
+ Hook, and creates project metadata. It does not run AI, infer requirements from
82
+ the repository, or generate placeholder knowledge. For an empty repository,
83
+ the first later Commit is eligible for analysis.
84
+
85
+ The Hook only sends a small `hook-event/v2` notification to the local backend.
86
+ It always exits successfully when the backend is unavailable; startup then
87
+ discovers reachable pending Commits from Git history. There is no offline task
88
+ spool and no manual Hook or manual analysis API.
89
+
90
+ Within a project, Commits run oldest-first and stop at the first failure.
91
+ Different projects may reconcile concurrently. Hook/startup overlap for the
92
+ same project shares one in-flight reconciliation.
93
+
94
+ ## Knowledge safety
95
+
96
+ AI receives a frozen claim containing the Commit SHA, real patch evidence,
97
+ bound requirement IDs, prompt hash, and fixed knowledge path. It can write only
98
+ to an internal per-run staging directory. A manifest must validate before any
99
+ file reaches the final project knowledge directory.
100
+
101
+ Promotion uses verified hashes, backups, and a durable journal. Only after
102
+ Markdown promotion succeeds does the analyzed-Commit pointer advance and mark
103
+ the index dirty. Index failure never rolls back Markdown or reruns AI; it stays
104
+ visible as dirty state and is retried.
105
+
106
+ `IndexService` is the only production LanceDB writer. Incremental updates and
107
+ full rebuilds share one process-wide FIFO. A full rebuild creates and validates
108
+ a separate database, atomically swaps it into place, and retains the previous
109
+ index under recovery.
110
+
111
+ The application does not create, edit, refresh, or delete `CLAUDE.md`.
112
+
113
+ ## Requirement capture
114
+
115
+ Coding-agent integrations can append the user's real request before code is
116
+ changed. Requirement capture writes bounded metadata to the selected project's
117
+ `requirements.jsonl`; it does not start analysis or write knowledge.
118
+
119
+ The MCP server exposes:
120
+
121
+ - read-only `resolve`, `search`, `ask`, `get`, and `history` tools;
122
+ - one write-only `record_requirement` metadata tool.
123
+
124
+ ```bash
125
+ npx project-knowledge@latest install
126
+ npx project-knowledge@latest install --ide claude
127
+ npx project-knowledge@latest install --ide codex
128
+ npx project-knowledge@latest install --ide opencode
129
+ ```
130
+
131
+ Read-only CLI examples:
132
+
133
+ ```bash
134
+ project-knowledge-kb search --project <projectId> --query "refresh token policy" --json
135
+ project-knowledge-kb ask --project <projectId> --query "what was decided about login?"
136
+ project-knowledge-kb get --project <projectId> --entry modules/auth.md --json
137
+ project-knowledge-kb history --project <projectId> --json
138
+ ```
139
+
140
+ Queries never create or rewrite configuration. If the internal index is
141
+ missing, dirty, or unavailable, search falls back to the project's Markdown
142
+ and explicitly configured related projects.
143
+
144
+ ## Storage
145
+
146
+ Default internal data directory: `~/.project-knowledge/`
147
+
148
+ Override it with `KB_DATA_DIR`:
149
+
150
+ ```powershell
151
+ $env:KB_DATA_DIR = 'D:\data\project-knowledge'
152
+ project-knowledge
153
+ ```
154
+
155
+ The user selects a global knowledge root before importing projects. That root
156
+ only chooses the directory for future imports. Each imported project stores an
157
+ absolute, fixed `knowledgePath`; changing the global root does not move existing
158
+ projects.
159
+
160
+ The selected knowledge root contains only authoritative project Markdown.
161
+ Settings, metadata, indexes, caches, runtime state, logs, and recovery assets
162
+ remain in the internal data directory:
163
+
164
+ ```text
165
+ ~/.project-knowledge/
166
+ ├── settings.json
167
+ ├── projects.json # minimal project ID/order index
168
+ ├── projects/<projectId>/
169
+ │ ├── config.json # fixed repoPath/knowledgePath
170
+ │ ├── state.json # tracking, claim, index, Hook state
171
+ │ └── requirements.jsonl # created only when used
172
+ ├── index/knowledge.lancedb # one derived index
173
+ ├── cache/ # models, exports, context packs
174
+ ├── runtime/ # claims, staging, journals, locks
175
+ ├── logs/
176
+ │ ├── app/
177
+ │ ├── projects/<projectId>/
178
+ │ └── hooks/
179
+ └── recovery/ # migrations, promotion/index backups
180
+
181
+ <selected knowledge root>/
182
+ └── <project storage name>/
183
+ ├── README.md # when produced by verified knowledge
184
+ ├── GOAL.md
185
+ ├── ARCHITECTURE.md
186
+ ├── modules/*.md
187
+ └── changes/*.md
188
+ ```
189
+
190
+ Team knowledge is an explicit exception: an import may bind an existing
191
+ checked-out team-store subdirectory. Its final absolute path is still fixed in
192
+ the project config, must remain inside the selected store, and is treated as
193
+ externally owned when the project registration is deleted.
194
+
195
+ ## Migration
196
+
197
+ The versioned `layout-v2` migration discovers legacy assets without modifying
198
+ them, creates a journal and centralized recovery backup, stages settings and
199
+ per-project metadata, validates preserved paths/secrets/pointers and any legacy
200
+ index, then activates files with the minimal registry last. The completion
201
+ marker is written only after the new stores reopen successfully.
202
+
203
+ Interrupted or failed migration keeps the legacy reader path available and
204
+ leaves source knowledge, old logs, configuration files, and backups intact for
205
+ retry or diagnosis.
206
+
207
+ ## Logging UI
208
+
209
+ The production web UI is a focused structured-log console. It provides:
210
+
211
+ - trace/debug/info/warn/error/fatal filtering;
212
+ - local-date, project, component, event, operation, Commit, and text filters;
213
+ - newest-first cursor pagination, pause/auto-refresh, and filtered export;
214
+ - operation-flow and structured error/stack details;
215
+ - logger health/degraded state and Hook/index/project read-only status;
216
+ - light/dark themes and a responsive narrow-screen layout.
217
+
218
+ Logs use `log/v2` JSONL, daily files and bounded segments. Retention defaults to
219
+ 365 days; `0` disables time-based deletion. Capacity cleanup is deterministic.
220
+ Secrets are recursively redacted during write, query, error serialization, and
221
+ export. The log root is fixed under the internal data directory.
222
+
223
+ ## HTTP security
224
+
225
+ The default loopback server accepts same-origin/loopback browser requests. It
226
+ does not use wildcard CORS. Binding to a non-loopback address requires
227
+ `KB_SITE_AUTH_TOKEN`, and requests must also pass Origin validation. Public AI
228
+ profile responses expose only masked secret metadata; generic errors return an
229
+ operation ID without a stack. There is no raw-file route.
230
+
231
+ ## Repository layout
232
+
233
+ ```text
234
+ _site/server.js # thin executable entry
235
+ _site/lib/server-app.js # HTTP/runtime composition
236
+ _site/lib/storage-layout.js # canonical internal paths
237
+ _site/lib/project-*-store.js # v2 registry/config/state stores
238
+ _site/lib/project-lifecycle-service.js
239
+ _site/lib/commit-reconciler.js
240
+ _site/lib/knowledge-promotion.js
241
+ _site/lib/index-service.js
242
+ _site/lib/structured-logger.js
243
+ _site/lib/knowledge-tool-runtime.js
244
+ _site/scripts/hook-trigger.js
245
+ ui/index.html # single production logging UI
246
+ bin/project-knowledge*.js # CLI and MCP entry points
247
+ desktop/ # Windows Electron package
248
+ ```
249
+
250
+ ## Testing
251
+
252
+ ```bash
253
+ npm ci
254
+ npm test -- --no-report
255
+ npm test --prefix desktop
256
+ npm pack --dry-run --json
257
+ ```
258
+
259
+ The Windows suite includes real Git Hooks, paths with spaces/non-ASCII text,
260
+ online and offline Commit reconciliation, crash-lock recovery, atomic index
261
+ replacement, migration fault injection, packaged-startup contracts, API
262
+ security, log redaction/cursors, and browser-level UI flows.
263
+
264
+ ## License
265
+
266
+ [Apache-2.0](LICENSE). See [NOTICE](NOTICE).
@@ -0,0 +1,30 @@
1
+ # KB Management Site
2
+
3
+ 本地知识库管理界面,默认监听 `http://127.0.0.1:5757`。
4
+
5
+ ## 启动
6
+
7
+ ```bash
8
+ node _site/server.js
9
+ ```
10
+
11
+ 也可以运行项目根目录的 `npm start`,或使用 `_site/start.bat`。
12
+
13
+ ## Commit 自动化
14
+
15
+ - Git `post-commit` Hook 在应用运行时立即通知服务端。
16
+ - 应用启动时会扫描关闭期间新增的 commit。
17
+ - 每个 commit 生成一个独立 Claude Code 后台任务。
18
+ - 同一项目按提交时间串行执行,不同项目可以并行。
19
+ - 任务直接更新当前项目知识库,没有草稿审核、`autoApply` 或人工批准阶段。
20
+ - 每个 commit 的 `discovered / queued / running / completed / failed` 状态持久化在项目 AI 工作目录中,完成的 commit 不会重复派发。
21
+
22
+ ## 主要接口
23
+
24
+ - `GET /api/state`:项目与知识库状态。
25
+ - `POST /api/hooks/post-commit`:接收 Hook 事件并执行 commit 对账。
26
+ - `POST /api/projects/:slug/scan`:只读扫描 Git 状态。
27
+ - `GET /api/projects/:slug/automation/runs`:查看自动化运行记录。
28
+ - `GET /api/claude/sessions-stream`:订阅 Claude Code 会话状态。
29
+
30
+ 服务只绑定回环地址。不要将端口直接暴露到公网。
@@ -0,0 +1,137 @@
1
+ // _site/_test/ai-profile-resolver-test.js
2
+ //
3
+ // Tests for the shared effective AI profile resolver. The resolver is the
4
+ // single source of truth for "which AI profile does this project use right
5
+ // now" — replacing the inconsistent fallback logic that used to live in
6
+ // Workbench start-session / send-input, the analyzer, the CommitReconciler,
7
+ // and import default assignment.
8
+ //
9
+ // Resolution order (per T01):
10
+ // 1. projectConfig.aiProfileId when usable
11
+ // 2. settings.ai.defaultProfileId when usable
12
+ // 3. first usable configured profile in stable configured order
13
+ // 4. otherwise AI_PROFILE_REQUIRED
14
+
15
+ const assert = require('assert');
16
+ const { resolveEffectiveAiProfile, isUsable, profileById } = require('../lib/ai-profile-resolver');
17
+
18
+ const PROFILE_A = { id: 'profile-a', name: 'A', enabled: true, vendor: 'anthropic', model: 'm' };
19
+ const PROFILE_B = { id: 'profile-b', name: 'B', enabled: true, vendor: 'anthropic', model: 'm' };
20
+ const PROFILE_DISABLED = { id: 'profile-disabled', name: 'Disabled', enabled: false, vendor: 'anthropic', model: 'm' };
21
+ const PROFILE_ENABLED_UNDEFINED = { id: 'profile-default-enabled', name: 'DefaultEnabled', vendor: 'anthropic', model: 'm' };
22
+
23
+ function settings(profiles, defaultProfileId) {
24
+ return { ai: { schema: 'ai-profiles/v1', profiles, defaultProfileId: defaultProfileId || null } };
25
+ }
26
+
27
+ (async () => {
28
+ // ---- Case 1: explicit project profile is preferred ----
29
+ {
30
+ const s = settings([PROFILE_A, PROFILE_B], 'profile-b');
31
+ const r = resolveEffectiveAiProfile(s, { aiProfileId: 'profile-a' });
32
+ assert.strictEqual(r.source, 'project');
33
+ assert.strictEqual(r.profileId, 'profile-a');
34
+ assert.strictEqual(r.profile.id, 'profile-a');
35
+ }
36
+
37
+ // ---- Case 2: default profile fallback when project has none ----
38
+ {
39
+ const s = settings([PROFILE_A, PROFILE_B], 'profile-b');
40
+ const r = resolveEffectiveAiProfile(s, { aiProfileId: null });
41
+ assert.strictEqual(r.source, 'default');
42
+ assert.strictEqual(r.profileId, 'profile-b');
43
+ }
44
+
45
+ // ---- Case 3: first-usable fallback when default is missing/disabled ----
46
+ {
47
+ const s = settings([PROFILE_DISABLED, PROFILE_A, PROFILE_B], 'profile-disabled');
48
+ const r = resolveEffectiveAiProfile(s, { aiProfileId: null });
49
+ assert.strictEqual(r.source, 'first-usable');
50
+ assert.strictEqual(r.profileId, 'profile-a');
51
+ }
52
+
53
+ // ---- Case 4: stale project profile id falls back safely ----
54
+ {
55
+ const s = settings([PROFILE_A, PROFILE_B], 'profile-b');
56
+ const r = resolveEffectiveAiProfile(s, { aiProfileId: 'profile-deleted' });
57
+ assert.strictEqual(r.source, 'default');
58
+ assert.strictEqual(r.profileId, 'profile-b');
59
+ }
60
+
61
+ // ---- Case 5: disabled project profile falls back to default ----
62
+ {
63
+ const s = settings([PROFILE_DISABLED, PROFILE_B], 'profile-b');
64
+ const r = resolveEffectiveAiProfile(s, { aiProfileId: 'profile-disabled' });
65
+ assert.strictEqual(r.source, 'default');
66
+ assert.strictEqual(r.profileId, 'profile-b');
67
+ }
68
+
69
+ // ---- Case 6: no usable profile produces one clear error ----
70
+ {
71
+ const s = settings([PROFILE_DISABLED], null);
72
+ let threw = null;
73
+ try { resolveEffectiveAiProfile(s, { aiProfileId: null }); }
74
+ catch (error) { threw = error; }
75
+ assert(threw, 'resolver must throw when no usable profile exists');
76
+ assert.strictEqual(threw.code, 'AI_PROFILE_REQUIRED');
77
+ assert.strictEqual(threw.status, 409);
78
+ assert(threw.details && typeof threw.details.hint === 'string');
79
+ }
80
+
81
+ // ---- Case 7: enabled=undefined (legacy profiles) is treated as usable ----
82
+ {
83
+ const s = settings([PROFILE_ENABLED_UNDEFINED], 'profile-default-enabled');
84
+ const r = resolveEffectiveAiProfile(s, { aiProfileId: null });
85
+ assert.strictEqual(r.source, 'default');
86
+ assert.strictEqual(r.profileId, 'profile-default-enabled');
87
+ }
88
+
89
+ // ---- Case 8: empty settings produces AI_PROFILE_REQUIRED ----
90
+ {
91
+ let threw = null;
92
+ try { resolveEffectiveAiProfile({ ai: { profiles: [] } }, { aiProfileId: null }); }
93
+ catch (error) { threw = error; }
94
+ assert(threw, 'empty settings must throw AI_PROFILE_REQUIRED');
95
+ assert.strictEqual(threw.code, 'AI_PROFILE_REQUIRED');
96
+ }
97
+
98
+ // ---- Case 9: null/undefined inputs are tolerated ----
99
+ {
100
+ const r = resolveEffectiveAiProfile({ ai: { profiles: [PROFILE_A] } }, null);
101
+ assert.strictEqual(r.source, 'first-usable');
102
+ assert.strictEqual(r.profileId, 'profile-a');
103
+ }
104
+
105
+ // ---- Case 10: isUsable + profileById helpers ----
106
+ {
107
+ assert.strictEqual(isUsable(PROFILE_A), true);
108
+ assert.strictEqual(isUsable(PROFILE_DISABLED), false);
109
+ assert.strictEqual(isUsable(null), false);
110
+ const s = settings([PROFILE_A, PROFILE_B]);
111
+ assert.strictEqual(profileById(s, 'profile-a').id, 'profile-a');
112
+ assert.strictEqual(profileById(s, 'profile-unknown'), null);
113
+ assert.strictEqual(profileById(s, ''), null);
114
+ }
115
+
116
+ // ---- Case 11: deterministic first-usable order ----
117
+ {
118
+ const s = settings([PROFILE_A, PROFILE_B], null);
119
+ const r1 = resolveEffectiveAiProfile(s, { aiProfileId: null });
120
+ const r2 = resolveEffectiveAiProfile(s, { aiProfileId: null });
121
+ assert.strictEqual(r1.profileId, 'profile-a');
122
+ assert.strictEqual(r2.profileId, 'profile-a');
123
+ }
124
+
125
+ // ---- Case 12: default profile that is enabled=undefined still wins over first-usable ----
126
+ {
127
+ const s = settings([PROFILE_A, PROFILE_ENABLED_UNDEFINED], 'profile-default-enabled');
128
+ const r = resolveEffectiveAiProfile(s, { aiProfileId: null });
129
+ assert.strictEqual(r.source, 'default');
130
+ assert.strictEqual(r.profileId, 'profile-default-enabled');
131
+ }
132
+
133
+ console.log('ai-profile-resolver-test PASS');
134
+ })().catch(error => {
135
+ console.error(error.stack || error.message);
136
+ process.exit(1);
137
+ });