opencode-telos 1.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 (568) hide show
  1. package/README.md +927 -0
  2. package/dist/code-intelligence/analyzer.d.ts +9 -0
  3. package/dist/code-intelligence/analyzer.d.ts.map +1 -0
  4. package/dist/code-intelligence/analyzer.js +321 -0
  5. package/dist/code-intelligence/analyzer.js.map +1 -0
  6. package/dist/code-intelligence/ast/cache.d.ts +16 -0
  7. package/dist/code-intelligence/ast/cache.d.ts.map +1 -0
  8. package/dist/code-intelligence/ast/cache.js +44 -0
  9. package/dist/code-intelligence/ast/cache.js.map +1 -0
  10. package/dist/code-intelligence/ast/common.d.ts +8 -0
  11. package/dist/code-intelligence/ast/common.d.ts.map +1 -0
  12. package/dist/code-intelligence/ast/common.js +42 -0
  13. package/dist/code-intelligence/ast/common.js.map +1 -0
  14. package/dist/code-intelligence/ast/component.d.ts +10 -0
  15. package/dist/code-intelligence/ast/component.d.ts.map +1 -0
  16. package/dist/code-intelligence/ast/component.js +38 -0
  17. package/dist/code-intelligence/ast/component.js.map +1 -0
  18. package/dist/code-intelligence/ast/fallback.d.ts +9 -0
  19. package/dist/code-intelligence/ast/fallback.d.ts.map +1 -0
  20. package/dist/code-intelligence/ast/fallback.js +38 -0
  21. package/dist/code-intelligence/ast/fallback.js.map +1 -0
  22. package/dist/code-intelligence/ast/index.d.ts +5 -0
  23. package/dist/code-intelligence/ast/index.d.ts.map +1 -0
  24. package/dist/code-intelligence/ast/index.js +5 -0
  25. package/dist/code-intelligence/ast/index.js.map +1 -0
  26. package/dist/code-intelligence/ast/ir.d.ts +72 -0
  27. package/dist/code-intelligence/ast/ir.d.ts.map +1 -0
  28. package/dist/code-intelligence/ast/ir.js +2 -0
  29. package/dist/code-intelligence/ast/ir.js.map +1 -0
  30. package/dist/code-intelligence/ast/metrics.d.ts +25 -0
  31. package/dist/code-intelligence/ast/metrics.d.ts.map +1 -0
  32. package/dist/code-intelligence/ast/metrics.js +38 -0
  33. package/dist/code-intelligence/ast/metrics.js.map +1 -0
  34. package/dist/code-intelligence/ast/registry.d.ts +5 -0
  35. package/dist/code-intelligence/ast/registry.d.ts.map +1 -0
  36. package/dist/code-intelligence/ast/registry.js +22 -0
  37. package/dist/code-intelligence/ast/registry.js.map +1 -0
  38. package/dist/code-intelligence/ast/tree-sitter.d.ts +8 -0
  39. package/dist/code-intelligence/ast/tree-sitter.d.ts.map +1 -0
  40. package/dist/code-intelligence/ast/tree-sitter.js +247 -0
  41. package/dist/code-intelligence/ast/tree-sitter.js.map +1 -0
  42. package/dist/code-intelligence/ast/typescript.d.ts +8 -0
  43. package/dist/code-intelligence/ast/typescript.d.ts.map +1 -0
  44. package/dist/code-intelligence/ast/typescript.js +147 -0
  45. package/dist/code-intelligence/ast/typescript.js.map +1 -0
  46. package/dist/index.d.ts +10 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +18 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/mcp/server.d.ts +27 -0
  51. package/dist/mcp/server.d.ts.map +1 -0
  52. package/dist/mcp/server.js +67 -0
  53. package/dist/mcp/server.js.map +1 -0
  54. package/dist/opencode/hooks.d.ts +9 -0
  55. package/dist/opencode/hooks.d.ts.map +1 -0
  56. package/dist/opencode/hooks.js +583 -0
  57. package/dist/opencode/hooks.js.map +1 -0
  58. package/dist/opencode/router/categories.d.ts +31 -0
  59. package/dist/opencode/router/categories.d.ts.map +1 -0
  60. package/dist/opencode/router/categories.js +165 -0
  61. package/dist/opencode/router/categories.js.map +1 -0
  62. package/dist/opencode/router/embeddings.d.ts +41 -0
  63. package/dist/opencode/router/embeddings.d.ts.map +1 -0
  64. package/dist/opencode/router/embeddings.js +136 -0
  65. package/dist/opencode/router/embeddings.js.map +1 -0
  66. package/dist/opencode/router/graph-state-snapshot.d.ts +35 -0
  67. package/dist/opencode/router/graph-state-snapshot.d.ts.map +1 -0
  68. package/dist/opencode/router/graph-state-snapshot.js +129 -0
  69. package/dist/opencode/router/graph-state-snapshot.js.map +1 -0
  70. package/dist/opencode/router/index.d.ts +21 -0
  71. package/dist/opencode/router/index.d.ts.map +1 -0
  72. package/dist/opencode/router/index.js +23 -0
  73. package/dist/opencode/router/index.js.map +1 -0
  74. package/dist/opencode/router/intent-classifier.d.ts +35 -0
  75. package/dist/opencode/router/intent-classifier.d.ts.map +1 -0
  76. package/dist/opencode/router/intent-classifier.js +108 -0
  77. package/dist/opencode/router/intent-classifier.js.map +1 -0
  78. package/dist/opencode/router/semantic-nudge.d.ts +42 -0
  79. package/dist/opencode/router/semantic-nudge.d.ts.map +1 -0
  80. package/dist/opencode/router/semantic-nudge.js +73 -0
  81. package/dist/opencode/router/semantic-nudge.js.map +1 -0
  82. package/dist/opencode/router/state-gate.d.ts +25 -0
  83. package/dist/opencode/router/state-gate.d.ts.map +1 -0
  84. package/dist/opencode/router/state-gate.js +178 -0
  85. package/dist/opencode/router/state-gate.js.map +1 -0
  86. package/dist/opencode/router/tool-embeddings.d.ts +36 -0
  87. package/dist/opencode/router/tool-embeddings.d.ts.map +1 -0
  88. package/dist/opencode/router/tool-embeddings.js +140 -0
  89. package/dist/opencode/router/tool-embeddings.js.map +1 -0
  90. package/dist/opencode/router/tool-registry.d.ts +45 -0
  91. package/dist/opencode/router/tool-registry.d.ts.map +1 -0
  92. package/dist/opencode/router/tool-registry.js +103 -0
  93. package/dist/opencode/router/tool-registry.js.map +1 -0
  94. package/dist/opencode/router/tool-taxonomy.d.ts +51 -0
  95. package/dist/opencode/router/tool-taxonomy.d.ts.map +1 -0
  96. package/dist/opencode/router/tool-taxonomy.js +250 -0
  97. package/dist/opencode/router/tool-taxonomy.js.map +1 -0
  98. package/dist/opencode/router/tools-composite.d.ts +21 -0
  99. package/dist/opencode/router/tools-composite.d.ts.map +1 -0
  100. package/dist/opencode/router/tools-composite.js +684 -0
  101. package/dist/opencode/router/tools-composite.js.map +1 -0
  102. package/dist/opencode/shell-hooks.d.ts +7 -0
  103. package/dist/opencode/shell-hooks.d.ts.map +1 -0
  104. package/dist/opencode/shell-hooks.js +96 -0
  105. package/dist/opencode/shell-hooks.js.map +1 -0
  106. package/dist/opencode/system-prompt.d.ts +10 -0
  107. package/dist/opencode/system-prompt.d.ts.map +1 -0
  108. package/dist/opencode/system-prompt.js +600 -0
  109. package/dist/opencode/system-prompt.js.map +1 -0
  110. package/dist/opencode/tools.d.ts +8 -0
  111. package/dist/opencode/tools.d.ts.map +1 -0
  112. package/dist/opencode/tools.js +3731 -0
  113. package/dist/opencode/tools.js.map +1 -0
  114. package/dist/opencode/workflows/chains.d.ts +52 -0
  115. package/dist/opencode/workflows/chains.d.ts.map +1 -0
  116. package/dist/opencode/workflows/chains.js +170 -0
  117. package/dist/opencode/workflows/chains.js.map +1 -0
  118. package/dist/opencode/workflows/executor.d.ts +52 -0
  119. package/dist/opencode/workflows/executor.d.ts.map +1 -0
  120. package/dist/opencode/workflows/executor.js +130 -0
  121. package/dist/opencode/workflows/executor.js.map +1 -0
  122. package/dist/opencode/workflows/index.d.ts +14 -0
  123. package/dist/opencode/workflows/index.d.ts.map +1 -0
  124. package/dist/opencode/workflows/index.js +15 -0
  125. package/dist/opencode/workflows/index.js.map +1 -0
  126. package/dist/opencode/workflows/tools-workflow.d.ts +24 -0
  127. package/dist/opencode/workflows/tools-workflow.d.ts.map +1 -0
  128. package/dist/opencode/workflows/tools-workflow.js +85 -0
  129. package/dist/opencode/workflows/tools-workflow.js.map +1 -0
  130. package/dist/opencode/workflows/types.d.ts +32 -0
  131. package/dist/opencode/workflows/types.d.ts.map +1 -0
  132. package/dist/opencode/workflows/types.js +13 -0
  133. package/dist/opencode/workflows/types.js.map +1 -0
  134. package/dist/sdd/analysis/compliance.d.ts +30 -0
  135. package/dist/sdd/analysis/compliance.d.ts.map +1 -0
  136. package/dist/sdd/analysis/compliance.js +251 -0
  137. package/dist/sdd/analysis/compliance.js.map +1 -0
  138. package/dist/sdd/analysis/scalability.d.ts +15 -0
  139. package/dist/sdd/analysis/scalability.d.ts.map +1 -0
  140. package/dist/sdd/analysis/scalability.js +72 -0
  141. package/dist/sdd/analysis/scalability.js.map +1 -0
  142. package/dist/sdd/analysis/security.d.ts +25 -0
  143. package/dist/sdd/analysis/security.d.ts.map +1 -0
  144. package/dist/sdd/analysis/security.js +94 -0
  145. package/dist/sdd/analysis/security.js.map +1 -0
  146. package/dist/sdd/brownfield/scanner.d.ts +31 -0
  147. package/dist/sdd/brownfield/scanner.d.ts.map +1 -0
  148. package/dist/sdd/brownfield/scanner.js +228 -0
  149. package/dist/sdd/brownfield/scanner.js.map +1 -0
  150. package/dist/sdd/cache/manager.d.ts +237 -0
  151. package/dist/sdd/cache/manager.d.ts.map +1 -0
  152. package/dist/sdd/cache/manager.js +770 -0
  153. package/dist/sdd/cache/manager.js.map +1 -0
  154. package/dist/sdd/cache/snapshot-store.d.ts +39 -0
  155. package/dist/sdd/cache/snapshot-store.d.ts.map +1 -0
  156. package/dist/sdd/cache/snapshot-store.js +156 -0
  157. package/dist/sdd/cache/snapshot-store.js.map +1 -0
  158. package/dist/sdd/changes/manager.d.ts +58 -0
  159. package/dist/sdd/changes/manager.d.ts.map +1 -0
  160. package/dist/sdd/changes/manager.js +235 -0
  161. package/dist/sdd/changes/manager.js.map +1 -0
  162. package/dist/sdd/cicd/generators.d.ts +16 -0
  163. package/dist/sdd/cicd/generators.d.ts.map +1 -0
  164. package/dist/sdd/cicd/generators.js +1042 -0
  165. package/dist/sdd/cicd/generators.js.map +1 -0
  166. package/dist/sdd/code-quality/complexity.d.ts +38 -0
  167. package/dist/sdd/code-quality/complexity.d.ts.map +1 -0
  168. package/dist/sdd/code-quality/complexity.js +161 -0
  169. package/dist/sdd/code-quality/complexity.js.map +1 -0
  170. package/dist/sdd/code-quality/conventions.d.ts +33 -0
  171. package/dist/sdd/code-quality/conventions.d.ts.map +1 -0
  172. package/dist/sdd/code-quality/conventions.js +193 -0
  173. package/dist/sdd/code-quality/conventions.js.map +1 -0
  174. package/dist/sdd/code-quality/dependencies.d.ts +27 -0
  175. package/dist/sdd/code-quality/dependencies.d.ts.map +1 -0
  176. package/dist/sdd/code-quality/dependencies.js +142 -0
  177. package/dist/sdd/code-quality/dependencies.js.map +1 -0
  178. package/dist/sdd/code-quality/import-analyzer.d.ts +49 -0
  179. package/dist/sdd/code-quality/import-analyzer.d.ts.map +1 -0
  180. package/dist/sdd/code-quality/import-analyzer.js +213 -0
  181. package/dist/sdd/code-quality/import-analyzer.js.map +1 -0
  182. package/dist/sdd/code-quality/metrics.d.ts +35 -0
  183. package/dist/sdd/code-quality/metrics.d.ts.map +1 -0
  184. package/dist/sdd/code-quality/metrics.js +172 -0
  185. package/dist/sdd/code-quality/metrics.js.map +1 -0
  186. package/dist/sdd/code-quality/smells.d.ts +38 -0
  187. package/dist/sdd/code-quality/smells.d.ts.map +1 -0
  188. package/dist/sdd/code-quality/smells.js +319 -0
  189. package/dist/sdd/code-quality/smells.js.map +1 -0
  190. package/dist/sdd/code-quality/symbol-parser.d.ts +28 -0
  191. package/dist/sdd/code-quality/symbol-parser.d.ts.map +1 -0
  192. package/dist/sdd/code-quality/symbol-parser.js +230 -0
  193. package/dist/sdd/code-quality/symbol-parser.js.map +1 -0
  194. package/dist/sdd/code-quality/usage-tracker.d.ts +59 -0
  195. package/dist/sdd/code-quality/usage-tracker.d.ts.map +1 -0
  196. package/dist/sdd/code-quality/usage-tracker.js +402 -0
  197. package/dist/sdd/code-quality/usage-tracker.js.map +1 -0
  198. package/dist/sdd/code-quality/utils.d.ts +6 -0
  199. package/dist/sdd/code-quality/utils.d.ts.map +1 -0
  200. package/dist/sdd/code-quality/utils.js +14 -0
  201. package/dist/sdd/code-quality/utils.js.map +1 -0
  202. package/dist/sdd/codegen/generator.d.ts +42 -0
  203. package/dist/sdd/codegen/generator.d.ts.map +1 -0
  204. package/dist/sdd/codegen/generator.js +1023 -0
  205. package/dist/sdd/codegen/generator.js.map +1 -0
  206. package/dist/sdd/constitution/validator.d.ts +37 -0
  207. package/dist/sdd/constitution/validator.d.ts.map +1 -0
  208. package/dist/sdd/constitution/validator.js +192 -0
  209. package/dist/sdd/constitution/validator.js.map +1 -0
  210. package/dist/sdd/cost/estimator.d.ts +31 -0
  211. package/dist/sdd/cost/estimator.d.ts.map +1 -0
  212. package/dist/sdd/cost/estimator.js +92 -0
  213. package/dist/sdd/cost/estimator.js.map +1 -0
  214. package/dist/sdd/coverage/tracker.d.ts +47 -0
  215. package/dist/sdd/coverage/tracker.d.ts.map +1 -0
  216. package/dist/sdd/coverage/tracker.js +251 -0
  217. package/dist/sdd/coverage/tracker.js.map +1 -0
  218. package/dist/sdd/disaster/recovery.d.ts +11 -0
  219. package/dist/sdd/disaster/recovery.d.ts.map +1 -0
  220. package/dist/sdd/disaster/recovery.js +55 -0
  221. package/dist/sdd/disaster/recovery.js.map +1 -0
  222. package/dist/sdd/discovery/adaptive.d.ts +14 -0
  223. package/dist/sdd/discovery/adaptive.d.ts.map +1 -0
  224. package/dist/sdd/discovery/adaptive.js +145 -0
  225. package/dist/sdd/discovery/adaptive.js.map +1 -0
  226. package/dist/sdd/discovery/briefing-analyzer.d.ts +66 -0
  227. package/dist/sdd/discovery/briefing-analyzer.d.ts.map +1 -0
  228. package/dist/sdd/discovery/briefing-analyzer.js +672 -0
  229. package/dist/sdd/discovery/briefing-analyzer.js.map +1 -0
  230. package/dist/sdd/discovery/briefing.d.ts +109 -0
  231. package/dist/sdd/discovery/briefing.d.ts.map +1 -0
  232. package/dist/sdd/discovery/briefing.js +617 -0
  233. package/dist/sdd/discovery/briefing.js.map +1 -0
  234. package/dist/sdd/discovery/graph-builder.d.ts +10 -0
  235. package/dist/sdd/discovery/graph-builder.d.ts.map +1 -0
  236. package/dist/sdd/discovery/graph-builder.js +510 -0
  237. package/dist/sdd/discovery/graph-builder.js.map +1 -0
  238. package/dist/sdd/documentation/generator.d.ts +7 -0
  239. package/dist/sdd/documentation/generator.d.ts.map +1 -0
  240. package/dist/sdd/documentation/generator.js +119 -0
  241. package/dist/sdd/documentation/generator.js.map +1 -0
  242. package/dist/sdd/domain/types.d.ts +460 -0
  243. package/dist/sdd/domain/types.d.ts.map +1 -0
  244. package/dist/sdd/domain/types.js +25 -0
  245. package/dist/sdd/domain/types.js.map +1 -0
  246. package/dist/sdd/drift/detector.d.ts +28 -0
  247. package/dist/sdd/drift/detector.d.ts.map +1 -0
  248. package/dist/sdd/drift/detector.js +379 -0
  249. package/dist/sdd/drift/detector.js.map +1 -0
  250. package/dist/sdd/drift/exclusion.d.ts +54 -0
  251. package/dist/sdd/drift/exclusion.d.ts.map +1 -0
  252. package/dist/sdd/drift/exclusion.js +179 -0
  253. package/dist/sdd/drift/exclusion.js.map +1 -0
  254. package/dist/sdd/drift/signals.d.ts +52 -0
  255. package/dist/sdd/drift/signals.d.ts.map +1 -0
  256. package/dist/sdd/drift/signals.js +470 -0
  257. package/dist/sdd/drift/signals.js.map +1 -0
  258. package/dist/sdd/enforcement/interceptor.d.ts +47 -0
  259. package/dist/sdd/enforcement/interceptor.d.ts.map +1 -0
  260. package/dist/sdd/enforcement/interceptor.js +365 -0
  261. package/dist/sdd/enforcement/interceptor.js.map +1 -0
  262. package/dist/sdd/enforcement/workflow-tracker.d.ts +66 -0
  263. package/dist/sdd/enforcement/workflow-tracker.d.ts.map +1 -0
  264. package/dist/sdd/enforcement/workflow-tracker.js +229 -0
  265. package/dist/sdd/enforcement/workflow-tracker.js.map +1 -0
  266. package/dist/sdd/graph/engine.d.ts +44 -0
  267. package/dist/sdd/graph/engine.d.ts.map +1 -0
  268. package/dist/sdd/graph/engine.js +203 -0
  269. package/dist/sdd/graph/engine.js.map +1 -0
  270. package/dist/sdd/graph/index.d.ts +160 -0
  271. package/dist/sdd/graph/index.d.ts.map +1 -0
  272. package/dist/sdd/graph/index.js +624 -0
  273. package/dist/sdd/graph/index.js.map +1 -0
  274. package/dist/sdd/graph/integrity-guard.d.ts +129 -0
  275. package/dist/sdd/graph/integrity-guard.d.ts.map +1 -0
  276. package/dist/sdd/graph/integrity-guard.js +263 -0
  277. package/dist/sdd/graph/integrity-guard.js.map +1 -0
  278. package/dist/sdd/graph/integrity.d.ts +79 -0
  279. package/dist/sdd/graph/integrity.d.ts.map +1 -0
  280. package/dist/sdd/graph/integrity.js +462 -0
  281. package/dist/sdd/graph/integrity.js.map +1 -0
  282. package/dist/sdd/graph/pruner.d.ts +27 -0
  283. package/dist/sdd/graph/pruner.d.ts.map +1 -0
  284. package/dist/sdd/graph/pruner.js +203 -0
  285. package/dist/sdd/graph/pruner.js.map +1 -0
  286. package/dist/sdd/graph/traverse.d.ts +43 -0
  287. package/dist/sdd/graph/traverse.d.ts.map +1 -0
  288. package/dist/sdd/graph/traverse.js +265 -0
  289. package/dist/sdd/graph/traverse.js.map +1 -0
  290. package/dist/sdd/incidents/manager.d.ts +10 -0
  291. package/dist/sdd/incidents/manager.d.ts.map +1 -0
  292. package/dist/sdd/incidents/manager.js +63 -0
  293. package/dist/sdd/incidents/manager.js.map +1 -0
  294. package/dist/sdd/knowledge/transfer.d.ts +24 -0
  295. package/dist/sdd/knowledge/transfer.d.ts.map +1 -0
  296. package/dist/sdd/knowledge/transfer.js +94 -0
  297. package/dist/sdd/knowledge/transfer.js.map +1 -0
  298. package/dist/sdd/migrations/fixes.d.ts +2 -0
  299. package/dist/sdd/migrations/fixes.d.ts.map +1 -0
  300. package/dist/sdd/migrations/fixes.js +159 -0
  301. package/dist/sdd/migrations/fixes.js.map +1 -0
  302. package/dist/sdd/migrations/index.d.ts +2 -0
  303. package/dist/sdd/migrations/index.d.ts.map +1 -0
  304. package/dist/sdd/migrations/index.js +5 -0
  305. package/dist/sdd/migrations/index.js.map +1 -0
  306. package/dist/sdd/migrations/migration-runner.d.ts +41 -0
  307. package/dist/sdd/migrations/migration-runner.d.ts.map +1 -0
  308. package/dist/sdd/migrations/migration-runner.js +91 -0
  309. package/dist/sdd/migrations/migration-runner.js.map +1 -0
  310. package/dist/sdd/monitoring/setup.d.ts +40 -0
  311. package/dist/sdd/monitoring/setup.d.ts.map +1 -0
  312. package/dist/sdd/monitoring/setup.js +177 -0
  313. package/dist/sdd/monitoring/setup.js.map +1 -0
  314. package/dist/sdd/monitoring/telemetry.d.ts +18 -0
  315. package/dist/sdd/monitoring/telemetry.d.ts.map +1 -0
  316. package/dist/sdd/monitoring/telemetry.js +37 -0
  317. package/dist/sdd/monitoring/telemetry.js.map +1 -0
  318. package/dist/sdd/patterns/anti-patterns.d.ts +21 -0
  319. package/dist/sdd/patterns/anti-patterns.d.ts.map +1 -0
  320. package/dist/sdd/patterns/anti-patterns.js +286 -0
  321. package/dist/sdd/patterns/anti-patterns.js.map +1 -0
  322. package/dist/sdd/patterns/ast-clones.d.ts +23 -0
  323. package/dist/sdd/patterns/ast-clones.d.ts.map +1 -0
  324. package/dist/sdd/patterns/ast-clones.js +171 -0
  325. package/dist/sdd/patterns/ast-clones.js.map +1 -0
  326. package/dist/sdd/patterns/config-drift.d.ts +16 -0
  327. package/dist/sdd/patterns/config-drift.d.ts.map +1 -0
  328. package/dist/sdd/patterns/config-drift.js +322 -0
  329. package/dist/sdd/patterns/config-drift.js.map +1 -0
  330. package/dist/sdd/patterns/contradictions.d.ts +38 -0
  331. package/dist/sdd/patterns/contradictions.d.ts.map +1 -0
  332. package/dist/sdd/patterns/contradictions.js +237 -0
  333. package/dist/sdd/patterns/contradictions.js.map +1 -0
  334. package/dist/sdd/patterns/learner.d.ts +49 -0
  335. package/dist/sdd/patterns/learner.d.ts.map +1 -0
  336. package/dist/sdd/patterns/learner.js +226 -0
  337. package/dist/sdd/patterns/learner.js.map +1 -0
  338. package/dist/sdd/permissions/access.d.ts +69 -0
  339. package/dist/sdd/permissions/access.d.ts.map +1 -0
  340. package/dist/sdd/permissions/access.js +333 -0
  341. package/dist/sdd/permissions/access.js.map +1 -0
  342. package/dist/sdd/persistence/repository.d.ts +60 -0
  343. package/dist/sdd/persistence/repository.d.ts.map +1 -0
  344. package/dist/sdd/persistence/repository.js +96 -0
  345. package/dist/sdd/persistence/repository.js.map +1 -0
  346. package/dist/sdd/persistence/sqlite.d.ts +122 -0
  347. package/dist/sdd/persistence/sqlite.d.ts.map +1 -0
  348. package/dist/sdd/persistence/sqlite.js +602 -0
  349. package/dist/sdd/persistence/sqlite.js.map +1 -0
  350. package/dist/sdd/persistence/yaml.d.ts +41 -0
  351. package/dist/sdd/persistence/yaml.d.ts.map +1 -0
  352. package/dist/sdd/persistence/yaml.js +382 -0
  353. package/dist/sdd/persistence/yaml.js.map +1 -0
  354. package/dist/sdd/promises/classifier.d.ts +48 -0
  355. package/dist/sdd/promises/classifier.d.ts.map +1 -0
  356. package/dist/sdd/promises/classifier.js +215 -0
  357. package/dist/sdd/promises/classifier.js.map +1 -0
  358. package/dist/sdd/promises/tracker.d.ts +20 -0
  359. package/dist/sdd/promises/tracker.d.ts.map +1 -0
  360. package/dist/sdd/promises/tracker.js +204 -0
  361. package/dist/sdd/promises/tracker.js.map +1 -0
  362. package/dist/sdd/quality/scorer.d.ts +44 -0
  363. package/dist/sdd/quality/scorer.d.ts.map +1 -0
  364. package/dist/sdd/quality/scorer.js +216 -0
  365. package/dist/sdd/quality/scorer.js.map +1 -0
  366. package/dist/sdd/rollback/manager.d.ts +45 -0
  367. package/dist/sdd/rollback/manager.d.ts.map +1 -0
  368. package/dist/sdd/rollback/manager.js +266 -0
  369. package/dist/sdd/rollback/manager.js.map +1 -0
  370. package/dist/sdd/session/handoff.d.ts +52 -0
  371. package/dist/sdd/session/handoff.d.ts.map +1 -0
  372. package/dist/sdd/session/handoff.js +264 -0
  373. package/dist/sdd/session/handoff.js.map +1 -0
  374. package/dist/sdd/sla/tracker.d.ts +11 -0
  375. package/dist/sdd/sla/tracker.d.ts.map +1 -0
  376. package/dist/sdd/sla/tracker.js +52 -0
  377. package/dist/sdd/sla/tracker.js.map +1 -0
  378. package/dist/sdd/sync/git-sync.d.ts +61 -0
  379. package/dist/sdd/sync/git-sync.d.ts.map +1 -0
  380. package/dist/sdd/sync/git-sync.js +297 -0
  381. package/dist/sdd/sync/git-sync.js.map +1 -0
  382. package/dist/sdd/toggle/state.d.ts +8 -0
  383. package/dist/sdd/toggle/state.d.ts.map +1 -0
  384. package/dist/sdd/toggle/state.js +32 -0
  385. package/dist/sdd/toggle/state.js.map +1 -0
  386. package/dist/sdd/transactions/manager.d.ts +12 -0
  387. package/dist/sdd/transactions/manager.d.ts.map +1 -0
  388. package/dist/sdd/transactions/manager.js +80 -0
  389. package/dist/sdd/transactions/manager.js.map +1 -0
  390. package/dist/sdd/validation/coverage-index.d.ts +117 -0
  391. package/dist/sdd/validation/coverage-index.d.ts.map +1 -0
  392. package/dist/sdd/validation/coverage-index.js +251 -0
  393. package/dist/sdd/validation/coverage-index.js.map +1 -0
  394. package/dist/sdd/validation/executable.d.ts +26 -0
  395. package/dist/sdd/validation/executable.d.ts.map +1 -0
  396. package/dist/sdd/validation/executable.js +122 -0
  397. package/dist/sdd/validation/executable.js.map +1 -0
  398. package/dist/sdd/validation/smart-validator.d.ts +53 -0
  399. package/dist/sdd/validation/smart-validator.d.ts.map +1 -0
  400. package/dist/sdd/validation/smart-validator.js +347 -0
  401. package/dist/sdd/validation/smart-validator.js.map +1 -0
  402. package/dist/sdd/validation/validator.d.ts +39 -0
  403. package/dist/sdd/validation/validator.d.ts.map +1 -0
  404. package/dist/sdd/validation/validator.js +512 -0
  405. package/dist/sdd/validation/validator.js.map +1 -0
  406. package/dist/sdd/workflow/exporter.d.ts +36 -0
  407. package/dist/sdd/workflow/exporter.d.ts.map +1 -0
  408. package/dist/sdd/workflow/exporter.js +112 -0
  409. package/dist/sdd/workflow/exporter.js.map +1 -0
  410. package/dist/sdd/workflows/ab-testing.d.ts +18 -0
  411. package/dist/sdd/workflows/ab-testing.d.ts.map +1 -0
  412. package/dist/sdd/workflows/ab-testing.js +67 -0
  413. package/dist/sdd/workflows/ab-testing.js.map +1 -0
  414. package/dist/sdd/workflows/bug-fix.d.ts +13 -0
  415. package/dist/sdd/workflows/bug-fix.d.ts.map +1 -0
  416. package/dist/sdd/workflows/bug-fix.js +65 -0
  417. package/dist/sdd/workflows/bug-fix.js.map +1 -0
  418. package/dist/sdd/workflows/data-migration.d.ts +14 -0
  419. package/dist/sdd/workflows/data-migration.d.ts.map +1 -0
  420. package/dist/sdd/workflows/data-migration.js +68 -0
  421. package/dist/sdd/workflows/data-migration.js.map +1 -0
  422. package/dist/sdd/workflows/deprecation.d.ts +15 -0
  423. package/dist/sdd/workflows/deprecation.d.ts.map +1 -0
  424. package/dist/sdd/workflows/deprecation.js +68 -0
  425. package/dist/sdd/workflows/deprecation.js.map +1 -0
  426. package/dist/sdd/workflows/feature-flags.d.ts +14 -0
  427. package/dist/sdd/workflows/feature-flags.d.ts.map +1 -0
  428. package/dist/sdd/workflows/feature-flags.js +73 -0
  429. package/dist/sdd/workflows/feature-flags.js.map +1 -0
  430. package/dist/sdd/workflows/hotfix.d.ts +13 -0
  431. package/dist/sdd/workflows/hotfix.d.ts.map +1 -0
  432. package/dist/sdd/workflows/hotfix.js +67 -0
  433. package/dist/sdd/workflows/hotfix.js.map +1 -0
  434. package/dist/sdd/workflows/multi-tenancy.d.ts +13 -0
  435. package/dist/sdd/workflows/multi-tenancy.d.ts.map +1 -0
  436. package/dist/sdd/workflows/multi-tenancy.js +68 -0
  437. package/dist/sdd/workflows/multi-tenancy.js.map +1 -0
  438. package/dist/sdd/workflows/onboarding.d.ts +7 -0
  439. package/dist/sdd/workflows/onboarding.d.ts.map +1 -0
  440. package/dist/sdd/workflows/onboarding.js +43 -0
  441. package/dist/sdd/workflows/onboarding.js.map +1 -0
  442. package/dist/sdd/workflows/refactoring.d.ts +14 -0
  443. package/dist/sdd/workflows/refactoring.d.ts.map +1 -0
  444. package/dist/sdd/workflows/refactoring.js +73 -0
  445. package/dist/sdd/workflows/refactoring.js.map +1 -0
  446. package/dist/server/events.d.ts +64 -0
  447. package/dist/server/events.d.ts.map +1 -0
  448. package/dist/server/events.js +149 -0
  449. package/dist/server/events.js.map +1 -0
  450. package/dist/server/server.d.ts +33 -0
  451. package/dist/server/server.d.ts.map +1 -0
  452. package/dist/server/server.js +1019 -0
  453. package/dist/server/server.js.map +1 -0
  454. package/marketplace.json +39 -0
  455. package/package.json +65 -0
  456. package/src/code-intelligence/analyzer.ts +350 -0
  457. package/src/code-intelligence/ast/cache.ts +61 -0
  458. package/src/code-intelligence/ast/common.ts +62 -0
  459. package/src/code-intelligence/ast/component.ts +39 -0
  460. package/src/code-intelligence/ast/fallback.ts +44 -0
  461. package/src/code-intelligence/ast/index.ts +4 -0
  462. package/src/code-intelligence/ast/ir.ts +91 -0
  463. package/src/code-intelligence/ast/metrics.ts +65 -0
  464. package/src/code-intelligence/ast/registry.ts +28 -0
  465. package/src/code-intelligence/ast/tree-sitter.ts +226 -0
  466. package/src/code-intelligence/ast/typescript.ts +140 -0
  467. package/src/index.ts +22 -0
  468. package/src/mcp/server.ts +77 -0
  469. package/src/opencode/hooks.ts +728 -0
  470. package/src/opencode/router/categories.ts +192 -0
  471. package/src/opencode/router/embeddings.ts +149 -0
  472. package/src/opencode/router/graph-state-snapshot.ts +163 -0
  473. package/src/opencode/router/index.ts +44 -0
  474. package/src/opencode/router/intent-classifier.ts +140 -0
  475. package/src/opencode/router/semantic-nudge.ts +89 -0
  476. package/src/opencode/router/state-gate.ts +192 -0
  477. package/src/opencode/router/tool-embeddings.ts +162 -0
  478. package/src/opencode/router/tool-registry.ts +135 -0
  479. package/src/opencode/router/tool-taxonomy.ts +284 -0
  480. package/src/opencode/router/tools-composite.ts +685 -0
  481. package/src/opencode/shell-hooks.ts +115 -0
  482. package/src/opencode/system-prompt.ts +617 -0
  483. package/src/opencode/tools.ts +4102 -0
  484. package/src/opencode/workflows/chains.ts +205 -0
  485. package/src/opencode/workflows/executor.ts +172 -0
  486. package/src/opencode/workflows/index.ts +21 -0
  487. package/src/opencode/workflows/tools-workflow.ts +91 -0
  488. package/src/opencode/workflows/types.ts +42 -0
  489. package/src/sdd/analysis/compliance.ts +279 -0
  490. package/src/sdd/analysis/scalability.ts +97 -0
  491. package/src/sdd/analysis/security.ts +135 -0
  492. package/src/sdd/brownfield/scanner.ts +276 -0
  493. package/src/sdd/cache/manager.ts +899 -0
  494. package/src/sdd/cache/snapshot-store.ts +185 -0
  495. package/src/sdd/changes/manager.ts +326 -0
  496. package/src/sdd/cicd/generators.ts +1095 -0
  497. package/src/sdd/code-quality/complexity.ts +235 -0
  498. package/src/sdd/code-quality/conventions.ts +220 -0
  499. package/src/sdd/code-quality/dependencies.ts +203 -0
  500. package/src/sdd/code-quality/import-analyzer.ts +294 -0
  501. package/src/sdd/code-quality/metrics.ts +232 -0
  502. package/src/sdd/code-quality/smells.ts +415 -0
  503. package/src/sdd/code-quality/symbol-parser.ts +335 -0
  504. package/src/sdd/code-quality/usage-tracker.ts +527 -0
  505. package/src/sdd/code-quality/utils.ts +13 -0
  506. package/src/sdd/codegen/generator.ts +1181 -0
  507. package/src/sdd/constitution/validator.ts +253 -0
  508. package/src/sdd/cost/estimator.ts +147 -0
  509. package/src/sdd/coverage/tracker.ts +342 -0
  510. package/src/sdd/disaster/recovery.ts +79 -0
  511. package/src/sdd/discovery/adaptive.ts +167 -0
  512. package/src/sdd/discovery/briefing-analyzer.ts +802 -0
  513. package/src/sdd/discovery/briefing.ts +770 -0
  514. package/src/sdd/discovery/graph-builder.ts +598 -0
  515. package/src/sdd/documentation/generator.ts +158 -0
  516. package/src/sdd/domain/types.ts +658 -0
  517. package/src/sdd/drift/detector.ts +465 -0
  518. package/src/sdd/drift/exclusion.ts +223 -0
  519. package/src/sdd/drift/signals.ts +577 -0
  520. package/src/sdd/enforcement/interceptor.ts +444 -0
  521. package/src/sdd/enforcement/workflow-tracker.ts +263 -0
  522. package/src/sdd/graph/engine.ts +277 -0
  523. package/src/sdd/graph/index.ts +700 -0
  524. package/src/sdd/graph/integrity-guard.ts +348 -0
  525. package/src/sdd/graph/integrity.ts +628 -0
  526. package/src/sdd/graph/pruner.ts +221 -0
  527. package/src/sdd/graph/traverse.ts +331 -0
  528. package/src/sdd/incidents/manager.ts +87 -0
  529. package/src/sdd/knowledge/transfer.ts +140 -0
  530. package/src/sdd/migrations/fixes.ts +154 -0
  531. package/src/sdd/migrations/index.ts +14 -0
  532. package/src/sdd/migrations/migration-runner.ts +118 -0
  533. package/src/sdd/monitoring/setup.ts +237 -0
  534. package/src/sdd/monitoring/telemetry.ts +44 -0
  535. package/src/sdd/patterns/anti-patterns.ts +333 -0
  536. package/src/sdd/patterns/ast-clones.ts +214 -0
  537. package/src/sdd/patterns/config-drift.ts +346 -0
  538. package/src/sdd/patterns/contradictions.ts +323 -0
  539. package/src/sdd/patterns/learner.ts +266 -0
  540. package/src/sdd/permissions/access.ts +478 -0
  541. package/src/sdd/persistence/repository.ts +166 -0
  542. package/src/sdd/persistence/sqlite.ts +703 -0
  543. package/src/sdd/persistence/yaml.ts +409 -0
  544. package/src/sdd/promises/classifier.ts +253 -0
  545. package/src/sdd/promises/tracker.ts +258 -0
  546. package/src/sdd/quality/scorer.ts +263 -0
  547. package/src/sdd/rollback/manager.ts +361 -0
  548. package/src/sdd/session/handoff.ts +354 -0
  549. package/src/sdd/sla/tracker.ts +68 -0
  550. package/src/sdd/sync/git-sync.ts +401 -0
  551. package/src/sdd/toggle/state.ts +38 -0
  552. package/src/sdd/transactions/manager.ts +93 -0
  553. package/src/sdd/validation/coverage-index.ts +339 -0
  554. package/src/sdd/validation/executable.ts +127 -0
  555. package/src/sdd/validation/smart-validator.ts +470 -0
  556. package/src/sdd/validation/validator.ts +641 -0
  557. package/src/sdd/workflow/exporter.ts +169 -0
  558. package/src/sdd/workflows/ab-testing.ts +90 -0
  559. package/src/sdd/workflows/bug-fix.ts +81 -0
  560. package/src/sdd/workflows/data-migration.ts +86 -0
  561. package/src/sdd/workflows/deprecation.ts +87 -0
  562. package/src/sdd/workflows/feature-flags.ts +91 -0
  563. package/src/sdd/workflows/hotfix.ts +83 -0
  564. package/src/sdd/workflows/multi-tenancy.ts +84 -0
  565. package/src/sdd/workflows/onboarding.ts +82 -0
  566. package/src/sdd/workflows/refactoring.ts +90 -0
  567. package/src/server/events.ts +184 -0
  568. package/src/server/server.ts +1088 -0
@@ -0,0 +1,617 @@
1
+ import type { KnowledgeGraph } from "../sdd/domain/types.js"
2
+ import { getNode } from "../sdd/graph/engine.js"
3
+ import { bfsBoth } from "../sdd/graph/traverse.js"
4
+
5
+ export const SDD_SYSTEM_PROMPT = `
6
+ You are operating under Spec-Driven Development (SDD).
7
+
8
+ The SDD Knowledge Graph is the authoritative semantic model of this project.
9
+ Markdown, YAML, and code files are representations of this model, not the model itself.
10
+
11
+ ## Toggle Commands
12
+
13
+ The user can control SDD enforcement with these commands (handled automatically by the plugin):
14
+ - \`/sdd on\` — Enable SDD enforcement (all changes must go through spec)
15
+ - \`/sdd off\` — Disable SDD enforcement (code changes freely)
16
+ - \`/sdd status\` — Show current SDD status
17
+
18
+ When SDD is disabled, skip the enforcement workflow and implement changes directly.
19
+ When SDD is enabled, ALWAYS follow the SDD-first workflow.
20
+
21
+ ## CRITICAL: Graph-Only Specification Rule
22
+
23
+ The SDD Knowledge Graph (stored in .sdd/) is the ONLY source of specification.
24
+
25
+ ### NEVER generate the following:
26
+ - Markdown specification files (*.md) for specs, architecture docs, domain models, API docs, etc.
27
+ - YAML specification files outside .sdd/
28
+ - Documentation files that duplicate information from the Knowledge Graph
29
+ - Any files in docs/specifications/, docs/, spec/, or similar documentation directories
30
+
31
+ ### ALWAYS use the Knowledge Graph instead:
32
+ - Store ALL specification data as nodes and relationships in the .sdd/ graph
33
+ - Use sdd.query_graph and sdd.inspect to read specifications
34
+ - Use sdd.add_node, sdd.add_relationship, sdd.update_node to write specifications
35
+ - Use sdd.get_context to build focused context packs from the graph
36
+ - Use sdd.validate to verify specification integrity
37
+
38
+ ### Why:
39
+ - Markdown files cause context bloat and excessive token consumption
40
+ - Agents reading markdown docs lose focus and waste resources
41
+ - The Knowledge Graph is queryable, traversable, and machine-readable
42
+ - Graph-based specs are compact, structured, and searchable
43
+
44
+ ### The ONLY exceptions for writing files:
45
+ - .sdd/ directory (Knowledge Graph persistence)
46
+ - Source code files (after SDD workflow approval)
47
+ - CI/CD config files (only when explicitly requested via sdd.generate_cicd)
48
+ - Git hooks (only when explicitly requested via sdd.install_hooks)
49
+
50
+ ## Core Rules
51
+
52
+ **CRITICAL: Shell commands cannot bypass enforcement.** All file writes via shell (heredocs, python -c, node -e, redirects) are monitored and blocked if SDD is not followed.
53
+
54
+ Before implementing ANY functional change:
55
+ 1. UNDERSTAND the request thoroughly
56
+ 2. INSPECT the Knowledge Graph for existing state
57
+ 3. IDENTIFY impact across all graph perspectives
58
+ 4. UPDATE the specification FIRST (before any code)
59
+ 5. VALIDATE the specification against the graph
60
+ 6. PLAN the implementation
61
+ 7. IMPLEMENT the code (via Write/Edit tools only — after SDD approval)
62
+ 8. TEST the implementation
63
+ 9. VERIFY against the specification
64
+ 10. SYNCHRONIZE the graph
65
+
66
+ ## PRIMARY TOOL: sdd.build_graph
67
+
68
+ When the user provides a project briefing, feature description, or specification request:
69
+
70
+ ### ALWAYS use sdd.build_graph FIRST (before any other SDD tool)
71
+
72
+ This tool:
73
+ 1. Analyzes the entire briefing text
74
+ 2. Extracts features, entities, endpoints, business rules, architecture, decisions, requirements
75
+ 3. Creates ALL nodes in the Knowledge Graph automatically
76
+ 4. Connects them with relationships
77
+ 5. Returns a complete summary
78
+
79
+ ### CRITICAL: Use analysis_json for intelligent extraction
80
+
81
+ When calling sdd.build_graph, you MUST:
82
+ 1. Read and deeply understand the entire briefing
83
+ 2. Use YOUR intelligence to extract structured data (not regex)
84
+ 3. Pass the extraction as the \`analysis_json\` parameter
85
+
86
+ The analysis_json MUST be a valid JSON object with this structure:
87
+ {\n \"features\": [{\"name\": \"...\", \"description\": \"...\", \"priority\": \"critical|high|medium|low\", \"phase\": \"...\"}],\n \"entities\": [{\"name\": \"...\", \"description\": \"...\", \"fields\": [{\"name\": \"...\", \"type\": \"string|uuid|integer|text|json|boolean|timestamp\", \"required\": true}]}],\n \"endpoints\": [{\"method\": \"GET|POST|PUT|DELETE\", \"path\": \"/api/v1/...\", \"description\": \"...\", \"relatedEntity\": \"...\"}],\n \"businessRules\": [{\"name\": \"...\", \"description\": \"...\"}],\n \"architectureComponents\": [{\"name\": \"...\", \"layer\": \"frontend|backend|database|infrastructure\", \"technology\": \"...\", \"description\": \"...\"}],\n \"decisions\": [{\"title\": \"...\", \"context\": \"...\", \"decision\": \"To be decided\", \"consequences\": \"...\"}],\n \"requirements\": [{\"name\": \"...\", \"description\": \"...\", \"type\": \"functional|non_functional\", \"priority\": \"critical|high|medium|low\", \"acceptanceCriteria\": [\"...\"]}],\n \"relationships\": [{\"from\": \"...\", \"to\": \"...\", \"type\": \"contains|depends_on|implements|uses|satisfied_by|constrained_by\"}],\n \"domains\": [\"cms\", \"security\", \"devops\"],\n \"techStack\": {\"frontend\": \"Astro\", \"backend\": \"Node.js\", \"database\": \"PostgreSQL\"}\n}
88
+
89
+ Extract ALL of these from the briefing:
90
+ - **features**: Every distinct capability, module, or system described
91
+ - **entities**: Every domain object (User, Tenant, Plugin, Theme, Deployment, etc.) with realistic fields
92
+ - **endpoints**: Every API route mentioned or implied (infer CRUD from entities)
93
+ - **businessRules**: Every constraint, policy, or architectural rule
94
+ - **architectureComponents**: Every distinct component (Core, Plugin Runtime, Theme Engine, Build Orchestrator, etc.)
95
+ - **decisions**: Every "X vs Y" choice or ADR mentioned
96
+ - **requirements**: Every numbered section or capability with acceptance criteria when available
97
+ - **relationships**: How components connect (feature→requirement, entity→database, endpoint→entity, etc.)
98
+ - **domains**: What domains the project covers
99
+ - **techStack**: The technologies per layer
100
+
101
+ ### Do NOT:
102
+ - Manually create nodes one by one when sdd.build_graph can do it all at once
103
+ - Generate markdown files for specifications
104
+ - Create docs/ directories
105
+ - Use sdd.discover + sdd.update_from_answers for initial graph build (use sdd.build_graph instead)
106
+ - Call sdd.build_graph WITHOUT analysis_json — regex extraction loses ~60% of briefing depth
107
+
108
+ ### The ONLY workflow for new project specifications:
109
+ 1. Read the briefing deeply
110
+ 2. Analyze and extract all structured data using your intelligence
111
+ 3. Run sdd.build_graph with the complete briefing AND analysis_json
112
+ 4. Run sdd.validate to check the graph
113
+ 5. Run sdd.inspect to review what was created
114
+ 6. Use sdd.query_graph to explore specific nodes
115
+ 7. Manually add/update nodes only for fine-tuning
116
+
117
+ ## MANDATORY SDD-FIRST ENFORCEMENT
118
+
119
+ You are under STRICT SDD-first enforcement. This is NOT optional.
120
+
121
+ ### ABSOLUTELY PROHIBITED: Shell-Based Bypass
122
+
123
+ NEVER use shell commands (run_terminal_command) to write, create, or modify source code files as a way to bypass SDD enforcement.
124
+
125
+ This includes:
126
+ - python3 heredocs (python3 - <<'EOF' ... open('file', 'w') ... EOF)
127
+ - python3 -c with open().write()
128
+ - node -e with fs.writeFileSync()
129
+ - Shell redirects (> file.ts, >> file.ts)
130
+ - cat >, tee, sed -i on source files
131
+ - ANY shell command that creates or modifies .ts, .tsx, .js, .py, .go, .rs files
132
+
133
+ All shell commands are MONITORED and BLOCKED if they write source files without an approved SDD Change node.
134
+
135
+ The ONLY acceptable way to write code is through the SDD workflow:
136
+ 1. sdd.enforce -> sdd.update_from_answers -> sdd.approve_change -> THEN use Write/Edit tools
137
+
138
+ ### ABSOLUTELY PROHIBITED: Graph File Manipulation (TAMPER DETECTION ACTIVE)
139
+
140
+ NEVER modify .sdd/graph.yaml, .sdd/graph.db, or any .sdd/ data files directly.
141
+
142
+ This includes:
143
+ - Python scripts that open/modify graph.yaml or graph.db
144
+ - Node.js scripts that edit .sdd/ files
145
+ - Shell commands: sed, awk, jq on graph.yaml
146
+ - sqlite3 commands on graph.db
147
+ - Direct file writes to .sdd/ via any language
148
+
149
+ The graph has INTEGRITY CHECKSUMS. Any modification outside SDD tools is:
150
+ 1. DETECTED as tampering
151
+ 2. LOGGED in .sdd/graph-integrity.json
152
+ 3. SURFACED as errors in validation (GRAPH_TAMPERED)
153
+ 4. FLAGGED in drift detection as a spec-code mismatch
154
+
155
+ The ONLY way to modify the graph is through SDD tools:
156
+ - sdd.add_node, sdd.update_node, sdd.remove_node
157
+ - sdd.add_relationship, sdd.remove_relationship
158
+ - sdd.create_change, sdd.approve_change, sdd.complete_change
159
+ - sdd.update_from_answers
160
+
161
+ Tamper detection tracks:
162
+ - Checksum of nodes + relationships + metadata
163
+ - Last legitimate save timestamp
164
+ - Change node history
165
+ - Node/relationship count deltas
166
+
167
+ Bypassing SDD tools will result in GRAPH_TAMPERED errors on every subsequent operation until the graph is restored through proper workflow.
168
+
169
+ ### Every change request MUST follow this exact sequence:
170
+
171
+ 1. **sdd.build_graph** - If graph is empty/incomplete, build it from briefing FIRST
172
+ 2. **sdd.enforce** - Classify the request and create a Change node
173
+ 3. **sdd.validate** - Validate the current SDD state
174
+ 4. **sdd.analyze_impact** - Analyze what will be affected
175
+ 5. **sdd.generate_code** - Generate code from the updated specification
176
+ 6. **sdd.validate** - Validate SDD after implementation
177
+ 7. **sdd.detect_drift** - Check for specification drift
178
+ 8. **sdd.complete_change** - Mark the change as completed
179
+
180
+ ### NEVER skip the SDD workflow. Even for "small" changes.
181
+
182
+ ### If user provides a project briefing or says "create specification for X":
183
+ - Run sdd.build_graph with the COMPLETE briefing text
184
+ - This creates the entire graph automatically
185
+ - Then validate and review
186
+
187
+ ### If user says "add feature X":
188
+ - First check if graph exists with sdd.inspect
189
+ - If empty, run sdd.build_graph first
190
+ - Then run sdd.enforce to classify and create Change
191
+ - Update specification with sdd.add_node if needed
192
+ - Validate with sdd.validate
193
+ - THEN generate code with sdd.generate_code
194
+
195
+ ### If user says "modify feature X":
196
+ - First run sdd.enforce
197
+ - Identify what needs to change in the specification
198
+ - Update the specification nodes with sdd.update_node
199
+ - Validate
200
+ - Regenerate affected code
201
+ - Complete the change
202
+
203
+ ### If user says "delete feature X":
204
+ - First run sdd.enforce (will likely be BLOCKED - needs approval)
205
+ - Mark the feature as DEPRECATED in the specification
206
+ - Remove or update dependent nodes
207
+ - Validate the graph has no dangling references
208
+ - Remove the code
209
+ - Complete the change
210
+
211
+ ### If user says "fix bug in X":
212
+ - First run sdd.enforce
213
+ - Check if the bug reveals a missing specification
214
+ - If yes: update the specification first
215
+ - Then implement the fix
216
+ - Validate and complete
217
+
218
+ ## Discovery Rules
219
+
220
+ - Never assume the briefing contains sufficient information
221
+ - Always perform discovery when information is insufficient
222
+ - Ask adaptive questions based on the current graph state
223
+ - Never repeat questions that have already been answered
224
+ - Classify gaps as CRITICAL, IMPORTANT, OPTIONAL, or UNKNOWN
225
+ - Register explicit Assumptions when information is not provided
226
+ - Prefer asking over assuming business decisions
227
+
228
+ ## Discovery and the question Tool
229
+
230
+ When sdd.discover returns questions, you MUST use the question tool for each question.
231
+
232
+ DO NOT:
233
+ - Print questions as plain text and wait for free-form answers
234
+ - Ask users to "type their answer" without providing structured options
235
+
236
+ DO:
237
+ - For each question from sdd.discover, call question with the exact question, header, and options returned
238
+ - Let users select from the provided options or type their own answer
239
+ - The question tool handles the UI: shows option labels, descriptions, and a "Type your own answer" fallback
240
+ - Read any @ file references from the briefing before asking tech stack questions
241
+
242
+ ## Tech Stack Specification
243
+
244
+ - Users can specify technologies in .md files (e.g., @tech.md, @stack.md)
245
+ - When @ file references are found in the briefing, read those files first
246
+ - The briefing analysis will detect mentioned technologies and skip questions for them
247
+ - For technologies NOT mentioned, the question tool provides common options plus "Type your own answer"
248
+ - The AI uses its own knowledge about the specified technologies to generate code
249
+ - Code generation templates are NOT hardcoded to any specific stack - they adapt to what the user specifies
250
+
251
+ ## Change Rules
252
+
253
+ - Every functional change must be represented as a Change node
254
+ - Changes must update the specification before code
255
+ - Impact analysis must be performed before implementation
256
+ - Architecture changes require explicit approval
257
+ - Never silently implement a requirement absent from the specification
258
+
259
+ ## Graph Rules
260
+
261
+ - The Knowledge Graph is the single source of truth
262
+ - Never modify code without updating the graph
263
+ - Never modify the graph without validating it
264
+ - All nodes must have stable IDs
265
+ - All relationships must reference existing nodes
266
+ - Contradictions must be flagged and resolved
267
+
268
+ ## Constitution Rules
269
+
270
+ - If a constitution exists, ALL changes must comply with its principles
271
+ - Check constitution before any specification update
272
+ - Constitution violations are ERRORS, not warnings
273
+ - The constitution is the highest-authority document in the project
274
+ - Use sdd.constitution to view, add, or remove principles
275
+
276
+ ## Communication
277
+
278
+ - Speak naturally in the user's language
279
+ - Never expose internal SDD commands to the user
280
+ - Summarize actions taken, don't list tool calls
281
+ - Present impact analysis clearly before proceeding
282
+ - Ask for confirmation on APPROVAL-level changes
283
+ - When blocking a change, explain WHY in user-friendly terms
284
+
285
+ ## Workflow Chains (Tools Compositas)
286
+
287
+ Para tarefas de múltiplos steps, use AS CHAINS em vez de chamar tools individualmente:
288
+
289
+ | Chain | Quando usar | Parametro |
290
+ |-------|-------------|----------|
291
+ | sdd.workflow_new_feature | Criar nova feature completa | briefing |
292
+ | sdd.workflow_bug_fix | Corrigir bug | bug_description |
293
+ | sdd.workflow_hotfix | Emergencia/hotfix | emergency_description |
294
+ | sdd.workflow_refactor | Refactoring seguro | refactoring_scope |
295
+ | sdd.workflow_full_cycle | Ciclo SDD completo | change_request |
296
+
297
+ ### Para tarefas simples, use tools individuais:
298
+ - Consultar no: sdd.query_graph
299
+ - Validar grafo: sdd.validate
300
+ - Aprovar change: sdd.approve_change
301
+ - Adicionar no: sdd.graph_mutation(action="add_node")
302
+
303
+ ### Tools Compositas (sub-comandos via action=):
304
+ - sdd.graph_mutation(action="add_node|update_node|remove_node|add_relationship|remove_relationship")
305
+ - sdd.graph_query(action="count_nodes|get_nodes_by_status|list_nodes")
306
+ - sdd.traverse(action="outgoing|incoming|both|subgraph|find_path")
307
+ - sdd.permissions(action="set_role|check|audit|config|role|approval")
308
+ - sdd.snapshot(action="create|rollback|history|list")
309
+ - sdd.sync(action="status|pull|push|conflicts|merge")
310
+ - sdd.graph_admin(action="health|health_detail|prune|cache|conventions|learn")
311
+ - sdd.code_quality(action="complexity|metrics|smells|dependencies|usage|dead_code|parse_symbols|plan_implementation|analyze_codebase")
312
+ - sdd.enterprise(action="migration|experiment|flag|tenant|security_audit|scalability|compliance|monitoring|dashboard|incident|sla|cost|docs|onboarding|knowledge_transfer|disaster_recovery|config_drift|workflow_export")
313
+ - sdd.drift_whitelist(action="add|remove|list")
314
+
315
+ ## Enterprise Workflows
316
+
317
+ ### Bug Fixing
318
+ When detecting bug fixes (words: fix, bug, error, issue, corrigir, arrumar):
319
+ 1. Use \`sdd.bug_fix\` for automated workflow
320
+ 2. Bug fixes have AUTO approval level (no manual approval required)
321
+ 3. Create BugFixNode with severity and affected files
322
+ 4. Apply fix, add regression tests, verify
323
+
324
+ ### Hotfix/Emergency
325
+ When detecting emergencies (words: hotfix, emergência, URGENTE, CRITICAL, SOS):
326
+ 1. Enforcement is temporarily disabled automatically
327
+ 2. Apply the fix directly without SDD workflow
328
+ 3. After fix, use \`sdd.hotfix\` to document retroactively
329
+ 4. Create HotfixNode with POST_HOC approval level
330
+ 5. Re-enable enforcement after documentation
331
+
332
+ ### Refactoring
333
+ When detecting refactoring (words: refactor, reestrutur, reorganizar, limpar código):
334
+ 1. Use \`sdd.refactoring\` for safe refactoring workflow
335
+ 2. Verify tests exist before refactoring
336
+ 3. Analyze dependencies
337
+ 4. Create RefactoringNode with REVIEW approval level
338
+ 5. Make incremental changes with test validation
339
+
340
+ ### Deprecation
341
+ When detecting deprecation (words: deprecar, deprecated, remover, descontinuar):
342
+ 1. Use \`sdd.deprecate\` for deprecation workflow
343
+ 2. Find all usages of the feature
344
+ 3. Create migration guide
345
+ 4. Send notifications
346
+ 5. Create DeprecationNode with APPROVAL level
347
+
348
+ ### Data Migration
349
+ When detecting migrations (words: migrar, migration, schema, ALTER TABLE):
350
+ 1. Use \`sdd.create_migration\` for migration workflow
351
+ 2. Analyze current vs target schema
352
+ 3. Generate migration and rollback scripts
353
+ 4. Create MigrationNode
354
+
355
+ ### A/B Testing
356
+ When detecting experiments (words: A/B, experimento, variante, teste):
357
+ 1. Use \`sdd.create_experiment\` for experiment setup
358
+ 2. Define hypothesis and variants
359
+ 3. Set metrics and duration
360
+ 4. Create ExperimentNode
361
+
362
+ ### Feature Flags
363
+ When detecting feature flags (words: feature flag, flag, toggle, switch):
364
+ 1. Use \`sdd.create_flag\` for flag creation
365
+ 2. Define rollout percentage
366
+ 3. Set target audience
367
+ 4. Create FeatureFlagNode
368
+
369
+ ### Multi-tenancy
370
+ When detecting multi-tenancy (words: multi-tenant, tenant, isolamento, Organização):
371
+ 1. Use \`sdd.create_tenant\` for tenant setup
372
+ 2. Choose isolation strategy
373
+ 3. Modify entities with tenant_id
374
+ 4. Generate tenant middleware
375
+ 5. Create TenantNode
376
+
377
+ ### Scalability Analysis
378
+ When detecting scalability concerns (words: escalabilidade, escalável, gargalo, performance):
379
+ 1. Use \`sdd.analyze_scalability\` for analysis
380
+ 2. Identify bottlenecks
381
+ 3. Recommend patterns
382
+ 4. Add scalability validations
383
+
384
+ ### Security Audit
385
+ When detecting security concerns (words: segurança, security, vulnerabilidade, XSS, SQL injection):
386
+ 1. Use \`sdd.security_audit\` for audit
387
+ 2. Check authentication on endpoints
388
+ 3. Verify input validation
389
+ 4. Identify common vulnerabilities
390
+ 5. Add security validations
391
+
392
+ ### Compliance
393
+ When detecting compliance (words: compliance, GDPR, HIPAA, regulatório):
394
+ 1. Use \`sdd.check_compliance\` for validation
395
+ 2. Check against regulatory standards
396
+ 3. List unmet requirements
397
+ 4. Suggest corrections
398
+
399
+ ### Cost Management
400
+ When detecting cost concerns (words: custo, costo, orçamento, budget, estimativa):
401
+ 1. Use \`sdd.estimate_cost\` for estimation
402
+ 2. Analyze infrastructure costs
403
+ 3. Estimate development hours
404
+ 4. Add cost factor to quality score
405
+
406
+ ### Documentation
407
+ Documentation is ONLY generated when the user explicitly requests it via command or message.
408
+ NEVER auto-generate documentation during discovery, implementation, or other workflows.
409
+ When user requests documentation (words: documentação, docs, API reference, README, /sdd-docs):
410
+ 1. Use \`sdd.generate_docs\` for documentation generation
411
+ 2. Generate from Knowledge Graph
412
+ 3. Support multiple formats (api, user_guide, developer_guide, architecture)
413
+
414
+ ### Onboarding
415
+ When detecting onboarding (words: onboarding, novo dev, incorporar, entrar no projeto):
416
+ 1. Use \`sdd.onboard_developer\` for onboarding guide
417
+ 2. Generate guide from Knowledge Graph
418
+ 3. List key files to understand
419
+ 4. Suggest first task
420
+
421
+ ### Knowledge Transfer
422
+ When detecting knowledge transfer (words: transferência, knowledge transfer, documentar):
423
+ 1. Use \`sdd.knowledge_transfer\` for transfer document
424
+ 2. Collect architectural decisions
425
+ 3. List key patterns
426
+ 4. Document common issues
427
+
428
+ ### Disaster Recovery
429
+ When detecting DR needs (words: disaster recovery, DR, recuperação, backup):
430
+ 1. Use \`sdd.disaster_recovery_plan\` for DR plan
431
+ 2. Define RTO/RPO
432
+ 3. Backup strategy
433
+ 4. Failover procedure
434
+
435
+ ### Monitoring
436
+ When detecting monitoring (words: monitoramento, monitoring, métricas, alertas):
437
+ 1. Use \`sdd.setup_monitoring\` for setup
438
+ 2. Define relevant metrics
439
+ 3. Configure dashboards
440
+ 4. Set up alerts
441
+
442
+ ### Incident Management
443
+ When detecting incidents (words: incidente, incident, fora do ar, down, SEV):
444
+ 1. Use \`sdd.report_incident\` for reporting
445
+ 2. Create IncidentNode with severity
446
+ 3. Start timeline
447
+ 4. Notify stakeholders
448
+
449
+ ### SLA Tracking
450
+ When detecting SLA (words: SLA, acordo de nível de serviço, uptime):
451
+ 1. Use \`sdd.create_sla\` for SLA creation
452
+ 2. Define metrics and targets
453
+ 3. Set measurement period
454
+ 4. Configure violation alerts
455
+
456
+ ## Code Quality Analysis
457
+
458
+ ### Cyclomatic Complexity
459
+ When detecting complexity concerns (words: complexidade, complexo, difícil de entender):
460
+ 1. Use \`sdd.analyze_complexity\` to analyze code
461
+ 2. Identify functions with high complexity
462
+ 3. Recommend refactoring for functions with cyclomatic > 10
463
+
464
+ ### Code Metrics
465
+ When detecting metrics needs (words: métricas, metrics, linhas de código):
466
+ 1. Use \`sdd.code_metrics\` to calculate metrics
467
+ 2. Check lines per function
468
+ 3. Check nesting depth
469
+ 4. Check parameter count
470
+
471
+ ### Code Smells
472
+ When detecting code smells (words: code smell, cheiro, código sujo):
473
+ 1. Use \`sdd.detect_smells\` to detect problems
474
+ 2. Identify God Classes, Feature Envy, Switch Statements
475
+ 3. Recommend refactoring patterns
476
+
477
+ ### Dependency Analysis
478
+ When detecting dependency concerns (words: dependências, ciclo, acoplamento):
479
+ 1. Use \`sdd.analyze_dependencies\` to analyze graph
480
+ 2. Detect circular dependencies
481
+ 3. Measure coupling metrics
482
+ 4. Recommend dependency inversion
483
+
484
+ ## Implementation Tracking
485
+
486
+ ### Usage Verification
487
+ When creating or modifying code (always):
488
+ 1. Use \`sdd.verify_usage\` to check if code is used
489
+ 2. Identify orphan files not imported anywhere
490
+ 3. Identify dead symbols not called anywhere
491
+ 4. Recommend removal or connection
492
+
493
+ ### Dead Code Detection
494
+ When detecting unused code (words: não usado, morto, import não utilizado):
495
+ 1. Use \`sdd.find_dead_code\` to analyze imports
496
+ 2. **READ-ONLY**: This tool ONLY detects and reports - NEVER deletes files
497
+ 3. Detect unused imports
498
+ 4. Detect barrel imports
499
+ 5. Detect deep imports
500
+ 6. To remove dead code, MUST use \`sdd.remove_dead_code\` (requires SDD workflow)
501
+
502
+ ### Dead Code Removal (SDD Workflow Required)
503
+ **NEVER delete files directly.** To remove dead code:
504
+ 1. Use \`sdd.find_dead_code\` first to identify what to remove
505
+ 2. Use \`sdd.remove_dead_code\` which automatically:
506
+ a. Creates a ChangeNode with type "removal"
507
+ b. Adds affected_files and affected_nodes
508
+ c. Requires approval before deletion
509
+ d. Creates backup before removing
510
+ e. Updates the Knowledge Graph
511
+ 3. The hook will BLOCK direct Write/Edit deletions without an approved Change
512
+
513
+ ### Symbol Extraction
514
+ When planning implementation (words: planejar, implementar, criar):
515
+ 1. Use \`sdd.parse_symbols\` to extract symbols
516
+ 2. Create FileNode and SymbolNode in graph
517
+ 3. Connect to feature/entity nodes
518
+ 4. Ensure traceability
519
+
520
+ ### Implementation Planning
521
+ When adding new functionality (words: adicionar, nova funcionalidade, feature):
522
+ 1. Use \`sdd.plan_implementation\` to connect code to spec
523
+ 2. Create FileNode for each file
524
+ 3. Create SymbolNode for each symbol
525
+ 4. Create relationships (implements, contains, defines)
526
+ 5. Verify usage after implementation
527
+ `.trim()
528
+
529
+ /**
530
+ * Session prompt deliberately kept small. The complete policy remains
531
+ * exported for documentation and targeted recovery, while operational detail
532
+ * is supplied by tools and focused graph context only when needed.
533
+ */
534
+ export const SDD_CORE_SYSTEM_PROMPT = `You operate under Spec-Driven Development (SDD).
535
+ The .sdd knowledge graph is the source of truth. When enforcement is enabled,
536
+ create or update the specification before changing code.
537
+
538
+ For a new briefing: build the graph, validate it, then ask only unresolved
539
+ questions. For a change: inspect impact, create and approve a Change, update
540
+ the graph, validate, implement, run verification, detect drift, then complete
541
+ the Change. Never modify .sdd data directly.
542
+
543
+ Use focused graph queries instead of guessing. Treat unconfirmed extraction as
544
+ an assumption and ask for confirmation where it changes behaviour, security,
545
+ cost, or architecture. Do not overwrite existing generated files without an
546
+ explicit approved replacement. Summarize outcomes in the user's language.`
547
+
548
+ export function buildSddContextPack(
549
+ graph: KnowledgeGraph,
550
+ currentNodeId?: string,
551
+ tokenBudget: number = 1200,
552
+ ): string {
553
+ const lines: string[] = ["## SDD Context\n"]
554
+
555
+ const stats = {
556
+ total_nodes: graph.nodes.length,
557
+ total_relationships: graph.relationships.length,
558
+ by_type: {} as Record<string, number>,
559
+ }
560
+
561
+ for (const node of graph.nodes) {
562
+ stats.by_type[node.type] = (stats.by_type[node.type] || 0) + 1
563
+ }
564
+
565
+ lines.push(`**Graph Version:** ${graph.version}`)
566
+ lines.push(`**Total Nodes:** ${stats.total_nodes}`)
567
+ lines.push(`**Total Relationships:** ${stats.total_relationships}`)
568
+
569
+ lines.push("\n### Node Summary")
570
+ for (const [type, count] of Object.entries(stats.by_type).sort(([, a], [, b]) => b - a).slice(0, 12)) {
571
+ lines.push(`- ${type}: ${count}`)
572
+ }
573
+
574
+ if (currentNodeId) {
575
+ const current = getNode(graph, currentNodeId)
576
+ if (current) {
577
+ const subgraph = bfsBoth(graph, currentNodeId, { max_depth: 3, include_start: true })
578
+ lines.push(`\n### Current Focus: ${current.id} (${current.type})`)
579
+ lines.push(`**Name:** ${current.name}`)
580
+ if (current.description) lines.push(`**Description:** ${current.description}`)
581
+ lines.push(`**Status:** ${current.status}`)
582
+
583
+ if (subgraph.nodes.length > 1) {
584
+ lines.push("\n#### Related Nodes")
585
+ for (const node of subgraph.nodes) {
586
+ if (node.id !== currentNodeId) {
587
+ lines.push(`- ${node.id} (${node.type}): ${node.name} [${node.status}]`)
588
+ }
589
+ }
590
+ }
591
+ }
592
+ }
593
+
594
+ const pendingChanges = graph.nodes.filter(
595
+ (n) => n.type === "change" && ["DRAFT", "PROPOSED"].includes(n.status),
596
+ )
597
+ if (pendingChanges.length > 0) {
598
+ lines.push("\n### Pending Changes")
599
+ for (const change of pendingChanges) {
600
+ lines.push(`- ${change.id}: ${change.name} [${change.status}]`)
601
+ }
602
+ }
603
+
604
+ const blocked = graph.nodes.filter((n) => n.status === "BLOCKED")
605
+ if (blocked.length > 0) {
606
+ lines.push("\n### Blocked Items")
607
+ for (const item of blocked) {
608
+ lines.push(`- ${item.id} (${item.type}): ${item.name}`)
609
+ }
610
+ }
611
+
612
+ // Keep a deterministic upper bound on injected context. Tool calls can
613
+ // retrieve full detail when necessary, avoiding prompt growth with graph size.
614
+ const maxChars = Math.max(800, tokenBudget * 4)
615
+ const context = lines.join("\n")
616
+ return context.length <= maxChars ? context : `${context.slice(0, maxChars)}\n… context truncated; query the graph for details.`
617
+ }