mcp-efficiency-engine 0.1.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 (360) hide show
  1. package/.github/CODEOWNERS +40 -0
  2. package/.github/GITHUB_MCP_INTEGRATION.md +366 -0
  3. package/.github/ISSUE_TEMPLATE/bug.md +51 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +45 -0
  5. package/.github/ISSUE_TEMPLATE/question.md +18 -0
  6. package/.github/agents/backend.agent.md +18 -0
  7. package/.github/agents/community-manager.agent.md +18 -0
  8. package/.github/agents/dba.agent.md +18 -0
  9. package/.github/agents/frontend-agent.agent.md +18 -0
  10. package/.github/agents/github-repository-manager.agent.md +338 -0
  11. package/.github/agents/iot.agent.md +20 -0
  12. package/.github/agents/legacy.agent.md +18 -0
  13. package/.github/agents/rag-azure.agent.md +18 -0
  14. package/.github/agents/rag-local.agent.md +18 -0
  15. package/.github/agents/snapshot.agent.md +18 -0
  16. package/.github/agents/ux-ui.agent.md +18 -0
  17. package/.github/agents/wiki-agent.agent.md +23 -0
  18. package/.github/copilot-instructions.md +44 -0
  19. package/.github/instructions/always-on-optimization.instructions.md +54 -0
  20. package/.github/prompts/auto-route.prompt.md +33 -0
  21. package/.github/prompts/azure-rag.query.prompt.md +19 -0
  22. package/.github/prompts/backend.fix-bug.prompt.md +13 -0
  23. package/.github/prompts/cavecrew.prompt.md +16 -0
  24. package/.github/prompts/caveman-commit.prompt.md +14 -0
  25. package/.github/prompts/caveman-compress.prompt.md +15 -0
  26. package/.github/prompts/caveman-debug.prompt.md +13 -0
  27. package/.github/prompts/caveman-help.prompt.md +11 -0
  28. package/.github/prompts/caveman-review.prompt.md +15 -0
  29. package/.github/prompts/caveman-stats.prompt.md +11 -0
  30. package/.github/prompts/caveman.prompt.md +11 -0
  31. package/.github/prompts/community.post.prompt.md +14 -0
  32. package/.github/prompts/dba.query-review.prompt.md +15 -0
  33. package/.github/prompts/dev.fix-bug.prompt.md +13 -0
  34. package/.github/prompts/frontend.code.prompt.md +13 -0
  35. package/.github/prompts/legacy.impact-analysis.prompt.md +14 -0
  36. package/.github/prompts/project.kickoff-analysis.prompt.md +51 -0
  37. package/.github/prompts/rag.knowledge-answer.prompt.md +13 -0
  38. package/.github/prompts/token-saver-review.prompt.md +14 -0
  39. package/.github/prompts/ux-ui.review.prompt.md +14 -0
  40. package/.github/pull_request_template.md +71 -0
  41. package/.github/skills/ahorro-tokens/SKILL.md +36 -0
  42. package/.github/skills/azure-rag-enterprise/SKILL.md +24 -0
  43. package/.github/skills/backend-coding/SKILL.md +24 -0
  44. package/.github/skills/cavecrew/SKILL.md +17 -0
  45. package/.github/skills/caveman/SKILL.md +25 -0
  46. package/.github/skills/caveman-commit/SKILL.md +15 -0
  47. package/.github/skills/caveman-compress/SKILL.md +14 -0
  48. package/.github/skills/caveman-help/SKILL.md +19 -0
  49. package/.github/skills/caveman-mode/SKILL.md +43 -0
  50. package/.github/skills/caveman-review/SKILL.md +16 -0
  51. package/.github/skills/caveman-stats/SKILL.md +13 -0
  52. package/.github/skills/community-content/SKILL.md +22 -0
  53. package/.github/skills/database-analysis/SKILL.md +23 -0
  54. package/.github/skills/dev-coding/SKILL.md +24 -0
  55. package/.github/skills/frontend-coding/SKILL.md +24 -0
  56. package/.github/skills/human-in-the-loop/SKILL.md +47 -0
  57. package/.github/skills/iot-architecture/SKILL.md +22 -0
  58. package/.github/skills/legacy-migration/SKILL.md +22 -0
  59. package/.github/skills/rag-knowledge/SKILL.md +21 -0
  60. package/.github/skills/token-saver/SKILL.md +36 -0
  61. package/.github/skills/ux-ui-governance/SKILL.md +24 -0
  62. package/.github/skills/wiki-tools.json +24 -0
  63. package/.github/workflows/auto-devlog.yml +56 -0
  64. package/.github/workflows/auto-manage-issues.yml +64 -0
  65. package/.github/workflows/auto-sync.yml +54 -0
  66. package/.github/workflows/autodocs-sync.yml +114 -0
  67. package/.github/workflows/ci.yml +68 -0
  68. package/.github/workflows/pages.yml +59 -0
  69. package/.github/workflows/routing-evals.yml +59 -0
  70. package/.github/workflows/techriders-coverage-effective.yml +91 -0
  71. package/.vscode/mcp.json +44 -0
  72. package/AGENTS.md +160 -0
  73. package/ARCHITECTURE.md +57 -0
  74. package/FINAL_USAGE_GUIDE.md +106 -0
  75. package/LICENSE +21 -0
  76. package/README.md +385 -0
  77. package/README_WIKI.md +130 -0
  78. package/autodocs/README.md +22 -0
  79. package/autodocs/schema/wiki-node.schema.json +56 -0
  80. package/autolearning/feedback-loop.md +90 -0
  81. package/bin/install-host.js +326 -0
  82. package/bin/mcpee.js +116 -0
  83. package/context/repomix/repomix.config.json +20 -0
  84. package/memory/cross-memory-reasoning.md +17 -0
  85. package/memory/mempry-registry.yml +16 -0
  86. package/observability/evals/chat-token-usage-report.json +64 -0
  87. package/observability/evals/chat-token-usage-report.md +33 -0
  88. package/observability/evals/iteration-value-report.json +76 -0
  89. package/observability/evals/iteration-value-report.md +39 -0
  90. package/observability/evals/learning-loop-report.json +268 -0
  91. package/observability/evals/learning-loop-report.md +37 -0
  92. package/observability/evals/repo-intake-eval-cases.md +23 -0
  93. package/observability/evals/routing-eval-cases.json +68 -0
  94. package/observability/evals/routing-eval-cases.md +25 -0
  95. package/observability/evals/routing-eval-report.json +72 -0
  96. package/observability/evaluation.md +34 -0
  97. package/observability/logs/copilot-usage-ingest-report.json +13 -0
  98. package/observability/logs/iteration-metrics.jsonl +75 -0
  99. package/observability/logs/learning-feedback.jsonl +152 -0
  100. package/observability/logs/routing-decisions.jsonl +333 -0
  101. package/observability/logs/session/agent-pipeline-preflight-20260701-004146.log +8 -0
  102. package/observability/logs/session/agent-pipeline-preflight-20260701-005554.log +8 -0
  103. package/observability/logs/session/agent-pipeline-preflight-20260701-010351.log +8 -0
  104. package/observability/logs/session/agent-pipeline-preflight-20260704-145829.log +8 -0
  105. package/observability/logs/session/agent-pipeline-preflight-20260704-150021.log +8 -0
  106. package/observability/logs/session/agent-pipeline-preflight-20260704-154328.log +8 -0
  107. package/observability/logs/session/bye-20260629-221513.json +39 -0
  108. package/observability/logs/session/bye-20260629-221545.json +59 -0
  109. package/observability/logs/session/bye-20260629-222007.json +52 -0
  110. package/observability/logs/session/bye-20260629-222133.json +59 -0
  111. package/observability/logs/session/bye-20260629-222412.json +45 -0
  112. package/observability/logs/session/bye-20260629-223224.json +52 -0
  113. package/observability/logs/session/bye-20260629-224050.json +59 -0
  114. package/observability/logs/session/bye-20260630-105732.json +24 -0
  115. package/observability/logs/session/bye-20260630-211536.json +87 -0
  116. package/observability/logs/session/bye-20260630-223423.json +87 -0
  117. package/observability/logs/session/bye-20260630-232534.json +87 -0
  118. package/observability/logs/session/bye-20260701-003638.json +126 -0
  119. package/observability/logs/session/bye-20260701-003849.json +126 -0
  120. package/observability/logs/session/bye-20260701-004315.json +138 -0
  121. package/observability/logs/session/bye-20260701-004559.json +76 -0
  122. package/observability/logs/session/bye-20260701-005913.json +138 -0
  123. package/observability/logs/session/bye-20260701-010753.json +138 -0
  124. package/observability/logs/session/bye-20260703-194106.json +24 -0
  125. package/observability/logs/session/bye-20260703-233443.json +76 -0
  126. package/observability/logs/session/bye-20260703-233653.json +76 -0
  127. package/observability/logs/session/bye-20260704-150317.json +152 -0
  128. package/observability/logs/session/bye-20260704-150929.json +75 -0
  129. package/observability/logs/session/bye-20260704-151050.json +75 -0
  130. package/observability/logs/session/bye-20260705-115458.json +165 -0
  131. package/observability/logs/session/codegraph-status-20260701-004228.log +39 -0
  132. package/observability/logs/session/codegraph-status-20260701-004310.log +39 -0
  133. package/observability/logs/session/codegraph-status-20260701-005637.log +39 -0
  134. package/observability/logs/session/codegraph-status-20260701-005908.log +39 -0
  135. package/observability/logs/session/codegraph-status-20260701-010444.log +39 -0
  136. package/observability/logs/session/codegraph-status-20260701-010747.log +39 -0
  137. package/observability/logs/session/codegraph-status-20260704-150137.log +26 -0
  138. package/observability/logs/session/codegraph-status-20260704-150313.log +28 -0
  139. package/observability/logs/session/codegraph-status-20260704-154445.log +26 -0
  140. package/observability/logs/session/codegraph-status-20260705-115454.log +27 -0
  141. package/observability/logs/session/codegraph-sync-20260701-004211.log +88 -0
  142. package/observability/logs/session/codegraph-sync-20260701-004241.log +82 -0
  143. package/observability/logs/session/codegraph-sync-20260701-005620.log +89 -0
  144. package/observability/logs/session/codegraph-sync-20260701-005840.log +88 -0
  145. package/observability/logs/session/codegraph-sync-20260701-010419.log +93 -0
  146. package/observability/logs/session/codegraph-sync-20260701-010609.log +90 -0
  147. package/observability/logs/session/codegraph-sync-20260704-145856.log +70 -0
  148. package/observability/logs/session/codegraph-sync-20260704-150047.log +53 -0
  149. package/observability/logs/session/codegraph-sync-20260704-150204.log +44 -0
  150. package/observability/logs/session/codegraph-sync-20260704-154353.log +26 -0
  151. package/observability/logs/session/codegraph-sync-20260705-115337.log +32 -0
  152. package/observability/logs/session/hi-20260629-221459.json +38 -0
  153. package/observability/logs/session/hi-20260629-221945.json +59 -0
  154. package/observability/logs/session/hi-20260629-222108.json +66 -0
  155. package/observability/logs/session/hi-20260629-222352.json +45 -0
  156. package/observability/logs/session/hi-20260629-225719.json +59 -0
  157. package/observability/logs/session/hi-20260629-233722.json +52 -0
  158. package/observability/logs/session/hi-20260629-233913.json +198 -0
  159. package/observability/logs/session/hi-20260630-110156.json +177 -0
  160. package/observability/logs/session/hi-20260630-191243.json +184 -0
  161. package/observability/logs/session/hi-20260630-230050.json +234 -0
  162. package/observability/logs/session/hi-20260630-230523.json +227 -0
  163. package/observability/logs/session/hi-20260630-230855.json +227 -0
  164. package/observability/logs/session/hi-20260630-231638.json +227 -0
  165. package/observability/logs/session/hi-20260630-231756.json +219 -0
  166. package/observability/logs/session/hi-20260701-002842.json +234 -0
  167. package/observability/logs/session/hi-20260701-003458.json +282 -0
  168. package/observability/logs/session/hi-20260701-004233.json +290 -0
  169. package/observability/logs/session/hi-20260701-004554.json +236 -0
  170. package/observability/logs/session/hi-20260701-005641.json +290 -0
  171. package/observability/logs/session/hi-20260701-010450.json +290 -0
  172. package/observability/logs/session/hi-20260703-233854.json +312 -0
  173. package/observability/logs/session/hi-20260703-234448.json +318 -0
  174. package/observability/logs/session/hi-20260704-145907.json +353 -0
  175. package/observability/logs/session/hi-20260704-150141.json +392 -0
  176. package/observability/logs/session/hi-20260704-154448.json +392 -0
  177. package/observability/logs/session/iteration-value-refresh-20260701-004309.log +3 -0
  178. package/observability/logs/session/iteration-value-refresh-20260701-005907.log +3 -0
  179. package/observability/logs/session/iteration-value-refresh-20260701-010747.log +3 -0
  180. package/observability/logs/session/iteration-value-refresh-20260704-150312.log +3 -0
  181. package/observability/logs/session/iteration-value-refresh-20260705-115453.log +3 -0
  182. package/observability/logs/session/learning-loop-refresh-20260701-004309.log +3 -0
  183. package/observability/logs/session/learning-loop-refresh-20260701-005906.log +3 -0
  184. package/observability/logs/session/learning-loop-refresh-20260701-010745.log +3 -0
  185. package/observability/logs/session/learning-loop-refresh-20260704-150309.log +3 -0
  186. package/observability/logs/session/learning-loop-refresh-20260705-115450.log +3 -0
  187. package/observability/logs/session/project-notes-refresh-20260701-004227.log +1 -0
  188. package/observability/logs/session/project-notes-refresh-20260701-004308.log +1 -0
  189. package/observability/logs/session/project-notes-refresh-20260701-005636.log +1 -0
  190. package/observability/logs/session/project-notes-refresh-20260701-005906.log +1 -0
  191. package/observability/logs/session/project-notes-refresh-20260701-010443.log +1 -0
  192. package/observability/logs/session/project-notes-refresh-20260701-010744.log +1 -0
  193. package/observability/logs/session/project-notes-refresh-20260704-150133.log +1 -0
  194. package/observability/logs/session/project-notes-refresh-20260704-150309.log +1 -0
  195. package/observability/logs/session/project-notes-refresh-20260704-154442.log +1 -0
  196. package/observability/logs/session/project-notes-refresh-20260705-115449.log +1 -0
  197. package/observability/logs/session/repo-intake-20260701-004218.log +6 -0
  198. package/observability/logs/session/repo-intake-20260701-005626.log +6 -0
  199. package/observability/logs/session/repo-intake-20260701-010433.log +6 -0
  200. package/observability/logs/session/repo-intake-20260704-150053.log +6 -0
  201. package/observability/logs/session/repo-intake-20260704-154404.log +6 -0
  202. package/observability/logs/session/repo-intake-refresh-20260701-004247.log +6 -0
  203. package/observability/logs/session/repo-intake-refresh-20260701-005847.log +6 -0
  204. package/observability/logs/session/repo-intake-refresh-20260701-010615.log +6 -0
  205. package/observability/logs/session/repo-intake-refresh-20260704-150209.log +6 -0
  206. package/observability/logs/session/repo-intake-refresh-20260705-115342.log +6 -0
  207. package/observability/logs/session/repo-registry-validation-20260701-004234.log +2 -0
  208. package/observability/logs/session/repo-registry-validation-20260701-004556.log +2 -0
  209. package/observability/logs/session/repo-registry-validation-20260701-005833.log +2 -0
  210. package/observability/logs/session/repo-registry-validation-20260701-010601.log +2 -0
  211. package/observability/logs/session/repo-registry-validation-20260704-150155.log +2 -0
  212. package/observability/logs/session/repo-registry-validation-20260705-115323.log +2 -0
  213. package/observability/logs/session/repomix-refresh-20260701-003823.log +4236 -0
  214. package/observability/logs/session/repomix-refresh-20260701-004251.log +4275 -0
  215. package/observability/logs/session/repomix-refresh-20260701-005850.log +4248 -0
  216. package/observability/logs/session/repomix-refresh-20260701-010619.log +6531 -0
  217. package/observability/logs/session/repomix-refresh-20260704-150239.log +652 -0
  218. package/observability/logs/session/repomix-refresh-20260705-115419.log +178 -0
  219. package/observability/logs/session/routing-evals-20260701-004221.log +2 -0
  220. package/observability/logs/session/routing-evals-20260701-004235.log +2 -0
  221. package/observability/logs/session/routing-evals-20260701-005629.log +2 -0
  222. package/observability/logs/session/routing-evals-20260701-005834.log +2 -0
  223. package/observability/logs/session/routing-evals-20260701-010437.log +2 -0
  224. package/observability/logs/session/routing-evals-20260701-010603.log +2 -0
  225. package/observability/logs/session/routing-evals-20260704-150125.log +2 -0
  226. package/observability/logs/session/routing-evals-20260704-150157.log +2 -0
  227. package/observability/logs/session/routing-evals-20260704-154434.log +2 -0
  228. package/observability/logs/session/routing-evals-20260705-115327.log +2 -0
  229. package/observability/logs/session/sibling-discovery-refresh-20260701-004250.log +3 -0
  230. package/observability/logs/session/sibling-discovery-refresh-20260701-005850.log +3 -0
  231. package/observability/logs/session/sibling-discovery-refresh-20260701-010618.log +3 -0
  232. package/observability/logs/session/sibling-discovery-refresh-20260704-150238.log +3 -0
  233. package/observability/logs/session/sibling-discovery-refresh-20260705-115418.log +3 -0
  234. package/observability/logs.schema.json +95 -0
  235. package/observability/logs.schema.md +26 -0
  236. package/observability/metrics.md +35 -0
  237. package/observability/routing-evaluator.md +37 -0
  238. package/observability/scoring-rubric.md +38 -0
  239. package/optimization/ALWAYS_ON_OPTIMIZATION.md +98 -0
  240. package/optimization/caveman-mode.md +62 -0
  241. package/optimization/examples/login-bug.md +25 -0
  242. package/optimization/examples/sla-query.md +25 -0
  243. package/optimization/optimization-routing.md +30 -0
  244. package/optimization/policies/response-style.policy.md +45 -0
  245. package/optimization/policies/token-budget.policy.md +28 -0
  246. package/optimization/profiles/always-on.profile.md +19 -0
  247. package/optimization/profiles/architecture.profile.md +20 -0
  248. package/optimization/profiles/debug.profile.md +20 -0
  249. package/optimization/profiles/enterprise-rag.profile.md +20 -0
  250. package/optimization/profiles/training.profile.md +20 -0
  251. package/optimization/token-saver.md +58 -0
  252. package/orchestrator/corporate-routing.md +51 -0
  253. package/orchestrator/decision-matrix.md +33 -0
  254. package/orchestrator/fallback.md +29 -0
  255. package/orchestrator/repo-routing.md +58 -0
  256. package/orchestrator/router.md +75 -0
  257. package/orchestrator/wiki/__init__.py +5 -0
  258. package/orchestrator/wiki/graph_consolidator.py +506 -0
  259. package/orchestrator/wiki/incremental_engine.py +57 -0
  260. package/orchestrator/wiki/plugin_manager.py +40 -0
  261. package/package.json +70 -0
  262. package/policies/context-policy.md +25 -0
  263. package/policies/cost-policy.md +25 -0
  264. package/policies/repo-intake-policy.md +36 -0
  265. package/policies/security-policy.md +25 -0
  266. package/repo-intake/README.md +81 -0
  267. package/repo-intake/templates/agent.template.md +4 -0
  268. package/repo-intake/templates/context-manifest.template.md +4 -0
  269. package/repo-intake/templates/skill.template.md +3 -0
  270. package/repo-registry/repos.schema.json +102 -0
  271. package/repo-registry/repos.template.json +26 -0
  272. package/requirements.txt +1 -0
  273. package/scripts/README.md +109 -0
  274. package/scripts/__init__.py +0 -0
  275. package/scripts/bootstrap-portable.cmd +4 -0
  276. package/scripts/bootstrap-portable.ps1 +90 -0
  277. package/scripts/context/azure-rag-mcp-adapter.py +1 -0
  278. package/scripts/context/build-graphify.ps1 +1 -0
  279. package/scripts/context/build-repomix.ps1 +1 -0
  280. package/scripts/discovery/discover-boost-repos.cmd +4 -0
  281. package/scripts/discovery/discover-boost-repos.py +186 -0
  282. package/scripts/discovery/refresh-project-notes.py +179 -0
  283. package/scripts/github/INSTALL.md +295 -0
  284. package/scripts/github/README.md +455 -0
  285. package/scripts/github/apply-boost-templates.ps1 +163 -0
  286. package/scripts/github/apply-single-repo.ps1 +85 -0
  287. package/scripts/github/create-devlog.ps1 +380 -0
  288. package/scripts/github/manage-issues.ps1 +332 -0
  289. package/scripts/github/sync-repo.ps1 +267 -0
  290. package/scripts/intake/agent-pipeline-preflight.py +151 -0
  291. package/scripts/intake/init-template-registry.cmd +4 -0
  292. package/scripts/intake/init-template-registry.ps1 +258 -0
  293. package/scripts/intake/repo-intake.py +354 -0
  294. package/scripts/intake/resolve-routing.py +620 -0
  295. package/scripts/intake/run-repo-intake.cmd +4 -0
  296. package/scripts/intake/run-repo-intake.ps1 +46 -0
  297. package/scripts/intake/run-routing-evals.py +147 -0
  298. package/scripts/intake/validate-database-routing.py +91 -0
  299. package/scripts/intake/validate-rag-routing.py +85 -0
  300. package/scripts/intake/validate-repo-registry.ps1 +20 -0
  301. package/scripts/intake/validate-repo-registry.py +286 -0
  302. package/scripts/intake/validate-security.py +170 -0
  303. package/scripts/learning/autolearning-gate.py +71 -0
  304. package/scripts/learning/chat-token-usage-report.py +326 -0
  305. package/scripts/learning/ingest-copilot-session-usage.py +421 -0
  306. package/scripts/learning/iteration-value-report.py +275 -0
  307. package/scripts/learning/learning-loop-report.py +272 -0
  308. package/scripts/learning/record-iteration-metrics.py +116 -0
  309. package/scripts/learning/record-learning-feedback.py +91 -0
  310. package/scripts/ops/bye.ps1 +620 -0
  311. package/scripts/ops/compare-demo-results.ps1 +826 -0
  312. package/scripts/ops/demo1.ps1 +11 -0
  313. package/scripts/ops/demo2.ps1 +11 -0
  314. package/scripts/ops/demo3.ps1 +11 -0
  315. package/scripts/ops/demo4.ps1 +11 -0
  316. package/scripts/ops/hi.ps1 +1045 -0
  317. package/scripts/ops/llm-token-probe.py +164 -0
  318. package/scripts/ops/run-all-demos.ps1 +39 -0
  319. package/scripts/ops/run-demo-block.ps1 +85 -0
  320. package/scripts/ops/run-demo-session.ps1 +532 -0
  321. package/scripts/setup/optimize-engines.ps1 +183 -0
  322. package/scripts/setup/setup-codegraph.ps1 +3 -0
  323. package/scripts/setup/setup-gitnexus.ps1 +3 -0
  324. package/scripts/setup/setup-graphify.ps1 +2 -0
  325. package/scripts/setup/setup-prerequisites.ps1 +205 -0
  326. package/scripts/setup/start-gitnexus.ps1 +71 -0
  327. package/scripts/setup/validate-context.ps1 +361 -0
  328. package/scripts/wiki/__init__.py +0 -0
  329. package/scripts/wiki/compiler_main.py +189 -0
  330. package/scripts/wiki/normalizer.py +206 -0
  331. package/scripts/wiki/providers/base_provider.py +25 -0
  332. package/scripts/wiki/providers/codegraph_provider.py +49 -0
  333. package/scripts/wiki/providers/graphify_provider.py +49 -0
  334. package/scripts/wiki/providers/repo_content_provider.py +408 -0
  335. package/scripts/wiki/query_autodocs.py +60 -0
  336. package/scripts/wiki/validator.py +183 -0
  337. package/scripts/wiki/wiki_compiler.py +5 -0
  338. package/specs/architecture.spec.md +32 -0
  339. package/specs/azure-rag.spec.md +28 -0
  340. package/specs/coding-standards.spec.md +24 -0
  341. package/specs/database.spec.md +29 -0
  342. package/specs/migration.spec.md +26 -0
  343. package/specs/observability.spec.md +24 -0
  344. package/specs/optimization.spec.md +31 -0
  345. package/specs/rag.spec.md +30 -0
  346. package/specs/repo-intake.spec.md +25 -0
  347. package/specs/routing.spec.md +24 -0
  348. package/specs/security.spec.md +30 -0
  349. package/specs/wiki/provider-contract.json +33 -0
  350. package/specs/wiki/unified-knowledge-graph.json +25 -0
  351. package/templates/BOOST_README_TEMPLATE.md +96 -0
  352. package/templates/CODEOWNERS_TEMPLATE.txt +29 -0
  353. package/templates/LICENSE_MIT_TEMPLATE.txt +21 -0
  354. package/templates/PERSONAL_README_TEMPLATE.md +90 -0
  355. package/templates/README_boost_RAG_Azure.md +46 -0
  356. package/templates/README_boost_azure_iot_edge.md +48 -0
  357. package/templates/README_boost_backend.md +47 -0
  358. package/templates/README_boost_dba.md +57 -0
  359. package/templates/ci.yml.template +73 -0
  360. package/tooling/tooling.manifest.json +72 -0
@@ -0,0 +1,267 @@
1
+ #Requires -Version 7
2
+
3
+ <#
4
+ .SYNOPSIS
5
+ Sincroniza cambios entre repositorios principales mediante GitHub MCP.
6
+
7
+ .DESCRIPTION
8
+ Detecta cambios en SourceRepo, filtra por patrón de archivos, y crea PR en TargetRepo.
9
+ Usa GitHub MCP Server para operaciones automatizadas.
10
+
11
+ .PARAMETER SourceRepo
12
+ Repo origen (owner/repo). Por defecto: Sertxito/mcp-efficiency-engine
13
+
14
+ .PARAMETER TargetRepo
15
+ Repo destino (owner/repo). Por defecto: Sertxito/boost_sertxIA
16
+
17
+ .PARAMETER FilesPattern
18
+ Patrón glob para filtrar archivos a sincronizar. Por defecto: projects/**
19
+
20
+ .PARAMETER BranchName
21
+ Nombre de rama para PR. Por defecto: sync/{timestamp}
22
+
23
+ .EXAMPLE
24
+ .\sync-repo.ps1 -FilesPattern "projects/**" -DryRun
25
+
26
+ .EXAMPLE
27
+ .\sync-repo.ps1 -SourceRepo "Sertxito/mcp-efficiency-engine" -TargetRepo "Sertxito/boost_sertxIA"
28
+
29
+ #>
30
+
31
+ param(
32
+ [string]$SourceRepo = "Sertxito/mcp-efficiency-engine",
33
+ [string]$TargetRepo = "Sertxito/boost_sertxIA",
34
+ [string]$FilesPattern = "projects/**",
35
+ [string]$BranchName = "sync/$(Get-Date -Format 'yyyyMMdd-HHmmss')",
36
+ [switch]$DryRun
37
+ )
38
+
39
+ $ErrorActionPreference = "Stop"
40
+
41
+ # Verificar MCP GitHub disponible
42
+ function Test-MCPGitHub {
43
+ try {
44
+ $result = gh api --version 2>&1
45
+ Write-Host "✓ GitHub CLI disponible: $result"
46
+ return $true
47
+ } catch {
48
+ Write-Host "✗ GitHub CLI no disponible. Instalar con: gh --version"
49
+ return $false
50
+ }
51
+ }
52
+
53
+ # Obtener cambios entre branches
54
+ function Get-RepoChanges {
55
+ param([string]$Repo, [string]$BaseBranch = "main")
56
+
57
+ Write-Host "Detectando cambios en $Repo/$BaseBranch..."
58
+
59
+ try {
60
+ $commits = gh api repos/$Repo/commits --limit 20 | ConvertFrom-Json
61
+ $files = @()
62
+
63
+ foreach ($commit in $commits) {
64
+ $commit_data = gh api repos/$Repo/commits/$($commit.sha) | ConvertFrom-Json
65
+ $files += $commit_data.files | Where-Object { $_.filename -like $FilesPattern }
66
+ }
67
+
68
+ return $files | Sort-Object filename -Unique
69
+ } catch {
70
+ Write-Host "Error al obtener cambios: $_"
71
+ return @()
72
+ }
73
+ }
74
+
75
+ # Crear rama en repo destino
76
+ function New-TargetBranch {
77
+ param([string]$Repo, [string]$Branch)
78
+
79
+ Write-Host "Creando rama $Branch en $Repo..."
80
+
81
+ if ($DryRun) {
82
+ Write-Host "[DRY-RUN] gh api repos/$Repo/git/refs -H 'Accept: application/vnd.github+json' -f ref=refs/heads/$Branch"
83
+ return $true
84
+ }
85
+
86
+ try {
87
+ # Obtener ref actual
88
+ $mainRef = gh api repos/$Repo/git/refs/heads/main | ConvertFrom-Json
89
+
90
+ # Crear nueva rama
91
+ gh api repos/$Repo/git/refs `
92
+ -H 'Accept: application/vnd.github+json' `
93
+ -f ref=refs/heads/$Branch `
94
+ -f sha=$mainRef.object.sha
95
+
96
+ Write-Host "✓ Rama creada: $Branch"
97
+ return $true
98
+ } catch {
99
+ Write-Host "✗ Error creando rama: $_"
100
+ return $false
101
+ }
102
+ }
103
+
104
+ # Sincronizar archivos
105
+ function Sync-Files {
106
+ param(
107
+ [string]$SourceRepo,
108
+ [string]$TargetRepo,
109
+ [string]$TargetBranch,
110
+ [array]$Files
111
+ )
112
+
113
+ Write-Host "Sincronizando $($Files.Count) archivos..."
114
+
115
+ $synced = 0
116
+ foreach ($file in $Files) {
117
+ try {
118
+ $filePath = $file.filename
119
+ Write-Host " Sincronizando: $filePath"
120
+
121
+ # Obtener contenido del archivo fuente
122
+ $content = gh api repos/$SourceRepo/contents/$filePath | ConvertFrom-Json
123
+ $fileContent = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($content.content))
124
+
125
+ if ($DryRun) {
126
+ Write-Host " [DRY-RUN] Actualizaría $filePath"
127
+ $synced++
128
+ continue
129
+ }
130
+
131
+ # Intentar obtener SHA actual en destino
132
+ $targetFile = gh api repos/$TargetRepo/contents/$filePath --jq '.sha' 2>$null || $null
133
+
134
+ # Crear/actualizar archivo en destino
135
+ $params = @{
136
+ message = "sync: Sincronizar $filePath desde $SourceRepo"
137
+ content = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($fileContent))
138
+ branch = $TargetBranch
139
+ }
140
+
141
+ if ($targetFile) {
142
+ $params.sha = $targetFile
143
+ }
144
+
145
+ gh api repos/$TargetRepo/contents/$filePath -X PUT @params | Out-Null
146
+
147
+ Write-Host " ✓ $filePath sincronizado"
148
+ $synced++
149
+ } catch {
150
+ Write-Host " ⚠ Error sincronizando $($file.filename): $_"
151
+ }
152
+ }
153
+
154
+ return $synced
155
+ }
156
+
157
+ # Crear PR de sincronización
158
+ function New-SyncPullRequest {
159
+ param(
160
+ [string]$TargetRepo,
161
+ [string]$TargetBranch,
162
+ [int]$FileCount
163
+ )
164
+
165
+ $title = "sync: Sincronizar cambios desde $SourceRepo"
166
+ $body = @"
167
+ ## Sincronización Automática
168
+
169
+ **Origen:** $SourceRepo
170
+ **Destino:** $TargetRepo
171
+ **Archivos sincronizados:** $FileCount
172
+
173
+ ### Patrón de archivos
174
+ \`\`\`
175
+ $FilesPattern
176
+ \`\`\`
177
+
178
+ ### Verificación
179
+ - [ ] Revisar cambios
180
+ - [ ] Ejecutar validaciones locales
181
+ - [ ] Confirmar comportamiento esperado
182
+
183
+ ### Referencias
184
+ - Source commit: $(gh api repos/$SourceRepo/commits/main --jq '.sha' | Cut -c 1-7)
185
+ - Sincronizado automáticamente vía GitHub MCP
186
+ "@
187
+
188
+ if ($DryRun) {
189
+ Write-Host "[DRY-RUN] Crearría PR:"
190
+ Write-Host " Título: $title"
191
+ Write-Host " Rama: $TargetBranch"
192
+ return $true
193
+ }
194
+
195
+ try {
196
+ $pr = gh pr create `
197
+ --repo "$TargetRepo" `
198
+ --base main `
199
+ --head $TargetBranch `
200
+ --title $title `
201
+ --body $body `
202
+ --draft
203
+
204
+ Write-Host "✓ PR creada: $pr"
205
+ return $true
206
+ } catch {
207
+ Write-Host "✗ Error creando PR: $_"
208
+ return $false
209
+ }
210
+ }
211
+
212
+ # ===================
213
+ # Main Execution
214
+ # ===================
215
+
216
+ Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
217
+ Write-Host "GitHub MCP Repo Synchronizer"
218
+ Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
219
+ Write-Host ""
220
+ Write-Host "Origen: $SourceRepo"
221
+ Write-Host "Destino: $TargetRepo"
222
+ Write-Host "Patrón: $FilesPattern"
223
+ Write-Host "Rama: $BranchName"
224
+
225
+ if ($DryRun) {
226
+ Write-Host "🔍 Modo DRY-RUN: No se realizarán cambios"
227
+ }
228
+ Write-Host ""
229
+
230
+ # 1. Verificar MCP GitHub
231
+ if (-not (Test-MCPGitHub)) {
232
+ exit 1
233
+ }
234
+
235
+ # 2. Obtener cambios
236
+ $changes = Get-RepoChanges -Repo $SourceRepo
237
+ if ($changes.Count -eq 0) {
238
+ Write-Host "ℹ No hay cambios que sincronizar"
239
+ exit 0
240
+ }
241
+
242
+ Write-Host "Encontrados $($changes.Count) cambios"
243
+ Write-Host ""
244
+
245
+ # 3. Crear rama destino
246
+ if (-not (New-TargetBranch -Repo $TargetRepo -Branch $BranchName)) {
247
+ exit 1
248
+ }
249
+
250
+ # 4. Sincronizar archivos
251
+ $synced = Sync-Files -SourceRepo $SourceRepo -TargetRepo $TargetRepo `
252
+ -TargetBranch $BranchName -Files $changes
253
+
254
+ Write-Host ""
255
+ Write-Host "Sincronizados: $synced/$($changes.Count) archivos"
256
+
257
+ if ($synced -gt 0) {
258
+ # 5. Crear PR
259
+ if (-not $DryRun) {
260
+ New-SyncPullRequest -TargetRepo $TargetRepo -TargetBranch $BranchName -FileCount $synced
261
+ } else {
262
+ Write-Host "[DRY-RUN] PR sería creada con $synced archivos"
263
+ }
264
+ }
265
+
266
+ Write-Host ""
267
+ Write-Host "✓ Sincronización completada"
@@ -0,0 +1,151 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import json
5
+ from pathlib import Path
6
+ from typing import Any
7
+
8
+
9
+ REQUIRED_AGENT_ALIASES: dict[str, list[str]] = {
10
+ "backend": ["backend", "backend"],
11
+ "frontend": ["frontend-agent"],
12
+ "legacy": ["legacy", "legacy"],
13
+ "dba": ["dba", "dba"],
14
+ "rag-local": ["rag-local", "rag-local"],
15
+ "rag-azure": ["rag-azure", "rag-azure"],
16
+ "iot": ["iot", "iot"],
17
+ "ux-ui": ["ux-ui", "ux-ui"],
18
+ "community-manager": ["community-manager", "community-manager"],
19
+ "snapshot": ["snapshot", "snapshot"],
20
+ }
21
+
22
+ AGENT_TEMPLATE: dict[str, str] = {
23
+ "backend": "Modern development tasks on a single repository.",
24
+ "frontend-agent": "Frontend development tasks on a single repository.",
25
+ "legacy": "Legacy/migration and multi-repo impact analysis.",
26
+ "dba": "SQL/schema/procedure and DBA analysis.",
27
+ "rag-local": "Local technical docs and knowledge retrieval.",
28
+ "rag-azure": "Corporate docs with mandatory evidence.",
29
+ "iot": "IoT/edge/telemetry mixed code+docs workflow.",
30
+ "ux-ui": "UX/UI governance and design-intent control workflow.",
31
+ "community-manager": "Education/posts/storytelling from grounded knowledge.",
32
+ "snapshot": "Portable scope-safe context export.",
33
+ }
34
+
35
+
36
+ def load_registry(path: Path) -> dict[str, Any]:
37
+ content = path.read_text(encoding="utf-8")
38
+ if content.lstrip().startswith("{"):
39
+ return json.loads(content)
40
+ raise ValueError("repo-registry/repos.yml must be JSON-first in this repository")
41
+
42
+
43
+ def write_agent_template(agent_name: str, path: Path) -> None:
44
+ desc = AGENT_TEMPLATE.get(agent_name, "Specialized agent definition.")
45
+ body = (
46
+ f"# {agent_name}\n\n"
47
+ "## Purpose\n\n"
48
+ f"{desc}\n\n"
49
+ "## Pipeline\n\n"
50
+ "1. Memory-first selection.\n"
51
+ "1. Route by intent/domain/source.\n"
52
+ "1. Apply always-on optimization.\n"
53
+ "1. Register feedback into AutoLearning.\n"
54
+ )
55
+ path.parent.mkdir(parents=True, exist_ok=True)
56
+ path.write_text(body, encoding="utf-8")
57
+
58
+
59
+ def main() -> int:
60
+ parser = argparse.ArgumentParser(description="Validate agent -> skills -> boost pipeline prerequisites.")
61
+ parser.add_argument("--registry", default="repo-registry/repos.yml")
62
+ parser.add_argument("--agents-dir", default=".github/agents")
63
+ parser.add_argument("--generated-root", default="repo-intake/generated")
64
+ parser.add_argument("--create-missing-templates", action="store_true")
65
+ args = parser.parse_args()
66
+
67
+ repo_root = Path(__file__).resolve().parents[2]
68
+ registry_path = (repo_root / args.registry).resolve()
69
+ agents_dir = (repo_root / args.agents_dir).resolve()
70
+ generated_root = (repo_root / args.generated_root).resolve()
71
+
72
+ registry = load_registry(registry_path)
73
+ repos = registry.get("repos", []) if isinstance(registry.get("repos", []), list) else []
74
+
75
+ missing_agents: list[str] = []
76
+ for logical_name, aliases in REQUIRED_AGENT_ALIASES.items():
77
+ candidates = [agents_dir / f"{alias}.agent.md" for alias in aliases]
78
+ if not any(path.exists() for path in candidates):
79
+ missing_agents.append(logical_name)
80
+
81
+ if missing_agents and args.create_missing_templates:
82
+ for logical_name in missing_agents:
83
+ preferred_name = REQUIRED_AGENT_ALIASES[logical_name][0]
84
+ write_agent_template(preferred_name, agents_dir / f"{preferred_name}.agent.md")
85
+
86
+ missing_boost_paths: list[str] = []
87
+ missing_manifests: list[str] = []
88
+ missing_capabilities: list[str] = []
89
+
90
+ for repo in repos:
91
+ if not isinstance(repo, dict):
92
+ continue
93
+ name = str(repo.get("name", "")).strip()
94
+ location = str(repo.get("location", "")).strip()
95
+ if not name or not location:
96
+ continue
97
+
98
+ abs_path = (repo_root / location).resolve()
99
+ if not abs_path.exists():
100
+ missing_boost_paths.append(f"{name} -> {abs_path}")
101
+
102
+ slug = name.lower().replace(" ", "-")
103
+ manifest = generated_root / slug / "context-manifests" / "manifest.json"
104
+ capability = generated_root / slug / "capabilities" / "capability.json"
105
+
106
+ if not manifest.exists():
107
+ missing_manifests.append(str(manifest))
108
+ if not capability.exists():
109
+ missing_capabilities.append(str(capability))
110
+
111
+ print("Agent Pipeline Preflight")
112
+ print(f"- agents_dir: {agents_dir}")
113
+ print(f"- required_agents: {len(REQUIRED_AGENT_ALIASES)}")
114
+ print(f"- missing_agents: {len(missing_agents)}")
115
+ print(f"- missing_boost_paths: {len(missing_boost_paths)}")
116
+ print(f"- missing_manifests: {len(missing_manifests)}")
117
+ print(f"- missing_capabilities: {len(missing_capabilities)}")
118
+
119
+ if missing_agents:
120
+ print("\nMissing agent definitions:")
121
+ for m in missing_agents:
122
+ accepted = ", ".join([f"{alias}.agent.md" for alias in REQUIRED_AGENT_ALIASES[m]])
123
+ print(f" - {m} (accepted: {accepted})")
124
+ if not args.create_missing_templates:
125
+ print("Hint: run with --create-missing-templates to scaffold placeholders.")
126
+
127
+ if missing_boost_paths:
128
+ print("\nMissing boost repository paths:")
129
+ for m in missing_boost_paths:
130
+ print(f" - {m}")
131
+
132
+ if missing_manifests:
133
+ print("\nMissing generated manifests:")
134
+ for m in missing_manifests[:20]:
135
+ print(f" - {m}")
136
+
137
+ if missing_capabilities:
138
+ print("\nMissing generated capabilities:")
139
+ for m in missing_capabilities[:20]:
140
+ print(f" - {m}")
141
+
142
+ if missing_agents or missing_boost_paths or missing_manifests or missing_capabilities:
143
+ return 1
144
+
145
+ print("Preflight OK. Agent pipeline can route to skills and boost platforms.")
146
+ return 0
147
+
148
+
149
+ if __name__ == "__main__":
150
+ raise SystemExit(main())
151
+
@@ -0,0 +1,4 @@
1
+ @echo off
2
+ setlocal
3
+ pwsh -NoProfile -ExecutionPolicy Bypass -File "%~dp0init-template-registry.ps1" %*
4
+ exit /b %ERRORLEVEL%
@@ -0,0 +1,258 @@
1
+ param(
2
+ [switch]$Force,
3
+ [string]$Owner,
4
+ [string]$RepoNamePrefix,
5
+ [string]$InitialRepoName,
6
+ [string]$InitialRepoDomain,
7
+ [string]$InitialRepoLocation,
8
+ [switch]$SkipInitialRepo,
9
+ [string]$TargetPath
10
+ )
11
+
12
+ Set-StrictMode -Version Latest
13
+ $ErrorActionPreference = "Stop"
14
+
15
+ $repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
16
+ Set-Location $repoRoot
17
+
18
+ $templatePath = Join-Path $repoRoot 'repo-registry\repos.template.json'
19
+ $targetPath = if ([string]::IsNullOrWhiteSpace($TargetPath)) {
20
+ Join-Path $repoRoot 'repo-registry\repos.yml'
21
+ }
22
+ else {
23
+ if ([System.IO.Path]::IsPathRooted($TargetPath)) {
24
+ $TargetPath
25
+ }
26
+ else {
27
+ Join-Path $repoRoot $TargetPath
28
+ }
29
+ }
30
+
31
+ function Read-RequiredValue {
32
+ param(
33
+ [Parameter(Mandatory = $true)][string]$Prompt,
34
+ [string]$DefaultValue = "",
35
+ [string]$ProvidedValue = ""
36
+ )
37
+
38
+ if (-not [string]::IsNullOrWhiteSpace($ProvidedValue)) {
39
+ return $ProvidedValue.Trim()
40
+ }
41
+
42
+ while ($true) {
43
+ $value = if ([string]::IsNullOrWhiteSpace($DefaultValue)) {
44
+ Read-Host $Prompt
45
+ }
46
+ else {
47
+ $inputValue = Read-Host "$Prompt [$DefaultValue]"
48
+ if ([string]::IsNullOrWhiteSpace($inputValue)) { $DefaultValue } else { $inputValue.Trim() }
49
+ }
50
+
51
+ if (-not [string]::IsNullOrWhiteSpace($value)) {
52
+ return $value.Trim()
53
+ }
54
+
55
+ Write-Host 'A value is required.'
56
+ }
57
+ }
58
+
59
+ function Read-ChoiceValue {
60
+ param(
61
+ [Parameter(Mandatory = $true)][string]$Prompt,
62
+ [Parameter(Mandatory = $true)][string[]]$AllowedValues,
63
+ [Parameter(Mandatory = $true)][string]$DefaultValue,
64
+ [string]$ProvidedValue = ""
65
+ )
66
+
67
+ $allowedLabels = $AllowedValues -join '/'
68
+ if (-not [string]::IsNullOrWhiteSpace($ProvidedValue)) {
69
+ $normalizedProvided = $ProvidedValue.Trim().ToLowerInvariant()
70
+ foreach ($candidate in $AllowedValues) {
71
+ if ($candidate.ToLowerInvariant() -eq $normalizedProvided) {
72
+ return $candidate
73
+ }
74
+ }
75
+
76
+ throw "Invalid value '$ProvidedValue' for $Prompt. Allowed values: $allowedLabels"
77
+ }
78
+
79
+ while ($true) {
80
+ $value = Read-Host "$Prompt [$DefaultValue] ($allowedLabels)"
81
+ if ([string]::IsNullOrWhiteSpace($value)) {
82
+ return $DefaultValue
83
+ }
84
+
85
+ $normalized = $value.Trim().ToLowerInvariant()
86
+ foreach ($candidate in $AllowedValues) {
87
+ if ($candidate.ToLowerInvariant() -eq $normalized) {
88
+ return $candidate
89
+ }
90
+ }
91
+
92
+ Write-Host "Allowed values: $allowedLabels"
93
+ }
94
+ }
95
+
96
+ function Read-YesNoValue {
97
+ param(
98
+ [Parameter(Mandatory = $true)][string]$Prompt,
99
+ [bool]$DefaultValue = $true,
100
+ [Nullable[bool]]$ProvidedValue = $null
101
+ )
102
+
103
+ if ($null -ne $ProvidedValue) {
104
+ return [bool]$ProvidedValue
105
+ }
106
+
107
+ $defaultLabel = if ($DefaultValue) { 'Y' } else { 'N' }
108
+ while ($true) {
109
+ $value = Read-Host "$Prompt [$defaultLabel]"
110
+ if ([string]::IsNullOrWhiteSpace($value)) {
111
+ return $DefaultValue
112
+ }
113
+
114
+ switch ($value.Trim().ToLowerInvariant()) {
115
+ 'y' { return $true }
116
+ 'yes' { return $true }
117
+ 'n' { return $false }
118
+ 'no' { return $false }
119
+ default { Write-Host 'Answer Y or N.' }
120
+ }
121
+ }
122
+ }
123
+
124
+ function Get-DefaultEnginesForDomain {
125
+ param([Parameter(Mandatory = $true)][string]$Domain)
126
+
127
+ switch ($Domain) {
128
+ 'dev' {
129
+ return [pscustomobject]@{
130
+ knowledge = 'codegraph'
131
+ execution = 'none'
132
+ snapshot = 'repomix'
133
+ }
134
+ }
135
+ 'legacy' {
136
+ return [pscustomobject]@{
137
+ knowledge = 'graphify'
138
+ execution = 'gitnexus'
139
+ snapshot = 'repomix'
140
+ }
141
+ }
142
+ 'dba' {
143
+ return [pscustomobject]@{
144
+ knowledge = 'graphify'
145
+ execution = 'none'
146
+ snapshot = 'repomix'
147
+ }
148
+ }
149
+ 'iot' {
150
+ return [pscustomobject]@{
151
+ knowledge = 'graphify'
152
+ execution = 'gitnexus'
153
+ snapshot = 'repomix'
154
+ }
155
+ }
156
+ 'azure-rag' {
157
+ return [pscustomobject]@{
158
+ knowledge = 'azure-rag-builder'
159
+ execution = 'none'
160
+ snapshot = 'repomix'
161
+ }
162
+ }
163
+ default {
164
+ return [pscustomobject]@{
165
+ knowledge = 'codegraph'
166
+ execution = 'none'
167
+ snapshot = 'repomix'
168
+ }
169
+ }
170
+ }
171
+ }
172
+
173
+ if (-not (Test-Path $templatePath)) {
174
+ throw "Missing template registry: $templatePath"
175
+ }
176
+
177
+ if ((Test-Path $targetPath) -and -not $Force) {
178
+ $currentRaw = Get-Content -Raw -Path $targetPath
179
+ $currentRegistry = $null
180
+ try {
181
+ $currentRegistry = $currentRaw | ConvertFrom-Json -Depth 20
182
+ }
183
+ catch {
184
+ $currentRegistry = $null
185
+ }
186
+
187
+ if ($currentRegistry -and ($currentRegistry.PSObject.Properties.Name -contains 'registry_mode') -and $currentRegistry.registry_mode -eq 'template') {
188
+ Write-Host "Template registry already initialized at $targetPath"
189
+ exit 0
190
+ }
191
+
192
+ throw "Registry already exists at $targetPath. Use -Force to overwrite it with the template."
193
+ }
194
+
195
+ $templateRegistry = Get-Content -Raw -Path $templatePath | ConvertFrom-Json -Depth 20
196
+
197
+ $defaultOwner = if ([string]::IsNullOrWhiteSpace($Owner)) { 'your-team' } else { $Owner }
198
+ $defaultPrefix = if ([string]::IsNullOrWhiteSpace($RepoNamePrefix)) { 'your-prefix_' } else { $RepoNamePrefix }
199
+
200
+ $resolvedOwner = Read-RequiredValue -Prompt 'Registry owner' -DefaultValue $defaultOwner -ProvidedValue $Owner
201
+ $resolvedPrefix = Read-RequiredValue -Prompt 'Repository name prefix' -DefaultValue $defaultPrefix -ProvidedValue $RepoNamePrefix
202
+
203
+ $templateRegistry.governance.owner = $resolvedOwner
204
+ $templateRegistry.governance.repo_name_prefix = $resolvedPrefix
205
+
206
+ $hasInitialRepoData = @($InitialRepoName, $InitialRepoDomain, $InitialRepoLocation) | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }
207
+ $addInitialRepo = $false
208
+ if ($SkipInitialRepo) {
209
+ $addInitialRepo = $false
210
+ }
211
+ elseif ($hasInitialRepoData.Count -gt 0) {
212
+ $addInitialRepo = $true
213
+ }
214
+ else {
215
+ $addInitialRepo = Read-YesNoValue -Prompt 'Add an initial repo entry now?' -DefaultValue $true
216
+ }
217
+
218
+ $templateRegistry.repos = @()
219
+ if ($addInitialRepo) {
220
+ $defaultRepoName = if ([string]::IsNullOrWhiteSpace($InitialRepoName)) { "$resolvedPrefix$((Split-Path $repoRoot -Leaf).ToLowerInvariant())" } else { $InitialRepoName }
221
+ $defaultRepoDomain = if ([string]::IsNullOrWhiteSpace($InitialRepoDomain)) { 'dev' } else { $InitialRepoDomain }
222
+ $defaultRepoLocation = if ([string]::IsNullOrWhiteSpace($InitialRepoLocation)) { '.' } else { $InitialRepoLocation }
223
+
224
+ $resolvedRepoName = Read-RequiredValue -Prompt 'Initial repo name' -DefaultValue $defaultRepoName -ProvidedValue $InitialRepoName
225
+ $resolvedRepoDomain = Read-ChoiceValue -Prompt 'Initial repo domain' -AllowedValues @('dev', 'legacy', 'dba', 'iot', 'azure-rag') -DefaultValue $defaultRepoDomain -ProvidedValue $InitialRepoDomain
226
+ $resolvedRepoLocation = Read-RequiredValue -Prompt 'Initial repo location' -DefaultValue $defaultRepoLocation -ProvidedValue $InitialRepoLocation
227
+ $resolvedEngines = Get-DefaultEnginesForDomain -Domain $resolvedRepoDomain
228
+
229
+ $templateRegistry.repos = @(
230
+ [pscustomobject]@{
231
+ name = $resolvedRepoName
232
+ domain = $resolvedRepoDomain
233
+ location = $resolvedRepoLocation
234
+ type = 'local'
235
+ optional = $false
236
+ dependencies = @()
237
+ engines = $resolvedEngines
238
+ }
239
+ )
240
+ }
241
+
242
+ $targetDir = Split-Path -Parent $targetPath
243
+ if (-not (Test-Path $targetDir)) {
244
+ New-Item -ItemType Directory -Path $targetDir -Force | Out-Null
245
+ }
246
+
247
+ $templateRegistry | ConvertTo-Json -Depth 20 | Set-Content -Path $targetPath -Encoding utf8
248
+ Write-Host "Template registry initialized at $targetPath"
249
+ Write-Host "Summary:"
250
+ Write-Host " owner: $resolvedOwner"
251
+ Write-Host " prefix: $resolvedPrefix"
252
+ Write-Host " repos: $($templateRegistry.repos.Count)"
253
+ if ($templateRegistry.repos.Count -gt 0) {
254
+ $firstRepo = $templateRegistry.repos[0]
255
+ Write-Host " first repo: $($firstRepo.name) [$($firstRepo.domain)] -> $($firstRepo.location)"
256
+ Write-Host " engines: knowledge=$($firstRepo.engines.knowledge), execution=$($firstRepo.engines.execution), snapshot=$($firstRepo.engines.snapshot)"
257
+ }
258
+ Write-Host "Next recommended step: .\\scripts\\intake\\run-repo-intake.cmd"