prjct-cli 0.35.2 → 0.35.4

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 (406) hide show
  1. package/core/commands/analysis.ts +58 -32
  2. package/core/commands/command-data.ts +11 -50
  3. package/core/commands/commands.ts +18 -21
  4. package/core/commands/context.ts +238 -0
  5. package/core/commands/register.ts +7 -5
  6. package/core/commands/setup.ts +1 -17
  7. package/core/commands/workflow.ts +3 -2
  8. package/core/index.ts +2 -4
  9. package/core/services/index.ts +2 -0
  10. package/core/services/sync-service.ts +1080 -0
  11. package/core/types/commands.ts +0 -12
  12. package/core/types/index.ts +0 -1
  13. package/dist/bin/prjct.mjs +1219 -310
  14. package/package.json +2 -8
  15. package/templates/_bases/tracker-base.md +309 -0
  16. package/templates/agentic/agent-routing.md +22 -88
  17. package/templates/agentic/agents/uxui.md +42 -197
  18. package/templates/agentic/context-filtering.md +14 -56
  19. package/templates/agentic/orchestrator.md +31 -365
  20. package/templates/agentic/skill-integration.md +37 -289
  21. package/templates/agentic/subagent-generation.md +31 -104
  22. package/templates/agentic/task-fragmentation.md +39 -273
  23. package/templates/agents/AGENTS.md +32 -188
  24. package/templates/commands/bug.md +22 -520
  25. package/templates/commands/dash.md +26 -161
  26. package/templates/commands/done.md +19 -250
  27. package/templates/commands/enrich.md +21 -732
  28. package/templates/commands/github.md +9 -0
  29. package/templates/commands/history.md +296 -83
  30. package/templates/commands/idea.md +18 -160
  31. package/templates/commands/init.md +20 -209
  32. package/templates/commands/jira.md +9 -0
  33. package/templates/commands/linear.md +9 -0
  34. package/templates/commands/merge.md +21 -185
  35. package/templates/commands/monday.md +9 -0
  36. package/templates/commands/next.md +21 -103
  37. package/templates/commands/p.md +198 -63
  38. package/templates/commands/pause.md +21 -272
  39. package/templates/commands/resume.md +19 -348
  40. package/templates/commands/setup.md +0 -1
  41. package/templates/commands/ship.md +30 -627
  42. package/templates/commands/sync.md +11 -1345
  43. package/templates/commands/task.md +17 -439
  44. package/templates/commands/test.md +30 -259
  45. package/CLAUDE.md +0 -211
  46. package/packages/shared/node_modules/@types/bun/LICENSE +0 -21
  47. package/packages/shared/node_modules/@types/bun/README.md +0 -20
  48. package/packages/shared/node_modules/@types/bun/index.d.ts +0 -1
  49. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/CLAUDE.md +0 -105
  50. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/README.md +0 -33
  51. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/bun.d.ts +0 -7032
  52. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/bun.ns.d.ts +0 -5
  53. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/bundle.d.ts +0 -74
  54. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/deprecated.d.ts +0 -184
  55. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/devserver.d.ts +0 -187
  56. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/README.md +0 -28
  57. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/bytecode.mdx +0 -465
  58. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/css.mdx +0 -1024
  59. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/esbuild.mdx +0 -298
  60. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/executables.mdx +0 -1277
  61. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/fullstack.mdx +0 -1086
  62. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/hot-reloading.mdx +0 -229
  63. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/html-static.mdx +0 -488
  64. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/index.mdx +0 -1604
  65. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/loaders.mdx +0 -451
  66. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/macros.mdx +0 -328
  67. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/minifier.mdx +0 -1286
  68. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/plugins.mdx +0 -425
  69. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/feedback.mdx +0 -75
  70. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/arraybuffer-to-array.mdx +0 -29
  71. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/arraybuffer-to-blob.mdx +0 -26
  72. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/arraybuffer-to-buffer.mdx +0 -27
  73. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/arraybuffer-to-string.mdx +0 -17
  74. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/arraybuffer-to-typedarray.mdx +0 -41
  75. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/blob-to-arraybuffer.mdx +0 -16
  76. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/blob-to-dataview.mdx +0 -16
  77. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/blob-to-stream.mdx +0 -16
  78. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/blob-to-string.mdx +0 -17
  79. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/blob-to-typedarray.mdx +0 -16
  80. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/buffer-to-arraybuffer.mdx +0 -16
  81. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/buffer-to-blob.mdx +0 -16
  82. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/buffer-to-readablestream.mdx +0 -43
  83. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/buffer-to-string.mdx +0 -27
  84. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/buffer-to-typedarray.mdx +0 -16
  85. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/dataview-to-string.mdx +0 -17
  86. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/typedarray-to-arraybuffer.mdx +0 -27
  87. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/typedarray-to-blob.mdx +0 -18
  88. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/typedarray-to-buffer.mdx +0 -16
  89. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/typedarray-to-dataview.mdx +0 -16
  90. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/typedarray-to-readablestream.mdx +0 -43
  91. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/typedarray-to-string.mdx +0 -18
  92. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/deployment/aws-lambda.mdx +0 -204
  93. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/deployment/digital-ocean.mdx +0 -161
  94. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/deployment/google-cloud-run.mdx +0 -194
  95. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/deployment/railway.mdx +0 -145
  96. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/deployment/render.mdx +0 -82
  97. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/deployment/vercel.mdx +0 -97
  98. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/astro.mdx +0 -82
  99. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/discordjs.mdx +0 -80
  100. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/docker.mdx +0 -151
  101. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/drizzle.mdx +0 -195
  102. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/elysia.mdx +0 -31
  103. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/express.mdx +0 -43
  104. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/gel.mdx +0 -261
  105. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/hono.mdx +0 -47
  106. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/mongoose.mdx +0 -92
  107. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/neon-drizzle.mdx +0 -234
  108. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/neon-serverless-postgres.mdx +0 -60
  109. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/nextjs.mdx +0 -103
  110. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/nuxt.mdx +0 -96
  111. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/pm2.mdx +0 -55
  112. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/prisma-postgres.mdx +0 -169
  113. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/prisma.mdx +0 -164
  114. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/qwik.mdx +0 -114
  115. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/react.mdx +0 -52
  116. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/remix.mdx +0 -97
  117. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/sentry.mdx +0 -54
  118. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/solidstart.mdx +0 -62
  119. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/ssr-react.mdx +0 -49
  120. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/stric.mdx +0 -54
  121. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/sveltekit.mdx +0 -138
  122. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/systemd.mdx +0 -114
  123. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/tanstack-start.mdx +0 -791
  124. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/upstash.mdx +0 -87
  125. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/vite.mdx +0 -77
  126. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/html-rewriter/extract-links.mdx +0 -71
  127. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/html-rewriter/extract-social-meta.mdx +0 -97
  128. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/cluster.mdx +0 -69
  129. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/fetch-unix.mdx +0 -35
  130. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/fetch.mdx +0 -26
  131. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/file-uploads.mdx +0 -97
  132. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/hot.mdx +0 -28
  133. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/proxy.mdx +0 -50
  134. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/server.mdx +0 -48
  135. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/simple.mdx +0 -20
  136. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/stream-file.mdx +0 -50
  137. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/stream-iterator.mdx +0 -49
  138. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/stream-node-streams-in-bun.mdx +0 -22
  139. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/tls.mdx +0 -32
  140. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/index.mdx +0 -10
  141. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/add-dev.mdx +0 -28
  142. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/add-git.mdx +0 -40
  143. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/add-optional.mdx +0 -27
  144. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/add-peer.mdx +0 -45
  145. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/add-tarball.mdx +0 -35
  146. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/add.mdx +0 -44
  147. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/azure-artifacts.mdx +0 -76
  148. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/cicd.mdx +0 -43
  149. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/custom-registry.mdx +0 -32
  150. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/from-npm-install-to-bun-install.mdx +0 -230
  151. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/git-diff-bun-lockfile.mdx +0 -48
  152. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/jfrog-artifactory.mdx +0 -28
  153. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/npm-alias.mdx +0 -25
  154. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/registry-scope.mdx +0 -40
  155. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/trusted.mdx +0 -52
  156. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/workspaces.mdx +0 -70
  157. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/yarnlock.mdx +0 -51
  158. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/argv.mdx +0 -66
  159. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/ctrl-c.mdx +0 -18
  160. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/ipc.mdx +0 -69
  161. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/nanoseconds.mdx +0 -15
  162. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/os-signals.mdx +0 -31
  163. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/spawn-stderr.mdx +0 -34
  164. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/spawn-stdout.mdx +0 -28
  165. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/spawn.mdx +0 -43
  166. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/stdin.mdx +0 -62
  167. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/arraybuffer.mdx +0 -30
  168. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/buffer.mdx +0 -21
  169. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/exists.mdx +0 -18
  170. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/json.mdx +0 -19
  171. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/mime.mdx +0 -22
  172. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/stream.mdx +0 -28
  173. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/string.mdx +0 -24
  174. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/uint8array.mdx +0 -23
  175. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/watch.mdx +0 -66
  176. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/build-time-constants.mdx +0 -295
  177. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/cicd.mdx +0 -45
  178. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/codesign-macos-executable.mdx +0 -61
  179. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/define-constant.mdx +0 -149
  180. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/delete-directory.mdx +0 -39
  181. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/delete-file.mdx +0 -21
  182. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/heap-snapshot.mdx +0 -28
  183. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/import-html.mdx +0 -15
  184. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/import-json.mdx +0 -46
  185. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/import-toml.mdx +0 -32
  186. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/import-yaml.mdx +0 -104
  187. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/read-env.mdx +0 -37
  188. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/set-env.mdx +0 -51
  189. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/shell.mdx +0 -42
  190. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/timezone.mdx +0 -38
  191. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/tsconfig-paths.mdx +0 -31
  192. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/typescript.mdx +0 -51
  193. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/vscode-debugger.mdx +0 -47
  194. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/web-debugger.mdx +0 -103
  195. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/node-readable-to-arraybuffer.mdx +0 -13
  196. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/node-readable-to-blob.mdx +0 -13
  197. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/node-readable-to-json.mdx +0 -14
  198. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/node-readable-to-string.mdx +0 -14
  199. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/node-readable-to-uint8array.mdx +0 -13
  200. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/to-array.mdx +0 -16
  201. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/to-arraybuffer.mdx +0 -16
  202. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/to-blob.mdx +0 -16
  203. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/to-buffer.mdx +0 -17
  204. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/to-json.mdx +0 -16
  205. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/to-string.mdx +0 -16
  206. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/to-typedarray.mdx +0 -24
  207. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/bail.mdx +0 -24
  208. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/concurrent-test-glob.mdx +0 -146
  209. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/coverage-threshold.mdx +0 -67
  210. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/coverage.mdx +0 -49
  211. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/happy-dom.mdx +0 -73
  212. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/migrate-from-jest.mdx +0 -125
  213. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/mock-clock.mdx +0 -50
  214. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/mock-functions.mdx +0 -70
  215. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/rerun-each.mdx +0 -16
  216. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/run-tests.mdx +0 -116
  217. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/skip-tests.mdx +0 -43
  218. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/snapshot.mdx +0 -102
  219. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/spy-on.mdx +0 -49
  220. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/svelte-test.mdx +0 -113
  221. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/testing-library.mdx +0 -93
  222. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/timeout.mdx +0 -17
  223. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/todo-tests.mdx +0 -74
  224. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/update-snapshots.mdx +0 -49
  225. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/watch-mode.mdx +0 -24
  226. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/base64.mdx +0 -17
  227. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/deep-equals.mdx +0 -41
  228. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/deflate.mdx +0 -20
  229. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/detect-bun.mdx +0 -28
  230. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/entrypoint.mdx +0 -19
  231. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/escape-html.mdx +0 -24
  232. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/file-url-to-path.mdx +0 -16
  233. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/gzip.mdx +0 -20
  234. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/hash-a-password.mdx +0 -56
  235. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/import-meta-dir.mdx +0 -15
  236. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/import-meta-file.mdx +0 -15
  237. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/import-meta-path.mdx +0 -15
  238. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/javascript-uuid.mdx +0 -25
  239. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/main.mdx +0 -43
  240. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/path-to-file-url.mdx +0 -16
  241. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/sleep.mdx +0 -24
  242. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/upgrade.mdx +0 -93
  243. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/version.mdx +0 -23
  244. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/which-path-to-executable-bin.mdx +0 -17
  245. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/websocket/compression.mdx +0 -33
  246. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/websocket/context.mdx +0 -79
  247. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/websocket/pubsub.mdx +0 -43
  248. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/websocket/simple.mdx +0 -38
  249. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/append.mdx +0 -54
  250. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/basic.mdx +0 -46
  251. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/blob.mdx +0 -30
  252. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/cat.mdx +0 -19
  253. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/file-cp.mdx +0 -18
  254. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/filesink.mdx +0 -54
  255. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/response.mdx +0 -19
  256. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/stdout.mdx +0 -23
  257. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/stream.mdx +0 -19
  258. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/unlink.mdx +0 -18
  259. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/index.mdx +0 -133
  260. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/installation.mdx +0 -365
  261. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/bunx.mdx +0 -91
  262. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/catalogs.mdx +0 -292
  263. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/add.mdx +0 -179
  264. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/audit.mdx +0 -60
  265. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/info.mdx +0 -70
  266. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/install.mdx +0 -606
  267. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/link.mdx +0 -61
  268. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/outdated.mdx +0 -197
  269. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/patch.mdx +0 -69
  270. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/pm.mdx +0 -323
  271. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/publish.mdx +0 -131
  272. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/remove.mdx +0 -16
  273. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/update.mdx +0 -140
  274. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/why.mdx +0 -84
  275. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/filter.mdx +0 -102
  276. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/global-cache.mdx +0 -72
  277. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/isolated-installs.mdx +0 -220
  278. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/lifecycle.mdx +0 -64
  279. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/lockfile.mdx +0 -64
  280. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/npmrc.mdx +0 -111
  281. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/overrides.mdx +0 -83
  282. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/scopes-registries.mdx +0 -35
  283. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/security-scanner-api.mdx +0 -95
  284. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/workspaces.mdx +0 -115
  285. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/project/benchmarking.mdx +0 -241
  286. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/project/bindgen.mdx +0 -223
  287. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/project/building-windows.mdx +0 -133
  288. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/project/contributing.mdx +0 -388
  289. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/project/feedback.mdx +0 -20
  290. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/project/license.mdx +0 -78
  291. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/project/roadmap.mdx +0 -8
  292. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/quickstart.mdx +0 -251
  293. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/auto-install.mdx +0 -97
  294. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/binary-data.mdx +0 -846
  295. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/bun-apis.mdx +0 -59
  296. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/bunfig.mdx +0 -723
  297. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/c-compiler.mdx +0 -204
  298. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/child-process.mdx +0 -659
  299. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/color.mdx +0 -267
  300. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/console.mdx +0 -67
  301. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/cookies.mdx +0 -454
  302. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/debugger.mdx +0 -335
  303. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/environment-variables.mdx +0 -231
  304. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/ffi.mdx +0 -565
  305. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/file-io.mdx +0 -306
  306. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/file-system-router.mdx +0 -118
  307. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/file-types.mdx +0 -435
  308. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/glob.mdx +0 -181
  309. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/globals.mdx +0 -72
  310. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/hashing.mdx +0 -315
  311. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/html-rewriter.mdx +0 -333
  312. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/http/cookies.mdx +0 -79
  313. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/http/error-handling.mdx +0 -40
  314. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/http/metrics.mdx +0 -36
  315. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/http/routing.mdx +0 -289
  316. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/http/server.mdx +0 -645
  317. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/http/tls.mdx +0 -101
  318. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/http/websockets.mdx +0 -414
  319. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/index.mdx +0 -223
  320. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/jsx.mdx +0 -115
  321. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/module-resolution.mdx +0 -374
  322. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/networking/dns.mdx +0 -111
  323. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/networking/fetch.mdx +0 -484
  324. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/networking/tcp.mdx +0 -239
  325. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/networking/udp.mdx +0 -129
  326. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/node-api.mdx +0 -19
  327. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/nodejs-compat.mdx +0 -468
  328. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/plugins.mdx +0 -419
  329. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/redis.mdx +0 -583
  330. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/s3.mdx +0 -863
  331. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/secrets.mdx +0 -340
  332. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/semver.mdx +0 -57
  333. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/shell.mdx +0 -637
  334. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/sql.mdx +0 -1404
  335. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/sqlite.mdx +0 -721
  336. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/streams.mdx +0 -232
  337. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/templating/create.mdx +0 -269
  338. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/templating/init.mdx +0 -58
  339. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/transpiler.mdx +0 -288
  340. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/typescript.mdx +0 -58
  341. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/utils.mdx +0 -922
  342. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/watch-mode.mdx +0 -161
  343. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/web-apis.mdx +0 -29
  344. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/workers.mdx +0 -314
  345. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/yaml.mdx +0 -469
  346. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/add.mdx +0 -166
  347. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/build.mdx +0 -196
  348. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/bunx.mdx +0 -49
  349. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/feedback.mdx +0 -17
  350. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/init.mdx +0 -84
  351. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/install.mdx +0 -173
  352. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/link.mdx +0 -163
  353. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/outdated.mdx +0 -140
  354. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/patch.mdx +0 -171
  355. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/publish.mdx +0 -198
  356. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/remove.mdx +0 -146
  357. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/run.mdx +0 -293
  358. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/test.mdx +0 -100
  359. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/update.mdx +0 -144
  360. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/code-coverage.mdx +0 -409
  361. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/configuration.mdx +0 -514
  362. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/dates-times.mdx +0 -129
  363. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/discovery.mdx +0 -90
  364. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/dom.mdx +0 -226
  365. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/index.mdx +0 -380
  366. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/lifecycle.mdx +0 -366
  367. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/mocks.mdx +0 -637
  368. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/reporters.mdx +0 -126
  369. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/runtime-behavior.mdx +0 -342
  370. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/snapshots.mdx +0 -434
  371. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/writing-tests.mdx +0 -672
  372. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/typescript.mdx +0 -54
  373. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/extensions.d.ts +0 -35
  374. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/fetch.d.ts +0 -79
  375. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/ffi.d.ts +0 -1154
  376. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/globals.d.ts +0 -2067
  377. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/html-rewriter.d.ts +0 -186
  378. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/index.d.ts +0 -32
  379. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/jsc.d.ts +0 -233
  380. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/overrides.d.ts +0 -376
  381. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/package.json +0 -37
  382. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/redis.d.ts +0 -3352
  383. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/s3.d.ts +0 -1299
  384. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/security.d.ts +0 -101
  385. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/serve.d.ts +0 -1296
  386. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/shell.d.ts +0 -380
  387. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/sql.d.ts +0 -887
  388. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/sqlite.d.ts +0 -1321
  389. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/test-globals.d.ts +0 -22
  390. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/test.d.ts +0 -2391
  391. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/branding.d.ts +0 -283
  392. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/index.d.ts +0 -1207
  393. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/messages.d.ts +0 -395
  394. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/overloads.d.ts +0 -669
  395. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/utils.d.ts +0 -431
  396. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/wasm.d.ts +0 -193
  397. package/packages/shared/node_modules/@types/bun/package.json +0 -53
  398. package/packages/shared/package.json +0 -29
  399. package/packages/shared/src/index.ts +0 -10
  400. package/packages/shared/src/schemas.ts +0 -124
  401. package/packages/shared/src/types.ts +0 -187
  402. package/packages/shared/src/unified.ts +0 -174
  403. package/packages/shared/src/utils.ts +0 -148
  404. package/packages/shared/tsconfig.json +0 -18
  405. package/templates/commands/redo.md +0 -144
  406. package/templates/commands/undo.md +0 -154
@@ -0,0 +1,1080 @@
1
+ /**
2
+ * SyncService - Comprehensive Project Sync
3
+ *
4
+ * Handles ALL sync operations in a single TypeScript execution:
5
+ * - Git analysis
6
+ * - Project stats
7
+ * - Context file generation
8
+ * - Agent generation
9
+ * - Skill configuration
10
+ * - State updates
11
+ *
12
+ * This eliminates the need for Claude to make 50+ individual tool calls.
13
+ * Instead, one command does everything.
14
+ *
15
+ * @version 1.0.0
16
+ */
17
+
18
+ import fs from 'fs/promises'
19
+ import path from 'path'
20
+ import { exec } from 'child_process'
21
+ import { promisify } from 'util'
22
+ import pathManager from '../infrastructure/path-manager'
23
+ import configManager from '../infrastructure/config-manager'
24
+ import dateHelper from '../utils/date-helper'
25
+
26
+ const execAsync = promisify(exec)
27
+
28
+ // ============================================================================
29
+ // TYPES
30
+ // ============================================================================
31
+
32
+ interface GitData {
33
+ branch: string
34
+ commits: number
35
+ contributors: number
36
+ hasChanges: boolean
37
+ stagedFiles: string[]
38
+ modifiedFiles: string[]
39
+ untrackedFiles: string[]
40
+ recentCommits: { hash: string; message: string; date: string }[]
41
+ weeklyCommits: number
42
+ }
43
+
44
+ interface ProjectStats {
45
+ fileCount: number
46
+ version: string
47
+ name: string
48
+ ecosystem: string
49
+ projectType: string
50
+ languages: string[]
51
+ frameworks: string[]
52
+ }
53
+
54
+ interface Commands {
55
+ install: string
56
+ run: string
57
+ test: string
58
+ build: string
59
+ dev: string
60
+ lint: string
61
+ format: string
62
+ }
63
+
64
+ interface StackDetection {
65
+ hasFrontend: boolean
66
+ hasBackend: boolean
67
+ hasDatabase: boolean
68
+ hasDocker: boolean
69
+ hasTesting: boolean
70
+ frontendType: 'web' | 'mobile' | 'both' | null
71
+ frameworks: string[]
72
+ }
73
+
74
+ interface AgentInfo {
75
+ name: string
76
+ type: 'workflow' | 'domain'
77
+ skill?: string
78
+ }
79
+
80
+ interface SyncResult {
81
+ success: boolean
82
+ projectId: string
83
+ cliVersion: string
84
+ git: GitData
85
+ stats: ProjectStats
86
+ commands: Commands
87
+ stack: StackDetection
88
+ agents: AgentInfo[]
89
+ skills: { agent: string; skill: string }[]
90
+ contextFiles: string[]
91
+ error?: string
92
+ }
93
+
94
+ // ============================================================================
95
+ // SYNC SERVICE
96
+ // ============================================================================
97
+
98
+ class SyncService {
99
+ private projectPath: string
100
+ private projectId: string | null = null
101
+ private globalPath: string = ''
102
+ private cliVersion: string = '0.0.0'
103
+
104
+ constructor() {
105
+ this.projectPath = process.cwd()
106
+ }
107
+
108
+ /**
109
+ * Main sync method - does everything in one call
110
+ */
111
+ async sync(projectPath: string = process.cwd()): Promise<SyncResult> {
112
+ this.projectPath = projectPath
113
+
114
+ try {
115
+ // 1. Get project config
116
+ this.projectId = await configManager.getProjectId(projectPath)
117
+ if (!this.projectId) {
118
+ return {
119
+ success: false,
120
+ projectId: '',
121
+ cliVersion: '',
122
+ git: this.emptyGitData(),
123
+ stats: this.emptyStats(),
124
+ commands: this.emptyCommands(),
125
+ stack: this.emptyStack(),
126
+ agents: [],
127
+ skills: [],
128
+ contextFiles: [],
129
+ error: 'No prjct project. Run p. init first.',
130
+ }
131
+ }
132
+
133
+ this.globalPath = pathManager.getGlobalProjectPath(this.projectId)
134
+ this.cliVersion = await this.getCliVersion()
135
+
136
+ // 2. Ensure directories exist
137
+ await this.ensureDirectories()
138
+
139
+ // 3. Gather all data
140
+ const git = await this.analyzeGit()
141
+ const stats = await this.gatherStats()
142
+ const commands = await this.detectCommands()
143
+ const stack = await this.detectStack()
144
+
145
+ // 4. Generate all files
146
+ const agents = await this.generateAgents(stack, stats)
147
+ const skills = this.configureSkills(agents)
148
+ const contextFiles = await this.generateContextFiles(git, stats, commands, agents)
149
+
150
+ // 5. Update project.json
151
+ await this.updateProjectJson(git, stats)
152
+
153
+ // 6. Update state.json with enterprise fields
154
+ await this.updateStateJson(stats, stack)
155
+
156
+ // 7. Log to memory
157
+ await this.logToMemory(git, stats)
158
+
159
+ return {
160
+ success: true,
161
+ projectId: this.projectId,
162
+ cliVersion: this.cliVersion,
163
+ git,
164
+ stats,
165
+ commands,
166
+ stack,
167
+ agents,
168
+ skills,
169
+ contextFiles,
170
+ }
171
+ } catch (error) {
172
+ return {
173
+ success: false,
174
+ projectId: this.projectId || '',
175
+ cliVersion: this.cliVersion,
176
+ git: this.emptyGitData(),
177
+ stats: this.emptyStats(),
178
+ commands: this.emptyCommands(),
179
+ stack: this.emptyStack(),
180
+ agents: [],
181
+ skills: [],
182
+ contextFiles: [],
183
+ error: (error as Error).message,
184
+ }
185
+ }
186
+ }
187
+
188
+ // ==========================================================================
189
+ // DIRECTORY SETUP
190
+ // ==========================================================================
191
+
192
+ private async ensureDirectories(): Promise<void> {
193
+ const dirs = ['storage', 'context', 'agents', 'memory', 'analysis', 'config', 'sync']
194
+ for (const dir of dirs) {
195
+ await fs.mkdir(path.join(this.globalPath, dir), { recursive: true })
196
+ }
197
+ }
198
+
199
+ // ==========================================================================
200
+ // GIT ANALYSIS
201
+ // ==========================================================================
202
+
203
+ private async analyzeGit(): Promise<GitData> {
204
+ const data: GitData = {
205
+ branch: 'main',
206
+ commits: 0,
207
+ contributors: 0,
208
+ hasChanges: false,
209
+ stagedFiles: [],
210
+ modifiedFiles: [],
211
+ untrackedFiles: [],
212
+ recentCommits: [],
213
+ weeklyCommits: 0,
214
+ }
215
+
216
+ try {
217
+ // Branch
218
+ const { stdout: branch } = await execAsync('git branch --show-current', {
219
+ cwd: this.projectPath,
220
+ })
221
+ data.branch = branch.trim() || 'main'
222
+
223
+ // Total commits
224
+ const { stdout: commits } = await execAsync('git rev-list --count HEAD', {
225
+ cwd: this.projectPath,
226
+ })
227
+ data.commits = parseInt(commits.trim()) || 0
228
+
229
+ // Contributors
230
+ const { stdout: contributors } = await execAsync('git shortlog -sn --all | wc -l', {
231
+ cwd: this.projectPath,
232
+ })
233
+ data.contributors = parseInt(contributors.trim()) || 0
234
+
235
+ // Status
236
+ const { stdout: status } = await execAsync('git status --porcelain', {
237
+ cwd: this.projectPath,
238
+ })
239
+ const lines = status.trim().split('\n').filter(Boolean)
240
+ data.hasChanges = lines.length > 0
241
+
242
+ for (const line of lines) {
243
+ const code = line.substring(0, 2)
244
+ const file = line.substring(3)
245
+ if (code.startsWith('A') || code.startsWith('M ')) {
246
+ data.stagedFiles.push(file)
247
+ } else if (code.includes('M')) {
248
+ data.modifiedFiles.push(file)
249
+ } else if (code.startsWith('??')) {
250
+ data.untrackedFiles.push(file)
251
+ }
252
+ }
253
+
254
+ // Recent commits
255
+ const { stdout: log } = await execAsync(
256
+ 'git log --oneline -20 --pretty=format:"%h|%s|%ad" --date=short',
257
+ { cwd: this.projectPath }
258
+ )
259
+ data.recentCommits = log
260
+ .split('\n')
261
+ .filter(Boolean)
262
+ .map((line) => {
263
+ const [hash, message, date] = line.split('|')
264
+ return { hash, message, date }
265
+ })
266
+
267
+ // Weekly commits
268
+ const { stdout: weekly } = await execAsync('git log --oneline --since="1 week ago" | wc -l', {
269
+ cwd: this.projectPath,
270
+ })
271
+ data.weeklyCommits = parseInt(weekly.trim()) || 0
272
+ } catch {
273
+ // Not a git repo - use defaults
274
+ }
275
+
276
+ return data
277
+ }
278
+
279
+ // ==========================================================================
280
+ // PROJECT STATS
281
+ // ==========================================================================
282
+
283
+ private async gatherStats(): Promise<ProjectStats> {
284
+ const stats: ProjectStats = {
285
+ fileCount: 0,
286
+ version: '0.0.0',
287
+ name: path.basename(this.projectPath),
288
+ ecosystem: 'unknown',
289
+ projectType: 'simple',
290
+ languages: [],
291
+ frameworks: [],
292
+ }
293
+
294
+ // Count files
295
+ try {
296
+ const { stdout } = await execAsync(
297
+ 'find . -type f \\( -name "*.js" -o -name "*.ts" -o -name "*.tsx" -o -name "*.py" -o -name "*.go" -o -name "*.rs" \\) -not -path "./node_modules/*" -not -path "./.git/*" | wc -l',
298
+ { cwd: this.projectPath }
299
+ )
300
+ stats.fileCount = parseInt(stdout.trim()) || 0
301
+ } catch {
302
+ stats.fileCount = 0
303
+ }
304
+
305
+ // Read package.json
306
+ try {
307
+ const pkgPath = path.join(this.projectPath, 'package.json')
308
+ const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf-8'))
309
+ stats.version = pkg.version || '0.0.0'
310
+ stats.name = pkg.name || stats.name
311
+ stats.ecosystem = 'JavaScript'
312
+
313
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies }
314
+
315
+ // Detect frameworks
316
+ if (deps.react || deps['react-dom']) stats.frameworks.push('React')
317
+ if (deps.next) stats.frameworks.push('Next.js')
318
+ if (deps.vue) stats.frameworks.push('Vue')
319
+ if (deps.express) stats.frameworks.push('Express')
320
+ if (deps.hono) stats.frameworks.push('Hono')
321
+ if (deps['@angular/core']) stats.frameworks.push('Angular')
322
+ if (deps.svelte) stats.frameworks.push('Svelte')
323
+
324
+ // Detect languages
325
+ if (pkg.devDependencies?.typescript || (await this.fileExists('tsconfig.json'))) {
326
+ stats.languages.push('TypeScript')
327
+ } else {
328
+ stats.languages.push('JavaScript')
329
+ }
330
+ } catch {
331
+ // No package.json
332
+ }
333
+
334
+ // Check other ecosystems
335
+ if (await this.fileExists('Cargo.toml')) {
336
+ stats.ecosystem = 'Rust'
337
+ stats.languages.push('Rust')
338
+ }
339
+ if (await this.fileExists('go.mod')) {
340
+ stats.ecosystem = 'Go'
341
+ stats.languages.push('Go')
342
+ }
343
+ if (await this.fileExists('requirements.txt') || await this.fileExists('pyproject.toml')) {
344
+ stats.ecosystem = 'Python'
345
+ stats.languages.push('Python')
346
+ }
347
+
348
+ // Determine project type
349
+ if (stats.fileCount > 300 || stats.frameworks.length >= 3) {
350
+ stats.projectType = 'enterprise'
351
+ } else if (stats.fileCount > 50 || stats.frameworks.length >= 2) {
352
+ stats.projectType = 'complex'
353
+ }
354
+
355
+ return stats
356
+ }
357
+
358
+ // ==========================================================================
359
+ // COMMAND DETECTION
360
+ // ==========================================================================
361
+
362
+ private async detectCommands(): Promise<Commands> {
363
+ const commands: Commands = {
364
+ install: 'npm install',
365
+ run: 'npm run',
366
+ test: 'npm test',
367
+ build: 'npm run build',
368
+ dev: 'npm run dev',
369
+ lint: 'npm run lint',
370
+ format: 'npm run format',
371
+ }
372
+
373
+ // Detect package manager
374
+ if (await this.fileExists('bun.lockb')) {
375
+ commands.install = 'bun install'
376
+ commands.run = 'bun run'
377
+ commands.test = 'bun test'
378
+ commands.build = 'bun run build'
379
+ commands.dev = 'bun run dev'
380
+ commands.lint = 'bun run lint'
381
+ commands.format = 'bun run format'
382
+ } else if (await this.fileExists('pnpm-lock.yaml')) {
383
+ commands.install = 'pnpm install'
384
+ commands.run = 'pnpm run'
385
+ commands.test = 'pnpm test'
386
+ commands.build = 'pnpm run build'
387
+ commands.dev = 'pnpm run dev'
388
+ commands.lint = 'pnpm run lint'
389
+ commands.format = 'pnpm run format'
390
+ } else if (await this.fileExists('yarn.lock')) {
391
+ commands.install = 'yarn'
392
+ commands.run = 'yarn'
393
+ commands.test = 'yarn test'
394
+ commands.build = 'yarn build'
395
+ commands.dev = 'yarn dev'
396
+ commands.lint = 'yarn lint'
397
+ commands.format = 'yarn format'
398
+ }
399
+
400
+ // Non-JS ecosystems
401
+ if (await this.fileExists('Cargo.toml')) {
402
+ commands.install = 'cargo build'
403
+ commands.run = 'cargo run'
404
+ commands.test = 'cargo test'
405
+ commands.build = 'cargo build --release'
406
+ commands.dev = 'cargo run'
407
+ commands.lint = 'cargo clippy'
408
+ commands.format = 'cargo fmt'
409
+ }
410
+
411
+ if (await this.fileExists('go.mod')) {
412
+ commands.install = 'go mod download'
413
+ commands.run = 'go run .'
414
+ commands.test = 'go test ./...'
415
+ commands.build = 'go build'
416
+ commands.dev = 'go run .'
417
+ commands.lint = 'golangci-lint run'
418
+ commands.format = 'go fmt ./...'
419
+ }
420
+
421
+ return commands
422
+ }
423
+
424
+ // ==========================================================================
425
+ // STACK DETECTION
426
+ // ==========================================================================
427
+
428
+ private async detectStack(): Promise<StackDetection> {
429
+ const stack: StackDetection = {
430
+ hasFrontend: false,
431
+ hasBackend: false,
432
+ hasDatabase: false,
433
+ hasDocker: false,
434
+ hasTesting: false,
435
+ frontendType: null,
436
+ frameworks: [],
437
+ }
438
+
439
+ try {
440
+ const pkgPath = path.join(this.projectPath, 'package.json')
441
+ const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf-8'))
442
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies }
443
+
444
+ // Frontend detection
445
+ if (deps.react || deps.vue || deps.svelte || deps['@angular/core']) {
446
+ stack.hasFrontend = true
447
+ stack.frontendType = 'web'
448
+ }
449
+ if (deps['react-native'] || deps.expo) {
450
+ stack.hasFrontend = true
451
+ stack.frontendType = stack.frontendType === 'web' ? 'both' : 'mobile'
452
+ }
453
+
454
+ // Backend detection
455
+ if (deps.express || deps.fastify || deps.hono || deps.koa || deps.nest) {
456
+ stack.hasBackend = true
457
+ }
458
+
459
+ // Database detection
460
+ if (deps.prisma || deps.mongoose || deps.pg || deps.mysql2 || deps.sequelize) {
461
+ stack.hasDatabase = true
462
+ }
463
+
464
+ // Testing detection
465
+ if (deps.jest || deps.vitest || deps.mocha || pkg.devDependencies?.['bun-types']) {
466
+ stack.hasTesting = true
467
+ }
468
+
469
+ // Collect frameworks
470
+ if (deps.react) stack.frameworks.push('React')
471
+ if (deps.next) stack.frameworks.push('Next.js')
472
+ if (deps.express) stack.frameworks.push('Express')
473
+ if (deps.hono) stack.frameworks.push('Hono')
474
+ } catch {
475
+ // No package.json
476
+ }
477
+
478
+ // Docker detection
479
+ stack.hasDocker =
480
+ (await this.fileExists('Dockerfile')) || (await this.fileExists('docker-compose.yml'))
481
+
482
+ return stack
483
+ }
484
+
485
+ // ==========================================================================
486
+ // AGENT GENERATION
487
+ // ==========================================================================
488
+
489
+ private async generateAgents(stack: StackDetection, stats: ProjectStats): Promise<AgentInfo[]> {
490
+ const agents: AgentInfo[] = []
491
+ const agentsPath = path.join(this.globalPath, 'agents')
492
+
493
+ // Purge old agents
494
+ try {
495
+ const files = await fs.readdir(agentsPath)
496
+ for (const file of files) {
497
+ if (file.endsWith('.md')) {
498
+ await fs.unlink(path.join(agentsPath, file))
499
+ }
500
+ }
501
+ } catch {
502
+ // Directory might not exist yet
503
+ }
504
+
505
+ // Workflow agents (always generated)
506
+ const workflowAgents = ['prjct-workflow', 'prjct-planner', 'prjct-shipper']
507
+ for (const name of workflowAgents) {
508
+ await this.generateWorkflowAgent(name, agentsPath)
509
+ agents.push({ name, type: 'workflow' })
510
+ }
511
+
512
+ // Domain agents (based on stack)
513
+ if (stack.hasFrontend) {
514
+ await this.generateDomainAgent('frontend', agentsPath, stats, stack)
515
+ agents.push({ name: 'frontend', type: 'domain', skill: 'javascript-typescript' })
516
+
517
+ await this.generateDomainAgent('uxui', agentsPath, stats, stack)
518
+ agents.push({ name: 'uxui', type: 'domain', skill: 'frontend-design' })
519
+ }
520
+
521
+ if (stack.hasBackend) {
522
+ await this.generateDomainAgent('backend', agentsPath, stats, stack)
523
+ agents.push({ name: 'backend', type: 'domain', skill: 'javascript-typescript' })
524
+ }
525
+
526
+ if (stack.hasDatabase) {
527
+ await this.generateDomainAgent('database', agentsPath, stats, stack)
528
+ agents.push({ name: 'database', type: 'domain' })
529
+ }
530
+
531
+ if (stack.hasTesting) {
532
+ await this.generateDomainAgent('testing', agentsPath, stats, stack)
533
+ agents.push({ name: 'testing', type: 'domain', skill: 'developer-kit' })
534
+ }
535
+
536
+ if (stack.hasDocker) {
537
+ await this.generateDomainAgent('devops', agentsPath, stats, stack)
538
+ agents.push({ name: 'devops', type: 'domain', skill: 'developer-kit' })
539
+ }
540
+
541
+ return agents
542
+ }
543
+
544
+ private async generateWorkflowAgent(name: string, agentsPath: string): Promise<void> {
545
+ // Try to read template
546
+ let content = ''
547
+ try {
548
+ const templatePath = path.join(
549
+ __dirname,
550
+ '..',
551
+ '..',
552
+ 'templates',
553
+ 'subagents',
554
+ 'workflow',
555
+ `${name}.md`
556
+ )
557
+ content = await fs.readFile(templatePath, 'utf-8')
558
+ } catch {
559
+ // Generate minimal agent
560
+ content = this.generateMinimalWorkflowAgent(name)
561
+ }
562
+
563
+ await fs.writeFile(path.join(agentsPath, `${name}.md`), content, 'utf-8')
564
+ }
565
+
566
+ private async generateDomainAgent(
567
+ name: string,
568
+ agentsPath: string,
569
+ stats: ProjectStats,
570
+ stack: StackDetection
571
+ ): Promise<void> {
572
+ // Try to read template
573
+ let content = ''
574
+ try {
575
+ const templatePath = path.join(
576
+ __dirname,
577
+ '..',
578
+ '..',
579
+ 'templates',
580
+ 'subagents',
581
+ 'domain',
582
+ `${name}.md`
583
+ )
584
+ content = await fs.readFile(templatePath, 'utf-8')
585
+
586
+ // Inject project-specific context
587
+ content = content.replace('{projectName}', stats.name)
588
+ content = content.replace('{frameworks}', stack.frameworks.join(', ') || 'None detected')
589
+ content = content.replace('{ecosystem}', stats.ecosystem)
590
+ } catch {
591
+ // Generate minimal agent
592
+ content = this.generateMinimalDomainAgent(name, stats, stack)
593
+ }
594
+
595
+ await fs.writeFile(path.join(agentsPath, `${name}.md`), content, 'utf-8')
596
+ }
597
+
598
+ private generateMinimalWorkflowAgent(name: string): string {
599
+ const descriptions: Record<string, string> = {
600
+ 'prjct-workflow': 'Task lifecycle: now, done, pause, resume',
601
+ 'prjct-planner': 'Planning: task, prd, spec, bug',
602
+ 'prjct-shipper': 'Shipping: ship, merge, review',
603
+ }
604
+
605
+ return `---
606
+ name: ${name}
607
+ description: ${descriptions[name] || 'Workflow agent'}
608
+ tools: Read, Write, Glob
609
+ ---
610
+
611
+ # ${name.toUpperCase()}
612
+
613
+ Workflow agent for prjct operations.
614
+
615
+ ## Project Context
616
+
617
+ When invoked:
618
+ 1. Read \`.prjct/prjct.config.json\` → extract \`projectId\`
619
+ 2. Read \`~/.prjct-cli/projects/{projectId}/storage/state.json\`
620
+ 3. Execute requested operation
621
+ `
622
+ }
623
+
624
+ private generateMinimalDomainAgent(
625
+ name: string,
626
+ stats: ProjectStats,
627
+ stack: StackDetection
628
+ ): string {
629
+ return `---
630
+ name: ${name}
631
+ description: ${name.charAt(0).toUpperCase() + name.slice(1)} specialist for ${stats.name}
632
+ tools: Read, Write, Glob, Grep
633
+ skills: []
634
+ ---
635
+
636
+ # ${name.toUpperCase()} AGENT
637
+
638
+ Domain specialist for ${name} tasks.
639
+
640
+ ## Project Context
641
+
642
+ - **Project**: ${stats.name}
643
+ - **Ecosystem**: ${stats.ecosystem}
644
+ - **Frameworks**: ${stack.frameworks.join(', ') || 'None detected'}
645
+
646
+ ## Your Role
647
+
648
+ You are the ${name} expert for this project. Apply best practices for the detected stack.
649
+ `
650
+ }
651
+
652
+ // ==========================================================================
653
+ // SKILL CONFIGURATION
654
+ // ==========================================================================
655
+
656
+ private configureSkills(agents: AgentInfo[]): { agent: string; skill: string }[] {
657
+ const skills: { agent: string; skill: string }[] = []
658
+
659
+ for (const agent of agents) {
660
+ if (agent.skill) {
661
+ skills.push({ agent: agent.name, skill: agent.skill })
662
+ }
663
+ }
664
+
665
+ // Write skills.json
666
+ const skillsConfig = {
667
+ projectId: this.projectId,
668
+ syncedAt: dateHelper.getTimestamp(),
669
+ skills: skills.map((s) => ({
670
+ name: s.skill,
671
+ linkedAgents: [s.agent],
672
+ })),
673
+ agentSkillMap: Object.fromEntries(skills.map((s) => [s.agent, s.skill])),
674
+ }
675
+
676
+ fs.writeFile(
677
+ path.join(this.globalPath, 'config', 'skills.json'),
678
+ JSON.stringify(skillsConfig, null, 2),
679
+ 'utf-8'
680
+ ).catch(() => {
681
+ // Best effort
682
+ })
683
+
684
+ return skills
685
+ }
686
+
687
+ // ==========================================================================
688
+ // CONTEXT FILE GENERATION
689
+ // ==========================================================================
690
+
691
+ private async generateContextFiles(
692
+ git: GitData,
693
+ stats: ProjectStats,
694
+ commands: Commands,
695
+ agents: AgentInfo[]
696
+ ): Promise<string[]> {
697
+ const contextPath = path.join(this.globalPath, 'context')
698
+ const files: string[] = []
699
+
700
+ // Generate CLAUDE.md
701
+ await this.generateClaudeMd(contextPath, git, stats, commands, agents)
702
+ files.push('context/CLAUDE.md')
703
+
704
+ // Generate now.md
705
+ await this.generateNowMd(contextPath)
706
+ files.push('context/now.md')
707
+
708
+ // Generate next.md
709
+ await this.generateNextMd(contextPath)
710
+ files.push('context/next.md')
711
+
712
+ // Generate ideas.md
713
+ await this.generateIdeasMd(contextPath)
714
+ files.push('context/ideas.md')
715
+
716
+ // Generate shipped.md
717
+ await this.generateShippedMd(contextPath)
718
+ files.push('context/shipped.md')
719
+
720
+ return files
721
+ }
722
+
723
+ private async generateClaudeMd(
724
+ contextPath: string,
725
+ git: GitData,
726
+ stats: ProjectStats,
727
+ commands: Commands,
728
+ agents: AgentInfo[]
729
+ ): Promise<void> {
730
+ const workflowAgents = agents.filter((a) => a.type === 'workflow').map((a) => a.name)
731
+ const domainAgents = agents.filter((a) => a.type === 'domain').map((a) => a.name)
732
+
733
+ const content = `# ${stats.name} - Project Rules
734
+ <!-- projectId: ${this.projectId} -->
735
+ <!-- Generated: ${dateHelper.getTimestamp()} -->
736
+ <!-- Ecosystem: ${stats.ecosystem} | Type: ${stats.projectType} -->
737
+
738
+ ## THIS PROJECT (${stats.ecosystem})
739
+
740
+ **Type:** ${stats.projectType}
741
+ **Path:** ${this.projectPath}
742
+
743
+ ### Commands (USE THESE, NOT OTHERS)
744
+
745
+ | Action | Command |
746
+ |--------|---------|
747
+ | Install dependencies | \`${commands.install}\` |
748
+ | Run dev server | \`${commands.dev}\` |
749
+ | Run tests | \`${commands.test}\` |
750
+ | Build | \`${commands.build}\` |
751
+ | Lint | \`${commands.lint}\` |
752
+ | Format | \`${commands.format}\` |
753
+
754
+ ### Code Conventions
755
+
756
+ - **Languages**: ${stats.languages.join(', ') || 'Not detected'}
757
+ - **Frameworks**: ${stats.frameworks.join(', ') || 'Not detected'}
758
+
759
+ ---
760
+
761
+ ## PRJCT RULES
762
+
763
+ ### Path Resolution
764
+ **ALL prjct writes go to**: \`~/.prjct-cli/projects/${this.projectId}/\`
765
+ - NEVER write to \`.prjct/\`
766
+ - NEVER write to \`./\` for prjct data
767
+
768
+ ### Workflow
769
+ \`\`\`
770
+ p. sync → p. task "desc" → [work] → p. done → p. ship
771
+ \`\`\`
772
+
773
+ | Command | Action |
774
+ |---------|--------|
775
+ | \`p. sync\` | Re-analyze project |
776
+ | \`p. task X\` | Start task |
777
+ | \`p. done\` | Complete subtask |
778
+ | \`p. ship X\` | Ship feature |
779
+
780
+ ---
781
+
782
+ ## PROJECT STATE
783
+
784
+ | Field | Value |
785
+ |-------|-------|
786
+ | Name | ${stats.name} |
787
+ | Version | ${stats.version} |
788
+ | Ecosystem | ${stats.ecosystem} |
789
+ | Branch | ${git.branch} |
790
+ | Files | ~${stats.fileCount} |
791
+ | Commits | ${git.commits} |
792
+
793
+ ---
794
+
795
+ ## AGENTS
796
+
797
+ Load from \`~/.prjct-cli/projects/${this.projectId}/agents/\`:
798
+
799
+ **Workflow**: ${workflowAgents.join(', ')}
800
+ **Domain**: ${domainAgents.join(', ') || 'none'}
801
+ `
802
+
803
+ await fs.writeFile(path.join(contextPath, 'CLAUDE.md'), content, 'utf-8')
804
+ }
805
+
806
+ private async generateNowMd(contextPath: string): Promise<void> {
807
+ // Read current task from state
808
+ let currentTask = null
809
+ try {
810
+ const statePath = path.join(this.globalPath, 'storage', 'state.json')
811
+ const state = JSON.parse(await fs.readFile(statePath, 'utf-8'))
812
+ currentTask = state.currentTask
813
+ } catch {
814
+ // No state file
815
+ }
816
+
817
+ const content = currentTask
818
+ ? `# NOW
819
+
820
+ **${currentTask.description}**
821
+
822
+ Started: ${currentTask.startedAt}
823
+ ${currentTask.branch ? `Branch: ${currentTask.branch.name}` : ''}
824
+ `
825
+ : `# NOW
826
+
827
+ _No active task_
828
+
829
+ Use \`p. task "description"\` to start working.
830
+ `
831
+
832
+ await fs.writeFile(path.join(contextPath, 'now.md'), content, 'utf-8')
833
+ }
834
+
835
+ private async generateNextMd(contextPath: string): Promise<void> {
836
+ let queue: { tasks: { description: string; priority?: string }[] } = { tasks: [] }
837
+ try {
838
+ const queuePath = path.join(this.globalPath, 'storage', 'queue.json')
839
+ queue = JSON.parse(await fs.readFile(queuePath, 'utf-8'))
840
+ } catch {
841
+ // No queue file
842
+ }
843
+
844
+ const content = `# NEXT
845
+
846
+ ${
847
+ queue.tasks.length > 0
848
+ ? queue.tasks.map((t, i) => `${i + 1}. ${t.description}${t.priority ? ` [${t.priority}]` : ''}`).join('\n')
849
+ : '_Empty queue_'
850
+ }
851
+ `
852
+
853
+ await fs.writeFile(path.join(contextPath, 'next.md'), content, 'utf-8')
854
+ }
855
+
856
+ private async generateIdeasMd(contextPath: string): Promise<void> {
857
+ let ideas: { ideas: { text: string; priority?: string }[] } = { ideas: [] }
858
+ try {
859
+ const ideasPath = path.join(this.globalPath, 'storage', 'ideas.json')
860
+ ideas = JSON.parse(await fs.readFile(ideasPath, 'utf-8'))
861
+ } catch {
862
+ // No ideas file
863
+ }
864
+
865
+ const content = `# IDEAS
866
+
867
+ ${
868
+ ideas.ideas.length > 0
869
+ ? ideas.ideas.map((i) => `- ${i.text}${i.priority ? ` [${i.priority}]` : ''}`).join('\n')
870
+ : '_No ideas captured yet_'
871
+ }
872
+ `
873
+
874
+ await fs.writeFile(path.join(contextPath, 'ideas.md'), content, 'utf-8')
875
+ }
876
+
877
+ private async generateShippedMd(contextPath: string): Promise<void> {
878
+ let shipped: { shipped: { name: string; version?: string; shippedAt: string }[] } = {
879
+ shipped: [],
880
+ }
881
+ try {
882
+ const shippedPath = path.join(this.globalPath, 'storage', 'shipped.json')
883
+ shipped = JSON.parse(await fs.readFile(shippedPath, 'utf-8'))
884
+ } catch {
885
+ // No shipped file
886
+ }
887
+
888
+ const content = `# SHIPPED 🚀
889
+
890
+ ${
891
+ shipped.shipped.length > 0
892
+ ? shipped.shipped
893
+ .slice(-10)
894
+ .map((s) => `- **${s.name}**${s.version ? ` v${s.version}` : ''} - ${s.shippedAt}`)
895
+ .join('\n')
896
+ : '_Nothing shipped yet_'
897
+ }
898
+
899
+ **Total shipped:** ${shipped.shipped.length}
900
+ `
901
+
902
+ await fs.writeFile(path.join(contextPath, 'shipped.md'), content, 'utf-8')
903
+ }
904
+
905
+ // ==========================================================================
906
+ // PROJECT.JSON UPDATE
907
+ // ==========================================================================
908
+
909
+ private async updateProjectJson(git: GitData, stats: ProjectStats): Promise<void> {
910
+ const projectJsonPath = path.join(this.globalPath, 'project.json')
911
+
912
+ // Read existing
913
+ let existing: Record<string, unknown> = {}
914
+ try {
915
+ existing = JSON.parse(await fs.readFile(projectJsonPath, 'utf-8'))
916
+ } catch {
917
+ // No existing file
918
+ }
919
+
920
+ const updated = {
921
+ ...existing,
922
+ projectId: this.projectId,
923
+ repoPath: this.projectPath,
924
+ name: stats.name,
925
+ version: stats.version,
926
+ cliVersion: this.cliVersion,
927
+ techStack: stats.frameworks,
928
+ fileCount: stats.fileCount,
929
+ commitCount: git.commits,
930
+ stack: stats.ecosystem,
931
+ currentBranch: git.branch,
932
+ hasUncommittedChanges: git.hasChanges,
933
+ createdAt: existing.createdAt || dateHelper.getTimestamp(),
934
+ lastSync: dateHelper.getTimestamp(),
935
+ }
936
+
937
+ await fs.writeFile(projectJsonPath, JSON.stringify(updated, null, 2), 'utf-8')
938
+ }
939
+
940
+ // ==========================================================================
941
+ // STATE.JSON UPDATE
942
+ // ==========================================================================
943
+
944
+ private async updateStateJson(stats: ProjectStats, stack: StackDetection): Promise<void> {
945
+ const statePath = path.join(this.globalPath, 'storage', 'state.json')
946
+
947
+ // Read existing
948
+ let state: Record<string, unknown> = {}
949
+ try {
950
+ state = JSON.parse(await fs.readFile(statePath, 'utf-8'))
951
+ } catch {
952
+ // No existing file
953
+ }
954
+
955
+ // Update with enterprise fields
956
+ state.projectId = this.projectId
957
+ state.stack = {
958
+ language: stats.languages[0] || 'Unknown',
959
+ framework: stats.frameworks[0] || null,
960
+ }
961
+ state.domains = {
962
+ hasFrontend: stack.hasFrontend,
963
+ hasBackend: stack.hasBackend,
964
+ hasDatabase: stack.hasDatabase,
965
+ hasTesting: stack.hasTesting,
966
+ hasDocker: stack.hasDocker,
967
+ }
968
+ state.projectType = stats.projectType
969
+ state.metrics = {
970
+ totalFiles: stats.fileCount,
971
+ }
972
+ state.lastSync = dateHelper.getTimestamp()
973
+ state.lastUpdated = dateHelper.getTimestamp()
974
+ state.context = {
975
+ ...(state.context as Record<string, unknown> || {}),
976
+ lastSession: dateHelper.getTimestamp(),
977
+ lastAction: 'Synced project',
978
+ nextAction: 'Run `p. task "description"` to start working',
979
+ }
980
+
981
+ await fs.writeFile(statePath, JSON.stringify(state, null, 2), 'utf-8')
982
+ }
983
+
984
+ // ==========================================================================
985
+ // MEMORY LOGGING
986
+ // ==========================================================================
987
+
988
+ private async logToMemory(git: GitData, stats: ProjectStats): Promise<void> {
989
+ const memoryPath = path.join(this.globalPath, 'memory', 'events.jsonl')
990
+
991
+ const event = {
992
+ ts: dateHelper.getTimestamp(),
993
+ action: 'sync',
994
+ branch: git.branch,
995
+ uncommitted: git.hasChanges,
996
+ fileCount: stats.fileCount,
997
+ commitCount: git.commits,
998
+ }
999
+
1000
+ await fs.appendFile(memoryPath, JSON.stringify(event) + '\n', 'utf-8')
1001
+ }
1002
+
1003
+ // ==========================================================================
1004
+ // HELPERS
1005
+ // ==========================================================================
1006
+
1007
+ private async fileExists(filename: string): Promise<boolean> {
1008
+ try {
1009
+ await fs.access(path.join(this.projectPath, filename))
1010
+ return true
1011
+ } catch {
1012
+ return false
1013
+ }
1014
+ }
1015
+
1016
+ private async getCliVersion(): Promise<string> {
1017
+ try {
1018
+ // Try to read from package.json in the module
1019
+ const pkgPath = path.join(__dirname, '..', '..', 'package.json')
1020
+ const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf-8'))
1021
+ return pkg.version || '0.0.0'
1022
+ } catch {
1023
+ return '0.0.0'
1024
+ }
1025
+ }
1026
+
1027
+ // Empty data structures for error cases
1028
+ private emptyGitData(): GitData {
1029
+ return {
1030
+ branch: 'main',
1031
+ commits: 0,
1032
+ contributors: 0,
1033
+ hasChanges: false,
1034
+ stagedFiles: [],
1035
+ modifiedFiles: [],
1036
+ untrackedFiles: [],
1037
+ recentCommits: [],
1038
+ weeklyCommits: 0,
1039
+ }
1040
+ }
1041
+
1042
+ private emptyStats(): ProjectStats {
1043
+ return {
1044
+ fileCount: 0,
1045
+ version: '0.0.0',
1046
+ name: 'unknown',
1047
+ ecosystem: 'unknown',
1048
+ projectType: 'simple',
1049
+ languages: [],
1050
+ frameworks: [],
1051
+ }
1052
+ }
1053
+
1054
+ private emptyCommands(): Commands {
1055
+ return {
1056
+ install: 'npm install',
1057
+ run: 'npm run',
1058
+ test: 'npm test',
1059
+ build: 'npm run build',
1060
+ dev: 'npm run dev',
1061
+ lint: 'npm run lint',
1062
+ format: 'npm run format',
1063
+ }
1064
+ }
1065
+
1066
+ private emptyStack(): StackDetection {
1067
+ return {
1068
+ hasFrontend: false,
1069
+ hasBackend: false,
1070
+ hasDatabase: false,
1071
+ hasDocker: false,
1072
+ hasTesting: false,
1073
+ frontendType: null,
1074
+ frameworks: [],
1075
+ }
1076
+ }
1077
+ }
1078
+
1079
+ export const syncService = new SyncService()
1080
+ export { SyncService, SyncResult }