prjct-cli 1.22.0 → 1.24.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 (448) hide show
  1. package/CHANGELOG.md +230 -0
  2. package/bin/prjct +30 -13
  3. package/dist/bin/prjct-core.mjs +1748 -0
  4. package/dist/bin/prjct.mjs +17 -36672
  5. package/dist/cli/linear.mjs +14 -0
  6. package/dist/daemon/entry.mjs +1429 -0
  7. package/dist/templates.json +1 -0
  8. package/package.json +4 -5
  9. package/bin/prjct.ts +0 -342
  10. package/core/__tests__/agentic/analysis-injection.test.ts +0 -377
  11. package/core/__tests__/agentic/cache-eviction.test.ts +0 -294
  12. package/core/__tests__/agentic/command-context.test.ts +0 -281
  13. package/core/__tests__/agentic/command-executor.test.ts +0 -659
  14. package/core/__tests__/agentic/domain-classifier.test.ts +0 -330
  15. package/core/__tests__/agentic/injection-validator.test.ts +0 -255
  16. package/core/__tests__/agentic/memory-system.test.ts +0 -281
  17. package/core/__tests__/agentic/plan-mode.test.ts +0 -386
  18. package/core/__tests__/agentic/prompt-assembly.test.ts +0 -298
  19. package/core/__tests__/agentic/prompt-builder.test.ts +0 -243
  20. package/core/__tests__/agentic/response-validator.test.ts +0 -263
  21. package/core/__tests__/agentic/semantic-matching.test.ts +0 -131
  22. package/core/__tests__/agentic/smart-context.test.ts +0 -372
  23. package/core/__tests__/agentic/tech-normalizer.test.ts +0 -136
  24. package/core/__tests__/agentic/token-budget.test.ts +0 -294
  25. package/core/__tests__/ai-tools/formatters.test.ts +0 -476
  26. package/core/__tests__/domain/bm25.test.ts +0 -225
  27. package/core/__tests__/domain/change-propagator.test.ts +0 -100
  28. package/core/__tests__/domain/fibonacci.test.ts +0 -113
  29. package/core/__tests__/domain/file-hasher.test.ts +0 -146
  30. package/core/__tests__/domain/file-ranker.test.ts +0 -169
  31. package/core/__tests__/domain/git-cochange.test.ts +0 -121
  32. package/core/__tests__/domain/import-graph.test.ts +0 -156
  33. package/core/__tests__/domain/velocity.test.ts +0 -623
  34. package/core/__tests__/infrastructure/performance-tracker.test.ts +0 -328
  35. package/core/__tests__/schemas/model.test.ts +0 -272
  36. package/core/__tests__/services/dependency-validator.test.ts +0 -175
  37. package/core/__tests__/services/hierarchical-agent-resolver.test.ts +0 -359
  38. package/core/__tests__/services/nested-context-resolver.test.ts +0 -443
  39. package/core/__tests__/services/project-index.test.ts +0 -355
  40. package/core/__tests__/services/staleness-checker.test.ts +0 -204
  41. package/core/__tests__/storage/analysis-storage.test.ts +0 -641
  42. package/core/__tests__/storage/archive-storage.test.ts +0 -455
  43. package/core/__tests__/storage/safe-reader.test.ts +0 -262
  44. package/core/__tests__/storage/sqlite-migration.test.ts +0 -1016
  45. package/core/__tests__/storage/state-storage-feedback.test.ts +0 -463
  46. package/core/__tests__/storage/state-storage-history.test.ts +0 -469
  47. package/core/__tests__/storage/storage-manager.test.ts +0 -383
  48. package/core/__tests__/storage/subtask-handoff.test.ts +0 -237
  49. package/core/__tests__/types/fs.test.ts +0 -125
  50. package/core/__tests__/utils/date-helper.test.ts +0 -449
  51. package/core/__tests__/utils/output.test.ts +0 -278
  52. package/core/__tests__/utils/preserve-sections.test.ts +0 -216
  53. package/core/__tests__/utils/project-commands.test.ts +0 -71
  54. package/core/__tests__/utils/retry.test.ts +0 -381
  55. package/core/__tests__/workflow/state-machine.test.ts +0 -216
  56. package/core/agentic/agent-router.ts +0 -150
  57. package/core/agentic/anti-hallucination.ts +0 -141
  58. package/core/agentic/chain-of-thought.ts +0 -234
  59. package/core/agentic/command-classifier.ts +0 -141
  60. package/core/agentic/command-context.ts +0 -168
  61. package/core/agentic/command-executor.ts +0 -471
  62. package/core/agentic/context-builder.ts +0 -285
  63. package/core/agentic/domain-classifier.ts +0 -525
  64. package/core/agentic/environment-block.ts +0 -102
  65. package/core/agentic/ground-truth.ts +0 -706
  66. package/core/agentic/index.ts +0 -193
  67. package/core/agentic/injection-validator.ts +0 -208
  68. package/core/agentic/loop-detector.ts +0 -451
  69. package/core/agentic/memory-system.ts +0 -1547
  70. package/core/agentic/orchestrator-executor.ts +0 -579
  71. package/core/agentic/plan-mode.ts +0 -525
  72. package/core/agentic/prompt-builder.ts +0 -1069
  73. package/core/agentic/response-validator.ts +0 -98
  74. package/core/agentic/services.ts +0 -167
  75. package/core/agentic/skill-loader.ts +0 -106
  76. package/core/agentic/smart-context.ts +0 -393
  77. package/core/agentic/tech-normalizer.ts +0 -167
  78. package/core/agentic/template-executor.ts +0 -272
  79. package/core/agentic/template-loader.ts +0 -109
  80. package/core/agentic/token-budget.ts +0 -226
  81. package/core/agentic/tool-registry.ts +0 -146
  82. package/core/agents/index.ts +0 -28
  83. package/core/agents/performance.ts +0 -429
  84. package/core/ai-tools/formatters.ts +0 -341
  85. package/core/ai-tools/generator.ts +0 -144
  86. package/core/ai-tools/index.ts +0 -15
  87. package/core/ai-tools/registry.ts +0 -201
  88. package/core/bus/bus.ts +0 -314
  89. package/core/bus/index.ts +0 -8
  90. package/core/cli/linear.ts +0 -500
  91. package/core/cli/lint-meta-commentary.ts +0 -177
  92. package/core/cli/start.ts +0 -386
  93. package/core/commands/analysis.ts +0 -1274
  94. package/core/commands/analytics.ts +0 -342
  95. package/core/commands/base.ts +0 -118
  96. package/core/commands/cleanup.ts +0 -157
  97. package/core/commands/command-data.ts +0 -463
  98. package/core/commands/commands.ts +0 -306
  99. package/core/commands/context.ts +0 -238
  100. package/core/commands/design.ts +0 -77
  101. package/core/commands/index.ts +0 -19
  102. package/core/commands/maintenance.ts +0 -77
  103. package/core/commands/performance.ts +0 -114
  104. package/core/commands/planning.ts +0 -662
  105. package/core/commands/register.ts +0 -127
  106. package/core/commands/registry.ts +0 -444
  107. package/core/commands/setup.ts +0 -280
  108. package/core/commands/shipping.ts +0 -267
  109. package/core/commands/snapshots.ts +0 -297
  110. package/core/commands/uninstall.ts +0 -542
  111. package/core/commands/velocity.ts +0 -149
  112. package/core/commands/workflow.ts +0 -505
  113. package/core/config/command-context.config.json +0 -66
  114. package/core/constants/index.ts +0 -379
  115. package/core/context/generator.ts +0 -368
  116. package/core/context-tools/files-tool.ts +0 -577
  117. package/core/context-tools/imports-tool.ts +0 -400
  118. package/core/context-tools/index.ts +0 -434
  119. package/core/context-tools/recent-tool.ts +0 -301
  120. package/core/context-tools/signatures-tool.ts +0 -495
  121. package/core/context-tools/summary-tool.ts +0 -301
  122. package/core/context-tools/token-counter.ts +0 -273
  123. package/core/context-tools/types.ts +0 -253
  124. package/core/domain/agent-generator.ts +0 -186
  125. package/core/domain/agent-loader.ts +0 -419
  126. package/core/domain/analyzer.ts +0 -387
  127. package/core/domain/architecture-generator.ts +0 -108
  128. package/core/domain/bm25.ts +0 -525
  129. package/core/domain/change-propagator.ts +0 -162
  130. package/core/domain/context-estimator.ts +0 -175
  131. package/core/domain/fibonacci.ts +0 -128
  132. package/core/domain/file-hasher.ts +0 -296
  133. package/core/domain/file-ranker.ts +0 -151
  134. package/core/domain/git-cochange.ts +0 -250
  135. package/core/domain/import-graph.ts +0 -315
  136. package/core/domain/snapshot-manager.ts +0 -415
  137. package/core/domain/task-stack.ts +0 -578
  138. package/core/domain/velocity.ts +0 -470
  139. package/core/errors.ts +0 -335
  140. package/core/events/events.ts +0 -85
  141. package/core/events/index.ts +0 -8
  142. package/core/index.ts +0 -481
  143. package/core/infrastructure/agent-detector.ts +0 -135
  144. package/core/infrastructure/ai-provider.ts +0 -578
  145. package/core/infrastructure/author-detector.ts +0 -133
  146. package/core/infrastructure/capability-installer.ts +0 -76
  147. package/core/infrastructure/claude-agent.ts +0 -297
  148. package/core/infrastructure/command-installer.ts +0 -752
  149. package/core/infrastructure/config-manager.ts +0 -364
  150. package/core/infrastructure/editors-config.ts +0 -172
  151. package/core/infrastructure/path-manager.ts +0 -571
  152. package/core/infrastructure/performance-tracker.ts +0 -326
  153. package/core/infrastructure/permission-manager.ts +0 -289
  154. package/core/infrastructure/setup.ts +0 -1061
  155. package/core/infrastructure/update-checker.ts +0 -246
  156. package/core/integrations/issue-tracker/enricher.ts +0 -271
  157. package/core/integrations/issue-tracker/index.ts +0 -8
  158. package/core/integrations/issue-tracker/manager.ts +0 -286
  159. package/core/integrations/issue-tracker/types.ts +0 -310
  160. package/core/integrations/jira/cache.ts +0 -57
  161. package/core/integrations/jira/client.ts +0 -688
  162. package/core/integrations/jira/index.ts +0 -23
  163. package/core/integrations/jira/service.ts +0 -244
  164. package/core/integrations/linear/cache.ts +0 -68
  165. package/core/integrations/linear/client.ts +0 -436
  166. package/core/integrations/linear/index.ts +0 -20
  167. package/core/integrations/linear/service.ts +0 -260
  168. package/core/integrations/linear/sync.ts +0 -314
  169. package/core/outcomes/analyzer.ts +0 -286
  170. package/core/outcomes/index.ts +0 -34
  171. package/core/outcomes/recorder.ts +0 -195
  172. package/core/plugin/builtin/webhook.ts +0 -148
  173. package/core/plugin/hooks.ts +0 -315
  174. package/core/plugin/index.ts +0 -50
  175. package/core/plugin/loader.ts +0 -354
  176. package/core/plugin/registry.ts +0 -326
  177. package/core/schemas/agents.ts +0 -27
  178. package/core/schemas/analysis.ts +0 -530
  179. package/core/schemas/classification.ts +0 -91
  180. package/core/schemas/command-context.ts +0 -29
  181. package/core/schemas/enriched-task.ts +0 -291
  182. package/core/schemas/ideas.ts +0 -114
  183. package/core/schemas/index.ts +0 -53
  184. package/core/schemas/issues.ts +0 -159
  185. package/core/schemas/llm-output.ts +0 -170
  186. package/core/schemas/metrics.ts +0 -143
  187. package/core/schemas/model.ts +0 -153
  188. package/core/schemas/outcomes.ts +0 -487
  189. package/core/schemas/performance.ts +0 -128
  190. package/core/schemas/permissions.ts +0 -180
  191. package/core/schemas/prd.ts +0 -450
  192. package/core/schemas/project.ts +0 -57
  193. package/core/schemas/roadmap.ts +0 -322
  194. package/core/schemas/schemas.ts +0 -38
  195. package/core/schemas/shipped.ts +0 -109
  196. package/core/schemas/state.ts +0 -284
  197. package/core/schemas/velocity.ts +0 -103
  198. package/core/server/index.ts +0 -21
  199. package/core/server/routes-extended.ts +0 -566
  200. package/core/server/routes.ts +0 -176
  201. package/core/server/server.ts +0 -149
  202. package/core/server/sse.ts +0 -192
  203. package/core/services/agent-generator.ts +0 -385
  204. package/core/services/agent-service.ts +0 -168
  205. package/core/services/breakdown-service.ts +0 -124
  206. package/core/services/context-generator.ts +0 -445
  207. package/core/services/context-selector.ts +0 -429
  208. package/core/services/dependency-validator.ts +0 -318
  209. package/core/services/diff-generator.ts +0 -313
  210. package/core/services/doctor-service.ts +0 -423
  211. package/core/services/file-categorizer.ts +0 -448
  212. package/core/services/file-scorer.ts +0 -270
  213. package/core/services/git-analyzer.ts +0 -293
  214. package/core/services/hierarchical-agent-resolver.ts +0 -236
  215. package/core/services/hooks-service.ts +0 -685
  216. package/core/services/index.ts +0 -46
  217. package/core/services/local-state-generator.ts +0 -158
  218. package/core/services/memory-service.ts +0 -181
  219. package/core/services/nested-context-resolver.ts +0 -842
  220. package/core/services/project-index.ts +0 -911
  221. package/core/services/project-service.ts +0 -155
  222. package/core/services/session-tracker.ts +0 -287
  223. package/core/services/skill-installer.ts +0 -447
  224. package/core/services/skill-lock.ts +0 -132
  225. package/core/services/skill-service.ts +0 -306
  226. package/core/services/stack-detector.ts +0 -229
  227. package/core/services/staleness-checker.ts +0 -327
  228. package/core/services/sync-service.ts +0 -1515
  229. package/core/services/sync-verifier.ts +0 -253
  230. package/core/services/watch-service.ts +0 -312
  231. package/core/session/compaction.ts +0 -248
  232. package/core/session/index.ts +0 -35
  233. package/core/session/log-migration.ts +0 -88
  234. package/core/session/metrics.ts +0 -323
  235. package/core/session/session-log-manager.ts +0 -307
  236. package/core/session/task-session-manager.ts +0 -404
  237. package/core/session/utils.ts +0 -51
  238. package/core/storage/analysis-storage.ts +0 -373
  239. package/core/storage/archive-storage.ts +0 -205
  240. package/core/storage/database.ts +0 -575
  241. package/core/storage/ideas-storage.ts +0 -298
  242. package/core/storage/index-storage.ts +0 -523
  243. package/core/storage/index.ts +0 -79
  244. package/core/storage/metrics-storage.ts +0 -321
  245. package/core/storage/migrate-json.ts +0 -720
  246. package/core/storage/queue-storage.ts +0 -336
  247. package/core/storage/safe-reader.ts +0 -105
  248. package/core/storage/shipped-storage.ts +0 -253
  249. package/core/storage/state-storage.ts +0 -1035
  250. package/core/storage/storage-manager.ts +0 -205
  251. package/core/storage/storage.ts +0 -177
  252. package/core/storage/velocity-storage.ts +0 -149
  253. package/core/sync/auth-config.ts +0 -138
  254. package/core/sync/index.ts +0 -31
  255. package/core/sync/oauth-handler.ts +0 -143
  256. package/core/sync/sync-client.ts +0 -251
  257. package/core/sync/sync-manager.ts +0 -327
  258. package/core/tsconfig.json +0 -22
  259. package/core/types/agentic.ts +0 -760
  260. package/core/types/agents.ts +0 -150
  261. package/core/types/bus.ts +0 -193
  262. package/core/types/citations.ts +0 -22
  263. package/core/types/commands.ts +0 -399
  264. package/core/types/config.ts +0 -92
  265. package/core/types/core.ts +0 -96
  266. package/core/types/diff.ts +0 -41
  267. package/core/types/domain.ts +0 -71
  268. package/core/types/errors.ts +0 -111
  269. package/core/types/events.ts +0 -42
  270. package/core/types/fs.ts +0 -72
  271. package/core/types/index.ts +0 -510
  272. package/core/types/infrastructure.ts +0 -210
  273. package/core/types/integrations.ts +0 -31
  274. package/core/types/jira.ts +0 -51
  275. package/core/types/logger.ts +0 -17
  276. package/core/types/memory.ts +0 -313
  277. package/core/types/outcomes.ts +0 -190
  278. package/core/types/output.ts +0 -47
  279. package/core/types/plugin.ts +0 -25
  280. package/core/types/project-sync.ts +0 -129
  281. package/core/types/provider.ts +0 -163
  282. package/core/types/server.ts +0 -71
  283. package/core/types/services.ts +0 -84
  284. package/core/types/session.ts +0 -135
  285. package/core/types/stack.ts +0 -19
  286. package/core/types/storage.ts +0 -318
  287. package/core/types/sync-verifier.ts +0 -33
  288. package/core/types/sync.ts +0 -121
  289. package/core/types/task.ts +0 -72
  290. package/core/types/template.ts +0 -24
  291. package/core/types/utils.ts +0 -92
  292. package/core/types/workflow.ts +0 -23
  293. package/core/utils/agent-stream.ts +0 -140
  294. package/core/utils/animations.ts +0 -251
  295. package/core/utils/branding.ts +0 -88
  296. package/core/utils/cache.ts +0 -187
  297. package/core/utils/citations.ts +0 -39
  298. package/core/utils/collection-filters.ts +0 -209
  299. package/core/utils/date-helper.ts +0 -176
  300. package/core/utils/error-messages.ts +0 -38
  301. package/core/utils/file-helper.ts +0 -277
  302. package/core/utils/fs-helpers.ts +0 -14
  303. package/core/utils/help.ts +0 -314
  304. package/core/utils/jsonl-helper.ts +0 -290
  305. package/core/utils/keychain.ts +0 -127
  306. package/core/utils/logger.ts +0 -77
  307. package/core/utils/markdown-builder.ts +0 -280
  308. package/core/utils/next-steps.ts +0 -95
  309. package/core/utils/output.ts +0 -403
  310. package/core/utils/preserve-sections.ts +0 -218
  311. package/core/utils/project-commands.ts +0 -126
  312. package/core/utils/project-credentials.ts +0 -143
  313. package/core/utils/provider-cache.ts +0 -49
  314. package/core/utils/retry.ts +0 -318
  315. package/core/utils/runtime.ts +0 -108
  316. package/core/utils/session-helper.ts +0 -278
  317. package/core/utils/subtask-table.ts +0 -227
  318. package/core/utils/version.ts +0 -128
  319. package/core/wizard/index.ts +0 -13
  320. package/core/wizard/onboarding.ts +0 -633
  321. package/core/workflow/index.ts +0 -7
  322. package/core/workflow/state-machine.ts +0 -198
  323. package/core/workflow/workflow-preferences.ts +0 -294
  324. package/dist/core/infrastructure/command-installer.js +0 -1141
  325. package/dist/core/infrastructure/editors-config.js +0 -177
  326. package/dist/core/infrastructure/setup.js +0 -2244
  327. package/dist/core/utils/version.js +0 -141
  328. package/templates/agentic/agent-routing.md +0 -45
  329. package/templates/agentic/agents/uxui.md +0 -63
  330. package/templates/agentic/checklist-routing.md +0 -98
  331. package/templates/agentic/orchestrator.md +0 -68
  332. package/templates/agentic/task-fragmentation.md +0 -89
  333. package/templates/agents/AGENTS.md +0 -68
  334. package/templates/analysis/analyze.md +0 -84
  335. package/templates/analysis/patterns.md +0 -60
  336. package/templates/antigravity/SKILL.md +0 -39
  337. package/templates/architect/discovery.md +0 -67
  338. package/templates/architect/phases.md +0 -59
  339. package/templates/checklists/architecture.md +0 -28
  340. package/templates/checklists/code-quality.md +0 -28
  341. package/templates/checklists/data.md +0 -33
  342. package/templates/checklists/documentation.md +0 -33
  343. package/templates/checklists/infrastructure.md +0 -33
  344. package/templates/checklists/performance.md +0 -33
  345. package/templates/checklists/security.md +0 -33
  346. package/templates/checklists/testing.md +0 -33
  347. package/templates/checklists/ux-ui.md +0 -37
  348. package/templates/commands/analyze.md +0 -56
  349. package/templates/commands/auth.md +0 -234
  350. package/templates/commands/bug.md +0 -163
  351. package/templates/commands/cleanup.md +0 -19
  352. package/templates/commands/dash.md +0 -99
  353. package/templates/commands/design.md +0 -15
  354. package/templates/commands/done.md +0 -291
  355. package/templates/commands/enrich.md +0 -174
  356. package/templates/commands/git.md +0 -295
  357. package/templates/commands/history.md +0 -389
  358. package/templates/commands/idea.md +0 -88
  359. package/templates/commands/impact.md +0 -864
  360. package/templates/commands/init.md +0 -54
  361. package/templates/commands/jira.md +0 -278
  362. package/templates/commands/linear.md +0 -288
  363. package/templates/commands/merge.md +0 -206
  364. package/templates/commands/next.md +0 -80
  365. package/templates/commands/p.md +0 -67
  366. package/templates/commands/p.toml +0 -37
  367. package/templates/commands/pause.md +0 -136
  368. package/templates/commands/plan.md +0 -696
  369. package/templates/commands/prd.md +0 -356
  370. package/templates/commands/resume.md +0 -171
  371. package/templates/commands/review.md +0 -276
  372. package/templates/commands/serve.md +0 -118
  373. package/templates/commands/setup.md +0 -91
  374. package/templates/commands/ship.md +0 -475
  375. package/templates/commands/skill.md +0 -259
  376. package/templates/commands/spec.md +0 -218
  377. package/templates/commands/status.md +0 -207
  378. package/templates/commands/sync.md +0 -104
  379. package/templates/commands/task.md +0 -312
  380. package/templates/commands/test.md +0 -93
  381. package/templates/commands/update.md +0 -63
  382. package/templates/commands/verify.md +0 -204
  383. package/templates/commands/workflow.md +0 -150
  384. package/templates/config/skill-mappings.json +0 -82
  385. package/templates/context/dashboard.md +0 -256
  386. package/templates/context/roadmap.md +0 -221
  387. package/templates/cursor/commands/bug.md +0 -8
  388. package/templates/cursor/commands/done.md +0 -4
  389. package/templates/cursor/commands/pause.md +0 -6
  390. package/templates/cursor/commands/resume.md +0 -4
  391. package/templates/cursor/commands/ship.md +0 -8
  392. package/templates/cursor/commands/sync.md +0 -4
  393. package/templates/cursor/commands/task.md +0 -8
  394. package/templates/cursor/p.md +0 -29
  395. package/templates/cursor/router.mdc +0 -28
  396. package/templates/design/api.md +0 -95
  397. package/templates/design/architecture.md +0 -77
  398. package/templates/design/component.md +0 -89
  399. package/templates/design/database.md +0 -78
  400. package/templates/design/flow.md +0 -94
  401. package/templates/global/ANTIGRAVITY.md +0 -254
  402. package/templates/global/CLAUDE.md +0 -497
  403. package/templates/global/CURSOR.mdc +0 -266
  404. package/templates/global/GEMINI.md +0 -293
  405. package/templates/global/STORAGE-SPEC.md +0 -391
  406. package/templates/global/WINDSURF.md +0 -266
  407. package/templates/global/modules/CLAUDE-commands.md +0 -70
  408. package/templates/global/modules/CLAUDE-core.md +0 -105
  409. package/templates/global/modules/CLAUDE-git.md +0 -50
  410. package/templates/global/modules/CLAUDE-intelligence.md +0 -92
  411. package/templates/global/modules/CLAUDE-storage.md +0 -50
  412. package/templates/global/modules/module-config.json +0 -36
  413. package/templates/mcp-config.json +0 -19
  414. package/templates/permissions/default.jsonc +0 -60
  415. package/templates/permissions/permissive.jsonc +0 -49
  416. package/templates/permissions/strict.jsonc +0 -58
  417. package/templates/planning-methodology.md +0 -195
  418. package/templates/skills/code-review.md +0 -47
  419. package/templates/skills/debug.md +0 -61
  420. package/templates/skills/refactor.md +0 -47
  421. package/templates/subagents/agent-base.md +0 -20
  422. package/templates/subagents/domain/backend.md +0 -109
  423. package/templates/subagents/domain/database.md +0 -121
  424. package/templates/subagents/domain/devops.md +0 -152
  425. package/templates/subagents/domain/frontend.md +0 -103
  426. package/templates/subagents/domain/testing.md +0 -169
  427. package/templates/subagents/pm-expert.md +0 -366
  428. package/templates/subagents/workflow/chief-architect.md +0 -657
  429. package/templates/subagents/workflow/prjct-planner.md +0 -159
  430. package/templates/subagents/workflow/prjct-shipper.md +0 -188
  431. package/templates/subagents/workflow/prjct-workflow.md +0 -98
  432. package/templates/tools/bash.txt +0 -22
  433. package/templates/tools/edit.txt +0 -18
  434. package/templates/tools/glob.txt +0 -19
  435. package/templates/tools/grep.txt +0 -21
  436. package/templates/tools/read.txt +0 -14
  437. package/templates/tools/task.txt +0 -20
  438. package/templates/tools/webfetch.txt +0 -16
  439. package/templates/tools/websearch.txt +0 -18
  440. package/templates/tools/write.txt +0 -17
  441. package/templates/windsurf/router.md +0 -28
  442. package/templates/windsurf/workflows/bug.md +0 -8
  443. package/templates/windsurf/workflows/done.md +0 -4
  444. package/templates/windsurf/workflows/pause.md +0 -4
  445. package/templates/windsurf/workflows/resume.md +0 -4
  446. package/templates/windsurf/workflows/ship.md +0 -8
  447. package/templates/windsurf/workflows/sync.md +0 -4
  448. package/templates/windsurf/workflows/task.md +0 -8
@@ -1,2244 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __esm = (fn, res) => function __init() {
10
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
- };
12
- var __export = (target, all) => {
13
- for (var name in all)
14
- __defProp(target, name, { get: all[name], enumerable: true });
15
- };
16
- var __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from === "object" || typeof from === "function") {
18
- for (let key of __getOwnPropNames(from))
19
- if (!__hasOwnProp.call(to, key) && key !== except)
20
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
- }
22
- return to;
23
- };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
- mod
31
- ));
32
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
-
34
- // core/utils/fs-helpers.ts
35
- async function fileExists(filePath) {
36
- try {
37
- await import_promises.default.access(filePath);
38
- return true;
39
- } catch {
40
- return false;
41
- }
42
- }
43
- var import_promises;
44
- var init_fs_helpers = __esm({
45
- "core/utils/fs-helpers.ts"() {
46
- "use strict";
47
- import_promises = __toESM(require("node:fs/promises"));
48
- __name(fileExists, "fileExists");
49
- }
50
- });
51
-
52
- // core/schemas/model.ts
53
- function compareSemver(a, b) {
54
- const pa = a.split(".").map(Number);
55
- const pb = b.split(".").map(Number);
56
- for (let i = 0; i < 3; i++) {
57
- const va = pa[i] ?? 0;
58
- const vb = pb[i] ?? 0;
59
- if (va < vb) return -1;
60
- if (va > vb) return 1;
61
- }
62
- return 0;
63
- }
64
- var import_zod, ClaudeModelSchema, GeminiModelSchema, AIModelSchema, ModelMetadataSchema, ModelPreferenceSchema;
65
- var init_model = __esm({
66
- "core/schemas/model.ts"() {
67
- "use strict";
68
- import_zod = require("zod");
69
- ClaudeModelSchema = import_zod.z.enum(["opus", "sonnet", "haiku"]);
70
- GeminiModelSchema = import_zod.z.enum(["2.5-pro", "2.5-flash", "2.0-flash"]);
71
- AIModelSchema = import_zod.z.string().min(1);
72
- ModelMetadataSchema = import_zod.z.object({
73
- /** Provider name (e.g., 'claude', 'gemini') */
74
- provider: import_zod.z.string(),
75
- /** Model identifier (e.g., 'opus', 'sonnet', '2.5-pro') */
76
- model: import_zod.z.string(),
77
- /** CLI version used */
78
- cliVersion: import_zod.z.string().optional(),
79
- /** When this was recorded */
80
- recordedAt: import_zod.z.string()
81
- });
82
- ModelPreferenceSchema = import_zod.z.object({
83
- /** Preferred model for this project */
84
- preferredModel: import_zod.z.string().optional(),
85
- /** Model used for last analysis (for mismatch detection) */
86
- lastAnalysisModel: ModelMetadataSchema.optional()
87
- });
88
- __name(compareSemver, "compareSemver");
89
- }
90
- });
91
-
92
- // core/utils/provider-cache.ts
93
- async function readProviderCache() {
94
- try {
95
- const raw = await import_promises2.default.readFile(CACHE_FILE, "utf-8");
96
- const cache = JSON.parse(raw);
97
- if (!cache.timestamp || !cache.detection) return null;
98
- const age = Date.now() - new Date(cache.timestamp).getTime();
99
- if (age > TTL_MS) return null;
100
- return cache.detection;
101
- } catch {
102
- return null;
103
- }
104
- }
105
- async function writeProviderCache(detection) {
106
- const cache = {
107
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
108
- detection
109
- };
110
- await import_promises2.default.mkdir(CACHE_DIR, { recursive: true });
111
- await import_promises2.default.writeFile(CACHE_FILE, JSON.stringify(cache, null, 2));
112
- }
113
- var import_promises2, import_node_os, import_node_path2, CACHE_DIR, CACHE_FILE, TTL_MS;
114
- var init_provider_cache = __esm({
115
- "core/utils/provider-cache.ts"() {
116
- "use strict";
117
- import_promises2 = __toESM(require("node:fs/promises"));
118
- import_node_os = __toESM(require("node:os"));
119
- import_node_path2 = __toESM(require("node:path"));
120
- CACHE_DIR = import_node_path2.default.join(import_node_os.default.homedir(), ".prjct-cli", "cache");
121
- CACHE_FILE = import_node_path2.default.join(CACHE_DIR, "providers.json");
122
- TTL_MS = 10 * 60 * 1e3;
123
- __name(readProviderCache, "readProviderCache");
124
- __name(writeProviderCache, "writeProviderCache");
125
- }
126
- });
127
-
128
- // core/infrastructure/ai-provider.ts
129
- var ai_provider_exports = {};
130
- __export(ai_provider_exports, {
131
- AntigravityProvider: () => AntigravityProvider,
132
- ClaudeProvider: () => ClaudeProvider,
133
- CursorProvider: () => CursorProvider,
134
- GeminiProvider: () => GeminiProvider,
135
- Providers: () => Providers,
136
- WindsurfProvider: () => WindsurfProvider,
137
- detectAllProviders: () => detectAllProviders,
138
- detectAntigravity: () => detectAntigravity,
139
- detectCursorProject: () => detectCursorProject,
140
- detectProvider: () => detectProvider,
141
- detectWindsurfProject: () => detectWindsurfProject,
142
- getActiveProvider: () => getActiveProvider,
143
- getCommandsDir: () => getCommandsDir,
144
- getGlobalContextPath: () => getGlobalContextPath,
145
- getGlobalSettingsPath: () => getGlobalSettingsPath,
146
- getProjectCommandsPath: () => getProjectCommandsPath,
147
- getProviderBranding: () => getProviderBranding,
148
- getSkillsPath: () => getSkillsPath,
149
- hasProviderConfig: () => hasProviderConfig,
150
- needsCursorRouterRegeneration: () => needsCursorRouterRegeneration,
151
- needsWindsurfRouterRegeneration: () => needsWindsurfRouterRegeneration,
152
- selectProvider: () => selectProvider,
153
- validateCliVersion: () => validateCliVersion
154
- });
155
- async function whichCommand(command) {
156
- try {
157
- const { stdout } = await execAsync(`which ${command}`, { timeout: SPAWN_TIMEOUT_MS });
158
- return stdout.trim();
159
- } catch {
160
- return null;
161
- }
162
- }
163
- async function getCliVersion(command) {
164
- try {
165
- const { stdout } = await execAsync(`${command} --version`, { timeout: SPAWN_TIMEOUT_MS });
166
- const match = stdout.match(/\d+\.\d+\.\d+/);
167
- return match ? match[0] : stdout.trim();
168
- } catch {
169
- return null;
170
- }
171
- }
172
- async function detectProvider(provider) {
173
- const config = Providers[provider];
174
- if (!config.cliCommand) {
175
- return { installed: false };
176
- }
177
- const cliPath = await whichCommand(config.cliCommand);
178
- if (!cliPath) {
179
- return { installed: false };
180
- }
181
- const version = await getCliVersion(config.cliCommand);
182
- const versionWarning = validateCliVersion(provider, version || void 0);
183
- return {
184
- installed: true,
185
- version: version || void 0,
186
- path: cliPath,
187
- versionWarning: versionWarning || void 0
188
- };
189
- }
190
- function validateCliVersion(provider, version) {
191
- const config = Providers[provider];
192
- if (!config.minCliVersion || !version) return null;
193
- if (compareSemver(version, config.minCliVersion) < 0) {
194
- return `\u26A0\uFE0F ${config.displayName} v${version} is below minimum v${config.minCliVersion}. Some features may not work correctly.`;
195
- }
196
- return null;
197
- }
198
- async function detectAllProviders(refresh = false) {
199
- if (!refresh) {
200
- const cached = await readProviderCache();
201
- if (cached) return cached;
202
- }
203
- const [claude, gemini] = await Promise.all([detectProvider("claude"), detectProvider("gemini")]);
204
- const detection = { claude, gemini };
205
- await writeProviderCache(detection).catch(() => {
206
- });
207
- return detection;
208
- }
209
- async function getActiveProvider(projectProvider) {
210
- if (projectProvider && Providers[projectProvider]) {
211
- return Providers[projectProvider];
212
- }
213
- const detection = await detectAllProviders();
214
- if (detection.claude.installed && !detection.gemini.installed) {
215
- return ClaudeProvider;
216
- }
217
- if (detection.gemini.installed && !detection.claude.installed) {
218
- return GeminiProvider;
219
- }
220
- return ClaudeProvider;
221
- }
222
- async function hasProviderConfig(provider) {
223
- const config = Providers[provider];
224
- if (!config.configDir) {
225
- return false;
226
- }
227
- return fileExists(config.configDir);
228
- }
229
- function getProviderBranding(provider) {
230
- const commitFooter = `Generated with [p/](https://www.prjct.app/)`;
231
- const signatures = {
232
- claude: "\u26A1 prjct + Claude",
233
- gemini: "\u26A1 prjct + Gemini",
234
- cursor: "\u26A1 prjct + Cursor",
235
- antigravity: "\u26A1 prjct + Antigravity",
236
- windsurf: "\u26A1 prjct + Windsurf"
237
- };
238
- return {
239
- commitFooter,
240
- signature: signatures[provider] || "\u26A1 prjct"
241
- };
242
- }
243
- async function detectCursorProject(projectRoot) {
244
- const cursorDir = import_node_path3.default.join(projectRoot, ".cursor");
245
- const rulesDir = import_node_path3.default.join(cursorDir, "rules");
246
- const routerPath = import_node_path3.default.join(rulesDir, "prjct.mdc");
247
- const [detected, routerInstalled] = await Promise.all([
248
- fileExists(cursorDir),
249
- fileExists(routerPath)
250
- ]);
251
- return {
252
- detected,
253
- routerInstalled,
254
- projectRoot: detected ? projectRoot : void 0
255
- };
256
- }
257
- async function needsCursorRouterRegeneration(projectRoot) {
258
- const detection = await detectCursorProject(projectRoot);
259
- return detection.detected && !detection.routerInstalled;
260
- }
261
- async function detectWindsurfProject(projectRoot) {
262
- const windsurfDir = import_node_path3.default.join(projectRoot, ".windsurf");
263
- const rulesDir = import_node_path3.default.join(windsurfDir, "rules");
264
- const routerPath = import_node_path3.default.join(rulesDir, "prjct.md");
265
- const [detected, routerInstalled] = await Promise.all([
266
- fileExists(windsurfDir),
267
- fileExists(routerPath)
268
- ]);
269
- return {
270
- detected,
271
- routerInstalled,
272
- projectRoot: detected ? projectRoot : void 0
273
- };
274
- }
275
- async function needsWindsurfRouterRegeneration(projectRoot) {
276
- const detection = await detectWindsurfProject(projectRoot);
277
- return detection.detected && !detection.routerInstalled;
278
- }
279
- async function detectAntigravity() {
280
- const configPath = AntigravityProvider.configDir;
281
- if (!configPath) {
282
- return { installed: false, skillInstalled: false };
283
- }
284
- const skillPath = import_node_path3.default.join(configPath, "skills", "prjct", "SKILL.md");
285
- const [installed, skillInstalled] = await Promise.all([
286
- fileExists(configPath),
287
- fileExists(skillPath)
288
- ]);
289
- return {
290
- installed,
291
- skillInstalled,
292
- configPath: installed ? configPath : void 0
293
- };
294
- }
295
- function getGlobalContextPath(provider) {
296
- const config = Providers[provider];
297
- if (!config.configDir) {
298
- return null;
299
- }
300
- return import_node_path3.default.join(config.configDir, config.contextFile);
301
- }
302
- function getGlobalSettingsPath(provider) {
303
- const config = Providers[provider];
304
- if (!config.configDir || !config.settingsFile) {
305
- return null;
306
- }
307
- return import_node_path3.default.join(config.configDir, config.settingsFile);
308
- }
309
- function getSkillsPath(provider) {
310
- return Providers[provider].skillsDir;
311
- }
312
- function getCommandsDir(provider) {
313
- return Providers[provider].commandsDir;
314
- }
315
- function getProjectCommandsPath(provider, projectRoot) {
316
- const config = Providers[provider];
317
- return import_node_path3.default.join(projectRoot, config.commandsDir);
318
- }
319
- async function selectProvider() {
320
- const detection = await detectAllProviders();
321
- const claudeInstalled = detection.claude.installed;
322
- const geminiInstalled = detection.gemini.installed;
323
- if (!claudeInstalled && !geminiInstalled) {
324
- return {
325
- provider: "claude",
326
- userSelected: false,
327
- detection
328
- };
329
- }
330
- if (claudeInstalled && !geminiInstalled) {
331
- return {
332
- provider: "claude",
333
- userSelected: false,
334
- detection
335
- };
336
- }
337
- if (geminiInstalled && !claudeInstalled) {
338
- return {
339
- provider: "gemini",
340
- userSelected: false,
341
- detection
342
- };
343
- }
344
- return {
345
- provider: "claude",
346
- userSelected: true,
347
- // Indicates user should be prompted
348
- detection
349
- };
350
- }
351
- var import_node_child_process2, import_node_os2, import_node_path3, import_node_util, execAsync, SPAWN_TIMEOUT_MS, ClaudeProvider, GeminiProvider, AntigravityProvider, CursorProvider, WindsurfProvider, Providers;
352
- var init_ai_provider = __esm({
353
- "core/infrastructure/ai-provider.ts"() {
354
- "use strict";
355
- import_node_child_process2 = require("node:child_process");
356
- import_node_os2 = __toESM(require("node:os"));
357
- import_node_path3 = __toESM(require("node:path"));
358
- import_node_util = require("node:util");
359
- init_model();
360
- init_fs_helpers();
361
- init_provider_cache();
362
- execAsync = (0, import_node_util.promisify)(import_node_child_process2.exec);
363
- SPAWN_TIMEOUT_MS = 2e3;
364
- ClaudeProvider = {
365
- name: "claude",
366
- displayName: "Claude Code",
367
- cliCommand: "claude",
368
- configDir: import_node_path3.default.join(import_node_os2.default.homedir(), ".claude"),
369
- contextFile: "CLAUDE.md",
370
- skillsDir: import_node_path3.default.join(import_node_os2.default.homedir(), ".claude", "skills"),
371
- commandsDir: ".claude/commands",
372
- commandFormat: "md",
373
- settingsFile: "settings.json",
374
- projectSettingsFile: "settings.local.json",
375
- ignoreFile: ".claudeignore",
376
- websiteUrl: "https://www.anthropic.com/claude",
377
- docsUrl: "https://docs.anthropic.com/claude-code",
378
- defaultModel: "sonnet",
379
- supportedModels: ["opus", "sonnet", "haiku"],
380
- minCliVersion: "1.0.0"
381
- };
382
- GeminiProvider = {
383
- name: "gemini",
384
- displayName: "Gemini CLI",
385
- cliCommand: "gemini",
386
- configDir: import_node_path3.default.join(import_node_os2.default.homedir(), ".gemini"),
387
- contextFile: "GEMINI.md",
388
- skillsDir: import_node_path3.default.join(import_node_os2.default.homedir(), ".gemini", "skills"),
389
- commandsDir: ".gemini/commands",
390
- commandFormat: "toml",
391
- settingsFile: "settings.json",
392
- projectSettingsFile: "settings.json",
393
- ignoreFile: ".geminiignore",
394
- websiteUrl: "https://geminicli.com",
395
- docsUrl: "https://geminicli.com/docs",
396
- defaultModel: "2.5-flash",
397
- supportedModels: ["2.5-pro", "2.5-flash", "2.0-flash"],
398
- minCliVersion: "1.0.0"
399
- };
400
- AntigravityProvider = {
401
- name: "antigravity",
402
- displayName: "Google Antigravity",
403
- cliCommand: null,
404
- // Not a CLI command, but a platform/app
405
- configDir: import_node_path3.default.join(import_node_os2.default.homedir(), ".gemini", "antigravity"),
406
- contextFile: "ANTIGRAVITY.md",
407
- skillsDir: import_node_path3.default.join(import_node_os2.default.homedir(), ".gemini", "antigravity", "global_skills"),
408
- commandsDir: ".agent/skills",
409
- // Antigravity uses .agent/skills in projects
410
- commandFormat: "md",
411
- // Uses SKILL.md
412
- settingsFile: "mcp_config.json",
413
- // Uses MCP config
414
- projectSettingsFile: null,
415
- ignoreFile: ".agentignore",
416
- // Assumed
417
- websiteUrl: "https://gemini.google.com/app/antigravity",
418
- docsUrl: "https://gemini.google.com/app/antigravity",
419
- defaultModel: null,
420
- // Platform-managed
421
- supportedModels: [],
422
- minCliVersion: null
423
- };
424
- CursorProvider = {
425
- name: "cursor",
426
- displayName: "Cursor IDE",
427
- cliCommand: null,
428
- // Not a CLI - GUI app
429
- configDir: null,
430
- // No global config directory
431
- contextFile: "prjct.mdc",
432
- // Uses .mdc format with frontmatter
433
- skillsDir: null,
434
- // No skills directory
435
- commandsDir: ".cursor/commands",
436
- rulesDir: ".cursor/rules",
437
- // Cursor-specific: rules directory
438
- commandFormat: "md",
439
- settingsFile: null,
440
- projectSettingsFile: null,
441
- ignoreFile: ".cursorignore",
442
- isProjectLevel: true,
443
- // Config is project-level only
444
- websiteUrl: "https://cursor.com",
445
- docsUrl: "https://cursor.com/docs",
446
- defaultModel: null,
447
- // Multi-model IDE, user selects
448
- supportedModels: [],
449
- minCliVersion: null
450
- };
451
- WindsurfProvider = {
452
- name: "windsurf",
453
- displayName: "Windsurf IDE",
454
- cliCommand: null,
455
- // Not a CLI - GUI app
456
- configDir: null,
457
- // No global config directory
458
- contextFile: "prjct.md",
459
- // Uses .md format (not .mdc)
460
- skillsDir: null,
461
- // No skills directory
462
- commandsDir: ".windsurf/workflows",
463
- // Windsurf uses "workflows" not "commands"
464
- rulesDir: ".windsurf/rules",
465
- commandFormat: "md",
466
- settingsFile: null,
467
- projectSettingsFile: null,
468
- ignoreFile: ".windsurfignore",
469
- isProjectLevel: true,
470
- // Config is project-level only
471
- websiteUrl: "https://windsurf.com",
472
- docsUrl: "https://docs.windsurf.com",
473
- defaultModel: null,
474
- // Multi-model IDE, user selects
475
- supportedModels: [],
476
- minCliVersion: null
477
- };
478
- Providers = {
479
- claude: ClaudeProvider,
480
- gemini: GeminiProvider,
481
- cursor: CursorProvider,
482
- antigravity: AntigravityProvider,
483
- windsurf: WindsurfProvider
484
- };
485
- __name(whichCommand, "whichCommand");
486
- __name(getCliVersion, "getCliVersion");
487
- __name(detectProvider, "detectProvider");
488
- __name(validateCliVersion, "validateCliVersion");
489
- __name(detectAllProviders, "detectAllProviders");
490
- __name(getActiveProvider, "getActiveProvider");
491
- __name(hasProviderConfig, "hasProviderConfig");
492
- __name(getProviderBranding, "getProviderBranding");
493
- __name(detectCursorProject, "detectCursorProject");
494
- __name(needsCursorRouterRegeneration, "needsCursorRouterRegeneration");
495
- __name(detectWindsurfProject, "detectWindsurfProject");
496
- __name(needsWindsurfRouterRegeneration, "needsWindsurfRouterRegeneration");
497
- __name(detectAntigravity, "detectAntigravity");
498
- __name(getGlobalContextPath, "getGlobalContextPath");
499
- __name(getGlobalSettingsPath, "getGlobalSettingsPath");
500
- __name(getSkillsPath, "getSkillsPath");
501
- __name(getCommandsDir, "getCommandsDir");
502
- __name(getProjectCommandsPath, "getProjectCommandsPath");
503
- __name(selectProvider, "selectProvider");
504
- }
505
- });
506
-
507
- // core/infrastructure/setup.ts
508
- var setup_exports = {};
509
- __export(setup_exports, {
510
- hasCursorProject: () => hasCursorProject,
511
- hasWindsurfProject: () => hasWindsurfProject,
512
- installAntigravitySkill: () => installAntigravitySkill,
513
- installCursorProject: () => installCursorProject,
514
- installWindsurfProject: () => installWindsurfProject,
515
- needsAntigravityInstallation: () => needsAntigravityInstallation,
516
- needsCursorRegeneration: () => needsCursorRegeneration,
517
- needsWindsurfRegeneration: () => needsWindsurfRegeneration,
518
- run: () => run
519
- });
520
- module.exports = __toCommonJS(setup_exports);
521
- var import_node_child_process3 = require("node:child_process");
522
- var import_promises5 = __toESM(require("node:fs/promises"));
523
- var import_node_os5 = __toESM(require("node:os"));
524
- var import_node_path6 = __toESM(require("node:path"));
525
- var import_chalk = __toESM(require("chalk"));
526
-
527
- // core/constants/index.ts
528
- var TIMEOUTS = {
529
- /** Tool availability checks (git --version, npm --version) */
530
- TOOL_CHECK: 5e3,
531
- /** Standard git operations (status, add, commit) */
532
- GIT_OPERATION: 1e4,
533
- /** Git clone with --depth 1 */
534
- GIT_CLONE: 6e4,
535
- /** HTTP fetch/API requests */
536
- API_REQUEST: 3e4,
537
- /** npm install -g (CLI installation) - 2 minutes */
538
- NPM_INSTALL: 12e4,
539
- /** User-defined workflow hooks */
540
- WORKFLOW_HOOK: 6e4
541
- };
542
- function getTimeout(key) {
543
- const envVar = `PRJCT_TIMEOUT_${key}`;
544
- const envValue = process.env[envVar];
545
- if (envValue) {
546
- const parsed = Number.parseInt(envValue, 10);
547
- if (!Number.isNaN(parsed) && parsed > 0) {
548
- return parsed;
549
- }
550
- }
551
- return TIMEOUTS[key];
552
- }
553
- __name(getTimeout, "getTimeout");
554
-
555
- // core/services/dependency-validator.ts
556
- var import_node_child_process = require("node:child_process");
557
-
558
- // core/utils/error-messages.ts
559
- function createError(message, hint, options) {
560
- return {
561
- message,
562
- hint,
563
- ...options
564
- };
565
- }
566
- __name(createError, "createError");
567
-
568
- // core/services/dependency-validator.ts
569
- var TOOLS = {
570
- git: {
571
- name: "git",
572
- command: "git --version",
573
- versionRegex: /git version ([\d.]+)/,
574
- required: true,
575
- installHint: "Install Git: https://git-scm.com/downloads",
576
- docs: "https://git-scm.com/doc"
577
- },
578
- node: {
579
- name: "node",
580
- command: "node --version",
581
- versionRegex: /v([\d.]+)/,
582
- required: true,
583
- installHint: "Install Node.js: https://nodejs.org",
584
- docs: "https://nodejs.org/docs"
585
- },
586
- bun: {
587
- name: "bun",
588
- command: "bun --version",
589
- versionRegex: /([\d.]+)/,
590
- required: false,
591
- installHint: "Install Bun: curl -fsSL https://bun.sh/install | bash",
592
- docs: "https://bun.sh/docs"
593
- },
594
- gh: {
595
- name: "gh",
596
- command: "gh --version",
597
- versionRegex: /gh version ([\d.]+)/,
598
- required: false,
599
- installHint: "Install GitHub CLI: https://cli.github.com",
600
- docs: "https://cli.github.com/manual"
601
- },
602
- npm: {
603
- name: "npm",
604
- command: "npm --version",
605
- versionRegex: /([\d.]+)/,
606
- required: false,
607
- installHint: "npm comes with Node.js: https://nodejs.org"
608
- },
609
- claude: {
610
- name: "claude",
611
- command: "claude --version",
612
- versionRegex: /claude ([\d.]+)/,
613
- required: false,
614
- installHint: "Install Claude Code: npm install -g @anthropic-ai/claude-code",
615
- docs: "https://docs.anthropic.com/claude-code"
616
- },
617
- gemini: {
618
- name: "gemini",
619
- command: "gemini --version",
620
- versionRegex: /gemini ([\d.]+)/,
621
- required: false,
622
- installHint: "Install Gemini CLI: npm install -g @google/gemini-cli",
623
- docs: "https://ai.google.dev/gemini-api/docs"
624
- }
625
- };
626
- var DependencyValidator = class {
627
- static {
628
- __name(this, "DependencyValidator");
629
- }
630
- cache = /* @__PURE__ */ new Map();
631
- cacheTimeout = 6e4;
632
- // 1 minute cache
633
- cacheTimestamps = /* @__PURE__ */ new Map();
634
- /**
635
- * Check if a tool is available
636
- * Uses caching to avoid repeated execSync calls
637
- */
638
- checkTool(toolName) {
639
- const cached = this.getCached(toolName);
640
- if (cached) return cached;
641
- const definition = TOOLS[toolName];
642
- if (!definition) {
643
- return this.checkUnknownTool(toolName);
644
- }
645
- const status = this.executeCheck(definition);
646
- this.setCache(toolName, status);
647
- return status;
648
- }
649
- /**
650
- * Ensure a tool is available, throw helpful error if not
651
- * Use this before operations that require a specific tool
652
- */
653
- ensureTool(toolName) {
654
- const status = this.checkTool(toolName);
655
- if (!status.available) {
656
- const definition = TOOLS[toolName];
657
- const error = status.error || {
658
- message: `${toolName} is not available`,
659
- hint: definition?.installHint || `Install ${toolName} and try again`,
660
- docs: definition?.docs
661
- };
662
- throw new DependencyError(error);
663
- }
664
- }
665
- /**
666
- * Ensure multiple tools are available
667
- */
668
- ensureTools(toolNames) {
669
- const missing = [];
670
- for (const name of toolNames) {
671
- const status = this.checkTool(name);
672
- if (!status.available) {
673
- missing.push(name);
674
- }
675
- }
676
- if (missing.length > 0) {
677
- const hints = missing.map((name) => {
678
- const def = TOOLS[name];
679
- return def ? ` ${name}: ${def.installHint}` : ` ${name}: Install and try again`;
680
- }).join("\n");
681
- throw new DependencyError({
682
- message: `Missing required tools: ${missing.join(", ")}`,
683
- hint: `Install the following:
684
- ${hints}`
685
- });
686
- }
687
- }
688
- /**
689
- * Check if tool is available (boolean convenience method)
690
- */
691
- isAvailable(toolName) {
692
- return this.checkTool(toolName).available;
693
- }
694
- /**
695
- * Get tool version if available
696
- */
697
- getVersion(toolName) {
698
- return this.checkTool(toolName).version;
699
- }
700
- /**
701
- * Check multiple tools and return summary
702
- */
703
- checkAll(toolNames) {
704
- const names = toolNames || Object.keys(TOOLS);
705
- const results = /* @__PURE__ */ new Map();
706
- for (const name of names) {
707
- results.set(name, this.checkTool(name));
708
- }
709
- return results;
710
- }
711
- /**
712
- * Clear the cache (useful for tests or after installations)
713
- */
714
- clearCache() {
715
- this.cache.clear();
716
- this.cacheTimestamps.clear();
717
- }
718
- // ==========================================================================
719
- // PRIVATE METHODS
720
- // ==========================================================================
721
- executeCheck(definition) {
722
- try {
723
- const output = (0, import_node_child_process.execSync)(definition.command, {
724
- encoding: "utf-8",
725
- stdio: ["pipe", "pipe", "pipe"],
726
- timeout: 5e3
727
- // 5 second timeout
728
- });
729
- let version;
730
- if (definition.versionRegex) {
731
- const match = output.match(definition.versionRegex);
732
- version = match ? match[1] : void 0;
733
- }
734
- return { available: true, version };
735
- } catch {
736
- return {
737
- available: false,
738
- error: createError(
739
- `${definition.name} is not installed or not in PATH`,
740
- definition.installHint,
741
- { docs: definition.docs }
742
- )
743
- };
744
- }
745
- }
746
- checkUnknownTool(toolName) {
747
- try {
748
- (0, import_node_child_process.execSync)(`${toolName} --version`, {
749
- encoding: "utf-8",
750
- stdio: ["pipe", "pipe", "pipe"],
751
- timeout: 5e3
752
- });
753
- return { available: true };
754
- } catch {
755
- try {
756
- (0, import_node_child_process.execSync)(`${toolName} -v`, {
757
- encoding: "utf-8",
758
- stdio: ["pipe", "pipe", "pipe"],
759
- timeout: 5e3
760
- });
761
- return { available: true };
762
- } catch {
763
- return {
764
- available: false,
765
- error: createError(
766
- `${toolName} is not installed or not in PATH`,
767
- `Install ${toolName} and try again`
768
- )
769
- };
770
- }
771
- }
772
- }
773
- getCached(toolName) {
774
- const timestamp = this.cacheTimestamps.get(toolName);
775
- if (!timestamp) return null;
776
- if (Date.now() - timestamp > this.cacheTimeout) {
777
- this.cache.delete(toolName);
778
- this.cacheTimestamps.delete(toolName);
779
- return null;
780
- }
781
- return this.cache.get(toolName) || null;
782
- }
783
- setCache(toolName, status) {
784
- this.cache.set(toolName, status);
785
- this.cacheTimestamps.set(toolName, Date.now());
786
- }
787
- };
788
- var DependencyError = class extends Error {
789
- static {
790
- __name(this, "DependencyError");
791
- }
792
- hint;
793
- docs;
794
- constructor(error) {
795
- super(error.message);
796
- this.name = "DependencyError";
797
- this.hint = error.hint;
798
- this.docs = error.docs;
799
- }
800
- };
801
- var dependencyValidator = new DependencyValidator();
802
-
803
- // core/types/fs.ts
804
- function isNodeError(error) {
805
- return error instanceof Error && "code" in error;
806
- }
807
- __name(isNodeError, "isNodeError");
808
- function isNotFoundError(error) {
809
- return isNodeError(error) && error.code === "ENOENT";
810
- }
811
- __name(isNotFoundError, "isNotFoundError");
812
- function getErrorMessage(error) {
813
- if (error instanceof Error) return error.message;
814
- if (typeof error === "string") return error;
815
- return "Unknown error";
816
- }
817
- __name(getErrorMessage, "getErrorMessage");
818
-
819
- // core/infrastructure/setup.ts
820
- init_fs_helpers();
821
-
822
- // core/utils/logger.ts
823
- var LEVELS = { error: 0, warn: 1, info: 2, debug: 3 };
824
- var TRUTHY_VALUES = /* @__PURE__ */ new Set(["1", "true", "*"]);
825
- function getLogLevel() {
826
- const debugEnv = process.env.PRJCT_DEBUG || process.env.DEBUG || "";
827
- if (!debugEnv) return { level: -1, name: "disabled" };
828
- if (TRUTHY_VALUES.has(debugEnv) || debugEnv.includes("prjct")) {
829
- return { level: LEVELS.debug, name: "debug" };
830
- }
831
- const levelValue = LEVELS[debugEnv] ?? -1;
832
- const levelName = levelValue >= 0 ? debugEnv : "disabled";
833
- return { level: levelValue, name: levelName };
834
- }
835
- __name(getLogLevel, "getLogLevel");
836
- var { level: currentLevel, name: currentLevelName } = getLogLevel();
837
- var noop = /* @__PURE__ */ __name(() => {
838
- }, "noop");
839
- function createLogMethod(levelThreshold, prefix, method) {
840
- return currentLevel >= levelThreshold ? (...args) => console[method](prefix, ...args) : noop;
841
- }
842
- __name(createLogMethod, "createLogMethod");
843
- var logger = {
844
- error: createLogMethod(LEVELS.error, "[prjct:error]", "error"),
845
- warn: createLogMethod(LEVELS.warn, "[prjct:warn]", "warn"),
846
- info: createLogMethod(LEVELS.info, "[prjct:info]", "log"),
847
- debug: createLogMethod(LEVELS.debug, "[prjct:debug]", "log"),
848
- // Check if logging is enabled (useful for expensive log prep)
849
- isEnabled: /* @__PURE__ */ __name(() => currentLevel >= 0, "isEnabled"),
850
- // Get current level name (pre-computed, no runtime lookup)
851
- level: /* @__PURE__ */ __name(() => currentLevelName, "level")
852
- };
853
- var logger_default = logger;
854
-
855
- // core/utils/version.ts
856
- var import_node_fs = __toESM(require("node:fs"));
857
- var import_node_path = __toESM(require("node:path"));
858
- var cachedVersion = null;
859
- var cachedPackageJson = null;
860
- var cachedPackageRoot = null;
861
- function getPackageRoot() {
862
- if (cachedPackageRoot) {
863
- return cachedPackageRoot;
864
- }
865
- let currentDir = __dirname;
866
- for (let i = 0; i < 5; i++) {
867
- const packageJsonPath = import_node_path.default.join(currentDir, "package.json");
868
- if (import_node_fs.default.existsSync(packageJsonPath)) {
869
- try {
870
- const pkg = JSON.parse(import_node_fs.default.readFileSync(packageJsonPath, "utf-8"));
871
- if (pkg.name === "prjct-cli") {
872
- cachedPackageRoot = currentDir;
873
- return currentDir;
874
- }
875
- } catch (_error) {
876
- }
877
- }
878
- currentDir = import_node_path.default.dirname(currentDir);
879
- }
880
- cachedPackageRoot = import_node_path.default.join(__dirname, "..", "..", "..");
881
- return cachedPackageRoot;
882
- }
883
- __name(getPackageRoot, "getPackageRoot");
884
- function getVersion() {
885
- if (cachedVersion) {
886
- return cachedVersion;
887
- }
888
- try {
889
- const packageJsonPath = import_node_path.default.join(getPackageRoot(), "package.json");
890
- const packageJson = JSON.parse(import_node_fs.default.readFileSync(packageJsonPath, "utf-8"));
891
- cachedVersion = packageJson.version;
892
- cachedPackageJson = packageJson;
893
- return cachedVersion;
894
- } catch (error) {
895
- console.error("Failed to read version from package.json:", getErrorMessage(error));
896
- return "0.0.0";
897
- }
898
- }
899
- __name(getVersion, "getVersion");
900
- var VERSION = getVersion();
901
- var PACKAGE_ROOT = getPackageRoot();
902
-
903
- // core/infrastructure/setup.ts
904
- init_ai_provider();
905
-
906
- // core/infrastructure/command-installer.ts
907
- var import_promises3 = __toESM(require("node:fs/promises"));
908
- var import_node_os3 = __toESM(require("node:os"));
909
- var import_node_path4 = __toESM(require("node:path"));
910
- async function loadModuleConfig() {
911
- try {
912
- const configPath = import_node_path4.default.join(PACKAGE_ROOT, "templates/global/modules/module-config.json");
913
- const content = await import_promises3.default.readFile(configPath, "utf-8");
914
- return JSON.parse(content);
915
- } catch {
916
- return null;
917
- }
918
- }
919
- __name(loadModuleConfig, "loadModuleConfig");
920
- async function composeGlobalTemplate(profile) {
921
- const config = await loadModuleConfig();
922
- const modulesDir = import_node_path4.default.join(PACKAGE_ROOT, "templates/global/modules");
923
- if (!config) {
924
- const legacyPath = import_node_path4.default.join(PACKAGE_ROOT, "templates/global/CLAUDE.md");
925
- return import_promises3.default.readFile(legacyPath, "utf-8");
926
- }
927
- const profileName = profile || config.default;
928
- const selectedProfile = config.profiles[profileName];
929
- if (!selectedProfile) {
930
- const defaultProfile = config.profiles[config.default];
931
- if (!defaultProfile) {
932
- const legacyPath = import_node_path4.default.join(PACKAGE_ROOT, "templates/global/CLAUDE.md");
933
- return import_promises3.default.readFile(legacyPath, "utf-8");
934
- }
935
- }
936
- const modules = (selectedProfile || config.profiles[config.default]).modules;
937
- const parts = [];
938
- parts.push("<!-- prjct:start - DO NOT REMOVE THIS MARKER -->");
939
- for (const moduleName of modules) {
940
- try {
941
- const modulePath = import_node_path4.default.join(modulesDir, moduleName);
942
- const content = await import_promises3.default.readFile(modulePath, "utf-8");
943
- parts.push("");
944
- parts.push(content);
945
- } catch {
946
- console.warn(`Module not found: ${moduleName}`);
947
- }
948
- }
949
- parts.push("");
950
- parts.push("<!-- prjct:end - DO NOT REMOVE THIS MARKER -->");
951
- parts.push("");
952
- return parts.join("\n");
953
- }
954
- __name(composeGlobalTemplate, "composeGlobalTemplate");
955
- async function installDocs() {
956
- try {
957
- const docsDir = import_node_path4.default.join(import_node_os3.default.homedir(), ".prjct-cli", "docs");
958
- const templateDocsDir = import_node_path4.default.join(PACKAGE_ROOT, "templates/global/docs");
959
- await import_promises3.default.mkdir(docsDir, { recursive: true });
960
- const docFiles = await import_promises3.default.readdir(templateDocsDir);
961
- for (const file of docFiles) {
962
- if (file.endsWith(".md")) {
963
- const srcPath = import_node_path4.default.join(templateDocsDir, file);
964
- const destPath = import_node_path4.default.join(docsDir, file);
965
- const content = await import_promises3.default.readFile(srcPath, "utf-8");
966
- await import_promises3.default.writeFile(destPath, content, "utf-8");
967
- }
968
- }
969
- return { success: true };
970
- } catch (error) {
971
- return { success: false, error: getErrorMessage(error) };
972
- }
973
- }
974
- __name(installDocs, "installDocs");
975
- async function installGlobalConfig() {
976
- const aiProvider = (init_ai_provider(), __toCommonJS(ai_provider_exports));
977
- const activeProvider = await aiProvider.getActiveProvider();
978
- const providerName = activeProvider.name;
979
- const detection = await aiProvider.detectProvider(providerName);
980
- if (!detection.installed && !activeProvider.configDir) {
981
- return {
982
- success: false,
983
- error: `${activeProvider.displayName} not detected`,
984
- action: "skipped"
985
- };
986
- }
987
- try {
988
- await import_promises3.default.mkdir(activeProvider.configDir, { recursive: true });
989
- const globalConfigPath = import_node_path4.default.join(activeProvider.configDir, activeProvider.contextFile);
990
- const templatePath = import_node_path4.default.join(PACKAGE_ROOT, "templates", "global", activeProvider.contextFile);
991
- let templateContent = "";
992
- try {
993
- templateContent = await import_promises3.default.readFile(templatePath, "utf-8");
994
- } catch (_error) {
995
- if (providerName === "claude") {
996
- try {
997
- templateContent = await composeGlobalTemplate("standard");
998
- } catch {
999
- const fallbackTemplatePath = import_node_path4.default.join(PACKAGE_ROOT, "templates/global/CLAUDE.md");
1000
- templateContent = await import_promises3.default.readFile(fallbackTemplatePath, "utf-8");
1001
- }
1002
- } else {
1003
- const fallbackTemplatePath = import_node_path4.default.join(PACKAGE_ROOT, "templates/global/CLAUDE.md");
1004
- templateContent = await import_promises3.default.readFile(fallbackTemplatePath, "utf-8");
1005
- if (providerName === "gemini") {
1006
- templateContent = templateContent.replace(/Claude/g, "Gemini");
1007
- }
1008
- }
1009
- }
1010
- let existingContent = "";
1011
- let fileExists2 = false;
1012
- try {
1013
- existingContent = await import_promises3.default.readFile(globalConfigPath, "utf-8");
1014
- fileExists2 = true;
1015
- } catch (error) {
1016
- if (isNotFoundError(error)) {
1017
- fileExists2 = false;
1018
- } else {
1019
- throw error;
1020
- }
1021
- }
1022
- if (!fileExists2) {
1023
- await import_promises3.default.writeFile(globalConfigPath, templateContent, "utf-8");
1024
- return {
1025
- success: true,
1026
- action: "created",
1027
- path: globalConfigPath
1028
- };
1029
- } else {
1030
- const startMarker = "<!-- prjct:start - DO NOT REMOVE THIS MARKER -->";
1031
- const endMarker = "<!-- prjct:end - DO NOT REMOVE THIS MARKER -->";
1032
- const hasMarkers = existingContent.includes(startMarker) && existingContent.includes(endMarker);
1033
- if (!hasMarkers) {
1034
- const updatedContent = `${existingContent}
1035
-
1036
- ${templateContent}`;
1037
- await import_promises3.default.writeFile(globalConfigPath, updatedContent, "utf-8");
1038
- return {
1039
- success: true,
1040
- action: "appended",
1041
- path: globalConfigPath
1042
- };
1043
- } else {
1044
- const beforeMarker = existingContent.substring(0, existingContent.indexOf(startMarker));
1045
- const afterMarker = existingContent.substring(
1046
- existingContent.indexOf(endMarker) + endMarker.length
1047
- );
1048
- const prjctSection = templateContent.substring(
1049
- templateContent.indexOf(startMarker),
1050
- templateContent.indexOf(endMarker) + endMarker.length
1051
- );
1052
- const updatedContent = beforeMarker + prjctSection + afterMarker;
1053
- await import_promises3.default.writeFile(globalConfigPath, updatedContent, "utf-8");
1054
- return {
1055
- success: true,
1056
- action: "updated",
1057
- path: globalConfigPath
1058
- };
1059
- }
1060
- }
1061
- } catch (error) {
1062
- return {
1063
- success: false,
1064
- error: getErrorMessage(error),
1065
- action: "failed"
1066
- };
1067
- }
1068
- }
1069
- __name(installGlobalConfig, "installGlobalConfig");
1070
- var CommandInstaller = class {
1071
- static {
1072
- __name(this, "CommandInstaller");
1073
- }
1074
- homeDir;
1075
- claudeCommandsPath = "";
1076
- claudeConfigPath = "";
1077
- templatesDir;
1078
- _initialized = false;
1079
- constructor() {
1080
- this.homeDir = import_node_os3.default.homedir();
1081
- this.templatesDir = import_node_path4.default.join(PACKAGE_ROOT, "templates", "commands");
1082
- }
1083
- async ensureInit() {
1084
- if (this._initialized) return;
1085
- const aiProvider = (init_ai_provider(), __toCommonJS(ai_provider_exports));
1086
- const activeProvider = await aiProvider.getActiveProvider();
1087
- if (activeProvider.name === "gemini") {
1088
- this.claudeCommandsPath = import_node_path4.default.join(activeProvider.configDir, "commands");
1089
- } else {
1090
- this.claudeCommandsPath = import_node_path4.default.join(activeProvider.configDir, "commands", "p");
1091
- }
1092
- this.claudeConfigPath = activeProvider.configDir;
1093
- this._initialized = true;
1094
- }
1095
- /**
1096
- * Detect if active provider is installed
1097
- */
1098
- async detectActiveProvider() {
1099
- await this.ensureInit();
1100
- try {
1101
- await import_promises3.default.access(this.claudeConfigPath);
1102
- return true;
1103
- } catch (error) {
1104
- if (isNotFoundError(error)) {
1105
- return false;
1106
- }
1107
- throw error;
1108
- }
1109
- }
1110
- /**
1111
- * Detect if Claude is installed (legacy support)
1112
- */
1113
- async detectClaude() {
1114
- return this.detectActiveProvider();
1115
- }
1116
- /**
1117
- * Get list of command files to install
1118
- */
1119
- async getCommandFiles() {
1120
- try {
1121
- const files = await import_promises3.default.readdir(this.templatesDir);
1122
- return files.filter((f) => f.endsWith(".md"));
1123
- } catch (_error) {
1124
- return [
1125
- "init.md",
1126
- "now.md",
1127
- "done.md",
1128
- "ship.md",
1129
- "next.md",
1130
- "idea.md",
1131
- "recap.md",
1132
- "progress.md",
1133
- "stuck.md",
1134
- "context.md",
1135
- "analyze.md",
1136
- "sync.md",
1137
- "roadmap.md",
1138
- "task.md",
1139
- "git.md",
1140
- "fix.md",
1141
- "test.md",
1142
- "cleanup.md",
1143
- "design.md"
1144
- ];
1145
- }
1146
- }
1147
- /**
1148
- * Install commands to active AI agent
1149
- */
1150
- async installCommands() {
1151
- const providerDetected = await this.detectActiveProvider();
1152
- const aiProvider = (init_ai_provider(), __toCommonJS(ai_provider_exports));
1153
- const activeProvider = await aiProvider.getActiveProvider();
1154
- if (!providerDetected) {
1155
- return {
1156
- success: false,
1157
- error: `${activeProvider.displayName} not detected. Please install it first.`
1158
- };
1159
- }
1160
- try {
1161
- await this.installRouter();
1162
- await import_promises3.default.mkdir(this.claudeCommandsPath, { recursive: true });
1163
- const commandFiles = await this.getCommandFiles();
1164
- const installed = [];
1165
- const errors = [];
1166
- for (const file of commandFiles) {
1167
- try {
1168
- const sourcePath = import_node_path4.default.join(this.templatesDir, file);
1169
- const destPath = import_node_path4.default.join(this.claudeCommandsPath, file);
1170
- const content = await import_promises3.default.readFile(sourcePath, "utf-8");
1171
- await import_promises3.default.writeFile(destPath, content, "utf-8");
1172
- installed.push(file.replace(".md", ""));
1173
- } catch (error) {
1174
- errors.push({ file, error: getErrorMessage(error) });
1175
- }
1176
- }
1177
- return {
1178
- success: true,
1179
- installed,
1180
- errors,
1181
- path: this.claudeCommandsPath
1182
- };
1183
- } catch (error) {
1184
- return {
1185
- success: false,
1186
- error: getErrorMessage(error)
1187
- };
1188
- }
1189
- }
1190
- /**
1191
- * Uninstall commands from Claude
1192
- */
1193
- async uninstallCommands() {
1194
- try {
1195
- const commandFiles = await this.getCommandFiles();
1196
- const uninstalled = [];
1197
- const errors = [];
1198
- for (const file of commandFiles) {
1199
- try {
1200
- const filePath = import_node_path4.default.join(this.claudeCommandsPath, file);
1201
- await import_promises3.default.unlink(filePath);
1202
- uninstalled.push(file.replace(".md", ""));
1203
- } catch (error) {
1204
- if (error.code !== "ENOENT") {
1205
- errors.push({ file, error: getErrorMessage(error) });
1206
- }
1207
- }
1208
- }
1209
- try {
1210
- await import_promises3.default.rmdir(this.claudeCommandsPath);
1211
- } catch (_error) {
1212
- }
1213
- return {
1214
- success: true,
1215
- uninstalled,
1216
- errors
1217
- };
1218
- } catch (error) {
1219
- return {
1220
- success: false,
1221
- error: getErrorMessage(error)
1222
- };
1223
- }
1224
- }
1225
- /**
1226
- * Check if commands are already installed
1227
- */
1228
- async checkInstallation() {
1229
- const claudeDetected = await this.detectClaude();
1230
- if (!claudeDetected) {
1231
- return {
1232
- installed: false,
1233
- claudeDetected: false
1234
- };
1235
- }
1236
- try {
1237
- await import_promises3.default.access(this.claudeCommandsPath);
1238
- const files = await import_promises3.default.readdir(this.claudeCommandsPath);
1239
- const installedCommands = files.filter((f) => f.endsWith(".md")).map((f) => f.replace(".md", ""));
1240
- return {
1241
- installed: installedCommands.length > 0,
1242
- claudeDetected: true,
1243
- commands: installedCommands,
1244
- path: this.claudeCommandsPath
1245
- };
1246
- } catch (error) {
1247
- if (isNotFoundError(error)) {
1248
- return {
1249
- installed: false,
1250
- claudeDetected: true,
1251
- commands: []
1252
- };
1253
- }
1254
- throw error;
1255
- }
1256
- }
1257
- /**
1258
- * Update commands (reinstall with latest templates)
1259
- */
1260
- async updateCommands() {
1261
- console.log("Updating commands with latest templates...");
1262
- const result = await this.installCommands();
1263
- if (result.success && result.installed) {
1264
- console.log(`Updated ${result.installed.length} commands`);
1265
- }
1266
- return result;
1267
- }
1268
- /**
1269
- * Install to all detected editors (alias for installCommands)
1270
- */
1271
- async installToAll() {
1272
- return await this.installCommands();
1273
- }
1274
- /**
1275
- * Get installation path for Claude commands
1276
- */
1277
- async getInstallPath() {
1278
- await this.ensureInit();
1279
- return this.claudeCommandsPath;
1280
- }
1281
- /**
1282
- * Verify command template exists
1283
- */
1284
- async verifyTemplate(commandName) {
1285
- try {
1286
- const templatePath = import_node_path4.default.join(this.templatesDir, `${commandName}.md`);
1287
- await import_promises3.default.access(templatePath);
1288
- return true;
1289
- } catch (error) {
1290
- if (isNotFoundError(error)) {
1291
- return false;
1292
- }
1293
- throw error;
1294
- }
1295
- }
1296
- /**
1297
- * Install the router (p.md for Claude, p.toml for Gemini) to commands directory
1298
- * This enables the "p. task" natural language trigger
1299
- */
1300
- async installRouter() {
1301
- const aiProvider = (init_ai_provider(), __toCommonJS(ai_provider_exports));
1302
- const activeProvider = await aiProvider.getActiveProvider();
1303
- const routerFile = activeProvider.name === "gemini" ? "p.toml" : "p.md";
1304
- try {
1305
- const routerSource = import_node_path4.default.join(this.templatesDir, routerFile);
1306
- const routerDest = import_node_path4.default.join(activeProvider.configDir, "commands", routerFile);
1307
- await import_promises3.default.mkdir(import_node_path4.default.dirname(routerDest), { recursive: true });
1308
- const content = await import_promises3.default.readFile(routerSource, "utf-8");
1309
- await import_promises3.default.writeFile(routerDest, content, "utf-8");
1310
- return true;
1311
- } catch (error) {
1312
- if (isNotFoundError(error)) {
1313
- return false;
1314
- }
1315
- throw error;
1316
- }
1317
- }
1318
- /**
1319
- * Remove legacy p.*.md files from commands root directory
1320
- * These were replaced by the p/ subdirectory structure in v0.50+
1321
- */
1322
- async removeLegacyCommands() {
1323
- const aiProvider = (init_ai_provider(), __toCommonJS(ai_provider_exports));
1324
- const activeProvider = await aiProvider.getActiveProvider();
1325
- const commandsRoot = import_node_path4.default.join(activeProvider.configDir, "commands");
1326
- let removed = 0;
1327
- try {
1328
- const files = await import_promises3.default.readdir(commandsRoot);
1329
- const legacyFiles = files.filter((f) => f.startsWith("p.") && f.endsWith(".md"));
1330
- for (const file of legacyFiles) {
1331
- try {
1332
- await import_promises3.default.unlink(import_node_path4.default.join(commandsRoot, file));
1333
- removed++;
1334
- } catch {
1335
- }
1336
- }
1337
- } catch {
1338
- }
1339
- return removed;
1340
- }
1341
- /**
1342
- * Sync commands - intelligent update that detects and removes orphans
1343
- */
1344
- async syncCommands() {
1345
- const providerDetected = await this.detectActiveProvider();
1346
- if (!providerDetected) {
1347
- return {
1348
- success: false,
1349
- error: "AI agent not detected",
1350
- added: 0,
1351
- updated: 0,
1352
- removed: 0
1353
- };
1354
- }
1355
- try {
1356
- await this.installRouter();
1357
- await import_promises3.default.mkdir(this.claudeCommandsPath, { recursive: true });
1358
- const templateFiles = await this.getCommandFiles();
1359
- let installedFiles = [];
1360
- try {
1361
- installedFiles = await import_promises3.default.readdir(this.claudeCommandsPath);
1362
- installedFiles = installedFiles.filter((f) => f.endsWith(".md"));
1363
- } catch (error) {
1364
- if (isNotFoundError(error)) {
1365
- installedFiles = [];
1366
- } else {
1367
- throw error;
1368
- }
1369
- }
1370
- const results = {
1371
- success: true,
1372
- added: 0,
1373
- updated: 0,
1374
- removed: 0,
1375
- errors: []
1376
- };
1377
- for (const file of templateFiles) {
1378
- try {
1379
- const sourcePath = import_node_path4.default.join(this.templatesDir, file);
1380
- const destPath = import_node_path4.default.join(this.claudeCommandsPath, file);
1381
- const exists = installedFiles.includes(file);
1382
- const content = await import_promises3.default.readFile(sourcePath, "utf-8");
1383
- await import_promises3.default.writeFile(destPath, content, "utf-8");
1384
- if (!exists) {
1385
- results.added++;
1386
- } else {
1387
- results.updated++;
1388
- }
1389
- } catch (error) {
1390
- results.errors.push({ file, error: getErrorMessage(error) });
1391
- }
1392
- }
1393
- await this.removeLegacyCommands();
1394
- return results;
1395
- } catch (error) {
1396
- return {
1397
- success: false,
1398
- error: getErrorMessage(error),
1399
- added: 0,
1400
- updated: 0,
1401
- removed: 0
1402
- };
1403
- }
1404
- }
1405
- /**
1406
- * Install or update global AI agent configuration (CLAUDE.md / GEMINI.md)
1407
- */
1408
- async installGlobalConfig() {
1409
- return installGlobalConfig();
1410
- }
1411
- /**
1412
- * Install documentation files to ~/.prjct-cli/docs/
1413
- */
1414
- async installDocs() {
1415
- return installDocs();
1416
- }
1417
- };
1418
- var commandInstaller = new CommandInstaller();
1419
- var command_installer_default = commandInstaller;
1420
-
1421
- // core/infrastructure/editors-config.ts
1422
- var import_promises4 = __toESM(require("node:fs/promises"));
1423
- var import_node_os4 = __toESM(require("node:os"));
1424
- var import_node_path5 = __toESM(require("node:path"));
1425
- var EditorsConfig = class {
1426
- static {
1427
- __name(this, "EditorsConfig");
1428
- }
1429
- homeDir;
1430
- configDir;
1431
- configFile;
1432
- constructor() {
1433
- this.homeDir = import_node_os4.default.homedir();
1434
- this.configDir = import_node_path5.default.join(this.homeDir, ".prjct-cli", "config");
1435
- this.configFile = import_node_path5.default.join(this.configDir, "installed-editors.json");
1436
- }
1437
- /**
1438
- * Ensure config directory exists
1439
- */
1440
- async ensureConfigDir() {
1441
- try {
1442
- await import_promises4.default.mkdir(this.configDir, { recursive: true });
1443
- } catch (error) {
1444
- console.error("[editors-config] Error creating config directory:", getErrorMessage(error));
1445
- }
1446
- }
1447
- /**
1448
- * Load installation configuration
1449
- */
1450
- async loadConfig() {
1451
- try {
1452
- const content = await import_promises4.default.readFile(this.configFile, "utf-8");
1453
- return JSON.parse(content);
1454
- } catch (error) {
1455
- if (error.code === "ENOENT") {
1456
- return null;
1457
- }
1458
- console.error("[editors-config] Error loading config:", getErrorMessage(error));
1459
- return null;
1460
- }
1461
- }
1462
- /**
1463
- * Save installation configuration
1464
- */
1465
- async saveConfig(version, installPath, provider = "claude") {
1466
- try {
1467
- await this.ensureConfigDir();
1468
- const config = {
1469
- version,
1470
- editor: provider,
1471
- // deprecated, kept for backward compatibility
1472
- provider,
1473
- lastInstall: (/* @__PURE__ */ new Date()).toISOString(),
1474
- path: installPath
1475
- };
1476
- await import_promises4.default.writeFile(this.configFile, JSON.stringify(config, null, 2), "utf-8");
1477
- return true;
1478
- } catch (error) {
1479
- console.error("[editors-config] Error saving config:", getErrorMessage(error));
1480
- return false;
1481
- }
1482
- }
1483
- /**
1484
- * Get the configured provider
1485
- */
1486
- async getProvider() {
1487
- const config = await this.loadConfig();
1488
- if (!config) return null;
1489
- return config.provider || config.editor || "claude";
1490
- }
1491
- /**
1492
- * Get last installed version
1493
- */
1494
- async getLastVersion() {
1495
- const config = await this.loadConfig();
1496
- return config ? config.version : null;
1497
- }
1498
- /**
1499
- * Check if version has changed since last install
1500
- */
1501
- async hasVersionChanged(currentVersion) {
1502
- const lastVersion = await this.getLastVersion();
1503
- return lastVersion !== null && lastVersion !== currentVersion;
1504
- }
1505
- /**
1506
- * Update version in configuration
1507
- */
1508
- async updateVersion(version) {
1509
- try {
1510
- const config = await this.loadConfig();
1511
- if (!config) {
1512
- return false;
1513
- }
1514
- config.version = version;
1515
- config.lastInstall = (/* @__PURE__ */ new Date()).toISOString();
1516
- await import_promises4.default.writeFile(this.configFile, JSON.stringify(config, null, 2), "utf-8");
1517
- return true;
1518
- } catch (error) {
1519
- console.error("[editors-config] Error updating version:", getErrorMessage(error));
1520
- return false;
1521
- }
1522
- }
1523
- /**
1524
- * Check if config file exists
1525
- */
1526
- async configExists() {
1527
- try {
1528
- await import_promises4.default.access(this.configFile);
1529
- return true;
1530
- } catch (_error) {
1531
- return false;
1532
- }
1533
- }
1534
- /**
1535
- * Delete configuration file
1536
- * Used during uninstallation to clean up tracking data
1537
- */
1538
- async deleteConfig() {
1539
- try {
1540
- const exists = await this.configExists();
1541
- if (exists) {
1542
- await import_promises4.default.unlink(this.configFile);
1543
- }
1544
- return true;
1545
- } catch (error) {
1546
- console.error("[editors-config] Error deleting config:", getErrorMessage(error));
1547
- return false;
1548
- }
1549
- }
1550
- };
1551
- var editorsConfig = new EditorsConfig();
1552
- var editors_config_default = editorsConfig;
1553
-
1554
- // core/infrastructure/setup.ts
1555
- async function installAICLI(provider) {
1556
- const packageName = provider.name === "claude" ? "@anthropic-ai/claude-code" : "@google/gemini-cli";
1557
- if (!dependencyValidator.isAvailable("npm")) {
1558
- console.log(`${import_chalk.default.yellow("\u26A0\uFE0F npm is not available")}`);
1559
- console.log("");
1560
- console.log(`${import_chalk.default.dim(`Install ${provider.displayName} using one of:`)}`);
1561
- console.log(import_chalk.default.dim(" \u2022 Install Node.js: https://nodejs.org"));
1562
- console.log(
1563
- import_chalk.default.dim(
1564
- ` \u2022 Use Homebrew: brew install ${provider.name === "claude" ? "claude" : "gemini"}`
1565
- )
1566
- );
1567
- console.log(import_chalk.default.dim(` \u2022 Use npx directly: npx ${packageName}`));
1568
- console.log("");
1569
- return false;
1570
- }
1571
- try {
1572
- console.log(import_chalk.default.yellow(`\u{1F4E6} ${provider.displayName} not found. Installing...`));
1573
- console.log("");
1574
- (0, import_node_child_process3.execSync)(`npm install -g ${packageName}`, {
1575
- stdio: "inherit",
1576
- timeout: getTimeout("NPM_INSTALL")
1577
- });
1578
- console.log("");
1579
- console.log(`${import_chalk.default.green("\u2713")} ${provider.displayName} installed successfully`);
1580
- console.log("");
1581
- return true;
1582
- } catch (error) {
1583
- const err = error;
1584
- const isTimeout = err.killed && err.signal === "SIGTERM";
1585
- if (isTimeout) {
1586
- console.log(import_chalk.default.yellow(`\u26A0\uFE0F Installation timed out for ${provider.displayName}`));
1587
- console.log("");
1588
- console.log(import_chalk.default.dim("The npm install took too long. Try:"));
1589
- console.log(import_chalk.default.dim(" \u2022 Set PRJCT_TIMEOUT_NPM_INSTALL=300000 for 5 minutes"));
1590
- console.log(import_chalk.default.dim(` \u2022 Run manually: npm install -g ${packageName}`));
1591
- } else {
1592
- console.log(import_chalk.default.yellow(`\u26A0\uFE0F Failed to install ${provider.displayName}: ${err.message}`));
1593
- }
1594
- console.log("");
1595
- console.log(import_chalk.default.dim("Alternative installation methods:"));
1596
- console.log(import_chalk.default.dim(` \u2022 npm: npm install -g ${packageName}`));
1597
- console.log(import_chalk.default.dim(` \u2022 yarn: yarn global add ${packageName}`));
1598
- console.log(import_chalk.default.dim(` \u2022 pnpm: pnpm add -g ${packageName}`));
1599
- console.log(
1600
- import_chalk.default.dim(` \u2022 brew: brew install ${provider.name === "claude" ? "claude" : "gemini"}`)
1601
- );
1602
- console.log("");
1603
- return false;
1604
- }
1605
- }
1606
- __name(installAICLI, "installAICLI");
1607
- async function run() {
1608
- const detection = await detectAllProviders();
1609
- const selection = await selectProvider();
1610
- const _primaryProvider = Providers[selection.provider];
1611
- const results = {
1612
- provider: selection.provider,
1613
- providers: [],
1614
- cliInstalled: false,
1615
- commandsAdded: 0,
1616
- commandsUpdated: 0,
1617
- configAction: null
1618
- };
1619
- const cliProviderNames = ["claude", "gemini"];
1620
- for (const providerName of cliProviderNames) {
1621
- const providerConfig = Providers[providerName];
1622
- const providerDetection = detection[providerName];
1623
- const providerResult = {
1624
- provider: providerName,
1625
- cliInstalled: false,
1626
- commandsAdded: 0,
1627
- commandsUpdated: 0,
1628
- configAction: null
1629
- };
1630
- if (!providerDetection.installed) {
1631
- if (providerName === selection.provider) {
1632
- const installed = await installAICLI(providerConfig);
1633
- if (installed) {
1634
- providerResult.cliInstalled = true;
1635
- results.cliInstalled = true;
1636
- } else {
1637
- throw new Error(`${providerConfig.displayName} installation failed`);
1638
- }
1639
- } else {
1640
- continue;
1641
- }
1642
- }
1643
- if (providerName === "claude") {
1644
- const claudeDetected = await command_installer_default.detectClaude();
1645
- if (claudeDetected) {
1646
- const syncResult = await command_installer_default.syncCommands();
1647
- if (syncResult.success) {
1648
- providerResult.commandsAdded = syncResult.added;
1649
- providerResult.commandsUpdated = syncResult.updated;
1650
- results.commandsAdded += syncResult.added;
1651
- results.commandsUpdated += syncResult.updated;
1652
- }
1653
- const configResult = await command_installer_default.installGlobalConfig();
1654
- if (configResult.success) {
1655
- providerResult.configAction = configResult.action;
1656
- if (!results.configAction) {
1657
- results.configAction = configResult.action;
1658
- }
1659
- }
1660
- await command_installer_default.installDocs();
1661
- await installStatusLine();
1662
- await installContext7MCP();
1663
- }
1664
- } else if (providerName === "gemini") {
1665
- const geminiInstalled = await installGeminiRouter();
1666
- if (geminiInstalled) {
1667
- providerResult.commandsAdded = 1;
1668
- results.commandsAdded += 1;
1669
- }
1670
- const geminiConfigResult = await installGeminiGlobalConfig();
1671
- if (geminiConfigResult.success) {
1672
- providerResult.configAction = geminiConfigResult.action;
1673
- }
1674
- }
1675
- results.providers.push(providerResult);
1676
- }
1677
- const antigravityDetection = await detectAntigravity();
1678
- if (antigravityDetection.installed) {
1679
- const antigravityResult = await installAntigravitySkill();
1680
- if (antigravityResult.success) {
1681
- console.log(` ${import_chalk.default.green("\u2713")} Antigravity skill installed`);
1682
- }
1683
- }
1684
- await editors_config_default.saveConfig(VERSION, await command_installer_default.getInstallPath(), selection.provider);
1685
- await migrateProjectsCliVersion();
1686
- for (const providerResult of results.providers) {
1687
- showResults(providerResult, Providers[providerResult.provider]);
1688
- }
1689
- return results;
1690
- }
1691
- __name(run, "run");
1692
- async function installGeminiRouter() {
1693
- try {
1694
- const geminiCommandsDir = import_node_path6.default.join(import_node_os5.default.homedir(), ".gemini", "commands");
1695
- const routerSource = import_node_path6.default.join(PACKAGE_ROOT, "templates", "commands", "p.toml");
1696
- const routerDest = import_node_path6.default.join(geminiCommandsDir, "p.toml");
1697
- await import_promises5.default.mkdir(geminiCommandsDir, { recursive: true });
1698
- if (await fileExists(routerSource)) {
1699
- await import_promises5.default.copyFile(routerSource, routerDest);
1700
- return true;
1701
- }
1702
- return false;
1703
- } catch (error) {
1704
- logger_default.warn(`Gemini router warning: ${getErrorMessage(error)}`);
1705
- return false;
1706
- }
1707
- }
1708
- __name(installGeminiRouter, "installGeminiRouter");
1709
- async function installGeminiGlobalConfig() {
1710
- try {
1711
- const geminiDir = import_node_path6.default.join(import_node_os5.default.homedir(), ".gemini");
1712
- const globalConfigPath = import_node_path6.default.join(geminiDir, "GEMINI.md");
1713
- const templatePath = import_node_path6.default.join(PACKAGE_ROOT, "templates", "global", "GEMINI.md");
1714
- await import_promises5.default.mkdir(geminiDir, { recursive: true });
1715
- const templateContent = await import_promises5.default.readFile(templatePath, "utf-8");
1716
- let existingContent = "";
1717
- let configExists = false;
1718
- try {
1719
- existingContent = await import_promises5.default.readFile(globalConfigPath, "utf-8");
1720
- configExists = true;
1721
- } catch (error) {
1722
- if (isNotFoundError(error)) {
1723
- configExists = false;
1724
- } else {
1725
- throw error;
1726
- }
1727
- }
1728
- if (!configExists) {
1729
- await import_promises5.default.writeFile(globalConfigPath, templateContent, "utf-8");
1730
- return { success: true, action: "created" };
1731
- }
1732
- const startMarker = "<!-- prjct:start - DO NOT REMOVE THIS MARKER -->";
1733
- const endMarker = "<!-- prjct:end - DO NOT REMOVE THIS MARKER -->";
1734
- const hasMarkers = existingContent.includes(startMarker) && existingContent.includes(endMarker);
1735
- if (!hasMarkers) {
1736
- const updatedContent2 = `${existingContent}
1737
-
1738
- ${templateContent}`;
1739
- await import_promises5.default.writeFile(globalConfigPath, updatedContent2, "utf-8");
1740
- return { success: true, action: "appended" };
1741
- }
1742
- const beforeMarker = existingContent.substring(0, existingContent.indexOf(startMarker));
1743
- const afterMarker = existingContent.substring(
1744
- existingContent.indexOf(endMarker) + endMarker.length
1745
- );
1746
- const prjctSection = templateContent.substring(
1747
- templateContent.indexOf(startMarker),
1748
- templateContent.indexOf(endMarker) + endMarker.length
1749
- );
1750
- const updatedContent = beforeMarker + prjctSection + afterMarker;
1751
- await import_promises5.default.writeFile(globalConfigPath, updatedContent, "utf-8");
1752
- return { success: true, action: "updated" };
1753
- } catch (error) {
1754
- logger_default.warn(`Gemini config warning: ${getErrorMessage(error)}`);
1755
- return { success: false, action: null };
1756
- }
1757
- }
1758
- __name(installGeminiGlobalConfig, "installGeminiGlobalConfig");
1759
- async function installAntigravitySkill() {
1760
- try {
1761
- const antigravitySkillsDir = import_node_path6.default.join(import_node_os5.default.homedir(), ".gemini", "antigravity", "skills");
1762
- const prjctSkillDir = import_node_path6.default.join(antigravitySkillsDir, "prjct");
1763
- const skillMdPath = import_node_path6.default.join(prjctSkillDir, "SKILL.md");
1764
- const templatePath = import_node_path6.default.join(PACKAGE_ROOT, "templates", "antigravity", "SKILL.md");
1765
- await import_promises5.default.mkdir(prjctSkillDir, { recursive: true });
1766
- const skillExists = await fileExists(skillMdPath);
1767
- if (!await fileExists(templatePath)) {
1768
- logger_default.warn("Antigravity SKILL.md template not found");
1769
- return { success: false, action: null };
1770
- }
1771
- const templateContent = await import_promises5.default.readFile(templatePath, "utf-8");
1772
- await import_promises5.default.writeFile(skillMdPath, templateContent, "utf-8");
1773
- return { success: true, action: skillExists ? "updated" : "created" };
1774
- } catch (error) {
1775
- logger_default.warn(`Antigravity skill warning: ${getErrorMessage(error)}`);
1776
- return { success: false, action: null };
1777
- }
1778
- }
1779
- __name(installAntigravitySkill, "installAntigravitySkill");
1780
- async function needsAntigravityInstallation() {
1781
- const detection = await detectAntigravity();
1782
- return detection.installed && !detection.skillInstalled;
1783
- }
1784
- __name(needsAntigravityInstallation, "needsAntigravityInstallation");
1785
- async function installCursorProject(projectRoot) {
1786
- const result = {
1787
- success: false,
1788
- rulesCreated: false,
1789
- commandsCreated: false,
1790
- gitignoreUpdated: false
1791
- };
1792
- try {
1793
- const cursorDir = import_node_path6.default.join(projectRoot, ".cursor");
1794
- const rulesDir = import_node_path6.default.join(cursorDir, "rules");
1795
- const commandsDir = import_node_path6.default.join(cursorDir, "commands");
1796
- const routerMdcDest = import_node_path6.default.join(rulesDir, "prjct.mdc");
1797
- const routerMdcSource = import_node_path6.default.join(PACKAGE_ROOT, "templates", "cursor", "router.mdc");
1798
- const cursorCommandsSource = import_node_path6.default.join(PACKAGE_ROOT, "templates", "cursor", "commands");
1799
- await import_promises5.default.mkdir(rulesDir, { recursive: true });
1800
- await import_promises5.default.mkdir(commandsDir, { recursive: true });
1801
- if (await fileExists(routerMdcSource)) {
1802
- await import_promises5.default.copyFile(routerMdcSource, routerMdcDest);
1803
- result.rulesCreated = true;
1804
- }
1805
- if (await fileExists(cursorCommandsSource)) {
1806
- const commandFiles = (await import_promises5.default.readdir(cursorCommandsSource)).filter((f) => f.endsWith(".md"));
1807
- for (const file of commandFiles) {
1808
- const src = import_node_path6.default.join(cursorCommandsSource, file);
1809
- const dest = import_node_path6.default.join(commandsDir, file);
1810
- await import_promises5.default.copyFile(src, dest);
1811
- }
1812
- result.commandsCreated = commandFiles.length > 0;
1813
- }
1814
- result.gitignoreUpdated = await addCursorToGitignore(projectRoot);
1815
- result.success = result.rulesCreated || result.commandsCreated;
1816
- return result;
1817
- } catch (error) {
1818
- logger_default.warn(`Cursor installation warning: ${getErrorMessage(error)}`);
1819
- return result;
1820
- }
1821
- }
1822
- __name(installCursorProject, "installCursorProject");
1823
- async function addCursorToGitignore(projectRoot) {
1824
- try {
1825
- const gitignorePath = import_node_path6.default.join(projectRoot, ".gitignore");
1826
- const entriesToAdd = [
1827
- "# prjct Cursor routers (regenerated per-developer)",
1828
- ".cursor/rules/prjct.mdc",
1829
- ".cursor/commands/sync.md",
1830
- ".cursor/commands/task.md",
1831
- ".cursor/commands/done.md",
1832
- ".cursor/commands/ship.md",
1833
- ".cursor/commands/bug.md",
1834
- ".cursor/commands/pause.md",
1835
- ".cursor/commands/resume.md"
1836
- ];
1837
- let content = "";
1838
- let configExists = false;
1839
- try {
1840
- content = await import_promises5.default.readFile(gitignorePath, "utf-8");
1841
- configExists = true;
1842
- } catch (error) {
1843
- if (!isNotFoundError(error)) {
1844
- throw error;
1845
- }
1846
- }
1847
- if (content.includes(".cursor/rules/prjct.mdc")) {
1848
- return false;
1849
- }
1850
- const newContent = configExists ? `${content.trimEnd()}
1851
-
1852
- ${entriesToAdd.join("\n")}
1853
- ` : `${entriesToAdd.join("\n")}
1854
- `;
1855
- await import_promises5.default.writeFile(gitignorePath, newContent, "utf-8");
1856
- return true;
1857
- } catch (error) {
1858
- logger_default.warn(`Gitignore update warning: ${getErrorMessage(error)}`);
1859
- return false;
1860
- }
1861
- }
1862
- __name(addCursorToGitignore, "addCursorToGitignore");
1863
- async function hasCursorProject(projectRoot) {
1864
- return await fileExists(import_node_path6.default.join(projectRoot, ".cursor"));
1865
- }
1866
- __name(hasCursorProject, "hasCursorProject");
1867
- async function needsCursorRegeneration(projectRoot) {
1868
- const cursorDir = import_node_path6.default.join(projectRoot, ".cursor");
1869
- const routerPath = import_node_path6.default.join(cursorDir, "rules", "prjct.mdc");
1870
- return await fileExists(cursorDir) && !await fileExists(routerPath);
1871
- }
1872
- __name(needsCursorRegeneration, "needsCursorRegeneration");
1873
- async function installWindsurfProject(projectRoot) {
1874
- const result = {
1875
- success: false,
1876
- rulesCreated: false,
1877
- workflowsCreated: false,
1878
- gitignoreUpdated: false
1879
- };
1880
- try {
1881
- const windsurfDir = import_node_path6.default.join(projectRoot, ".windsurf");
1882
- const rulesDir = import_node_path6.default.join(windsurfDir, "rules");
1883
- const workflowsDir = import_node_path6.default.join(windsurfDir, "workflows");
1884
- const routerDest = import_node_path6.default.join(rulesDir, "prjct.md");
1885
- const routerSource = import_node_path6.default.join(PACKAGE_ROOT, "templates", "windsurf", "router.md");
1886
- const windsurfWorkflowsSource = import_node_path6.default.join(PACKAGE_ROOT, "templates", "windsurf", "workflows");
1887
- await import_promises5.default.mkdir(rulesDir, { recursive: true });
1888
- await import_promises5.default.mkdir(workflowsDir, { recursive: true });
1889
- if (await fileExists(routerSource)) {
1890
- await import_promises5.default.copyFile(routerSource, routerDest);
1891
- result.rulesCreated = true;
1892
- }
1893
- if (await fileExists(windsurfWorkflowsSource)) {
1894
- const workflowFiles = (await import_promises5.default.readdir(windsurfWorkflowsSource)).filter(
1895
- (f) => f.endsWith(".md")
1896
- );
1897
- for (const file of workflowFiles) {
1898
- const src = import_node_path6.default.join(windsurfWorkflowsSource, file);
1899
- const dest = import_node_path6.default.join(workflowsDir, file);
1900
- await import_promises5.default.copyFile(src, dest);
1901
- }
1902
- result.workflowsCreated = workflowFiles.length > 0;
1903
- }
1904
- result.gitignoreUpdated = await addWindsurfToGitignore(projectRoot);
1905
- result.success = result.rulesCreated || result.workflowsCreated;
1906
- return result;
1907
- } catch (error) {
1908
- logger_default.warn(`Windsurf installation warning: ${getErrorMessage(error)}`);
1909
- return result;
1910
- }
1911
- }
1912
- __name(installWindsurfProject, "installWindsurfProject");
1913
- async function addWindsurfToGitignore(projectRoot) {
1914
- try {
1915
- const gitignorePath = import_node_path6.default.join(projectRoot, ".gitignore");
1916
- const entriesToAdd = [
1917
- "# prjct Windsurf routers (regenerated per-developer)",
1918
- ".windsurf/rules/prjct.md",
1919
- ".windsurf/workflows/sync.md",
1920
- ".windsurf/workflows/task.md",
1921
- ".windsurf/workflows/done.md",
1922
- ".windsurf/workflows/ship.md",
1923
- ".windsurf/workflows/bug.md",
1924
- ".windsurf/workflows/pause.md",
1925
- ".windsurf/workflows/resume.md"
1926
- ];
1927
- let content = "";
1928
- let configExists = false;
1929
- try {
1930
- content = await import_promises5.default.readFile(gitignorePath, "utf-8");
1931
- configExists = true;
1932
- } catch (error) {
1933
- if (!isNotFoundError(error)) {
1934
- throw error;
1935
- }
1936
- }
1937
- if (content.includes(".windsurf/rules/prjct.md")) {
1938
- return false;
1939
- }
1940
- const newContent = configExists ? `${content.trimEnd()}
1941
-
1942
- ${entriesToAdd.join("\n")}
1943
- ` : `${entriesToAdd.join("\n")}
1944
- `;
1945
- await import_promises5.default.writeFile(gitignorePath, newContent, "utf-8");
1946
- return true;
1947
- } catch (error) {
1948
- logger_default.warn(`Gitignore update warning: ${getErrorMessage(error)}`);
1949
- return false;
1950
- }
1951
- }
1952
- __name(addWindsurfToGitignore, "addWindsurfToGitignore");
1953
- async function hasWindsurfProject(projectRoot) {
1954
- return await fileExists(import_node_path6.default.join(projectRoot, ".windsurf"));
1955
- }
1956
- __name(hasWindsurfProject, "hasWindsurfProject");
1957
- async function needsWindsurfRegeneration(projectRoot) {
1958
- const windsurfDir = import_node_path6.default.join(projectRoot, ".windsurf");
1959
- const routerPath = import_node_path6.default.join(windsurfDir, "rules", "prjct.md");
1960
- return await fileExists(windsurfDir) && !await fileExists(routerPath);
1961
- }
1962
- __name(needsWindsurfRegeneration, "needsWindsurfRegeneration");
1963
- async function migrateProjectsCliVersion() {
1964
- try {
1965
- const projectsDir = import_node_path6.default.join(import_node_os5.default.homedir(), ".prjct-cli", "projects");
1966
- if (!await fileExists(projectsDir)) {
1967
- return;
1968
- }
1969
- const projectDirs = (await import_promises5.default.readdir(projectsDir, { withFileTypes: true })).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
1970
- let migrated = 0;
1971
- for (const projectId of projectDirs) {
1972
- const projectJsonPath = import_node_path6.default.join(projectsDir, projectId, "project.json");
1973
- if (!await fileExists(projectJsonPath)) {
1974
- continue;
1975
- }
1976
- try {
1977
- const content = await import_promises5.default.readFile(projectJsonPath, "utf8");
1978
- const project = JSON.parse(content);
1979
- if (project.cliVersion !== VERSION) {
1980
- project.cliVersion = VERSION;
1981
- await import_promises5.default.writeFile(projectJsonPath, JSON.stringify(project, null, 2));
1982
- migrated++;
1983
- }
1984
- } catch (error) {
1985
- if (!isNotFoundError(error) && !(error instanceof SyntaxError)) {
1986
- throw error;
1987
- }
1988
- }
1989
- }
1990
- if (migrated > 0) {
1991
- console.log(` ${import_chalk.default.green("\u2713")} Updated ${migrated} project(s) to v${VERSION}`);
1992
- }
1993
- } catch (error) {
1994
- if (!isNotFoundError(error)) {
1995
- logger_default.warn(`Migration warning: ${getErrorMessage(error)}`);
1996
- }
1997
- }
1998
- }
1999
- __name(migrateProjectsCliVersion, "migrateProjectsCliVersion");
2000
- async function ensureStatusLineSettings(settingsPath, statusLinePath) {
2001
- let settings = {};
2002
- if (await fileExists(settingsPath)) {
2003
- try {
2004
- settings = JSON.parse(await import_promises5.default.readFile(settingsPath, "utf8"));
2005
- } catch (error) {
2006
- if (!(error instanceof SyntaxError)) {
2007
- throw error;
2008
- }
2009
- }
2010
- }
2011
- settings.statusLine = { type: "command", command: statusLinePath };
2012
- await import_promises5.default.writeFile(settingsPath, JSON.stringify(settings, null, 2));
2013
- }
2014
- __name(ensureStatusLineSettings, "ensureStatusLineSettings");
2015
- async function installStatusLine() {
2016
- try {
2017
- const claudeDir = import_node_path6.default.join(import_node_os5.default.homedir(), ".claude");
2018
- const settingsPath = import_node_path6.default.join(claudeDir, "settings.json");
2019
- const claudeStatusLinePath = import_node_path6.default.join(claudeDir, "prjct-statusline.sh");
2020
- const prjctStatusLineDir = import_node_path6.default.join(import_node_os5.default.homedir(), ".prjct-cli", "statusline");
2021
- const prjctStatusLinePath = import_node_path6.default.join(prjctStatusLineDir, "statusline.sh");
2022
- const prjctThemesDir = import_node_path6.default.join(prjctStatusLineDir, "themes");
2023
- const prjctLibDir = import_node_path6.default.join(prjctStatusLineDir, "lib");
2024
- const prjctComponentsDir = import_node_path6.default.join(prjctStatusLineDir, "components");
2025
- const prjctConfigPath = import_node_path6.default.join(prjctStatusLineDir, "config.json");
2026
- const assetsDir = import_node_path6.default.join(PACKAGE_ROOT, "assets", "statusline");
2027
- const sourceScript = import_node_path6.default.join(assetsDir, "statusline.sh");
2028
- const sourceThemeDir = import_node_path6.default.join(assetsDir, "themes");
2029
- const sourceLibDir = import_node_path6.default.join(assetsDir, "lib");
2030
- const sourceComponentsDir = import_node_path6.default.join(assetsDir, "components");
2031
- const sourceConfigPath = import_node_path6.default.join(assetsDir, "default-config.json");
2032
- if (!await fileExists(claudeDir)) {
2033
- await import_promises5.default.mkdir(claudeDir, { recursive: true });
2034
- }
2035
- if (!await fileExists(prjctStatusLineDir)) {
2036
- await import_promises5.default.mkdir(prjctStatusLineDir, { recursive: true });
2037
- }
2038
- if (!await fileExists(prjctThemesDir)) {
2039
- await import_promises5.default.mkdir(prjctThemesDir, { recursive: true });
2040
- }
2041
- if (!await fileExists(prjctLibDir)) {
2042
- await import_promises5.default.mkdir(prjctLibDir, { recursive: true });
2043
- }
2044
- if (!await fileExists(prjctComponentsDir)) {
2045
- await import_promises5.default.mkdir(prjctComponentsDir, { recursive: true });
2046
- }
2047
- if (await fileExists(prjctStatusLinePath)) {
2048
- const existingContent = await import_promises5.default.readFile(prjctStatusLinePath, "utf8");
2049
- if (existingContent.includes("CLI_VERSION=")) {
2050
- const versionMatch = existingContent.match(/CLI_VERSION="([^"]*)"/);
2051
- if (versionMatch && versionMatch[1] !== VERSION) {
2052
- const updatedContent = existingContent.replace(
2053
- /CLI_VERSION="[^"]*"/,
2054
- `CLI_VERSION="${VERSION}"`
2055
- );
2056
- await import_promises5.default.writeFile(prjctStatusLinePath, updatedContent, { mode: 493 });
2057
- }
2058
- await installStatusLineModules(sourceLibDir, prjctLibDir);
2059
- await installStatusLineModules(sourceComponentsDir, prjctComponentsDir);
2060
- await ensureStatusLineSymlink(claudeStatusLinePath, prjctStatusLinePath);
2061
- await ensureStatusLineSettings(settingsPath, claudeStatusLinePath);
2062
- return;
2063
- }
2064
- }
2065
- if (await fileExists(sourceScript)) {
2066
- let scriptContent = await import_promises5.default.readFile(sourceScript, "utf8");
2067
- scriptContent = scriptContent.replace(/CLI_VERSION="[^"]*"/, `CLI_VERSION="${VERSION}"`);
2068
- await import_promises5.default.writeFile(prjctStatusLinePath, scriptContent, { mode: 493 });
2069
- await installStatusLineModules(sourceLibDir, prjctLibDir);
2070
- await installStatusLineModules(sourceComponentsDir, prjctComponentsDir);
2071
- if (await fileExists(sourceThemeDir)) {
2072
- const themes = await import_promises5.default.readdir(sourceThemeDir);
2073
- for (const theme of themes) {
2074
- const src = import_node_path6.default.join(sourceThemeDir, theme);
2075
- const dest = import_node_path6.default.join(prjctThemesDir, theme);
2076
- await import_promises5.default.copyFile(src, dest);
2077
- }
2078
- }
2079
- if (!await fileExists(prjctConfigPath) && await fileExists(sourceConfigPath)) {
2080
- await import_promises5.default.copyFile(sourceConfigPath, prjctConfigPath);
2081
- }
2082
- } else {
2083
- const scriptContent = `#!/bin/bash
2084
- # prjct Status Line for Claude Code
2085
- CLI_VERSION="${VERSION}"
2086
- input=$(cat)
2087
- CWD=$(echo "$input" | jq -r '.workspace.current_dir // "~"' 2>/dev/null)
2088
- CONFIG="$CWD/.prjct/prjct.config.json"
2089
- if [ -f "$CONFIG" ]; then
2090
- PROJECT_ID=$(jq -r '.projectId // ""' "$CONFIG" 2>/dev/null)
2091
- if [ -n "$PROJECT_ID" ]; then
2092
- PROJECT_JSON="$HOME/.prjct-cli/projects/$PROJECT_ID/project.json"
2093
- if [ -f "$PROJECT_JSON" ]; then
2094
- PROJECT_VERSION=$(jq -r '.cliVersion // ""' "$PROJECT_JSON" 2>/dev/null)
2095
- if [ -z "$PROJECT_VERSION" ] || [ "$PROJECT_VERSION" != "$CLI_VERSION" ]; then
2096
- echo "prjct v$CLI_VERSION - run p. sync"
2097
- exit 0
2098
- fi
2099
- else
2100
- echo "prjct v$CLI_VERSION - run p. sync"
2101
- exit 0
2102
- fi
2103
- STATE="$HOME/.prjct-cli/projects/$PROJECT_ID/storage/state.json"
2104
- if [ -f "$STATE" ]; then
2105
- TASK=$(jq -r '.currentTask.description // ""' "$STATE" 2>/dev/null)
2106
- if [ -n "$TASK" ]; then
2107
- echo "$TASK"
2108
- exit 0
2109
- fi
2110
- fi
2111
- fi
2112
- fi
2113
- echo "prjct"
2114
- `;
2115
- await import_promises5.default.writeFile(prjctStatusLinePath, scriptContent, { mode: 493 });
2116
- }
2117
- await ensureStatusLineSymlink(claudeStatusLinePath, prjctStatusLinePath);
2118
- await ensureStatusLineSettings(settingsPath, claudeStatusLinePath);
2119
- } catch (error) {
2120
- if (!isNotFoundError(error)) {
2121
- logger_default.warn(`Status line warning: ${getErrorMessage(error)}`);
2122
- }
2123
- }
2124
- }
2125
- __name(installStatusLine, "installStatusLine");
2126
- async function installContext7MCP() {
2127
- try {
2128
- const claudeDir = import_node_path6.default.join(import_node_os5.default.homedir(), ".claude");
2129
- const mcpConfigPath = import_node_path6.default.join(claudeDir, "mcp.json");
2130
- if (!await fileExists(claudeDir)) {
2131
- await import_promises5.default.mkdir(claudeDir, { recursive: true });
2132
- }
2133
- const context7Config = {
2134
- mcpServers: {
2135
- context7: {
2136
- command: "npx",
2137
- args: ["-y", "@upstash/context7-mcp@latest"]
2138
- }
2139
- }
2140
- };
2141
- if (await fileExists(mcpConfigPath)) {
2142
- const existingContent = await import_promises5.default.readFile(mcpConfigPath, "utf-8");
2143
- const existingConfig = JSON.parse(existingContent);
2144
- if (existingConfig.mcpServers?.context7) {
2145
- return;
2146
- }
2147
- existingConfig.mcpServers = existingConfig.mcpServers || {};
2148
- existingConfig.mcpServers.context7 = context7Config.mcpServers.context7;
2149
- await import_promises5.default.writeFile(mcpConfigPath, JSON.stringify(existingConfig, null, 2), "utf-8");
2150
- } else {
2151
- await import_promises5.default.writeFile(mcpConfigPath, JSON.stringify(context7Config, null, 2), "utf-8");
2152
- }
2153
- } catch (error) {
2154
- logger_default.warn(`Context7 MCP setup warning: ${getErrorMessage(error)}`);
2155
- }
2156
- }
2157
- __name(installContext7MCP, "installContext7MCP");
2158
- async function installStatusLineModules(sourceDir, destDir) {
2159
- if (!await fileExists(sourceDir)) {
2160
- return;
2161
- }
2162
- const files = await import_promises5.default.readdir(sourceDir);
2163
- for (const file of files) {
2164
- if (file.endsWith(".sh")) {
2165
- const src = import_node_path6.default.join(sourceDir, file);
2166
- const dest = import_node_path6.default.join(destDir, file);
2167
- await import_promises5.default.copyFile(src, dest);
2168
- await import_promises5.default.chmod(dest, 493);
2169
- }
2170
- }
2171
- }
2172
- __name(installStatusLineModules, "installStatusLineModules");
2173
- async function ensureStatusLineSymlink(linkPath, targetPath) {
2174
- try {
2175
- if (await fileExists(linkPath)) {
2176
- const stats = await import_promises5.default.lstat(linkPath);
2177
- if (stats.isSymbolicLink()) {
2178
- const existingTarget = await import_promises5.default.readlink(linkPath);
2179
- if (existingTarget === targetPath) {
2180
- return;
2181
- }
2182
- }
2183
- await import_promises5.default.unlink(linkPath);
2184
- }
2185
- await import_promises5.default.symlink(targetPath, linkPath);
2186
- } catch (_error) {
2187
- try {
2188
- if (await fileExists(targetPath)) {
2189
- await import_promises5.default.copyFile(targetPath, linkPath);
2190
- await import_promises5.default.chmod(linkPath, 493);
2191
- }
2192
- } catch (copyError) {
2193
- if (!isNotFoundError(copyError)) {
2194
- logger_default.warn(`Symlink fallback warning: ${copyError.message}`);
2195
- }
2196
- }
2197
- }
2198
- }
2199
- __name(ensureStatusLineSymlink, "ensureStatusLineSymlink");
2200
- function showResults(results, provider) {
2201
- console.log("");
2202
- if (results.cliInstalled) {
2203
- console.log(` ${import_chalk.default.green("\u2713")} ${provider.displayName} CLI installed`);
2204
- } else {
2205
- console.log(` ${import_chalk.default.green("\u2713")} ${provider.displayName} CLI found`);
2206
- }
2207
- const totalCommands = results.commandsAdded + results.commandsUpdated;
2208
- if (totalCommands > 0) {
2209
- const parts = [];
2210
- if (results.commandsAdded > 0) parts.push(`${results.commandsAdded} new`);
2211
- if (results.commandsUpdated > 0) parts.push(`${results.commandsUpdated} updated`);
2212
- console.log(` ${import_chalk.default.green("\u2713")} Commands synced (${parts.join(", ")})`);
2213
- } else {
2214
- console.log(` ${import_chalk.default.green("\u2713")} Commands up to date`);
2215
- }
2216
- if (results.configAction === "created") {
2217
- console.log(` ${import_chalk.default.green("\u2713")} Global config created (${provider.contextFile})`);
2218
- } else if (results.configAction === "updated") {
2219
- console.log(` ${import_chalk.default.green("\u2713")} Global config updated (${provider.contextFile})`);
2220
- } else if (results.configAction === "appended") {
2221
- console.log(` ${import_chalk.default.green("\u2713")} Global config merged (${provider.contextFile})`);
2222
- }
2223
- console.log("");
2224
- }
2225
- __name(showResults, "showResults");
2226
- var isDirectRun = process.argv[1]?.includes("setup.ts") || process.argv[1]?.includes("setup.js");
2227
- if (isDirectRun) {
2228
- run().catch((error) => {
2229
- console.error("Setup error:", error.message);
2230
- process.exit(1);
2231
- });
2232
- }
2233
- // Annotate the CommonJS export names for ESM import in node:
2234
- 0 && (module.exports = {
2235
- hasCursorProject,
2236
- hasWindsurfProject,
2237
- installAntigravitySkill,
2238
- installCursorProject,
2239
- installWindsurfProject,
2240
- needsAntigravityInstallation,
2241
- needsCursorRegeneration,
2242
- needsWindsurfRegeneration,
2243
- run
2244
- });