semantic-atlas 0.4.0 → 2.0.0

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 (346) hide show
  1. package/.agents/skills/semantic-atlas/SKILL.md +134 -166
  2. package/.agents/skills/semantic-atlas/agents/openai.yaml +4 -0
  3. package/.agents/skills/semantic-atlas/references/observations.md +130 -0
  4. package/.agents/skills/semantic-atlas/scripts/query-context.mjs +110 -0
  5. package/.agents/skills/semantic-atlas-maintenance/SKILL.md +93 -0
  6. package/.agents/skills/semantic-atlas-maintenance/agents/openai.yaml +4 -0
  7. package/.agents/skills/semantic-atlas-maintenance/references/reconciliation.md +56 -0
  8. package/README.md +133 -265
  9. package/dist/application/map-application.d.ts +24 -0
  10. package/dist/application/map-application.d.ts.map +1 -0
  11. package/dist/application/map-application.js +134 -0
  12. package/dist/application/map-application.js.map +1 -0
  13. package/dist/cli/bin.js +6 -42
  14. package/dist/cli/bin.js.map +1 -0
  15. package/dist/cli/observation-commands.d.ts +16 -0
  16. package/dist/cli/observation-commands.d.ts.map +1 -0
  17. package/dist/cli/observation-commands.js +118 -0
  18. package/dist/cli/observation-commands.js.map +1 -0
  19. package/dist/cli/projection-writer.d.ts +2 -0
  20. package/dist/cli/projection-writer.d.ts.map +1 -0
  21. package/dist/cli/projection-writer.js +9 -0
  22. package/dist/cli/projection-writer.js.map +1 -0
  23. package/dist/cli/reconciliation-command.d.ts +7 -0
  24. package/dist/cli/reconciliation-command.d.ts.map +1 -0
  25. package/dist/cli/reconciliation-command.js +33 -0
  26. package/dist/cli/reconciliation-command.js.map +1 -0
  27. package/dist/cli/run-cli.d.ts +21 -0
  28. package/dist/cli/run-cli.d.ts.map +1 -0
  29. package/dist/cli/run-cli.js +299 -0
  30. package/dist/cli/run-cli.js.map +1 -0
  31. package/dist/contracts/cli.d.ts +166 -1211
  32. package/dist/contracts/cli.d.ts.map +1 -1
  33. package/dist/contracts/cli.js +2 -232
  34. package/dist/contracts/cli.js.map +1 -0
  35. package/dist/contracts/insights.d.ts +39 -1
  36. package/dist/contracts/insights.d.ts.map +1 -1
  37. package/dist/contracts/insights.js +2 -1
  38. package/dist/contracts/insights.js.map +1 -0
  39. package/dist/contracts/map.d.ts +154 -0
  40. package/dist/contracts/map.d.ts.map +1 -0
  41. package/dist/contracts/map.js +60 -0
  42. package/dist/contracts/map.js.map +1 -0
  43. package/dist/contracts/observation.d.ts +414 -0
  44. package/dist/contracts/observation.d.ts.map +1 -0
  45. package/dist/contracts/observation.js +125 -0
  46. package/dist/contracts/observation.js.map +1 -0
  47. package/dist/contracts/projection.d.ts +7 -0
  48. package/dist/contracts/projection.d.ts.map +1 -0
  49. package/dist/contracts/projection.js +2 -0
  50. package/dist/contracts/projection.js.map +1 -0
  51. package/dist/contracts/reconciliation.d.ts +40 -0
  52. package/dist/contracts/reconciliation.d.ts.map +1 -0
  53. package/dist/contracts/reconciliation.js +2 -0
  54. package/dist/contracts/reconciliation.js.map +1 -0
  55. package/dist/index.d.ts +7 -17
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +3 -9
  58. package/dist/index.js.map +1 -0
  59. package/dist/insights/insight-service.d.ts +14 -0
  60. package/dist/insights/insight-service.d.ts.map +1 -0
  61. package/dist/insights/insight-service.js +129 -0
  62. package/dist/insights/insight-service.js.map +1 -0
  63. package/dist/map/business-graph.d.ts +32 -0
  64. package/dist/map/business-graph.d.ts.map +1 -0
  65. package/dist/map/business-graph.js +122 -0
  66. package/dist/map/business-graph.js.map +1 -0
  67. package/dist/map/map-document-loader.d.ts +13 -0
  68. package/dist/map/map-document-loader.d.ts.map +1 -0
  69. package/dist/map/map-document-loader.js +86 -0
  70. package/dist/map/map-document-loader.js.map +1 -0
  71. package/dist/map/map-validator.d.ts +12 -0
  72. package/dist/map/map-validator.d.ts.map +1 -0
  73. package/dist/map/map-validator.js +322 -0
  74. package/dist/map/map-validator.js.map +1 -0
  75. package/dist/observations/observation-application.d.ts +23 -0
  76. package/dist/observations/observation-application.d.ts.map +1 -0
  77. package/dist/observations/observation-application.js +62 -0
  78. package/dist/observations/observation-application.js.map +1 -0
  79. package/dist/observations/observation-claim-manager.d.ts +17 -0
  80. package/dist/observations/observation-claim-manager.d.ts.map +1 -0
  81. package/dist/observations/observation-claim-manager.js +198 -0
  82. package/dist/observations/observation-claim-manager.js.map +1 -0
  83. package/dist/observations/observation-store.d.ts +43 -0
  84. package/dist/observations/observation-store.d.ts.map +1 -0
  85. package/dist/observations/observation-store.js +213 -0
  86. package/dist/observations/observation-store.js.map +1 -0
  87. package/dist/observations/repository-identity.d.ts +12 -0
  88. package/dist/observations/repository-identity.d.ts.map +1 -0
  89. package/dist/observations/repository-identity.js +108 -0
  90. package/dist/observations/repository-identity.js.map +1 -0
  91. package/dist/query/context-query-service.d.ts +15 -0
  92. package/dist/query/context-query-service.d.ts.map +1 -0
  93. package/dist/query/context-query-service.js +36 -0
  94. package/dist/query/context-query-service.js.map +1 -0
  95. package/dist/reconciliation/reconciliation-service.d.ts +10 -0
  96. package/dist/reconciliation/reconciliation-service.d.ts.map +1 -0
  97. package/dist/reconciliation/reconciliation-service.js +114 -0
  98. package/dist/reconciliation/reconciliation-service.js.map +1 -0
  99. package/dist/rendering/map-projector.d.ts +8 -0
  100. package/dist/rendering/map-projector.d.ts.map +1 -0
  101. package/dist/rendering/map-projector.js +386 -0
  102. package/dist/rendering/map-projector.js.map +1 -0
  103. package/dist/setup/managed-skill-installer.d.ts +60 -0
  104. package/dist/setup/managed-skill-installer.d.ts.map +1 -0
  105. package/dist/setup/managed-skill-installer.js +293 -0
  106. package/dist/setup/managed-skill-installer.js.map +1 -0
  107. package/dist/setup/package-identity.d.ts +6 -0
  108. package/dist/setup/package-identity.d.ts.map +1 -0
  109. package/dist/setup/package-identity.js +16 -0
  110. package/dist/setup/package-identity.js.map +1 -0
  111. package/dist/setup/package-upgrader.d.ts +10 -22
  112. package/dist/setup/package-upgrader.d.ts.map +1 -1
  113. package/dist/setup/package-upgrader.js +60 -76
  114. package/dist/setup/package-upgrader.js.map +1 -0
  115. package/docs/architecture.md +426 -0
  116. package/docs/evaluation.md +220 -174
  117. package/docs/index.md +27 -45
  118. package/docs/map-format.md +225 -0
  119. package/docs/observations.md +167 -0
  120. package/docs/product-contract.md +282 -165
  121. package/examples/commerce.yaml +204 -0
  122. package/package.json +31 -32
  123. package/.agents/skills/semantic-atlas/references/graph-patch.md +0 -190
  124. package/.agents/skills/semantic-atlas/references/product-feedback.md +0 -34
  125. package/.agents/skills/semantic-atlas/references/result-routing.md +0 -104
  126. package/.agents/skills/semantic-atlas/references/snapshot-bootstrap.md +0 -42
  127. package/.agents/skills/semantic-atlas-insights/SKILL.md +0 -55
  128. package/README.zh-CN.md +0 -296
  129. package/dist/business-flow/business-flow-derivation-service.d.ts +0 -11
  130. package/dist/business-flow/business-flow-derivation-service.d.ts.map +0 -1
  131. package/dist/business-flow/business-flow-derivation-service.js +0 -151
  132. package/dist/business-flow/business-flow-draft.d.ts +0 -16
  133. package/dist/business-flow/business-flow-draft.d.ts.map +0 -1
  134. package/dist/business-flow/business-flow-draft.js +0 -150
  135. package/dist/business-flow/framework-business-strategy.d.ts +0 -7
  136. package/dist/business-flow/framework-business-strategy.d.ts.map +0 -1
  137. package/dist/business-flow/framework-business-strategy.js +0 -1
  138. package/dist/business-flow/strategies/bullmq-business-strategy.d.ts +0 -10
  139. package/dist/business-flow/strategies/bullmq-business-strategy.d.ts.map +0 -1
  140. package/dist/business-flow/strategies/bullmq-business-strategy.js +0 -79
  141. package/dist/business-flow/strategies/called-operation-derivation.d.ts +0 -13
  142. package/dist/business-flow/strategies/called-operation-derivation.d.ts.map +0 -1
  143. package/dist/business-flow/strategies/called-operation-derivation.js +0 -32
  144. package/dist/business-flow/strategies/graphql-business-strategy.d.ts +0 -8
  145. package/dist/business-flow/strategies/graphql-business-strategy.d.ts.map +0 -1
  146. package/dist/business-flow/strategies/graphql-business-strategy.js +0 -65
  147. package/dist/business-flow/strategies/nestjs-business-strategy.d.ts +0 -8
  148. package/dist/business-flow/strategies/nestjs-business-strategy.d.ts.map +0 -1
  149. package/dist/business-flow/strategies/nestjs-business-strategy.js +0 -72
  150. package/dist/business-flow/strategies/strategy-helpers.d.ts +0 -32
  151. package/dist/business-flow/strategies/strategy-helpers.d.ts.map +0 -1
  152. package/dist/business-flow/strategies/strategy-helpers.js +0 -49
  153. package/dist/business-flow/strategies/typeorm-business-strategy.d.ts +0 -10
  154. package/dist/business-flow/strategies/typeorm-business-strategy.d.ts.map +0 -1
  155. package/dist/business-flow/strategies/typeorm-business-strategy.js +0 -136
  156. package/dist/business-flow/strategies/verified-invariant-strategy.d.ts +0 -5
  157. package/dist/business-flow/strategies/verified-invariant-strategy.d.ts.map +0 -1
  158. package/dist/business-flow/strategies/verified-invariant-strategy.js +0 -38
  159. package/dist/business-flow/strategies/verified-test-strategy.d.ts +0 -5
  160. package/dist/business-flow/strategies/verified-test-strategy.d.ts.map +0 -1
  161. package/dist/business-flow/strategies/verified-test-strategy.js +0 -26
  162. package/dist/business-flow/structural-flow-catalog.d.ts +0 -21
  163. package/dist/business-flow/structural-flow-catalog.d.ts.map +0 -1
  164. package/dist/business-flow/structural-flow-catalog.js +0 -125
  165. package/dist/business-flow/types.d.ts +0 -51
  166. package/dist/business-flow/types.d.ts.map +0 -1
  167. package/dist/business-flow/types.js +0 -1
  168. package/dist/cli/argument-parser.d.ts +0 -3
  169. package/dist/cli/argument-parser.d.ts.map +0 -1
  170. package/dist/cli/argument-parser.js +0 -200
  171. package/dist/cli/cli-application.d.ts +0 -39
  172. package/dist/cli/cli-application.d.ts.map +0 -1
  173. package/dist/cli/cli-application.js +0 -571
  174. package/dist/cli/cli-error.d.ts +0 -12
  175. package/dist/cli/cli-error.d.ts.map +0 -1
  176. package/dist/cli/cli-error.js +0 -44
  177. package/dist/cli/cli-presenter.d.ts +0 -14
  178. package/dist/cli/cli-presenter.d.ts.map +0 -1
  179. package/dist/cli/cli-presenter.js +0 -36
  180. package/dist/cli/insights-cli.d.ts +0 -6
  181. package/dist/cli/insights-cli.d.ts.map +0 -1
  182. package/dist/cli/insights-cli.js +0 -236
  183. package/dist/cli/main.d.ts +0 -3
  184. package/dist/cli/main.d.ts.map +0 -1
  185. package/dist/cli/main.js +0 -137
  186. package/dist/cli/standalone-cli.d.ts +0 -3
  187. package/dist/cli/standalone-cli.d.ts.map +0 -1
  188. package/dist/cli/standalone-cli.js +0 -104
  189. package/dist/cli/types.d.ts +0 -49
  190. package/dist/cli/types.d.ts.map +0 -1
  191. package/dist/cli/types.js +0 -1
  192. package/dist/cli/web-cli.d.ts +0 -9
  193. package/dist/cli/web-cli.d.ts.map +0 -1
  194. package/dist/cli/web-cli.js +0 -134
  195. package/dist/contracts/graph.d.ts +0 -266
  196. package/dist/contracts/graph.d.ts.map +0 -1
  197. package/dist/contracts/graph.js +0 -182
  198. package/dist/contracts/identifiers.d.ts +0 -4
  199. package/dist/contracts/identifiers.d.ts.map +0 -1
  200. package/dist/contracts/identifiers.js +0 -7
  201. package/dist/contracts/public-contracts.d.ts +0 -5
  202. package/dist/contracts/public-contracts.d.ts.map +0 -1
  203. package/dist/contracts/public-contracts.js +0 -4
  204. package/dist/evaluation/comparison.d.ts +0 -30
  205. package/dist/evaluation/comparison.d.ts.map +0 -1
  206. package/dist/evaluation/comparison.js +0 -108
  207. package/dist/evaluation/contracts.d.ts +0 -301
  208. package/dist/evaluation/contracts.d.ts.map +0 -1
  209. package/dist/evaluation/contracts.js +0 -413
  210. package/dist/graph/graph-store.d.ts +0 -55
  211. package/dist/graph/graph-store.d.ts.map +0 -1
  212. package/dist/graph/graph-store.js +0 -912
  213. package/dist/graph/types.d.ts +0 -189
  214. package/dist/graph/types.d.ts.map +0 -1
  215. package/dist/graph/types.js +0 -1
  216. package/dist/insights/contracts.d.ts +0 -266
  217. package/dist/insights/contracts.d.ts.map +0 -1
  218. package/dist/insights/contracts.js +0 -124
  219. package/dist/insights/insights-store.d.ts +0 -73
  220. package/dist/insights/insights-store.d.ts.map +0 -1
  221. package/dist/insights/insights-store.js +0 -246
  222. package/dist/knowledge/business-knowledge-service.d.ts +0 -24
  223. package/dist/knowledge/business-knowledge-service.d.ts.map +0 -1
  224. package/dist/knowledge/business-knowledge-service.js +0 -200
  225. package/dist/knowledge/graph-patch-conflict-error.d.ts +0 -8
  226. package/dist/knowledge/graph-patch-conflict-error.d.ts.map +0 -1
  227. package/dist/knowledge/graph-patch-conflict-error.js +0 -12
  228. package/dist/knowledge/structural-target-binding.d.ts +0 -14
  229. package/dist/knowledge/structural-target-binding.d.ts.map +0 -1
  230. package/dist/knowledge/structural-target-binding.js +0 -11
  231. package/dist/package-metadata.d.ts +0 -2
  232. package/dist/package-metadata.d.ts.map +0 -1
  233. package/dist/package-metadata.js +0 -9
  234. package/dist/repository/git-command.d.ts +0 -3
  235. package/dist/repository/git-command.d.ts.map +0 -1
  236. package/dist/repository/git-command.js +0 -25
  237. package/dist/repository/repository-inspector.d.ts +0 -8
  238. package/dist/repository/repository-inspector.d.ts.map +0 -1
  239. package/dist/repository/repository-inspector.js +0 -97
  240. package/dist/repository/repository-language-support.d.ts +0 -14
  241. package/dist/repository/repository-language-support.d.ts.map +0 -1
  242. package/dist/repository/repository-language-support.js +0 -64
  243. package/dist/repository/types.d.ts +0 -9
  244. package/dist/repository/types.d.ts.map +0 -1
  245. package/dist/repository/types.js +0 -1
  246. package/dist/runtime/sqlite-compatibility-process.d.ts +0 -8
  247. package/dist/runtime/sqlite-compatibility-process.d.ts.map +0 -1
  248. package/dist/runtime/sqlite-compatibility-process.js +0 -20
  249. package/dist/setup/skill-installer.d.ts +0 -20
  250. package/dist/setup/skill-installer.d.ts.map +0 -1
  251. package/dist/setup/skill-installer.js +0 -187
  252. package/dist/snapshots/repository-snapshot.d.ts +0 -4
  253. package/dist/snapshots/repository-snapshot.d.ts.map +0 -1
  254. package/dist/snapshots/repository-snapshot.js +0 -119
  255. package/dist/snapshots/types.d.ts +0 -30
  256. package/dist/snapshots/types.d.ts.map +0 -1
  257. package/dist/snapshots/types.js +0 -1
  258. package/dist/storage/atlas-database.d.ts +0 -25
  259. package/dist/storage/atlas-database.d.ts.map +0 -1
  260. package/dist/storage/atlas-database.js +0 -483
  261. package/dist/storage/snapshot-store.d.ts +0 -19
  262. package/dist/storage/snapshot-store.d.ts.map +0 -1
  263. package/dist/storage/snapshot-store.js +0 -74
  264. package/dist/structural-backend/codegraph-backend.d.ts +0 -57
  265. package/dist/structural-backend/codegraph-backend.d.ts.map +0 -1
  266. package/dist/structural-backend/codegraph-backend.js +0 -1230
  267. package/dist/structural-backend/codegraph-worker-client.d.ts +0 -5
  268. package/dist/structural-backend/codegraph-worker-client.d.ts.map +0 -1
  269. package/dist/structural-backend/codegraph-worker-client.js +0 -118
  270. package/dist/structural-backend/codegraph-worker-protocol.d.ts +0 -35
  271. package/dist/structural-backend/codegraph-worker-protocol.d.ts.map +0 -1
  272. package/dist/structural-backend/codegraph-worker-protocol.js +0 -1
  273. package/dist/structural-backend/codegraph-worker.d.ts +0 -2
  274. package/dist/structural-backend/codegraph-worker.d.ts.map +0 -1
  275. package/dist/structural-backend/codegraph-worker.js +0 -131
  276. package/dist/structural-backend/process-instance.d.ts +0 -18
  277. package/dist/structural-backend/process-instance.d.ts.map +0 -1
  278. package/dist/structural-backend/process-instance.js +0 -207
  279. package/dist/structural-backend/structural-fact-changes.d.ts +0 -7
  280. package/dist/structural-backend/structural-fact-changes.d.ts.map +0 -1
  281. package/dist/structural-backend/structural-fact-changes.js +0 -78
  282. package/dist/structural-backend/structural-projection-bootstrapper.d.ts +0 -10
  283. package/dist/structural-backend/structural-projection-bootstrapper.d.ts.map +0 -1
  284. package/dist/structural-backend/structural-projection-bootstrapper.js +0 -295
  285. package/dist/structural-backend/structural-publication.d.ts +0 -13
  286. package/dist/structural-backend/structural-publication.d.ts.map +0 -1
  287. package/dist/structural-backend/structural-publication.js +0 -255
  288. package/dist/structural-backend/structural-write-lock.d.ts +0 -8
  289. package/dist/structural-backend/structural-write-lock.d.ts.map +0 -1
  290. package/dist/structural-backend/structural-write-lock.js +0 -415
  291. package/dist/structural-backend/types.d.ts +0 -144
  292. package/dist/structural-backend/types.d.ts.map +0 -1
  293. package/dist/structural-backend/types.js +0 -11
  294. package/dist/web/application/atlas-read-service.d.ts +0 -27
  295. package/dist/web/application/atlas-read-service.d.ts.map +0 -1
  296. package/dist/web/application/atlas-read-service.js +0 -216
  297. package/dist/web/application/primary-repository-catalog.d.ts +0 -15
  298. package/dist/web/application/primary-repository-catalog.d.ts.map +0 -1
  299. package/dist/web/application/primary-repository-catalog.js +0 -202
  300. package/dist/web/application/types.d.ts +0 -41
  301. package/dist/web/application/types.d.ts.map +0 -1
  302. package/dist/web/application/types.js +0 -1
  303. package/dist/web/server/api-router.d.ts +0 -4
  304. package/dist/web/server/api-router.d.ts.map +0 -1
  305. package/dist/web/server/api-router.js +0 -151
  306. package/dist/web/server/local-web-server.d.ts +0 -12
  307. package/dist/web/server/local-web-server.d.ts.map +0 -1
  308. package/dist/web/server/local-web-server.js +0 -100
  309. package/dist/web-client/assets/index-DneaErDj.css +0 -1
  310. package/dist/web-client/assets/index-cze_4vtt.js +0 -2
  311. package/dist/web-client/assets/index-cze_4vtt.js.map +0 -1
  312. package/dist/web-client/index.html +0 -61
  313. package/dist/world/business-map-projector.d.ts +0 -14
  314. package/dist/world/business-map-projector.d.ts.map +0 -1
  315. package/dist/world/business-map-projector.js +0 -178
  316. package/dist/world/types.d.ts +0 -77
  317. package/dist/world/types.d.ts.map +0 -1
  318. package/dist/world/types.js +0 -1
  319. package/dist/world/world-graph-query.d.ts +0 -30
  320. package/dist/world/world-graph-query.d.ts.map +0 -1
  321. package/dist/world/world-graph-query.js +0 -252
  322. package/dist/world/world-model-service.d.ts +0 -21
  323. package/dist/world/world-model-service.d.ts.map +0 -1
  324. package/dist/world/world-model-service.js +0 -219
  325. package/dist/world/world-snapshot-store.d.ts +0 -41
  326. package/dist/world/world-snapshot-store.d.ts.map +0 -1
  327. package/dist/world/world-snapshot-store.js +0 -581
  328. package/docs/README.md +0 -30
  329. package/docs/architecture/codegraph-backend.md +0 -190
  330. package/docs/architecture/continuous-business-learning.md +0 -240
  331. package/docs/architecture/web-viewer.md +0 -225
  332. package/docs/contracts/cli-v1.md +0 -179
  333. package/docs/contracts/graph-model.md +0 -106
  334. package/docs/contracts/graph-patch-v1.md +0 -105
  335. package/docs/contracts/http-api-v1.md +0 -155
  336. package/docs/contracts/insights-v1.md +0 -84
  337. package/docs/log.md +0 -159
  338. package/docs/mindmaps/semantic-atlas-overview.drawio +0 -255
  339. package/docs/mindmaps/semantic-atlas-overview.png +0 -0
  340. package/docs/mindmaps/semantic-atlas-overview.zh-CN.drawio +0 -255
  341. package/docs/mindmaps/semantic-atlas-overview.zh-CN.png +0 -0
  342. package/schemas/cli-envelope-v1.schema.json +0 -1244
  343. package/schemas/evaluation-plan-v1.schema.json +0 -211
  344. package/schemas/evaluation-run-v1.schema.json +0 -659
  345. package/schemas/graph-patch-v1.schema.json +0 -392
  346. package/schemas/insights-envelope-v1.schema.json +0 -428
@@ -1,136 +0,0 @@
1
- import { addBusinessNode, addBusinessRelation, nodeKey, hasDecorator, } from "./strategy-helpers.js";
2
- const WRITE_METHODS = new Set(["save", "insert", "update", "delete", "remove", "softDelete", "softRemove", "upsert"]);
3
- const READ_METHODS = new Set(["find", "findOne", "findBy", "findOneBy", "count", "exists", "query"]);
4
- export class TypeOrmBusinessStrategy {
5
- derive(catalog, options, draft) {
6
- const entities = findTypeOrmEntities(catalog);
7
- const entityKeys = new Map(entities.map((entity) => {
8
- const key = nodeKey(options.capability.key, "data", entity);
9
- addBusinessNode(draft, {
10
- key,
11
- kind: "Data",
12
- label: entity.name,
13
- summary: `TypeORM persisted data represented by ${entity.qualifiedName}.`,
14
- evidence: entity,
15
- });
16
- return [entity.reference.id, key];
17
- }));
18
- if (entities.length === 0) {
19
- return;
20
- }
21
- for (const operation of catalog.nodes.filter(isOperationNode)) {
22
- const operationKey = nodeKey(options.capability.key, "operations", operation);
23
- for (const call of catalog.outgoing(operation.reference.id, "calls")) {
24
- const dataAccess = catalog.exactTarget(call);
25
- if (dataAccess === undefined || !looksLikeRepositoryAccess(dataAccess)) {
26
- continue;
27
- }
28
- const accessType = classifyDataAccess(dataAccess.name);
29
- if (accessType === undefined) {
30
- draft.addBoundary("typeorm", "classify_data_access", `The TypeORM access ${dataAccess.qualifiedName} cannot be classified as a supported read or write.`, dataAccess, [...entityKeys.values()]);
31
- continue;
32
- }
33
- const entity = resolveEntityTarget(dataAccess, entities);
34
- if (entity === undefined) {
35
- draft.addBoundary("typeorm", "resolve_data_target", `The TypeORM access ${dataAccess.qualifiedName} does not identify one decorated entity.`, dataAccess, entities.map((entity) => entity.reference.id));
36
- continue;
37
- }
38
- const dataKey = entityKeys.get(entity.reference.id);
39
- addBusinessNode(draft, {
40
- key: operationKey,
41
- kind: "Operation",
42
- label: operation.name,
43
- summary: `Performs ${operation.qualifiedName}.`,
44
- evidence: operation,
45
- });
46
- addBusinessRelation(draft, {
47
- from: operationKey,
48
- type: accessType,
49
- to: dataKey,
50
- evidence: dataAccess,
51
- });
52
- }
53
- deriveUnresolvedRepositoryAccess(operation, catalog, draft);
54
- }
55
- }
56
- }
57
- function deriveUnresolvedRepositoryAccess(operation, catalog, draft) {
58
- const fileContext = catalog.contextNodes(operation.path);
59
- const hasTypeOrmImport = fileContext.some(isTypeOrmImport);
60
- const boundaries = catalog.boundaries.filter((boundary) => (boundary.owner.id === operation.reference.id && boundary.operation === "calls"));
61
- if (!hasTypeOrmImport || !hasRepositoryTypeEvidence(operation.path, catalog)) {
62
- return;
63
- }
64
- for (const boundary of boundaries) {
65
- if (boundary.target === undefined || classifyDataAccess(boundary.target) === undefined) {
66
- continue;
67
- }
68
- draft.addBoundary("typeorm", "resolve_repository_access", `The TypeORM repository call ${boundary.target} is unresolved and requires source inspection.`, operation, boundary.candidates);
69
- }
70
- }
71
- function hasRepositoryTypeEvidence(path, catalog) {
72
- return catalog.contextBoundaries(path).some((boundary) => (boundary.target === "Repository"
73
- && (boundary.operation === "references" || boundary.operation === "imports")));
74
- }
75
- export function findTypeOrmEntities(catalog) {
76
- const entities = catalog.nodes.filter((node) => (hasDecorator(node, ["Entity", "ViewEntity"])
77
- || isConventionalEntity(node, catalog)));
78
- for (const file of catalog.nodes.filter(isTypeOrmEntityFile)) {
79
- const children = catalog.outgoing(file.reference.id, "declares")
80
- .filter((relation) => relation.support.status === "exact")
81
- .map((relation) => catalog.node(relation.to.id))
82
- .filter((node) => node !== undefined);
83
- if (!children.some(isTypeOrmImport)) {
84
- continue;
85
- }
86
- const entityName = entityNameFromFile(file.name);
87
- entities.push(...children.filter((node) => (node.declarationKind === "class" && node.name.toLowerCase() === entityName)));
88
- }
89
- return [...new Map(entities.map((entity) => [entity.reference.id, entity])).values()];
90
- }
91
- function isConventionalEntity(node, catalog) {
92
- if (node.declarationKind !== "class") {
93
- return false;
94
- }
95
- const ownerFile = catalog.contextIncoming(node.reference.id, "declares")
96
- .map((relation) => catalog.contextNode(relation.from.id))
97
- .find((owner) => owner !== undefined && isTypeOrmEntityFile(owner));
98
- return ownerFile !== undefined
99
- && node.name.toLowerCase() === entityNameFromFile(ownerFile.name)
100
- && catalog.contextNodes(ownerFile.path).some(isTypeOrmImport);
101
- }
102
- function entityNameFromFile(fileName) {
103
- return fileName.replace(/\.entity\.[cm]?[jt]sx?$/iu, "")
104
- .replace(/[^a-z0-9]/giu, "")
105
- .toLowerCase();
106
- }
107
- function isTypeOrmEntityFile(node) {
108
- return node.declarationKind === "file"
109
- && /(?:^|\.)entity\.[cm]?[jt]sx?$/iu.test(node.name);
110
- }
111
- function isTypeOrmImport(node) {
112
- return node.declarationKind === "import"
113
- && (node.name === "typeorm" || node.qualifiedName === "typeorm");
114
- }
115
- function classifyDataAccess(name) {
116
- if (WRITE_METHODS.has(name)) {
117
- return "writes";
118
- }
119
- return READ_METHODS.has(name) ? "reads" : undefined;
120
- }
121
- function looksLikeRepositoryAccess(node) {
122
- return /(?:^|::|\.)(?:Repository(?:<[^>]+>)?|EntityManager|(?:Select|Insert|Update|Delete|SoftDelete|Relation)?QueryBuilder)(?:::|\.)/u
123
- .test(node.qualifiedName);
124
- }
125
- function resolveEntityTarget(access, entities) {
126
- const generic = access.qualifiedName.match(/Repository<([^>]+)>(?:::|\.)/u)?.[1];
127
- if (generic === undefined) {
128
- return undefined;
129
- }
130
- const entityName = generic.split(/[.:]/u).at(-1)?.trim();
131
- const candidates = entities.filter((entity) => entity.name === entityName);
132
- return candidates.length === 1 ? candidates[0] : undefined;
133
- }
134
- function isOperationNode(node) {
135
- return node.declarationKind === "method" || node.declarationKind === "function";
136
- }
@@ -1,5 +0,0 @@
1
- import type { BusinessFlowDraft } from "../business-flow-draft.js";
2
- import type { StructuralFlowCatalog } from "../structural-flow-catalog.js";
3
- import type { BusinessFlowDerivationOptions } from "../types.js";
4
- export declare function deriveVerifiedInvariants(catalog: StructuralFlowCatalog, options: BusinessFlowDerivationOptions, draft: BusinessFlowDraft): void;
5
- //# sourceMappingURL=verified-invariant-strategy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verified-invariant-strategy.d.ts","sourceRoot":"","sources":["../../../src/business-flow/strategies/verified-invariant-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAOjE,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,6BAA6B,EACtC,KAAK,EAAE,iBAAiB,GACvB,IAAI,CAoCN"}
@@ -1,38 +0,0 @@
1
- import { addBusinessNode, addBusinessRelation, nodeKey, } from "./strategy-helpers.js";
2
- export function deriveVerifiedInvariants(catalog, options, draft) {
3
- for (const invariant of options.invariants ?? []) {
4
- const evidence = catalog.node(invariant.evidence.id);
5
- if (evidence === undefined) {
6
- throw new Error(`Verified invariant ${invariant.key} references missing evidence`);
7
- }
8
- addBusinessNode(draft, {
9
- key: invariant.key,
10
- kind: "Invariant",
11
- label: invariant.label,
12
- summary: invariant.summary,
13
- evidence,
14
- certainty: invariant.certainty ?? "inferred",
15
- });
16
- for (const constrainedReference of invariant.constrains) {
17
- const constrained = catalog.node(constrainedReference.id);
18
- if (constrained === undefined) {
19
- throw new Error(`Verified invariant ${invariant.key} has a missing target`);
20
- }
21
- const constrainedKey = nodeKey(options.capability.key, "operations", constrained);
22
- addBusinessNode(draft, {
23
- key: constrainedKey,
24
- kind: "Operation",
25
- label: constrained.name,
26
- summary: `Performs ${constrained.qualifiedName}.`,
27
- evidence: constrained,
28
- });
29
- addBusinessRelation(draft, {
30
- from: constrainedKey,
31
- type: "constrained_by",
32
- to: invariant.key,
33
- evidence,
34
- certainty: invariant.certainty ?? "inferred",
35
- });
36
- }
37
- }
38
- }
@@ -1,5 +0,0 @@
1
- import type { BusinessFlowDraft } from "../business-flow-draft.js";
2
- import type { StructuralFlowCatalog } from "../structural-flow-catalog.js";
3
- import type { BusinessFlowDerivationOptions } from "../types.js";
4
- export declare function deriveVerifiedTests(catalog: StructuralFlowCatalog, options: BusinessFlowDerivationOptions, draft: BusinessFlowDraft): void;
5
- //# sourceMappingURL=verified-test-strategy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verified-test-strategy.d.ts","sourceRoot":"","sources":["../../../src/business-flow/strategies/verified-test-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAOjE,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,6BAA6B,EACtC,KAAK,EAAE,iBAAiB,GACvB,IAAI,CAwBN"}
@@ -1,26 +0,0 @@
1
- import { addBusinessNode, addStructuralRelation, nodeKey, } from "./strategy-helpers.js";
2
- export function deriveVerifiedTests(catalog, options, draft) {
3
- for (const verification of options.verifications ?? []) {
4
- const operation = catalog.node(verification.operation.id);
5
- const test = catalog.node(verification.test.id);
6
- if (operation === undefined || test === undefined) {
7
- throw new Error("Verified test flow references missing structural evidence");
8
- }
9
- const operationKey = nodeKey(options.capability.key, "operations", operation);
10
- addBusinessNode(draft, {
11
- key: operationKey,
12
- kind: "Operation",
13
- label: operation.name,
14
- summary: `Performs ${operation.qualifiedName}.`,
15
- evidence: operation,
16
- certainty: verification.certainty ?? "inferred",
17
- });
18
- addStructuralRelation(draft, {
19
- from: operationKey,
20
- type: "verified_by",
21
- to: test,
22
- evidence: test,
23
- certainty: verification.certainty ?? "inferred",
24
- });
25
- }
26
- }
@@ -1,21 +0,0 @@
1
- import type { StructuralIndexBackend, StructuralNode, StructuralReference, StructuralRelation, StructuralUnknownBoundary } from "../structural-backend/types.js";
2
- export declare class StructuralFlowCatalog {
3
- #private;
4
- readonly nodes: readonly StructuralNode[];
5
- readonly relations: readonly StructuralRelation[];
6
- readonly boundaries: readonly StructuralUnknownBoundary[];
7
- private constructor();
8
- static load(structural: StructuralIndexBackend, verifiedReferences?: readonly StructuralReference[]): Promise<StructuralFlowCatalog>;
9
- scopeTo(roots: readonly StructuralReference[]): StructuralFlowCatalog;
10
- node(reference: string): StructuralNode | undefined;
11
- outgoing(reference: string, type?: StructuralRelation["type"]): readonly StructuralRelation[];
12
- incoming(reference: string, type?: StructuralRelation["type"]): readonly StructuralRelation[];
13
- exactTarget(relation: StructuralRelation): StructuralNode | undefined;
14
- contextNodes(path: string): readonly StructuralNode[];
15
- contextIncoming(reference: string, type?: StructuralRelation["type"]): readonly StructuralRelation[];
16
- contextNode(reference: string): StructuralNode | undefined;
17
- contextBoundaries(path: string): readonly StructuralUnknownBoundary[];
18
- isRoot(reference: string): boolean;
19
- private outgoingClosure;
20
- }
21
- //# sourceMappingURL=structural-flow-catalog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"structural-flow-catalog.d.ts","sourceRoot":"","sources":["../../src/business-flow/structural-flow-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,sBAAsB,EACtB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,gCAAgC,CAAC;AASxC,qBAAa,qBAAqB;;IAChC,QAAQ,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAClD,QAAQ,CAAC,UAAU,EAAE,SAAS,yBAAyB,EAAE,CAAC;IAQ1D,OAAO;WAsBM,IAAI,CACf,UAAU,EAAE,sBAAsB,EAClC,kBAAkB,GAAE,SAAS,mBAAmB,EAAO,GACtD,OAAO,CAAC,qBAAqB,CAAC;IAkBjC,OAAO,CAAC,KAAK,EAAE,SAAS,mBAAmB,EAAE,GAAG,qBAAqB;IAwBrE,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAInD,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,GAAG,SAAS,kBAAkB,EAAE;IAM7F,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,GAAG,SAAS,kBAAkB,EAAE;IAM7F,WAAW,CAAC,QAAQ,EAAE,kBAAkB,GAAG,cAAc,GAAG,SAAS;IAOrE,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,cAAc,EAAE;IAIrD,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,GAAG,SAAS,kBAAkB,EAAE;IAMpG,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAI1D,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,yBAAyB,EAAE;IAIrE,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIlC,OAAO,CAAC,eAAe;CAsBxB"}
@@ -1,125 +0,0 @@
1
- const CAPABILITY_REACHABILITY = new Set([
2
- "contains",
3
- "declares",
4
- "references",
5
- "calls",
6
- ]);
7
- export class StructuralFlowCatalog {
8
- nodes;
9
- relations;
10
- boundaries;
11
- #nodesByReference;
12
- #contextNodesByReference;
13
- #contextNodes;
14
- #contextRelations;
15
- #contextBoundaries;
16
- #rootReferences;
17
- constructor(nodes, relations, boundaries, context = { nodes, relations, boundaries }, rootReferences = new Set()) {
18
- this.nodes = nodes;
19
- this.relations = relations;
20
- this.boundaries = boundaries;
21
- this.#contextNodes = context.nodes;
22
- this.#contextRelations = context.relations;
23
- this.#contextBoundaries = context.boundaries;
24
- this.#rootReferences = rootReferences;
25
- this.#nodesByReference = new Map(nodes.map((node) => [node.reference.id, node]));
26
- this.#contextNodesByReference = new Map(context.nodes.map((node) => [node.reference.id, node]));
27
- }
28
- static async load(structural, verifiedReferences = []) {
29
- const graph = await structural.readProjectGraph({
30
- declarationKinds: ["file", "import", "route", "class", "method", "function"],
31
- });
32
- const graphNodeIds = new Set(graph.nodes.map((node) => node.reference.id));
33
- const verifiedNodes = await Promise.all(uniqueReferences(verifiedReferences)
34
- .filter((reference) => !graphNodeIds.has(reference.id))
35
- .map((reference) => structural.getNode(reference)));
36
- return new StructuralFlowCatalog([...graph.nodes, ...verifiedNodes.filter((node) => node !== undefined)]
37
- .sort(compareNodes), uniqueRelations(graph.relations), uniqueBoundaries(graph.boundaries));
38
- }
39
- scopeTo(roots) {
40
- if (roots.length === 0) {
41
- throw new Error("Business flow derivation requires at least one capability root");
42
- }
43
- const owned = this.outgoingClosure(roots);
44
- const missing = roots.filter((root) => !owned.has(root.id));
45
- if (missing.length > 0) {
46
- throw new Error(`Business flow roots reference missing evidence: ${missing.map((root) => root.id).join(", ")}`);
47
- }
48
- return new StructuralFlowCatalog(this.#contextNodes.filter((node) => owned.has(node.reference.id)), this.#contextRelations.filter((relation) => (owned.has(relation.from.id) && owned.has(relation.to.id))), this.#contextBoundaries.filter((boundary) => owned.has(boundary.owner.id)), {
49
- nodes: this.#contextNodes,
50
- relations: this.#contextRelations,
51
- boundaries: this.#contextBoundaries,
52
- }, new Set(roots.map((root) => root.id)));
53
- }
54
- node(reference) {
55
- return this.#nodesByReference.get(reference);
56
- }
57
- outgoing(reference, type) {
58
- return this.relations.filter((relation) => (relation.from.id === reference && (type === undefined || relation.type === type)));
59
- }
60
- incoming(reference, type) {
61
- return this.relations.filter((relation) => (relation.to.id === reference && (type === undefined || relation.type === type)));
62
- }
63
- exactTarget(relation) {
64
- return relation.support.status === "exact"
65
- && this.nodes.some((node) => node.reference.id === relation.to.id)
66
- ? this.node(relation.to.id)
67
- : undefined;
68
- }
69
- contextNodes(path) {
70
- return this.#contextNodes.filter((node) => node.path === path);
71
- }
72
- contextIncoming(reference, type) {
73
- return this.#contextRelations.filter((relation) => (relation.to.id === reference && (type === undefined || relation.type === type)));
74
- }
75
- contextNode(reference) {
76
- return this.#contextNodesByReference.get(reference);
77
- }
78
- contextBoundaries(path) {
79
- return this.#contextBoundaries.filter((boundary) => boundary.path === path);
80
- }
81
- isRoot(reference) {
82
- return this.#rootReferences.has(reference);
83
- }
84
- outgoingClosure(roots) {
85
- const knownNodes = new Set(this.#contextNodes.map((node) => node.reference.id));
86
- const owned = new Set();
87
- const queue = roots.map((root) => root.id);
88
- for (let index = 0; index < queue.length; index += 1) {
89
- const reference = queue[index];
90
- if (!knownNodes.has(reference) || owned.has(reference)) {
91
- continue;
92
- }
93
- owned.add(reference);
94
- for (const relation of this.#contextRelations) {
95
- if (relation.from.id === reference
96
- && relation.support.status === "exact"
97
- && CAPABILITY_REACHABILITY.has(relation.type)) {
98
- queue.push(relation.to.id);
99
- }
100
- }
101
- }
102
- return owned;
103
- }
104
- }
105
- function uniqueReferences(references) {
106
- return [...new Map(references.map((reference) => [reference.id, reference])).values()];
107
- }
108
- function uniqueRelations(relations) {
109
- return [...new Map(relations.map((relation) => [
110
- [relation.from.id, relation.type, relation.to.id].join("\0"),
111
- relation,
112
- ])).values()].sort((left, right) => (left.from.id.localeCompare(right.from.id)
113
- || left.type.localeCompare(right.type)
114
- || left.to.id.localeCompare(right.to.id)));
115
- }
116
- function uniqueBoundaries(boundaries) {
117
- return [...new Map(boundaries.map((boundary) => [boundary.reference.id, boundary])).values()]
118
- .sort((left, right) => left.reference.id.localeCompare(right.reference.id));
119
- }
120
- function compareNodes(left, right) {
121
- return left.path.localeCompare(right.path)
122
- || left.range.start.line - right.range.start.line
123
- || left.range.start.column - right.range.start.column
124
- || left.reference.id.localeCompare(right.reference.id);
125
- }
@@ -1,51 +0,0 @@
1
- import type { GraphPatchV1 } from "../contracts/graph.js";
2
- import type { AssertionCertainty, GraphSourceLocation, StructuralNodeReference } from "../graph/types.js";
3
- import type { StructuralReference } from "../structural-backend/types.js";
4
- export type SupportedBusinessFramework = "nestjs" | "graphql" | "typeorm" | "bullmq";
5
- export interface BusinessCapabilityDefinition {
6
- readonly key: string;
7
- readonly label: string;
8
- readonly summary: string;
9
- readonly aliases?: readonly string[];
10
- readonly roots: readonly StructuralReference[];
11
- }
12
- export interface VerifiedMessageFlow {
13
- readonly channel: string;
14
- readonly producer: StructuralReference;
15
- readonly consumer: StructuralReference;
16
- readonly certainty?: AssertionCertainty;
17
- }
18
- export interface VerifiedInvariant {
19
- readonly key: string;
20
- readonly label: string;
21
- readonly summary: string;
22
- readonly evidence: StructuralReference;
23
- readonly constrains: readonly StructuralReference[];
24
- readonly certainty?: AssertionCertainty;
25
- }
26
- export interface VerifiedTestFlow {
27
- readonly operation: StructuralReference;
28
- readonly test: StructuralReference;
29
- readonly certainty?: AssertionCertainty;
30
- }
31
- export interface BusinessFlowDerivationOptions {
32
- readonly capability: BusinessCapabilityDefinition;
33
- readonly messageFlows?: readonly VerifiedMessageFlow[];
34
- readonly invariants?: readonly VerifiedInvariant[];
35
- readonly verifications?: readonly VerifiedTestFlow[];
36
- }
37
- export interface BusinessFlowBoundary {
38
- readonly id: string;
39
- readonly framework: SupportedBusinessFramework;
40
- readonly operation: string;
41
- readonly reason: string;
42
- readonly owner: StructuralNodeReference;
43
- readonly location: GraphSourceLocation;
44
- readonly candidates: readonly string[];
45
- readonly resolution: "unresolved" | "source_fallback";
46
- }
47
- export interface DerivedBusinessFlow {
48
- readonly patch: GraphPatchV1;
49
- readonly boundaries: readonly BusinessFlowBoundary[];
50
- }
51
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/business-flow/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,MAAM,MAAM,0BAA0B,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAErF,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,SAAS,mBAAmB,EAAE,CAAC;CAChD;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACpD,QAAQ,CAAC,SAAS,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,UAAU,EAAE,4BAA4B,CAAC;IAClD,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACvD,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACnD,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACtD;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,0BAA0B,CAAC;IAC/C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,uBAAuB,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,YAAY,GAAG,iBAAiB,CAAC;CACvD;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACtD"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import type { ParsedInvocation } from "./types.js";
2
- export declare function parseCliArguments(arguments_: readonly string[], currentDirectory: string): ParsedInvocation;
3
- //# sourceMappingURL=argument-parser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"argument-parser.d.ts","sourceRoot":"","sources":["../../src/cli/argument-parser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,gBAAgB,EAAE,MAAM,GACvB,gBAAgB,CAQlB"}
@@ -1,200 +0,0 @@
1
- import { contentIdentifierSchema } from "../contracts/identifiers.js";
2
- import { businessKeySchema } from "../contracts/graph.js";
3
- import { invalidInput } from "./cli-error.js";
4
- export function parseCliArguments(arguments_, currentDirectory) {
5
- const commandName = identifyCommand(arguments_);
6
- const global = parseGlobalOptions(arguments_, currentDirectory, commandName);
7
- return {
8
- repo: global.repo,
9
- pretty: global.pretty,
10
- command: parseCommand(global.arguments, commandName),
11
- };
12
- }
13
- function parseGlobalOptions(arguments_, currentDirectory, command) {
14
- const remaining = [];
15
- let repo = currentDirectory;
16
- let pretty = false;
17
- let hasRepo = false;
18
- for (let index = 0; index < arguments_.length; index += 1) {
19
- const argument = arguments_[index];
20
- if (argument === "--pretty") {
21
- if (pretty)
22
- throw invalidInput("--pretty may only be provided once.", command);
23
- pretty = true;
24
- continue;
25
- }
26
- if (argument === "--repo") {
27
- if (hasRepo)
28
- throw invalidInput("--repo may only be provided once.", command);
29
- const value = arguments_[index + 1];
30
- if (value === undefined || value.startsWith("-")) {
31
- throw invalidInput("--repo requires a directory path.", command);
32
- }
33
- repo = value;
34
- hasRepo = true;
35
- index += 1;
36
- continue;
37
- }
38
- remaining.push(argument);
39
- }
40
- return { arguments: remaining, repo, pretty };
41
- }
42
- function parseCommand(arguments_, identified) {
43
- const [command, subcommand, ...rest] = arguments_;
44
- if (command === "status" || command === "index") {
45
- requireNoArguments([subcommand, ...rest].filter(isDefined), identified);
46
- return { name: command };
47
- }
48
- if (command === "learn") {
49
- if (subcommand !== "--stdin" || rest.length !== 0) {
50
- throw invalidInput("learn requires exactly --stdin.", "learn");
51
- }
52
- return { name: "learn" };
53
- }
54
- if (command === "feedback") {
55
- if (subcommand !== "report" || rest.length !== 1 || rest[0] !== "--stdin") {
56
- throw invalidInput("feedback report requires exactly --stdin.", "feedback.report");
57
- }
58
- return { name: "feedback.report" };
59
- }
60
- if (command === "changes") {
61
- return parseChanges([subcommand, ...rest].filter(isDefined));
62
- }
63
- if (command === "map") {
64
- return parseMap(subcommand, rest);
65
- }
66
- if (command === "code") {
67
- return parseCode(subcommand, rest);
68
- }
69
- throw invalidInput("The command arguments are invalid.", identified);
70
- }
71
- function parseMap(subcommand, arguments_) {
72
- if (subcommand === "view") {
73
- if (arguments_.length > 1) {
74
- throw invalidInput("map view accepts at most one business key.", "map.view");
75
- }
76
- const focusKey = arguments_[0];
77
- return {
78
- name: "map.view",
79
- ...(focusKey === undefined ? {} : { focusKey: requireBusinessKey(focusKey, "map.view") }),
80
- };
81
- }
82
- if (subcommand === "search") {
83
- const [query, ...options] = arguments_;
84
- if (query === undefined || query.trim().length === 0) {
85
- throw invalidInput("map search requires a lexical query.", "map.search");
86
- }
87
- return {
88
- name: "map.search",
89
- query,
90
- limit: parsePositiveIntegerOption(options, "--limit", 20, "map.search"),
91
- };
92
- }
93
- if (subcommand === "show") {
94
- if (arguments_.length !== 1) {
95
- throw invalidInput("map show requires one business key.", "map.show");
96
- }
97
- return {
98
- name: "map.show",
99
- businessKey: requireBusinessKey(arguments_[0], "map.show"),
100
- };
101
- }
102
- throw invalidInput("The map command is invalid.", identifyMapCommand(subcommand));
103
- }
104
- function parseCode(subcommand, arguments_) {
105
- if (subcommand === "search") {
106
- const [query, ...options] = arguments_;
107
- if (query === undefined || query.trim().length === 0) {
108
- throw invalidInput("code search requires a structural query.", "code.search");
109
- }
110
- return {
111
- name: "code.search",
112
- query,
113
- limit: parsePositiveIntegerOption(options, "--limit", 20, "code.search"),
114
- };
115
- }
116
- throw invalidInput("The code command is invalid.", identifyCodeCommand(subcommand));
117
- }
118
- function parseChanges(arguments_) {
119
- let fromSnapshotId;
120
- let toSnapshotId;
121
- for (let index = 0; index < arguments_.length; index += 2) {
122
- const option = arguments_[index];
123
- const value = arguments_[index + 1];
124
- if ((option !== "--from" && option !== "--to") || value === undefined) {
125
- throw invalidInput("changes accepts --from and --to snapshot IDs.", "changes");
126
- }
127
- const snapshotId = parseSnapshotId(value);
128
- if (option === "--from") {
129
- if (fromSnapshotId !== undefined)
130
- throw invalidInput("--from may only be provided once.", "changes");
131
- fromSnapshotId = snapshotId;
132
- }
133
- else {
134
- if (toSnapshotId !== undefined)
135
- throw invalidInput("--to may only be provided once.", "changes");
136
- toSnapshotId = snapshotId;
137
- }
138
- }
139
- return {
140
- name: "changes",
141
- ...(fromSnapshotId === undefined ? {} : { fromSnapshotId }),
142
- ...(toSnapshotId === undefined ? {} : { toSnapshotId }),
143
- };
144
- }
145
- function parsePositiveIntegerOption(arguments_, option, defaultValue, command, maximum) {
146
- if (arguments_.length === 0)
147
- return defaultValue;
148
- if (arguments_.length !== 2 || arguments_[0] !== option) {
149
- throw invalidInput(`${command} accepts only ${option}.`, command);
150
- }
151
- const value = Number(arguments_[1]);
152
- if (!Number.isInteger(value) || value < 1 || (maximum !== undefined && value > maximum)) {
153
- const range = maximum === undefined ? "a positive integer" : `an integer from 1 through ${maximum}`;
154
- throw invalidInput(`${option} must be ${range}.`, command);
155
- }
156
- return value;
157
- }
158
- function requireBusinessKey(value, command) {
159
- const business = businessKeySchema.safeParse(value);
160
- if (!business.success) {
161
- throw invalidInput("Expected a business key.", command);
162
- }
163
- return business.data;
164
- }
165
- function parseSnapshotId(value) {
166
- const result = contentIdentifierSchema.safeParse(value);
167
- if (!result.success)
168
- throw invalidInput("Snapshot IDs must be SHA-256 identifiers.", "changes");
169
- return result.data;
170
- }
171
- function requireNoArguments(arguments_, command) {
172
- if (arguments_.length > 0)
173
- throw invalidInput("The command does not accept arguments.", command);
174
- }
175
- function identifyCommand(arguments_) {
176
- const positional = arguments_.filter((argument, index) => (argument !== "--pretty"
177
- && argument !== "--repo"
178
- && arguments_[index - 1] !== "--repo"));
179
- const [command, subcommand] = positional;
180
- if (command === "status" || command === "index" || command === "learn" || command === "changes") {
181
- return command;
182
- }
183
- if (command === "map")
184
- return identifyMapCommand(subcommand);
185
- if (command === "code")
186
- return identifyCodeCommand(subcommand);
187
- return command === "feedback" && subcommand === "report" ? "feedback.report" : null;
188
- }
189
- function identifyMapCommand(subcommand) {
190
- if (subcommand === "view" || subcommand === "search" || subcommand === "show") {
191
- return `map.${subcommand}`;
192
- }
193
- return null;
194
- }
195
- function identifyCodeCommand(subcommand) {
196
- return subcommand === "search" ? "code.search" : null;
197
- }
198
- function isDefined(value) {
199
- return value !== undefined;
200
- }