symphony-forge 1.2.44__py3-none-any.whl

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 (623) hide show
  1. forge/__init__.py +4 -0
  2. forge/app_baseline.py +148 -0
  3. forge/approval.py +298 -0
  4. forge/autoreview.py +139 -0
  5. forge/backfill.py +298 -0
  6. forge/board.py +1197 -0
  7. forge/board_app/app.js +276 -0
  8. forge/board_app/assign.css +91 -0
  9. forge/board_app/assign.js +157 -0
  10. forge/board_app/insights.js +80 -0
  11. forge/board_app/item.css +380 -0
  12. forge/board_app/item.js +594 -0
  13. forge/board_app/markdown.js +110 -0
  14. forge/board_app/now.css +417 -0
  15. forge/board_app/now.js +248 -0
  16. forge/board_app/pages.css +178 -0
  17. forge/board_app/releases.js +203 -0
  18. forge/board_app/shell.html +31 -0
  19. forge/board_app/tokens.css +220 -0
  20. forge/board_facts.py +696 -0
  21. forge/board_graph.py +38 -0
  22. forge/board_server.py +431 -0
  23. forge/board_trends.py +105 -0
  24. forge/box.py +54 -0
  25. forge/box_ssh.py +209 -0
  26. forge/checks.py +743 -0
  27. forge/citime.py +259 -0
  28. forge/claude_sdk.py +56 -0
  29. forge/claude_turn.py +62 -0
  30. forge/cli.py +185 -0
  31. forge/close.py +1193 -0
  32. forge/close_remote.py +85 -0
  33. forge/codex.py +1200 -0
  34. forge/codex_turn.py +346 -0
  35. forge/deny.py +253 -0
  36. forge/design.py +201 -0
  37. forge/design_skills.py +16 -0
  38. forge/docskip.py +175 -0
  39. forge/doctor.py +578 -0
  40. forge/event_log.py +128 -0
  41. forge/fasttest.py +846 -0
  42. forge/feature.py +318 -0
  43. forge/feature_api.py +593 -0
  44. forge/feature_python.py +1107 -0
  45. forge/feature_python_contracts.py +268 -0
  46. forge/feature_python_tests.py +1134 -0
  47. forge/feature_python_tools.py +81 -0
  48. forge/feature_remove.py +189 -0
  49. forge/feature_schema.py +156 -0
  50. forge/feature_tests.py +1062 -0
  51. forge/fullrun.py +166 -0
  52. forge/gaps.py +109 -0
  53. forge/githooks.py +251 -0
  54. forge/github.py +191 -0
  55. forge/init.py +494 -0
  56. forge/intake.py +226 -0
  57. forge/journey.py +126 -0
  58. forge/known_issues.py +165 -0
  59. forge/land.py +882 -0
  60. forge/machine.py +821 -0
  61. forge/merge.py +530 -0
  62. forge/merge_review.py +84 -0
  63. forge/merge_timings.py +46 -0
  64. forge/migrate.py +673 -0
  65. forge/migration_warnings.py +108 -0
  66. forge/mod/.claude-plugin/plugin.json +20 -0
  67. forge/mod/hooks/hooks.json +3 -0
  68. forge/mod/hooks/pane.test.ts +608 -0
  69. forge/mod/hooks/register.ts +413 -0
  70. forge/mod/tsconfig.json +18 -0
  71. forge/native.py +306 -0
  72. forge/nextstep.py +1184 -0
  73. forge/node_workers.cjs +26 -0
  74. forge/noise.py +40 -0
  75. forge/open_decisions.py +205 -0
  76. forge/owner_choices.py +167 -0
  77. forge/payback.py +97 -0
  78. forge/plain_english.py +20 -0
  79. forge/plan_scope.py +76 -0
  80. forge/prcheck.py +640 -0
  81. forge/quicktest.py +198 -0
  82. forge/records.py +912 -0
  83. forge/releases.py +100 -0
  84. forge/repo.py +1154 -0
  85. forge/review.py +1199 -0
  86. forge/review_process.py +86 -0
  87. forge/review_skip.py +116 -0
  88. forge/roles.py +141 -0
  89. forge/round_limits.py +7 -0
  90. forge/score.py +192 -0
  91. forge/spotted.py +271 -0
  92. forge/standards.md +318 -0
  93. forge/story.py +1200 -0
  94. forge/sync.py +783 -0
  95. forge/task.py +1082 -0
  96. forge/templates/adapters/AGENTS.md +98 -0
  97. forge/templates/brief.md +834 -0
  98. forge/templates/cold-read.md +324 -0
  99. forge/templates/conventions/api.md +144 -0
  100. forge/templates/conventions/backend.md +171 -0
  101. forge/templates/conventions/database.md +81 -0
  102. forge/templates/conventions/demo-data.md +61 -0
  103. forge/templates/conventions/deploy.md +114 -0
  104. forge/templates/conventions/frontend.md +187 -0
  105. forge/templates/conventions/python.md +336 -0
  106. forge/templates/conventions/security.md +44 -0
  107. forge/templates/conventions/stack.md +96 -0
  108. forge/templates/conventions/testing.md +165 -0
  109. forge/templates/delegation.md +3 -0
  110. forge/templates/design/render-check.d.mts +25 -0
  111. forge/templates/design/render-check.mjs +113 -0
  112. forge/templates/design/support.js +159 -0
  113. forge/templates/design/ui-checks.js +111 -0
  114. forge/templates/fde.md +218 -0
  115. forge/templates/feature/kinds.toml +140 -0
  116. forge/templates/handover.md +26 -0
  117. forge/templates/migrate-skill.md +87 -0
  118. forge/templates/records-only-action.yml +16 -0
  119. forge/templates/review-light.md +48 -0
  120. forge/templates/review-tests.py +200 -0
  121. forge/templates/review.md +661 -0
  122. forge/templates/run-reference.md +328 -0
  123. forge/templates/skeleton/.dockerignore +18 -0
  124. forge/templates/skeleton/Dockerfile +10 -0
  125. forge/templates/skeleton/docs/decisions/README.md +13 -0
  126. forge/templates/skeleton/docs/product/BRIEF.md +47 -0
  127. forge/templates/skeleton/docs/product/DISCOVERY.md +46 -0
  128. forge/templates/skeleton/docs/specs/README.md +41 -0
  129. forge/templates/skeleton/services.toml +6 -0
  130. forge/templates/skill.md +2753 -0
  131. forge/templates/skills/agents/SKILL.md +446 -0
  132. forge/templates/skills/agents/assistant-module/python/apps/api/app/assistant/README.md +131 -0
  133. forge/templates/skills/agents/assistant-module/python/apps/api/app/assistant/__init__.py +5 -0
  134. forge/templates/skills/agents/assistant-module/python/apps/api/app/assistant/chats.py +60 -0
  135. forge/templates/skills/agents/assistant-module/python/apps/api/app/assistant/cleanup.py +91 -0
  136. forge/templates/skills/agents/assistant-module/python/apps/api/app/assistant/models.py +57 -0
  137. forge/templates/skills/agents/assistant-module/python/apps/api/migrations/versions/20261106_assistant.py +90 -0
  138. forge/templates/skills/agents/assistant-module/python/apps/api/tests/test_assistant_chats.py +173 -0
  139. forge/templates/skills/agents/assistant-module/typescript/apps/api/prisma/migrations/20261106000000_assistant/migration.sql +17 -0
  140. forge/templates/skills/agents/assistant-module/typescript/apps/api/prisma/schema/assistant.prisma +19 -0
  141. forge/templates/skills/agents/assistant-module/typescript/apps/api/test/assistant-api.e2e-spec.ts +185 -0
  142. forge/templates/skills/agents/assistant-module/typescript/apps/api/test/assistant-chats.e2e-spec.ts +75 -0
  143. forge/templates/skills/agents/assistant-module/typescript/libs/assistant/README.md +107 -0
  144. forge/templates/skills/agents/assistant-module/typescript/libs/assistant/contracts/package.json +10 -0
  145. forge/templates/skills/agents/assistant-module/typescript/libs/assistant/contracts/src/index.ts +66 -0
  146. forge/templates/skills/agents/assistant-module/typescript/libs/assistant/contracts/tsconfig.json +12 -0
  147. forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/package.json +23 -0
  148. forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/src/assistant.chats.controller.ts +54 -0
  149. forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/src/assistant.chats.service.ts +140 -0
  150. forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/src/assistant.cleanup.ts +34 -0
  151. forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/src/assistant.module.ts +20 -0
  152. forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/src/index.ts +3 -0
  153. forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/tsconfig.json +15 -0
  154. forge/templates/skills/app-baseline/SKILL.md +241 -0
  155. forge/templates/skills/database/SKILL.md +155 -0
  156. forge/templates/skills/emil-design-eng/FORGE-NOTICE.md +9 -0
  157. forge/templates/skills/emil-design-eng/LICENSE +21 -0
  158. forge/templates/skills/emil-design-eng/SKILL.md +674 -0
  159. forge/templates/skills/impeccable/FORGE-NOTICE.md +10 -0
  160. forge/templates/skills/impeccable/LICENSE +191 -0
  161. forge/templates/skills/impeccable/NOTICE.md +11 -0
  162. forge/templates/skills/impeccable/SKILL.md +88 -0
  163. forge/templates/skills/impeccable/reference/adapt.md +318 -0
  164. forge/templates/skills/impeccable/reference/adapt.native.md +58 -0
  165. forge/templates/skills/impeccable/reference/android.md +46 -0
  166. forge/templates/skills/impeccable/reference/animate.md +89 -0
  167. forge/templates/skills/impeccable/reference/audit.md +139 -0
  168. forge/templates/skills/impeccable/reference/audit.native.md +139 -0
  169. forge/templates/skills/impeccable/reference/bolder.md +33 -0
  170. forge/templates/skills/impeccable/reference/clarify.md +94 -0
  171. forge/templates/skills/impeccable/reference/colorize.md +86 -0
  172. forge/templates/skills/impeccable/reference/component-review.md +63 -0
  173. forge/templates/skills/impeccable/reference/craft-floor.md +44 -0
  174. forge/templates/skills/impeccable/reference/craft.md +5 -0
  175. forge/templates/skills/impeccable/reference/critique.md +819 -0
  176. forge/templates/skills/impeccable/reference/degraded/asset-producer.md +42 -0
  177. forge/templates/skills/impeccable/reference/degraded/documenter.md +24 -0
  178. forge/templates/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
  179. forge/templates/skills/impeccable/reference/degraded/manual-edit-applier.md +92 -0
  180. forge/templates/skills/impeccable/reference/delight.md +70 -0
  181. forge/templates/skills/impeccable/reference/distill.md +111 -0
  182. forge/templates/skills/impeccable/reference/doctor.md +54 -0
  183. forge/templates/skills/impeccable/reference/document.md +416 -0
  184. forge/templates/skills/impeccable/reference/extract.md +69 -0
  185. forge/templates/skills/impeccable/reference/generate.md +101 -0
  186. forge/templates/skills/impeccable/reference/harden.md +362 -0
  187. forge/templates/skills/impeccable/reference/hooks.md +114 -0
  188. forge/templates/skills/impeccable/reference/init.md +131 -0
  189. forge/templates/skills/impeccable/reference/ios.md +51 -0
  190. forge/templates/skills/impeccable/reference/layout.md +84 -0
  191. forge/templates/skills/impeccable/reference/live-setup.md +104 -0
  192. forge/templates/skills/impeccable/reference/live.md +325 -0
  193. forge/templates/skills/impeccable/reference/mode-operate.md +21 -0
  194. forge/templates/skills/impeccable/reference/mode-persuade.md +19 -0
  195. forge/templates/skills/impeccable/reference/mode-read.md +21 -0
  196. forge/templates/skills/impeccable/reference/new-work.md +154 -0
  197. forge/templates/skills/impeccable/reference/onboard.md +234 -0
  198. forge/templates/skills/impeccable/reference/operate.md +61 -0
  199. forge/templates/skills/impeccable/reference/optimize.md +257 -0
  200. forge/templates/skills/impeccable/reference/overdrive.md +127 -0
  201. forge/templates/skills/impeccable/reference/polish.md +105 -0
  202. forge/templates/skills/impeccable/reference/quieter.md +99 -0
  203. forge/templates/skills/impeccable/reference/region-map.md +26 -0
  204. forge/templates/skills/impeccable/reference/routing.md +24 -0
  205. forge/templates/skills/impeccable/reference/shape.md +59 -0
  206. forge/templates/skills/impeccable/reference/typeset.md +90 -0
  207. forge/templates/skills/impeccable/reference/visualize.md +47 -0
  208. forge/templates/skills/impeccable/scripts/VERSION +1 -0
  209. forge/templates/skills/impeccable/scripts/command-metadata.json +98 -0
  210. forge/templates/skills/impeccable/scripts/data/font-index-failures.json +121 -0
  211. forge/templates/skills/impeccable/scripts/data/font-index.json +1 -0
  212. forge/templates/skills/impeccable/scripts/engine-checksums.txt +9 -0
  213. forge/templates/skills/impeccable/scripts/impeccable +249 -0
  214. forge/templates/skills/impeccable/scripts/impeccable.cmd +278 -0
  215. forge/templates/skills/impeccable/scripts/live-browser-dom.js +321 -0
  216. forge/templates/skills/impeccable/scripts/live-browser-ignores.js +247 -0
  217. forge/templates/skills/impeccable/scripts/live-browser-session.js +184 -0
  218. forge/templates/skills/impeccable/scripts/live-browser.js +13646 -0
  219. forge/templates/skills/impeccable/scripts/modern-screenshot.umd.js +15 -0
  220. forge/templates/skills/remote-approval/SKILL.md +40 -0
  221. forge/templates/skills/security-audit/AI-AND-LLM.md +83 -0
  222. forge/templates/skills/security-audit/ATTACK-CLASSES.md +130 -0
  223. forge/templates/skills/security-audit/CLIENT-SIDE.md +83 -0
  224. forge/templates/skills/security-audit/CLOUD-AND-DEPLOYMENT.md +86 -0
  225. forge/templates/skills/security-audit/DATA-ISOLATION-AND-LIFECYCLE.md +84 -0
  226. forge/templates/skills/security-audit/DESKTOP-MOBILE-AND-LOCAL-IPC.md +89 -0
  227. forge/templates/skills/security-audit/HUNTING.md +251 -0
  228. forge/templates/skills/security-audit/LICENSE +21 -0
  229. forge/templates/skills/security-audit/MEMORY-SAFETY-AND-BINARY.md +101 -0
  230. forge/templates/skills/security-audit/NOTICE.md +6 -0
  231. forge/templates/skills/security-audit/PROTOCOLS-RPC-AND-MESSAGING.md +81 -0
  232. forge/templates/skills/security-audit/RECONNAISSANCE.md +156 -0
  233. forge/templates/skills/security-audit/RESOURCE-EXHAUSTION-AND-AVAILABILITY.md +78 -0
  234. forge/templates/skills/security-audit/SKILL.md +192 -0
  235. forge/templates/skills/security-audit/SUPPLY-CHAIN-AND-RELEASE.md +73 -0
  236. forge/templates/skills/security-audit/VALIDATION-AND-REPORTING.md +186 -0
  237. forge/templates/skills/security-audit/WEB-PROTOCOL-AND-AUTH.md +105 -0
  238. forge/templates/skills/security-audit/report-schema.json +461 -0
  239. forge/templates/skills/security-audit/validate-coverage-ledger.cjs +873 -0
  240. forge/templates/skills/security-audit/validate-findings.cjs +774 -0
  241. forge/templates/skills/simplified-technical-english/LICENSE +28 -0
  242. forge/templates/skills/simplified-technical-english/NOTICE.md +33 -0
  243. forge/templates/skills/simplified-technical-english/SKILL.md +127 -0
  244. forge/templates/skills/simplified-technical-english/examples/before-after.md +86 -0
  245. forge/templates/skills/simplified-technical-english/references/substitutions.md +113 -0
  246. forge/templates/skills/simplified-technical-english/references/writing-rules.md +209 -0
  247. forge/templates/skills/simplified-technical-english/scripts/ste_check.py +301 -0
  248. forge/templates/skills/test-audit/NOTICE.md +25 -0
  249. forge/templates/skills/test-audit/SKILL.md +182 -0
  250. forge/templates/start.md +27 -0
  251. forge/templates/starter/.env.example +14 -0
  252. forge/templates/starter/.gitignore +7 -0
  253. forge/templates/starter/.npmrc +1 -0
  254. forge/templates/starter/Dockerfile +23 -0
  255. forge/templates/starter/README.md +121 -0
  256. forge/templates/starter/apps/api/package.json +15 -0
  257. forge/templates/starter/apps/api/prisma/migrations/20261022000000_initial/migration.sql +68 -0
  258. forge/templates/starter/apps/api/prisma/migrations/20261025000000_organisations/migration.sql +44 -0
  259. forge/templates/starter/apps/api/prisma/migrations/20261025000100_invites/migration.sql +18 -0
  260. forge/templates/starter/apps/api/prisma/migrations/20261025000200_history/migration.sql +13 -0
  261. forge/templates/starter/apps/api/prisma/migrations/20261025000300_soft_delete_only/migration.sql +10 -0
  262. forge/templates/starter/apps/api/prisma/migrations/20261026000000_extensions/migration.sql +3 -0
  263. forge/templates/starter/apps/api/prisma/migrations/20261026000100_ids_and_updated_at/migration.sql +31 -0
  264. forge/templates/starter/apps/api/prisma/migrations/20261026000150_module_schemas/migration.sql +19 -0
  265. forge/templates/starter/apps/api/prisma/migrations/20261026000200_columns/migration.sql +51 -0
  266. forge/templates/starter/apps/api/prisma/migrations/20261026000300_history_subjects/migration.sql +11 -0
  267. forge/templates/starter/apps/api/prisma/migrations/20261027000000_agents/migration.sql +12 -0
  268. forge/templates/starter/apps/api/prisma/migrations/20261027000100_mcp/migration.sql +20 -0
  269. forge/templates/starter/apps/api/prisma/migrations/20261028000000_via_agent/migration.sql +7 -0
  270. forge/templates/starter/apps/api/prisma/migrations/20261102000000_sign_in_attempts/migration.sql +13 -0
  271. forge/templates/starter/apps/api/prisma/migrations/20261104000000_notifications/migration.sql +23 -0
  272. forge/templates/starter/apps/api/prisma/migrations/migration_lock.toml +1 -0
  273. forge/templates/starter/apps/api/prisma/schema/auth.prisma +65 -0
  274. forge/templates/starter/apps/api/prisma/schema/base.prisma +9 -0
  275. forge/templates/starter/apps/api/prisma/schema/history.prisma +19 -0
  276. forge/templates/starter/apps/api/prisma/schema/mcp.prisma +18 -0
  277. forge/templates/starter/apps/api/prisma/schema/notifications.prisma +20 -0
  278. forge/templates/starter/apps/api/prisma/schema/organisations.prisma +66 -0
  279. forge/templates/starter/apps/api/prisma/schema/projects.prisma +23 -0
  280. forge/templates/starter/apps/api/project.json +35 -0
  281. forge/templates/starter/apps/api/src/app.module.ts +36 -0
  282. forge/templates/starter/apps/api/src/health/health.controller.ts +16 -0
  283. forge/templates/starter/apps/api/src/health/health.module.ts +5 -0
  284. forge/templates/starter/apps/api/src/main.ts +44 -0
  285. forge/templates/starter/apps/api/src/setup-company.ts +33 -0
  286. forge/templates/starter/apps/api/test/agents.e2e-spec.ts +99 -0
  287. forge/templates/starter/apps/api/test/api.e2e-spec.ts +250 -0
  288. forge/templates/starter/apps/api/test/auth.e2e-spec.ts +287 -0
  289. forge/templates/starter/apps/api/test/database.e2e-spec.ts +171 -0
  290. forge/templates/starter/apps/api/test/environment.e2e-spec.ts +56 -0
  291. forge/templates/starter/apps/api/test/error-reports.e2e-spec.ts +72 -0
  292. forge/templates/starter/apps/api/test/exports.e2e-spec.ts +85 -0
  293. forge/templates/starter/apps/api/test/helpers.ts +103 -0
  294. forge/templates/starter/apps/api/test/history.e2e-spec.ts +93 -0
  295. forge/templates/starter/apps/api/test/invites.e2e-spec.ts +262 -0
  296. forge/templates/starter/apps/api/test/mcp.e2e-spec.ts +269 -0
  297. forge/templates/starter/apps/api/test/notifications.e2e-spec.ts +117 -0
  298. forge/templates/starter/apps/api/test/one-company.e2e-spec.ts +154 -0
  299. forge/templates/starter/apps/api/test/organisations.e2e-spec.ts +210 -0
  300. forge/templates/starter/apps/api/test/projects.e2e-spec.ts +824 -0
  301. forge/templates/starter/apps/api/test/soft-delete.e2e-spec.ts +31 -0
  302. forge/templates/starter/apps/api/tsconfig.json +44 -0
  303. forge/templates/starter/apps/api/tsconfig.test.json +17 -0
  304. forge/templates/starter/apps/api/vitest.config.ts +13 -0
  305. forge/templates/starter/apps/web/e2e/motion.spec.ts +88 -0
  306. forge/templates/starter/apps/web/e2e/rules/accept-invite.spec.ts +59 -0
  307. forge/templates/starter/apps/web/e2e/rules/members.spec.ts +212 -0
  308. forge/templates/starter/apps/web/e2e/rules/reset-password.spec.ts +78 -0
  309. forge/templates/starter/apps/web/e2e/rules/sign-in.spec.ts +87 -0
  310. forge/templates/starter/apps/web/e2e/served-app.spec.ts +19 -0
  311. forge/templates/starter/apps/web/index.html +14 -0
  312. forge/templates/starter/apps/web/package.json +9 -0
  313. forge/templates/starter/apps/web/playwright.config.ts +21 -0
  314. forge/templates/starter/apps/web/project.json +36 -0
  315. forge/templates/starter/apps/web/src/index.css +166 -0
  316. forge/templates/starter/apps/web/src/main.tsx +14 -0
  317. forge/templates/starter/apps/web/src/shared-states.test.tsx +40 -0
  318. forge/templates/starter/apps/web/tsconfig.json +30 -0
  319. forge/templates/starter/apps/web/vite.config.ts +19 -0
  320. forge/templates/starter/apps/web/vitest.config.ts +23 -0
  321. forge/templates/starter/apps/web/vitest.setup.ts +5 -0
  322. forge/templates/starter/compose.test.yml +66 -0
  323. forge/templates/starter/eslint.config.mjs +56 -0
  324. forge/templates/starter/libs/auth/contracts/package.json +17 -0
  325. forge/templates/starter/libs/auth/contracts/project.json +15 -0
  326. forge/templates/starter/libs/auth/contracts/src/index.ts +56 -0
  327. forge/templates/starter/libs/auth/contracts/tsconfig.json +18 -0
  328. forge/templates/starter/libs/auth/server/package.json +19 -0
  329. forge/templates/starter/libs/auth/server/project.json +15 -0
  330. forge/templates/starter/libs/auth/server/src/agents.controller.ts +24 -0
  331. forge/templates/starter/libs/auth/server/src/auth.controller.ts +136 -0
  332. forge/templates/starter/libs/auth/server/src/auth.dto.ts +53 -0
  333. forge/templates/starter/libs/auth/server/src/auth.module.ts +18 -0
  334. forge/templates/starter/libs/auth/server/src/auth.service.ts +251 -0
  335. forge/templates/starter/libs/auth/server/src/index.ts +3 -0
  336. forge/templates/starter/libs/auth/server/src/invites.controller.ts +37 -0
  337. forge/templates/starter/libs/auth/server/src/members.controller.ts +47 -0
  338. forge/templates/starter/libs/auth/server/src/session.guard.ts +52 -0
  339. forge/templates/starter/libs/auth/server/tsconfig.json +29 -0
  340. forge/templates/starter/libs/core/server/package.json +17 -0
  341. forge/templates/starter/libs/core/server/project.json +19 -0
  342. forge/templates/starter/libs/core/server/src/common/account-principal.ts +8 -0
  343. forge/templates/starter/libs/core/server/src/common/admin-only.decorator.ts +18 -0
  344. forge/templates/starter/libs/core/server/src/common/all-exceptions.filter.ts +55 -0
  345. forge/templates/starter/libs/core/server/src/common/api-envelope.decorator.ts +28 -0
  346. forge/templates/starter/libs/core/server/src/common/api-response.dto.ts +26 -0
  347. forge/templates/starter/libs/core/server/src/common/api-zod.decorator.ts +21 -0
  348. forge/templates/starter/libs/core/server/src/common/authenticated-request.ts +7 -0
  349. forge/templates/starter/libs/core/server/src/common/common.module.ts +7 -0
  350. forge/templates/starter/libs/core/server/src/common/correlation.middleware.ts +12 -0
  351. forge/templates/starter/libs/core/server/src/common/csrf.guard.ts +35 -0
  352. forge/templates/starter/libs/core/server/src/common/csv.ts +14 -0
  353. forge/templates/starter/libs/core/server/src/common/current-account.decorator.ts +11 -0
  354. forge/templates/starter/libs/core/server/src/common/envelope.interceptor.ts +10 -0
  355. forge/templates/starter/libs/core/server/src/common/error-report.ts +43 -0
  356. forge/templates/starter/libs/core/server/src/common/json-logger.test.ts +95 -0
  357. forge/templates/starter/libs/core/server/src/common/json-logger.ts +57 -0
  358. forge/templates/starter/libs/core/server/src/common/permissions.ts +49 -0
  359. forge/templates/starter/libs/core/server/src/common/prompts.ts +42 -0
  360. forge/templates/starter/libs/core/server/src/common/public.decorator.ts +4 -0
  361. forge/templates/starter/libs/core/server/src/common/request-log.middleware.ts +19 -0
  362. forge/templates/starter/libs/core/server/src/common/resources.ts +88 -0
  363. forge/templates/starter/libs/core/server/src/common/retry-keys.ts +31 -0
  364. forge/templates/starter/libs/core/server/src/common/tools.test.ts +205 -0
  365. forge/templates/starter/libs/core/server/src/common/tools.ts +266 -0
  366. forge/templates/starter/libs/core/server/src/common/zod-validation.pipe.ts +22 -0
  367. forge/templates/starter/libs/core/server/src/config/environment.ts +95 -0
  368. forge/templates/starter/libs/core/server/src/index.ts +27 -0
  369. forge/templates/starter/libs/core/server/src/mail/mail.module.ts +19 -0
  370. forge/templates/starter/libs/core/server/src/mail/mail.provider.ts +22 -0
  371. forge/templates/starter/libs/core/server/src/prisma/prisma.module.ts +7 -0
  372. forge/templates/starter/libs/core/server/src/prisma/prisma.service.ts +19 -0
  373. forge/templates/starter/libs/core/server/tsconfig.json +23 -0
  374. forge/templates/starter/libs/core/web/package.json +16 -0
  375. forge/templates/starter/libs/core/web/project.json +15 -0
  376. forge/templates/starter/libs/core/web/src/api-client.ts +42 -0
  377. forge/templates/starter/libs/core/web/src/error-report.ts +12 -0
  378. forge/templates/starter/libs/core/web/src/form-errors.ts +18 -0
  379. forge/templates/starter/libs/core/web/src/index.ts +4 -0
  380. forge/templates/starter/libs/core/web/src/permissions.ts +9 -0
  381. forge/templates/starter/libs/core/web/src/query-client.ts +10 -0
  382. forge/templates/starter/libs/core/web/tsconfig.json +18 -0
  383. forge/templates/starter/libs/history/contracts/package.json +14 -0
  384. forge/templates/starter/libs/history/contracts/project.json +15 -0
  385. forge/templates/starter/libs/history/contracts/src/index.ts +2 -0
  386. forge/templates/starter/libs/history/contracts/src/service.ts +21 -0
  387. forge/templates/starter/libs/history/contracts/tsconfig.json +14 -0
  388. forge/templates/starter/libs/history/server/package.json +19 -0
  389. forge/templates/starter/libs/history/server/project.json +19 -0
  390. forge/templates/starter/libs/history/server/src/history.controller.ts +45 -0
  391. forge/templates/starter/libs/history/server/src/history.dto.ts +22 -0
  392. forge/templates/starter/libs/history/server/src/history.module.ts +12 -0
  393. forge/templates/starter/libs/history/server/src/history.service.test.ts +18 -0
  394. forge/templates/starter/libs/history/server/src/history.service.ts +42 -0
  395. forge/templates/starter/libs/history/server/src/index.ts +2 -0
  396. forge/templates/starter/libs/history/server/tsconfig.json +29 -0
  397. forge/templates/starter/libs/mcp/server/package.json +18 -0
  398. forge/templates/starter/libs/mcp/server/project.json +15 -0
  399. forge/templates/starter/libs/mcp/server/src/index.ts +1 -0
  400. forge/templates/starter/libs/mcp/server/src/mcp.controller.ts +102 -0
  401. forge/templates/starter/libs/mcp/server/src/mcp.module.ts +5 -0
  402. forge/templates/starter/libs/mcp/server/tsconfig.json +26 -0
  403. forge/templates/starter/libs/notifications/contracts/package.json +14 -0
  404. forge/templates/starter/libs/notifications/contracts/project.json +12 -0
  405. forge/templates/starter/libs/notifications/contracts/src/index.ts +1 -0
  406. forge/templates/starter/libs/notifications/contracts/src/service.ts +19 -0
  407. forge/templates/starter/libs/notifications/contracts/tsconfig.json +12 -0
  408. forge/templates/starter/libs/notifications/server/package.json +18 -0
  409. forge/templates/starter/libs/notifications/server/project.json +12 -0
  410. forge/templates/starter/libs/notifications/server/src/index.ts +1 -0
  411. forge/templates/starter/libs/notifications/server/src/notifications.controller.ts +21 -0
  412. forge/templates/starter/libs/notifications/server/src/notifications.dto.ts +28 -0
  413. forge/templates/starter/libs/notifications/server/src/notifications.module.ts +12 -0
  414. forge/templates/starter/libs/notifications/server/src/notifications.service.ts +36 -0
  415. forge/templates/starter/libs/notifications/server/tsconfig.json +18 -0
  416. forge/templates/starter/libs/organisations/contracts/package.json +14 -0
  417. forge/templates/starter/libs/organisations/contracts/project.json +15 -0
  418. forge/templates/starter/libs/organisations/contracts/src/index.ts +54 -0
  419. forge/templates/starter/libs/organisations/contracts/src/service.ts +29 -0
  420. forge/templates/starter/libs/organisations/contracts/tsconfig.json +14 -0
  421. forge/templates/starter/libs/organisations/server/package.json +20 -0
  422. forge/templates/starter/libs/organisations/server/project.json +15 -0
  423. forge/templates/starter/libs/organisations/server/src/index.ts +2 -0
  424. forge/templates/starter/libs/organisations/server/src/organisations.controller.ts +101 -0
  425. forge/templates/starter/libs/organisations/server/src/organisations.dto.ts +46 -0
  426. forge/templates/starter/libs/organisations/server/src/organisations.module.ts +14 -0
  427. forge/templates/starter/libs/organisations/server/src/organisations.service.ts +221 -0
  428. forge/templates/starter/libs/organisations/server/tsconfig.json +32 -0
  429. forge/templates/starter/libs/projects/contracts/package.json +14 -0
  430. forge/templates/starter/libs/projects/contracts/project.json +15 -0
  431. forge/templates/starter/libs/projects/contracts/src/index.ts +87 -0
  432. forge/templates/starter/libs/projects/contracts/tsconfig.json +14 -0
  433. forge/templates/starter/libs/projects/server/package.json +21 -0
  434. forge/templates/starter/libs/projects/server/project.json +15 -0
  435. forge/templates/starter/libs/projects/server/src/index.ts +2 -0
  436. forge/templates/starter/libs/projects/server/src/projects.controller.ts +165 -0
  437. forge/templates/starter/libs/projects/server/src/projects.dto.ts +77 -0
  438. forge/templates/starter/libs/projects/server/src/projects.module.ts +19 -0
  439. forge/templates/starter/libs/projects/server/src/projects.permissions.ts +7 -0
  440. forge/templates/starter/libs/projects/server/src/projects.service.ts +314 -0
  441. forge/templates/starter/libs/projects/server/src/projects.tools.ts +28 -0
  442. forge/templates/starter/libs/projects/server/tsconfig.json +29 -0
  443. forge/templates/starter/libs/shared/ui/components.json +21 -0
  444. forge/templates/starter/libs/shared/ui/package.json +27 -0
  445. forge/templates/starter/libs/shared/ui/project.json +15 -0
  446. forge/templates/starter/libs/shared/ui/src/components/states.tsx +73 -0
  447. forge/templates/starter/libs/shared/ui/src/components/theme-provider.tsx +39 -0
  448. forge/templates/starter/libs/shared/ui/src/components/ui/LICENSE +21 -0
  449. forge/templates/starter/libs/shared/ui/src/components/ui/alert-dialog.tsx +196 -0
  450. forge/templates/starter/libs/shared/ui/src/components/ui/alert.tsx +65 -0
  451. forge/templates/starter/libs/shared/ui/src/components/ui/avatar.tsx +108 -0
  452. forge/templates/starter/libs/shared/ui/src/components/ui/badge.tsx +47 -0
  453. forge/templates/starter/libs/shared/ui/src/components/ui/breadcrumb.tsx +108 -0
  454. forge/templates/starter/libs/shared/ui/src/components/ui/button.tsx +63 -0
  455. forge/templates/starter/libs/shared/ui/src/components/ui/card.tsx +91 -0
  456. forge/templates/starter/libs/shared/ui/src/components/ui/checkbox.tsx +29 -0
  457. forge/templates/starter/libs/shared/ui/src/components/ui/collapsible.tsx +33 -0
  458. forge/templates/starter/libs/shared/ui/src/components/ui/command.tsx +184 -0
  459. forge/templates/starter/libs/shared/ui/src/components/ui/dialog.tsx +158 -0
  460. forge/templates/starter/libs/shared/ui/src/components/ui/dropdown-menu.tsx +256 -0
  461. forge/templates/starter/libs/shared/ui/src/components/ui/empty.tsx +103 -0
  462. forge/templates/starter/libs/shared/ui/src/components/ui/form.tsx +167 -0
  463. forge/templates/starter/libs/shared/ui/src/components/ui/input.tsx +20 -0
  464. forge/templates/starter/libs/shared/ui/src/components/ui/label.tsx +23 -0
  465. forge/templates/starter/libs/shared/ui/src/components/ui/popover.tsx +88 -0
  466. forge/templates/starter/libs/shared/ui/src/components/ui/select.tsx +189 -0
  467. forge/templates/starter/libs/shared/ui/src/components/ui/separator.tsx +27 -0
  468. forge/templates/starter/libs/shared/ui/src/components/ui/sheet.tsx +142 -0
  469. forge/templates/starter/libs/shared/ui/src/components/ui/sidebar.tsx +726 -0
  470. forge/templates/starter/libs/shared/ui/src/components/ui/skeleton.tsx +13 -0
  471. forge/templates/starter/libs/shared/ui/src/components/ui/sonner.tsx +40 -0
  472. forge/templates/starter/libs/shared/ui/src/components/ui/switch.tsx +32 -0
  473. forge/templates/starter/libs/shared/ui/src/components/ui/table.tsx +115 -0
  474. forge/templates/starter/libs/shared/ui/src/components/ui/textarea.tsx +17 -0
  475. forge/templates/starter/libs/shared/ui/src/components/ui/tooltip.tsx +56 -0
  476. forge/templates/starter/libs/shared/ui/src/hooks/use-mobile.ts +19 -0
  477. forge/templates/starter/libs/shared/ui/src/lib/utils.ts +6 -0
  478. forge/templates/starter/libs/shared/ui/tsconfig.json +23 -0
  479. forge/templates/starter/libs/shared/util/package.json +14 -0
  480. forge/templates/starter/libs/shared/util/project.json +19 -0
  481. forge/templates/starter/libs/shared/util/src/csv-field.ts +6 -0
  482. forge/templates/starter/libs/shared/util/src/envelope.ts +9 -0
  483. forge/templates/starter/libs/shared/util/src/format.test.ts +33 -0
  484. forge/templates/starter/libs/shared/util/src/format.ts +43 -0
  485. forge/templates/starter/libs/shared/util/src/index.ts +12 -0
  486. forge/templates/starter/libs/shared/util/tsconfig.json +14 -0
  487. forge/templates/starter/nx.json +7 -0
  488. forge/templates/starter/package.json +97 -0
  489. forge/templates/starter/pnpm-lock.yaml +11587 -0
  490. forge/templates/starter/pnpm-workspace.yaml +4 -0
  491. forge/templates/starter/prisma.config.ts +13 -0
  492. forge/templates/starter/scripts/affected.mjs +27 -0
  493. forge/templates/starter/scripts/test-build.mjs +29 -0
  494. forge/templates/starter/scripts/test.mjs +107 -0
  495. forge/templates/starter/services.toml +7 -0
  496. forge/templates/starter/tsconfig.base.json +15 -0
  497. forge/templates/starter-python/.env.example +8 -0
  498. forge/templates/starter-python/.gitignore +13 -0
  499. forge/templates/starter-python/Dockerfile +30 -0
  500. forge/templates/starter-python/README.md +101 -0
  501. forge/templates/starter-python/apps/api/.python-version +1 -0
  502. forge/templates/starter-python/apps/api/alembic.ini +38 -0
  503. forge/templates/starter-python/apps/api/app/__init__.py +1 -0
  504. forge/templates/starter-python/apps/api/app/auth/__init__.py +27 -0
  505. forge/templates/starter-python/apps/api/app/auth/models.py +111 -0
  506. forge/templates/starter-python/apps/api/app/auth/routes.py +398 -0
  507. forge/templates/starter-python/apps/api/app/auth/schema.py +117 -0
  508. forge/templates/starter-python/apps/api/app/auth/service.py +453 -0
  509. forge/templates/starter-python/apps/api/app/core/__init__.py +89 -0
  510. forge/templates/starter-python/apps/api/app/core/admin.py +23 -0
  511. forge/templates/starter-python/apps/api/app/core/config.py +83 -0
  512. forge/templates/starter-python/apps/api/app/core/csv.py +40 -0
  513. forge/templates/starter-python/apps/api/app/core/database.py +21 -0
  514. forge/templates/starter-python/apps/api/app/core/envelope.py +40 -0
  515. forge/templates/starter-python/apps/api/app/core/error_report.py +85 -0
  516. forge/templates/starter-python/apps/api/app/core/errors.py +153 -0
  517. forge/templates/starter-python/apps/api/app/core/logging.py +66 -0
  518. forge/templates/starter-python/apps/api/app/core/mail.py +34 -0
  519. forge/templates/starter-python/apps/api/app/core/permissions.py +59 -0
  520. forge/templates/starter-python/apps/api/app/core/principal.py +12 -0
  521. forge/templates/starter-python/apps/api/app/core/prompts.py +96 -0
  522. forge/templates/starter-python/apps/api/app/core/resources.py +230 -0
  523. forge/templates/starter-python/apps/api/app/core/retry_keys.py +101 -0
  524. forge/templates/starter-python/apps/api/app/core/schema.py +13 -0
  525. forge/templates/starter-python/apps/api/app/core/security.py +197 -0
  526. forge/templates/starter-python/apps/api/app/core/tools.py +1117 -0
  527. forge/templates/starter-python/apps/api/app/history/__init__.py +5 -0
  528. forge/templates/starter-python/apps/api/app/history/models.py +48 -0
  529. forge/templates/starter-python/apps/api/app/history/routes.py +65 -0
  530. forge/templates/starter-python/apps/api/app/history/schema.py +29 -0
  531. forge/templates/starter-python/apps/api/app/history/service.py +77 -0
  532. forge/templates/starter-python/apps/api/app/main.py +115 -0
  533. forge/templates/starter-python/apps/api/app/mcp/__init__.py +3 -0
  534. forge/templates/starter-python/apps/api/app/mcp/server.py +192 -0
  535. forge/templates/starter-python/apps/api/app/notifications/__init__.py +5 -0
  536. forge/templates/starter-python/apps/api/app/notifications/models.py +62 -0
  537. forge/templates/starter-python/apps/api/app/notifications/routes.py +25 -0
  538. forge/templates/starter-python/apps/api/app/notifications/schema.py +39 -0
  539. forge/templates/starter-python/apps/api/app/notifications/service.py +70 -0
  540. forge/templates/starter-python/apps/api/app/openapi.py +17 -0
  541. forge/templates/starter-python/apps/api/app/organisations/__init__.py +10 -0
  542. forge/templates/starter-python/apps/api/app/organisations/models.py +128 -0
  543. forge/templates/starter-python/apps/api/app/organisations/routes.py +176 -0
  544. forge/templates/starter-python/apps/api/app/organisations/schema.py +76 -0
  545. forge/templates/starter-python/apps/api/app/organisations/service.py +403 -0
  546. forge/templates/starter-python/apps/api/app/projects/__init__.py +14 -0
  547. forge/templates/starter-python/apps/api/app/projects/models.py +67 -0
  548. forge/templates/starter-python/apps/api/app/projects/permissions.py +13 -0
  549. forge/templates/starter-python/apps/api/app/projects/routes.py +246 -0
  550. forge/templates/starter-python/apps/api/app/projects/schema.py +118 -0
  551. forge/templates/starter-python/apps/api/app/projects/service.py +359 -0
  552. forge/templates/starter-python/apps/api/app/projects/tools.py +28 -0
  553. forge/templates/starter-python/apps/api/app/setup_company.py +56 -0
  554. forge/templates/starter-python/apps/api/migrations/env.py +51 -0
  555. forge/templates/starter-python/apps/api/migrations/script.py.mako +25 -0
  556. forge/templates/starter-python/apps/api/migrations/versions/0001_initial.py +167 -0
  557. forge/templates/starter-python/apps/api/migrations/versions/0002_soft_delete_only.py +31 -0
  558. forge/templates/starter-python/apps/api/migrations/versions/0003_organisations.py +115 -0
  559. forge/templates/starter-python/apps/api/migrations/versions/0004_invites.py +58 -0
  560. forge/templates/starter-python/apps/api/migrations/versions/0005_history.py +51 -0
  561. forge/templates/starter-python/apps/api/migrations/versions/0006_extensions.py +22 -0
  562. forge/templates/starter-python/apps/api/migrations/versions/0007_ids_and_updated_at.py +52 -0
  563. forge/templates/starter-python/apps/api/migrations/versions/0008_module_schemas.py +42 -0
  564. forge/templates/starter-python/apps/api/migrations/versions/0009_columns.py +97 -0
  565. forge/templates/starter-python/apps/api/migrations/versions/0010_history_subjects.py +46 -0
  566. forge/templates/starter-python/apps/api/migrations/versions/0011_agents.py +44 -0
  567. forge/templates/starter-python/apps/api/migrations/versions/0012_mcp.py +71 -0
  568. forge/templates/starter-python/apps/api/migrations/versions/0013_via_agent.py +23 -0
  569. forge/templates/starter-python/apps/api/migrations/versions/20261103_sign_in_attempts.py +48 -0
  570. forge/templates/starter-python/apps/api/migrations/versions/20261105_notifications.py +84 -0
  571. forge/templates/starter-python/apps/api/pyproject.toml +86 -0
  572. forge/templates/starter-python/apps/api/tests/conftest.py +146 -0
  573. forge/templates/starter-python/apps/api/tests/test_agents.py +169 -0
  574. forge/templates/starter-python/apps/api/tests/test_api.py +319 -0
  575. forge/templates/starter-python/apps/api/tests/test_auth.py +428 -0
  576. forge/templates/starter-python/apps/api/tests/test_config.py +58 -0
  577. forge/templates/starter-python/apps/api/tests/test_database.py +204 -0
  578. forge/templates/starter-python/apps/api/tests/test_error_reports.py +119 -0
  579. forge/templates/starter-python/apps/api/tests/test_history.py +206 -0
  580. forge/templates/starter-python/apps/api/tests/test_invites.py +427 -0
  581. forge/templates/starter-python/apps/api/tests/test_logging.py +56 -0
  582. forge/templates/starter-python/apps/api/tests/test_mcp.py +556 -0
  583. forge/templates/starter-python/apps/api/tests/test_module_schemas.py +100 -0
  584. forge/templates/starter-python/apps/api/tests/test_notifications.py +182 -0
  585. forge/templates/starter-python/apps/api/tests/test_one_company.py +188 -0
  586. forge/templates/starter-python/apps/api/tests/test_organisations.py +231 -0
  587. forge/templates/starter-python/apps/api/tests/test_projects.py +874 -0
  588. forge/templates/starter-python/apps/api/tests/test_soft_delete.py +80 -0
  589. forge/templates/starter-python/apps/api/tests/test_tools.py +395 -0
  590. forge/templates/starter-python/apps/api/uv.lock +1277 -0
  591. forge/templates/starter-python/compose.test.yml +63 -0
  592. forge/templates/starter-python/eslint.config.mjs +49 -0
  593. forge/templates/starter-python/libs/auth/contracts/package.json +17 -0
  594. forge/templates/starter-python/libs/auth/contracts/src/index.ts +51 -0
  595. forge/templates/starter-python/libs/auth/contracts/tsconfig.json +16 -0
  596. forge/templates/starter-python/libs/history/contracts/package.json +17 -0
  597. forge/templates/starter-python/libs/history/contracts/src/index.ts +3 -0
  598. forge/templates/starter-python/libs/history/contracts/tsconfig.json +16 -0
  599. forge/templates/starter-python/libs/organisations/contracts/package.json +17 -0
  600. forge/templates/starter-python/libs/organisations/contracts/src/index.ts +30 -0
  601. forge/templates/starter-python/libs/organisations/contracts/tsconfig.json +16 -0
  602. forge/templates/starter-python/libs/projects/contracts/package.json +17 -0
  603. forge/templates/starter-python/libs/projects/contracts/src/index.ts +65 -0
  604. forge/templates/starter-python/libs/projects/contracts/tsconfig.json +16 -0
  605. forge/templates/starter-python/libs/shared/api-types/package.json +14 -0
  606. forge/templates/starter-python/libs/shared/api-types/tsconfig.json +14 -0
  607. forge/templates/starter-python/package.json +71 -0
  608. forge/templates/starter-python/pnpm-lock.yaml +7574 -0
  609. forge/templates/starter-python/pnpm-workspace.yaml +4 -0
  610. forge/templates/starter-python/scripts/affected.mjs +20 -0
  611. forge/templates/starter-python/scripts/test-browser.mjs +39 -0
  612. forge/templates/starter-python/scripts/test.mjs +86 -0
  613. forge/templates/starter-python/services.toml +7 -0
  614. forge/templates/story.md +89 -0
  615. forge/time_records.py +1022 -0
  616. forge/ui_checks.py +97 -0
  617. forge/upgrade.py +368 -0
  618. forge/worker.py +876 -0
  619. symphony_forge-1.2.44.dist-info/METADATA +7 -0
  620. symphony_forge-1.2.44.dist-info/RECORD +623 -0
  621. symphony_forge-1.2.44.dist-info/WHEEL +4 -0
  622. symphony_forge-1.2.44.dist-info/entry_points.txt +2 -0
  623. symphony_forge-1.2.44.dist-info/licenses/LICENSE +21 -0
forge/init.py ADDED
@@ -0,0 +1,494 @@
1
+ """forge init: set up a new repo in one first commit, or adopt a repo with history on a fix branch."""
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ import json
6
+ import re
7
+ import shlex
8
+ import shutil
9
+ import subprocess
10
+ from pathlib import Path
11
+ from typing import Any, NoReturn
12
+
13
+ from forge import __version__, githooks, repo, story, sync
14
+
15
+ COMMANDS = [{
16
+ # False: init checks the pin itself, after adoption lists a forge.toml Forge didn't write.
17
+ "words": "init", "run": "init", "changes_state": False,
18
+ "help": "Set up a new repo: forge.toml, the docs skeleton, the first commit, then sync",
19
+ "args": [(("--starter",), {"nargs": "?", "const": "react", "choices": ["react", "python"],
20
+ "help": "start a new app from a starter: react (the default) or python (a FastAPI backend)"}),
21
+ (("--actions",), {"choices": ["yes", "no"],
22
+ "help": "whether this repo runs GitHub Actions"}),
23
+ (("--test",), {"help": "a repo with history: its test command"}),
24
+ (("--runner",), {"default": "ubuntu-24.04",
25
+ "help": "GitHub Actions runner label (default: ubuntu-24.04)"}),
26
+ (("--checks",), {"action": "append", "metavar": "CHECK",
27
+ "help": "a repo with history: a check branch protection requires"}),
28
+ (("--interfaces",), {"action": "append", "metavar": "GLOB",
29
+ "help": "a repo with history: its route or migration folders"}),
30
+ (("--approver",), {"help": "a repo with history: who approves stories"}),
31
+ (("--merger",), {"help": "a repo with history: who merges pull requests"}),
32
+ (("--never-touch",), {"action": "append", "metavar": "PATH",
33
+ "help": "a repo with history: a path agents never change"})],
34
+ "position": 10,
35
+ "listing": "| `forge init` | Sets up a new repo: `forge.toml`, the docs skeleton, the first commit, then `forge sync` |",
36
+ }]
37
+
38
+ REFUSALS = {
39
+ "identity": ("Git cannot use your name or email to make a commit. No files were written.",
40
+ 'git config user.name "Your Name", then git config user.email "you@example.com", '
41
+ 'then run forge init again'),
42
+ "starter_history": ("This repo already has commits, so forge init --starter cannot set it up.",
43
+ "use a new repo for the starter"),
44
+ "starter_app": ("forge init --starter found an existing app file: {path}.",
45
+ "use a new folder for the starter, or forge init to keep this app"),
46
+ "actions": ("Forge needs to know: Does this repo run GitHub Actions? Check "
47
+ "gh api repos/{owner}/{repo}/actions/permissions (enabled), then choose "
48
+ "--actions yes or --actions no.", "forge init --actions yes|no"),
49
+ "answers": ("This repo already has commits, so forge init adopts it on a fix branch, and it "
50
+ "needs the answers you confirmed: {missing}.",
51
+ 'forge init --actions yes|no --test "<command>" --checks <check> --interfaces "<glob>" '
52
+ '--approver "<who>" --merger "<who>" --never-touch "<path>"'),
53
+ "not_current": ("This checkout isn't clean at {ref}, which forge init adopts, so it can't check "
54
+ "that tree here.", "commit or set aside your changes, git switch {default} && "
55
+ "git pull, then forge init again"),
56
+ "adopting": ("fix/adopt-forge is already there, so Forge has started adopting this repo.",
57
+ "forge close adopt-forge"),
58
+ "taken": ("forge init won't write over files that Forge didn't write: {paths}.",
59
+ "move or rename those files, then forge init again"),
60
+ "no_origin": ("This repo has no origin remote, so Forge can't push the first commit or protect "
61
+ "the default branch.", "gh repo create <name> --private --source . --remote origin"),
62
+ "origin_repo": ("Forge cannot identify a GitHub repository from origin.", "git remote set-url origin <GitHub repository URL>"),
63
+ "protect": ("Branch protection on {branch} was not set: {problem}.", "{command}"),
64
+ }
65
+
66
+ # Interface paths for the fix lane: API routes, the database schema and migrations, a CLI
67
+ # command table and the config schema.
68
+ INTERFACES = ["**/routes/**", "**/*.controller.*", "**/migrations/**", "**/schema.*",
69
+ "**/*.schema.*", "**/cli.*"]
70
+ # ponytail: the stack is read from one marker file; add a row when a client brings another stack.
71
+ # Go needs -v to print a skipped test and its reason, which forge close shows the reviewer.
72
+ STACKS = [("pyproject.toml", "uv run pytest"), ("go.mod", "go test -v ./...")]
73
+ # Otherwise the smallest client stack (Node). Before the first story adds the app there is
74
+ # nothing to test, and the tests check passes; after that it runs the app's tests.
75
+ NODE_TEST = "[ ! -f package.json ] || (npm ci && npm test)"
76
+ # Implementation, cold-read and review models for each host.
77
+ MODELS = """
78
+ [models.build.codex]
79
+ model = "gpt-6.1-sol"
80
+ effort = "low"
81
+
82
+ [models.build.claude]
83
+ model = "claude-sonnet-5-5"
84
+ effort = "low"
85
+ subagents = "claude-haiku-5-5"
86
+ subagent_effort = "high"
87
+
88
+ [models.fix.codex]
89
+ model = "gpt-6.1-sol"
90
+ effort = "low"
91
+
92
+ [models.fix.claude]
93
+ model = "claude-sonnet-5-5"
94
+ effort = "low"
95
+ subagents = "claude-haiku-5-5"
96
+ subagent_effort = "high"
97
+
98
+ [models.lite.codex]
99
+ model = "gpt-6.1-sol"
100
+ effort = "low"
101
+ subagents = "gpt-6-luna"
102
+ subagent_effort = "max"
103
+
104
+ [models.lite.claude]
105
+ model = "claude-sonnet-5-5"
106
+ effort = "low"
107
+ subagents = "claude-haiku-5-5"
108
+ subagent_effort = "high"
109
+
110
+ [models.explore.codex]
111
+ model = "gpt-6.1-sol"
112
+ effort = "medium"
113
+ subagents = "gpt-6-luna"
114
+ subagent_effort = "max"
115
+
116
+ [models.explore.claude]
117
+ model = "claude-haiku-5-5"
118
+ effort = "high"
119
+
120
+ [models.grill.codex]
121
+ model = "gpt-6.1-terra"
122
+ effort = "max"
123
+
124
+ [models.grill.claude]
125
+ model = "claude-sonnet-5-5"
126
+ effort = "high"
127
+
128
+ [models.review.codex]
129
+ model = "gpt-6.1-terra"
130
+ effort = "max"
131
+
132
+ [models.light_review.codex]
133
+ model = "gpt-6.1-terra"
134
+ effort = "max"
135
+
136
+ [models.review.claude]
137
+ model = "claude-sonnet-5-5"
138
+ effort = "high"
139
+
140
+ [models.design.claude]
141
+ model = "claude-sonnet-5-5"
142
+ effort = "xhigh"
143
+
144
+ [models.design.codex]
145
+ model = "gpt-6.1-sol"
146
+ effort = "high"
147
+
148
+ """
149
+
150
+
151
+ ROADMAP = '{\n "items": []\n}\n'
152
+ ADOPT_BRANCH, ADOPT_ITEM = "fix/adopt-forge", "adopt-forge"
153
+ ADOPT_WHY = "Adopt Forge in this repo, which already has history."
154
+ ADOPT_DONE = ("Forge runs this repo as a live app: forge.toml names its tests, any checks and interface "
155
+ "folders, and AGENTS.md keeps the team's lines and its house rules.")
156
+
157
+
158
+ def signed_in(tool: str, top: Path | None = None) -> bool | None:
159
+ """Read the CLI's status; an unavailable check leaves sign-in unknown."""
160
+ binary = shutil.which(tool)
161
+ if not binary:
162
+ return False
163
+ command = [binary, "auth", "status"] if tool == "claude" else [binary, "login", "status"]
164
+ try:
165
+ status = subprocess.run(command, cwd=top, input="", capture_output=True, text=True,
166
+ encoding="utf-8", timeout=15)
167
+ if tool == "claude":
168
+ auth = json.loads(status.stdout)
169
+ value = auth.get("loggedIn") if isinstance(auth, dict) else None
170
+ return value if isinstance(value, bool) else None
171
+ if status.returncode == 0:
172
+ return True
173
+ if status.returncode == 1 and "Not logged in" in status.stdout + status.stderr:
174
+ return False
175
+ except (OSError, subprocess.TimeoutExpired, ValueError):
176
+ pass
177
+ return None
178
+
179
+
180
+ def _settings(stage: str, test_place: str, test: str, checks: list[str], interfaces: list[str],
181
+ merge: str = "", runner: str = "ubuntu-24.04", fast_test: str = "") -> str:
182
+ claude, codex = signed_in("claude"), signed_in("codex")
183
+ workers = 'workers = "claude"\n' # Claude builds; reviews and cold reads go to Codex when it is there
184
+ if claude is True and codex is False:
185
+ workers = 'tools = "claude"\nworkers = "claude"\n'
186
+ print("Only Claude is signed in. Forge uses Claude for all work.")
187
+ elif claude is False and codex is True:
188
+ workers = 'tools = "codex"\nworkers = "codex"\n'
189
+ print("Only Codex is signed in. Forge uses Codex for all work.")
190
+ elif claude is False and codex is False:
191
+ print("Sign in to Claude or Codex before you start work. Forge keeps Claude as the worker.")
192
+ return ("# Forge's settings. Your coding agent keeps this file: ask it to change a setting or "
193
+ "upgrade Forge.\n"
194
+ f'version = "v{__version__}"\nrepo = "client"\nstage = "{stage}"\n'
195
+ + (f'merge = "{merge}"\n' if merge else "") + workers +
196
+ f'test_place = "{test_place}"\n'
197
+ 'groups = 1\n'
198
+ f"test = {json.dumps(test)}\n"
199
+ + (f"fast_test = {json.dumps(fast_test)}\n" if fast_test else "") +
200
+ f"checks = {json.dumps(checks)}\n"
201
+ f"runner = {json.dumps(runner)}\n"
202
+ f"interfaces = {json.dumps(interfaces)}\n{MODELS}")
203
+
204
+
205
+ def _starter_files(starter: str) -> dict[str, Path]:
206
+ """The selected starter's source files, keyed by their client-relative paths."""
207
+ react = sync.TEMPLATES / "starter"
208
+ if starter == "python":
209
+ sources = {path.relative_to(react).as_posix(): path
210
+ for path in sorted((react / "apps/web").rglob("*")) if path.is_file()}
211
+ sources.update({path.relative_to(react).as_posix(): path
212
+ for path in sorted((react / "libs/shared/util").rglob("*")) if path.is_file()})
213
+ for library in (react / "libs/shared/ui", *sorted((react / "libs").glob("*/web"))):
214
+ sources.update({path.relative_to(react).as_posix(): path
215
+ for path in sorted(library.rglob("*")) if path.is_file()})
216
+ sources.update({name: react / name for name in ("tsconfig.base.json", ".npmrc")})
217
+ root = sync.TEMPLATES / "starter-python"
218
+ else:
219
+ sources = {}
220
+ root = react
221
+ sources.update({path.relative_to(root).as_posix(): path
222
+ for path in sorted(root.rglob("*")) if path.is_file()})
223
+ caches = {"__pycache__", ".pytest_cache", ".mypy_cache", ".ruff_cache", ".import_linter_cache"}
224
+ return {rel: path for rel, path in sources.items()
225
+ if path.suffix not in {".pyc", ".pyo"} and not caches.intersection(Path(rel).parts)}
226
+
227
+
228
+ def _scaffold(top: Path, actions: str, runner: str = "ubuntu-24.04",
229
+ starter: str | None = None) -> dict[str, str]:
230
+ """forge.toml, the docs skeleton and an empty roadmap: repo-relative path -> text."""
231
+ skeleton = sync.TEMPLATES / "skeleton"
232
+ test = ("node scripts/test.mjs" if starter else
233
+ next((command for marker, command in STACKS if (top / marker).is_file()), NODE_TEST))
234
+ fast_test = ("node scripts/test.mjs {base}"
235
+ if starter and "scripts/affected.mjs" in _starter_files(starter) else "")
236
+ return {
237
+ "forge.toml": (sync.read(top / "forge.toml") if (top / "forge.toml").exists() else
238
+ _settings("prototype", "ci" if actions == "yes" else "local", test,
239
+ ["tests", "forge-pr-check"] if actions == "yes" else [],
240
+ INTERFACES, runner=runner, fast_test=fast_test)),
241
+ **{path.relative_to(skeleton).as_posix(): path.read_text(encoding="utf-8")
242
+ for path in sorted(skeleton.rglob("*")) if path.is_file()
243
+ and (starter or test == NODE_TEST or path.name not in ("Dockerfile", ".dockerignore", "services.toml"))},
244
+ **({rel: path.read_bytes().decode("utf-8")
245
+ for rel, path in _starter_files(starter).items()}
246
+ if starter else {}),
247
+ "plans/roadmap.json": ROADMAP,
248
+ }
249
+
250
+
251
+ def protect(top: Path, branch: str, checks: list[str]) -> None:
252
+ """Require pull requests, live checks and admin enforcement while keeping other rules."""
253
+ origin = repo.git("remote", "get-url", "origin", cwd=top)
254
+ # Local bare remotes are used by Forge's command tests; gh resolves their placeholders.
255
+ match = re.fullmatch(r"(?:https?://github\.com/|ssh://git@(?:ssh\.)?github\.com(?::443)?/|"
256
+ r"git@github\.com:)([^/]+)/([^/]+?)(?:\.git)?", origin)
257
+ if not match and not Path(origin).is_absolute():
258
+ repo.refuse(REFUSALS["origin_repo"])
259
+ endpoint = f"repos/{match[1]}/{match[2]}/branches/{branch}/protection" if match else (
260
+ f"repos/{{owner}}/{{repo}}/branches/{branch}/protection")
261
+ read = ["gh", "api", endpoint]
262
+ done = repo.run(*read, cwd=top)
263
+ if no_protection_plan(done):
264
+ print(skipped(branch, checks))
265
+ return
266
+ try:
267
+ current = json.loads(done.stdout) if done.returncode == 0 else {}
268
+ except ValueError:
269
+ current = None
270
+ # GitHub answers 404 "Branch not protected" when there is no rule yet; anything else unread
271
+ # would be overwritten blind, so it stops.
272
+ if not isinstance(current, dict) or (
273
+ done.returncode and "Branch not protected" not in done.stdout + done.stderr):
274
+ _protect_failed(done, branch, read)
275
+ body = _stronger(current, checks, _removed_workflow_checks(top))
276
+ path = repo.forge_dir(top) / "branch-protection.json"
277
+ path.write_text(json.dumps(body, indent=2) + "\n", encoding="utf-8")
278
+ args = ["gh", "api", "--method", "PUT", endpoint, "--input", str(path)]
279
+ done = repo.run(*args, cwd=top)
280
+ if done.returncode:
281
+ _protect_failed(done, branch, args)
282
+ protection = (f"changes arrive only through a pull request whose {' and '.join(checks)} checks pass"
283
+ if checks else "changes arrive only through a pull request; no checks are required")
284
+ print(f"Branch protection is on for {branch}: {protection}, and nobody can push to it directly."
285
+ + (" Its other rules stay as they were." if current else ""))
286
+
287
+
288
+ def no_protection_plan(done: subprocess.CompletedProcess[str]) -> bool:
289
+ """GitHub's answer when the repo's plan has no branch protection, as for a private repo on a
290
+ free plan: 'Upgrade to GitHub Pro (or Team) or make this repository public'."""
291
+ return done.returncode != 0 and "Upgrade to GitHub" in done.stdout + done.stderr
292
+
293
+
294
+ def skipped(branch: str, checks: list[str]) -> str:
295
+ if not checks:
296
+ return (f"Branch protection on {branch} was skipped: this repository's GitHub plan doesn't "
297
+ "offer it. Forge's own close and merge still use a clean review and local tests; "
298
+ "no GitHub checks are required.")
299
+ return (f"Branch protection on {branch} was skipped: this repository's GitHub plan doesn't "
300
+ f"offer it. Forge's own close and merge still wait for the {' and '.join(checks)} "
301
+ "checks.")
302
+
303
+
304
+ def _protect_failed(done: subprocess.CompletedProcess[str], branch: str, args: list[str]) -> NoReturn:
305
+ said = (done.stderr.strip() or f"gh exited with code {done.returncode}").splitlines()[0]
306
+ repo.refuse(REFUSALS["protect"], branch=branch, problem=said.rstrip("."), command=shlex.join(args))
307
+
308
+
309
+ def _removed_workflow_checks(top: Path) -> set[str]:
310
+ """Job names removed in history, unless a workflow in this tree still produces them."""
311
+ def jobs(source: str) -> set[str]:
312
+ found: dict[str, str] = {}
313
+ job_id = ""
314
+ in_jobs = False
315
+ for line in source.splitlines():
316
+ if line == "jobs:":
317
+ in_jobs = True
318
+ elif in_jobs and line and not line[0].isspace() and not line.startswith("#"):
319
+ in_jobs = False
320
+ elif in_jobs:
321
+ if job := re.match(r"^ ([\w-]+):\s*(?:#.*)?$", line):
322
+ job_id = job[1]
323
+ found[job_id] = job_id
324
+ if job_id and (named := re.match(r"^ name:\s*([^#]+?)\s*(?:#.*)?$", line)):
325
+ found[job_id] = named[1].strip('"\'')
326
+ return set(found.values())
327
+
328
+ removed: set[str] = set()
329
+ for commit in repo.git("log", "--format=%H", "--diff-filter=D", "HEAD", "--",
330
+ ".github/workflows", cwd=top).splitlines():
331
+ for path in repo.git("diff-tree", "--no-commit-id", "--name-only", "-r", "-z",
332
+ "--diff-filter=D", commit, "--", ".github/workflows",
333
+ cwd=top).split("\0"):
334
+ if path.endswith((".yml", ".yaml")):
335
+ if (old := repo.run("git", "show", f"{commit}^:{path}", cwd=top)).returncode == 0:
336
+ removed.update(jobs(old.stdout))
337
+ remaining = {name for path in (top / ".github/workflows").glob("*.y*ml")
338
+ for name in jobs(path.read_text(encoding="utf-8"))}
339
+ return removed - remaining
340
+
341
+
342
+ def _stronger(current: dict[str, Any], checks: list[str], removed: set[str]) -> dict[str, Any]:
343
+ """The protection GitHub reported (its read shape), in the shape it takes, with Forge's rules
344
+ added: a pull request, the named checks and admins included."""
345
+ def on(block: Any) -> bool:
346
+ return isinstance(block, dict) and block.get("enabled") is True
347
+
348
+ def who(block: Any) -> dict[str, list[str]]:
349
+ block = block if isinstance(block, dict) else {}
350
+ return {kind: [entry[key] for entry in block.get(kind) or [] if key in entry]
351
+ for kind, key in (("users", "login"), ("teams", "slug"), ("apps", "slug"))}
352
+
353
+ status = current.get("required_status_checks") or {}
354
+ # A check keeps the app it must come from; one named only by context (older rules) has none.
355
+ kept = status.get("checks") or [{"context": name} for name in status.get("contexts") or []]
356
+ required = [{"context": entry["context"], **({"app_id": entry["app_id"]}
357
+ if isinstance(entry.get("app_id"), int) else {})}
358
+ for entry in kept if isinstance(entry, dict) and "context" in entry
359
+ and (entry["context"] not in removed or entry["context"] in checks)]
360
+ required += [{"context": name} for name in checks
361
+ if name not in {entry["context"] for entry in required}]
362
+ reviews = current.get("required_pull_request_reviews") or {}
363
+ pull = {"required_approving_review_count": reviews.get("required_approving_review_count", 0),
364
+ **{key: reviews[key] for key in ("dismiss_stale_reviews", "require_code_owner_reviews",
365
+ "require_last_push_approval") if key in reviews},
366
+ **{key: who(reviews[key]) for key in ("dismissal_restrictions",
367
+ "bypass_pull_request_allowances")
368
+ if key in reviews}}
369
+ return {"required_status_checks": {"strict": status.get("strict") is True, "checks": required},
370
+ "enforce_admins": True, # nobody pushes directly, admins included
371
+ "required_pull_request_reviews": pull,
372
+ "restrictions": who(current["restrictions"]) if current.get("restrictions") else None,
373
+ **{key: on(current[key]) for key in (
374
+ "required_linear_history", "allow_force_pushes", "allow_deletions", "block_creations",
375
+ "required_conversation_resolution", "lock_branch", "allow_fork_syncing")
376
+ if key in current}}
377
+
378
+
379
+ def init(args: argparse.Namespace) -> None:
380
+ top = repo.root()
381
+ if repo.run("git", "var", "GIT_AUTHOR_IDENT", cwd=top).returncode:
382
+ repo.refuse(REFUSALS["identity"])
383
+ history = repo.run("git", "rev-parse", "--verify", "-q", "HEAD", cwd=top).returncode == 0
384
+ if args.actions is None and not history:
385
+ repo.refuse(REFUSALS["actions"])
386
+ if args.starter:
387
+ if history:
388
+ repo.refuse(REFUSALS["starter_history"])
389
+ for marker in ("package.json", "pyproject.toml", "go.mod"):
390
+ if (top / marker).exists():
391
+ repo.refuse(REFUSALS["starter_app"], path=marker)
392
+ for rel in _starter_files(args.starter):
393
+ if (top / rel).exists():
394
+ repo.refuse(REFUSALS["starter_app"], path=rel)
395
+ if repo.run("git", "remote", "get-url", "origin", cwd=top).returncode:
396
+ repo.refuse(REFUSALS["no_origin"])
397
+ if not shutil.which("gh"):
398
+ repo.refuse(repo.REFUSALS["missing_tool"], tool="gh")
399
+ if history:
400
+ return _adopt(top, args)
401
+ repo.check_pin(top)
402
+ branch = repo.current_branch(top)
403
+ scaffold = _scaffold(top, args.actions, args.runner, args.starter)
404
+ if (top / "Dockerfile").exists():
405
+ scaffold.pop("services.toml", None)
406
+ for rel, text in scaffold.items():
407
+ if not (top / rel).exists(): # init never overwrites a file that is already there
408
+ sync.write_file(top, rel, text)
409
+ cfg = repo.config(top)
410
+ sync.write(top, cfg)
411
+ # The one first commit holds the scaffold and the sync output. The git hooks go in after it.
412
+ repo.commit_state("Set up Forge", *scaffold, *sync.files(top, cfg), top=top)
413
+ repo.git("push", "-q", "-u", "origin", branch, cwd=top)
414
+ repo.git("remote", "set-head", "origin", branch, cwd=top)
415
+ sync.install_shims(top, cfg)
416
+ sync.install_mod(top)
417
+ print(f"Set up Forge {cfg['version']} in one first commit on {branch}: forge.toml, the docs "
418
+ "skeleton, and the adapters for Claude Code and Codex.")
419
+ print(f"Pushed {branch} to origin and installed the git hooks that check each commit and push.")
420
+ protect(top, branch, cfg["checks"])
421
+ print("Tell the person the seven steps in the Forge guide's journey, then ask for the client notes or the idea.")
422
+ print("Next: forge next")
423
+
424
+
425
+ def _adopt(top: Path, args: argparse.Namespace) -> None:
426
+ """Adopt a repo with history: everything is checked against the default branch as last
427
+ fetched, which the checkout must be at, before anything changes; then one commit on
428
+ fix/adopt-forge in its own worktree. The default branch changes only when its pull request
429
+ merges."""
430
+ missing = []
431
+ if not args.actions:
432
+ missing.append("--actions")
433
+ if not args.test:
434
+ missing.append("--test")
435
+ if args.actions != "no" and not args.checks:
436
+ missing.append("--checks")
437
+ missing.extend(f"--{name}" for name in ("interfaces", "approver", "merger")
438
+ if not getattr(args, name))
439
+ if missing:
440
+ repo.refuse(REFUSALS["answers"], missing=", ".join(missing))
441
+ ref, default = story.landed_ref(top), repo.default_branch(top)
442
+ heads = repo.run("git", "rev-parse", "HEAD", f"{ref}^{{commit}}", cwd=top).stdout.split()
443
+ if len(heads) != 2 or heads[0] != heads[1] or repo.git("status", "--porcelain", cwd=top):
444
+ repo.refuse(REFUSALS["not_current"], ref=ref, default=default)
445
+ if repo.run("git", "rev-parse", "-q", "--verify", f"refs/heads/{ADOPT_BRANCH}",
446
+ cwd=top).returncode == 0:
447
+ repo.refuse(REFUSALS["adopting"])
448
+ # Forge's own check gates each pull request once Forge is on the default branch.
449
+ checks = [] if args.actions == "no" else [*(args.checks or [])]
450
+ if args.actions != "no":
451
+ for check in ("tests", "forge-pr-check"):
452
+ if check not in checks:
453
+ checks.append(check)
454
+ toml = _settings("live", "ci" if args.actions == "yes" else "local", args.test,
455
+ checks, args.interfaces, merge="human", runner=args.runner)
456
+ cfg = repo._config_text(toml) # pyright: ignore[reportPrivateUsage]
457
+ # Files sync merges into keep the team's lines; any other file Forge writes whole, so one
458
+ # already there with other text is the team's, and adoption stops before changing anything.
459
+ merged = {*githooks.ships(top, cfg), *sync.ships(top, cfg)}
460
+ wanted = {"forge.toml": toml, "plans/roadmap.json": ROADMAP, **sync.files(top, cfg),
461
+ repo.state_path(ADOPT_ITEM): None} # its state file is written later, never kept
462
+ taken = sorted(rel for rel, text in wanted.items() if rel not in merged
463
+ and (top / rel).exists() and sync.read(top / rel) != text)
464
+ if taken:
465
+ repo.refuse(REFUSALS["taken"], paths=", ".join(taken))
466
+ path = story.add_worktree(top, ADOPT_BRANCH, ref)
467
+ sync.write_file(path, "forge.toml", toml)
468
+ sync.write_file(path, "plans/roadmap.json", ROADMAP)
469
+ never = ", ".join(args.never_touch or []) or "nothing named yet"
470
+ rules = (f"## House rules\n\n- Approves stories: {args.approver}\n"
471
+ f"- Merges pull requests: {args.merger}\n- Never touch: {never}\n")
472
+ team = sync.read(path / "AGENTS.md")
473
+ sync.write_file(path, "AGENTS.md", f"{team.rstrip()}\n\n{rules}" if team.strip() else rules)
474
+ touched = {"forge.toml", "plans/roadmap.json", "AGENTS.md", *sync.write(path, cfg)}
475
+ who = repo.git("var", "GIT_AUTHOR_IDENT", cwd=path).split("<")[0].strip()
476
+ fix = {"kind": "adopt", "why": ADOPT_WHY, "done_when": ADOPT_DONE, "branch": ADOPT_BRANCH,
477
+ "status": "started", "base": repo.git("rev-parse", ref, cwd=path), "touches": 0,
478
+ "allow_large": f"Adopting Forge adds its settings, skills and hooks in one change; "
479
+ f"{who} allowed it by running forge init."}
480
+ touched.add(repo.write_state(ADOPT_ITEM, repo.add_step(fix, "start"), path))
481
+ # Exactly these paths, even ones the team's .gitignore matches.
482
+ repo.git("add", "-f", "--", *sorted(touched), cwd=path)
483
+ repo.git("commit", "-q", "-m", "Adopt Forge", cwd=path)
484
+ sync.install_shims(path, cfg)
485
+ sync.install_mod(path)
486
+ print(f"Made {ADOPT_BRANCH} in {path} with one commit, not pushed yet: forge.toml marks this "
487
+ "repo live with the tests, checks and interface folders you confirmed, AGENTS.md keeps "
488
+ "your lines and adds the house rules, and the Forge skills and hooks are added. "
489
+ f"{default} is unchanged until its pull request merges.")
490
+ print(f"After that pull request merges, forge close {ADOPT_ITEM} turns on branch protection "
491
+ f"for {default}, keeping its existing rules.")
492
+ from forge import quicktest # imported here because quicktest imports init
493
+ quicktest.combined_note(path, repo.config(path))
494
+ print(f"Next: your tests in {path}, then forge close {ADOPT_ITEM}")