@seasb/metafab 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/README.md +46 -1
  2. package/dist/cli.d.ts +11 -0
  3. package/dist/cli.js +317 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/commands/build.d.ts +2 -0
  6. package/dist/commands/build.js +70 -0
  7. package/dist/commands/build.js.map +1 -0
  8. package/dist/commands/check.d.ts +2 -0
  9. package/dist/commands/check.js +41 -0
  10. package/dist/commands/check.js.map +1 -0
  11. package/dist/commands/create.d.ts +2 -0
  12. package/dist/commands/create.js +74 -0
  13. package/dist/commands/create.js.map +1 -0
  14. package/dist/commands/detach.d.ts +2 -0
  15. package/dist/commands/detach.js +24 -0
  16. package/dist/commands/detach.js.map +1 -0
  17. package/dist/commands/diff.d.ts +2 -0
  18. package/dist/commands/diff.js +35 -0
  19. package/dist/commands/diff.js.map +1 -0
  20. package/dist/commands/import.d.ts +2 -0
  21. package/dist/commands/import.js +107 -0
  22. package/dist/commands/import.js.map +1 -0
  23. package/dist/commands/init.d.ts +2 -0
  24. package/dist/commands/init.js +77 -0
  25. package/dist/commands/init.js.map +1 -0
  26. package/dist/commands/map.d.ts +2 -0
  27. package/dist/commands/map.js +43 -0
  28. package/dist/commands/map.js.map +1 -0
  29. package/dist/commands/not-implemented.d.ts +2 -0
  30. package/dist/commands/not-implemented.js +19 -0
  31. package/dist/commands/not-implemented.js.map +1 -0
  32. package/dist/commands/pipeline-add.d.ts +2 -0
  33. package/dist/commands/pipeline-add.js +67 -0
  34. package/dist/commands/pipeline-add.js.map +1 -0
  35. package/dist/commands/pipeline-remove.d.ts +2 -0
  36. package/dist/commands/pipeline-remove.js +44 -0
  37. package/dist/commands/pipeline-remove.js.map +1 -0
  38. package/dist/commands/publish.d.ts +2 -0
  39. package/dist/commands/publish.js +147 -0
  40. package/dist/commands/publish.js.map +1 -0
  41. package/dist/commands/types.d.ts +45 -0
  42. package/dist/commands/types.js +2 -0
  43. package/dist/commands/types.js.map +1 -0
  44. package/dist/commands/update.d.ts +2 -0
  45. package/dist/commands/update.js +97 -0
  46. package/dist/commands/update.js.map +1 -0
  47. package/dist/core/adopt.d.ts +53 -0
  48. package/dist/core/adopt.js +676 -0
  49. package/dist/core/adopt.js.map +1 -0
  50. package/dist/core/build/agents.d.ts +23 -0
  51. package/dist/core/build/agents.js +60 -0
  52. package/dist/core/build/agents.js.map +1 -0
  53. package/dist/core/build/index.d.ts +4 -0
  54. package/dist/core/build/index.js +5 -0
  55. package/dist/core/build/index.js.map +1 -0
  56. package/dist/core/build/markers.d.ts +34 -0
  57. package/dist/core/build/markers.js +97 -0
  58. package/dist/core/build/markers.js.map +1 -0
  59. package/dist/core/build/plan.d.ts +48 -0
  60. package/dist/core/build/plan.js +792 -0
  61. package/dist/core/build/plan.js.map +1 -0
  62. package/dist/core/build/skill.d.ts +60 -0
  63. package/dist/core/build/skill.js +275 -0
  64. package/dist/core/build/skill.js.map +1 -0
  65. package/dist/core/check/drift.d.ts +13 -0
  66. package/dist/core/check/drift.js +205 -0
  67. package/dist/core/check/drift.js.map +1 -0
  68. package/dist/core/check/index.d.ts +12 -0
  69. package/dist/core/check/index.js +78 -0
  70. package/dist/core/check/index.js.map +1 -0
  71. package/dist/core/check/markers.d.ts +9 -0
  72. package/dist/core/check/markers.js +220 -0
  73. package/dist/core/check/markers.js.map +1 -0
  74. package/dist/core/config/destinations.d.ts +5 -0
  75. package/dist/core/config/destinations.js +20 -0
  76. package/dist/core/config/destinations.js.map +1 -0
  77. package/dist/core/config/load.d.ts +4 -0
  78. package/dist/core/config/load.js +41 -0
  79. package/dist/core/config/load.js.map +1 -0
  80. package/dist/core/config/parse.d.ts +8 -0
  81. package/dist/core/config/parse.js +198 -0
  82. package/dist/core/config/parse.js.map +1 -0
  83. package/dist/core/config/source.d.ts +14 -0
  84. package/dist/core/config/source.js +44 -0
  85. package/dist/core/config/source.js.map +1 -0
  86. package/dist/core/config/types.d.ts +48 -0
  87. package/dist/core/config/types.js +2 -0
  88. package/dist/core/config/types.js.map +1 -0
  89. package/dist/core/config/validate.d.ts +11 -0
  90. package/dist/core/config/validate.js +351 -0
  91. package/dist/core/config/validate.js.map +1 -0
  92. package/dist/core/config/writers.d.ts +14 -0
  93. package/dist/core/config/writers.js +261 -0
  94. package/dist/core/config/writers.js.map +1 -0
  95. package/dist/core/config.d.ts +7 -0
  96. package/dist/core/config.js +8 -0
  97. package/dist/core/config.js.map +1 -0
  98. package/dist/core/discovery.d.ts +34 -0
  99. package/dist/core/discovery.js +272 -0
  100. package/dist/core/discovery.js.map +1 -0
  101. package/dist/core/edit/create.d.ts +18 -0
  102. package/dist/core/edit/create.js +190 -0
  103. package/dist/core/edit/create.js.map +1 -0
  104. package/dist/core/edit/document.d.ts +4 -0
  105. package/dist/core/edit/document.js +16 -0
  106. package/dist/core/edit/document.js.map +1 -0
  107. package/dist/core/edit/factory-yaml.d.ts +17 -0
  108. package/dist/core/edit/factory-yaml.js +211 -0
  109. package/dist/core/edit/factory-yaml.js.map +1 -0
  110. package/dist/core/edit/files.d.ts +6 -0
  111. package/dist/core/edit/files.js +47 -0
  112. package/dist/core/edit/files.js.map +1 -0
  113. package/dist/core/edit/index.d.ts +9 -0
  114. package/dist/core/edit/index.js +10 -0
  115. package/dist/core/edit/index.js.map +1 -0
  116. package/dist/core/edit/map.d.ts +24 -0
  117. package/dist/core/edit/map.js +82 -0
  118. package/dist/core/edit/map.js.map +1 -0
  119. package/dist/core/edit/names.d.ts +2 -0
  120. package/dist/core/edit/names.js +17 -0
  121. package/dist/core/edit/names.js.map +1 -0
  122. package/dist/core/edit/paths.d.ts +8 -0
  123. package/dist/core/edit/paths.js +76 -0
  124. package/dist/core/edit/paths.js.map +1 -0
  125. package/dist/core/edit/pipeline.d.ts +19 -0
  126. package/dist/core/edit/pipeline.js +146 -0
  127. package/dist/core/edit/pipeline.js.map +1 -0
  128. package/dist/core/edit/skill.d.ts +1 -0
  129. package/dist/core/edit/skill.js +10 -0
  130. package/dist/core/edit/skill.js.map +1 -0
  131. package/dist/core/factory/discovery.d.ts +9 -0
  132. package/dist/core/factory/discovery.js +139 -0
  133. package/dist/core/factory/discovery.js.map +1 -0
  134. package/dist/core/factory/factory-yaml.d.ts +16 -0
  135. package/dist/core/factory/factory-yaml.js +375 -0
  136. package/dist/core/factory/factory-yaml.js.map +1 -0
  137. package/dist/core/factory/index.d.ts +5 -0
  138. package/dist/core/factory/index.js +6 -0
  139. package/dist/core/factory/index.js.map +1 -0
  140. package/dist/core/factory/lines.d.ts +8 -0
  141. package/dist/core/factory/lines.js +11 -0
  142. package/dist/core/factory/lines.js.map +1 -0
  143. package/dist/core/factory/load.d.ts +4 -0
  144. package/dist/core/factory/load.js +81 -0
  145. package/dist/core/factory/load.js.map +1 -0
  146. package/dist/core/factory/requires.d.ts +9 -0
  147. package/dist/core/factory/requires.js +123 -0
  148. package/dist/core/factory/requires.js.map +1 -0
  149. package/dist/core/factory/types.d.ts +45 -0
  150. package/dist/core/factory/types.js +2 -0
  151. package/dist/core/factory/types.js.map +1 -0
  152. package/dist/core/factory/validate.d.ts +41 -0
  153. package/dist/core/factory/validate.js +441 -0
  154. package/dist/core/factory/validate.js.map +1 -0
  155. package/dist/core/hooks/index.d.ts +8 -0
  156. package/dist/core/hooks/index.js +15 -0
  157. package/dist/core/hooks/index.js.map +1 -0
  158. package/dist/core/hooks/script.d.ts +21 -0
  159. package/dist/core/hooks/script.js +34 -0
  160. package/dist/core/hooks/script.js.map +1 -0
  161. package/dist/core/hooks/sync.d.ts +17 -0
  162. package/dist/core/hooks/sync.js +262 -0
  163. package/dist/core/hooks/sync.js.map +1 -0
  164. package/dist/core/import/conflicts.d.ts +82 -0
  165. package/dist/core/import/conflicts.js +256 -0
  166. package/dist/core/import/conflicts.js.map +1 -0
  167. package/dist/core/import/copy.d.ts +10 -0
  168. package/dist/core/import/copy.js +76 -0
  169. package/dist/core/import/copy.js.map +1 -0
  170. package/dist/core/import/file-tree.d.ts +43 -0
  171. package/dist/core/import/file-tree.js +107 -0
  172. package/dist/core/import/file-tree.js.map +1 -0
  173. package/dist/core/import/index.d.ts +5 -0
  174. package/dist/core/import/index.js +6 -0
  175. package/dist/core/import/index.js.map +1 -0
  176. package/dist/core/import/pipeline-changes.d.ts +8 -0
  177. package/dist/core/import/pipeline-changes.js +89 -0
  178. package/dist/core/import/pipeline-changes.js.map +1 -0
  179. package/dist/core/import/run.d.ts +76 -0
  180. package/dist/core/import/run.js +258 -0
  181. package/dist/core/import/run.js.map +1 -0
  182. package/dist/core/init/gitattributes.d.ts +20 -0
  183. package/dist/core/init/gitattributes.js +89 -0
  184. package/dist/core/init/gitattributes.js.map +1 -0
  185. package/dist/core/init/index.d.ts +4 -0
  186. package/dist/core/init/index.js +5 -0
  187. package/dist/core/init/index.js.map +1 -0
  188. package/dist/core/init/name.d.ts +1 -0
  189. package/dist/core/init/name.js +4 -0
  190. package/dist/core/init/name.js.map +1 -0
  191. package/dist/core/init/run.d.ts +51 -0
  192. package/dist/core/init/run.js +261 -0
  193. package/dist/core/init/run.js.map +1 -0
  194. package/dist/core/init/targets.d.ts +17 -0
  195. package/dist/core/init/targets.js +87 -0
  196. package/dist/core/init/targets.js.map +1 -0
  197. package/dist/core/merge.d.ts +88 -0
  198. package/dist/core/merge.js +239 -0
  199. package/dist/core/merge.js.map +1 -0
  200. package/dist/core/publish/exclude.d.ts +9 -0
  201. package/dist/core/publish/exclude.js +32 -0
  202. package/dist/core/publish/exclude.js.map +1 -0
  203. package/dist/core/publish/git-target.d.ts +32 -0
  204. package/dist/core/publish/git-target.js +447 -0
  205. package/dist/core/publish/git-target.js.map +1 -0
  206. package/dist/core/publish/index.d.ts +10 -0
  207. package/dist/core/publish/index.js +11 -0
  208. package/dist/core/publish/index.js.map +1 -0
  209. package/dist/core/publish/npm-target.d.ts +15 -0
  210. package/dist/core/publish/npm-target.js +170 -0
  211. package/dist/core/publish/npm-target.js.map +1 -0
  212. package/dist/core/publish/package-json.d.ts +31 -0
  213. package/dist/core/publish/package-json.js +74 -0
  214. package/dist/core/publish/package-json.js.map +1 -0
  215. package/dist/core/publish/prepare.d.ts +24 -0
  216. package/dist/core/publish/prepare.js +93 -0
  217. package/dist/core/publish/prepare.js.map +1 -0
  218. package/dist/core/publish/provenance.d.ts +1 -0
  219. package/dist/core/publish/provenance.js +20 -0
  220. package/dist/core/publish/provenance.js.map +1 -0
  221. package/dist/core/publish/publish.d.ts +13 -0
  222. package/dist/core/publish/publish.js +130 -0
  223. package/dist/core/publish/publish.js.map +1 -0
  224. package/dist/core/publish/readme.d.ts +22 -0
  225. package/dist/core/publish/readme.js +112 -0
  226. package/dist/core/publish/readme.js.map +1 -0
  227. package/dist/core/publish/stage.d.ts +19 -0
  228. package/dist/core/publish/stage.js +333 -0
  229. package/dist/core/publish/stage.js.map +1 -0
  230. package/dist/core/publish/types.d.ts +71 -0
  231. package/dist/core/publish/types.js +2 -0
  232. package/dist/core/publish/types.js.map +1 -0
  233. package/dist/core/requires/check.d.ts +15 -0
  234. package/dist/core/requires/check.js +83 -0
  235. package/dist/core/requires/check.js.map +1 -0
  236. package/dist/core/requires/index.d.ts +4 -0
  237. package/dist/core/requires/index.js +5 -0
  238. package/dist/core/requires/index.js.map +1 -0
  239. package/dist/core/requires/inspect.d.ts +44 -0
  240. package/dist/core/requires/inspect.js +114 -0
  241. package/dist/core/requires/inspect.js.map +1 -0
  242. package/dist/core/requires/paths.d.ts +29 -0
  243. package/dist/core/requires/paths.js +83 -0
  244. package/dist/core/requires/paths.js.map +1 -0
  245. package/dist/core/requires/setup.d.ts +37 -0
  246. package/dist/core/requires/setup.js +147 -0
  247. package/dist/core/requires/setup.js.map +1 -0
  248. package/dist/core/setup.d.ts +27 -0
  249. package/dist/core/setup.js +84 -0
  250. package/dist/core/setup.js.map +1 -0
  251. package/dist/core/sources/cache.d.ts +38 -0
  252. package/dist/core/sources/cache.js +200 -0
  253. package/dist/core/sources/cache.js.map +1 -0
  254. package/dist/core/sources/containment.d.ts +21 -0
  255. package/dist/core/sources/containment.js +50 -0
  256. package/dist/core/sources/containment.js.map +1 -0
  257. package/dist/core/sources/env.d.ts +12 -0
  258. package/dist/core/sources/env.js +28 -0
  259. package/dist/core/sources/env.js.map +1 -0
  260. package/dist/core/sources/extract.d.ts +25 -0
  261. package/dist/core/sources/extract.js +676 -0
  262. package/dist/core/sources/extract.js.map +1 -0
  263. package/dist/core/sources/git-process.d.ts +26 -0
  264. package/dist/core/sources/git-process.js +51 -0
  265. package/dist/core/sources/git-process.js.map +1 -0
  266. package/dist/core/sources/git.d.ts +41 -0
  267. package/dist/core/sources/git.js +511 -0
  268. package/dist/core/sources/git.js.map +1 -0
  269. package/dist/core/sources/https.d.ts +21 -0
  270. package/dist/core/sources/https.js +208 -0
  271. package/dist/core/sources/https.js.map +1 -0
  272. package/dist/core/sources/index.d.ts +13 -0
  273. package/dist/core/sources/index.js +14 -0
  274. package/dist/core/sources/index.js.map +1 -0
  275. package/dist/core/sources/npm-cli.d.ts +19 -0
  276. package/dist/core/sources/npm-cli.js +43 -0
  277. package/dist/core/sources/npm-cli.js.map +1 -0
  278. package/dist/core/sources/npm.d.ts +29 -0
  279. package/dist/core/sources/npm.js +386 -0
  280. package/dist/core/sources/npm.js.map +1 -0
  281. package/dist/core/sources/parse.d.ts +32 -0
  282. package/dist/core/sources/parse.js +389 -0
  283. package/dist/core/sources/parse.js.map +1 -0
  284. package/dist/core/sources/path.d.ts +10 -0
  285. package/dist/core/sources/path.js +316 -0
  286. package/dist/core/sources/path.js.map +1 -0
  287. package/dist/core/sources/redact.d.ts +2 -0
  288. package/dist/core/sources/redact.js +70 -0
  289. package/dist/core/sources/redact.js.map +1 -0
  290. package/dist/core/sources/resolve.d.ts +9 -0
  291. package/dist/core/sources/resolve.js +29 -0
  292. package/dist/core/sources/resolve.js.map +1 -0
  293. package/dist/core/sources/types.d.ts +86 -0
  294. package/dist/core/sources/types.js +2 -0
  295. package/dist/core/sources/types.js.map +1 -0
  296. package/dist/core/sources/validate.d.ts +9 -0
  297. package/dist/core/sources/validate.js +111 -0
  298. package/dist/core/sources/validate.js.map +1 -0
  299. package/dist/core/summary.d.ts +77 -0
  300. package/dist/core/summary.js +405 -0
  301. package/dist/core/summary.js.map +1 -0
  302. package/dist/core/update/clashes.d.ts +63 -0
  303. package/dist/core/update/clashes.js +192 -0
  304. package/dist/core/update/clashes.js.map +1 -0
  305. package/dist/core/update/detach.d.ts +21 -0
  306. package/dist/core/update/detach.js +38 -0
  307. package/dist/core/update/detach.js.map +1 -0
  308. package/dist/core/update/diff.d.ts +58 -0
  309. package/dist/core/update/diff.js +180 -0
  310. package/dist/core/update/diff.js.map +1 -0
  311. package/dist/core/update/fetch.d.ts +34 -0
  312. package/dist/core/update/fetch.js +73 -0
  313. package/dist/core/update/fetch.js.map +1 -0
  314. package/dist/core/update/index.d.ts +6 -0
  315. package/dist/core/update/index.js +7 -0
  316. package/dist/core/update/index.js.map +1 -0
  317. package/dist/core/update/restore.d.ts +20 -0
  318. package/dist/core/update/restore.js +195 -0
  319. package/dist/core/update/restore.js.map +1 -0
  320. package/dist/core/update/run.d.ts +113 -0
  321. package/dist/core/update/run.js +1132 -0
  322. package/dist/core/update/run.js.map +1 -0
  323. package/dist/core/update/select.d.ts +39 -0
  324. package/dist/core/update/select.js +157 -0
  325. package/dist/core/update/select.js.map +1 -0
  326. package/dist/core/update/spelling.d.ts +51 -0
  327. package/dist/core/update/spelling.js +185 -0
  328. package/dist/core/update/spelling.js.map +1 -0
  329. package/dist/core/update/trees.d.ts +24 -0
  330. package/dist/core/update/trees.js +72 -0
  331. package/dist/core/update/trees.js.map +1 -0
  332. package/dist/errors.d.ts +29 -0
  333. package/dist/errors.js +24 -0
  334. package/dist/errors.js.map +1 -0
  335. package/dist/help.d.ts +46 -0
  336. package/dist/help.js +103 -0
  337. package/dist/help.js.map +1 -0
  338. package/dist/input.d.ts +25 -0
  339. package/dist/input.js +173 -0
  340. package/dist/input.js.map +1 -0
  341. package/dist/output.d.ts +21 -0
  342. package/dist/output.js +37 -0
  343. package/dist/output.js.map +1 -0
  344. package/dist/util/frontmatter.d.ts +12 -0
  345. package/dist/util/frontmatter.js +58 -0
  346. package/dist/util/frontmatter.js.map +1 -0
  347. package/dist/util/fs.d.ts +32 -0
  348. package/dist/util/fs.js +126 -0
  349. package/dist/util/fs.js.map +1 -0
  350. package/dist/util/git-names.d.ts +8 -0
  351. package/dist/util/git-names.js +25 -0
  352. package/dist/util/git-names.js.map +1 -0
  353. package/dist/util/git.d.ts +12 -0
  354. package/dist/util/git.js +33 -0
  355. package/dist/util/git.js.map +1 -0
  356. package/dist/util/suggest.d.ts +6 -0
  357. package/dist/util/suggest.js +48 -0
  358. package/dist/util/suggest.js.map +1 -0
  359. package/dist/util/text.d.ts +8 -0
  360. package/dist/util/text.js +19 -0
  361. package/dist/util/text.js.map +1 -0
  362. package/dist/util/version.d.ts +7 -0
  363. package/dist/util/version.js +13 -0
  364. package/dist/util/version.js.map +1 -0
  365. package/dist/util/yaml.d.ts +30 -0
  366. package/dist/util/yaml.js +201 -0
  367. package/dist/util/yaml.js.map +1 -0
  368. package/package.json +50 -3
  369. package/resources/metafab-skill/SKILL.md +99 -0
@@ -0,0 +1,76 @@
1
+ import type { Problem } from "../../errors.js";
2
+ import type { InputIO } from "../../input.js";
3
+ import type { AdoptionMove } from "../adopt.js";
4
+ import type { BuildChange } from "../build/index.js";
5
+ import type { UpstreamEntry } from "../config/types.js";
6
+ import type { HookChange } from "../hooks/index.js";
7
+ import type { TargetPrompt } from "../init/targets.js";
8
+ import type { RequirementResult } from "../requires/inspect.js";
9
+ import type { SourceOptions } from "../sources/index.js";
10
+ import type { Summary } from "../summary.js";
11
+ export interface ImportOptions {
12
+ /** Directory that contains, or will contain, `.factory/`. */
13
+ root: string;
14
+ /** The source exactly as the user typed it. */
15
+ source: string;
16
+ /** Directory relative paths resolve against; the process cwd by default. */
17
+ cwd?: string;
18
+ /** Raw `--agents` value. */
19
+ agents?: string;
20
+ /** Replace differing local files instead of stopping. */
21
+ force?: boolean;
22
+ /** Consent to adopt existing repository skills without asking. */
23
+ adopt?: boolean;
24
+ /** Create the missing required files: `true` for `--setup`, `false` for `--no-setup`. */
25
+ setup?: boolean;
26
+ /** Injected input and output; production uses the process streams. */
27
+ io?: InputIO;
28
+ /** Injected agent-target prompt, so tests do not need a terminal. */
29
+ prompt?: TargetPrompt;
30
+ /** Let Git prompt for credentials; the command enables it for a TTY. */
31
+ interactive?: boolean;
32
+ /** Injected source settings, used by tests for a local registry or transport. */
33
+ sourceOptions?: SourceOptions;
34
+ /**
35
+ * @internal Test seam: runs after the setup consent and before the agreed
36
+ * files are created, so a test can make one appear in between.
37
+ */
38
+ beforeCreate?: () => Promise<void>;
39
+ }
40
+ export interface ImportReport {
41
+ root: string;
42
+ upstream: UpstreamEntry;
43
+ /** Files created before the copy, such as `metafab.yaml` and `.gitattributes`. */
44
+ created: string[];
45
+ /** Existing files changed before the copy. */
46
+ updated: string[];
47
+ /** `.gitattributes` lines added. */
48
+ gitattributes: string[];
49
+ /** Skills moved from a destination into `.factory/skills/`. */
50
+ moved: AdoptionMove[];
51
+ /** The repository files the factory requires, in `factory.yaml` order. */
52
+ requires: RequirementResult[];
53
+ /** Fab paths copied into `.factory/`. */
54
+ copied: string[];
55
+ /** Files created, updated, or removed by the closing build. */
56
+ changed: BuildChange[];
57
+ /** Git hooks created, updated, or removed by the closing build. */
58
+ hooks: HookChange[];
59
+ /** Build warnings. */
60
+ problems: Problem[];
61
+ /** The review summary, also rendered as the command's human output. */
62
+ review: Summary;
63
+ /** True when the adoption question was answered with no. */
64
+ declined: boolean;
65
+ }
66
+ /**
67
+ * Runs `metafab import`: resolve and fetch the source, check it against the
68
+ * repository without writing, collect adoption consent, then create the local
69
+ * configuration, adopt skills, copy the fab, record the upstream and build.
70
+ *
71
+ * Nothing is written before the preflight and consent are complete. A temporary
72
+ * fetch directory is removed whatever way the command ends.
73
+ */
74
+ export declare function runImport(options: ImportOptions): Promise<ImportReport>;
75
+ /** Human-readable report for `import`: the review summary, or the declined notice. */
76
+ export declare function describeImport(report: ImportReport): string;
@@ -0,0 +1,258 @@
1
+ import path from "node:path";
2
+ import { ExitCode, MetafabError } from "../../errors.js";
3
+ import { confirm, NeedsInput } from "../../input.js";
4
+ import { isDirectory, pathExists } from "../../util/fs.js";
5
+ import { cliVersion } from "../../util/version.js";
6
+ import { ADOPTION_QUESTION, adoptionRequired, applyAdoption, assertAdoptionAllowed, planAdoption, } from "../adopt.js";
7
+ import { applyBuild, planBuild } from "../build/index.js";
8
+ import { destinations } from "../config/destinations.js";
9
+ import { CONFIG_FILE, CONFIG_FILENAME } from "../config/parse.js";
10
+ import { createConfig, setUpstream } from "../config/writers.js";
11
+ import { loadFactory } from "../factory/load.js";
12
+ import { hookChangeLines } from "../hooks/index.js";
13
+ import { assertGitattributesWritable, ensureGitattributes } from "../init/gitattributes.js";
14
+ import { selectTargets } from "../init/targets.js";
15
+ import { inspectRequirement } from "../requires/inspect.js";
16
+ import { createRequirements, decideSetup, declineRequirements, setupRequired, } from "../requires/setup.js";
17
+ import { assertFactoryDirectoryUsable, preflightBuild, readConfig, selectedTargets, } from "../setup.js";
18
+ import { fetchFab, parseSource, resolve } from "../sources/index.js";
19
+ import { renderSummary, summarise } from "../summary.js";
20
+ import { copyFactoryTree, FAB_ROOT_EXCLUDES } from "./copy.js";
21
+ import { findImportConflicts, localFilesForImport } from "./conflicts.js";
22
+ import { emptyTree, snapshotDirectories, snapshotFactory, snapshotTree } from "./file-tree.js";
23
+ import { alignFactorySpelling } from "../update/spelling.js";
24
+ function upstreamExists() {
25
+ return new MetafabError("This factory already has an upstream", {
26
+ exitCode: ExitCode.NotOwned,
27
+ code: "upstream-exists",
28
+ problems: [
29
+ {
30
+ level: "error",
31
+ file: CONFIG_FILE,
32
+ message: "This factory already has an upstream",
33
+ fix: "Use metafab update or metafab detach",
34
+ },
35
+ ],
36
+ });
37
+ }
38
+ function importConflicts(conflicts) {
39
+ return new MetafabError("Import stopped because the incoming fab would replace local files.", {
40
+ exitCode: ExitCode.NotOwned,
41
+ code: "import-conflict",
42
+ problems: conflicts,
43
+ });
44
+ }
45
+ function importTitle(upstream) {
46
+ switch (upstream.kind) {
47
+ case "npm":
48
+ return `Imported ${upstream.source} ${upstream.version}`;
49
+ case "git":
50
+ return upstream.version === undefined
51
+ ? `Imported ${upstream.source} ${upstream.commit.slice(0, 7)}`
52
+ : `Imported ${upstream.source} ${upstream.version}`;
53
+ case "unversioned":
54
+ return `Imported ${upstream.source}`;
55
+ }
56
+ }
57
+ function declinedReport(root, upstream, review, requires) {
58
+ return {
59
+ root,
60
+ upstream,
61
+ created: [],
62
+ updated: [],
63
+ gitattributes: [],
64
+ moved: [],
65
+ requires,
66
+ copied: [],
67
+ changed: [],
68
+ hooks: [],
69
+ problems: [],
70
+ review,
71
+ declined: true,
72
+ };
73
+ }
74
+ /**
75
+ * Runs `metafab import`: resolve and fetch the source, check it against the
76
+ * repository without writing, collect adoption consent, then create the local
77
+ * configuration, adopt skills, copy the fab, record the upstream and build.
78
+ *
79
+ * Nothing is written before the preflight and consent are complete. A temporary
80
+ * fetch directory is removed whatever way the command ends.
81
+ */
82
+ export async function runImport(options) {
83
+ const root = path.resolve(options.root);
84
+ const factoryDir = path.join(root, ".factory");
85
+ const io = options.io ?? {};
86
+ const tty = io.tty ?? process.stdin.isTTY === true;
87
+ await assertFactoryDirectoryUsable(factoryDir, "import");
88
+ const hasFactory = await isDirectory(factoryDir);
89
+ const existingConfig = await readConfig(factoryDir, "import");
90
+ if (existingConfig.upstream !== undefined)
91
+ throw upstreamExists();
92
+ const configErrors = existingConfig.problems.filter((problem) => problem.level === "error");
93
+ if (configErrors.length > 0) {
94
+ throw new MetafabError("The factory configuration has problems.", {
95
+ exitCode: ExitCode.Failed,
96
+ code: "config-invalid",
97
+ problems: configErrors,
98
+ });
99
+ }
100
+ const spec = parseSource(options.source, { cwd: options.cwd ?? process.cwd() });
101
+ const sourceOptions = {
102
+ ...options.sourceOptions,
103
+ ...(options.interactive === true ? { interactive: true } : {}),
104
+ };
105
+ const resolved = await resolve(spec, sourceOptions);
106
+ let fetched;
107
+ try {
108
+ fetched = await fetchFab(resolved, sourceOptions);
109
+ const selection = await selectTargets({
110
+ ...(options.agents === undefined ? {} : { agents: options.agents }),
111
+ ...(hasFactory ? { existing: existingConfig.agentsRaw ?? "all" } : {}),
112
+ io,
113
+ ...(options.prompt === undefined ? {} : { prompt: options.prompt }),
114
+ });
115
+ const targets = selectedTargets(selection);
116
+ const factory = hasFactory ? await loadFactory(root) : undefined;
117
+ const plan = await planAdoption(root, destinations(targets).map((destination) => destination.directory), factory);
118
+ assertAdoptionAllowed(plan);
119
+ const local = await localFilesForImport(root, factoryDir, plan.moves, hasFactory);
120
+ await assertGitattributesWritable(root, "import");
121
+ const { conflicts, ambiguities } = await findImportConflicts(fetched.factoryDir, local);
122
+ // `--force` replaces differing local content, but it cannot choose between
123
+ // two local entries that fold to one incoming path: a case-sensitive
124
+ // filesystem can hold both, and renaming either would be a guess.
125
+ if (ambiguities.length > 0)
126
+ throw importConflicts([...ambiguities, ...conflicts]);
127
+ if (conflicts.length > 0 && options.force !== true)
128
+ throw importConflicts(conflicts);
129
+ // The fetch validated the fab, so rules 12 and 13 hold for these entries.
130
+ // Inspection only reads: nothing outside `.factory/` changes before the
131
+ // consent below is complete.
132
+ const fetchedFactory = await loadFactory(path.dirname(fetched.factoryDir));
133
+ const inspected = [];
134
+ for (const requirement of fetchedFactory.factoryYaml?.requires ?? []) {
135
+ inspected.push(await inspectRequirement(root, requirement));
136
+ }
137
+ // Consent is collected before the first write. Adoption is asked first so
138
+ // a declined adoption still changes nothing; the setup question follows it
139
+ // in the same readline session.
140
+ const adoptionNeeded = plan.moves.length > 0 && options.adopt !== true;
141
+ // Only a missing file with a template can be created, so only that needs
142
+ // an answer. A template-less or blocked entry is never asked about.
143
+ const setupNeedsFlag = options.setup === undefined &&
144
+ inspected.some((result) => result.state === "missing" && result.template !== undefined);
145
+ if (!tty) {
146
+ if (adoptionNeeded && setupNeedsFlag) {
147
+ throw new NeedsInput([adoptionRequired(plan), setupRequired(inspected)]);
148
+ }
149
+ if (adoptionNeeded)
150
+ throw new NeedsInput([adoptionRequired(plan)]);
151
+ if (setupNeedsFlag)
152
+ throw new NeedsInput([setupRequired(inspected)]);
153
+ }
154
+ let declined = false;
155
+ if (adoptionNeeded) {
156
+ const accepted = await confirm({ name: "adopt", flag: "--adopt", description: ADOPTION_QUESTION }, {}, { ...io, tty });
157
+ declined = !accepted;
158
+ }
159
+ if (declined) {
160
+ return declinedReport(root, fetched.upstream, summarise(emptyTree(), emptyTree(), { title: importTitle(fetched.upstream) }), inspected);
161
+ }
162
+ const setupAgreed = await decideSetup(inspected, options.setup, io, tty);
163
+ if (setupAgreed === "needs-input")
164
+ throw new NeedsInput([setupRequired(inspected)]);
165
+ const configExists = hasFactory && (await pathExists(path.join(factoryDir, CONFIG_FILENAME)));
166
+ await preflightBuild(root, existingConfig, selection, configExists, plan.moves);
167
+ const created = [];
168
+ const updated = [];
169
+ if (await createConfig(factoryDir, { agents: selection })) {
170
+ created.push(`.factory/${CONFIG_FILENAME}`);
171
+ }
172
+ const gitattributesExisted = await pathExists(path.join(root, ".gitattributes"));
173
+ const gitattributes = await ensureGitattributes(root);
174
+ if (gitattributes.changed) {
175
+ if (gitattributesExisted)
176
+ updated.push(".gitattributes");
177
+ else
178
+ created.push(".gitattributes");
179
+ }
180
+ const before = await snapshotFactory(root);
181
+ if (plan.moves.length > 0)
182
+ await applyAdoption(plan);
183
+ // With `--force` a case-only clash is realigned before the copy, so the
184
+ // result is the same on every filesystem. A declined import never reaches
185
+ // here, so it still renames nothing. A local file where the fab has a
186
+ // directory is skipped by `alignFactorySpelling` and replaced by the copy.
187
+ const fabTree = await snapshotTree(fetched.factoryDir);
188
+ await alignFactorySpelling(factoryDir, {
189
+ files: Object.keys(fabTree).filter((relativePath) => relativePath.includes("/") || !FAB_ROOT_EXCLUDES.has(relativePath)),
190
+ directories: await snapshotDirectories(fetched.factoryDir),
191
+ });
192
+ const copied = await copyFactoryTree(fetched.factoryDir, factoryDir);
193
+ await setUpstream(factoryDir, fetched.upstream);
194
+ const after = await snapshotFactory(root);
195
+ // The factory is copied and recorded, so a file that cannot be created is a
196
+ // warning and the import continues. Creation happens after the copy (the
197
+ // template is read from the fab's committed bytes in `.factory/`) and
198
+ // before the build, which ignores `requires`.
199
+ await options.beforeCreate?.();
200
+ const creationProblems = [];
201
+ const requirements = setupAgreed === true
202
+ ? await createRequirements(root, inspected, creationProblems)
203
+ : declineRequirements(inspected);
204
+ const builtFactory = await loadFactory(root);
205
+ const config = await readConfig(factoryDir, "import");
206
+ const warnings = [
207
+ ...builtFactory.problems,
208
+ ...config.problems,
209
+ ...creationProblems,
210
+ ].filter((problem) => problem.level === "warning");
211
+ const buildPlan = await planBuild(builtFactory, config, cliVersion());
212
+ if (buildPlan.conflicts.length > 0) {
213
+ throw new MetafabError("Build stopped because the repository contains output that Metafab does not own.", {
214
+ exitCode: ExitCode.NotOwned,
215
+ code: "build-conflict",
216
+ problems: [...buildPlan.conflicts, ...buildPlan.errors, ...warnings, ...buildPlan.warnings],
217
+ });
218
+ }
219
+ if (buildPlan.errors.length > 0) {
220
+ throw new MetafabError("Build failed after import.", {
221
+ exitCode: ExitCode.Failed,
222
+ code: "build-failed",
223
+ problems: [...buildPlan.errors, ...warnings, ...buildPlan.warnings],
224
+ });
225
+ }
226
+ const build = await applyBuild(buildPlan);
227
+ return {
228
+ root,
229
+ upstream: fetched.upstream,
230
+ created,
231
+ updated,
232
+ gitattributes: [...gitattributes.added],
233
+ moved: plan.moves.map((move) => ({ ...move, from: [...move.from] })),
234
+ requires: requirements,
235
+ copied,
236
+ changed: build.changed,
237
+ hooks: build.hooks,
238
+ problems: [...warnings, ...buildPlan.warnings, ...build.hookWarnings],
239
+ review: summarise(before, after, {
240
+ title: importTitle(fetched.upstream),
241
+ requirements,
242
+ }),
243
+ declined: false,
244
+ };
245
+ }
246
+ finally {
247
+ await fetched?.cleanup?.();
248
+ }
249
+ }
250
+ /** Human-readable report for `import`: the review summary, or the declined notice. */
251
+ export function describeImport(report) {
252
+ const body = report.declined ? "Adoption declined. Nothing changed." : renderSummary(report.review);
253
+ const hookLines = hookChangeLines(report.hooks);
254
+ if (hookLines.length === 0)
255
+ return body;
256
+ return body === "" ? hookLines.join("\n") : [body, ...hookLines].join("\n");
257
+ }
258
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/core/import/run.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,YAAY,GACb,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,aAAa,EAA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K,CAAC;QAAE,OAAO,IAAI,CAAC;IACxC,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,20 @@
1
+ export declare const GITATTRIBUTES_FILE = ".gitattributes";
2
+ export declare const GITATTRIBUTES_LINES: readonly [".factory/** text=auto eol=lf", ".claude/skills/** text=auto eol=lf", ".agents/skills/** text=auto eol=lf"];
3
+ export interface GitattributesChange {
4
+ changed: boolean;
5
+ /** The resulting file content. */
6
+ text: string;
7
+ /** The exact lines added, in specification order. */
8
+ added: string[];
9
+ }
10
+ export declare function addGitattributesLines(existing: string | undefined): GitattributesChange;
11
+ export declare function ensureGitattributes(root: string): Promise<GitattributesChange>;
12
+ /**
13
+ * Refuses a symbolic link at the root `.gitattributes` that `command` would
14
+ * write through. `lstat` finds the link itself; `readFile` follows it, so a
15
+ * dangling link reads as empty and counts as a file that needs every line.
16
+ *
17
+ * A link to an existing file that already has every line needs no write and is
18
+ * left alone.
19
+ */
20
+ export declare function assertGitattributesWritable(root: string, command: "init" | "import"): Promise<void>;
@@ -0,0 +1,89 @@
1
+ import { lstat, readFile, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { ExitCode, MetafabError } from "../../errors.js";
4
+ export const GITATTRIBUTES_FILE = ".gitattributes";
5
+ export const GITATTRIBUTES_LINES = [
6
+ ".factory/** text=auto eol=lf",
7
+ ".claude/skills/** text=auto eol=lf",
8
+ ".agents/skills/** text=auto eol=lf",
9
+ ];
10
+ function isPresent(line, existing) {
11
+ return existing.some((candidate) => {
12
+ const value = candidate.trimEnd();
13
+ return value !== "" && !value.startsWith("#") && value === line;
14
+ });
15
+ }
16
+ export function addGitattributesLines(existing) {
17
+ const text = existing ?? "";
18
+ const present = text.split(/\r?\n/);
19
+ const missing = GITATTRIBUTES_LINES.filter((line) => !isPresent(line, present));
20
+ if (missing.length === 0)
21
+ return { changed: false, text, added: [] };
22
+ const separator = text === "" || text.endsWith("\n") ? "" : "\n";
23
+ return {
24
+ changed: true,
25
+ text: `${text}${separator}${missing.join("\n")}\n`,
26
+ added: [...missing],
27
+ };
28
+ }
29
+ export async function ensureGitattributes(root) {
30
+ const file = path.join(root, GITATTRIBUTES_FILE);
31
+ let existing;
32
+ try {
33
+ existing = await readFile(file, "utf8");
34
+ }
35
+ catch (error) {
36
+ if (error.code !== "ENOENT")
37
+ throw error;
38
+ }
39
+ const change = addGitattributesLines(existing);
40
+ if (change.changed)
41
+ await writeFile(file, change.text, "utf8");
42
+ return change;
43
+ }
44
+ /**
45
+ * Refuses a symbolic link at the root `.gitattributes` that `command` would
46
+ * write through. `lstat` finds the link itself; `readFile` follows it, so a
47
+ * dangling link reads as empty and counts as a file that needs every line.
48
+ *
49
+ * A link to an existing file that already has every line needs no write and is
50
+ * left alone.
51
+ */
52
+ export async function assertGitattributesWritable(root, command) {
53
+ const file = path.join(root, GITATTRIBUTES_FILE);
54
+ let info;
55
+ try {
56
+ info = await lstat(file);
57
+ }
58
+ catch (error) {
59
+ if (error.code === "ENOENT")
60
+ return;
61
+ throw error;
62
+ }
63
+ if (!info.isSymbolicLink())
64
+ return;
65
+ let existing;
66
+ try {
67
+ existing = await readFile(file, "utf8");
68
+ }
69
+ catch {
70
+ // A dangling link has no content, so every line is still missing.
71
+ existing = undefined;
72
+ }
73
+ if (!addGitattributesLines(existing).changed)
74
+ return;
75
+ const message = `${GITATTRIBUTES_FILE} is a symbolic link, so metafab ${command} will not write through it`;
76
+ throw new MetafabError(message, {
77
+ exitCode: ExitCode.Failed,
78
+ code: "factory-unreadable",
79
+ problems: [
80
+ {
81
+ level: "error",
82
+ file: GITATTRIBUTES_FILE,
83
+ message,
84
+ fix: `Replace it with a regular file, then run metafab ${command} again`,
85
+ },
86
+ ],
87
+ });
88
+ }
89
+ //#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IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;QAAE,OAAO;IAEnC,IAAI,QAA4B,CAAC;IACjC,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,kEAAkE;QAClE,QAAQ,GAAG,SAAS,CAAC;IACvB,CAAC;IAED,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,OAAO;QAAE,OAAO;IAErD,MAAM,OAAO,GAAG,GAAG,kBAAkB,mCAAmC,OAAO,4BAA4B,CAAC;IAC5G,MAAM,IAAI,YAAY,CAAC,OAAO,EAAE;QAC9B,QAAQ,EAAE,QAAQ,CAAC,MAAM;QACzB,IAAI,EAAE,oBAAoB;QAC1B,QAAQ,EAAE;YACR;gBACE,KAAK,EAAE,OAAO;gBACd,IAAI,EAAE,kBAAkB;gBACxB,OAAO;gBACP,GAAG,EAAE,oDAAoD,OAAO,QAAQ;aACzE;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./name.js";
2
+ export * from "./targets.js";
3
+ export * from "./gitattributes.js";
4
+ export * from "./run.js";
@@ -0,0 +1,5 @@
1
+ export * from "./name.js";
2
+ export * from "./targets.js";
3
+ export * from "./gitattributes.js";
4
+ export * from "./run.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/init/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC"}
@@ -0,0 +1 @@
1
+ export { deriveFactoryName } from "../edit/paths.js";
@@ -0,0 +1,4 @@
1
+ // `pipeline add` needs the same derivation when it creates a missing factory.yaml,
2
+ // so `edit` owns the implementation and `init` exposes it for `init` and `import`.
3
+ export { deriveFactoryName } from "../edit/paths.js";
4
+ //# sourceMappingURL=name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name.js","sourceRoot":"","sources":["../../../src/core/init/name.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,mFAAmF;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,51 @@
1
+ import type { Problem } from "../../errors.js";
2
+ import type { InputIO } from "../../input.js";
3
+ import type { AdoptionMove } from "../adopt.js";
4
+ import type { BuildChange } from "../build/index.js";
5
+ import type { HookChange } from "../hooks/index.js";
6
+ import type { TargetPrompt } from "./targets.js";
7
+ export interface InitOptions {
8
+ /** Directory that will contain `.factory/`. */
9
+ root: string;
10
+ /** Raw `--agents` value. */
11
+ agents?: string;
12
+ /** Consent to adopt existing repository skills without asking. */
13
+ adopt?: boolean;
14
+ /** `--git-hooks` (`true`) or `--no-git-hooks` (`false`); absent when neither was given. */
15
+ gitHooks?: boolean;
16
+ /** Injected input and output; production uses the process streams. */
17
+ io?: InputIO;
18
+ /** Injected agent-target prompt, so tests do not need a terminal. */
19
+ prompt?: TargetPrompt;
20
+ }
21
+ export interface InitReport {
22
+ root: string;
23
+ /** Files created by `init`, in the order it created them. */
24
+ created: string[];
25
+ /** Existing files changed by `init`, other than build output. */
26
+ updated: string[];
27
+ /** `.gitattributes` lines added. */
28
+ gitattributes: string[];
29
+ /** Skills moved from a destination into `.factory/skills/`. */
30
+ moved: AdoptionMove[];
31
+ /** Files created, updated, or removed by the closing build. */
32
+ changed: BuildChange[];
33
+ /** Git hooks created, updated, or removed by the closing build. */
34
+ hooks: HookChange[];
35
+ /** Build and hook warnings. */
36
+ problems: Problem[];
37
+ /** True when the adoption question was answered with no. */
38
+ declined: boolean;
39
+ /** Human notes, such as a `git-hooks` value that was left alone. */
40
+ notes: string[];
41
+ /** Suggestions printed last, such as the Orca worktree setup step. */
42
+ suggestions: string[];
43
+ }
44
+ /**
45
+ * Runs the `init` sequence: resolve targets, preflight adoption and collect consent,
46
+ * create missing factory files, add `.gitattributes` lines, apply adoption, then build.
47
+ * Nothing is written before the adoption preflight and consent are complete.
48
+ */
49
+ export declare function runInit(options: InitOptions): Promise<InitReport>;
50
+ /** Human-readable report for `init`, or `Already initialised` when nothing needed changing. */
51
+ export declare function describeInit(report: InitReport): string;