@selvakumaresra/specship 0.1.2 → 0.1.3

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 (576) hide show
  1. package/package.json +8 -3
  2. package/scripts/sync-shim-version.mjs +64 -0
  3. package/dist/bin/node-version-check.d.ts +0 -37
  4. package/dist/bin/node-version-check.d.ts.map +0 -1
  5. package/dist/bin/node-version-check.js +0 -79
  6. package/dist/bin/node-version-check.js.map +0 -1
  7. package/dist/bin/specship.d.ts +0 -25
  8. package/dist/bin/specship.d.ts.map +0 -1
  9. package/dist/bin/specship.js +0 -2018
  10. package/dist/bin/specship.js.map +0 -1
  11. package/dist/bin/uninstall.d.ts +0 -13
  12. package/dist/bin/uninstall.d.ts.map +0 -1
  13. package/dist/bin/uninstall.js +0 -35
  14. package/dist/bin/uninstall.js.map +0 -1
  15. package/dist/context/formatter.d.ts +0 -30
  16. package/dist/context/formatter.d.ts.map +0 -1
  17. package/dist/context/formatter.js +0 -263
  18. package/dist/context/formatter.js.map +0 -1
  19. package/dist/context/index.d.ts +0 -119
  20. package/dist/context/index.d.ts.map +0 -1
  21. package/dist/context/index.js +0 -1289
  22. package/dist/context/index.js.map +0 -1
  23. package/dist/context/markers.d.ts +0 -19
  24. package/dist/context/markers.d.ts.map +0 -1
  25. package/dist/context/markers.js +0 -22
  26. package/dist/context/markers.js.map +0 -1
  27. package/dist/db/index.d.ts +0 -101
  28. package/dist/db/index.d.ts.map +0 -1
  29. package/dist/db/index.js +0 -276
  30. package/dist/db/index.js.map +0 -1
  31. package/dist/db/migrations.d.ts +0 -44
  32. package/dist/db/migrations.d.ts.map +0 -1
  33. package/dist/db/migrations.js +0 -427
  34. package/dist/db/migrations.js.map +0 -1
  35. package/dist/db/queries.d.ts +0 -357
  36. package/dist/db/queries.d.ts.map +0 -1
  37. package/dist/db/queries.js +0 -1504
  38. package/dist/db/queries.js.map +0 -1
  39. package/dist/db/schema.sql +0 -410
  40. package/dist/db/spec-queries.d.ts +0 -101
  41. package/dist/db/spec-queries.d.ts.map +0 -1
  42. package/dist/db/spec-queries.js +0 -675
  43. package/dist/db/spec-queries.js.map +0 -1
  44. package/dist/db/sqlite-adapter.d.ts +0 -65
  45. package/dist/db/sqlite-adapter.d.ts.map +0 -1
  46. package/dist/db/sqlite-adapter.js +0 -214
  47. package/dist/db/sqlite-adapter.js.map +0 -1
  48. package/dist/directory.d.ts +0 -57
  49. package/dist/directory.d.ts.map +0 -1
  50. package/dist/directory.js +0 -253
  51. package/dist/directory.js.map +0 -1
  52. package/dist/errors.d.ts +0 -136
  53. package/dist/errors.d.ts.map +0 -1
  54. package/dist/errors.js +0 -219
  55. package/dist/errors.js.map +0 -1
  56. package/dist/extraction/dfm-extractor.d.ts +0 -31
  57. package/dist/extraction/dfm-extractor.d.ts.map +0 -1
  58. package/dist/extraction/dfm-extractor.js +0 -151
  59. package/dist/extraction/dfm-extractor.js.map +0 -1
  60. package/dist/extraction/generated-detection.d.ts +0 -30
  61. package/dist/extraction/generated-detection.d.ts.map +0 -1
  62. package/dist/extraction/generated-detection.js +0 -80
  63. package/dist/extraction/generated-detection.js.map +0 -1
  64. package/dist/extraction/grammars.d.ts +0 -100
  65. package/dist/extraction/grammars.d.ts.map +0 -1
  66. package/dist/extraction/grammars.js +0 -426
  67. package/dist/extraction/grammars.js.map +0 -1
  68. package/dist/extraction/index.d.ts +0 -138
  69. package/dist/extraction/index.d.ts.map +0 -1
  70. package/dist/extraction/index.js +0 -1394
  71. package/dist/extraction/index.js.map +0 -1
  72. package/dist/extraction/languages/c-cpp.d.ts +0 -4
  73. package/dist/extraction/languages/c-cpp.d.ts.map +0 -1
  74. package/dist/extraction/languages/c-cpp.js +0 -171
  75. package/dist/extraction/languages/c-cpp.js.map +0 -1
  76. package/dist/extraction/languages/csharp.d.ts +0 -3
  77. package/dist/extraction/languages/csharp.d.ts.map +0 -1
  78. package/dist/extraction/languages/csharp.js +0 -73
  79. package/dist/extraction/languages/csharp.js.map +0 -1
  80. package/dist/extraction/languages/dart.d.ts +0 -3
  81. package/dist/extraction/languages/dart.d.ts.map +0 -1
  82. package/dist/extraction/languages/dart.js +0 -192
  83. package/dist/extraction/languages/dart.js.map +0 -1
  84. package/dist/extraction/languages/go.d.ts +0 -3
  85. package/dist/extraction/languages/go.d.ts.map +0 -1
  86. package/dist/extraction/languages/go.js +0 -74
  87. package/dist/extraction/languages/go.js.map +0 -1
  88. package/dist/extraction/languages/index.d.ts +0 -10
  89. package/dist/extraction/languages/index.d.ts.map +0 -1
  90. package/dist/extraction/languages/index.js +0 -51
  91. package/dist/extraction/languages/index.js.map +0 -1
  92. package/dist/extraction/languages/java.d.ts +0 -3
  93. package/dist/extraction/languages/java.d.ts.map +0 -1
  94. package/dist/extraction/languages/java.js +0 -70
  95. package/dist/extraction/languages/java.js.map +0 -1
  96. package/dist/extraction/languages/javascript.d.ts +0 -3
  97. package/dist/extraction/languages/javascript.d.ts.map +0 -1
  98. package/dist/extraction/languages/javascript.js +0 -90
  99. package/dist/extraction/languages/javascript.js.map +0 -1
  100. package/dist/extraction/languages/kotlin.d.ts +0 -3
  101. package/dist/extraction/languages/kotlin.d.ts.map +0 -1
  102. package/dist/extraction/languages/kotlin.js +0 -259
  103. package/dist/extraction/languages/kotlin.js.map +0 -1
  104. package/dist/extraction/languages/lua.d.ts +0 -3
  105. package/dist/extraction/languages/lua.d.ts.map +0 -1
  106. package/dist/extraction/languages/lua.js +0 -150
  107. package/dist/extraction/languages/lua.js.map +0 -1
  108. package/dist/extraction/languages/luau.d.ts +0 -3
  109. package/dist/extraction/languages/luau.d.ts.map +0 -1
  110. package/dist/extraction/languages/luau.js +0 -37
  111. package/dist/extraction/languages/luau.js.map +0 -1
  112. package/dist/extraction/languages/objc.d.ts +0 -3
  113. package/dist/extraction/languages/objc.d.ts.map +0 -1
  114. package/dist/extraction/languages/objc.js +0 -133
  115. package/dist/extraction/languages/objc.js.map +0 -1
  116. package/dist/extraction/languages/pascal.d.ts +0 -3
  117. package/dist/extraction/languages/pascal.d.ts.map +0 -1
  118. package/dist/extraction/languages/pascal.js +0 -66
  119. package/dist/extraction/languages/pascal.js.map +0 -1
  120. package/dist/extraction/languages/php.d.ts +0 -3
  121. package/dist/extraction/languages/php.d.ts.map +0 -1
  122. package/dist/extraction/languages/php.js +0 -107
  123. package/dist/extraction/languages/php.js.map +0 -1
  124. package/dist/extraction/languages/python.d.ts +0 -3
  125. package/dist/extraction/languages/python.d.ts.map +0 -1
  126. package/dist/extraction/languages/python.js +0 -56
  127. package/dist/extraction/languages/python.js.map +0 -1
  128. package/dist/extraction/languages/ruby.d.ts +0 -3
  129. package/dist/extraction/languages/ruby.d.ts.map +0 -1
  130. package/dist/extraction/languages/ruby.js +0 -114
  131. package/dist/extraction/languages/ruby.js.map +0 -1
  132. package/dist/extraction/languages/rust.d.ts +0 -3
  133. package/dist/extraction/languages/rust.d.ts.map +0 -1
  134. package/dist/extraction/languages/rust.js +0 -109
  135. package/dist/extraction/languages/rust.js.map +0 -1
  136. package/dist/extraction/languages/scala.d.ts +0 -3
  137. package/dist/extraction/languages/scala.d.ts.map +0 -1
  138. package/dist/extraction/languages/scala.js +0 -139
  139. package/dist/extraction/languages/scala.js.map +0 -1
  140. package/dist/extraction/languages/swift.d.ts +0 -3
  141. package/dist/extraction/languages/swift.d.ts.map +0 -1
  142. package/dist/extraction/languages/swift.js +0 -91
  143. package/dist/extraction/languages/swift.js.map +0 -1
  144. package/dist/extraction/languages/typescript.d.ts +0 -3
  145. package/dist/extraction/languages/typescript.d.ts.map +0 -1
  146. package/dist/extraction/languages/typescript.js +0 -129
  147. package/dist/extraction/languages/typescript.js.map +0 -1
  148. package/dist/extraction/liquid-extractor.d.ts +0 -52
  149. package/dist/extraction/liquid-extractor.d.ts.map +0 -1
  150. package/dist/extraction/liquid-extractor.js +0 -313
  151. package/dist/extraction/liquid-extractor.js.map +0 -1
  152. package/dist/extraction/mybatis-extractor.d.ts +0 -48
  153. package/dist/extraction/mybatis-extractor.d.ts.map +0 -1
  154. package/dist/extraction/mybatis-extractor.js +0 -198
  155. package/dist/extraction/mybatis-extractor.js.map +0 -1
  156. package/dist/extraction/parse-worker.d.ts +0 -8
  157. package/dist/extraction/parse-worker.d.ts.map +0 -1
  158. package/dist/extraction/parse-worker.js +0 -94
  159. package/dist/extraction/parse-worker.js.map +0 -1
  160. package/dist/extraction/specs/markdown-spec-extractor.d.ts +0 -59
  161. package/dist/extraction/specs/markdown-spec-extractor.d.ts.map +0 -1
  162. package/dist/extraction/specs/markdown-spec-extractor.js +0 -327
  163. package/dist/extraction/specs/markdown-spec-extractor.js.map +0 -1
  164. package/dist/extraction/specs/types.d.ts +0 -39
  165. package/dist/extraction/specs/types.d.ts.map +0 -1
  166. package/dist/extraction/specs/types.js +0 -8
  167. package/dist/extraction/specs/types.js.map +0 -1
  168. package/dist/extraction/svelte-extractor.d.ts +0 -56
  169. package/dist/extraction/svelte-extractor.d.ts.map +0 -1
  170. package/dist/extraction/svelte-extractor.js +0 -272
  171. package/dist/extraction/svelte-extractor.js.map +0 -1
  172. package/dist/extraction/tree-sitter-helpers.d.ts +0 -28
  173. package/dist/extraction/tree-sitter-helpers.d.ts.map +0 -1
  174. package/dist/extraction/tree-sitter-helpers.js +0 -103
  175. package/dist/extraction/tree-sitter-helpers.js.map +0 -1
  176. package/dist/extraction/tree-sitter-types.d.ts +0 -193
  177. package/dist/extraction/tree-sitter-types.d.ts.map +0 -1
  178. package/dist/extraction/tree-sitter-types.js +0 -10
  179. package/dist/extraction/tree-sitter-types.js.map +0 -1
  180. package/dist/extraction/tree-sitter.d.ts +0 -317
  181. package/dist/extraction/tree-sitter.d.ts.map +0 -1
  182. package/dist/extraction/tree-sitter.js +0 -3092
  183. package/dist/extraction/tree-sitter.js.map +0 -1
  184. package/dist/extraction/vue-extractor.d.ts +0 -51
  185. package/dist/extraction/vue-extractor.d.ts.map +0 -1
  186. package/dist/extraction/vue-extractor.js +0 -251
  187. package/dist/extraction/vue-extractor.js.map +0 -1
  188. package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  189. package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  190. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  191. package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  192. package/dist/extraction/wasm-runtime-flags.d.ts +0 -38
  193. package/dist/extraction/wasm-runtime-flags.d.ts.map +0 -1
  194. package/dist/extraction/wasm-runtime-flags.js +0 -106
  195. package/dist/extraction/wasm-runtime-flags.js.map +0 -1
  196. package/dist/graph/index.d.ts +0 -8
  197. package/dist/graph/index.d.ts.map +0 -1
  198. package/dist/graph/index.js +0 -13
  199. package/dist/graph/index.js.map +0 -1
  200. package/dist/graph/queries.d.ts +0 -106
  201. package/dist/graph/queries.d.ts.map +0 -1
  202. package/dist/graph/queries.js +0 -366
  203. package/dist/graph/queries.js.map +0 -1
  204. package/dist/graph/traversal.d.ts +0 -127
  205. package/dist/graph/traversal.d.ts.map +0 -1
  206. package/dist/graph/traversal.js +0 -531
  207. package/dist/graph/traversal.js.map +0 -1
  208. package/dist/index.d.ts +0 -551
  209. package/dist/index.d.ts.map +0 -1
  210. package/dist/index.js +0 -1165
  211. package/dist/index.js.map +0 -1
  212. package/dist/installer/config-writer.d.ts +0 -28
  213. package/dist/installer/config-writer.d.ts.map +0 -1
  214. package/dist/installer/config-writer.js +0 -91
  215. package/dist/installer/config-writer.js.map +0 -1
  216. package/dist/installer/index.d.ts +0 -87
  217. package/dist/installer/index.d.ts.map +0 -1
  218. package/dist/installer/index.js +0 -409
  219. package/dist/installer/index.js.map +0 -1
  220. package/dist/installer/instructions-template.d.ts +0 -18
  221. package/dist/installer/instructions-template.d.ts.map +0 -1
  222. package/dist/installer/instructions-template.js +0 -21
  223. package/dist/installer/instructions-template.js.map +0 -1
  224. package/dist/installer/targets/claude.d.ts +0 -88
  225. package/dist/installer/targets/claude.d.ts.map +0 -1
  226. package/dist/installer/targets/claude.js +0 -582
  227. package/dist/installer/targets/claude.js.map +0 -1
  228. package/dist/installer/targets/registry.d.ts +0 -19
  229. package/dist/installer/targets/registry.d.ts.map +0 -1
  230. package/dist/installer/targets/registry.js +0 -31
  231. package/dist/installer/targets/registry.js.map +0 -1
  232. package/dist/installer/targets/shared.d.ts +0 -62
  233. package/dist/installer/targets/shared.d.ts.map +0 -1
  234. package/dist/installer/targets/shared.js +0 -207
  235. package/dist/installer/targets/shared.js.map +0 -1
  236. package/dist/installer/targets/types.d.ts +0 -76
  237. package/dist/installer/targets/types.d.ts.map +0 -1
  238. package/dist/installer/targets/types.js +0 -12
  239. package/dist/installer/targets/types.js.map +0 -1
  240. package/dist/isolation/worktree.d.ts +0 -65
  241. package/dist/isolation/worktree.d.ts.map +0 -1
  242. package/dist/isolation/worktree.js +0 -231
  243. package/dist/isolation/worktree.js.map +0 -1
  244. package/dist/mcp/daemon-paths.d.ts +0 -46
  245. package/dist/mcp/daemon-paths.d.ts.map +0 -1
  246. package/dist/mcp/daemon-paths.js +0 -125
  247. package/dist/mcp/daemon-paths.js.map +0 -1
  248. package/dist/mcp/daemon.d.ts +0 -161
  249. package/dist/mcp/daemon.d.ts.map +0 -1
  250. package/dist/mcp/daemon.js +0 -403
  251. package/dist/mcp/daemon.js.map +0 -1
  252. package/dist/mcp/engine.d.ts +0 -105
  253. package/dist/mcp/engine.d.ts.map +0 -1
  254. package/dist/mcp/engine.js +0 -270
  255. package/dist/mcp/engine.js.map +0 -1
  256. package/dist/mcp/index.d.ts +0 -112
  257. package/dist/mcp/index.d.ts.map +0 -1
  258. package/dist/mcp/index.js +0 -477
  259. package/dist/mcp/index.js.map +0 -1
  260. package/dist/mcp/proxy.d.ts +0 -81
  261. package/dist/mcp/proxy.d.ts.map +0 -1
  262. package/dist/mcp/proxy.js +0 -510
  263. package/dist/mcp/proxy.js.map +0 -1
  264. package/dist/mcp/server-instructions.d.ts +0 -18
  265. package/dist/mcp/server-instructions.d.ts.map +0 -1
  266. package/dist/mcp/server-instructions.js +0 -77
  267. package/dist/mcp/server-instructions.js.map +0 -1
  268. package/dist/mcp/session.d.ts +0 -77
  269. package/dist/mcp/session.d.ts.map +0 -1
  270. package/dist/mcp/session.js +0 -294
  271. package/dist/mcp/session.js.map +0 -1
  272. package/dist/mcp/spec-tools.d.ts +0 -39
  273. package/dist/mcp/spec-tools.d.ts.map +0 -1
  274. package/dist/mcp/spec-tools.js +0 -326
  275. package/dist/mcp/spec-tools.js.map +0 -1
  276. package/dist/mcp/tools.d.ts +0 -404
  277. package/dist/mcp/tools.d.ts.map +0 -1
  278. package/dist/mcp/tools.js +0 -3066
  279. package/dist/mcp/tools.js.map +0 -1
  280. package/dist/mcp/transport.d.ts +0 -188
  281. package/dist/mcp/transport.d.ts.map +0 -1
  282. package/dist/mcp/transport.js +0 -343
  283. package/dist/mcp/transport.js.map +0 -1
  284. package/dist/mcp/version.d.ts +0 -19
  285. package/dist/mcp/version.d.ts.map +0 -1
  286. package/dist/mcp/version.js +0 -71
  287. package/dist/mcp/version.js.map +0 -1
  288. package/dist/resolution/callback-synthesizer.d.ts +0 -10
  289. package/dist/resolution/callback-synthesizer.d.ts.map +0 -1
  290. package/dist/resolution/callback-synthesizer.js +0 -1300
  291. package/dist/resolution/callback-synthesizer.js.map +0 -1
  292. package/dist/resolution/frameworks/cargo-workspace.d.ts +0 -18
  293. package/dist/resolution/frameworks/cargo-workspace.d.ts.map +0 -1
  294. package/dist/resolution/frameworks/cargo-workspace.js +0 -225
  295. package/dist/resolution/frameworks/cargo-workspace.js.map +0 -1
  296. package/dist/resolution/frameworks/csharp.d.ts +0 -8
  297. package/dist/resolution/frameworks/csharp.d.ts.map +0 -1
  298. package/dist/resolution/frameworks/csharp.js +0 -241
  299. package/dist/resolution/frameworks/csharp.js.map +0 -1
  300. package/dist/resolution/frameworks/drupal.d.ts +0 -51
  301. package/dist/resolution/frameworks/drupal.d.ts.map +0 -1
  302. package/dist/resolution/frameworks/drupal.js +0 -367
  303. package/dist/resolution/frameworks/drupal.js.map +0 -1
  304. package/dist/resolution/frameworks/expo-modules.d.ts +0 -3
  305. package/dist/resolution/frameworks/expo-modules.d.ts.map +0 -1
  306. package/dist/resolution/frameworks/expo-modules.js +0 -143
  307. package/dist/resolution/frameworks/expo-modules.js.map +0 -1
  308. package/dist/resolution/frameworks/express.d.ts +0 -8
  309. package/dist/resolution/frameworks/express.d.ts.map +0 -1
  310. package/dist/resolution/frameworks/express.js +0 -308
  311. package/dist/resolution/frameworks/express.js.map +0 -1
  312. package/dist/resolution/frameworks/fabric.d.ts +0 -3
  313. package/dist/resolution/frameworks/fabric.d.ts.map +0 -1
  314. package/dist/resolution/frameworks/fabric.js +0 -354
  315. package/dist/resolution/frameworks/fabric.js.map +0 -1
  316. package/dist/resolution/frameworks/go.d.ts +0 -8
  317. package/dist/resolution/frameworks/go.d.ts.map +0 -1
  318. package/dist/resolution/frameworks/go.js +0 -161
  319. package/dist/resolution/frameworks/go.js.map +0 -1
  320. package/dist/resolution/frameworks/index.d.ts +0 -48
  321. package/dist/resolution/frameworks/index.d.ts.map +0 -1
  322. package/dist/resolution/frameworks/index.js +0 -161
  323. package/dist/resolution/frameworks/index.js.map +0 -1
  324. package/dist/resolution/frameworks/java.d.ts +0 -8
  325. package/dist/resolution/frameworks/java.d.ts.map +0 -1
  326. package/dist/resolution/frameworks/java.js +0 -504
  327. package/dist/resolution/frameworks/java.js.map +0 -1
  328. package/dist/resolution/frameworks/laravel.d.ts +0 -13
  329. package/dist/resolution/frameworks/laravel.d.ts.map +0 -1
  330. package/dist/resolution/frameworks/laravel.js +0 -257
  331. package/dist/resolution/frameworks/laravel.js.map +0 -1
  332. package/dist/resolution/frameworks/nestjs.d.ts +0 -26
  333. package/dist/resolution/frameworks/nestjs.d.ts.map +0 -1
  334. package/dist/resolution/frameworks/nestjs.js +0 -698
  335. package/dist/resolution/frameworks/nestjs.js.map +0 -1
  336. package/dist/resolution/frameworks/play.d.ts +0 -19
  337. package/dist/resolution/frameworks/play.d.ts.map +0 -1
  338. package/dist/resolution/frameworks/play.js +0 -111
  339. package/dist/resolution/frameworks/play.js.map +0 -1
  340. package/dist/resolution/frameworks/python.d.ts +0 -10
  341. package/dist/resolution/frameworks/python.d.ts.map +0 -1
  342. package/dist/resolution/frameworks/python.js +0 -396
  343. package/dist/resolution/frameworks/python.js.map +0 -1
  344. package/dist/resolution/frameworks/react-native.d.ts +0 -3
  345. package/dist/resolution/frameworks/react-native.d.ts.map +0 -1
  346. package/dist/resolution/frameworks/react-native.js +0 -360
  347. package/dist/resolution/frameworks/react-native.js.map +0 -1
  348. package/dist/resolution/frameworks/react.d.ts +0 -8
  349. package/dist/resolution/frameworks/react.d.ts.map +0 -1
  350. package/dist/resolution/frameworks/react.js +0 -365
  351. package/dist/resolution/frameworks/react.js.map +0 -1
  352. package/dist/resolution/frameworks/ruby.d.ts +0 -8
  353. package/dist/resolution/frameworks/ruby.d.ts.map +0 -1
  354. package/dist/resolution/frameworks/ruby.js +0 -302
  355. package/dist/resolution/frameworks/ruby.js.map +0 -1
  356. package/dist/resolution/frameworks/rust.d.ts +0 -8
  357. package/dist/resolution/frameworks/rust.d.ts.map +0 -1
  358. package/dist/resolution/frameworks/rust.js +0 -304
  359. package/dist/resolution/frameworks/rust.js.map +0 -1
  360. package/dist/resolution/frameworks/svelte.d.ts +0 -9
  361. package/dist/resolution/frameworks/svelte.d.ts.map +0 -1
  362. package/dist/resolution/frameworks/svelte.js +0 -249
  363. package/dist/resolution/frameworks/svelte.js.map +0 -1
  364. package/dist/resolution/frameworks/swift-objc.d.ts +0 -37
  365. package/dist/resolution/frameworks/swift-objc.d.ts.map +0 -1
  366. package/dist/resolution/frameworks/swift-objc.js +0 -252
  367. package/dist/resolution/frameworks/swift-objc.js.map +0 -1
  368. package/dist/resolution/frameworks/swift.d.ts +0 -10
  369. package/dist/resolution/frameworks/swift.d.ts.map +0 -1
  370. package/dist/resolution/frameworks/swift.js +0 -400
  371. package/dist/resolution/frameworks/swift.js.map +0 -1
  372. package/dist/resolution/frameworks/vue.d.ts +0 -9
  373. package/dist/resolution/frameworks/vue.d.ts.map +0 -1
  374. package/dist/resolution/frameworks/vue.js +0 -306
  375. package/dist/resolution/frameworks/vue.js.map +0 -1
  376. package/dist/resolution/go-module.d.ts +0 -26
  377. package/dist/resolution/go-module.d.ts.map +0 -1
  378. package/dist/resolution/go-module.js +0 -78
  379. package/dist/resolution/go-module.js.map +0 -1
  380. package/dist/resolution/import-resolver.d.ts +0 -68
  381. package/dist/resolution/import-resolver.d.ts.map +0 -1
  382. package/dist/resolution/import-resolver.js +0 -1275
  383. package/dist/resolution/import-resolver.js.map +0 -1
  384. package/dist/resolution/index.d.ts +0 -117
  385. package/dist/resolution/index.d.ts.map +0 -1
  386. package/dist/resolution/index.js +0 -895
  387. package/dist/resolution/index.js.map +0 -1
  388. package/dist/resolution/lru-cache.d.ts +0 -24
  389. package/dist/resolution/lru-cache.d.ts.map +0 -1
  390. package/dist/resolution/lru-cache.js +0 -62
  391. package/dist/resolution/lru-cache.js.map +0 -1
  392. package/dist/resolution/name-matcher.d.ts +0 -32
  393. package/dist/resolution/name-matcher.d.ts.map +0 -1
  394. package/dist/resolution/name-matcher.js +0 -596
  395. package/dist/resolution/name-matcher.js.map +0 -1
  396. package/dist/resolution/path-aliases.d.ts +0 -68
  397. package/dist/resolution/path-aliases.d.ts.map +0 -1
  398. package/dist/resolution/path-aliases.js +0 -238
  399. package/dist/resolution/path-aliases.js.map +0 -1
  400. package/dist/resolution/spec-link-resolver.d.ts +0 -103
  401. package/dist/resolution/spec-link-resolver.d.ts.map +0 -1
  402. package/dist/resolution/spec-link-resolver.js +0 -259
  403. package/dist/resolution/spec-link-resolver.js.map +0 -1
  404. package/dist/resolution/strip-comments.d.ts +0 -27
  405. package/dist/resolution/strip-comments.d.ts.map +0 -1
  406. package/dist/resolution/strip-comments.js +0 -441
  407. package/dist/resolution/strip-comments.js.map +0 -1
  408. package/dist/resolution/swift-objc-bridge.d.ts +0 -134
  409. package/dist/resolution/swift-objc-bridge.d.ts.map +0 -1
  410. package/dist/resolution/swift-objc-bridge.js +0 -256
  411. package/dist/resolution/swift-objc-bridge.js.map +0 -1
  412. package/dist/resolution/types.d.ts +0 -216
  413. package/dist/resolution/types.d.ts.map +0 -1
  414. package/dist/resolution/types.js +0 -8
  415. package/dist/resolution/types.js.map +0 -1
  416. package/dist/resolution/workspace-packages.d.ts +0 -48
  417. package/dist/resolution/workspace-packages.d.ts.map +0 -1
  418. package/dist/resolution/workspace-packages.js +0 -208
  419. package/dist/resolution/workspace-packages.js.map +0 -1
  420. package/dist/search/query-parser.d.ts +0 -57
  421. package/dist/search/query-parser.d.ts.map +0 -1
  422. package/dist/search/query-parser.js +0 -177
  423. package/dist/search/query-parser.js.map +0 -1
  424. package/dist/search/query-utils.d.ts +0 -71
  425. package/dist/search/query-utils.d.ts.map +0 -1
  426. package/dist/search/query-utils.js +0 -380
  427. package/dist/search/query-utils.js.map +0 -1
  428. package/dist/server/cli.js +0 -152
  429. package/dist/server/index.js +0 -12
  430. package/dist/server/ingest/index.js +0 -18
  431. package/dist/server/ingest/ingestor.js +0 -406
  432. package/dist/server/ingest/parser.js +0 -104
  433. package/dist/server/ingest/pricing.js +0 -78
  434. package/dist/server/ingest/types.js +0 -9
  435. package/dist/server/ingest/watcher.js +0 -77
  436. package/dist/server/package.json +0 -3
  437. package/dist/server/project-registry.js +0 -101
  438. package/dist/server/routes/claude.js +0 -480
  439. package/dist/server/routes/graph.js +0 -149
  440. package/dist/server/routes/memory.js +0 -272
  441. package/dist/server/routes/projects.js +0 -197
  442. package/dist/server/routes/spec.js +0 -105
  443. package/dist/server/routes/status.js +0 -35
  444. package/dist/server/routes/workflow.js +0 -184
  445. package/dist/server/server.js +0 -206
  446. package/dist/server/static-handler.js +0 -87
  447. package/dist/sync/git-hooks.d.ts +0 -45
  448. package/dist/sync/git-hooks.d.ts.map +0 -1
  449. package/dist/sync/git-hooks.js +0 -225
  450. package/dist/sync/git-hooks.js.map +0 -1
  451. package/dist/sync/index.d.ts +0 -19
  452. package/dist/sync/index.d.ts.map +0 -1
  453. package/dist/sync/index.js +0 -35
  454. package/dist/sync/index.js.map +0 -1
  455. package/dist/sync/watch-policy.d.ts +0 -48
  456. package/dist/sync/watch-policy.d.ts.map +0 -1
  457. package/dist/sync/watch-policy.js +0 -124
  458. package/dist/sync/watch-policy.js.map +0 -1
  459. package/dist/sync/watcher.d.ts +0 -283
  460. package/dist/sync/watcher.d.ts.map +0 -1
  461. package/dist/sync/watcher.js +0 -606
  462. package/dist/sync/watcher.js.map +0 -1
  463. package/dist/sync/worktree.d.ts +0 -54
  464. package/dist/sync/worktree.d.ts.map +0 -1
  465. package/dist/sync/worktree.js +0 -137
  466. package/dist/sync/worktree.js.map +0 -1
  467. package/dist/types.d.ts +0 -623
  468. package/dist/types.d.ts.map +0 -1
  469. package/dist/types.js +0 -108
  470. package/dist/types.js.map +0 -1
  471. package/dist/ui/glyphs.d.ts +0 -42
  472. package/dist/ui/glyphs.d.ts.map +0 -1
  473. package/dist/ui/glyphs.js +0 -78
  474. package/dist/ui/glyphs.js.map +0 -1
  475. package/dist/ui/shimmer-progress.d.ts +0 -11
  476. package/dist/ui/shimmer-progress.d.ts.map +0 -1
  477. package/dist/ui/shimmer-progress.js +0 -90
  478. package/dist/ui/shimmer-progress.js.map +0 -1
  479. package/dist/ui/shimmer-worker.d.ts +0 -2
  480. package/dist/ui/shimmer-worker.d.ts.map +0 -1
  481. package/dist/ui/shimmer-worker.js +0 -118
  482. package/dist/ui/shimmer-worker.js.map +0 -1
  483. package/dist/ui/types.d.ts +0 -17
  484. package/dist/ui/types.d.ts.map +0 -1
  485. package/dist/ui/types.js +0 -3
  486. package/dist/ui/types.js.map +0 -1
  487. package/dist/utils.d.ts +0 -205
  488. package/dist/utils.d.ts.map +0 -1
  489. package/dist/utils.js +0 -549
  490. package/dist/utils.js.map +0 -1
  491. package/dist/web/chunk-2YZXEHZ2.js +0 -1
  492. package/dist/web/chunk-3GIC555L.js +0 -18
  493. package/dist/web/chunk-3IIIGRMT.js +0 -1
  494. package/dist/web/chunk-47QYKLE5.js +0 -1
  495. package/dist/web/chunk-4LHBWWP7.js +0 -1
  496. package/dist/web/chunk-4OAZLD5W.js +0 -1
  497. package/dist/web/chunk-5OQKAJAE.js +0 -1
  498. package/dist/web/chunk-7B525GKQ.js +0 -1
  499. package/dist/web/chunk-BPDXCOOZ.js +0 -1
  500. package/dist/web/chunk-DT37HTZB.js +0 -1
  501. package/dist/web/chunk-EIMUHJND.js +0 -1
  502. package/dist/web/chunk-FTESTUEO.js +0 -1
  503. package/dist/web/chunk-GLJZV6MU.js +0 -1
  504. package/dist/web/chunk-I7LS67U5.js +0 -1
  505. package/dist/web/chunk-L4TVIPSR.js +0 -1
  506. package/dist/web/chunk-MASCULC2.js +0 -1
  507. package/dist/web/chunk-MW7ICSRM.js +0 -1
  508. package/dist/web/chunk-OI5VP2A3.js +0 -1
  509. package/dist/web/chunk-RA6EBF6I.js +0 -1
  510. package/dist/web/chunk-RP3WU5Y6.js +0 -1
  511. package/dist/web/chunk-RQDRMTXN.js +0 -1
  512. package/dist/web/chunk-TQMT6UDU.js +0 -1
  513. package/dist/web/chunk-U7IYOV7T.js +0 -1
  514. package/dist/web/chunk-UE227MWF.js +0 -1
  515. package/dist/web/chunk-WV573J4K.js +0 -1
  516. package/dist/web/chunk-WVCKOJZL.js +0 -4
  517. package/dist/web/chunk-XZKLVPHE.js +0 -1
  518. package/dist/web/chunk-ZABKKHJ3.js +0 -1
  519. package/dist/web/favicon-16.png +0 -0
  520. package/dist/web/favicon-180.png +0 -0
  521. package/dist/web/favicon-32.png +0 -0
  522. package/dist/web/favicon-512.png +0 -0
  523. package/dist/web/favicon-small.svg +0 -15
  524. package/dist/web/favicon.ico +0 -0
  525. package/dist/web/favicon.svg +0 -20
  526. package/dist/web/index.html +0 -145
  527. package/dist/web/main-RI5CO5Z4.js +0 -1
  528. package/dist/web/styles-CYN7IKT4.css +0 -1
  529. package/dist/workflows/condition-evaluator.d.ts +0 -75
  530. package/dist/workflows/condition-evaluator.d.ts.map +0 -1
  531. package/dist/workflows/condition-evaluator.js +0 -282
  532. package/dist/workflows/condition-evaluator.js.map +0 -1
  533. package/dist/workflows/defaults/index.d.ts +0 -26
  534. package/dist/workflows/defaults/index.d.ts.map +0 -1
  535. package/dist/workflows/defaults/index.js +0 -94
  536. package/dist/workflows/defaults/index.js.map +0 -1
  537. package/dist/workflows/defaults/spec-fix.yaml +0 -110
  538. package/dist/workflows/defaults/spec-implement.yaml +0 -150
  539. package/dist/workflows/defaults/spec-relink.yaml +0 -81
  540. package/dist/workflows/defaults/spec-verify.yaml +0 -51
  541. package/dist/workflows/discovery.d.ts +0 -46
  542. package/dist/workflows/discovery.d.ts.map +0 -1
  543. package/dist/workflows/discovery.js +0 -193
  544. package/dist/workflows/discovery.js.map +0 -1
  545. package/dist/workflows/executor.d.ts +0 -83
  546. package/dist/workflows/executor.d.ts.map +0 -1
  547. package/dist/workflows/executor.js +0 -623
  548. package/dist/workflows/executor.js.map +0 -1
  549. package/dist/workflows/runners/approval.d.ts +0 -18
  550. package/dist/workflows/runners/approval.d.ts.map +0 -1
  551. package/dist/workflows/runners/approval.js +0 -34
  552. package/dist/workflows/runners/approval.js.map +0 -1
  553. package/dist/workflows/runners/bash.d.ts +0 -13
  554. package/dist/workflows/runners/bash.d.ts.map +0 -1
  555. package/dist/workflows/runners/bash.js +0 -143
  556. package/dist/workflows/runners/bash.js.map +0 -1
  557. package/dist/workflows/runners/cancel.d.ts +0 -10
  558. package/dist/workflows/runners/cancel.d.ts.map +0 -1
  559. package/dist/workflows/runners/cancel.js +0 -19
  560. package/dist/workflows/runners/cancel.js.map +0 -1
  561. package/dist/workflows/runners/prompt.d.ts +0 -28
  562. package/dist/workflows/runners/prompt.d.ts.map +0 -1
  563. package/dist/workflows/runners/prompt.js +0 -212
  564. package/dist/workflows/runners/prompt.js.map +0 -1
  565. package/dist/workflows/runners/script.d.ts +0 -17
  566. package/dist/workflows/runners/script.d.ts.map +0 -1
  567. package/dist/workflows/runners/script.js +0 -155
  568. package/dist/workflows/runners/script.js.map +0 -1
  569. package/dist/workflows/runners/types.d.ts +0 -51
  570. package/dist/workflows/runners/types.d.ts.map +0 -1
  571. package/dist/workflows/runners/types.js +0 -13
  572. package/dist/workflows/runners/types.js.map +0 -1
  573. package/dist/workflows/schemas/workflow.d.ts +0 -166
  574. package/dist/workflows/schemas/workflow.d.ts.map +0 -1
  575. package/dist/workflows/schemas/workflow.js +0 -437
  576. package/dist/workflows/schemas/workflow.js.map +0 -1
@@ -1,2018 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- /**
4
- * SpecShip CLI
5
- *
6
- * Command-line interface for SpecShip code intelligence.
7
- *
8
- * Usage:
9
- * specship Run interactive installer (when no args)
10
- * specship install Run interactive installer
11
- * specship uninstall Remove SpecShip from your agents
12
- * specship init [path] Initialize SpecShip in a project
13
- * specship uninit [path] Remove SpecShip from a project
14
- * specship index [path] Index all files in the project
15
- * specship sync [path] Sync changes since last index
16
- * specship status [path] Show index status
17
- * specship query <search> Search for symbols
18
- * specship files [options] Show project file structure
19
- * specship context <task> Build context for a task
20
- * specship callers <symbol> Find what calls a function/method
21
- * specship callees <symbol> Find what a function/method calls
22
- * specship impact <symbol> Analyze what code is affected by changing a symbol
23
- * specship affected [files] Find test files affected by changes
24
- */
25
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
26
- if (k2 === undefined) k2 = k;
27
- var desc = Object.getOwnPropertyDescriptor(m, k);
28
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
29
- desc = { enumerable: true, get: function() { return m[k]; } };
30
- }
31
- Object.defineProperty(o, k2, desc);
32
- }) : (function(o, m, k, k2) {
33
- if (k2 === undefined) k2 = k;
34
- o[k2] = m[k];
35
- }));
36
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
37
- Object.defineProperty(o, "default", { enumerable: true, value: v });
38
- }) : function(o, v) {
39
- o["default"] = v;
40
- });
41
- var __importStar = (this && this.__importStar) || (function () {
42
- var ownKeys = function(o) {
43
- ownKeys = Object.getOwnPropertyNames || function (o) {
44
- var ar = [];
45
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
46
- return ar;
47
- };
48
- return ownKeys(o);
49
- };
50
- return function (mod) {
51
- if (mod && mod.__esModule) return mod;
52
- var result = {};
53
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
54
- __setModuleDefault(result, mod);
55
- return result;
56
- };
57
- })();
58
- Object.defineProperty(exports, "__esModule", { value: true });
59
- const commander_1 = require("commander");
60
- const path = __importStar(require("path"));
61
- const fs = __importStar(require("fs"));
62
- const os = __importStar(require("os"));
63
- const directory_1 = require("../directory");
64
- const worktree_1 = require("../sync/worktree");
65
- const shimmer_progress_1 = require("../ui/shimmer-progress");
66
- const glyphs_1 = require("../ui/glyphs");
67
- const node_version_check_1 = require("./node-version-check");
68
- const wasm_runtime_flags_1 = require("../extraction/wasm-runtime-flags");
69
- // Lazy-load heavy modules (SpecShip, runInstaller) to keep CLI startup fast.
70
- async function loadSpecShip() {
71
- try {
72
- return await Promise.resolve().then(() => __importStar(require('../index')));
73
- }
74
- catch (err) {
75
- const msg = err instanceof Error ? err.message : String(err);
76
- console.error(`\x1b[31m${(0, glyphs_1.getGlyphs)().err}\x1b[0m Failed to load SpecShip modules.`);
77
- console.error(`\n Node: ${process.version} Platform: ${process.platform} ${process.arch}`);
78
- console.error(`\n Error: ${msg}`);
79
- console.error('\n Try reinstalling with: npm install -g @selvakumaresra/specship\n');
80
- process.exit(1);
81
- }
82
- }
83
- async function loadServerPackage() {
84
- // Resolution order:
85
- // 1. Bundled mode — `dist/server/index.js` next to this CLI. This is
86
- // what every `npm i -g @selvakumaresra/specship` install hits, since
87
- // the publish pipeline copies the compiled server into the root's
88
- // `dist/`.
89
- // 2. npm dep `@selvakumaresra/specship-server` if some downstream
90
- // consumer ever wires it as a separate package (kept for forward
91
- // compatibility — not the shipped path).
92
- // 3. Dev/workspace sibling: `packages/server/dist/index.js` for
93
- // running from a checkout without a prior `npm run build`.
94
- const candidates = [
95
- path.resolve(__dirname, '..', 'server', 'index.js'),
96
- '@selvakumaresra/specship-server',
97
- path.resolve(__dirname, '..', '..', 'packages', 'server', 'dist', 'index.js'),
98
- path.resolve(__dirname, '..', '..', '..', 'packages', 'server', 'dist', 'index.js'),
99
- ];
100
- let lastErr = null;
101
- for (const c of candidates) {
102
- try {
103
- return (await Promise.resolve(`${c}`).then(s => __importStar(require(s))));
104
- }
105
- catch (e) {
106
- lastErr = e;
107
- }
108
- }
109
- console.error(`\x1b[31m${(0, glyphs_1.getGlyphs)().err}\x1b[0m Could not load the bundled HTTP server. Re-run \`npm run build\` (or the bundled npm install is corrupt).`);
110
- if (lastErr)
111
- console.error(' ' + (lastErr instanceof Error ? lastErr.message : String(lastErr)));
112
- process.exit(1);
113
- }
114
- /**
115
- * The JSONL ingest watcher now ships inside `@selvakumaresra/specship-server`
116
- * itself — `createServer({ ingest: true })` starts it. No separate package.
117
- */
118
- /**
119
- * Auto-pick a default project for `specship serve --ui` when the user
120
- * didn't pass `-p` and the cwd isn't initialized either. Walks
121
- * `~/.claude/projects/*` (Claude Code's per-project transcript dirs),
122
- * decodes each slug back to a real path, and returns the most-recently-
123
- * touched one that's still on disk AND has been `specship init`'d.
124
- *
125
- * Returns null when nothing qualifies — the server boots projectless and
126
- * the desktop UI prompts the user to pick.
127
- */
128
- async function pickRecentInitializedProject() {
129
- const claudeRoot = path.join(os.homedir(), '.claude', 'projects');
130
- let entries;
131
- try {
132
- entries = fs.readdirSync(claudeRoot, { withFileTypes: true });
133
- }
134
- catch {
135
- return null;
136
- }
137
- const candidates = [];
138
- for (const ent of entries) {
139
- if (!ent.isDirectory())
140
- continue;
141
- const slug = ent.name;
142
- // Same encoding the server's decodeProjectSlug uses: '-' → '/'.
143
- const decoded = slug.startsWith('-') ? '/' + slug.slice(1).replace(/-/g, '/') : slug;
144
- try {
145
- const st = fs.statSync(decoded);
146
- if (!st.isDirectory())
147
- continue;
148
- }
149
- catch {
150
- continue;
151
- }
152
- if (!(0, directory_1.isInitialized)(decoded))
153
- continue;
154
- // Use the newest .jsonl mtime in the slug dir as the activity signal.
155
- let lastTouched = 0;
156
- try {
157
- const files = fs.readdirSync(path.join(claudeRoot, slug), { withFileTypes: true });
158
- for (const f of files) {
159
- if (!f.isFile() || !f.name.toLowerCase().endsWith('.jsonl'))
160
- continue;
161
- try {
162
- const st = fs.statSync(path.join(claudeRoot, slug, f.name));
163
- if (st.mtimeMs > lastTouched)
164
- lastTouched = st.mtimeMs;
165
- }
166
- catch { /* ignore */ }
167
- }
168
- }
169
- catch { /* ignore */ }
170
- candidates.push({ decoded, lastTouched });
171
- }
172
- candidates.sort((a, b) => b.lastTouched - a.lastTouched);
173
- return candidates[0]?.decoded ?? null;
174
- }
175
- /**
176
- * Locate the built Angular UI for `specship serve --ui`. Mirrors the
177
- * lookup order in `packages/server/src/cli.ts:locateWebDir` so both entry
178
- * points behave identically. Returns null when nothing is found — the
179
- * server then runs API-only.
180
- */
181
- function locateWebDir(explicit) {
182
- const envDir = process.env.SPECSHIP_WEB_DIR ?? process.env.SPECSHIP_WEB_DIR;
183
- const candidates = [];
184
- if (explicit)
185
- candidates.push(path.resolve(explicit));
186
- if (envDir)
187
- candidates.push(path.resolve(envDir));
188
- // 1. Bundled mode — `dist/web/` next to this CLI. This is what every
189
- // `npm i -g @selvakumaresra/specship` install hits.
190
- candidates.push(path.resolve(__dirname, '..', 'web'));
191
- // 2. Legacy / forward-compat: the old `@selvakumaresra/specship-server`
192
- // used to ship the SPA at <pkg>/public/web.
193
- try {
194
- const pkgJson = require.resolve('@selvakumaresra/specship-server/package.json');
195
- candidates.push(path.resolve(path.dirname(pkgJson), 'public', 'web'));
196
- }
197
- catch { /* not installed as separate package — fall through */ }
198
- // 3. Dev monorepo layouts (running from a checkout).
199
- candidates.push(path.resolve(__dirname, '..', '..', 'packages', 'server', 'public', 'web'));
200
- candidates.push(path.resolve(__dirname, '..', '..', '..', 'packages', 'server', 'public', 'web'));
201
- candidates.push(path.resolve(__dirname, '..', '..', 'packages', 'web-ng', 'dist', 'web-ng', 'browser'));
202
- candidates.push(path.resolve(__dirname, '..', '..', '..', 'packages', 'web-ng', 'dist', 'web-ng', 'browser'));
203
- // 4. Walk up from cwd in case the bin is run inside a checkout.
204
- let cur = process.cwd();
205
- for (let depth = 0; depth < 6; depth++) {
206
- candidates.push(path.join(cur, 'dist', 'web'));
207
- candidates.push(path.join(cur, 'packages', 'server', 'public', 'web'));
208
- candidates.push(path.join(cur, 'packages', 'web-ng', 'dist', 'web-ng', 'browser'));
209
- const parent = path.dirname(cur);
210
- if (parent === cur)
211
- break;
212
- cur = parent;
213
- }
214
- for (const c of candidates) {
215
- try {
216
- if (fs.existsSync(path.join(c, 'index.html')))
217
- return c;
218
- }
219
- catch { /* ignore */ }
220
- }
221
- return null;
222
- }
223
- // Dynamic import helper — tsc compiles import() to require() in CJS mode,
224
- // which fails for ESM-only packages. This bypasses the transformation.
225
- // eslint-disable-next-line @typescript-eslint/no-implied-eval
226
- const importESM = new Function('specifier', 'return import(specifier)');
227
- // Block SpecShip on Node.js 25.x — V8's turboshaft WASM JIT has a Zone
228
- // allocator bug that reliably crashes when compiling tree-sitter
229
- // grammars (see #54, #81, #140). The previous behaviour was a soft
230
- // console.warn that scrolls off-screen before the OOM crash 30 seconds
231
- // later, leading to a steady stream of "what is this OOM" reports.
232
- // Hard-exit before any WASM work; allow override via env var for users
233
- // who patched V8 themselves or want to test a future fix.
234
- const nodeVersion = process.versions.node;
235
- const nodeMajor = parseInt(nodeVersion.split('.')[0] ?? '0', 10);
236
- if (nodeMajor >= 25) {
237
- process.stderr.write((0, node_version_check_1.buildNode25BlockBanner)(nodeVersion) + '\n');
238
- if (!process.env.SPECSHIP_ALLOW_UNSAFE_NODE) {
239
- process.exit(1);
240
- }
241
- // Override active — banner shown for visibility, continuing.
242
- }
243
- // Enforce the supported Node floor. `engines` in package.json only *warns* on
244
- // install (unless engine-strict), so hard-block here to actually keep users off
245
- // unsupported versions. Mirrors the 25+ block above. See package.json `engines`.
246
- if (nodeMajor < node_version_check_1.MIN_NODE_MAJOR) {
247
- process.stderr.write((0, node_version_check_1.buildNodeTooOldBanner)(nodeVersion) + '\n');
248
- if (!process.env.SPECSHIP_ALLOW_UNSAFE_NODE) {
249
- process.exit(1);
250
- }
251
- // Override active — banner shown for visibility, continuing.
252
- }
253
- // Re-exec with V8's `--liftoff-only` if it isn't already set, so tree-sitter's
254
- // large WASM grammars never hit the turboshaft Zone OOM (`Fatal process out of
255
- // memory: Zone`) on Node >= 22. No-op under the bundled launcher, which already
256
- // passes the flag. Must run before any grammar (in the parse worker, which
257
- // inherits this process's flags) is compiled. See ../extraction/wasm-runtime-flags.
258
- (0, wasm_runtime_flags_1.relaunchWithWasmRuntimeFlagsIfNeeded)(__filename);
259
- // Check if running with no arguments - run installer
260
- if (process.argv.length === 2) {
261
- Promise.resolve().then(() => __importStar(require('../installer'))).then(({ runInstaller }) => runInstaller()).catch((err) => {
262
- console.error('Installation failed:', err instanceof Error ? err.message : String(err));
263
- process.exit(1);
264
- });
265
- }
266
- else {
267
- // Normal CLI flow
268
- main();
269
- }
270
- process.on('uncaughtException', (error) => {
271
- console.error('[SpecShip] Uncaught exception:', error);
272
- });
273
- process.on('unhandledRejection', (reason) => {
274
- console.error('[SpecShip] Unhandled rejection:', reason);
275
- });
276
- function main() {
277
- const program = new commander_1.Command();
278
- // Version from package.json
279
- const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'package.json'), 'utf-8'));
280
- // =============================================================================
281
- // ANSI Color Helpers (avoid chalk ESM issues)
282
- // =============================================================================
283
- const colors = {
284
- reset: '\x1b[0m',
285
- bold: '\x1b[1m',
286
- dim: '\x1b[2m',
287
- red: '\x1b[31m',
288
- green: '\x1b[32m',
289
- yellow: '\x1b[33m',
290
- blue: '\x1b[34m',
291
- cyan: '\x1b[36m',
292
- white: '\x1b[37m',
293
- gray: '\x1b[90m',
294
- };
295
- const chalk = {
296
- bold: (s) => `${colors.bold}${s}${colors.reset}`,
297
- dim: (s) => `${colors.dim}${s}${colors.reset}`,
298
- red: (s) => `${colors.red}${s}${colors.reset}`,
299
- green: (s) => `${colors.green}${s}${colors.reset}`,
300
- yellow: (s) => `${colors.yellow}${s}${colors.reset}`,
301
- blue: (s) => `${colors.blue}${s}${colors.reset}`,
302
- cyan: (s) => `${colors.cyan}${s}${colors.reset}`,
303
- white: (s) => `${colors.white}${s}${colors.reset}`,
304
- gray: (s) => `${colors.gray}${s}${colors.reset}`,
305
- };
306
- program
307
- .name('specship')
308
- .description('Code intelligence and knowledge graph for any codebase')
309
- .version(packageJson.version);
310
- // =============================================================================
311
- // Helper Functions
312
- // =============================================================================
313
- /**
314
- * Resolve project path from argument or current directory
315
- * Walks up parent directories to find nearest initialized SpecShip project
316
- * (must have .specship/specship.db, not just .specship/lessons.db)
317
- */
318
- function resolveProjectPath(pathArg) {
319
- const absolutePath = path.resolve(pathArg || process.cwd());
320
- // If exact path is initialized (has specship.db), use it
321
- if ((0, directory_1.isInitialized)(absolutePath)) {
322
- return absolutePath;
323
- }
324
- // Walk up to find nearest parent with SpecShip initialized
325
- // Note: findNearestSpecShipRoot finds any .specship folder, but we need one with specship.db
326
- let current = absolutePath;
327
- const root = path.parse(current).root;
328
- while (current !== root) {
329
- const parent = path.dirname(current);
330
- if (parent === current)
331
- break;
332
- current = parent;
333
- if ((0, directory_1.isInitialized)(current)) {
334
- return current;
335
- }
336
- }
337
- // Not found - return original path (will fail later with helpful error)
338
- return absolutePath;
339
- }
340
- /**
341
- * Format a number with commas
342
- */
343
- function formatNumber(n) {
344
- return n.toLocaleString();
345
- }
346
- /**
347
- * Format duration in milliseconds to human readable
348
- */
349
- function formatDuration(ms) {
350
- if (ms < 1000) {
351
- return `${ms}ms`;
352
- }
353
- const seconds = ms / 1000;
354
- if (seconds < 60) {
355
- return `${seconds.toFixed(1)}s`;
356
- }
357
- const minutes = Math.floor(seconds / 60);
358
- const remainingSeconds = seconds % 60;
359
- return `${minutes}m ${remainingSeconds.toFixed(0)}s`;
360
- }
361
- // Shimmer progress renderer (runs in a worker thread for smooth animation)
362
- // Imported at top of file from '../ui/shimmer-progress'
363
- /**
364
- * Create a plain-text progress callback for --verbose mode.
365
- * No animations, no ANSI tricks — just timestamped lines to stdout.
366
- */
367
- function createVerboseProgress() {
368
- let lastPhase = '';
369
- let lastPct = -1;
370
- const startTime = Date.now();
371
- return (progress) => {
372
- const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
373
- if (progress.phase !== lastPhase) {
374
- lastPhase = progress.phase;
375
- lastPct = -1;
376
- console.log(`[${elapsed}s] Phase: ${progress.phase}`);
377
- }
378
- if (progress.total > 0) {
379
- const pct = Math.floor((progress.current / progress.total) * 100);
380
- // Log every 5% to keep output manageable
381
- if (pct >= lastPct + 5 || progress.current === progress.total) {
382
- lastPct = pct;
383
- console.log(`[${elapsed}s] ${progress.current}/${progress.total} (${pct}%)${progress.currentFile ? ` ${(0, glyphs_1.getGlyphs)().dash} ${progress.currentFile}` : ''}`);
384
- }
385
- }
386
- else if (progress.current > 0) {
387
- // Scanning phase (no total yet) — log periodically
388
- if (progress.current % 1000 === 0 || progress.current === 1) {
389
- console.log(`[${elapsed}s] ${formatNumber(progress.current)} files found`);
390
- }
391
- }
392
- };
393
- }
394
- /**
395
- * Print success message
396
- */
397
- function success(message) {
398
- console.log(chalk.green((0, glyphs_1.getGlyphs)().ok) + ' ' + message);
399
- }
400
- /**
401
- * Print error message
402
- */
403
- function error(message) {
404
- console.error(chalk.red((0, glyphs_1.getGlyphs)().err) + ' ' + message);
405
- }
406
- /**
407
- * Print info message
408
- */
409
- function info(message) {
410
- console.log(chalk.blue((0, glyphs_1.getGlyphs)().info) + ' ' + message);
411
- }
412
- /**
413
- * Print warning message
414
- */
415
- function warn(message) {
416
- console.log(chalk.yellow((0, glyphs_1.getGlyphs)().warn) + ' ' + message);
417
- }
418
- /**
419
- * Print indexing results using clack log methods
420
- */
421
- function printIndexResult(clack, result, projectPath) {
422
- const hasErrors = result.filesErrored > 0;
423
- // Surface non-file-level failures (e.g. lock-acquisition failure
424
- // when another indexer is running) before the file-count branches.
425
- // Without this the CLI falls through to "No files found to index",
426
- // which is actively misleading — the index DID run, it just couldn't
427
- // get the lock.
428
- //
429
- // If success is false but no severity:'error' entry exists in
430
- // `result.errors` (degenerate case — shouldn't happen in practice
431
- // but worth guarding because the result shape is plumbed through
432
- // multiple call sites), fall back to a generic message rather than
433
- // continuing to the misleading "No files found" branch or throwing.
434
- if (!result.success && !hasErrors && result.filesIndexed === 0) {
435
- const generic = result.errors.find((e) => e.severity === 'error');
436
- clack.log.error(generic?.message ?? `Indexing failed ${(0, glyphs_1.getGlyphs)().dash} no further details available`);
437
- return;
438
- }
439
- if (result.filesIndexed > 0) {
440
- if (hasErrors) {
441
- clack.log.success(`Indexed ${formatNumber(result.filesIndexed)} files (${formatNumber(result.filesErrored)} could not be parsed)`);
442
- }
443
- else {
444
- clack.log.success(`Indexed ${formatNumber(result.filesIndexed)} files`);
445
- }
446
- clack.log.info(`${formatNumber(result.nodesCreated)} nodes, ${formatNumber(result.edgesCreated)} edges in ${formatDuration(result.durationMs)}`);
447
- }
448
- else if (hasErrors) {
449
- clack.log.error(`Indexing failed ${(0, glyphs_1.getGlyphs)().dash} all ${formatNumber(result.filesErrored)} files had errors`);
450
- }
451
- else {
452
- clack.log.warn('No files found to index');
453
- }
454
- if (hasErrors) {
455
- const errorsByCode = new Map();
456
- for (const err of result.errors) {
457
- if (err.severity === 'error') {
458
- const code = err.code || 'unknown';
459
- errorsByCode.set(code, (errorsByCode.get(code) || 0) + 1);
460
- }
461
- }
462
- const codeLabels = {
463
- parse_error: 'files failed to parse',
464
- read_error: 'files could not be read',
465
- size_exceeded: 'files exceeded size limit',
466
- path_traversal: 'blocked paths',
467
- unsupported_language: 'unsupported language',
468
- parser_error: 'parser initialization failures',
469
- };
470
- const breakdown = Array.from(errorsByCode)
471
- .map(([code, count]) => `${formatNumber(count)} ${codeLabels[code] || code}`)
472
- .join('\n');
473
- clack.note(breakdown, 'Error breakdown');
474
- if (projectPath) {
475
- writeErrorLog(projectPath, result.errors);
476
- clack.log.info('See .specship/errors.log for details');
477
- }
478
- if (result.filesIndexed > 0) {
479
- clack.log.info(`The index is fully usable ${(0, glyphs_1.getGlyphs)().dash} only the failed files are missing.`);
480
- }
481
- }
482
- else if (projectPath) {
483
- const logPath = path.join(projectPath, '.specship', 'errors.log');
484
- if (fs.existsSync(logPath)) {
485
- fs.unlinkSync(logPath);
486
- }
487
- }
488
- }
489
- /**
490
- * Write detailed error log to .specship/errors.log
491
- */
492
- function writeErrorLog(projectPath, errors) {
493
- const cgDir = path.join(projectPath, '.specship');
494
- if (!fs.existsSync(cgDir))
495
- return;
496
- const logPath = path.join(cgDir, 'errors.log');
497
- // Group errors by file path
498
- const errorsByFile = new Map();
499
- const noFileErrors = [];
500
- for (const err of errors) {
501
- if (err.severity !== 'error')
502
- continue;
503
- if (err.filePath) {
504
- let list = errorsByFile.get(err.filePath);
505
- if (!list) {
506
- list = [];
507
- errorsByFile.set(err.filePath, list);
508
- }
509
- list.push({ message: err.message, code: err.code });
510
- }
511
- else {
512
- noFileErrors.push({ message: err.message, code: err.code });
513
- }
514
- }
515
- const lines = [
516
- `SpecShip Error Log - ${new Date().toISOString()}`,
517
- `${errorsByFile.size} files with errors`,
518
- '',
519
- ];
520
- for (const [filePath, fileErrors] of errorsByFile) {
521
- for (const err of fileErrors) {
522
- lines.push(`${filePath}: ${err.message}`);
523
- }
524
- }
525
- for (const err of noFileErrors) {
526
- lines.push(err.message);
527
- }
528
- fs.writeFileSync(logPath, lines.join('\n') + '\n');
529
- }
530
- // =============================================================================
531
- // Commands
532
- // =============================================================================
533
- /**
534
- * specship init [path]
535
- */
536
- program
537
- .command('init [path]')
538
- .description('Initialize SpecShip in a project directory and build the initial index')
539
- .option('-i, --index', 'Deprecated: indexing now runs by default; flag accepted for backward compatibility')
540
- .option('-v, --verbose', 'Show detailed worker lifecycle and memory info')
541
- .action(async (pathArg, options) => {
542
- const projectPath = path.resolve(pathArg || process.cwd());
543
- const clack = await importESM('@clack/prompts');
544
- clack.intro('Initializing SpecShip');
545
- try {
546
- if ((0, directory_1.isInitialized)(projectPath)) {
547
- clack.log.warn(`Already initialized in ${projectPath}`);
548
- clack.log.info('Use "specship index" to re-index or "specship sync" to update');
549
- try {
550
- const { offerWatchFallback } = await Promise.resolve().then(() => __importStar(require('../installer')));
551
- await offerWatchFallback(clack, projectPath);
552
- }
553
- catch { /* non-fatal */ }
554
- clack.outro('');
555
- return;
556
- }
557
- const { default: SpecShip } = await loadSpecShip();
558
- const cg = await SpecShip.init(projectPath, { index: false });
559
- clack.log.success(`Initialized in ${projectPath}`);
560
- // Indexing runs by default now. The legacy -i/--index flag is still
561
- // accepted (so existing muscle memory and scripts don't break) but is a
562
- // no-op — initializing always builds the initial index.
563
- let result;
564
- if (options.verbose) {
565
- result = await cg.indexAll({
566
- onProgress: createVerboseProgress(),
567
- verbose: true,
568
- });
569
- }
570
- else {
571
- process.stdout.write(`${colors.dim}${(0, glyphs_1.getGlyphs)().rail}${colors.reset}\n`);
572
- const progress = (0, shimmer_progress_1.createShimmerProgress)();
573
- result = await cg.indexAll({
574
- onProgress: progress.onProgress,
575
- });
576
- await progress.stop();
577
- }
578
- printIndexResult(clack, result, projectPath);
579
- try {
580
- const { offerWatchFallback } = await Promise.resolve().then(() => __importStar(require('../installer')));
581
- await offerWatchFallback(clack, projectPath);
582
- }
583
- catch { /* non-fatal */ }
584
- clack.outro('Done');
585
- cg.destroy();
586
- }
587
- catch (err) {
588
- clack.log.error(`Failed: ${err instanceof Error ? err.message : String(err)}`);
589
- process.exit(1);
590
- }
591
- });
592
- /**
593
- * specship uninit [path]
594
- */
595
- program
596
- .command('uninit [path]')
597
- .description('Remove SpecShip from a project (deletes .specship/ directory)')
598
- .option('-f, --force', 'Skip confirmation prompt')
599
- .action(async (pathArg, options) => {
600
- const projectPath = resolveProjectPath(pathArg);
601
- try {
602
- if (!(0, directory_1.isInitialized)(projectPath)) {
603
- warn(`SpecShip is not initialized in ${projectPath}`);
604
- return;
605
- }
606
- if (!options.force) {
607
- // Confirm with user
608
- const readline = await Promise.resolve().then(() => __importStar(require('readline')));
609
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
610
- const answer = await new Promise((resolve) => {
611
- rl.question(chalk.yellow(`${(0, glyphs_1.getGlyphs)().warn} This will permanently delete all SpecShip data. Continue? (y/N) `), resolve);
612
- });
613
- rl.close();
614
- if (answer.toLowerCase() !== 'y') {
615
- info('Cancelled');
616
- return;
617
- }
618
- }
619
- const { default: SpecShip } = await loadSpecShip();
620
- const cg = SpecShip.openSync(projectPath);
621
- cg.uninitialize();
622
- // Clean up any git sync hooks we installed (no-op if none / not a repo).
623
- try {
624
- const { removeGitSyncHook } = await Promise.resolve().then(() => __importStar(require('../sync/git-hooks')));
625
- const removed = removeGitSyncHook(projectPath);
626
- if (removed.installed.length > 0) {
627
- info(`Removed git ${removed.installed.join(', ')} sync hook${removed.installed.length > 1 ? 's' : ''}`);
628
- }
629
- }
630
- catch { /* non-fatal */ }
631
- success(`Removed SpecShip from ${projectPath}`);
632
- }
633
- catch (err) {
634
- error(`Failed to uninitialize: ${err instanceof Error ? err.message : String(err)}`);
635
- process.exit(1);
636
- }
637
- });
638
- /**
639
- * specship index [path]
640
- */
641
- program
642
- .command('index [path]')
643
- .description('Index all files in the project')
644
- .option('-f, --force', 'Force full re-index even if already indexed')
645
- .option('-q, --quiet', 'Suppress progress output')
646
- .option('-v, --verbose', 'Show detailed worker lifecycle and memory info')
647
- .action(async (pathArg, options) => {
648
- const projectPath = resolveProjectPath(pathArg);
649
- try {
650
- if (!(0, directory_1.isInitialized)(projectPath)) {
651
- error(`SpecShip not initialized in ${projectPath}`);
652
- info('Run "specship init" first');
653
- process.exit(1);
654
- }
655
- const { default: SpecShip } = await loadSpecShip();
656
- const cg = await SpecShip.open(projectPath);
657
- if (options.quiet) {
658
- // Quiet mode: no UI, just run
659
- if (options.force)
660
- cg.clear();
661
- const result = await cg.indexAll();
662
- if (!result.success)
663
- process.exit(1);
664
- cg.destroy();
665
- return;
666
- }
667
- const clack = await importESM('@clack/prompts');
668
- clack.intro('Indexing project');
669
- if (options.force) {
670
- cg.clear();
671
- clack.log.info('Cleared existing index');
672
- }
673
- let result;
674
- if (options.verbose) {
675
- result = await cg.indexAll({
676
- onProgress: createVerboseProgress(),
677
- verbose: true,
678
- });
679
- }
680
- else {
681
- process.stdout.write(`${colors.dim}${(0, glyphs_1.getGlyphs)().rail}${colors.reset}\n`);
682
- const progress = (0, shimmer_progress_1.createShimmerProgress)();
683
- result = await cg.indexAll({
684
- onProgress: progress.onProgress,
685
- });
686
- await progress.stop();
687
- }
688
- printIndexResult(clack, result, projectPath);
689
- if (!result.success) {
690
- process.exit(1);
691
- }
692
- clack.outro('Done');
693
- cg.destroy();
694
- }
695
- catch (err) {
696
- error(`Failed to index: ${err instanceof Error ? err.message : String(err)}`);
697
- process.exit(1);
698
- }
699
- });
700
- /**
701
- * specship sync [path]
702
- */
703
- program
704
- .command('sync [path]')
705
- .description('Sync changes since last index')
706
- .option('-q, --quiet', 'Suppress output (for git hooks)')
707
- .action(async (pathArg, options) => {
708
- const projectPath = resolveProjectPath(pathArg);
709
- try {
710
- if (!(0, directory_1.isInitialized)(projectPath)) {
711
- if (!options.quiet) {
712
- error(`SpecShip not initialized in ${projectPath}`);
713
- }
714
- process.exit(1);
715
- }
716
- const { default: SpecShip } = await loadSpecShip();
717
- const cg = await SpecShip.open(projectPath);
718
- if (options.quiet) {
719
- await cg.sync();
720
- cg.destroy();
721
- return;
722
- }
723
- const clack = await importESM('@clack/prompts');
724
- clack.intro('Syncing SpecShip');
725
- process.stdout.write(`${colors.dim}${(0, glyphs_1.getGlyphs)().rail}${colors.reset}\n`);
726
- const progress = (0, shimmer_progress_1.createShimmerProgress)();
727
- const result = await cg.sync({
728
- onProgress: progress.onProgress,
729
- });
730
- await progress.stop();
731
- const totalChanges = result.filesAdded + result.filesModified + result.filesRemoved;
732
- if (totalChanges === 0) {
733
- clack.log.info('Already up to date');
734
- }
735
- else {
736
- clack.log.success(`Synced ${formatNumber(totalChanges)} changed files`);
737
- const details = [];
738
- if (result.filesAdded > 0)
739
- details.push(`Added: ${result.filesAdded}`);
740
- if (result.filesModified > 0)
741
- details.push(`Modified: ${result.filesModified}`);
742
- if (result.filesRemoved > 0)
743
- details.push(`Removed: ${result.filesRemoved}`);
744
- clack.log.info(`${details.join(', ')} ${(0, glyphs_1.getGlyphs)().dash} ${formatNumber(result.nodesUpdated)} nodes in ${formatDuration(result.durationMs)}`);
745
- }
746
- clack.outro('Done');
747
- cg.destroy();
748
- }
749
- catch (err) {
750
- if (!options.quiet) {
751
- error(`Failed to sync: ${err instanceof Error ? err.message : String(err)}`);
752
- }
753
- process.exit(1);
754
- }
755
- });
756
- /**
757
- * specship status [path]
758
- */
759
- program
760
- .command('status [path]')
761
- .description('Show index status and statistics')
762
- .option('-j, --json', 'Output as JSON')
763
- .action(async (pathArg, options) => {
764
- const projectPath = resolveProjectPath(pathArg);
765
- // The directory the user actually ran from, before walking up to the index
766
- // root. Used to detect when the resolved index lives in a different git
767
- // working tree (e.g. a nested worktree borrowing the main checkout's index).
768
- const startPath = path.resolve(pathArg || process.cwd());
769
- const worktreeMismatch = (0, worktree_1.detectWorktreeIndexMismatch)(startPath, projectPath);
770
- try {
771
- if (!(0, directory_1.isInitialized)(projectPath)) {
772
- if (options.json) {
773
- console.log(JSON.stringify({
774
- initialized: false,
775
- version: packageJson.version,
776
- projectPath,
777
- indexPath: (0, directory_1.getSpecShipDir)(projectPath),
778
- lastIndexed: null,
779
- }));
780
- return;
781
- }
782
- console.log(chalk.bold('\nSpecShip Status\n'));
783
- info(`Project: ${projectPath}`);
784
- warn('Not initialized');
785
- info('Run "specship init" to initialize');
786
- return;
787
- }
788
- const { default: SpecShip } = await loadSpecShip();
789
- const cg = await SpecShip.open(projectPath);
790
- const stats = cg.getStats();
791
- const changes = cg.getChangedFiles();
792
- const backend = cg.getBackend();
793
- const journalMode = cg.getJournalMode();
794
- // JSON output mode
795
- if (options.json) {
796
- const lastIndexedMs = cg.getLastIndexedAt();
797
- console.log(JSON.stringify({
798
- initialized: true,
799
- version: packageJson.version,
800
- projectPath,
801
- indexPath: (0, directory_1.getSpecShipDir)(projectPath),
802
- lastIndexed: lastIndexedMs != null ? new Date(lastIndexedMs).toISOString() : null,
803
- fileCount: stats.fileCount,
804
- nodeCount: stats.nodeCount,
805
- edgeCount: stats.edgeCount,
806
- dbSizeBytes: stats.dbSizeBytes,
807
- backend,
808
- journalMode,
809
- nodesByKind: stats.nodesByKind,
810
- languages: Object.entries(stats.filesByLanguage).filter(([, count]) => count > 0).map(([lang]) => lang),
811
- pendingChanges: {
812
- added: changes.added.length,
813
- modified: changes.modified.length,
814
- removed: changes.removed.length,
815
- },
816
- worktreeMismatch: worktreeMismatch
817
- ? { worktreeRoot: worktreeMismatch.worktreeRoot, indexRoot: worktreeMismatch.indexRoot }
818
- : null,
819
- }));
820
- cg.destroy();
821
- return;
822
- }
823
- console.log(chalk.bold('\nSpecShip Status\n'));
824
- // Project info
825
- console.log(chalk.cyan('Project:'), projectPath);
826
- if (worktreeMismatch) {
827
- warn((0, worktree_1.worktreeMismatchWarning)(worktreeMismatch));
828
- }
829
- console.log();
830
- // Index stats
831
- console.log(chalk.bold('Index Statistics:'));
832
- console.log(` Files: ${formatNumber(stats.fileCount)}`);
833
- console.log(` Nodes: ${formatNumber(stats.nodeCount)}`);
834
- console.log(` Edges: ${formatNumber(stats.edgeCount)}`);
835
- console.log(` DB Size: ${(stats.dbSizeBytes / 1024 / 1024).toFixed(2)} MB`);
836
- // Surface the active SQLite backend. Two paths:
837
- // - 'node-sqlite' → Node's built-in module (production: bundled Node 24 has FTS5).
838
- // - 'better-sqlite3' → optional devDep that ships its own SQLite with FTS5.
839
- const backendLabel = backend === 'better-sqlite3'
840
- ? chalk.green(`better-sqlite3 ${(0, glyphs_1.getGlyphs)().dash} ships its own SQLite (FTS5)`)
841
- : chalk.green(`node:sqlite ${(0, glyphs_1.getGlyphs)().dash} built-in (full WAL)`);
842
- console.log(` Backend: ${backendLabel}`);
843
- // Effective journal mode: 'wal' means concurrent reads never block on a
844
- // writer; anything else means they can ("database is locked"). node:sqlite
845
- // supports WAL everywhere, so a non-wal mode means the filesystem can't
846
- // (network mounts, WSL2 /mnt). See issue #238.
847
- const journalLabel = journalMode === 'wal'
848
- ? chalk.green('wal')
849
- : chalk.yellow(`${journalMode || 'unknown'} ${(0, glyphs_1.getGlyphs)().dash} WAL inactive; reads can block on writes`);
850
- console.log(` Journal: ${journalLabel}`);
851
- console.log();
852
- // Node breakdown
853
- console.log(chalk.bold('Nodes by Kind:'));
854
- const nodesByKind = Object.entries(stats.nodesByKind)
855
- .filter(([, count]) => count > 0)
856
- .sort((a, b) => b[1] - a[1]);
857
- for (const [kind, count] of nodesByKind) {
858
- console.log(` ${kind.padEnd(15)} ${formatNumber(count)}`);
859
- }
860
- console.log();
861
- // Language breakdown
862
- console.log(chalk.bold('Files by Language:'));
863
- const filesByLang = Object.entries(stats.filesByLanguage)
864
- .filter(([, count]) => count > 0)
865
- .sort((a, b) => b[1] - a[1]);
866
- for (const [lang, count] of filesByLang) {
867
- console.log(` ${lang.padEnd(15)} ${formatNumber(count)}`);
868
- }
869
- console.log();
870
- // Pending changes
871
- const totalChanges = changes.added.length + changes.modified.length + changes.removed.length;
872
- if (totalChanges > 0) {
873
- console.log(chalk.bold('Pending Changes:'));
874
- if (changes.added.length > 0) {
875
- console.log(` Added: ${changes.added.length} files`);
876
- }
877
- if (changes.modified.length > 0) {
878
- console.log(` Modified: ${changes.modified.length} files`);
879
- }
880
- if (changes.removed.length > 0) {
881
- console.log(` Removed: ${changes.removed.length} files`);
882
- }
883
- info('Run "specship sync" to update the index');
884
- }
885
- else {
886
- success('Index is up to date');
887
- }
888
- console.log();
889
- cg.destroy();
890
- }
891
- catch (err) {
892
- error(`Failed to get status: ${err instanceof Error ? err.message : String(err)}`);
893
- process.exit(1);
894
- }
895
- });
896
- /**
897
- * specship query <search>
898
- */
899
- program
900
- .command('query <search>')
901
- .description('Search for symbols in the codebase')
902
- .option('-p, --path <path>', 'Project path')
903
- .option('-l, --limit <number>', 'Maximum results', '10')
904
- .option('-k, --kind <kind>', 'Filter by node kind (function, class, etc.)')
905
- .option('-j, --json', 'Output as JSON')
906
- .action(async (search, options) => {
907
- const projectPath = resolveProjectPath(options.path);
908
- try {
909
- if (!(0, directory_1.isInitialized)(projectPath)) {
910
- error(`SpecShip not initialized in ${projectPath}`);
911
- process.exit(1);
912
- }
913
- const { default: SpecShip } = await loadSpecShip();
914
- const cg = await SpecShip.open(projectPath);
915
- const limit = parseInt(options.limit || '10', 10);
916
- const rawResults = cg.searchNodes(search, {
917
- limit,
918
- kinds: options.kind ? [options.kind] : undefined,
919
- });
920
- // Mirror the MCP search down-rank so the CLI also surfaces the
921
- // hand-written implementation before protobuf/gRPC scaffolding
922
- // when both share a name. See extraction/generated-detection.ts.
923
- const { isGeneratedFile } = await Promise.resolve().then(() => __importStar(require('../extraction/generated-detection')));
924
- const results = [...rawResults].sort((a, b) => {
925
- const aGen = isGeneratedFile(a.node.filePath) ? 1 : 0;
926
- const bGen = isGeneratedFile(b.node.filePath) ? 1 : 0;
927
- return aGen - bGen;
928
- });
929
- if (options.json) {
930
- console.log(JSON.stringify(results, null, 2));
931
- }
932
- else {
933
- if (results.length === 0) {
934
- info(`No results found for "${search}"`);
935
- }
936
- else {
937
- console.log(chalk.bold(`\nSearch Results for "${search}":\n`));
938
- for (const result of results) {
939
- const node = result.node;
940
- const location = `${node.filePath}:${node.startLine}`;
941
- const score = chalk.dim(`(${(result.score * 100).toFixed(0)}%)`);
942
- console.log(chalk.cyan(node.kind.padEnd(12)) +
943
- chalk.white(node.name) +
944
- ' ' + score);
945
- console.log(chalk.dim(` ${location}`));
946
- if (node.signature) {
947
- console.log(chalk.dim(` ${node.signature}`));
948
- }
949
- console.log();
950
- }
951
- }
952
- }
953
- cg.destroy();
954
- }
955
- catch (err) {
956
- error(`Search failed: ${err instanceof Error ? err.message : String(err)}`);
957
- process.exit(1);
958
- }
959
- });
960
- /**
961
- * specship files [path]
962
- */
963
- program
964
- .command('files')
965
- .description('Show project file structure from the index')
966
- .option('-p, --path <path>', 'Project path')
967
- .option('--filter <dir>', 'Filter to files under this directory')
968
- .option('--pattern <glob>', 'Filter files matching this glob pattern')
969
- .option('--format <format>', 'Output format (tree, flat, grouped)', 'tree')
970
- .option('--max-depth <number>', 'Maximum directory depth for tree format')
971
- .option('--no-metadata', 'Hide file metadata (language, symbol count)')
972
- .option('-j, --json', 'Output as JSON')
973
- .action(async (options) => {
974
- const projectPath = resolveProjectPath(options.path);
975
- try {
976
- if (!(0, directory_1.isInitialized)(projectPath)) {
977
- error(`SpecShip not initialized in ${projectPath}`);
978
- process.exit(1);
979
- }
980
- const { default: SpecShip } = await loadSpecShip();
981
- const cg = await SpecShip.open(projectPath);
982
- let files = cg.getFiles();
983
- if (files.length === 0) {
984
- info('No files indexed. Run "specship index" first.');
985
- cg.destroy();
986
- return;
987
- }
988
- // Filter by path prefix
989
- if (options.filter) {
990
- const filter = options.filter;
991
- files = files.filter(f => f.path.startsWith(filter) || f.path.startsWith('./' + filter));
992
- }
993
- // Filter by glob pattern
994
- if (options.pattern) {
995
- const regex = globToRegex(options.pattern);
996
- files = files.filter(f => regex.test(f.path));
997
- }
998
- if (files.length === 0) {
999
- info('No files found matching the criteria.');
1000
- cg.destroy();
1001
- return;
1002
- }
1003
- // JSON output
1004
- if (options.json) {
1005
- const output = files.map(f => ({
1006
- path: f.path,
1007
- language: f.language,
1008
- nodeCount: f.nodeCount,
1009
- size: f.size,
1010
- }));
1011
- console.log(JSON.stringify(output, null, 2));
1012
- cg.destroy();
1013
- return;
1014
- }
1015
- const includeMetadata = options.metadata !== false;
1016
- const format = options.format || 'tree';
1017
- const maxDepth = options.maxDepth ? parseInt(options.maxDepth, 10) : undefined;
1018
- // Format output
1019
- switch (format) {
1020
- case 'flat':
1021
- console.log(chalk.bold(`\nFiles (${files.length}):\n`));
1022
- for (const file of files.sort((a, b) => a.path.localeCompare(b.path))) {
1023
- if (includeMetadata) {
1024
- console.log(` ${file.path} ${chalk.dim(`(${file.language}, ${file.nodeCount} symbols)`)}`);
1025
- }
1026
- else {
1027
- console.log(` ${file.path}`);
1028
- }
1029
- }
1030
- break;
1031
- case 'grouped':
1032
- console.log(chalk.bold(`\nFiles by Language (${files.length} total):\n`));
1033
- const byLang = new Map();
1034
- for (const file of files) {
1035
- const existing = byLang.get(file.language) || [];
1036
- existing.push(file);
1037
- byLang.set(file.language, existing);
1038
- }
1039
- const sortedLangs = [...byLang.entries()].sort((a, b) => b[1].length - a[1].length);
1040
- for (const [lang, langFiles] of sortedLangs) {
1041
- console.log(chalk.cyan(`${lang} (${langFiles.length}):`));
1042
- for (const file of langFiles.sort((a, b) => a.path.localeCompare(b.path))) {
1043
- if (includeMetadata) {
1044
- console.log(` ${file.path} ${chalk.dim(`(${file.nodeCount} symbols)`)}`);
1045
- }
1046
- else {
1047
- console.log(` ${file.path}`);
1048
- }
1049
- }
1050
- console.log();
1051
- }
1052
- break;
1053
- case 'tree':
1054
- default:
1055
- console.log(chalk.bold(`\nProject Structure (${files.length} files):\n`));
1056
- printFileTree(files, includeMetadata, maxDepth, chalk);
1057
- break;
1058
- }
1059
- console.log();
1060
- cg.destroy();
1061
- }
1062
- catch (err) {
1063
- error(`Failed to list files: ${err instanceof Error ? err.message : String(err)}`);
1064
- process.exit(1);
1065
- }
1066
- });
1067
- /**
1068
- * Convert glob pattern to regex
1069
- */
1070
- function globToRegex(pattern) {
1071
- const escaped = pattern
1072
- .replace(/[.+^${}()|[\]\\]/g, '\\$&')
1073
- .replace(/\*\*/g, '{{GLOBSTAR}}')
1074
- .replace(/\*/g, '[^/]*')
1075
- .replace(/\?/g, '[^/]')
1076
- .replace(/\{\{GLOBSTAR\}\}/g, '.*');
1077
- return new RegExp(escaped);
1078
- }
1079
- /**
1080
- * Print files as a tree
1081
- */
1082
- function printFileTree(files, includeMetadata, maxDepth, chalk) {
1083
- const root = { name: '', children: new Map() };
1084
- for (const file of files) {
1085
- const parts = file.path.split('/');
1086
- let current = root;
1087
- for (let i = 0; i < parts.length; i++) {
1088
- const part = parts[i];
1089
- if (!part)
1090
- continue;
1091
- if (!current.children.has(part)) {
1092
- current.children.set(part, { name: part, children: new Map() });
1093
- }
1094
- current = current.children.get(part);
1095
- if (i === parts.length - 1) {
1096
- current.file = { language: file.language, nodeCount: file.nodeCount };
1097
- }
1098
- }
1099
- }
1100
- const renderNode = (node, prefix, isLast, depth) => {
1101
- if (maxDepth !== undefined && depth > maxDepth)
1102
- return;
1103
- const glyphs = (0, glyphs_1.getGlyphs)();
1104
- const connector = isLast ? glyphs.treeLast : glyphs.treeBranch;
1105
- const childPrefix = isLast ? ' ' : glyphs.treePipe;
1106
- if (node.name) {
1107
- let line = prefix + connector + node.name;
1108
- if (node.file && includeMetadata) {
1109
- line += chalk.dim(` (${node.file.language}, ${node.file.nodeCount} symbols)`);
1110
- }
1111
- console.log(line);
1112
- }
1113
- const children = [...node.children.values()];
1114
- children.sort((a, b) => {
1115
- const aIsDir = a.children.size > 0 && !a.file;
1116
- const bIsDir = b.children.size > 0 && !b.file;
1117
- if (aIsDir !== bIsDir)
1118
- return aIsDir ? -1 : 1;
1119
- return a.name.localeCompare(b.name);
1120
- });
1121
- for (let i = 0; i < children.length; i++) {
1122
- const child = children[i];
1123
- const nextPrefix = node.name ? prefix + childPrefix : prefix;
1124
- renderNode(child, nextPrefix, i === children.length - 1, depth + 1);
1125
- }
1126
- };
1127
- renderNode(root, '', true, 0);
1128
- }
1129
- /**
1130
- * specship serve
1131
- */
1132
- program
1133
- .command('serve')
1134
- .description('Start SpecShip as an MCP server for AI assistants, an HTTP API for the desktop UI, or both')
1135
- .option('-p, --path <path>', 'Project path (optional for MCP mode, uses rootUri from client)')
1136
- .option('--mcp', 'Run as MCP server (stdio transport)')
1137
- .option('--ui', 'Run as HTTP API server for the SpecShip Desktop UI (binds 127.0.0.1)')
1138
- .option('--port <n>', 'HTTP port when --ui is set (default 4242)')
1139
- .option('--host <h>', 'HTTP bind host when --ui is set (default 127.0.0.1)')
1140
- .option('--ingest', 'Enable Claude Code JSONL transcript watcher (only when --ui is set)')
1141
- .option('--web-dir <path>', 'Path to a built Angular UI (index.html lives here); auto-detected by default')
1142
- .option('--no-web', 'Run --ui headless (API only, no SPA)')
1143
- .option('--no-watch', 'Disable the file watcher (no auto-sync; useful on slow filesystems like WSL2 /mnt drives)')
1144
- .action(async (options) => {
1145
- const projectPath = options.path ? resolveProjectPath(options.path) : undefined;
1146
- // Commander sets watch=false when --no-watch is passed. Route it through
1147
- // the same env-var chokepoint the watcher and MCP server already honor.
1148
- if (options.watch === false) {
1149
- process.env.SPECSHIP_NO_WATCH = '1';
1150
- }
1151
- try {
1152
- if (options.ui) {
1153
- // HTTP API mode. Boots the specship server + optional JSONL
1154
- // ingest watcher. Optionally also starts MCP stdio in parallel.
1155
- //
1156
- // Project root resolution:
1157
- // 1. `-p <path>` if passed.
1158
- // 2. The current cwd if it has been `specship init`-ed.
1159
- // 3. Most-recently-touched initialized project under
1160
- // ~/.claude/projects/ — so a user who runs `specship serve --ui`
1161
- // from anywhere lands on the project they were last active in.
1162
- // 4. None — server boots projectless, the desktop picker prompts
1163
- // the user to choose one (analytics endpoints return 409 until
1164
- // a primary exists).
1165
- let root = null;
1166
- if (projectPath) {
1167
- root = projectPath;
1168
- if (!(0, directory_1.isInitialized)(root)) {
1169
- error(`SpecShip not initialized in ${root}. Run \`specship init -i\` first.`);
1170
- process.exit(1);
1171
- }
1172
- }
1173
- else if ((0, directory_1.isInitialized)(process.cwd())) {
1174
- root = process.cwd();
1175
- }
1176
- else {
1177
- root = await pickRecentInitializedProject();
1178
- }
1179
- const port = options.port ? parseInt(options.port, 10) : 4242;
1180
- const host = options.host ?? '127.0.0.1';
1181
- // Lazy-load the server package via dist path. The npm bin is
1182
- // packaged with the server already built under
1183
- // node_modules/@selvakumaresra/specship-server, OR (dev) the
1184
- // sibling packages/server/dist directory.
1185
- const { createServer } = await loadServerPackage();
1186
- // Locate the built Angular UI so the same port serves the SPA at /.
1187
- // `--no-web` opts out (Commander sets web=false then). Otherwise we
1188
- // try the explicit --web-dir, then auto-detect.
1189
- const webDir = options.web === false ? null : locateWebDir(options.webDir ?? null);
1190
- // The JSONL ingest watcher now starts in-process inside createServer
1191
- // when `ingest: true`. The server owns its lifecycle; CLI just toggles.
1192
- const handle = await createServer({
1193
- projectRoot: root ?? undefined,
1194
- host,
1195
- port,
1196
- ingest: options.ingest !== false,
1197
- webDir,
1198
- verbose: false,
1199
- });
1200
- console.error(chalk.bold('\nSpecShip Desktop server\n'));
1201
- console.error(chalk.green((0, glyphs_1.getGlyphs)().ok) + ` HTTP API: ${handle.url}`);
1202
- if (root) {
1203
- console.error(chalk.dim(` project: ${root}`));
1204
- }
1205
- else {
1206
- console.error(chalk.yellow((0, glyphs_1.getGlyphs)().warn) + ' no primary project — pick one in the desktop UI');
1207
- console.error(chalk.dim(' analytics endpoints will return 409 until one is selected'));
1208
- }
1209
- if (webDir) {
1210
- console.error(chalk.green((0, glyphs_1.getGlyphs)().ok) + ` SPA: ${handle.url}/ (from ${webDir})`);
1211
- }
1212
- else if (options.web !== false) {
1213
- console.error(chalk.yellow((0, glyphs_1.getGlyphs)().warn) + ' UI not found — running API-only.');
1214
- console.error(chalk.dim(' Build it first: cd packages/server && npm run build:all'));
1215
- }
1216
- if (options.ingest !== false) {
1217
- console.error(chalk.dim(' Claude Code transcript ingest watcher active'));
1218
- }
1219
- if (options.mcp) {
1220
- if (!root) {
1221
- console.error(chalk.yellow((0, glyphs_1.getGlyphs)().warn) + ' --mcp needs an initialized project — skipping MCP stdio');
1222
- }
1223
- else {
1224
- // Also start MCP stdio in this process. The two are unrelated
1225
- // surfaces hitting the same specship instance, both safe under WAL.
1226
- const { MCPServer } = await Promise.resolve().then(() => __importStar(require('../mcp/index')));
1227
- const mcp = new MCPServer(root);
1228
- void mcp.start();
1229
- console.error(chalk.green((0, glyphs_1.getGlyphs)().ok) + ' MCP stdio: running');
1230
- }
1231
- }
1232
- const shutdown = async () => {
1233
- console.error(chalk.dim('shutting down…'));
1234
- await handle.stop();
1235
- process.exit(0);
1236
- };
1237
- process.on('SIGINT', () => { void shutdown(); });
1238
- process.on('SIGTERM', () => { void shutdown(); });
1239
- // Server now runs until terminated.
1240
- return;
1241
- }
1242
- if (options.mcp) {
1243
- // Start MCP server - it handles initialization lazily based on rootUri from client
1244
- const { MCPServer } = await Promise.resolve().then(() => __importStar(require('../mcp/index')));
1245
- const server = new MCPServer(projectPath);
1246
- await server.start();
1247
- // Server will run until terminated
1248
- }
1249
- else {
1250
- // Default: show info about MCP mode.
1251
- // Use stderr so stdout stays clean for any piped/stdio usage.
1252
- console.error(chalk.bold('\nSpecShip MCP Server\n'));
1253
- console.error(chalk.blue((0, glyphs_1.getGlyphs)().info) + ' Use --mcp flag to start the MCP server');
1254
- console.error('\nTo use with Claude Code, add to your MCP configuration:');
1255
- console.error(chalk.dim(`
1256
- {
1257
- "mcpServers": {
1258
- "specship": {
1259
- "command": "specship",
1260
- "args": ["serve", "--mcp"]
1261
- }
1262
- }
1263
- }
1264
- `));
1265
- console.error('Available tools:');
1266
- console.error(chalk.cyan(' specship_explore') + ' - Primary: source of the relevant symbols for any question');
1267
- console.error(chalk.cyan(' specship_search') + ' - Search for code symbols');
1268
- console.error(chalk.cyan(' specship_callers') + ' - Find callers of a symbol');
1269
- console.error(chalk.cyan(' specship_callees') + ' - Find what a symbol calls');
1270
- console.error(chalk.cyan(' specship_impact') + ' - Analyze impact of changes');
1271
- console.error(chalk.cyan(' specship_node') + ' - Get symbol details');
1272
- console.error(chalk.cyan(' specship_files') + ' - Get project file structure');
1273
- console.error(chalk.cyan(' specship_status') + ' - Get index status');
1274
- }
1275
- }
1276
- catch (err) {
1277
- error(`Failed to start server: ${err instanceof Error ? err.message : String(err)}`);
1278
- process.exit(1);
1279
- }
1280
- });
1281
- /**
1282
- * specship unlock [path]
1283
- */
1284
- program
1285
- .command('unlock [path]')
1286
- .description('Remove a stale lock file that is blocking indexing')
1287
- .action(async (pathArg) => {
1288
- const projectPath = resolveProjectPath(pathArg);
1289
- try {
1290
- if (!(0, directory_1.isInitialized)(projectPath)) {
1291
- error(`SpecShip not initialized in ${projectPath}`);
1292
- return;
1293
- }
1294
- const lockPath = path.join((0, directory_1.getSpecShipDir)(projectPath), 'specship.lock');
1295
- if (!fs.existsSync(lockPath)) {
1296
- info(`No lock file found ${(0, glyphs_1.getGlyphs)().dash} nothing to do`);
1297
- return;
1298
- }
1299
- fs.unlinkSync(lockPath);
1300
- success('Removed lock file. You can now run indexing again.');
1301
- }
1302
- catch (err) {
1303
- error(`Failed to remove lock: ${err instanceof Error ? err.message : String(err)}`);
1304
- process.exit(1);
1305
- }
1306
- });
1307
- /**
1308
- * specship callers <symbol>
1309
- *
1310
- * CLI parity with the MCP graph tools (specship_callers/callees/impact) so the
1311
- * traversal queries work in scripts, CI, and git hooks without a running MCP
1312
- * server.
1313
- */
1314
- program
1315
- .command('callers <symbol>')
1316
- .description('Find all functions/methods that call a specific symbol')
1317
- .option('-p, --path <path>', 'Project path')
1318
- .option('-l, --limit <number>', 'Maximum results', '20')
1319
- .option('-j, --json', 'Output as JSON')
1320
- .action(async (symbol, options) => {
1321
- const projectPath = resolveProjectPath(options.path);
1322
- try {
1323
- if (!(0, directory_1.isInitialized)(projectPath)) {
1324
- error(`SpecShip not initialized in ${projectPath}`);
1325
- process.exit(1);
1326
- }
1327
- const { default: SpecShip } = await loadSpecShip();
1328
- const cg = await SpecShip.open(projectPath);
1329
- const limit = parseInt(options.limit || '20', 10);
1330
- const matches = cg.searchNodes(symbol, { limit: 50 });
1331
- if (matches.length === 0) {
1332
- info(`Symbol "${symbol}" not found`);
1333
- cg.destroy();
1334
- return;
1335
- }
1336
- const seen = new Set();
1337
- const allCallers = [];
1338
- for (const match of matches) {
1339
- const exactMatch = match.node.name === symbol || match.node.name.endsWith(`.${symbol}`) || match.node.name.endsWith(`::${symbol}`);
1340
- if (!exactMatch && matches.length > 1)
1341
- continue;
1342
- for (const c of cg.getCallers(match.node.id)) {
1343
- if (!seen.has(c.node.id)) {
1344
- seen.add(c.node.id);
1345
- allCallers.push({ name: c.node.name, kind: c.node.kind, filePath: c.node.filePath, startLine: c.node.startLine });
1346
- }
1347
- }
1348
- }
1349
- // Fallback: if exact filter removed everything, use the top match
1350
- if (allCallers.length === 0 && matches[0]) {
1351
- for (const c of cg.getCallers(matches[0].node.id)) {
1352
- if (!seen.has(c.node.id)) {
1353
- seen.add(c.node.id);
1354
- allCallers.push({ name: c.node.name, kind: c.node.kind, filePath: c.node.filePath, startLine: c.node.startLine });
1355
- }
1356
- }
1357
- }
1358
- const limited = allCallers.slice(0, limit);
1359
- if (options.json) {
1360
- console.log(JSON.stringify({ symbol, callers: limited }, null, 2));
1361
- }
1362
- else if (limited.length === 0) {
1363
- info(`No callers found for "${symbol}"`);
1364
- }
1365
- else {
1366
- console.log(chalk.bold(`\nCallers of "${symbol}" (${limited.length}):\n`));
1367
- for (const node of limited) {
1368
- const loc = node.startLine ? `:${node.startLine}` : '';
1369
- console.log(chalk.cyan(node.kind.padEnd(12)) +
1370
- chalk.white(node.name));
1371
- console.log(chalk.dim(` ${node.filePath}${loc}`));
1372
- console.log();
1373
- }
1374
- }
1375
- cg.destroy();
1376
- }
1377
- catch (err) {
1378
- error(`callers failed: ${err instanceof Error ? err.message : String(err)}`);
1379
- process.exit(1);
1380
- }
1381
- });
1382
- /**
1383
- * specship callees <symbol>
1384
- */
1385
- program
1386
- .command('callees <symbol>')
1387
- .description('Find all functions/methods that a specific symbol calls')
1388
- .option('-p, --path <path>', 'Project path')
1389
- .option('-l, --limit <number>', 'Maximum results', '20')
1390
- .option('-j, --json', 'Output as JSON')
1391
- .action(async (symbol, options) => {
1392
- const projectPath = resolveProjectPath(options.path);
1393
- try {
1394
- if (!(0, directory_1.isInitialized)(projectPath)) {
1395
- error(`SpecShip not initialized in ${projectPath}`);
1396
- process.exit(1);
1397
- }
1398
- const { default: SpecShip } = await loadSpecShip();
1399
- const cg = await SpecShip.open(projectPath);
1400
- const limit = parseInt(options.limit || '20', 10);
1401
- const matches = cg.searchNodes(symbol, { limit: 50 });
1402
- if (matches.length === 0) {
1403
- info(`Symbol "${symbol}" not found`);
1404
- cg.destroy();
1405
- return;
1406
- }
1407
- const seen = new Set();
1408
- const allCallees = [];
1409
- for (const match of matches) {
1410
- const exactMatch = match.node.name === symbol || match.node.name.endsWith(`.${symbol}`) || match.node.name.endsWith(`::${symbol}`);
1411
- if (!exactMatch && matches.length > 1)
1412
- continue;
1413
- for (const c of cg.getCallees(match.node.id)) {
1414
- if (!seen.has(c.node.id)) {
1415
- seen.add(c.node.id);
1416
- allCallees.push({ name: c.node.name, kind: c.node.kind, filePath: c.node.filePath, startLine: c.node.startLine });
1417
- }
1418
- }
1419
- }
1420
- if (allCallees.length === 0 && matches[0]) {
1421
- for (const c of cg.getCallees(matches[0].node.id)) {
1422
- if (!seen.has(c.node.id)) {
1423
- seen.add(c.node.id);
1424
- allCallees.push({ name: c.node.name, kind: c.node.kind, filePath: c.node.filePath, startLine: c.node.startLine });
1425
- }
1426
- }
1427
- }
1428
- const limited = allCallees.slice(0, limit);
1429
- if (options.json) {
1430
- console.log(JSON.stringify({ symbol, callees: limited }, null, 2));
1431
- }
1432
- else if (limited.length === 0) {
1433
- info(`No callees found for "${symbol}"`);
1434
- }
1435
- else {
1436
- console.log(chalk.bold(`\nCallees of "${symbol}" (${limited.length}):\n`));
1437
- for (const node of limited) {
1438
- const loc = node.startLine ? `:${node.startLine}` : '';
1439
- console.log(chalk.cyan(node.kind.padEnd(12)) +
1440
- chalk.white(node.name));
1441
- console.log(chalk.dim(` ${node.filePath}${loc}`));
1442
- console.log();
1443
- }
1444
- }
1445
- cg.destroy();
1446
- }
1447
- catch (err) {
1448
- error(`callees failed: ${err instanceof Error ? err.message : String(err)}`);
1449
- process.exit(1);
1450
- }
1451
- });
1452
- /**
1453
- * specship impact <symbol>
1454
- */
1455
- program
1456
- .command('impact <symbol>')
1457
- .description('Analyze what code is affected by changing a symbol')
1458
- .option('-p, --path <path>', 'Project path')
1459
- .option('-d, --depth <number>', 'Traversal depth', '2')
1460
- .option('-j, --json', 'Output as JSON')
1461
- .action(async (symbol, options) => {
1462
- const projectPath = resolveProjectPath(options.path);
1463
- try {
1464
- if (!(0, directory_1.isInitialized)(projectPath)) {
1465
- error(`SpecShip not initialized in ${projectPath}`);
1466
- process.exit(1);
1467
- }
1468
- const { default: SpecShip } = await loadSpecShip();
1469
- const cg = await SpecShip.open(projectPath);
1470
- const depth = Math.min(Math.max(parseInt(options.depth || '2', 10), 1), 10);
1471
- const matches = cg.searchNodes(symbol, { limit: 50 });
1472
- if (matches.length === 0) {
1473
- info(`Symbol "${symbol}" not found`);
1474
- cg.destroy();
1475
- return;
1476
- }
1477
- // Merge impact subgraphs across all exact-matching symbols
1478
- const mergedNodes = new Map();
1479
- const seenEdges = new Set();
1480
- let edgeCount = 0;
1481
- for (const match of matches) {
1482
- const exactMatch = match.node.name === symbol || match.node.name.endsWith(`.${symbol}`) || match.node.name.endsWith(`::${symbol}`);
1483
- if (!exactMatch && matches.length > 1)
1484
- continue;
1485
- const impact = cg.getImpactRadius(match.node.id, depth);
1486
- for (const [id, n] of impact.nodes) {
1487
- mergedNodes.set(id, { name: n.name, kind: n.kind, filePath: n.filePath, startLine: n.startLine });
1488
- }
1489
- for (const e of impact.edges) {
1490
- const key = `${e.source}->${e.target}:${e.kind}`;
1491
- if (!seenEdges.has(key)) {
1492
- seenEdges.add(key);
1493
- edgeCount++;
1494
- }
1495
- }
1496
- }
1497
- // Fallback to top match if exact filter removed everything
1498
- if (mergedNodes.size === 0 && matches[0]) {
1499
- const impact = cg.getImpactRadius(matches[0].node.id, depth);
1500
- for (const [id, n] of impact.nodes) {
1501
- mergedNodes.set(id, { name: n.name, kind: n.kind, filePath: n.filePath, startLine: n.startLine });
1502
- }
1503
- edgeCount = impact.edges.length;
1504
- }
1505
- if (options.json) {
1506
- console.log(JSON.stringify({
1507
- symbol,
1508
- depth,
1509
- nodeCount: mergedNodes.size,
1510
- edgeCount,
1511
- affected: Array.from(mergedNodes.values()),
1512
- }, null, 2));
1513
- }
1514
- else if (mergedNodes.size === 0) {
1515
- info(`No affected symbols found for "${symbol}"`);
1516
- }
1517
- else {
1518
- console.log(chalk.bold(`\nImpact of changing "${symbol}" — ${mergedNodes.size} affected symbols:\n`));
1519
- // Group by file
1520
- const byFile = new Map();
1521
- for (const node of mergedNodes.values()) {
1522
- const list = byFile.get(node.filePath) || [];
1523
- list.push({ name: node.name, kind: node.kind, startLine: node.startLine });
1524
- byFile.set(node.filePath, list);
1525
- }
1526
- for (const [file, nodes] of byFile) {
1527
- console.log(chalk.cyan(file));
1528
- for (const node of nodes) {
1529
- const loc = node.startLine ? `:${node.startLine}` : '';
1530
- console.log(` ${chalk.dim(node.kind.padEnd(12))}${node.name}${chalk.dim(loc)}`);
1531
- }
1532
- console.log();
1533
- }
1534
- }
1535
- cg.destroy();
1536
- }
1537
- catch (err) {
1538
- error(`impact failed: ${err instanceof Error ? err.message : String(err)}`);
1539
- process.exit(1);
1540
- }
1541
- });
1542
- /**
1543
- * specship affected [files...]
1544
- *
1545
- * Find test files affected by the given source files.
1546
- * Traces dependency edges transitively to find test files that depend on changed code.
1547
- *
1548
- * Usage:
1549
- * git diff --name-only | specship affected --stdin
1550
- * specship affected src/lib/components/Editor.svelte src/routes/+page.svelte
1551
- */
1552
- program
1553
- .command('affected [files...]')
1554
- .description('Find test files affected by changed source files')
1555
- .option('-p, --path <path>', 'Project path')
1556
- .option('--stdin', 'Read file list from stdin (one per line)')
1557
- .option('-d, --depth <number>', 'Max dependency traversal depth', '5')
1558
- .option('-f, --filter <glob>', 'Custom glob filter for test files (e.g. "e2e/*.spec.ts")')
1559
- .option('-j, --json', 'Output as JSON')
1560
- .option('-q, --quiet', 'Only output file paths, no decoration')
1561
- .action(async (fileArgs, options) => {
1562
- const projectPath = resolveProjectPath(options.path);
1563
- try {
1564
- if (!(0, directory_1.isInitialized)(projectPath)) {
1565
- error(`SpecShip not initialized in ${projectPath}`);
1566
- process.exit(1);
1567
- }
1568
- // Collect changed files from args or stdin
1569
- let changedFiles = [...(fileArgs || [])];
1570
- if (options.stdin) {
1571
- const stdinData = fs.readFileSync(0, 'utf-8');
1572
- const stdinFiles = stdinData.split('\n').map(f => f.trim()).filter(Boolean);
1573
- changedFiles.push(...stdinFiles);
1574
- }
1575
- if (changedFiles.length === 0) {
1576
- if (!options.quiet)
1577
- info('No files provided. Use file arguments or --stdin.');
1578
- process.exit(0);
1579
- }
1580
- const { default: SpecShip } = await loadSpecShip();
1581
- const cg = await SpecShip.open(projectPath);
1582
- const maxDepth = parseInt(options.depth || '5', 10);
1583
- // Common test file patterns
1584
- const defaultTestPatterns = [
1585
- /\.spec\./,
1586
- /\.test\./,
1587
- /\/__tests__\//,
1588
- /\/tests?\//,
1589
- /\/e2e\//,
1590
- /\/spec\//,
1591
- ];
1592
- // Custom filter pattern
1593
- let customFilter = null;
1594
- if (options.filter) {
1595
- // Convert glob to regex: ** → .+, * → [^/]*, . → \.
1596
- const regex = options.filter
1597
- .replace(/[+[\]{}()^$|\\]/g, '\\$&')
1598
- .replace(/\./g, '\\.')
1599
- .replace(/\*\*/g, '.+')
1600
- .replace(/\*/g, '[^/]*');
1601
- customFilter = new RegExp(regex);
1602
- }
1603
- function isTestFile(filePath) {
1604
- if (customFilter)
1605
- return customFilter.test(filePath);
1606
- return defaultTestPatterns.some(p => p.test(filePath));
1607
- }
1608
- // BFS to find all transitive dependents of changed files, filtered to test files
1609
- const affectedTests = new Set();
1610
- const allDependents = new Set();
1611
- for (const file of changedFiles) {
1612
- // If the changed file is itself a test file, include it
1613
- if (isTestFile(file)) {
1614
- affectedTests.add(file);
1615
- continue;
1616
- }
1617
- // BFS through dependents
1618
- const queue = [{ file, depth: 0 }];
1619
- const visited = new Set();
1620
- visited.add(file);
1621
- while (queue.length > 0) {
1622
- const current = queue.shift();
1623
- if (current.depth >= maxDepth)
1624
- continue;
1625
- const dependents = cg.getFileDependents(current.file);
1626
- for (const dep of dependents) {
1627
- if (visited.has(dep))
1628
- continue;
1629
- visited.add(dep);
1630
- allDependents.add(dep);
1631
- if (isTestFile(dep)) {
1632
- affectedTests.add(dep);
1633
- }
1634
- else {
1635
- queue.push({ file: dep, depth: current.depth + 1 });
1636
- }
1637
- }
1638
- }
1639
- }
1640
- const sortedTests = Array.from(affectedTests).sort();
1641
- // Output
1642
- if (options.json) {
1643
- console.log(JSON.stringify({
1644
- changedFiles,
1645
- affectedTests: sortedTests,
1646
- totalDependentsTraversed: allDependents.size,
1647
- }, null, 2));
1648
- }
1649
- else if (options.quiet) {
1650
- for (const t of sortedTests)
1651
- console.log(t);
1652
- }
1653
- else {
1654
- if (sortedTests.length === 0) {
1655
- info('No test files affected by the changed files.');
1656
- }
1657
- else {
1658
- console.log(chalk.bold(`\nAffected test files (${sortedTests.length}):\n`));
1659
- for (const t of sortedTests) {
1660
- console.log(' ' + chalk.cyan(t));
1661
- }
1662
- console.log();
1663
- }
1664
- }
1665
- cg.destroy();
1666
- }
1667
- catch (err) {
1668
- error(`Affected analysis failed: ${err instanceof Error ? err.message : String(err)}`);
1669
- process.exit(1);
1670
- }
1671
- });
1672
- /**
1673
- * specship install
1674
- */
1675
- program
1676
- .command('install')
1677
- .description('Install specship MCP server into Claude Code')
1678
- .option('-l, --location <where>', 'Install location: "global" or "local". Default: prompt')
1679
- .option('-y, --yes', 'Non-interactive: defaults to --location=global, auto-allow on')
1680
- .option('--no-permissions', 'Skip writing the auto-allow permissions list')
1681
- .option('--print-config', 'Print MCP config snippet for Claude Code and exit (no file writes)')
1682
- // -t/--target is vestigial — kept so existing `--target claude` / `--target auto`
1683
- // invocations (including our own offline-install scripts) keep working.
1684
- .option('-t, --target <ids>', '(vestigial) accepted: "claude" | "auto" | "all" | "none"')
1685
- .action(async (opts) => {
1686
- if (opts.printConfig) {
1687
- const { claudeTarget } = await Promise.resolve().then(() => __importStar(require('../installer/targets/claude')));
1688
- const loc = (opts.location === 'local' ? 'local' : 'global');
1689
- process.stdout.write(claudeTarget.printConfig(loc));
1690
- return;
1691
- }
1692
- const { runInstallerWithOptions } = await Promise.resolve().then(() => __importStar(require('../installer')));
1693
- if (opts.location && opts.location !== 'global' && opts.location !== 'local') {
1694
- error(`--location must be "global" or "local" (got "${opts.location}").`);
1695
- process.exit(1);
1696
- }
1697
- try {
1698
- // Commander's `--no-permissions` makes `opts.permissions === false`;
1699
- // omitting the flag leaves it `true` (the positive-form default).
1700
- // We MUST treat the default-true as "user did not override — let
1701
- // the orchestrator prompt" and only forward an explicit `false`
1702
- // (or `true` when --yes implies it). Otherwise the auto-allow
1703
- // prompt is silently skipped on every interactive run.
1704
- const explicitNoPermissions = opts.permissions === false;
1705
- const autoAllow = explicitNoPermissions
1706
- ? false
1707
- : opts.yes
1708
- ? true
1709
- : undefined;
1710
- await runInstallerWithOptions({
1711
- target: opts.target,
1712
- location: opts.location,
1713
- autoAllow,
1714
- yes: opts.yes,
1715
- });
1716
- }
1717
- catch (err) {
1718
- error(err instanceof Error ? err.message : String(err));
1719
- process.exit(1);
1720
- }
1721
- });
1722
- /**
1723
- * specship uninstall
1724
- *
1725
- * Inverse of `install`. Removes the specship MCP server entry and
1726
- * permissions from Claude Code. Prompts global-vs-local when not
1727
- * given. Does NOT delete the `.specship/` index — that's
1728
- * `specship uninit`.
1729
- */
1730
- program
1731
- .command('uninstall')
1732
- .description('Remove specship from Claude Code')
1733
- .option('-l, --location <where>', 'Uninstall location: "global" or "local". Default: prompt')
1734
- .option('-y, --yes', 'Non-interactive: defaults to --location=global')
1735
- // vestigial — kept so existing `--target claude` invocations keep working.
1736
- .option('-t, --target <ids>', '(vestigial) accepted: "claude" | "auto" | "all" | "none"')
1737
- .action(async (opts) => {
1738
- const { runUninstaller } = await Promise.resolve().then(() => __importStar(require('../installer')));
1739
- if (opts.location && opts.location !== 'global' && opts.location !== 'local') {
1740
- error(`--location must be "global" or "local" (got "${opts.location}").`);
1741
- process.exit(1);
1742
- }
1743
- try {
1744
- await runUninstaller({
1745
- target: opts.target,
1746
- location: opts.location,
1747
- yes: opts.yes,
1748
- });
1749
- }
1750
- catch (err) {
1751
- error(err instanceof Error ? err.message : String(err));
1752
- process.exit(1);
1753
- }
1754
- });
1755
- // =============================================================================
1756
- // Spec layer / Workflow engine commands (v5)
1757
- // =============================================================================
1758
- program
1759
- .command('drifted [path]')
1760
- .description('List spec links in concerning states (drifted, broken, orphaned).')
1761
- .option('-s, --state <list>', 'comma-separated states (default: drifted,broken,orphaned)')
1762
- .option('-l, --limit <n>', 'max links to print (default: 50)')
1763
- .option('--fail-on <list>', 'comma-separated states that cause non-zero exit (CI gate)')
1764
- .option('--json', 'emit JSON')
1765
- .action(async (pathArg, options) => {
1766
- const projectRoot = path.resolve(pathArg ?? process.cwd());
1767
- if (!(0, directory_1.isInitialized)(projectRoot)) {
1768
- error(`SpecShip not initialized in ${projectRoot}. Run \`specship init -i\` first.`);
1769
- process.exit(1);
1770
- }
1771
- const { SpecShip } = await loadSpecShip();
1772
- const cg = await SpecShip.open(projectRoot);
1773
- try {
1774
- const states = (options.state ?? 'drifted,broken,orphaned')
1775
- .split(',')
1776
- .map((s) => s.trim())
1777
- .filter(Boolean);
1778
- const limit = options.limit ? Math.max(1, parseInt(options.limit, 10) || 50) : 50;
1779
- const links = cg.getSpecQueries().getLinksByState(states).slice(0, limit);
1780
- if (options.json) {
1781
- // eslint-disable-next-line no-console
1782
- console.log(JSON.stringify({ count: links.length, links }, null, 2));
1783
- }
1784
- else if (links.length === 0) {
1785
- // eslint-disable-next-line no-console
1786
- console.log(`No links in states: ${states.join(', ')}. ✨ Drift queue is clean.`);
1787
- }
1788
- else {
1789
- for (const link of links) {
1790
- const drift = link.driftAxis ? ` [drift=${link.driftAxis}]` : '';
1791
- // eslint-disable-next-line no-console
1792
- console.log(`#${link.id} [${link.state}${drift}] ${link.specId} → ${link.targetFilePath}:${link.targetQualifiedName} <${link.provenance}>`);
1793
- }
1794
- }
1795
- if (options.failOn) {
1796
- const failStates = options.failOn.split(',').map((s) => s.trim()).filter(Boolean);
1797
- const offending = links.filter((l) => failStates.includes(l.state));
1798
- if (offending.length > 0) {
1799
- process.exit(1);
1800
- }
1801
- }
1802
- }
1803
- finally {
1804
- cg.close();
1805
- }
1806
- });
1807
- program
1808
- .command('workflow <action> [arg]')
1809
- .description('Workflow engine: list | run <name> | resume <runId> | cancel <runId> | approve <runId> | reject <runId> | runs')
1810
- .option('-i, --input <kv...>', 'workflow inputs as KEY=VALUE (repeatable)')
1811
- .option('--path <projectRoot>', 'project root (default: cwd)')
1812
- .option('--comment <text>', 'comment for approve/reject')
1813
- .option('--reason <text>', 'reason for cancel/reject')
1814
- .option('--json', 'emit JSON where applicable')
1815
- .action(async (action, arg, options) => {
1816
- const projectRoot = path.resolve(options.path ?? process.cwd());
1817
- if (!(0, directory_1.isInitialized)(projectRoot)) {
1818
- error(`SpecShip not initialized in ${projectRoot}. Run \`specship init -i\` first.`);
1819
- process.exit(1);
1820
- }
1821
- const { SpecShip } = await loadSpecShip();
1822
- const { discoverWorkflows, loadWorkflowByName } = await Promise.resolve().then(() => __importStar(require('../workflows/discovery')));
1823
- const { WorkflowExecutor } = await Promise.resolve().then(() => __importStar(require('../workflows/executor')));
1824
- const { WorktreeProvider } = await Promise.resolve().then(() => __importStar(require('../isolation/worktree')));
1825
- const cg = await SpecShip.open(projectRoot);
1826
- try {
1827
- const specQueries = cg.getSpecQueries();
1828
- const worktrees = new WorktreeProvider(specQueries);
1829
- const executor = new WorkflowExecutor(specQueries, worktrees);
1830
- switch (action) {
1831
- case 'list': {
1832
- const result = discoverWorkflows(projectRoot);
1833
- if (options.json) {
1834
- // eslint-disable-next-line no-console
1835
- console.log(JSON.stringify({
1836
- workflows: result.workflows.map((w) => ({
1837
- name: w.workflow.name,
1838
- scope: w.scope,
1839
- sourcePath: w.sourcePath,
1840
- description: w.workflow.description,
1841
- nodes: w.workflow.nodes.length,
1842
- requires: w.workflow.requires,
1843
- })),
1844
- errors: result.errors,
1845
- }, null, 2));
1846
- }
1847
- else {
1848
- for (const w of result.workflows) {
1849
- // eslint-disable-next-line no-console
1850
- console.log(` [${w.scope}] ${w.workflow.name} (${w.workflow.nodes.length} nodes) — ${w.workflow.description ?? ''}`);
1851
- }
1852
- if (result.errors.length > 0) {
1853
- // eslint-disable-next-line no-console
1854
- console.error(`\n${result.errors.length} workflow file(s) had errors:`);
1855
- for (const e of result.errors) {
1856
- // eslint-disable-next-line no-console
1857
- console.error(` ${e.sourcePath}:`);
1858
- for (const er of e.errors) {
1859
- // eslint-disable-next-line no-console
1860
- console.error(` ${er.path}: ${er.message}`);
1861
- }
1862
- }
1863
- }
1864
- }
1865
- break;
1866
- }
1867
- case 'run': {
1868
- if (!arg) {
1869
- error('workflow run requires a workflow name');
1870
- process.exit(1);
1871
- }
1872
- const loaded = loadWorkflowByName(projectRoot, arg);
1873
- if (!loaded) {
1874
- error(`Workflow "${arg}" not found. Use \`specship workflow list\` to see available workflows.`);
1875
- process.exit(1);
1876
- }
1877
- const inputs = {};
1878
- for (const kv of options.input ?? []) {
1879
- const eqIdx = kv.indexOf('=');
1880
- if (eqIdx <= 0) {
1881
- error(`--input must be KEY=VALUE (got "${kv}")`);
1882
- process.exit(1);
1883
- }
1884
- inputs[kv.slice(0, eqIdx)] = kv.slice(eqIdx + 1);
1885
- }
1886
- // Check required inputs.
1887
- for (const inp of loaded.workflow.inputs ?? []) {
1888
- if (inp.required && !(inp.name in inputs)) {
1889
- error(`Required input missing: --input ${inp.name}=...`);
1890
- process.exit(1);
1891
- }
1892
- }
1893
- const result = await executor.start(loaded.workflow, {
1894
- projectRoot,
1895
- inputs,
1896
- variables: {
1897
- ARTIFACTS_DIR: path.join(projectRoot, '.specship', 'artifacts'),
1898
- CONTEXT: projectRoot,
1899
- },
1900
- });
1901
- if (options.json) {
1902
- // eslint-disable-next-line no-console
1903
- console.log(JSON.stringify({
1904
- runId: result.run.id,
1905
- status: result.run.status,
1906
- isolationEnvId: result.run.isolationEnvId,
1907
- nodeStates: Object.fromEntries(result.nodeStates),
1908
- }, null, 2));
1909
- }
1910
- else {
1911
- // eslint-disable-next-line no-console
1912
- console.log(`Run ${result.run.id} → ${result.run.status}`);
1913
- if (result.run.isolationEnvId) {
1914
- // eslint-disable-next-line no-console
1915
- console.log(`Worktree: ${result.run.isolationEnvId}`);
1916
- }
1917
- if (result.run.errorMessage) {
1918
- // eslint-disable-next-line no-console
1919
- console.log(`Error: ${result.run.errorMessage}`);
1920
- }
1921
- }
1922
- if (result.run.status === 'failed')
1923
- process.exit(1);
1924
- break;
1925
- }
1926
- case 'resume': {
1927
- if (!arg) {
1928
- error('workflow resume requires a runId');
1929
- process.exit(1);
1930
- }
1931
- const run = specQueries.getWorkflowRunById(arg);
1932
- if (!run) {
1933
- error(`Run ${arg} not found`);
1934
- process.exit(1);
1935
- }
1936
- const loaded = loadWorkflowByName(projectRoot, run.workflowName);
1937
- if (!loaded) {
1938
- error(`Workflow "${run.workflowName}" no longer exists`);
1939
- process.exit(1);
1940
- }
1941
- const result = await executor.resume(loaded.workflow, arg, {
1942
- projectRoot,
1943
- inputs: run.inputs,
1944
- variables: {
1945
- ARTIFACTS_DIR: path.join(projectRoot, '.specship', 'artifacts'),
1946
- CONTEXT: projectRoot,
1947
- },
1948
- });
1949
- // eslint-disable-next-line no-console
1950
- console.log(`Run ${result.run.id} → ${result.run.status}`);
1951
- if (result.run.status === 'failed')
1952
- process.exit(1);
1953
- break;
1954
- }
1955
- case 'cancel': {
1956
- if (!arg) {
1957
- error('workflow cancel requires a runId');
1958
- process.exit(1);
1959
- }
1960
- executor.cancel(arg, options.reason ?? 'cancelled via CLI');
1961
- // eslint-disable-next-line no-console
1962
- console.log(`Run ${arg} cancelled`);
1963
- break;
1964
- }
1965
- case 'approve': {
1966
- if (!arg) {
1967
- error('workflow approve requires a runId');
1968
- process.exit(1);
1969
- }
1970
- executor.approve(arg, options.comment);
1971
- // eslint-disable-next-line no-console
1972
- console.log(`Run ${arg} approved. Call \`specship workflow resume ${arg}\` to continue.`);
1973
- break;
1974
- }
1975
- case 'reject': {
1976
- if (!arg) {
1977
- error('workflow reject requires a runId');
1978
- process.exit(1);
1979
- }
1980
- executor.reject(arg, options.reason);
1981
- // eslint-disable-next-line no-console
1982
- console.log(`Run ${arg} rejected`);
1983
- break;
1984
- }
1985
- case 'runs': {
1986
- const runs = specQueries.getAllWorkflowRuns(50);
1987
- if (options.json) {
1988
- // eslint-disable-next-line no-console
1989
- console.log(JSON.stringify(runs, null, 2));
1990
- }
1991
- else if (runs.length === 0) {
1992
- // eslint-disable-next-line no-console
1993
- console.log('No runs yet.');
1994
- }
1995
- else {
1996
- for (const r of runs) {
1997
- const dur = r.completedAt
1998
- ? `${Math.round((r.completedAt - (r.startedAt ?? r.createdAt)) / 1000)}s`
1999
- : '—';
2000
- // eslint-disable-next-line no-console
2001
- console.log(`${r.id.substring(0, 8)} [${r.status}] ${r.workflowName} (${dur})`);
2002
- }
2003
- }
2004
- break;
2005
- }
2006
- default:
2007
- error(`Unknown workflow action "${action}". Use: list | run | resume | cancel | approve | reject | runs`);
2008
- process.exit(1);
2009
- }
2010
- }
2011
- finally {
2012
- cg.close();
2013
- }
2014
- });
2015
- // Parse and run
2016
- program.parse();
2017
- } // end main()
2018
- //# sourceMappingURL=specship.js.map