@unbrained/pm-cli 2026.5.29 → 2026.5.31

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 (274) hide show
  1. package/CHANGELOG.md +54 -12
  2. package/dist/cli/bootstrap-args.d.ts +1 -1
  3. package/dist/cli/bootstrap-args.js +59 -9
  4. package/dist/cli/bootstrap-args.js.map +1 -1
  5. package/dist/cli/commands/activity.js +4 -4
  6. package/dist/cli/commands/activity.js.map +1 -1
  7. package/dist/cli/commands/calendar.js +83 -11
  8. package/dist/cli/commands/calendar.js.map +1 -1
  9. package/dist/cli/commands/close.js +4 -4
  10. package/dist/cli/commands/close.js.map +1 -1
  11. package/dist/cli/commands/completion.js +4 -4
  12. package/dist/cli/commands/completion.js.map +1 -1
  13. package/dist/cli/commands/create.js +50 -7
  14. package/dist/cli/commands/create.js.map +1 -1
  15. package/dist/cli/commands/deps.js +4 -4
  16. package/dist/cli/commands/deps.js.map +1 -1
  17. package/dist/cli/commands/extension/install-sources.d.ts +3 -0
  18. package/dist/cli/commands/extension/install-sources.js +29 -4
  19. package/dist/cli/commands/extension/install-sources.js.map +1 -1
  20. package/dist/cli/commands/extension.js +26 -5
  21. package/dist/cli/commands/extension.js.map +1 -1
  22. package/dist/cli/commands/get.js +6 -3
  23. package/dist/cli/commands/get.js.map +1 -1
  24. package/dist/cli/commands/list.js +25 -6
  25. package/dist/cli/commands/list.js.map +1 -1
  26. package/dist/cli/commands/reindex.js +3 -3
  27. package/dist/cli/commands/reindex.js.map +1 -1
  28. package/dist/cli/commands/search.d.ts +17 -0
  29. package/dist/cli/commands/search.js +40 -10
  30. package/dist/cli/commands/search.js.map +1 -1
  31. package/dist/cli/commands/stats.js +4 -4
  32. package/dist/cli/commands/stats.js.map +1 -1
  33. package/dist/cli/commands/test-all.js +4 -4
  34. package/dist/cli/commands/test-all.js.map +1 -1
  35. package/dist/cli/main.d.ts +2 -0
  36. package/dist/cli/main.js +39 -11
  37. package/dist/cli/main.js.map +1 -1
  38. package/dist/cli/register-list-query.js +10 -12
  39. package/dist/cli/register-list-query.js.map +1 -1
  40. package/dist/cli/register-mutation.js +20 -22
  41. package/dist/cli/register-mutation.js.map +1 -1
  42. package/dist/cli/register-operations.js +32 -25
  43. package/dist/cli/register-operations.js.map +1 -1
  44. package/dist/cli/register-setup.js +7 -9
  45. package/dist/cli/register-setup.js.map +1 -1
  46. package/dist/cli/registration-helpers.js +6 -3
  47. package/dist/cli/registration-helpers.js.map +1 -1
  48. package/dist/cli/search-refresh.d.ts +2 -0
  49. package/dist/cli/search-refresh.js +13 -0
  50. package/dist/cli/search-refresh.js.map +1 -0
  51. package/dist/cli-bundle/chunks/activity-OWYSUZOY.js +17 -0
  52. package/dist/cli-bundle/chunks/activity-OWYSUZOY.js.map +7 -0
  53. package/dist/cli-bundle/chunks/aggregate-ADUOSFRO.js +209 -0
  54. package/dist/cli-bundle/chunks/aggregate-ADUOSFRO.js.map +7 -0
  55. package/dist/cli-bundle/chunks/append-JD2DETU7.js +73 -0
  56. package/dist/cli-bundle/chunks/append-JD2DETU7.js.map +7 -0
  57. package/dist/cli-bundle/chunks/chunk-3HUE7XOF.js +27 -0
  58. package/dist/cli-bundle/chunks/chunk-3HUE7XOF.js.map +7 -0
  59. package/dist/cli-bundle/chunks/chunk-3M73P3G6.js +1636 -0
  60. package/dist/cli-bundle/chunks/chunk-3M73P3G6.js.map +7 -0
  61. package/dist/cli-bundle/chunks/chunk-4AEZR5EJ.js +189 -0
  62. package/dist/cli-bundle/chunks/chunk-4AEZR5EJ.js.map +7 -0
  63. package/dist/cli-bundle/chunks/chunk-5HSEP75M.js +330 -0
  64. package/dist/cli-bundle/chunks/chunk-5HSEP75M.js.map +7 -0
  65. package/dist/cli-bundle/chunks/chunk-6HT2F4TK.js +1770 -0
  66. package/dist/cli-bundle/chunks/chunk-6HT2F4TK.js.map +7 -0
  67. package/dist/cli-bundle/chunks/chunk-6YCV7WSL.js +552 -0
  68. package/dist/cli-bundle/chunks/chunk-6YCV7WSL.js.map +7 -0
  69. package/dist/cli-bundle/chunks/chunk-7Y53ZJIQ.js +202 -0
  70. package/dist/cli-bundle/chunks/chunk-7Y53ZJIQ.js.map +7 -0
  71. package/dist/cli-bundle/chunks/chunk-A7E7PUVX.js +157 -0
  72. package/dist/cli-bundle/chunks/chunk-A7E7PUVX.js.map +7 -0
  73. package/dist/cli-bundle/chunks/chunk-AKOOMO3T.js +90 -0
  74. package/dist/cli-bundle/chunks/chunk-AKOOMO3T.js.map +7 -0
  75. package/dist/cli-bundle/chunks/chunk-BUPWJ3IJ.js +950 -0
  76. package/dist/cli-bundle/chunks/chunk-BUPWJ3IJ.js.map +7 -0
  77. package/dist/cli-bundle/chunks/chunk-CEFIVZPG.js +79 -0
  78. package/dist/cli-bundle/chunks/chunk-CEFIVZPG.js.map +7 -0
  79. package/dist/cli-bundle/chunks/chunk-D7AOMPRH.js +349 -0
  80. package/dist/cli-bundle/chunks/chunk-D7AOMPRH.js.map +7 -0
  81. package/dist/cli-bundle/chunks/chunk-EAOG77HM.js +56 -0
  82. package/dist/cli-bundle/chunks/chunk-EAOG77HM.js.map +7 -0
  83. package/dist/cli-bundle/chunks/chunk-EGUGFSNX.js +47 -0
  84. package/dist/cli-bundle/chunks/chunk-EGUGFSNX.js.map +7 -0
  85. package/dist/cli-bundle/chunks/chunk-FM26RGSU.js +56 -0
  86. package/dist/cli-bundle/chunks/chunk-FM26RGSU.js.map +7 -0
  87. package/dist/cli-bundle/chunks/chunk-FQE6XZDB.js +435 -0
  88. package/dist/cli-bundle/chunks/chunk-FQE6XZDB.js.map +7 -0
  89. package/dist/cli-bundle/chunks/chunk-G57E5D7T.js +185 -0
  90. package/dist/cli-bundle/chunks/chunk-G57E5D7T.js.map +7 -0
  91. package/dist/cli-bundle/chunks/chunk-GN7IJPCD.js +3621 -0
  92. package/dist/cli-bundle/chunks/chunk-GN7IJPCD.js.map +7 -0
  93. package/dist/cli-bundle/chunks/chunk-JFWUHHS2.js +233 -0
  94. package/dist/cli-bundle/chunks/chunk-JFWUHHS2.js.map +7 -0
  95. package/dist/cli-bundle/chunks/chunk-JTWRXG4B.js +1861 -0
  96. package/dist/cli-bundle/chunks/chunk-JTWRXG4B.js.map +7 -0
  97. package/dist/cli-bundle/chunks/chunk-JULRTHJQ.js +648 -0
  98. package/dist/cli-bundle/chunks/chunk-JULRTHJQ.js.map +7 -0
  99. package/dist/cli-bundle/chunks/chunk-KBQY3YG5.js +122 -0
  100. package/dist/cli-bundle/chunks/chunk-KBQY3YG5.js.map +7 -0
  101. package/dist/cli-bundle/chunks/chunk-L2FXEKDB.js +185 -0
  102. package/dist/cli-bundle/chunks/chunk-L2FXEKDB.js.map +7 -0
  103. package/dist/cli-bundle/chunks/chunk-LRBOHPUE.js +189 -0
  104. package/dist/cli-bundle/chunks/chunk-LRBOHPUE.js.map +7 -0
  105. package/dist/cli-bundle/chunks/chunk-LSXGH6NE.js +5153 -0
  106. package/dist/cli-bundle/chunks/chunk-LSXGH6NE.js.map +7 -0
  107. package/dist/cli-bundle/chunks/chunk-MD7K4JYF.js +1345 -0
  108. package/dist/cli-bundle/chunks/chunk-MD7K4JYF.js.map +7 -0
  109. package/dist/cli-bundle/chunks/chunk-NGN7UV5K.js +341 -0
  110. package/dist/cli-bundle/chunks/chunk-NGN7UV5K.js.map +7 -0
  111. package/dist/cli-bundle/chunks/chunk-O7IWB35H.js +18 -0
  112. package/dist/cli-bundle/chunks/chunk-O7IWB35H.js.map +7 -0
  113. package/dist/cli-bundle/chunks/chunk-OGZEG5TT.js +2929 -0
  114. package/dist/cli-bundle/chunks/chunk-OGZEG5TT.js.map +7 -0
  115. package/dist/cli-bundle/chunks/chunk-P53TN6IA.js +674 -0
  116. package/dist/cli-bundle/chunks/chunk-P53TN6IA.js.map +7 -0
  117. package/dist/cli-bundle/chunks/chunk-PVNQLCIS.js +176 -0
  118. package/dist/cli-bundle/chunks/chunk-PVNQLCIS.js.map +7 -0
  119. package/dist/cli-bundle/chunks/chunk-PXUAZUUY.js +1680 -0
  120. package/dist/cli-bundle/chunks/chunk-PXUAZUUY.js.map +7 -0
  121. package/dist/cli-bundle/chunks/chunk-QAJBIGRA.js +20 -0
  122. package/dist/cli-bundle/chunks/chunk-QAJBIGRA.js.map +7 -0
  123. package/dist/cli-bundle/chunks/chunk-SEXQN4KL.js +60 -0
  124. package/dist/cli-bundle/chunks/chunk-SEXQN4KL.js.map +7 -0
  125. package/dist/cli-bundle/chunks/chunk-U7FMKRXH.js +362 -0
  126. package/dist/cli-bundle/chunks/chunk-U7FMKRXH.js.map +7 -0
  127. package/dist/cli-bundle/chunks/chunk-VGICHR7D.js +141 -0
  128. package/dist/cli-bundle/chunks/chunk-VGICHR7D.js.map +7 -0
  129. package/dist/cli-bundle/chunks/chunk-WDPXDQFG.js +632 -0
  130. package/dist/cli-bundle/chunks/chunk-WDPXDQFG.js.map +7 -0
  131. package/dist/cli-bundle/chunks/chunk-WJ2NAC37.js +252 -0
  132. package/dist/cli-bundle/chunks/chunk-WJ2NAC37.js.map +7 -0
  133. package/dist/cli-bundle/chunks/claim-EE4TKKCV.js +133 -0
  134. package/dist/cli-bundle/chunks/claim-EE4TKKCV.js.map +7 -0
  135. package/dist/cli-bundle/chunks/close-XY4CSAYF.js +14 -0
  136. package/dist/cli-bundle/chunks/close-XY4CSAYF.js.map +7 -0
  137. package/dist/cli-bundle/chunks/comments-AAKJQ6LW.js +104 -0
  138. package/dist/cli-bundle/chunks/comments-AAKJQ6LW.js.map +7 -0
  139. package/dist/cli-bundle/chunks/config-V3FZOKLI.js +1577 -0
  140. package/dist/cli-bundle/chunks/config-V3FZOKLI.js.map +7 -0
  141. package/dist/cli-bundle/chunks/context-RZ5QPNJB.js +1458 -0
  142. package/dist/cli-bundle/chunks/context-RZ5QPNJB.js.map +7 -0
  143. package/dist/cli-bundle/chunks/contracts-YLMH33VU.js +1245 -0
  144. package/dist/cli-bundle/chunks/contracts-YLMH33VU.js.map +7 -0
  145. package/dist/cli-bundle/chunks/create-PZVHRIZQ.js +28 -0
  146. package/dist/cli-bundle/chunks/create-PZVHRIZQ.js.map +7 -0
  147. package/dist/cli-bundle/chunks/delete-RHCTEORS.js +59 -0
  148. package/dist/cli-bundle/chunks/delete-RHCTEORS.js.map +7 -0
  149. package/dist/cli-bundle/chunks/deps-MZYCMLAO.js +229 -0
  150. package/dist/cli-bundle/chunks/deps-MZYCMLAO.js.map +7 -0
  151. package/dist/cli-bundle/chunks/docs-FXXUCZYU.js +35 -0
  152. package/dist/cli-bundle/chunks/docs-FXXUCZYU.js.map +7 -0
  153. package/dist/cli-bundle/chunks/extension-B4WL7BQU.js +25 -0
  154. package/dist/cli-bundle/chunks/extension-B4WL7BQU.js.map +7 -0
  155. package/dist/cli-bundle/chunks/files-WVOX67PE.js +286 -0
  156. package/dist/cli-bundle/chunks/files-WVOX67PE.js.map +7 -0
  157. package/dist/cli-bundle/chunks/gc-JWNF66EC.js +181 -0
  158. package/dist/cli-bundle/chunks/gc-JWNF66EC.js.map +7 -0
  159. package/dist/cli-bundle/chunks/get-LTK3HOCQ.js +198 -0
  160. package/dist/cli-bundle/chunks/get-LTK3HOCQ.js.map +7 -0
  161. package/dist/cli-bundle/chunks/health-TCWL55KM.js +1233 -0
  162. package/dist/cli-bundle/chunks/health-TCWL55KM.js.map +7 -0
  163. package/dist/cli-bundle/chunks/history-A2JUDXUE.js +21 -0
  164. package/dist/cli-bundle/chunks/history-A2JUDXUE.js.map +7 -0
  165. package/dist/cli-bundle/chunks/history-redact-ED6RFCPL.js +20 -0
  166. package/dist/cli-bundle/chunks/history-redact-ED6RFCPL.js.map +7 -0
  167. package/dist/cli-bundle/chunks/history-repair-ZWSTDRH2.js +198 -0
  168. package/dist/cli-bundle/chunks/history-repair-ZWSTDRH2.js.map +7 -0
  169. package/dist/cli-bundle/chunks/init-M2WUB4YH.js +16 -0
  170. package/dist/cli-bundle/chunks/init-M2WUB4YH.js.map +7 -0
  171. package/dist/cli-bundle/chunks/learnings-NXTWE3FR.js +48 -0
  172. package/dist/cli-bundle/chunks/learnings-NXTWE3FR.js.map +7 -0
  173. package/dist/cli-bundle/chunks/list-OGWQPC26.js +20 -0
  174. package/dist/cli-bundle/chunks/list-OGWQPC26.js.map +7 -0
  175. package/dist/cli-bundle/chunks/notes-DFS5ZGOO.js +48 -0
  176. package/dist/cli-bundle/chunks/notes-DFS5ZGOO.js.map +7 -0
  177. package/dist/cli-bundle/chunks/plan-67AB2PLM.js +1175 -0
  178. package/dist/cli-bundle/chunks/plan-67AB2PLM.js.map +7 -0
  179. package/dist/cli-bundle/chunks/register-list-query-UP3VRUFS.js +232 -0
  180. package/dist/cli-bundle/chunks/register-list-query-UP3VRUFS.js.map +7 -0
  181. package/dist/cli-bundle/chunks/register-mutation-YWSBF545.js +712 -0
  182. package/dist/cli-bundle/chunks/register-mutation-YWSBF545.js.map +7 -0
  183. package/dist/cli-bundle/chunks/register-operations-3BDTGSDH.js +374 -0
  184. package/dist/cli-bundle/chunks/register-operations-3BDTGSDH.js.map +7 -0
  185. package/dist/cli-bundle/chunks/register-setup-V56GDRUS.js +246 -0
  186. package/dist/cli-bundle/chunks/register-setup-V56GDRUS.js.map +7 -0
  187. package/dist/cli-bundle/chunks/restore-MB2ISME7.js +18 -0
  188. package/dist/cli-bundle/chunks/restore-MB2ISME7.js.map +7 -0
  189. package/dist/cli-bundle/chunks/schema-Q622KC46.js +119 -0
  190. package/dist/cli-bundle/chunks/schema-Q622KC46.js.map +7 -0
  191. package/dist/cli-bundle/chunks/search-HENBL456.js +1135 -0
  192. package/dist/cli-bundle/chunks/search-HENBL456.js.map +7 -0
  193. package/dist/cli-bundle/chunks/stats-N6H3YP2F.js +124 -0
  194. package/dist/cli-bundle/chunks/stats-N6H3YP2F.js.map +7 -0
  195. package/dist/cli-bundle/chunks/test-VNBDRJ4Z.js +32 -0
  196. package/dist/cli-bundle/chunks/test-VNBDRJ4Z.js.map +7 -0
  197. package/dist/cli-bundle/chunks/test-all-G2AZOHXI.js +332 -0
  198. package/dist/cli-bundle/chunks/test-all-G2AZOHXI.js.map +7 -0
  199. package/dist/cli-bundle/chunks/test-runs-GX5HTPSF.js +939 -0
  200. package/dist/cli-bundle/chunks/test-runs-GX5HTPSF.js.map +7 -0
  201. package/dist/cli-bundle/chunks/update-H6SCWNMA.js +22 -0
  202. package/dist/cli-bundle/chunks/update-H6SCWNMA.js.map +7 -0
  203. package/dist/cli-bundle/chunks/update-many-46HRSP2Q.js +676 -0
  204. package/dist/cli-bundle/chunks/update-many-46HRSP2Q.js.map +7 -0
  205. package/dist/cli-bundle/chunks/upgrade-H5HHM5UV.js +271 -0
  206. package/dist/cli-bundle/chunks/upgrade-H5HHM5UV.js.map +7 -0
  207. package/dist/cli-bundle/chunks/validate-TMCVKIGZ.js +1110 -0
  208. package/dist/cli-bundle/chunks/validate-TMCVKIGZ.js.map +7 -0
  209. package/dist/cli-bundle/main.js +6952 -0
  210. package/dist/cli-bundle/main.js.map +7 -0
  211. package/dist/cli.js +1 -1
  212. package/dist/core/config/nested-settings.d.ts +2 -0
  213. package/dist/core/config/nested-settings.js +17 -2
  214. package/dist/core/config/nested-settings.js.map +1 -1
  215. package/dist/core/item/item-type-definition.js +6 -2
  216. package/dist/core/item/item-type-definition.js.map +1 -1
  217. package/dist/core/item/type-registry.d.ts +4 -0
  218. package/dist/core/item/type-registry.js +10 -2
  219. package/dist/core/item/type-registry.js.map +1 -1
  220. package/dist/core/item/type-synonyms.d.ts +20 -0
  221. package/dist/core/item/type-synonyms.js +42 -0
  222. package/dist/core/item/type-synonyms.js.map +1 -0
  223. package/dist/core/search/background-refresh.d.ts +53 -0
  224. package/dist/core/search/background-refresh.js +286 -0
  225. package/dist/core/search/background-refresh.js.map +1 -0
  226. package/dist/core/search/cache.d.ts +20 -1
  227. package/dist/core/search/cache.js +76 -5
  228. package/dist/core/search/cache.js.map +1 -1
  229. package/dist/core/search/semantic-defaults.js +73 -32
  230. package/dist/core/search/semantic-defaults.js.map +1 -1
  231. package/dist/core/search/vector-stores.js +7 -3
  232. package/dist/core/search/vector-stores.js.map +1 -1
  233. package/dist/core/sentry/helpers.d.ts +1 -1
  234. package/dist/core/sentry/helpers.js +4 -4
  235. package/dist/core/sentry/helpers.js.map +1 -1
  236. package/dist/core/shared/constants.d.ts +2 -2
  237. package/dist/core/shared/constants.js +3 -3
  238. package/dist/core/shared/constants.js.map +1 -1
  239. package/dist/core/shared/html-entity-decode.d.ts +2 -1
  240. package/dist/core/shared/html-entity-decode.js +14 -9
  241. package/dist/core/shared/html-entity-decode.js.map +1 -1
  242. package/dist/core/shared/time.js +52 -2
  243. package/dist/core/shared/time.js.map +1 -1
  244. package/dist/core/store/front-matter-cache.d.ts +24 -0
  245. package/dist/core/store/front-matter-cache.js +119 -8
  246. package/dist/core/store/front-matter-cache.js.map +1 -1
  247. package/dist/core/store/item-format-migration.js +25 -15
  248. package/dist/core/store/item-format-migration.js.map +1 -1
  249. package/dist/core/store/item-store.d.ts +7 -0
  250. package/dist/core/store/item-store.js +13 -3
  251. package/dist/core/store/item-store.js.map +1 -1
  252. package/dist/core/store/settings-validator.d.ts +1 -0
  253. package/dist/core/store/settings-validator.js +7 -2
  254. package/dist/core/store/settings-validator.js.map +1 -1
  255. package/dist/core/store/settings.js +19 -3
  256. package/dist/core/store/settings.js.map +1 -1
  257. package/dist/core/telemetry/runtime.d.ts +10 -0
  258. package/dist/core/telemetry/runtime.js +86 -2
  259. package/dist/core/telemetry/runtime.js.map +1 -1
  260. package/dist/mcp/server.js +3 -3
  261. package/dist/mcp/server.js.map +1 -1
  262. package/dist/sdk/cli-contracts/tool-parameter-tables.js +4 -4
  263. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  264. package/dist/sdk/cli-contracts.js +29 -8
  265. package/dist/sdk/cli-contracts.js.map +1 -1
  266. package/dist/types.d.ts +9 -1
  267. package/dist/types.js +2 -2
  268. package/dist/types.js.map +1 -1
  269. package/docs/CONFIGURATION.md +11 -0
  270. package/docs/RELEASING.md +1 -1
  271. package/package.json +7 -5
  272. package/packages/pm-calendar/extensions/calendar/index.js +27 -2
  273. package/packages/pm-calendar/extensions/calendar/index.ts +28 -2
  274. package/scripts/bundle-cli.mjs +39 -0
@@ -0,0 +1,648 @@
1
+ import {
2
+ runExtension
3
+ } from "./chunk-OGZEG5TT.js";
4
+ import {
5
+ normalizePrefix
6
+ } from "./chunk-CEFIVZPG.js";
7
+ import {
8
+ resolveItemTypeRegistry
9
+ } from "./chunk-WDPXDQFG.js";
10
+ import {
11
+ EXIT_CODE,
12
+ GOVERNANCE_PRESET_DEFAULTS,
13
+ PM_REQUIRED_SUBDIRS,
14
+ PmCliError,
15
+ SETTINGS_DEFAULTS,
16
+ ensureRuntimeSchemaFileScaffold,
17
+ getActiveExtensionRegistrations,
18
+ pathExists,
19
+ readSettings,
20
+ resolvePmRoot,
21
+ runActiveOnWriteHooks,
22
+ writeSettings
23
+ } from "./chunk-LSXGH6NE.js";
24
+
25
+ // dist/cli/commands/init.js
26
+ import fs2 from "node:fs/promises";
27
+ import path2 from "node:path";
28
+ import readline2 from "node:readline/promises";
29
+ import { stdin as input2, stdout as output2 } from "node:process";
30
+
31
+ // dist/cli/commands/init-agent-guidance.js
32
+ import fs from "node:fs/promises";
33
+ import path from "node:path";
34
+ import readline from "node:readline/promises";
35
+ import { stdin as input, stdout as output } from "node:process";
36
+ !(function() {
37
+ try {
38
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
39
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "5a5676f5-f102-5fdd-9b33-04645e8971c2");
40
+ } catch (e2) {
41
+ }
42
+ })();
43
+ var INIT_AGENT_GUIDANCE_MODE_VALUES = ["ask", "add", "skip", "status"];
44
+ var AGENT_GUIDANCE_TARGET_FILENAMES = ["AGENTS.md", "CLAUDE.md"];
45
+ var AGENT_GUIDANCE_REQUIRED_TOKENS = [
46
+ "pm init",
47
+ "pm context",
48
+ "pm search",
49
+ "pm create",
50
+ "pm claim",
51
+ "pm files",
52
+ "pm docs",
53
+ "pm test --run",
54
+ "pm close",
55
+ "pm release",
56
+ "pm_author"
57
+ ];
58
+ var AGENT_GUIDANCE_REQUIRED_TOKEN_THRESHOLD = 8;
59
+ var AGENT_GUIDANCE_TEMPLATE_VERSION = 1;
60
+ var AGENT_GUIDANCE_START_MARKER_PREFIX = "<!-- pm-cli:agent-guidance:start:";
61
+ var AGENT_GUIDANCE_START_MARKER = `<!-- pm-cli:agent-guidance:start:v${AGENT_GUIDANCE_TEMPLATE_VERSION} -->`;
62
+ var AGENT_GUIDANCE_END_MARKER = "<!-- pm-cli:agent-guidance:end -->";
63
+ function toPortableRelativePath(projectRoot, targetPath) {
64
+ const relative = path.relative(projectRoot, targetPath);
65
+ if (relative.length === 0) {
66
+ return path.basename(targetPath);
67
+ }
68
+ return relative.split(path.sep).join("/");
69
+ }
70
+ function ensureTrailingNewline(value) {
71
+ return value.endsWith("\n") ? value : `${value}
72
+ `;
73
+ }
74
+ function detectLineEnding(value) {
75
+ return value.includes("\r\n") ? "\r\n" : "\n";
76
+ }
77
+ function findGuidanceBlockRange(content) {
78
+ const startIndex = content.indexOf(AGENT_GUIDANCE_START_MARKER_PREFIX);
79
+ if (startIndex === -1) {
80
+ return null;
81
+ }
82
+ const endMarkerIndex = content.indexOf(AGENT_GUIDANCE_END_MARKER, startIndex);
83
+ if (endMarkerIndex === -1) {
84
+ return null;
85
+ }
86
+ return {
87
+ start_index: startIndex,
88
+ end_index: endMarkerIndex + AGENT_GUIDANCE_END_MARKER.length
89
+ };
90
+ }
91
+ function hasGuidanceMarker(content) {
92
+ return findGuidanceBlockRange(content) !== null;
93
+ }
94
+ function buildAgentGuidanceBlock(lineEnding) {
95
+ const lines = [
96
+ AGENT_GUIDANCE_START_MARKER,
97
+ "## pm Workflow (Agent Quickstart)",
98
+ "",
99
+ '- Orient before mutate: `pm context --limit 10`, `pm search "<keywords>" --limit 10`, `pm list-open --limit 20`.',
100
+ "- Claim and execute: `pm claim <id>` then `pm update <id> --status in_progress`.",
101
+ '- Link evidence while coding: `pm files <id> --add ...`, `pm docs <id> --add ...`, `pm test <id> --add command="node scripts/run-tests.mjs test -- ..."`.',
102
+ '- Verify and close: `pm test <id> --run --progress`, `pm close <id> "<evidence>" --validate-close warn`, `pm release <id>`.',
103
+ "- Set `PM_AUTHOR=<stable-agent-id>` before mutation commands.",
104
+ "",
105
+ AGENT_GUIDANCE_END_MARKER,
106
+ ""
107
+ ];
108
+ return lines.join(lineEnding);
109
+ }
110
+ function upsertAgentGuidanceBlock(existingContent) {
111
+ const lineEnding = detectLineEnding(existingContent);
112
+ const nextBlock = buildAgentGuidanceBlock(lineEnding);
113
+ const existingRange = findGuidanceBlockRange(existingContent);
114
+ if (existingRange) {
115
+ const nextContent2 = ensureTrailingNewline(`${existingContent.slice(0, existingRange.start_index)}${nextBlock}${existingContent.slice(existingRange.end_index)}`);
116
+ return {
117
+ next_content: nextContent2,
118
+ changed: nextContent2 !== existingContent
119
+ };
120
+ }
121
+ const separator = existingContent.length === 0 ? "" : existingContent.endsWith("\n") ? "\n" : "\n\n";
122
+ const nextContent = ensureTrailingNewline(`${existingContent}${separator}${nextBlock}`);
123
+ return {
124
+ next_content: nextContent,
125
+ changed: nextContent !== existingContent
126
+ };
127
+ }
128
+ function resolveProjectRoot(pmRoot, cwd) {
129
+ const parent = path.dirname(pmRoot);
130
+ if (path.basename(pmRoot) === "pm" && path.basename(parent) === ".agents") {
131
+ return path.dirname(parent);
132
+ }
133
+ return path.resolve(cwd, pmRoot);
134
+ }
135
+ function resolveTargetGuidancePath(scans, projectRoot) {
136
+ const existingAgents = scans.find((entry) => path.basename(entry.file_path) === "AGENTS.md" && entry.exists);
137
+ if (existingAgents) {
138
+ return existingAgents.file_path;
139
+ }
140
+ const existingAny = scans.find((entry) => entry.exists);
141
+ if (existingAny) {
142
+ return existingAny.file_path;
143
+ }
144
+ return path.join(projectRoot, "AGENTS.md");
145
+ }
146
+ function parsePromptChoice(answer, currentDefault) {
147
+ const normalized = answer.trim().toLowerCase();
148
+ if (normalized.length === 0) {
149
+ return currentDefault;
150
+ }
151
+ if (normalized === "y" || normalized === "yes") {
152
+ return true;
153
+ }
154
+ if (normalized === "n" || normalized === "no") {
155
+ return false;
156
+ }
157
+ return currentDefault;
158
+ }
159
+ async function promptForGuidanceWrite(targetRelativePath) {
160
+ const rl = readline.createInterface({ input, output });
161
+ try {
162
+ output.write("\nAgent guidance check\n");
163
+ output.write("No AGENTS.md/CLAUDE.md file currently contains compact pm workflow guidance.\n");
164
+ const answer = await rl.question(`Add a compact pm workflow section to ${targetRelativePath}? [Y/n] `);
165
+ output.write("\n");
166
+ return parsePromptChoice(answer, true);
167
+ } finally {
168
+ rl.close();
169
+ }
170
+ }
171
+ function normalizeAgentGuidanceState(settings) {
172
+ const current = settings.agent_guidance;
173
+ return {
174
+ prompt_completed: current?.prompt_completed === true,
175
+ declined: current?.declined === true,
176
+ declined_at: typeof current?.declined_at === "string" ? current.declined_at : "",
177
+ template_version: typeof current?.template_version === "number" && Number.isInteger(current.template_version) && current.template_version > 0 ? current.template_version : AGENT_GUIDANCE_TEMPLATE_VERSION,
178
+ last_checked_files: Array.isArray(current?.last_checked_files) ? [...new Set(current.last_checked_files.map((value) => value.trim()).filter((value) => value.length > 0))].sort((left, right) => left.localeCompare(right)) : []
179
+ };
180
+ }
181
+ async function scanGuidanceFiles(projectRoot) {
182
+ const scans = [];
183
+ for (const filename of AGENT_GUIDANCE_TARGET_FILENAMES) {
184
+ const filePath = path.join(projectRoot, filename);
185
+ const exists = await pathExists(filePath);
186
+ if (!exists) {
187
+ scans.push({
188
+ file_path: filePath,
189
+ exists,
190
+ has_guidance: false,
191
+ has_marker: false
192
+ });
193
+ continue;
194
+ }
195
+ const content = await fs.readFile(filePath, "utf8");
196
+ const contentLower = content.toLowerCase();
197
+ const tokenHits = AGENT_GUIDANCE_REQUIRED_TOKENS.filter((token) => contentLower.includes(token));
198
+ const hasMarker = hasGuidanceMarker(content);
199
+ scans.push({
200
+ file_path: filePath,
201
+ exists,
202
+ has_guidance: hasMarker || tokenHits.length >= AGENT_GUIDANCE_REQUIRED_TOKEN_THRESHOLD,
203
+ has_marker: hasMarker
204
+ });
205
+ }
206
+ return scans;
207
+ }
208
+ function pushUnique(target, value) {
209
+ if (!target.includes(value)) {
210
+ target.push(value);
211
+ }
212
+ }
213
+ function applyAgentGuidanceState(settings, currentState) {
214
+ const existing = normalizeAgentGuidanceState(settings);
215
+ const changed = JSON.stringify(existing) !== JSON.stringify(currentState);
216
+ if (changed) {
217
+ settings.agent_guidance = currentState;
218
+ }
219
+ return { changed, state: currentState };
220
+ }
221
+ async function writeGuidanceFile(filePath) {
222
+ const exists = await pathExists(filePath);
223
+ const currentContent = exists ? await fs.readFile(filePath, "utf8") : "";
224
+ const nextContent = upsertAgentGuidanceBlock(currentContent);
225
+ if (!nextContent.changed) {
226
+ return { changed: false, warnings: [] };
227
+ }
228
+ await fs.writeFile(filePath, nextContent.next_content, "utf8");
229
+ return {
230
+ changed: true,
231
+ warnings: await runActiveOnWriteHooks({
232
+ path: filePath,
233
+ scope: "project",
234
+ op: "init:agent_guidance_file"
235
+ })
236
+ };
237
+ }
238
+ async function runInitAgentGuidance(options) {
239
+ const warnings = [];
240
+ const nextSteps = [];
241
+ const projectRoot = resolveProjectRoot(options.pm_root, options.cwd);
242
+ let scans = await scanGuidanceFiles(projectRoot);
243
+ const targetPath = resolveTargetGuidancePath(scans, projectRoot);
244
+ const targetRelativePath = toPortableRelativePath(projectRoot, targetPath);
245
+ const addLaterHint = "Add workflow guidance later: pm init --agent-guidance add";
246
+ let prompted = false;
247
+ let applied = false;
248
+ let skipped = false;
249
+ let state = normalizeAgentGuidanceState(options.settings);
250
+ const checkedFiles = scans.map((entry) => toPortableRelativePath(projectRoot, entry.file_path));
251
+ const presentBefore = scans.some((entry) => entry.has_guidance);
252
+ const markState = (partial) => {
253
+ state = {
254
+ ...state,
255
+ ...partial,
256
+ template_version: AGENT_GUIDANCE_TEMPLATE_VERSION,
257
+ last_checked_files: checkedFiles
258
+ };
259
+ };
260
+ if (options.mode === "status") {
261
+ if (!presentBefore) {
262
+ warnings.push("agent_guidance:missing");
263
+ pushUnique(nextSteps, addLaterHint);
264
+ }
265
+ } else if (options.mode === "skip") {
266
+ skipped = true;
267
+ markState({
268
+ prompt_completed: true,
269
+ declined: true,
270
+ declined_at: state.declined_at.length > 0 ? state.declined_at : (/* @__PURE__ */ new Date()).toISOString()
271
+ });
272
+ warnings.push("agent_guidance:explicit_skip");
273
+ pushUnique(nextSteps, addLaterHint);
274
+ } else if (options.mode === "add") {
275
+ if (!presentBefore) {
276
+ const writeResult = await writeGuidanceFile(targetPath);
277
+ warnings.push(...writeResult.warnings);
278
+ if (writeResult.changed) {
279
+ applied = true;
280
+ warnings.push(`agent_guidance:added:${targetRelativePath}`);
281
+ }
282
+ }
283
+ markState({
284
+ prompt_completed: true,
285
+ declined: false,
286
+ declined_at: ""
287
+ });
288
+ } else if (presentBefore) {
289
+ if (state.declined) {
290
+ markState({
291
+ prompt_completed: true,
292
+ declined: false,
293
+ declined_at: ""
294
+ });
295
+ }
296
+ } else if (state.prompt_completed && state.declined) {
297
+ skipped = true;
298
+ warnings.push("agent_guidance:skipped_declined");
299
+ pushUnique(nextSteps, addLaterHint);
300
+ } else if (options.interactive) {
301
+ prompted = true;
302
+ const approved = await promptForGuidanceWrite(targetRelativePath);
303
+ if (approved) {
304
+ const writeResult = await writeGuidanceFile(targetPath);
305
+ warnings.push(...writeResult.warnings);
306
+ if (writeResult.changed) {
307
+ applied = true;
308
+ warnings.push(`agent_guidance:added:${targetRelativePath}`);
309
+ }
310
+ markState({
311
+ prompt_completed: true,
312
+ declined: false,
313
+ declined_at: ""
314
+ });
315
+ } else {
316
+ skipped = true;
317
+ markState({
318
+ prompt_completed: true,
319
+ declined: true,
320
+ declined_at: (/* @__PURE__ */ new Date()).toISOString()
321
+ });
322
+ warnings.push("agent_guidance:declined");
323
+ pushUnique(nextSteps, addLaterHint);
324
+ }
325
+ } else {
326
+ warnings.push("agent_guidance:missing_non_interactive");
327
+ pushUnique(nextSteps, addLaterHint);
328
+ }
329
+ const stateUpdate = applyAgentGuidanceState(options.settings, state);
330
+ if (applied) {
331
+ scans = await scanGuidanceFiles(projectRoot);
332
+ }
333
+ const summary = {
334
+ mode: options.mode,
335
+ present: scans.some((entry) => entry.has_guidance),
336
+ prompted,
337
+ applied,
338
+ skipped,
339
+ declined: state.declined,
340
+ prompt_completed: state.prompt_completed,
341
+ template_version: state.template_version,
342
+ target_file: targetRelativePath,
343
+ checked_files: scans.map((entry) => toPortableRelativePath(projectRoot, entry.file_path)),
344
+ files_with_guidance: scans.filter((entry) => entry.has_guidance).map((entry) => toPortableRelativePath(projectRoot, entry.file_path)),
345
+ missing_files: scans.filter((entry) => !entry.exists).map((entry) => toPortableRelativePath(projectRoot, entry.file_path))
346
+ };
347
+ return {
348
+ summary,
349
+ warnings,
350
+ next_steps: nextSteps,
351
+ settings_changed: stateUpdate.changed
352
+ };
353
+ }
354
+
355
+ // dist/cli/commands/init.js
356
+ !(function() {
357
+ try {
358
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
359
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "e4370e86-cea8-5bf3-837b-de4b3c51daa1");
360
+ } catch (e2) {
361
+ }
362
+ })();
363
+ function summarizeInitResult(result) {
364
+ return {
365
+ ok: result.ok,
366
+ path: result.path,
367
+ id_prefix: result.settings.id_prefix,
368
+ governance_preset: result.governance_preset,
369
+ telemetry: {
370
+ enabled: result.settings.telemetry.enabled,
371
+ capture_level: result.settings.telemetry.capture_level
372
+ },
373
+ output_format: result.settings.output.default_format,
374
+ created_dirs_count: result.created_dirs.length,
375
+ created_dirs: result.created_dirs,
376
+ warnings: result.warnings,
377
+ wizard_used: result.wizard_used,
378
+ ...result.installed_packages ? { installed_packages: result.installed_packages } : {},
379
+ next_steps: result.next_steps,
380
+ agent_guidance: result.agent_guidance,
381
+ hint: "Re-run with --verbose for the full settings tree."
382
+ };
383
+ }
384
+ function cloneDefaults() {
385
+ return structuredClone(SETTINGS_DEFAULTS);
386
+ }
387
+ var BUILTIN_GOVERNANCE_PRESETS = ["minimal", "default", "strict"];
388
+ function normalizeInitGovernancePreset(rawValue) {
389
+ if (rawValue === void 0) {
390
+ return void 0;
391
+ }
392
+ const normalized = rawValue.trim().toLowerCase().replaceAll("-", "_");
393
+ if (normalized.length === 0) {
394
+ throw new PmCliError("--preset must not be empty", EXIT_CODE.USAGE);
395
+ }
396
+ if (normalized === "minimal" || normalized === "default" || normalized === "strict") {
397
+ return normalized;
398
+ }
399
+ if (normalized === "lite" || normalized === "minimum") {
400
+ return "minimal";
401
+ }
402
+ throw new PmCliError(`Invalid --preset value "${rawValue}". Allowed: ${BUILTIN_GOVERNANCE_PRESETS.join(", ")}`, EXIT_CODE.USAGE);
403
+ }
404
+ function normalizeOptionalInitAuthor(rawValue) {
405
+ if (rawValue === void 0) {
406
+ return void 0;
407
+ }
408
+ const normalized = rawValue.trim();
409
+ if (normalized.length === 0) {
410
+ throw new PmCliError("--author must not be empty", EXIT_CODE.USAGE);
411
+ }
412
+ return normalized;
413
+ }
414
+ function normalizeInitAgentGuidanceMode(rawValue) {
415
+ if (rawValue === void 0) {
416
+ return "ask";
417
+ }
418
+ const normalized = rawValue.trim().toLowerCase().replaceAll("-", "_");
419
+ if (normalized.length === 0) {
420
+ throw new PmCliError("--agent-guidance must not be empty", EXIT_CODE.USAGE);
421
+ }
422
+ if (normalized === "ask" || normalized === "add" || normalized === "skip" || normalized === "status") {
423
+ return normalized;
424
+ }
425
+ throw new PmCliError(`Invalid --agent-guidance value "${rawValue}". Allowed: ${INIT_AGENT_GUIDANCE_MODE_VALUES.join(", ")}`, EXIT_CODE.USAGE);
426
+ }
427
+ function parseYesNoChoice(answer, currentDefault) {
428
+ const normalized = answer.trim().toLowerCase();
429
+ if (normalized.length === 0) {
430
+ return currentDefault;
431
+ }
432
+ if (normalized === "y" || normalized === "yes") {
433
+ return true;
434
+ }
435
+ if (normalized === "n" || normalized === "no") {
436
+ return false;
437
+ }
438
+ return currentDefault;
439
+ }
440
+ function applyGovernancePreset(settings, preset) {
441
+ const knobs = GOVERNANCE_PRESET_DEFAULTS[preset];
442
+ settings.governance = {
443
+ preset,
444
+ ...knobs
445
+ };
446
+ settings.validation.parent_reference = knobs.parent_reference;
447
+ settings.validation.metadata_profile = knobs.metadata_profile;
448
+ }
449
+ function summarizeInstalledPackages(result) {
450
+ const details = result.details;
451
+ return {
452
+ installed_all: details.installed_all === true,
453
+ installed_count: typeof details.installed_count === "number" ? details.installed_count : 0,
454
+ packages: Array.isArray(details.packages) ? details.packages.map((entry) => ({
455
+ alias: typeof entry.alias === "string" ? entry.alias : "",
456
+ ok: entry.ok === true
457
+ })) : []
458
+ };
459
+ }
460
+ async function runInitWizard(initialPrefix, telemetryDefault) {
461
+ const rl = readline2.createInterface({ input: input2, output: output2 });
462
+ try {
463
+ output2.write("pm init setup wizard (agent-optimized)\n");
464
+ output2.write("This walkthrough is non-destructive and each choice can be changed later with pm config.\n\n");
465
+ output2.write("1/3 Item ID prefix\n");
466
+ output2.write("Prefix is prepended to generated IDs (for example pm-a1b2).\n");
467
+ const prefixAnswer = await rl.question(`Item ID prefix [${initialPrefix}]: `);
468
+ const resolvedPrefix = prefixAnswer.trim().length > 0 ? normalizePrefix(prefixAnswer) : initialPrefix;
469
+ output2.write("\n2/3 Governance preset\n");
470
+ output2.write("minimal: no ownership blocking, progressive create defaults, close validation off.\n");
471
+ output2.write("default: ownership conflict warnings, progressive create defaults, close validation warn.\n");
472
+ output2.write("strict: ownership blocking, strict create defaults, close validation strict.\n");
473
+ const presetAnswer = await rl.question("Governance preset [minimal/default/strict] (default: minimal): ");
474
+ const resolvedPreset = normalizeInitGovernancePreset(presetAnswer.trim().length > 0 ? presetAnswer : "minimal") ?? "minimal";
475
+ output2.write("\n3/3 Project telemetry\n");
476
+ output2.write("Telemetry helps improve reliability and can be disabled anytime via pm config.\n");
477
+ const telemetryLabel = telemetryDefault ? "Y/n" : "y/N";
478
+ const telemetryAnswer = await rl.question(`Enable telemetry for this project? [${telemetryLabel}] `);
479
+ const telemetryEnabled = parseYesNoChoice(telemetryAnswer, telemetryDefault);
480
+ output2.write("\n");
481
+ return {
482
+ prefix: resolvedPrefix,
483
+ preset: resolvedPreset,
484
+ telemetry_enabled: telemetryEnabled
485
+ };
486
+ } finally {
487
+ rl.close();
488
+ }
489
+ }
490
+ async function runInit(prefixArg, global2, options = {}) {
491
+ const cwd = process.cwd();
492
+ const pmRoot = resolvePmRoot(cwd, global2.path);
493
+ const createdDirs = [];
494
+ const warnings = [];
495
+ let wizardUsed = false;
496
+ for (const subdir of PM_REQUIRED_SUBDIRS) {
497
+ const target = subdir ? path2.join(pmRoot, subdir) : pmRoot;
498
+ const existed = await pathExists(target);
499
+ await fs2.mkdir(target, { recursive: true });
500
+ if (existed) {
501
+ warnings.push(`already_exists:${target}`);
502
+ } else {
503
+ createdDirs.push(target);
504
+ }
505
+ warnings.push(...await runActiveOnWriteHooks({
506
+ path: target,
507
+ scope: "project",
508
+ op: "init:ensure_dir"
509
+ }));
510
+ }
511
+ const settingsPath = path2.join(pmRoot, "settings.json");
512
+ const settingsExists = await pathExists(settingsPath);
513
+ let normalizedPrefix = normalizePrefix(prefixArg);
514
+ const presetFromOption = normalizeInitGovernancePreset(options.preset);
515
+ const useDefaults = options.defaults === true;
516
+ const authorFromOption = normalizeOptionalInitAuthor(options.author);
517
+ const installBundledPackages = options.withPackages === true;
518
+ const agentGuidanceMode = normalizeInitAgentGuidanceMode(options.agentGuidance);
519
+ let chosenPreset = presetFromOption;
520
+ let chosenTelemetryEnabled;
521
+ let settings;
522
+ if (settingsExists) {
523
+ settings = await readSettings(pmRoot);
524
+ warnings.push(`already_exists:${settingsPath}`);
525
+ let changed = false;
526
+ if (prefixArg !== void 0 && settings.id_prefix !== normalizedPrefix) {
527
+ settings.id_prefix = normalizedPrefix;
528
+ warnings.push(`updated:id_prefix:${normalizedPrefix}`);
529
+ changed = true;
530
+ }
531
+ if (presetFromOption !== void 0 && settings.governance.preset !== presetFromOption) {
532
+ applyGovernancePreset(settings, presetFromOption);
533
+ warnings.push(`updated:governance_preset:${presetFromOption}`);
534
+ changed = true;
535
+ }
536
+ if (authorFromOption !== void 0 && settings.author_default !== authorFromOption) {
537
+ settings.author_default = authorFromOption;
538
+ warnings.push(`updated:author_default:${authorFromOption}`);
539
+ changed = true;
540
+ }
541
+ if (changed) {
542
+ await writeSettings(pmRoot, settings);
543
+ }
544
+ } else {
545
+ if (presetFromOption === void 0 && !useDefaults && process.stdin.isTTY === true && process.stdout.isTTY === true) {
546
+ const wizardChoices = await runInitWizard(normalizedPrefix, SETTINGS_DEFAULTS.telemetry.enabled);
547
+ normalizedPrefix = wizardChoices.prefix;
548
+ chosenPreset = wizardChoices.preset;
549
+ chosenTelemetryEnabled = wizardChoices.telemetry_enabled;
550
+ wizardUsed = true;
551
+ }
552
+ const effectivePreset = chosenPreset ?? "minimal";
553
+ settings = cloneDefaults();
554
+ settings.id_prefix = normalizedPrefix;
555
+ applyGovernancePreset(settings, effectivePreset);
556
+ if (authorFromOption !== void 0) {
557
+ settings.author_default = authorFromOption;
558
+ }
559
+ if (chosenTelemetryEnabled !== void 0) {
560
+ settings.telemetry.enabled = chosenTelemetryEnabled;
561
+ settings.telemetry.first_run_prompt_completed = true;
562
+ }
563
+ await writeSettings(pmRoot, settings);
564
+ }
565
+ const agentGuidanceResult = await runInitAgentGuidance({
566
+ pm_root: pmRoot,
567
+ cwd,
568
+ mode: agentGuidanceMode,
569
+ interactive: process.stdin.isTTY === true && process.stdout.isTTY === true,
570
+ settings
571
+ });
572
+ warnings.push(...agentGuidanceResult.warnings);
573
+ if (agentGuidanceResult.settings_changed) {
574
+ await writeSettings(pmRoot, settings);
575
+ }
576
+ const runtimeSchemaScaffold = await ensureRuntimeSchemaFileScaffold(pmRoot, settings.schema);
577
+ for (const createdPath of runtimeSchemaScaffold.created_paths) {
578
+ createdDirs.push(createdPath);
579
+ warnings.push(...await runActiveOnWriteHooks({
580
+ path: createdPath,
581
+ scope: "project",
582
+ op: "init:runtime_schema_file"
583
+ }));
584
+ }
585
+ const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
586
+ for (const typeFolder of typeRegistry.folders) {
587
+ if (PM_REQUIRED_SUBDIRS.includes(typeFolder)) {
588
+ continue;
589
+ }
590
+ const target = path2.join(pmRoot, typeFolder);
591
+ const existed = await pathExists(target);
592
+ await fs2.mkdir(target, { recursive: true });
593
+ if (existed) {
594
+ warnings.push(`already_exists:${target}`);
595
+ } else {
596
+ createdDirs.push(target);
597
+ }
598
+ warnings.push(...await runActiveOnWriteHooks({
599
+ path: target,
600
+ scope: "project",
601
+ op: "init:ensure_dir"
602
+ }));
603
+ }
604
+ let installedPackages;
605
+ if (installBundledPackages) {
606
+ const packageInstallResult = await runExtension("all", { install: true, project: true }, global2);
607
+ warnings.push(...packageInstallResult.warnings);
608
+ installedPackages = summarizeInstalledPackages(packageInstallResult);
609
+ if (!installedPackages.installed_all || installedPackages.packages.some((entry) => !entry.ok)) {
610
+ throw new PmCliError("pm init --with-packages did not install all bundled packages successfully.", EXIT_CODE.GENERIC_FAILURE);
611
+ }
612
+ }
613
+ const nextSteps = [
614
+ 'Create your first item: pm create --type Task --title "<title>"',
615
+ "List active items: pm list",
616
+ "Get agent-friendly project context: pm context"
617
+ ];
618
+ if (!installBundledPackages) {
619
+ nextSteps.push("Add optional packages for richer workflows: pm install calendar --project, pm install templates --project, pm install guide-shell --project");
620
+ nextSteps.push("Or install everything bundled: pm init --with-packages (idempotent on re-run)");
621
+ } else {
622
+ nextSteps.push("Explore newly-available commands: pm cal, pm templates, pm guide");
623
+ }
624
+ nextSteps.push("Set PM_AUTHOR=<your-agent-id> so mutations attribute to the right caller.");
625
+ for (const guidanceNextStep of agentGuidanceResult.next_steps) {
626
+ if (!nextSteps.includes(guidanceNextStep)) {
627
+ nextSteps.push(guidanceNextStep);
628
+ }
629
+ }
630
+ return {
631
+ ok: true,
632
+ path: pmRoot,
633
+ settings,
634
+ created_dirs: createdDirs,
635
+ warnings,
636
+ governance_preset: settings.governance.preset,
637
+ wizard_used: wizardUsed,
638
+ ...installedPackages ? { installed_packages: installedPackages } : {},
639
+ next_steps: nextSteps,
640
+ agent_guidance: agentGuidanceResult.summary
641
+ };
642
+ }
643
+
644
+ export {
645
+ summarizeInitResult,
646
+ runInit
647
+ };
648
+ //# sourceMappingURL=chunk-JULRTHJQ.js.map