@praneeth_54/agentdoctor 1.0.0 → 1.1.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 (208) hide show
  1. package/CHANGELOG.md +60 -5
  2. package/README.md +462 -251
  3. package/dist/cli/commands/brain-mcp.d.ts +9 -0
  4. package/dist/cli/commands/brain-mcp.js +38 -0
  5. package/dist/cli/program.js +13 -0
  6. package/dist/constants.d.ts +1 -1
  7. package/dist/constants.js +1 -1
  8. package/dist/core/understanding/architecture/index.d.ts +4 -0
  9. package/dist/core/understanding/architecture/index.js +3 -0
  10. package/dist/core/understanding/architecture/infer.d.ts +6 -0
  11. package/dist/core/understanding/architecture/infer.js +39 -0
  12. package/dist/core/understanding/architecture/models.d.ts +23 -0
  13. package/dist/core/understanding/architecture/models.js +127 -0
  14. package/dist/core/understanding/architecture/patterns/distribution.d.ts +2 -0
  15. package/dist/core/understanding/architecture/patterns/distribution.js +115 -0
  16. package/dist/core/understanding/architecture/patterns/index.d.ts +2 -0
  17. package/dist/core/understanding/architecture/patterns/index.js +8 -0
  18. package/dist/core/understanding/architecture/patterns/layered.d.ts +2 -0
  19. package/dist/core/understanding/architecture/patterns/layered.js +279 -0
  20. package/dist/core/understanding/architecture/patterns/structural.d.ts +2 -0
  21. package/dist/core/understanding/architecture/patterns/structural.js +197 -0
  22. package/dist/core/understanding/architecture/rules.d.ts +4 -0
  23. package/dist/core/understanding/architecture/rules.js +6 -0
  24. package/dist/core/understanding/architecture/types.d.ts +52 -0
  25. package/dist/core/understanding/architecture/types.js +1 -0
  26. package/dist/core/understanding/brain/build.d.ts +13 -0
  27. package/dist/core/understanding/brain/build.js +158 -0
  28. package/dist/core/understanding/brain/claims/index.d.ts +3 -0
  29. package/dist/core/understanding/brain/claims/index.js +2 -0
  30. package/dist/core/understanding/brain/claims/lifecycle.d.ts +16 -0
  31. package/dist/core/understanding/brain/claims/lifecycle.js +78 -0
  32. package/dist/core/understanding/brain/claims/types.d.ts +32 -0
  33. package/dist/core/understanding/brain/claims/types.js +25 -0
  34. package/dist/core/understanding/brain/components/index.d.ts +17 -0
  35. package/dist/core/understanding/brain/components/index.js +97 -0
  36. package/dist/core/understanding/brain/components/types.d.ts +16 -0
  37. package/dist/core/understanding/brain/components/types.js +8 -0
  38. package/dist/core/understanding/brain/confidence.d.ts +19 -0
  39. package/dist/core/understanding/brain/confidence.js +39 -0
  40. package/dist/core/understanding/brain/contract.d.ts +17 -0
  41. package/dist/core/understanding/brain/contract.js +100 -0
  42. package/dist/core/understanding/brain/contradictions/index.d.ts +12 -0
  43. package/dist/core/understanding/brain/contradictions/index.js +57 -0
  44. package/dist/core/understanding/brain/contradictions/types.d.ts +12 -0
  45. package/dist/core/understanding/brain/contradictions/types.js +8 -0
  46. package/dist/core/understanding/brain/delta.d.ts +25 -0
  47. package/dist/core/understanding/brain/delta.js +116 -0
  48. package/dist/core/understanding/brain/evidence/index.d.ts +3 -0
  49. package/dist/core/understanding/brain/evidence/index.js +2 -0
  50. package/dist/core/understanding/brain/evidence/redact.d.ts +4 -0
  51. package/dist/core/understanding/brain/evidence/redact.js +36 -0
  52. package/dist/core/understanding/brain/evidence/types.d.ts +34 -0
  53. package/dist/core/understanding/brain/evidence/types.js +35 -0
  54. package/dist/core/understanding/brain/explain.d.ts +17 -0
  55. package/dist/core/understanding/brain/explain.js +33 -0
  56. package/dist/core/understanding/brain/index.d.ts +28 -0
  57. package/dist/core/understanding/brain/index.js +16 -0
  58. package/dist/core/understanding/brain/migrate.d.ts +21 -0
  59. package/dist/core/understanding/brain/migrate.js +47 -0
  60. package/dist/core/understanding/brain/query.d.ts +60 -0
  61. package/dist/core/understanding/brain/query.js +92 -0
  62. package/dist/core/understanding/brain/security.d.ts +3 -0
  63. package/dist/core/understanding/brain/security.js +43 -0
  64. package/dist/core/understanding/brain/storage/index.d.ts +2 -0
  65. package/dist/core/understanding/brain/storage/index.js +1 -0
  66. package/dist/core/understanding/brain/storage/store.d.ts +53 -0
  67. package/dist/core/understanding/brain/storage/store.js +305 -0
  68. package/dist/core/understanding/brain/trace.d.ts +24 -0
  69. package/dist/core/understanding/brain/trace.js +207 -0
  70. package/dist/core/understanding/brain/types.d.ts +32 -0
  71. package/dist/core/understanding/brain/types.js +8 -0
  72. package/dist/core/understanding/brain/version.d.ts +13 -0
  73. package/dist/core/understanding/brain/version.js +7 -0
  74. package/dist/core/understanding/delta/compare.d.ts +26 -0
  75. package/dist/core/understanding/delta/compare.js +74 -0
  76. package/dist/core/understanding/delta/index.d.ts +2 -0
  77. package/dist/core/understanding/delta/index.js +1 -0
  78. package/dist/core/understanding/dependencies/discover.d.ts +7 -0
  79. package/dist/core/understanding/dependencies/discover.js +550 -0
  80. package/dist/core/understanding/dependencies/extract.d.ts +10 -0
  81. package/dist/core/understanding/dependencies/extract.js +189 -0
  82. package/dist/core/understanding/dependencies/index.d.ts +4 -0
  83. package/dist/core/understanding/dependencies/index.js +3 -0
  84. package/dist/core/understanding/dependencies/models.d.ts +12 -0
  85. package/dist/core/understanding/dependencies/models.js +125 -0
  86. package/dist/core/understanding/dependencies/types.d.ts +27 -0
  87. package/dist/core/understanding/dependencies/types.js +1 -0
  88. package/dist/core/understanding/domain/discover.d.ts +14 -0
  89. package/dist/core/understanding/domain/discover.js +90 -0
  90. package/dist/core/understanding/domain/index.d.ts +2 -0
  91. package/dist/core/understanding/domain/index.js +1 -0
  92. package/dist/core/understanding/entrypoints/discover.d.ts +6 -0
  93. package/dist/core/understanding/entrypoints/discover.js +62 -0
  94. package/dist/core/understanding/entrypoints/extract.d.ts +19 -0
  95. package/dist/core/understanding/entrypoints/extract.js +43 -0
  96. package/dist/core/understanding/entrypoints/index.d.ts +4 -0
  97. package/dist/core/understanding/entrypoints/index.js +3 -0
  98. package/dist/core/understanding/entrypoints/models.d.ts +26 -0
  99. package/dist/core/understanding/entrypoints/models.js +216 -0
  100. package/dist/core/understanding/entrypoints/types.d.ts +20 -0
  101. package/dist/core/understanding/entrypoints/types.js +1 -0
  102. package/dist/core/understanding/index.d.ts +32 -0
  103. package/dist/core/understanding/index.js +18 -0
  104. package/dist/core/understanding/mind/build.d.ts +16 -0
  105. package/dist/core/understanding/mind/build.js +134 -0
  106. package/dist/core/understanding/mind/index.d.ts +6 -0
  107. package/dist/core/understanding/mind/index.js +3 -0
  108. package/dist/core/understanding/mind/query.d.ts +33 -0
  109. package/dist/core/understanding/mind/query.js +39 -0
  110. package/dist/core/understanding/mind/types.d.ts +24 -0
  111. package/dist/core/understanding/mind/types.js +7 -0
  112. package/dist/core/understanding/model/builder.d.ts +9 -0
  113. package/dist/core/understanding/model/builder.js +209 -0
  114. package/dist/core/understanding/model/ids.d.ts +7 -0
  115. package/dist/core/understanding/model/ids.js +48 -0
  116. package/dist/core/understanding/model/index.d.ts +7 -0
  117. package/dist/core/understanding/model/index.js +6 -0
  118. package/dist/core/understanding/model/schema.d.ts +12 -0
  119. package/dist/core/understanding/model/schema.js +33 -0
  120. package/dist/core/understanding/model/serializer.d.ts +9 -0
  121. package/dist/core/understanding/model/serializer.js +46 -0
  122. package/dist/core/understanding/model/types.d.ts +110 -0
  123. package/dist/core/understanding/model/types.js +1 -0
  124. package/dist/core/understanding/model/validator.d.ts +5 -0
  125. package/dist/core/understanding/model/validator.js +126 -0
  126. package/dist/core/understanding/model/version.d.ts +9 -0
  127. package/dist/core/understanding/model/version.js +7 -0
  128. package/dist/core/understanding/ownership/discover.d.ts +12 -0
  129. package/dist/core/understanding/ownership/discover.js +242 -0
  130. package/dist/core/understanding/ownership/index.d.ts +2 -0
  131. package/dist/core/understanding/ownership/index.js +1 -0
  132. package/dist/core/understanding/ownership/types.d.ts +23 -0
  133. package/dist/core/understanding/ownership/types.js +1 -0
  134. package/dist/core/understanding/query/engine.d.ts +24 -0
  135. package/dist/core/understanding/query/engine.js +35 -0
  136. package/dist/core/understanding/query/errors.d.ts +13 -0
  137. package/dist/core/understanding/query/errors.js +26 -0
  138. package/dist/core/understanding/query/executor.d.ts +8 -0
  139. package/dist/core/understanding/query/executor.js +34 -0
  140. package/dist/core/understanding/query/index.d.ts +7 -0
  141. package/dist/core/understanding/query/index.js +5 -0
  142. package/dist/core/understanding/query/models.d.ts +102 -0
  143. package/dist/core/understanding/query/models.js +1 -0
  144. package/dist/core/understanding/query/query.d.ts +68 -0
  145. package/dist/core/understanding/query/query.js +145 -0
  146. package/dist/core/understanding/query/registry.d.ts +8 -0
  147. package/dist/core/understanding/query/registry.js +340 -0
  148. package/dist/core/understanding/query/types.d.ts +63 -0
  149. package/dist/core/understanding/query/types.js +1 -0
  150. package/dist/core/understanding/relationships/discover.d.ts +11 -0
  151. package/dist/core/understanding/relationships/discover.js +517 -0
  152. package/dist/core/understanding/relationships/extract.d.ts +14 -0
  153. package/dist/core/understanding/relationships/extract.js +165 -0
  154. package/dist/core/understanding/relationships/index.d.ts +4 -0
  155. package/dist/core/understanding/relationships/index.js +3 -0
  156. package/dist/core/understanding/relationships/models.d.ts +21 -0
  157. package/dist/core/understanding/relationships/models.js +185 -0
  158. package/dist/core/understanding/relationships/types.d.ts +42 -0
  159. package/dist/core/understanding/relationships/types.js +1 -0
  160. package/dist/core/understanding/risks/discover.d.ts +8 -0
  161. package/dist/core/understanding/risks/discover.js +155 -0
  162. package/dist/core/understanding/risks/index.d.ts +2 -0
  163. package/dist/core/understanding/risks/index.js +1 -0
  164. package/dist/core/understanding/risks/types.d.ts +26 -0
  165. package/dist/core/understanding/risks/types.js +1 -0
  166. package/dist/core/understanding/shared/domain-lexicon.d.ts +9 -0
  167. package/dist/core/understanding/shared/domain-lexicon.js +107 -0
  168. package/dist/core/understanding/shared/index.d.ts +2 -0
  169. package/dist/core/understanding/shared/index.js +2 -0
  170. package/dist/core/understanding/shared/tokens.d.ts +7 -0
  171. package/dist/core/understanding/shared/tokens.js +141 -0
  172. package/dist/core/understanding/snapshot/identity.d.ts +24 -0
  173. package/dist/core/understanding/snapshot/identity.js +79 -0
  174. package/dist/core/understanding/snapshot/index.d.ts +2 -0
  175. package/dist/core/understanding/snapshot/index.js +1 -0
  176. package/dist/core/understanding/types/index.d.ts +22 -0
  177. package/dist/core/understanding/types/index.js +1 -0
  178. package/dist/core/understanding/understand/formatter.d.ts +10 -0
  179. package/dist/core/understanding/understand/formatter.js +115 -0
  180. package/dist/core/understanding/understand/index.d.ts +4 -0
  181. package/dist/core/understanding/understand/index.js +3 -0
  182. package/dist/core/understanding/understand/service.d.ts +17 -0
  183. package/dist/core/understanding/understand/service.js +76 -0
  184. package/dist/core/understanding/understand/summary.d.ts +14 -0
  185. package/dist/core/understanding/understand/summary.js +39 -0
  186. package/dist/core/understanding/understand/types.d.ts +31 -0
  187. package/dist/core/understanding/understand/types.js +1 -0
  188. package/dist/mcp/brain/compile.d.ts +9 -0
  189. package/dist/mcp/brain/compile.js +42 -0
  190. package/dist/mcp/brain/errors.d.ts +12 -0
  191. package/dist/mcp/brain/errors.js +23 -0
  192. package/dist/mcp/brain/index.d.ts +11 -0
  193. package/dist/mcp/brain/index.js +8 -0
  194. package/dist/mcp/brain/provenance.d.ts +29 -0
  195. package/dist/mcp/brain/provenance.js +59 -0
  196. package/dist/mcp/brain/schemas.d.ts +13 -0
  197. package/dist/mcp/brain/schemas.js +105 -0
  198. package/dist/mcp/brain/security/root.d.ts +6 -0
  199. package/dist/mcp/brain/security/root.js +66 -0
  200. package/dist/mcp/brain/server.d.ts +12 -0
  201. package/dist/mcp/brain/server.js +46 -0
  202. package/dist/mcp/brain/session.d.ts +33 -0
  203. package/dist/mcp/brain/session.js +117 -0
  204. package/dist/mcp/brain/tools/handlers.d.ts +13 -0
  205. package/dist/mcp/brain/tools/handlers.js +483 -0
  206. package/dist/mcp/brain/tools/registry.d.ts +9 -0
  207. package/dist/mcp/brain/tools/registry.js +191 -0
  208. package/package.json +11 -4
@@ -0,0 +1,216 @@
1
+ function basename(relativePath) {
2
+ const parts = relativePath.split("/");
3
+ return parts[parts.length - 1] ?? relativePath;
4
+ }
5
+ function posix(relativePath) {
6
+ return relativePath.replace(/\\/g, "/");
7
+ }
8
+ /**
9
+ * Deterministic entrypoint models. Order matters for stable multi-match preference
10
+ * when the same file could qualify under multiple frameworks (NestJS before Node).
11
+ */
12
+ export const ENTRYPOINT_MODELS = [
13
+ {
14
+ framework: "Flutter",
15
+ pathTest: (p) => {
16
+ const path = posix(p);
17
+ return (path === "lib/main.dart" ||
18
+ path.endsWith("/lib/main.dart") ||
19
+ basename(path) === "main.dart");
20
+ },
21
+ signals: [
22
+ { label: "runApp()", pattern: /\brunApp\s*\(/ },
23
+ { label: "MaterialApp", pattern: /\bMaterialApp\b/ },
24
+ { label: "CupertinoApp", pattern: /\bCupertinoApp\b/ },
25
+ { label: "GoRouter", pattern: /\bGoRouter\b/ },
26
+ ],
27
+ pathConfidence: 0.7,
28
+ signalBoost: 0.1,
29
+ requireSignal: false,
30
+ },
31
+ {
32
+ framework: "Laravel",
33
+ pathTest: (p) => {
34
+ const path = posix(p);
35
+ return (path === "routes/web.php" ||
36
+ path === "routes/api.php" ||
37
+ path.endsWith("/routes/web.php") ||
38
+ path.endsWith("/routes/api.php") ||
39
+ basename(path) === "artisan" ||
40
+ path === "bootstrap/app.php" ||
41
+ path.endsWith("/bootstrap/app.php"));
42
+ },
43
+ signals: [
44
+ { label: "Route::", pattern: /\bRoute\s*::/ },
45
+ { label: "Illuminate\\", pattern: /Illuminate\\/ },
46
+ { label: "Application::configure", pattern: /Application\s*::\s*configure/ },
47
+ ],
48
+ pathConfidence: 0.85,
49
+ signalBoost: 0.05,
50
+ requireSignal: false,
51
+ },
52
+ {
53
+ framework: "Next.js",
54
+ pathTest: (p) => {
55
+ const path = posix(p);
56
+ const base = basename(path);
57
+ const inApp = /(^|\/)app\//.test(path) &&
58
+ (base === "layout.tsx" ||
59
+ base === "layout.jsx" ||
60
+ base === "layout.js" ||
61
+ base === "page.tsx" ||
62
+ base === "page.jsx" ||
63
+ base === "page.js");
64
+ const inPages = /(^|\/)pages\//.test(path) &&
65
+ (base === "_app.tsx" ||
66
+ base === "_app.jsx" ||
67
+ base === "_app.js" ||
68
+ base === "index.tsx" ||
69
+ base === "index.jsx" ||
70
+ base === "index.js");
71
+ return inApp || inPages;
72
+ },
73
+ signals: [
74
+ { label: "next/navigation", pattern: /from\s+["']next\/navigation["']/ },
75
+ { label: "next/router", pattern: /from\s+["']next\/router["']/ },
76
+ { label: "next/head", pattern: /from\s+["']next\/head["']/ },
77
+ { label: "Metadata", pattern: /\bexport\s+(const|async\s+function|function)\s+metadata\b/ },
78
+ ],
79
+ pathConfidence: 0.8,
80
+ signalBoost: 0.06,
81
+ requireSignal: false,
82
+ },
83
+ {
84
+ framework: "NestJS",
85
+ pathTest: (p) => {
86
+ const path = posix(p);
87
+ const base = basename(path);
88
+ return base === "main.ts" || base === "main.js";
89
+ },
90
+ signals: [
91
+ { label: "NestFactory", pattern: /\bNestFactory\b/ },
92
+ {
93
+ label: "bootstrap()",
94
+ pattern: /\basync\s+function\s+bootstrap\s*\(|\bbootstrap\s*\(\s*\)/,
95
+ },
96
+ { label: "@nestjs/core", pattern: /@nestjs\/core/ },
97
+ ],
98
+ pathConfidence: 0.55,
99
+ signalBoost: 0.15,
100
+ requireSignal: true,
101
+ },
102
+ {
103
+ framework: "React",
104
+ pathTest: (p) => {
105
+ const path = posix(p);
106
+ const base = basename(path);
107
+ if (/(^|\/)(app|pages)\//.test(path)) {
108
+ return false;
109
+ }
110
+ return (base === "main.tsx" ||
111
+ base === "main.jsx" ||
112
+ base === "index.tsx" ||
113
+ base === "index.jsx" ||
114
+ base === "App.tsx" ||
115
+ base === "App.jsx");
116
+ },
117
+ signals: [
118
+ { label: "ReactDOM.createRoot()", pattern: /ReactDOM\s*\.\s*createRoot\s*\(/ },
119
+ { label: "createRoot()", pattern: /\bcreateRoot\s*\(/ },
120
+ { label: "ReactDOM.render(", pattern: /ReactDOM\s*\.\s*render\s*\(/ },
121
+ { label: 'from "react"', pattern: /from\s+["']react["']/ },
122
+ ],
123
+ pathConfidence: 0.6,
124
+ signalBoost: 0.12,
125
+ requireSignal: true,
126
+ },
127
+ {
128
+ framework: "Node",
129
+ pathTest: (p) => {
130
+ const path = posix(p);
131
+ const base = basename(path);
132
+ return (base === "server.ts" ||
133
+ base === "server.js" ||
134
+ base === "server.mjs" ||
135
+ base === "app.ts" ||
136
+ base === "app.js" ||
137
+ base === "app.mjs" ||
138
+ base === "index.ts" ||
139
+ base === "index.js");
140
+ },
141
+ signals: [
142
+ { label: "express()", pattern: /\bexpress\s*\(/ },
143
+ { label: "fastify()", pattern: /\bfastify\s*\(/ },
144
+ { label: "createServer(", pattern: /\bcreateServer\s*\(/ },
145
+ { label: "listen(", pattern: /\.listen\s*\(/ },
146
+ { label: "koa(", pattern: /\bnew\s+Koa\s*\(|\bkoa\s*\(/ },
147
+ ],
148
+ pathConfidence: 0.5,
149
+ signalBoost: 0.15,
150
+ requireSignal: true,
151
+ },
152
+ {
153
+ framework: "Django",
154
+ pathTest: (p) => basename(posix(p)) === "manage.py",
155
+ signals: [
156
+ { label: "django", pattern: /\bdjango\b/i },
157
+ { label: "execute_from_command_line", pattern: /\bexecute_from_command_line\b/ },
158
+ ],
159
+ pathConfidence: 0.9,
160
+ signalBoost: 0.04,
161
+ requireSignal: false,
162
+ },
163
+ {
164
+ framework: "Python",
165
+ pathTest: (p) => {
166
+ const base = basename(posix(p));
167
+ return base === "main.py" || base === "app.py" || base === "wsgi.py" || base === "asgi.py";
168
+ },
169
+ signals: [
170
+ { label: "FastAPI()", pattern: /\bFastAPI\s*\(/ },
171
+ { label: "Flask(", pattern: /\bFlask\s*\(/ },
172
+ { label: "uvicorn", pattern: /\buvicorn\b/ },
173
+ { label: "if __name__", pattern: /if\s+__name__\s*==\s*["']__main__["']/ },
174
+ ],
175
+ pathConfidence: 0.55,
176
+ signalBoost: 0.15,
177
+ requireSignal: true,
178
+ },
179
+ {
180
+ framework: "Java",
181
+ pathTest: (p) => {
182
+ const path = posix(p);
183
+ return path.endsWith(".java") && /Application\.java$|Main\.java$/i.test(basename(path));
184
+ },
185
+ signals: [
186
+ { label: "@SpringBootApplication", pattern: /@SpringBootApplication\b/ },
187
+ { label: "public static void main", pattern: /public\s+static\s+void\s+main\s*\(/ },
188
+ { label: "SpringApplication.run", pattern: /\bSpringApplication\s*\.\s*run\s*\(/ },
189
+ ],
190
+ pathConfidence: 0.55,
191
+ signalBoost: 0.15,
192
+ requireSignal: true,
193
+ },
194
+ {
195
+ framework: "Go",
196
+ pathTest: (p) => basename(posix(p)) === "main.go",
197
+ signals: [
198
+ { label: "package main", pattern: /^package\s+main\b/m },
199
+ { label: "func main()", pattern: /\bfunc\s+main\s*\(\s*\)/ },
200
+ ],
201
+ pathConfidence: 0.65,
202
+ signalBoost: 0.15,
203
+ requireSignal: true,
204
+ },
205
+ {
206
+ framework: "Rust",
207
+ pathTest: (p) => {
208
+ const path = posix(p);
209
+ return (path === "src/main.rs" || path.endsWith("/src/main.rs") || basename(path) === "main.rs");
210
+ },
211
+ signals: [{ label: "fn main()", pattern: /\bfn\s+main\s*\(\s*\)/ }],
212
+ pathConfidence: 0.7,
213
+ signalBoost: 0.2,
214
+ requireSignal: true,
215
+ },
216
+ ];
@@ -0,0 +1,20 @@
1
+ export type EntrypointFramework = "Flutter" | "Laravel" | "React" | "Next.js" | "Node" | "NestJS" | "Python" | "Django" | "Java" | "Go" | "Rust";
2
+ export interface EntrypointMatch {
3
+ framework: EntrypointFramework;
4
+ file: string;
5
+ confidence: number;
6
+ evidence: string[];
7
+ }
8
+ export interface EntrypointDiscoveryResult {
9
+ entrypoints: EntrypointMatch[];
10
+ timingMs: number;
11
+ filesConsidered: number;
12
+ filesInspected: number;
13
+ }
14
+ export interface EntrypointDiscoveryOptions {
15
+ cwd?: string;
16
+ /** Minimum confidence to include (0–1). Default 0.55. */
17
+ minConfidence?: number;
18
+ /** Max bytes to read from a candidate file. Default 256 KiB. */
19
+ maxReadBytes?: number;
20
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Internal Software Understanding Engine.
3
+ * Not wired into scan/CLI. Import from this module only.
4
+ */
5
+ export { discoverDomains, scoreDomainConfidence } from "./domain/index.js";
6
+ export { discoverEntrypoints, scoreEntrypointConfidence, ENTRYPOINT_MODELS, } from "./entrypoints/index.js";
7
+ export { discoverDependencies, scoreDependencyConfidence, extractReferences, RELATION_CONFIDENCE, } from "./dependencies/index.js";
8
+ export { discoverRelationships, scoreRelationshipConfidence, classifyComponent, classifyRoleFromPath, extractSemanticSignals, ROLE_PAIR_RULES, } from "./relationships/index.js";
9
+ export { inferArchitectures, ARCHITECTURE_RULES, listArchitecturePatterns, scorePatternConfidence, } from "./architecture/index.js";
10
+ export { ProjectModelBuilder, buildProjectModel, serializeProjectModel, parseProjectModel, validateProjectModel, PROJECT_MODEL_SCHEMA, PROJECT_MODEL_SCHEMA_VERSION, UNDERSTANDING_COMPILER_VERSION, } from "./model/index.js";
11
+ export { QueryEngine, createQueryEngine, Queries, executeQuery, validateQuery, listSupportedQueryTypes, QueryError, QueryValidationError, QueryNotFoundError, QueryUnsupportedError, } from "./query/index.js";
12
+ export { UnderstandService, createUnderstandService, understandAsText, UNDERSTAND_LIMITATIONS, } from "./understand/index.js";
13
+ export { discoverOwnership, ownersForPath, matchCodeownersPattern, scoreOwnershipConfidence, } from "./ownership/index.js";
14
+ export { discoverRisks } from "./risks/index.js";
15
+ export { computeContentHash, createSnapshotIdentity, hashSerializedModel, } from "./snapshot/index.js";
16
+ export { compareProjectModels } from "./delta/index.js";
17
+ export { buildProjectMind, buildProjectMindSync, extractClaims, findMindClaim, findMindOwner, findMindRisks, listMindOwnership, listMindRisks, mindSummary, PROJECT_MIND_LIMITATIONS, } from "./mind/index.js";
18
+ export type { DomainDiscoveryOptions, DomainDiscoveryResult, DomainMatch, UnderstandingConfidence, UnderstandingEvidence, } from "./types/index.js";
19
+ export type { EntrypointDiscoveryOptions, EntrypointDiscoveryResult, EntrypointFramework, EntrypointMatch, } from "./entrypoints/types.js";
20
+ export type { DependencyDiscoveryOptions, DependencyDiscoveryResult, DependencyMatch, DependencyRelationType, ExtractedReference, } from "./dependencies/types.js";
21
+ export type { RelationshipDiscoveryOptions, RelationshipDiscoveryResult, RelationshipKind, RelationshipMatch, RelationshipStrength, ComponentRole, } from "./relationships/types.js";
22
+ export type { ArchitectureInferenceInput, ArchitectureInferenceOptions, ArchitectureInferenceResult, ArchitectureMatch, ArchitecturePattern, } from "./architecture/types.js";
23
+ export type { ProjectModel, ProjectModelBuilderInput, ProjectModelValidationResult, CompilerPassId, } from "./model/types.js";
24
+ export type { Query, QueryType, QueryResponse, QueryMetadata, FindDomainResult, RepositorySummaryResult, } from "./query/index.js";
25
+ export type { UnderstandResult, UnderstandSection, UnderstandSnapshot, UnderstandServiceOptions, } from "./understand/types.js";
26
+ export type { OwnershipDiscoveryOptions, OwnershipDiscoveryResult, OwnershipMatch, OwnershipSource, } from "./ownership/index.js";
27
+ export type { RiskDiscoveryOptions, RiskDiscoveryResult, RiskKind, RiskMatch, RiskSeverity, } from "./risks/index.js";
28
+ export type { SnapshotIdentity } from "./snapshot/index.js";
29
+ export type { SetDelta, UnderstandingDelta } from "./delta/index.js";
30
+ export type { BuildProjectMindOptions, ClaimKind, ProjectClaim, ProjectMind, } from "./mind/index.js";
31
+ export { buildProjectBrain, createBrainQueryEngine, BrainQueryEngine, explainClaim, traceBrain, buildBrainDelta, serializeBrainDelta, parseBrainDelta, LocalBrainStore, BrainStorageError, serializeBrain, CONFIDENCE_CONTRACT, PROJECT_BRAIN_SCHEMA_VERSION, BRAIN_STORAGE_FORMAT_VERSION, PROJECT_BRAIN_LIMITATIONS, PROJECT_BRAIN_CONTRACT, assertBrainContract, redactBrainForStorage, applyClaimLifecycle, detectContradictions, } from "./brain/index.js";
32
+ export type { ProjectBrain, BrainClaim, BrainEvidence, BrainDelta, BrainQuery, BrainQueryResponse, ClaimExplanation, TraceResult, TraceMode, SnapshotMeta, BrainComponent, ClaimStatus, BuildProjectBrainOptions, } from "./brain/index.js";
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Internal Software Understanding Engine.
3
+ * Not wired into scan/CLI. Import from this module only.
4
+ */
5
+ export { discoverDomains, scoreDomainConfidence } from "./domain/index.js";
6
+ export { discoverEntrypoints, scoreEntrypointConfidence, ENTRYPOINT_MODELS, } from "./entrypoints/index.js";
7
+ export { discoverDependencies, scoreDependencyConfidence, extractReferences, RELATION_CONFIDENCE, } from "./dependencies/index.js";
8
+ export { discoverRelationships, scoreRelationshipConfidence, classifyComponent, classifyRoleFromPath, extractSemanticSignals, ROLE_PAIR_RULES, } from "./relationships/index.js";
9
+ export { inferArchitectures, ARCHITECTURE_RULES, listArchitecturePatterns, scorePatternConfidence, } from "./architecture/index.js";
10
+ export { ProjectModelBuilder, buildProjectModel, serializeProjectModel, parseProjectModel, validateProjectModel, PROJECT_MODEL_SCHEMA, PROJECT_MODEL_SCHEMA_VERSION, UNDERSTANDING_COMPILER_VERSION, } from "./model/index.js";
11
+ export { QueryEngine, createQueryEngine, Queries, executeQuery, validateQuery, listSupportedQueryTypes, QueryError, QueryValidationError, QueryNotFoundError, QueryUnsupportedError, } from "./query/index.js";
12
+ export { UnderstandService, createUnderstandService, understandAsText, UNDERSTAND_LIMITATIONS, } from "./understand/index.js";
13
+ export { discoverOwnership, ownersForPath, matchCodeownersPattern, scoreOwnershipConfidence, } from "./ownership/index.js";
14
+ export { discoverRisks } from "./risks/index.js";
15
+ export { computeContentHash, createSnapshotIdentity, hashSerializedModel, } from "./snapshot/index.js";
16
+ export { compareProjectModels } from "./delta/index.js";
17
+ export { buildProjectMind, buildProjectMindSync, extractClaims, findMindClaim, findMindOwner, findMindRisks, listMindOwnership, listMindRisks, mindSummary, PROJECT_MIND_LIMITATIONS, } from "./mind/index.js";
18
+ export { buildProjectBrain, createBrainQueryEngine, BrainQueryEngine, explainClaim, traceBrain, buildBrainDelta, serializeBrainDelta, parseBrainDelta, LocalBrainStore, BrainStorageError, serializeBrain, CONFIDENCE_CONTRACT, PROJECT_BRAIN_SCHEMA_VERSION, BRAIN_STORAGE_FORMAT_VERSION, PROJECT_BRAIN_LIMITATIONS, PROJECT_BRAIN_CONTRACT, assertBrainContract, redactBrainForStorage, applyClaimLifecycle, detectContradictions, } from "./brain/index.js";
@@ -0,0 +1,16 @@
1
+ import type { ProjectModel } from "../model/types.js";
2
+ import { type OwnershipDiscoveryResult } from "../ownership/index.js";
3
+ import { type RiskDiscoveryResult } from "../risks/index.js";
4
+ import { type ProjectClaim, type ProjectMind } from "./types.js";
5
+ export declare function extractClaims(model: ProjectModel, ownership: OwnershipDiscoveryResult, risks: RiskDiscoveryResult, snapshotId: string): ProjectClaim[];
6
+ export interface BuildProjectMindOptions {
7
+ cwd?: string;
8
+ ownership?: OwnershipDiscoveryResult;
9
+ risks?: RiskDiscoveryResult;
10
+ }
11
+ /**
12
+ * Build a Project Mind from a ProjectModel (+ ownership/risk discovery).
13
+ * Never invents facts; preserves unknowns.
14
+ */
15
+ export declare function buildProjectMind(model: ProjectModel, options?: BuildProjectMindOptions): Promise<ProjectMind>;
16
+ export declare function buildProjectMindSync(model: ProjectModel, ownership: OwnershipDiscoveryResult, risks?: RiskDiscoveryResult): ProjectMind;
@@ -0,0 +1,134 @@
1
+ import { discoverOwnership } from "../ownership/index.js";
2
+ import { discoverRisks } from "../risks/index.js";
3
+ import { createSnapshotIdentity } from "../snapshot/index.js";
4
+ import { PROJECT_MIND_LIMITATIONS } from "./types.js";
5
+ function collectUnknowns(ownership, risks, model) {
6
+ const unknowns = new Set();
7
+ for (const item of ownership.unknowns) {
8
+ unknowns.add(item);
9
+ }
10
+ for (const item of risks.unknowns) {
11
+ unknowns.add(item);
12
+ }
13
+ for (const arch of model.architectures) {
14
+ for (const unknown of arch.unknowns) {
15
+ unknowns.add(unknown);
16
+ }
17
+ }
18
+ if (model.domains.length === 0) {
19
+ unknowns.add("No domains discovered at current confidence thresholds");
20
+ }
21
+ return [...unknowns].sort((a, b) => a.localeCompare(b));
22
+ }
23
+ export function extractClaims(model, ownership, risks, snapshotId) {
24
+ const claims = [];
25
+ for (const domain of model.domains) {
26
+ claims.push({
27
+ id: domain.id,
28
+ kind: "domain",
29
+ subject: domain.name,
30
+ confidence: domain.confidence,
31
+ evidence: domain.evidence,
32
+ snapshotId,
33
+ });
34
+ }
35
+ for (const entry of model.entrypoints) {
36
+ claims.push({
37
+ id: entry.id,
38
+ kind: "entrypoint",
39
+ subject: entry.file,
40
+ confidence: entry.confidence,
41
+ evidence: entry.evidence,
42
+ snapshotId,
43
+ });
44
+ }
45
+ for (const dep of model.dependencies) {
46
+ claims.push({
47
+ id: dep.id,
48
+ kind: "dependency",
49
+ subject: `${dep.from}->${dep.to}`,
50
+ confidence: dep.confidence,
51
+ evidence: dep.evidence,
52
+ snapshotId,
53
+ });
54
+ }
55
+ for (const rel of model.relationships) {
56
+ claims.push({
57
+ id: rel.id,
58
+ kind: "relationship",
59
+ subject: `${rel.source}->${rel.target}:${rel.relationship}`,
60
+ confidence: rel.confidence,
61
+ evidence: rel.evidence,
62
+ snapshotId,
63
+ });
64
+ }
65
+ for (const arch of model.architectures) {
66
+ claims.push({
67
+ id: arch.id,
68
+ kind: "architecture",
69
+ subject: arch.pattern,
70
+ confidence: arch.confidence,
71
+ evidence: arch.evidence,
72
+ snapshotId,
73
+ });
74
+ }
75
+ ownership.ownerships.forEach((ownershipMatch, index) => {
76
+ claims.push({
77
+ id: `ownership_${index}_${ownershipMatch.path}`,
78
+ kind: "ownership",
79
+ subject: ownershipMatch.path,
80
+ confidence: ownershipMatch.confidence,
81
+ evidence: ownershipMatch.evidence,
82
+ snapshotId,
83
+ });
84
+ });
85
+ risks.risks.forEach((risk, index) => {
86
+ claims.push({
87
+ id: `risk_${index}_${risk.kind}_${risk.target}`,
88
+ kind: "risk",
89
+ subject: risk.target,
90
+ confidence: risk.confidence,
91
+ evidence: risk.evidence,
92
+ snapshotId,
93
+ });
94
+ });
95
+ return claims.sort((a, b) => b.confidence - a.confidence ||
96
+ a.kind.localeCompare(b.kind) ||
97
+ a.subject.localeCompare(b.subject));
98
+ }
99
+ /**
100
+ * Build a Project Mind from a ProjectModel (+ ownership/risk discovery).
101
+ * Never invents facts; preserves unknowns.
102
+ */
103
+ export async function buildProjectMind(model, options = {}) {
104
+ const snapshot = createSnapshotIdentity(model);
105
+ const ownership = options.ownership ??
106
+ (await discoverOwnership(options.cwd !== undefined ? { cwd: options.cwd } : {}));
107
+ const risks = options.risks ?? discoverRisks(model, ownership);
108
+ const claims = extractClaims(model, ownership, risks, snapshot.id);
109
+ const unknowns = collectUnknowns(ownership, risks, model);
110
+ return Object.freeze({
111
+ snapshot,
112
+ model,
113
+ ownership,
114
+ risks,
115
+ claims: Object.freeze(claims),
116
+ unknowns: Object.freeze(unknowns),
117
+ limitations: Object.freeze([...PROJECT_MIND_LIMITATIONS]),
118
+ });
119
+ }
120
+ export function buildProjectMindSync(model, ownership, risks) {
121
+ const snapshot = createSnapshotIdentity(model);
122
+ const resolvedRisks = risks ?? discoverRisks(model, ownership);
123
+ const claims = extractClaims(model, ownership, resolvedRisks, snapshot.id);
124
+ const unknowns = collectUnknowns(ownership, resolvedRisks, model);
125
+ return Object.freeze({
126
+ snapshot,
127
+ model,
128
+ ownership,
129
+ risks: resolvedRisks,
130
+ claims: Object.freeze(claims),
131
+ unknowns: Object.freeze(unknowns),
132
+ limitations: Object.freeze([...PROJECT_MIND_LIMITATIONS]),
133
+ });
134
+ }
@@ -0,0 +1,6 @@
1
+ export { buildProjectMind, buildProjectMindSync, extractClaims } from "./build.js";
2
+ export { findMindClaim, findMindOwner, findMindRisks, listMindOwnership, listMindRisks, mindSummary, } from "./query.js";
3
+ export { PROJECT_MIND_LIMITATIONS } from "./types.js";
4
+ export type { BuildProjectMindOptions } from "./build.js";
5
+ export type { MindClaimResult, MindOwnershipResult, MindRiskResult } from "./query.js";
6
+ export type { ClaimKind, ProjectClaim, ProjectMind } from "./types.js";
@@ -0,0 +1,3 @@
1
+ export { buildProjectMind, buildProjectMindSync, extractClaims } from "./build.js";
2
+ export { findMindClaim, findMindOwner, findMindRisks, listMindOwnership, listMindRisks, mindSummary, } from "./query.js";
3
+ export { PROJECT_MIND_LIMITATIONS } from "./types.js";
@@ -0,0 +1,33 @@
1
+ import type { OwnershipMatch } from "../ownership/types.js";
2
+ import type { RiskMatch } from "../risks/types.js";
3
+ import type { ProjectClaim, ProjectMind } from "./types.js";
4
+ export interface MindOwnershipResult {
5
+ ownerships: readonly OwnershipMatch[];
6
+ count: number;
7
+ unknowns: readonly string[];
8
+ }
9
+ export interface MindRiskResult {
10
+ risks: readonly RiskMatch[];
11
+ count: number;
12
+ unknowns: readonly string[];
13
+ }
14
+ export interface MindClaimResult {
15
+ claim: ProjectClaim | null;
16
+ found: boolean;
17
+ }
18
+ export declare function listMindOwnership(mind: ProjectMind): MindOwnershipResult;
19
+ export declare function listMindRisks(mind: ProjectMind): MindRiskResult;
20
+ export declare function findMindOwner(mind: ProjectMind, filePath: string): OwnershipMatch | null;
21
+ export declare function findMindRisks(mind: ProjectMind, target: string): RiskMatch[];
22
+ export declare function findMindClaim(mind: ProjectMind, claimId: string): MindClaimResult;
23
+ export declare function mindSummary(mind: ProjectMind): {
24
+ projectName: string;
25
+ snapshotId: string;
26
+ contentHash: string;
27
+ claimCount: number;
28
+ ownershipCount: number;
29
+ riskCount: number;
30
+ unknownCount: number;
31
+ topDomains: readonly string[];
32
+ topRisks: readonly string[];
33
+ };
@@ -0,0 +1,39 @@
1
+ import { ownersForPath } from "../ownership/index.js";
2
+ export function listMindOwnership(mind) {
3
+ return {
4
+ ownerships: mind.ownership.ownerships,
5
+ count: mind.ownership.ownerships.length,
6
+ unknowns: mind.ownership.unknowns,
7
+ };
8
+ }
9
+ export function listMindRisks(mind) {
10
+ return {
11
+ risks: mind.risks.risks,
12
+ count: mind.risks.risks.length,
13
+ unknowns: mind.risks.unknowns,
14
+ };
15
+ }
16
+ export function findMindOwner(mind, filePath) {
17
+ return ownersForPath(filePath, mind.ownership.ownerships);
18
+ }
19
+ export function findMindRisks(mind, target) {
20
+ const needle = target.toLowerCase();
21
+ return mind.risks.risks.filter((risk) => risk.target.toLowerCase().includes(needle) || risk.kind.toLowerCase().includes(needle));
22
+ }
23
+ export function findMindClaim(mind, claimId) {
24
+ const claim = mind.claims.find((item) => item.id === claimId) ?? null;
25
+ return { claim, found: claim !== null };
26
+ }
27
+ export function mindSummary(mind) {
28
+ return {
29
+ projectName: mind.model.metadata.project.name,
30
+ snapshotId: mind.snapshot.id,
31
+ contentHash: mind.snapshot.contentHash,
32
+ claimCount: mind.claims.length,
33
+ ownershipCount: mind.ownership.ownerships.length,
34
+ riskCount: mind.risks.risks.length,
35
+ unknownCount: mind.unknowns.length,
36
+ topDomains: mind.model.summary.topDomains,
37
+ topRisks: mind.risks.risks.slice(0, 5).map((risk) => `${risk.kind}:${risk.target}`),
38
+ };
39
+ }
@@ -0,0 +1,24 @@
1
+ import type { ProjectModel } from "../model/types.js";
2
+ import type { OwnershipDiscoveryResult } from "../ownership/types.js";
3
+ import type { RiskDiscoveryResult } from "../risks/types.js";
4
+ import type { SnapshotIdentity } from "../snapshot/index.js";
5
+ export type ClaimKind = "domain" | "entrypoint" | "dependency" | "relationship" | "architecture" | "ownership" | "risk";
6
+ export interface ProjectClaim {
7
+ id: string;
8
+ kind: ClaimKind;
9
+ subject: string;
10
+ confidence: number;
11
+ evidence: readonly string[];
12
+ /** Snapshot that produced this claim. */
13
+ snapshotId: string;
14
+ }
15
+ export interface ProjectMind {
16
+ snapshot: SnapshotIdentity;
17
+ model: ProjectModel;
18
+ ownership: OwnershipDiscoveryResult;
19
+ risks: RiskDiscoveryResult;
20
+ claims: readonly ProjectClaim[];
21
+ unknowns: readonly string[];
22
+ limitations: readonly string[];
23
+ }
24
+ export declare const PROJECT_MIND_LIMITATIONS: readonly ["Project Mind is derived from deterministic compiler passes only", "Ownership requires explicit CODEOWNERS / MAINTAINERS / package.json evidence", "Risks describe change-danger, not vulnerability scanning", "Business rules and design intent remain unknown unless evidenced", "AI consumers must not invent repository facts beyond this representation"];
@@ -0,0 +1,7 @@
1
+ export const PROJECT_MIND_LIMITATIONS = [
2
+ "Project Mind is derived from deterministic compiler passes only",
3
+ "Ownership requires explicit CODEOWNERS / MAINTAINERS / package.json evidence",
4
+ "Risks describe change-danger, not vulnerability scanning",
5
+ "Business rules and design intent remain unknown unless evidenced",
6
+ "AI consumers must not invent repository facts beyond this representation",
7
+ ];
@@ -0,0 +1,9 @@
1
+ import type { ProjectModel, ProjectModelBuilderInput } from "./types.js";
2
+ /**
3
+ * Builds a canonical immutable ProjectModel from compiler pass outputs.
4
+ */
5
+ export declare class ProjectModelBuilder {
6
+ build(input: ProjectModelBuilderInput): ProjectModel;
7
+ }
8
+ /** Convenience function wrapping ProjectModelBuilder. */
9
+ export declare function buildProjectModel(input: ProjectModelBuilderInput): ProjectModel;