studiograph 1.1.2 → 1.2.0-beta.1

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 (349) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +301 -10
  3. package/dist/agent/orchestrator.d.ts +17 -9
  4. package/dist/agent/orchestrator.js +142 -97
  5. package/dist/agent/orchestrator.js.map +1 -1
  6. package/dist/agent/prompts/system.md +186 -0
  7. package/dist/agent/skill-loader.d.ts +48 -0
  8. package/dist/agent/skill-loader.js +166 -0
  9. package/dist/agent/skill-loader.js.map +1 -0
  10. package/dist/agent/skills/enrich-entities.md +136 -0
  11. package/dist/agent/skills/entity-schema.md +502 -0
  12. package/dist/agent/skills/gather-context.md +46 -0
  13. package/dist/agent/skills/obsidian-source-setup.md +246 -0
  14. package/dist/agent/skills/skill-loader.d.ts +48 -0
  15. package/dist/agent/skills/skill-loader.js +166 -0
  16. package/dist/agent/skills/skill-loader.js.map +1 -0
  17. package/dist/agent/skills/sync-configuration.md +144 -0
  18. package/dist/agent/skills/sync-setup.md +68 -0
  19. package/dist/agent/tools/connector-tools.d.ts +37 -0
  20. package/dist/agent/tools/connector-tools.js +132 -0
  21. package/dist/agent/tools/connector-tools.js.map +1 -0
  22. package/dist/agent/tools/fs-tools.d.ts +39 -0
  23. package/dist/agent/tools/fs-tools.js +106 -0
  24. package/dist/agent/tools/fs-tools.js.map +1 -0
  25. package/dist/agent/tools/graph-tools.d.ts +30 -2
  26. package/dist/agent/tools/graph-tools.js +154 -37
  27. package/dist/agent/tools/graph-tools.js.map +1 -1
  28. package/dist/agent/tools/load-skill.d.ts +42 -0
  29. package/dist/agent/tools/load-skill.js +45 -0
  30. package/dist/agent/tools/load-skill.js.map +1 -0
  31. package/dist/agent/tools/sync-tools.d.ts +25 -0
  32. package/dist/agent/tools/sync-tools.js +691 -0
  33. package/dist/agent/tools/sync-tools.js.map +1 -0
  34. package/dist/agent/tools/tool-loader.d.ts +25 -0
  35. package/dist/agent/tools/tool-loader.js +73 -0
  36. package/dist/agent/tools/tool-loader.js.map +1 -0
  37. package/dist/auth/github.d.ts +11 -8
  38. package/dist/auth/github.js +56 -75
  39. package/dist/auth/github.js.map +1 -1
  40. package/dist/cli/colors.d.ts +54 -0
  41. package/dist/cli/colors.js +133 -0
  42. package/dist/cli/colors.js.map +1 -0
  43. package/dist/cli/commands/app.d.ts +7 -0
  44. package/dist/cli/commands/app.js +167 -0
  45. package/dist/cli/commands/app.js.map +1 -0
  46. package/dist/cli/commands/auth.d.ts +1 -1
  47. package/dist/cli/commands/auth.js +26 -10
  48. package/dist/cli/commands/auth.js.map +1 -1
  49. package/dist/cli/commands/clone.d.ts +9 -0
  50. package/dist/cli/commands/clone.js +167 -0
  51. package/dist/cli/commands/clone.js.map +1 -0
  52. package/dist/cli/commands/commit.d.ts +8 -0
  53. package/dist/cli/commands/commit.js +43 -0
  54. package/dist/cli/commands/commit.js.map +1 -0
  55. package/dist/cli/commands/config.d.ts +13 -0
  56. package/dist/cli/commands/config.js +276 -0
  57. package/dist/cli/commands/config.js.map +1 -0
  58. package/dist/cli/commands/connector.d.ts +33 -0
  59. package/dist/cli/commands/connector.js +178 -0
  60. package/dist/cli/commands/connector.js.map +1 -0
  61. package/dist/cli/commands/deploy.d.ts +11 -0
  62. package/dist/cli/commands/deploy.js +153 -0
  63. package/dist/cli/commands/deploy.js.map +1 -0
  64. package/dist/cli/commands/enrich.d.ts +11 -0
  65. package/dist/cli/commands/enrich.js +135 -0
  66. package/dist/cli/commands/enrich.js.map +1 -0
  67. package/dist/cli/commands/graphrag.d.ts +12 -0
  68. package/dist/cli/commands/graphrag.js +122 -0
  69. package/dist/cli/commands/graphrag.js.map +1 -0
  70. package/dist/cli/commands/index.d.ts +15 -0
  71. package/dist/cli/commands/index.js +117 -0
  72. package/dist/cli/commands/index.js.map +1 -0
  73. package/dist/cli/commands/init.js +110 -210
  74. package/dist/cli/commands/init.js.map +1 -1
  75. package/dist/cli/commands/join.js +89 -24
  76. package/dist/cli/commands/join.js.map +1 -1
  77. package/dist/cli/commands/lint.d.ts +8 -0
  78. package/dist/cli/commands/lint.js +70 -0
  79. package/dist/cli/commands/lint.js.map +1 -0
  80. package/dist/cli/commands/mcp.d.ts +27 -0
  81. package/dist/cli/commands/mcp.js +56 -0
  82. package/dist/cli/commands/mcp.js.map +1 -0
  83. package/dist/cli/commands/orphans.d.ts +8 -0
  84. package/dist/cli/commands/orphans.js +125 -0
  85. package/dist/cli/commands/orphans.js.map +1 -0
  86. package/dist/cli/commands/provision.d.ts +8 -0
  87. package/dist/cli/commands/provision.js +116 -0
  88. package/dist/cli/commands/provision.js.map +1 -0
  89. package/dist/cli/commands/r2.d.ts +2 -0
  90. package/dist/cli/commands/r2.js +87 -6
  91. package/dist/cli/commands/r2.js.map +1 -1
  92. package/dist/cli/commands/reset.d.ts +12 -0
  93. package/dist/cli/commands/reset.js +137 -0
  94. package/dist/cli/commands/reset.js.map +1 -0
  95. package/dist/cli/commands/review.d.ts +19 -0
  96. package/dist/cli/commands/review.js +128 -0
  97. package/dist/cli/commands/review.js.map +1 -0
  98. package/dist/cli/commands/serve.js +47 -2
  99. package/dist/cli/commands/serve.js.map +1 -1
  100. package/dist/cli/commands/source.d.ts +16 -0
  101. package/dist/cli/commands/source.js +159 -0
  102. package/dist/cli/commands/source.js.map +1 -0
  103. package/dist/cli/commands/start.js +472 -103
  104. package/dist/cli/commands/start.js.map +1 -1
  105. package/dist/cli/commands/sync-entities.d.ts +13 -0
  106. package/dist/cli/commands/sync-entities.js +242 -0
  107. package/dist/cli/commands/sync-entities.js.map +1 -0
  108. package/dist/cli/commands/sync.js +40 -9
  109. package/dist/cli/commands/sync.js.map +1 -1
  110. package/dist/cli/commands/update.d.ts +8 -0
  111. package/dist/cli/commands/update.js +155 -0
  112. package/dist/cli/commands/update.js.map +1 -0
  113. package/dist/cli/index.js +114 -3
  114. package/dist/cli/index.js.map +1 -1
  115. package/dist/cli/scaffolding.d.ts +10 -0
  116. package/dist/cli/scaffolding.js +302 -0
  117. package/dist/cli/scaffolding.js.map +1 -0
  118. package/dist/cli/setup-wizard.d.ts +30 -0
  119. package/dist/cli/setup-wizard.js +244 -0
  120. package/dist/cli/setup-wizard.js.map +1 -0
  121. package/dist/cli/sync-review-interactive.d.ts +31 -0
  122. package/dist/cli/sync-review-interactive.js +393 -0
  123. package/dist/cli/sync-review-interactive.js.map +1 -0
  124. package/dist/cli/theme.d.ts +31 -0
  125. package/dist/cli/theme.js +116 -0
  126. package/dist/cli/theme.js.map +1 -0
  127. package/dist/core/graph.d.ts +16 -9
  128. package/dist/core/graph.js +263 -145
  129. package/dist/core/graph.js.map +1 -1
  130. package/dist/core/migration-runner.d.ts +42 -0
  131. package/dist/core/migration-runner.js +232 -0
  132. package/dist/core/migration-runner.js.map +1 -0
  133. package/dist/core/migration-types.d.ts +101 -0
  134. package/dist/core/migration-types.js +21 -0
  135. package/dist/core/migration-types.js.map +1 -0
  136. package/dist/core/migrations/20260219-formalize-memory-location.d.ts +2 -0
  137. package/dist/core/migrations/20260219-formalize-memory-location.js +35 -0
  138. package/dist/core/migrations/20260219-formalize-memory-location.js.map +1 -0
  139. package/dist/core/migrations/20260220-add-workspace-metadata.d.ts +12 -0
  140. package/dist/core/migrations/20260220-add-workspace-metadata.js +65 -0
  141. package/dist/core/migrations/20260220-add-workspace-metadata.js.map +1 -0
  142. package/dist/core/migrations/20260220-add-workspace-readme.d.ts +11 -0
  143. package/dist/core/migrations/20260220-add-workspace-readme.js +82 -0
  144. package/dist/core/migrations/20260220-add-workspace-readme.js.map +1 -0
  145. package/dist/core/migrations/20260220-migrate-yaml-to-json.d.ts +9 -0
  146. package/dist/core/migrations/20260220-migrate-yaml-to-json.js +64 -0
  147. package/dist/core/migrations/20260220-migrate-yaml-to-json.js.map +1 -0
  148. package/dist/core/migrations/index.d.ts +11 -0
  149. package/dist/core/migrations/index.js +23 -0
  150. package/dist/core/migrations/index.js.map +1 -0
  151. package/dist/core/schema-registry.d.ts +36 -0
  152. package/dist/core/schema-registry.js +161 -0
  153. package/dist/core/schema-registry.js.map +1 -0
  154. package/dist/core/types.d.ts +242 -3
  155. package/dist/core/types.js +21 -2
  156. package/dist/core/types.js.map +1 -1
  157. package/dist/core/user-config.d.ts +16 -0
  158. package/dist/core/user-config.js +8 -0
  159. package/dist/core/user-config.js.map +1 -1
  160. package/dist/core/validation.d.ts +973 -32
  161. package/dist/core/validation.js +163 -4
  162. package/dist/core/validation.js.map +1 -1
  163. package/dist/core/workspace-manager.d.ts +26 -2
  164. package/dist/core/workspace-manager.js +113 -15
  165. package/dist/core/workspace-manager.js.map +1 -1
  166. package/dist/core/workspace.d.ts +20 -11
  167. package/dist/core/workspace.js +123 -34
  168. package/dist/core/workspace.js.map +1 -1
  169. package/dist/mcp/connector-manager.d.ts +65 -0
  170. package/dist/mcp/connector-manager.js +223 -0
  171. package/dist/mcp/connector-manager.js.map +1 -0
  172. package/dist/mcp/connectors/asana.d.ts +2 -0
  173. package/dist/mcp/connectors/asana.js +20 -0
  174. package/dist/mcp/connectors/asana.js.map +1 -0
  175. package/dist/mcp/connectors/definitions.d.ts +45 -0
  176. package/dist/mcp/connectors/definitions.js +32 -0
  177. package/dist/mcp/connectors/definitions.js.map +1 -0
  178. package/dist/mcp/connectors/figma.d.ts +5 -0
  179. package/dist/mcp/connectors/figma.js +21 -0
  180. package/dist/mcp/connectors/figma.js.map +1 -0
  181. package/dist/mcp/connectors/gdrive.d.ts +2 -0
  182. package/dist/mcp/connectors/gdrive.js +20 -0
  183. package/dist/mcp/connectors/gdrive.js.map +1 -0
  184. package/dist/mcp/connectors/granola.d.ts +2 -0
  185. package/dist/mcp/connectors/granola.js +12 -0
  186. package/dist/mcp/connectors/granola.js.map +1 -0
  187. package/dist/mcp/connectors/linear.d.ts +2 -0
  188. package/dist/mcp/connectors/linear.js +19 -0
  189. package/dist/mcp/connectors/linear.js.map +1 -0
  190. package/dist/mcp/connectors/obsidian.d.ts +2 -0
  191. package/dist/mcp/connectors/obsidian.js +19 -0
  192. package/dist/mcp/connectors/obsidian.js.map +1 -0
  193. package/dist/mcp/connectors/pipedrive.d.ts +2 -0
  194. package/dist/mcp/connectors/pipedrive.js +20 -0
  195. package/dist/mcp/connectors/pipedrive.js.map +1 -0
  196. package/dist/mcp/connectors/slack.d.ts +2 -0
  197. package/dist/mcp/connectors/slack.js +21 -0
  198. package/dist/mcp/connectors/slack.js.map +1 -0
  199. package/dist/mcp/oauth-provider.d.ts +41 -0
  200. package/dist/mcp/oauth-provider.js +160 -0
  201. package/dist/mcp/oauth-provider.js.map +1 -0
  202. package/dist/mcp/server.d.ts +11 -0
  203. package/dist/mcp/server.js +28 -0
  204. package/dist/mcp/server.js.map +1 -0
  205. package/dist/mcp/tools.d.ts +14 -0
  206. package/dist/mcp/tools.js +172 -0
  207. package/dist/mcp/tools.js.map +1 -0
  208. package/dist/server/index.js +17 -4
  209. package/dist/server/index.js.map +1 -1
  210. package/dist/server/plugin-loader.d.ts +15 -0
  211. package/dist/server/plugin-loader.js +68 -2
  212. package/dist/server/plugin-loader.js.map +1 -1
  213. package/dist/server/routes/graph-api.js +1 -1
  214. package/dist/server/routes/graph-api.js.map +1 -1
  215. package/dist/server/routes/webhook.js +33 -0
  216. package/dist/server/routes/webhook.js.map +1 -1
  217. package/dist/services/github-provisioner.d.ts +9 -3
  218. package/dist/services/github-provisioner.js +46 -8
  219. package/dist/services/github-provisioner.js.map +1 -1
  220. package/dist/services/lint-service.d.ts +27 -0
  221. package/dist/services/lint-service.js +83 -0
  222. package/dist/services/lint-service.js.map +1 -0
  223. package/dist/services/markdown.d.ts +9 -0
  224. package/dist/services/markdown.js +26 -5
  225. package/dist/services/markdown.js.map +1 -1
  226. package/dist/services/memory-service.d.ts +1 -2
  227. package/dist/services/memory-service.js +5 -4
  228. package/dist/services/memory-service.js.map +1 -1
  229. package/dist/services/orphan-service.d.ts +31 -0
  230. package/dist/services/orphan-service.js +100 -0
  231. package/dist/services/orphan-service.js.map +1 -0
  232. package/dist/services/sync/commit.d.ts +58 -0
  233. package/dist/services/sync/commit.js +350 -0
  234. package/dist/services/sync/commit.js.map +1 -0
  235. package/dist/services/sync/context-index.d.ts +69 -0
  236. package/dist/services/sync/context-index.js +280 -0
  237. package/dist/services/sync/context-index.js.map +1 -0
  238. package/dist/services/sync/derive.d.ts +34 -0
  239. package/dist/services/sync/derive.js +164 -0
  240. package/dist/services/sync/derive.js.map +1 -0
  241. package/dist/services/sync/enrichment-state.d.ts +31 -0
  242. package/dist/services/sync/enrichment-state.js +63 -0
  243. package/dist/services/sync/enrichment-state.js.map +1 -0
  244. package/dist/services/sync/enrichment.d.ts +25 -0
  245. package/dist/services/sync/enrichment.js +121 -0
  246. package/dist/services/sync/enrichment.js.map +1 -0
  247. package/dist/services/sync/frontmatter-extractor.d.ts +40 -0
  248. package/dist/services/sync/frontmatter-extractor.js +273 -0
  249. package/dist/services/sync/frontmatter-extractor.js.map +1 -0
  250. package/dist/services/sync/graph-match-state.d.ts +33 -0
  251. package/dist/services/sync/graph-match-state.js +61 -0
  252. package/dist/services/sync/graph-match-state.js.map +1 -0
  253. package/dist/services/sync/graph-match.d.ts +53 -0
  254. package/dist/services/sync/graph-match.js +316 -0
  255. package/dist/services/sync/graph-match.js.map +1 -0
  256. package/dist/services/sync/graphrag-client.d.ts +43 -0
  257. package/dist/services/sync/graphrag-client.js +94 -0
  258. package/dist/services/sync/graphrag-client.js.map +1 -0
  259. package/dist/services/sync/graphrag-config.d.ts +16 -0
  260. package/dist/services/sync/graphrag-config.js +39 -0
  261. package/dist/services/sync/graphrag-config.js.map +1 -0
  262. package/dist/services/sync/graphrag-context.d.ts +14 -0
  263. package/dist/services/sync/graphrag-context.js +109 -0
  264. package/dist/services/sync/graphrag-context.js.map +1 -0
  265. package/dist/services/sync/graphrag-indexer.d.ts +30 -0
  266. package/dist/services/sync/graphrag-indexer.js +358 -0
  267. package/dist/services/sync/graphrag-indexer.js.map +1 -0
  268. package/dist/services/sync/llm.d.ts +32 -0
  269. package/dist/services/sync/llm.js +115 -0
  270. package/dist/services/sync/llm.js.map +1 -0
  271. package/dist/services/sync/mcp-client.d.ts +59 -0
  272. package/dist/services/sync/mcp-client.js +285 -0
  273. package/dist/services/sync/mcp-client.js.map +1 -0
  274. package/dist/services/sync/model-factory.d.ts +10 -0
  275. package/dist/services/sync/model-factory.js +24 -0
  276. package/dist/services/sync/model-factory.js.map +1 -0
  277. package/dist/services/sync/name-quality.d.ts +31 -0
  278. package/dist/services/sync/name-quality.js +60 -0
  279. package/dist/services/sync/name-quality.js.map +1 -0
  280. package/dist/services/sync/output-schemas.d.ts +92 -0
  281. package/dist/services/sync/output-schemas.js +43 -0
  282. package/dist/services/sync/output-schemas.js.map +1 -0
  283. package/dist/services/sync/prompts.d.ts +19 -0
  284. package/dist/services/sync/prompts.js +128 -0
  285. package/dist/services/sync/prompts.js.map +1 -0
  286. package/dist/services/sync/reconciler.d.ts +48 -0
  287. package/dist/services/sync/reconciler.js +295 -0
  288. package/dist/services/sync/reconciler.js.map +1 -0
  289. package/dist/services/sync/source-config.d.ts +45 -0
  290. package/dist/services/sync/source-config.js +208 -0
  291. package/dist/services/sync/source-config.js.map +1 -0
  292. package/dist/services/sync/source-definitions/asana.d.ts +15 -0
  293. package/dist/services/sync/source-definitions/asana.js +48 -0
  294. package/dist/services/sync/source-definitions/asana.js.map +1 -0
  295. package/dist/services/sync/source-definitions/definitions.d.ts +21 -0
  296. package/dist/services/sync/source-definitions/definitions.js +26 -0
  297. package/dist/services/sync/source-definitions/definitions.js.map +1 -0
  298. package/dist/services/sync/source-definitions/gdrive.d.ts +16 -0
  299. package/dist/services/sync/source-definitions/gdrive.js +68 -0
  300. package/dist/services/sync/source-definitions/gdrive.js.map +1 -0
  301. package/dist/services/sync/source-definitions/granola.d.ts +2 -0
  302. package/dist/services/sync/source-definitions/granola.js +28 -0
  303. package/dist/services/sync/source-definitions/granola.js.map +1 -0
  304. package/dist/services/sync/source-definitions/linear.d.ts +2 -0
  305. package/dist/services/sync/source-definitions/linear.js +60 -0
  306. package/dist/services/sync/source-definitions/linear.js.map +1 -0
  307. package/dist/services/sync/source-definitions/obsidian.d.ts +2 -0
  308. package/dist/services/sync/source-definitions/obsidian.js +55 -0
  309. package/dist/services/sync/source-definitions/obsidian.js.map +1 -0
  310. package/dist/services/sync/source-definitions/pipedrive.d.ts +2 -0
  311. package/dist/services/sync/source-definitions/pipedrive.js +52 -0
  312. package/dist/services/sync/source-definitions/pipedrive.js.map +1 -0
  313. package/dist/services/sync/staging.d.ts +53 -0
  314. package/dist/services/sync/staging.js +131 -0
  315. package/dist/services/sync/staging.js.map +1 -0
  316. package/dist/services/sync/structured-extractor.d.ts +49 -0
  317. package/dist/services/sync/structured-extractor.js +344 -0
  318. package/dist/services/sync/structured-extractor.js.map +1 -0
  319. package/dist/services/sync/sync-runner.d.ts +32 -0
  320. package/dist/services/sync/sync-runner.js +195 -0
  321. package/dist/services/sync/sync-runner.js.map +1 -0
  322. package/dist/services/sync/sync-state.d.ts +43 -0
  323. package/dist/services/sync/sync-state.js +154 -0
  324. package/dist/services/sync/sync-state.js.map +1 -0
  325. package/dist/services/sync/types.d.ts +203 -0
  326. package/dist/services/sync/types.js +8 -0
  327. package/dist/services/sync/types.js.map +1 -0
  328. package/dist/services/sync/unstructured-extractor.d.ts +29 -0
  329. package/dist/services/sync/unstructured-extractor.js +197 -0
  330. package/dist/services/sync/unstructured-extractor.js.map +1 -0
  331. package/dist/services/vector-service.d.ts +88 -0
  332. package/dist/services/vector-service.js +322 -0
  333. package/dist/services/vector-service.js.map +1 -0
  334. package/dist/utils/git.d.ts +26 -4
  335. package/dist/utils/git.js +55 -7
  336. package/dist/utils/git.js.map +1 -1
  337. package/dist/utils/merge-resolver.d.ts +34 -0
  338. package/dist/utils/merge-resolver.js +201 -0
  339. package/dist/utils/merge-resolver.js.map +1 -0
  340. package/dist/utils/preflight.d.ts +2 -1
  341. package/dist/utils/preflight.js +8 -1
  342. package/dist/utils/preflight.js.map +1 -1
  343. package/dist/utils/version-checker.d.ts +23 -0
  344. package/dist/utils/version-checker.js +116 -0
  345. package/dist/utils/version-checker.js.map +1 -0
  346. package/dist/utils/workspace-config.d.ts +8 -0
  347. package/dist/utils/workspace-config.js +22 -0
  348. package/dist/utils/workspace-config.js.map +1 -0
  349. package/package.json +24 -11
@@ -3,19 +3,41 @@
3
3
  * Extracted so tests can mock them without mocking the built-in child_process.
4
4
  */
5
5
  export type PullResult = 'updated' | 'up-to-date' | 'conflict';
6
- export type PushResult = 'pushed' | 'nothing-to-push';
6
+ export type PushResult = 'pushed' | 'nothing-to-push' | 'rejected';
7
+ export interface GitPullOptions {
8
+ /** When true (default), abort the rebase on conflict to leave repo clean.
9
+ * Set to false to leave the rebase in progress so a resolver can work on it. */
10
+ abortOnConflict?: boolean;
11
+ }
7
12
  /**
8
13
  * Pull the latest changes in a local git repo.
14
+ * Uses --rebase to automatically handle divergent branches
15
+ * (replays local commits on top of remote changes).
16
+ * Auto-stashes uncommitted changes before pulling and restores them after.
9
17
  * Returns 'updated', 'up-to-date', or 'conflict'.
10
18
  * Throws on hard errors (no remote, auth failure, etc.).
11
19
  */
12
- export declare function gitPull(repoPath: string): PullResult;
20
+ export declare function gitPull(repoPath: string, opts?: GitPullOptions): PullResult;
13
21
  /**
14
22
  * Push local commits in a git repo to its remote.
15
- * Returns 'pushed' or 'nothing-to-push'.
16
- * Throws on errors (no remote, auth failure, etc.).
23
+ * Returns 'pushed', 'nothing-to-push', or 'rejected' (remote has newer commits).
24
+ * Throws on hard errors (no remote, auth failure, etc.).
17
25
  */
18
26
  export declare function gitPush(repoPath: string): PushResult;
27
+ /**
28
+ * Pop the most recent stash entry, if any.
29
+ * Safe to call even if the stash is empty.
30
+ */
31
+ export declare function gitStashPop(repoPath: string): void;
32
+ /**
33
+ * Check if a git repo has uncommitted changes (staged or unstaged).
34
+ * Returns true if the working tree is dirty.
35
+ */
36
+ export declare function gitHasUncommittedChanges(repoPath: string): boolean;
37
+ /**
38
+ * Check if a directory is a git repository.
39
+ */
40
+ export declare function isGitRepo(repoPath: string): boolean;
19
41
  /**
20
42
  * Clone a remote repository to a local path.
21
43
  * Throws if the git command fails.
package/dist/utils/git.js CHANGED
@@ -5,25 +5,47 @@
5
5
  import { execSync, spawnSync } from 'child_process';
6
6
  /**
7
7
  * Pull the latest changes in a local git repo.
8
+ * Uses --rebase to automatically handle divergent branches
9
+ * (replays local commits on top of remote changes).
10
+ * Auto-stashes uncommitted changes before pulling and restores them after.
8
11
  * Returns 'updated', 'up-to-date', or 'conflict'.
9
12
  * Throws on hard errors (no remote, auth failure, etc.).
10
13
  */
11
- export function gitPull(repoPath) {
12
- const result = spawnSync('git', ['pull'], { cwd: repoPath, encoding: 'utf-8' });
14
+ export function gitPull(repoPath, opts) {
15
+ const abortOnConflict = opts?.abortOnConflict ?? true;
16
+ // Auto-stash if the working tree is dirty (rebase refuses to run otherwise)
17
+ const dirty = gitHasUncommittedChanges(repoPath);
18
+ if (dirty) {
19
+ spawnSync('git', ['stash', '--include-untracked'], { cwd: repoPath, encoding: 'utf-8' });
20
+ }
21
+ const result = spawnSync('git', ['pull', '--rebase'], { cwd: repoPath, encoding: 'utf-8' });
13
22
  if (result.status === 0) {
23
+ if (dirty)
24
+ spawnSync('git', ['stash', 'pop'], { cwd: repoPath, encoding: 'utf-8' });
14
25
  const output = result.stdout + result.stderr;
15
- return output.toLowerCase().includes('already up to date') ? 'up-to-date' : 'updated';
26
+ return output.toLowerCase().includes('already up to date') ||
27
+ output.toLowerCase().includes('is up to date')
28
+ ? 'up-to-date'
29
+ : 'updated';
16
30
  }
17
31
  const combined = result.stdout + result.stderr;
18
- if (combined.includes('CONFLICT') || combined.includes('Automatic merge failed')) {
32
+ if (combined.includes('CONFLICT') || combined.includes('could not apply')) {
33
+ if (abortOnConflict) {
34
+ spawnSync('git', ['rebase', '--abort'], { cwd: repoPath, encoding: 'utf-8' });
35
+ if (dirty)
36
+ spawnSync('git', ['stash', 'pop'], { cwd: repoPath, encoding: 'utf-8' });
37
+ }
38
+ // When !abortOnConflict, stash stays parked — resolver will pop after resolution
19
39
  return 'conflict';
20
40
  }
41
+ if (dirty)
42
+ spawnSync('git', ['stash', 'pop'], { cwd: repoPath, encoding: 'utf-8' });
21
43
  throw new Error((result.stderr || result.stdout || `git pull failed with exit ${result.status}`).trim());
22
44
  }
23
45
  /**
24
46
  * Push local commits in a git repo to its remote.
25
- * Returns 'pushed' or 'nothing-to-push'.
26
- * Throws on errors (no remote, auth failure, etc.).
47
+ * Returns 'pushed', 'nothing-to-push', or 'rejected' (remote has newer commits).
48
+ * Throws on hard errors (no remote, auth failure, etc.).
27
49
  */
28
50
  export function gitPush(repoPath) {
29
51
  const result = spawnSync('git', ['push'], { cwd: repoPath, encoding: 'utf-8' });
@@ -31,7 +53,33 @@ export function gitPush(repoPath) {
31
53
  const combined = result.stdout + result.stderr;
32
54
  return combined.includes('Everything up-to-date') ? 'nothing-to-push' : 'pushed';
33
55
  }
34
- throw new Error((result.stderr || result.stdout || `git push failed with exit ${result.status}`).trim());
56
+ const combined = result.stdout + result.stderr;
57
+ if (combined.includes('non-fast-forward') || combined.includes('fetch first') || combined.includes('rejected')) {
58
+ return 'rejected';
59
+ }
60
+ throw new Error((combined || `git push failed with exit ${result.status}`).trim());
61
+ }
62
+ /**
63
+ * Pop the most recent stash entry, if any.
64
+ * Safe to call even if the stash is empty.
65
+ */
66
+ export function gitStashPop(repoPath) {
67
+ spawnSync('git', ['stash', 'pop'], { cwd: repoPath, encoding: 'utf-8' });
68
+ }
69
+ /**
70
+ * Check if a git repo has uncommitted changes (staged or unstaged).
71
+ * Returns true if the working tree is dirty.
72
+ */
73
+ export function gitHasUncommittedChanges(repoPath) {
74
+ const result = spawnSync('git', ['status', '--porcelain'], { cwd: repoPath, encoding: 'utf-8' });
75
+ return result.status === 0 && result.stdout.trim().length > 0;
76
+ }
77
+ /**
78
+ * Check if a directory is a git repository.
79
+ */
80
+ export function isGitRepo(repoPath) {
81
+ const result = spawnSync('git', ['rev-parse', '--git-dir'], { cwd: repoPath, encoding: 'utf-8' });
82
+ return result.status === 0;
35
83
  }
36
84
  /**
37
85
  * Clone a remote repository to a local path.
@@ -1 +1 @@
1
- {"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAKpD;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,QAAgB;IACtC,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IAChF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC7C,OAAO,MAAM,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;IACxF,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC/C,IAAI,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,CAAC;QACjF,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,6BAA6B,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAC3G,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,QAAgB;IACtC,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,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AM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,SAAS,CAAC;IACzF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * LLM-based merge conflict resolution for markdown entity files.
3
+ *
4
+ * When git rebase hits a conflict, this module:
5
+ * 1. Identifies conflicted files
6
+ * 2. Extracts ours/theirs versions from conflict markers
7
+ * 3. Asks an LLM to produce a merged version
8
+ * 4. Writes the merged content and stages the file
9
+ * 5. Continues the rebase
10
+ *
11
+ * Falls back gracefully if no API key is available or LLM fails.
12
+ */
13
+ export interface MergeResolution {
14
+ file: string;
15
+ resolved: boolean;
16
+ summary?: string;
17
+ }
18
+ export interface ResolveResult {
19
+ success: boolean;
20
+ resolutions: MergeResolution[];
21
+ }
22
+ /**
23
+ * Attempt to resolve all conflicts in a repo mid-rebase using LLM.
24
+ * The repo should be in a conflicted rebase state (not yet aborted).
25
+ * Returns success=true if all conflicts were resolved and rebase continued.
26
+ */
27
+ export declare function resolveConflicts(repoPath: string, onProgress?: (msg: string) => void): Promise<ResolveResult>;
28
+ /**
29
+ * Extract ours and theirs versions from git conflict markers.
30
+ */
31
+ export declare function extractConflictVersions(content: string): {
32
+ ours: string | null;
33
+ theirs: string | null;
34
+ };
@@ -0,0 +1,201 @@
1
+ /**
2
+ * LLM-based merge conflict resolution for markdown entity files.
3
+ *
4
+ * When git rebase hits a conflict, this module:
5
+ * 1. Identifies conflicted files
6
+ * 2. Extracts ours/theirs versions from conflict markers
7
+ * 3. Asks an LLM to produce a merged version
8
+ * 4. Writes the merged content and stages the file
9
+ * 5. Continues the rebase
10
+ *
11
+ * Falls back gracefully if no API key is available or LLM fails.
12
+ */
13
+ import { spawnSync } from 'child_process';
14
+ import { readFileSync, writeFileSync } from 'fs';
15
+ import { join } from 'path';
16
+ import { generateText } from 'ai';
17
+ import { createModel } from '../services/sync/model-factory.js';
18
+ import { loadUserConfig, getAnthropicCredential } from '../core/user-config.js';
19
+ /**
20
+ * Attempt to resolve all conflicts in a repo mid-rebase using LLM.
21
+ * The repo should be in a conflicted rebase state (not yet aborted).
22
+ * Returns success=true if all conflicts were resolved and rebase continued.
23
+ */
24
+ export async function resolveConflicts(repoPath, onProgress) {
25
+ const log = onProgress ?? (() => { });
26
+ // Check for API key — can't resolve without LLM
27
+ const config = loadUserConfig();
28
+ const apiKey = getAnthropicCredential(config) || process.env.ANTHROPIC_API_KEY;
29
+ if (!apiKey) {
30
+ return { success: false, resolutions: [] };
31
+ }
32
+ // Find conflicted files
33
+ const conflicted = getConflictedFiles(repoPath);
34
+ if (conflicted.length === 0) {
35
+ return { success: false, resolutions: [] };
36
+ }
37
+ log(` Resolving ${conflicted.length} conflict${conflicted.length === 1 ? '' : 's'} via AI merge...`);
38
+ const provider = config.enrichment_model_provider ?? config.model_provider ?? 'anthropic';
39
+ const modelId = config.enrichment_model_id ?? config.model_id ?? 'claude-sonnet-4-5-20250929';
40
+ const model = createModel(provider, modelId, apiKey);
41
+ const resolutions = [];
42
+ for (const file of conflicted) {
43
+ const fullPath = join(repoPath, file);
44
+ try {
45
+ const content = readFileSync(fullPath, 'utf-8');
46
+ const { ours, theirs } = extractConflictVersions(content);
47
+ if (!ours || !theirs) {
48
+ // Can't parse conflict markers — skip this file
49
+ resolutions.push({ file, resolved: false });
50
+ continue;
51
+ }
52
+ log(` Merging: ${file}`);
53
+ const merged = await llmMerge(model, ours, theirs, file);
54
+ if (!merged) {
55
+ resolutions.push({ file, resolved: false });
56
+ continue;
57
+ }
58
+ // Write merged content and stage the file
59
+ writeFileSync(fullPath, merged, 'utf-8');
60
+ spawnSync('git', ['add', file], { cwd: repoPath, encoding: 'utf-8' });
61
+ resolutions.push({ file, resolved: true, summary: 'merged by AI' });
62
+ }
63
+ catch (err) {
64
+ log(` Failed to resolve ${file}: ${err instanceof Error ? err.message : 'unknown error'}`);
65
+ resolutions.push({ file, resolved: false });
66
+ }
67
+ }
68
+ // If any file wasn't resolved, abort
69
+ const allResolved = resolutions.every(r => r.resolved);
70
+ if (!allResolved) {
71
+ spawnSync('git', ['rebase', '--abort'], { cwd: repoPath, encoding: 'utf-8' });
72
+ return { success: false, resolutions };
73
+ }
74
+ // All resolved — continue the rebase
75
+ const cont = spawnSync('git', ['rebase', '--continue'], {
76
+ cwd: repoPath,
77
+ encoding: 'utf-8',
78
+ env: { ...process.env, GIT_EDITOR: 'true' }, // skip commit message editor
79
+ });
80
+ if (cont.status !== 0) {
81
+ // Rebase continue failed — might have more conflicts in later commits
82
+ // Try to resolve recursively (up to 10 rounds)
83
+ const combined = cont.stdout + cont.stderr;
84
+ if (combined.includes('CONFLICT') || combined.includes('could not apply')) {
85
+ const nestedResult = await resolveConflicts(repoPath, onProgress);
86
+ return {
87
+ success: nestedResult.success,
88
+ resolutions: [...resolutions, ...nestedResult.resolutions],
89
+ };
90
+ }
91
+ spawnSync('git', ['rebase', '--abort'], { cwd: repoPath, encoding: 'utf-8' });
92
+ return { success: false, resolutions };
93
+ }
94
+ return { success: true, resolutions };
95
+ }
96
+ /**
97
+ * Get list of conflicted files in the current rebase.
98
+ */
99
+ function getConflictedFiles(repoPath) {
100
+ const result = spawnSync('git', ['diff', '--name-only', '--diff-filter=U'], { cwd: repoPath, encoding: 'utf-8' });
101
+ if (result.status !== 0)
102
+ return [];
103
+ return result.stdout.trim().split('\n').filter(Boolean);
104
+ }
105
+ /**
106
+ * Extract ours and theirs versions from git conflict markers.
107
+ */
108
+ export function extractConflictVersions(content) {
109
+ const lines = content.split('\n');
110
+ let ours = '';
111
+ let theirs = '';
112
+ let section = 'none';
113
+ let hasConflict = false;
114
+ let oursContext = '';
115
+ let theirsContext = '';
116
+ let commonBefore = '';
117
+ let commonAfter = '';
118
+ let afterConflict = false;
119
+ for (const line of lines) {
120
+ if (line.startsWith('<<<<<<<')) {
121
+ hasConflict = true;
122
+ section = 'ours';
123
+ oursContext += commonBefore;
124
+ theirsContext += commonBefore;
125
+ commonBefore = '';
126
+ continue;
127
+ }
128
+ if (line.startsWith('=======') && section === 'ours') {
129
+ section = 'theirs';
130
+ continue;
131
+ }
132
+ if (line.startsWith('>>>>>>>')) {
133
+ section = 'none';
134
+ afterConflict = true;
135
+ continue;
136
+ }
137
+ if (section === 'ours') {
138
+ oursContext += line + '\n';
139
+ }
140
+ else if (section === 'theirs') {
141
+ theirsContext += line + '\n';
142
+ }
143
+ else {
144
+ if (afterConflict) {
145
+ commonAfter += line + '\n';
146
+ }
147
+ else {
148
+ commonBefore += line + '\n';
149
+ }
150
+ }
151
+ }
152
+ if (!hasConflict)
153
+ return { ours: null, theirs: null };
154
+ ours = (oursContext + commonAfter).trim();
155
+ theirs = (theirsContext + commonAfter).trim();
156
+ // Return full file versions (common prefix + conflict section + common suffix)
157
+ const prefix = commonBefore.trimEnd();
158
+ return {
159
+ ours: prefix ? `${prefix}\n${ours}` : ours,
160
+ theirs: prefix ? `${prefix}\n${theirs}` : theirs,
161
+ };
162
+ }
163
+ /**
164
+ * Ask the LLM to merge two versions of a file.
165
+ */
166
+ async function llmMerge(model, ours, theirs, filename) {
167
+ const prompt = `You are merging two versions of a Studiograph entity file (${filename}).
168
+ This is a markdown file with YAML frontmatter. Your job is to produce a single merged version that preserves the intent of both changes.
169
+
170
+ Rules:
171
+ - For timestamps (created_at, updated_at): keep the most recent value
172
+ - For additive changes (new fields, new content): include both
173
+ - For conflicting scalar values: prefer the version with more information; if unclear, prefer "theirs" (the remote version)
174
+ - For content (markdown body): combine both additions if they are distinct; deduplicate if they overlap
175
+ - Output ONLY the merged file content, no explanation or code fences
176
+
177
+ ## Version A (local)
178
+
179
+ ${ours}
180
+
181
+ ## Version B (remote)
182
+
183
+ ${theirs}
184
+
185
+ ## Merged output`;
186
+ try {
187
+ const result = await generateText({
188
+ model,
189
+ prompt,
190
+ maxOutputTokens: 4096,
191
+ });
192
+ const text = result.text.trim();
193
+ if (!text)
194
+ return null;
195
+ return text;
196
+ }
197
+ catch {
198
+ return null;
199
+ }
200
+ }
201
+ //# sourceMappingURL=merge-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-resolver.js","sourceRoot":"","sources":["../../src/utils/merge-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAahF;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,QAAgB,EAChB,UAAkC;IAElC,MAAM,GAAG,GAAG,UAAU,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAErC,gDAAgD;IAChD,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,sBAAsB,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAC/E,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IAC7C,CAAC;IAED,wBAAwB;IACxB,MAAM,UAAU,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAChD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IAC7C,CAAC;IAED,GAAG,CAAC,eAAe,UAAU,CAAC,MAAM,YAAY,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CA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I,CAAC,WAAW;QAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAEtD,IAAI,GAAG,CAAC,WAAW,GAAG,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1C,MAAM,GAAG,CAAC,aAAa,GAAG,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC;IAE9C,+EAA+E;IAC/E,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC;IACtC,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI;QAC1C,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM;KACjD,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,QAAQ,CACrB,KAAU,EACV,IAAY,EACZ,MAAc,EACd,QAAgB;IAEhB,MAAM,MAAM,GAAG,8DAA8D,QAAQ;;;;;;;;;;;;EAYrF,IAAI;;;;EAIJ,MAAM;;iBAES,CAAC;IAEhB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC;YAChC,KAAK;YACL,MAAM;YACN,eAAe,EAAE,IAAI;SACtB,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAChC,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QAEvB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -25,7 +25,8 @@ export declare function checkGit(): CheckResult;
25
25
  */
26
26
  export declare function checkNode(): CheckResult;
27
27
  /**
28
- * Check whether a GitHub auth token is stored.
28
+ * Check whether a GitHub auth token is available.
29
+ * Checks env vars first, then stored file.
29
30
  * This is contextual — absence is a warning, not a failure.
30
31
  */
31
32
  export declare function checkGithubAuth(): AuthCheckResult;
@@ -43,10 +43,17 @@ export function checkNode() {
43
43
  };
44
44
  }
45
45
  /**
46
- * Check whether a GitHub auth token is stored.
46
+ * Check whether a GitHub auth token is available.
47
+ * Checks env vars first, then stored file.
47
48
  * This is contextual — absence is a warning, not a failure.
48
49
  */
49
50
  export function checkGithubAuth() {
51
+ if (process.env.STUDIOGRAPH_GITHUB_TOKEN) {
52
+ return { present: true, message: 'GitHub auth configured (via STUDIOGRAPH_GITHUB_TOKEN)' };
53
+ }
54
+ if (process.env.GITHUB_TOKEN) {
55
+ return { present: true, message: 'GitHub auth configured (via GITHUB_TOKEN)' };
56
+ }
50
57
  const stored = loadToken();
51
58
  if (stored) {
52
59
  return { present: true, message: `GitHub auth configured (${stored.user.login})` };
@@ -1 +1 @@
1
- {"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/utils/preflight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,8CAA8C;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAcjC;;GAEG;AACH,MAAM,UAAU,QAAQ;IACtB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,QAAQ,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;QAC9E,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAChD,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC1C,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EA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AC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC;IAED,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,UAAU,GAAG,eAAe,EAAE,CAAC;QACrC,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;YACvB,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Version checking utility
3
+ *
4
+ * Provides lightweight version checking that can be called by commands
5
+ * to notify users of available updates.
6
+ */
7
+ /**
8
+ * Get current CLI version from package.json
9
+ */
10
+ export declare function getCurrentVersion(): string;
11
+ /**
12
+ * Check if an update is available (non-blocking, cached)
13
+ * Returns update info or null if up-to-date or check failed
14
+ */
15
+ export declare function checkForUpdate(): Promise<{
16
+ current: string;
17
+ latest: string;
18
+ } | null>;
19
+ /**
20
+ * Print update notification to console (if update available)
21
+ * Call this in commands to notify users about updates
22
+ */
23
+ export declare function notifyUpdateAvailable(): Promise<void>;
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Version checking utility
3
+ *
4
+ * Provides lightweight version checking that can be called by commands
5
+ * to notify users of available updates.
6
+ */
7
+ import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';
8
+ import { join } from 'path';
9
+ import { homedir } from 'os';
10
+ import { execSync } from 'child_process';
11
+ import { fileURLToPath } from 'url';
12
+ import { dirname } from 'path';
13
+ const CACHE_PATH = join(homedir(), '.studiograph', 'version-cache.json');
14
+ const CACHE_TTL_HOURS = 24; // Check once per day
15
+ /**
16
+ * Get current CLI version from package.json
17
+ */
18
+ export function getCurrentVersion() {
19
+ const __filename = fileURLToPath(import.meta.url);
20
+ const __dirname = dirname(__filename);
21
+ const pkgPath = join(__dirname, '../../package.json');
22
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
23
+ return pkg.version;
24
+ }
25
+ /**
26
+ * Fetch latest version from npm (with caching)
27
+ */
28
+ async function getLatestVersion() {
29
+ // Check cache first
30
+ if (existsSync(CACHE_PATH)) {
31
+ try {
32
+ const cache = JSON.parse(readFileSync(CACHE_PATH, 'utf-8'));
33
+ const cacheAge = Date.now() - new Date(cache.lastChecked).getTime();
34
+ const cacheAgeHours = cacheAge / (1000 * 60 * 60);
35
+ if (cacheAgeHours < CACHE_TTL_HOURS) {
36
+ return cache.latestVersion;
37
+ }
38
+ }
39
+ catch {
40
+ // Cache read failed, continue to fetch
41
+ }
42
+ }
43
+ // Fetch from npm
44
+ try {
45
+ const result = execSync('npm view studiograph version', {
46
+ encoding: 'utf-8',
47
+ stdio: 'pipe',
48
+ timeout: 5000, // 5 second timeout
49
+ });
50
+ const latest = result.trim();
51
+ // Update cache
52
+ const cacheDir = dirname(CACHE_PATH);
53
+ if (!existsSync(cacheDir)) {
54
+ mkdirSync(cacheDir, { recursive: true, mode: 0o755 });
55
+ }
56
+ const cache = {
57
+ lastChecked: new Date().toISOString(),
58
+ latestVersion: latest,
59
+ };
60
+ writeFileSync(CACHE_PATH, JSON.stringify(cache, null, 2), 'utf-8');
61
+ return latest;
62
+ }
63
+ catch {
64
+ // Network error or timeout - return null
65
+ return null;
66
+ }
67
+ }
68
+ /**
69
+ * Compare two semantic versions
70
+ * Returns: 1 if v1 > v2, -1 if v1 < v2, 0 if equal
71
+ */
72
+ function compareVersions(v1, v2) {
73
+ const parts1 = v1.split('.').map(Number);
74
+ const parts2 = v2.split('.').map(Number);
75
+ for (let i = 0; i < 3; i++) {
76
+ if (parts1[i] > parts2[i])
77
+ return 1;
78
+ if (parts1[i] < parts2[i])
79
+ return -1;
80
+ }
81
+ return 0;
82
+ }
83
+ /**
84
+ * Check if an update is available (non-blocking, cached)
85
+ * Returns update info or null if up-to-date or check failed
86
+ */
87
+ export async function checkForUpdate() {
88
+ const current = getCurrentVersion();
89
+ const latest = await getLatestVersion();
90
+ if (!latest)
91
+ return null;
92
+ const comparison = compareVersions(latest, current);
93
+ if (comparison > 0) {
94
+ return { current, latest };
95
+ }
96
+ return null;
97
+ }
98
+ /**
99
+ * Print update notification to console (if update available)
100
+ * Call this in commands to notify users about updates
101
+ */
102
+ export async function notifyUpdateAvailable() {
103
+ try {
104
+ const update = await checkForUpdate();
105
+ if (update) {
106
+ console.log('');
107
+ console.log(`\x1b[33m⚠️ Update available: v${update.current} → v${update.latest}\x1b[0m`);
108
+ console.log(`\x1b[2m Run: studiograph update\x1b[0m`);
109
+ console.log('');
110
+ }
111
+ }
112
+ catch {
113
+ // Silently fail - don't block command execution
114
+ }
115
+ }
116
+ //# sourceMappingURL=version-checker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-checker.js","sourceRoot":"","sources":["../../src/utils/version-checker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OA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C,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,MAAM,MAAM,GAAG,MAAM,gBAAgB,EAAE,CAAC;IAExC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzB,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEpD,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QACnB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,cAAc,EAAE,CAAC;QAEtC,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,kCAAkC,MAAM,CAAC,OAAO,OAAO,MAAM,CAAC,MAAM,SAAS,CAAC,CAAC;YAC3F,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;YACxD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,gDAAgD;IAClD,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Lightweight workspace config reader.
3
+ *
4
+ * Reads .studiograph/workspace.json synchronously without
5
+ * instantiating the full Workspace class. Used by sync pipeline
6
+ * modules that only need repo paths.
7
+ */
8
+ export declare function loadWorkspaceConfig(workspacePath: string): any;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Lightweight workspace config reader.
3
+ *
4
+ * Reads .studiograph/workspace.json synchronously without
5
+ * instantiating the full Workspace class. Used by sync pipeline
6
+ * modules that only need repo paths.
7
+ */
8
+ import { existsSync, readFileSync } from 'fs';
9
+ import { join } from 'path';
10
+ export function loadWorkspaceConfig(workspacePath) {
11
+ try {
12
+ const configPath = join(workspacePath, '.studiograph', 'workspace.json');
13
+ if (existsSync(configPath)) {
14
+ return JSON.parse(readFileSync(configPath, 'utf-8'));
15
+ }
16
+ }
17
+ catch {
18
+ // non-fatal — callers handle null
19
+ }
20
+ return null;
21
+ }
22
+ //# sourceMappingURL=workspace-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-config.js","sourceRoot":"","sources":["../../src/utils/workspace-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,MAAM,UAAU,mBAAmB,CAAC,aAAqB;IACvD,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,cAAc,EAAE,gBAAgB,CAAC,CAAC;QACzE,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,kCAAkC;IACpC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}