gitx.do 0.1.1 → 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 (376) hide show
  1. package/README.md +40 -353
  2. package/dist/do/logger.d.ts +50 -0
  3. package/dist/do/logger.d.ts.map +1 -0
  4. package/dist/do/logger.js +122 -0
  5. package/dist/do/logger.js.map +1 -0
  6. package/dist/{durable-object → do}/schema.d.ts +3 -3
  7. package/dist/do/schema.d.ts.map +1 -0
  8. package/dist/{durable-object → do}/schema.js +4 -3
  9. package/dist/do/schema.js.map +1 -0
  10. package/dist/do/types.d.ts +267 -0
  11. package/dist/do/types.d.ts.map +1 -0
  12. package/dist/do/types.js +62 -0
  13. package/dist/do/types.js.map +1 -0
  14. package/dist/index.d.ts +15 -469
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +39 -481
  17. package/dist/index.js.map +1 -1
  18. package/dist/mcp/auth.d.ts +77 -0
  19. package/dist/mcp/auth.d.ts.map +1 -0
  20. package/dist/mcp/auth.js +278 -0
  21. package/dist/mcp/auth.js.map +1 -0
  22. package/dist/mcp/index.d.ts +13 -0
  23. package/dist/mcp/index.d.ts.map +1 -0
  24. package/dist/mcp/index.js +19 -0
  25. package/dist/mcp/index.js.map +1 -0
  26. package/dist/mcp/server.d.ts +200 -0
  27. package/dist/mcp/server.d.ts.map +1 -0
  28. package/dist/mcp/server.js +275 -0
  29. package/dist/mcp/server.js.map +1 -0
  30. package/dist/mcp/tool-registry.d.ts +47 -0
  31. package/dist/mcp/tool-registry.d.ts.map +1 -0
  32. package/dist/mcp/tool-registry.js +284 -0
  33. package/dist/mcp/tool-registry.js.map +1 -0
  34. package/dist/mcp/tools.d.ts +103 -515
  35. package/dist/mcp/tools.d.ts.map +1 -1
  36. package/dist/mcp/tools.js +676 -3087
  37. package/dist/mcp/tools.js.map +1 -1
  38. package/dist/mcp/types.d.ts +124 -0
  39. package/dist/mcp/types.d.ts.map +1 -0
  40. package/dist/mcp/types.js +9 -0
  41. package/dist/mcp/types.js.map +1 -0
  42. package/package.json +19 -21
  43. package/dist/cli/commands/add.d.ts +0 -176
  44. package/dist/cli/commands/add.d.ts.map +0 -1
  45. package/dist/cli/commands/add.js +0 -979
  46. package/dist/cli/commands/add.js.map +0 -1
  47. package/dist/cli/commands/blame.d.ts +0 -259
  48. package/dist/cli/commands/blame.d.ts.map +0 -1
  49. package/dist/cli/commands/blame.js +0 -609
  50. package/dist/cli/commands/blame.js.map +0 -1
  51. package/dist/cli/commands/branch.d.ts +0 -249
  52. package/dist/cli/commands/branch.d.ts.map +0 -1
  53. package/dist/cli/commands/branch.js +0 -693
  54. package/dist/cli/commands/branch.js.map +0 -1
  55. package/dist/cli/commands/checkout.d.ts +0 -73
  56. package/dist/cli/commands/checkout.d.ts.map +0 -1
  57. package/dist/cli/commands/checkout.js +0 -725
  58. package/dist/cli/commands/checkout.js.map +0 -1
  59. package/dist/cli/commands/commit.d.ts +0 -182
  60. package/dist/cli/commands/commit.d.ts.map +0 -1
  61. package/dist/cli/commands/commit.js +0 -457
  62. package/dist/cli/commands/commit.js.map +0 -1
  63. package/dist/cli/commands/diff.d.ts +0 -464
  64. package/dist/cli/commands/diff.d.ts.map +0 -1
  65. package/dist/cli/commands/diff.js +0 -959
  66. package/dist/cli/commands/diff.js.map +0 -1
  67. package/dist/cli/commands/log.d.ts +0 -239
  68. package/dist/cli/commands/log.d.ts.map +0 -1
  69. package/dist/cli/commands/log.js +0 -535
  70. package/dist/cli/commands/log.js.map +0 -1
  71. package/dist/cli/commands/merge.d.ts +0 -106
  72. package/dist/cli/commands/merge.d.ts.map +0 -1
  73. package/dist/cli/commands/merge.js +0 -852
  74. package/dist/cli/commands/merge.js.map +0 -1
  75. package/dist/cli/commands/review.d.ts +0 -457
  76. package/dist/cli/commands/review.d.ts.map +0 -1
  77. package/dist/cli/commands/review.js +0 -558
  78. package/dist/cli/commands/review.js.map +0 -1
  79. package/dist/cli/commands/stash.d.ts +0 -157
  80. package/dist/cli/commands/stash.d.ts.map +0 -1
  81. package/dist/cli/commands/stash.js +0 -655
  82. package/dist/cli/commands/stash.js.map +0 -1
  83. package/dist/cli/commands/status.d.ts +0 -269
  84. package/dist/cli/commands/status.d.ts.map +0 -1
  85. package/dist/cli/commands/status.js +0 -492
  86. package/dist/cli/commands/status.js.map +0 -1
  87. package/dist/cli/commands/web.d.ts +0 -199
  88. package/dist/cli/commands/web.d.ts.map +0 -1
  89. package/dist/cli/commands/web.js +0 -697
  90. package/dist/cli/commands/web.js.map +0 -1
  91. package/dist/cli/fs-adapter.d.ts +0 -656
  92. package/dist/cli/fs-adapter.d.ts.map +0 -1
  93. package/dist/cli/fs-adapter.js +0 -1177
  94. package/dist/cli/fs-adapter.js.map +0 -1
  95. package/dist/cli/fsx-cli-adapter.d.ts +0 -359
  96. package/dist/cli/fsx-cli-adapter.d.ts.map +0 -1
  97. package/dist/cli/fsx-cli-adapter.js +0 -619
  98. package/dist/cli/fsx-cli-adapter.js.map +0 -1
  99. package/dist/cli/index.d.ts +0 -387
  100. package/dist/cli/index.d.ts.map +0 -1
  101. package/dist/cli/index.js +0 -579
  102. package/dist/cli/index.js.map +0 -1
  103. package/dist/cli/ui/components/DiffView.d.ts +0 -12
  104. package/dist/cli/ui/components/DiffView.d.ts.map +0 -1
  105. package/dist/cli/ui/components/DiffView.js +0 -11
  106. package/dist/cli/ui/components/DiffView.js.map +0 -1
  107. package/dist/cli/ui/components/ErrorDisplay.d.ts +0 -10
  108. package/dist/cli/ui/components/ErrorDisplay.d.ts.map +0 -1
  109. package/dist/cli/ui/components/ErrorDisplay.js +0 -11
  110. package/dist/cli/ui/components/ErrorDisplay.js.map +0 -1
  111. package/dist/cli/ui/components/FuzzySearch.d.ts +0 -15
  112. package/dist/cli/ui/components/FuzzySearch.d.ts.map +0 -1
  113. package/dist/cli/ui/components/FuzzySearch.js +0 -12
  114. package/dist/cli/ui/components/FuzzySearch.js.map +0 -1
  115. package/dist/cli/ui/components/LoadingSpinner.d.ts +0 -10
  116. package/dist/cli/ui/components/LoadingSpinner.d.ts.map +0 -1
  117. package/dist/cli/ui/components/LoadingSpinner.js +0 -10
  118. package/dist/cli/ui/components/LoadingSpinner.js.map +0 -1
  119. package/dist/cli/ui/components/NavigationList.d.ts +0 -14
  120. package/dist/cli/ui/components/NavigationList.d.ts.map +0 -1
  121. package/dist/cli/ui/components/NavigationList.js +0 -11
  122. package/dist/cli/ui/components/NavigationList.js.map +0 -1
  123. package/dist/cli/ui/components/ScrollableContent.d.ts +0 -13
  124. package/dist/cli/ui/components/ScrollableContent.d.ts.map +0 -1
  125. package/dist/cli/ui/components/ScrollableContent.js +0 -11
  126. package/dist/cli/ui/components/ScrollableContent.js.map +0 -1
  127. package/dist/cli/ui/components/index.d.ts +0 -7
  128. package/dist/cli/ui/components/index.d.ts.map +0 -1
  129. package/dist/cli/ui/components/index.js +0 -9
  130. package/dist/cli/ui/components/index.js.map +0 -1
  131. package/dist/cli/ui/terminal-ui.d.ts +0 -85
  132. package/dist/cli/ui/terminal-ui.d.ts.map +0 -1
  133. package/dist/cli/ui/terminal-ui.js +0 -121
  134. package/dist/cli/ui/terminal-ui.js.map +0 -1
  135. package/dist/do/BashModule.d.ts +0 -871
  136. package/dist/do/BashModule.d.ts.map +0 -1
  137. package/dist/do/BashModule.js +0 -1143
  138. package/dist/do/BashModule.js.map +0 -1
  139. package/dist/do/FsModule.d.ts +0 -612
  140. package/dist/do/FsModule.d.ts.map +0 -1
  141. package/dist/do/FsModule.js +0 -1120
  142. package/dist/do/FsModule.js.map +0 -1
  143. package/dist/do/GitModule.d.ts +0 -635
  144. package/dist/do/GitModule.d.ts.map +0 -1
  145. package/dist/do/GitModule.js +0 -784
  146. package/dist/do/GitModule.js.map +0 -1
  147. package/dist/do/GitRepoDO.d.ts +0 -281
  148. package/dist/do/GitRepoDO.d.ts.map +0 -1
  149. package/dist/do/GitRepoDO.js +0 -479
  150. package/dist/do/GitRepoDO.js.map +0 -1
  151. package/dist/do/bash-ast.d.ts +0 -246
  152. package/dist/do/bash-ast.d.ts.map +0 -1
  153. package/dist/do/bash-ast.js +0 -888
  154. package/dist/do/bash-ast.js.map +0 -1
  155. package/dist/do/container-executor.d.ts +0 -491
  156. package/dist/do/container-executor.d.ts.map +0 -1
  157. package/dist/do/container-executor.js +0 -731
  158. package/dist/do/container-executor.js.map +0 -1
  159. package/dist/do/index.d.ts +0 -53
  160. package/dist/do/index.d.ts.map +0 -1
  161. package/dist/do/index.js +0 -91
  162. package/dist/do/index.js.map +0 -1
  163. package/dist/do/tiered-storage.d.ts +0 -403
  164. package/dist/do/tiered-storage.d.ts.map +0 -1
  165. package/dist/do/tiered-storage.js +0 -689
  166. package/dist/do/tiered-storage.js.map +0 -1
  167. package/dist/do/withBash.d.ts +0 -231
  168. package/dist/do/withBash.d.ts.map +0 -1
  169. package/dist/do/withBash.js +0 -244
  170. package/dist/do/withBash.js.map +0 -1
  171. package/dist/do/withFs.d.ts +0 -237
  172. package/dist/do/withFs.d.ts.map +0 -1
  173. package/dist/do/withFs.js +0 -387
  174. package/dist/do/withFs.js.map +0 -1
  175. package/dist/do/withGit.d.ts +0 -180
  176. package/dist/do/withGit.d.ts.map +0 -1
  177. package/dist/do/withGit.js +0 -271
  178. package/dist/do/withGit.js.map +0 -1
  179. package/dist/durable-object/object-store.d.ts +0 -633
  180. package/dist/durable-object/object-store.d.ts.map +0 -1
  181. package/dist/durable-object/object-store.js +0 -1164
  182. package/dist/durable-object/object-store.js.map +0 -1
  183. package/dist/durable-object/schema.d.ts.map +0 -1
  184. package/dist/durable-object/schema.js.map +0 -1
  185. package/dist/durable-object/wal.d.ts +0 -416
  186. package/dist/durable-object/wal.d.ts.map +0 -1
  187. package/dist/durable-object/wal.js +0 -445
  188. package/dist/durable-object/wal.js.map +0 -1
  189. package/dist/mcp/adapter.d.ts +0 -772
  190. package/dist/mcp/adapter.d.ts.map +0 -1
  191. package/dist/mcp/adapter.js +0 -895
  192. package/dist/mcp/adapter.js.map +0 -1
  193. package/dist/mcp/sandbox/miniflare-evaluator.d.ts +0 -22
  194. package/dist/mcp/sandbox/miniflare-evaluator.d.ts.map +0 -1
  195. package/dist/mcp/sandbox/miniflare-evaluator.js +0 -140
  196. package/dist/mcp/sandbox/miniflare-evaluator.js.map +0 -1
  197. package/dist/mcp/sandbox/object-store-proxy.d.ts +0 -32
  198. package/dist/mcp/sandbox/object-store-proxy.d.ts.map +0 -1
  199. package/dist/mcp/sandbox/object-store-proxy.js +0 -30
  200. package/dist/mcp/sandbox/object-store-proxy.js.map +0 -1
  201. package/dist/mcp/sandbox/template.d.ts +0 -17
  202. package/dist/mcp/sandbox/template.d.ts.map +0 -1
  203. package/dist/mcp/sandbox/template.js +0 -71
  204. package/dist/mcp/sandbox/template.js.map +0 -1
  205. package/dist/mcp/sandbox.d.ts +0 -764
  206. package/dist/mcp/sandbox.d.ts.map +0 -1
  207. package/dist/mcp/sandbox.js +0 -1362
  208. package/dist/mcp/sandbox.js.map +0 -1
  209. package/dist/mcp/sdk-adapter.d.ts +0 -835
  210. package/dist/mcp/sdk-adapter.d.ts.map +0 -1
  211. package/dist/mcp/sdk-adapter.js +0 -974
  212. package/dist/mcp/sdk-adapter.js.map +0 -1
  213. package/dist/mcp/tools/do.d.ts +0 -32
  214. package/dist/mcp/tools/do.d.ts.map +0 -1
  215. package/dist/mcp/tools/do.js +0 -117
  216. package/dist/mcp/tools/do.js.map +0 -1
  217. package/dist/ops/blame.d.ts +0 -551
  218. package/dist/ops/blame.d.ts.map +0 -1
  219. package/dist/ops/blame.js +0 -1037
  220. package/dist/ops/blame.js.map +0 -1
  221. package/dist/ops/branch.d.ts +0 -766
  222. package/dist/ops/branch.d.ts.map +0 -1
  223. package/dist/ops/branch.js +0 -950
  224. package/dist/ops/branch.js.map +0 -1
  225. package/dist/ops/commit-traversal.d.ts +0 -349
  226. package/dist/ops/commit-traversal.d.ts.map +0 -1
  227. package/dist/ops/commit-traversal.js +0 -821
  228. package/dist/ops/commit-traversal.js.map +0 -1
  229. package/dist/ops/commit.d.ts +0 -555
  230. package/dist/ops/commit.d.ts.map +0 -1
  231. package/dist/ops/commit.js +0 -826
  232. package/dist/ops/commit.js.map +0 -1
  233. package/dist/ops/merge-base.d.ts +0 -397
  234. package/dist/ops/merge-base.d.ts.map +0 -1
  235. package/dist/ops/merge-base.js +0 -691
  236. package/dist/ops/merge-base.js.map +0 -1
  237. package/dist/ops/merge.d.ts +0 -855
  238. package/dist/ops/merge.d.ts.map +0 -1
  239. package/dist/ops/merge.js +0 -1551
  240. package/dist/ops/merge.js.map +0 -1
  241. package/dist/ops/tag.d.ts +0 -247
  242. package/dist/ops/tag.d.ts.map +0 -1
  243. package/dist/ops/tag.js +0 -649
  244. package/dist/ops/tag.js.map +0 -1
  245. package/dist/ops/tree-builder.d.ts +0 -178
  246. package/dist/ops/tree-builder.d.ts.map +0 -1
  247. package/dist/ops/tree-builder.js +0 -271
  248. package/dist/ops/tree-builder.js.map +0 -1
  249. package/dist/ops/tree-diff.d.ts +0 -291
  250. package/dist/ops/tree-diff.d.ts.map +0 -1
  251. package/dist/ops/tree-diff.js +0 -705
  252. package/dist/ops/tree-diff.js.map +0 -1
  253. package/dist/pack/delta.d.ts +0 -248
  254. package/dist/pack/delta.d.ts.map +0 -1
  255. package/dist/pack/delta.js +0 -740
  256. package/dist/pack/delta.js.map +0 -1
  257. package/dist/pack/format.d.ts +0 -446
  258. package/dist/pack/format.d.ts.map +0 -1
  259. package/dist/pack/format.js +0 -572
  260. package/dist/pack/format.js.map +0 -1
  261. package/dist/pack/full-generation.d.ts +0 -612
  262. package/dist/pack/full-generation.d.ts.map +0 -1
  263. package/dist/pack/full-generation.js +0 -1378
  264. package/dist/pack/full-generation.js.map +0 -1
  265. package/dist/pack/generation.d.ts +0 -441
  266. package/dist/pack/generation.d.ts.map +0 -1
  267. package/dist/pack/generation.js +0 -707
  268. package/dist/pack/generation.js.map +0 -1
  269. package/dist/pack/index.d.ts +0 -502
  270. package/dist/pack/index.d.ts.map +0 -1
  271. package/dist/pack/index.js +0 -833
  272. package/dist/pack/index.js.map +0 -1
  273. package/dist/refs/branch.d.ts +0 -683
  274. package/dist/refs/branch.d.ts.map +0 -1
  275. package/dist/refs/branch.js +0 -881
  276. package/dist/refs/branch.js.map +0 -1
  277. package/dist/refs/storage.d.ts +0 -833
  278. package/dist/refs/storage.d.ts.map +0 -1
  279. package/dist/refs/storage.js +0 -1023
  280. package/dist/refs/storage.js.map +0 -1
  281. package/dist/refs/tag.d.ts +0 -860
  282. package/dist/refs/tag.d.ts.map +0 -1
  283. package/dist/refs/tag.js +0 -996
  284. package/dist/refs/tag.js.map +0 -1
  285. package/dist/storage/backend.d.ts +0 -425
  286. package/dist/storage/backend.d.ts.map +0 -1
  287. package/dist/storage/backend.js +0 -41
  288. package/dist/storage/backend.js.map +0 -1
  289. package/dist/storage/fsx-adapter.d.ts +0 -204
  290. package/dist/storage/fsx-adapter.d.ts.map +0 -1
  291. package/dist/storage/fsx-adapter.js +0 -518
  292. package/dist/storage/fsx-adapter.js.map +0 -1
  293. package/dist/storage/lru-cache.d.ts +0 -691
  294. package/dist/storage/lru-cache.d.ts.map +0 -1
  295. package/dist/storage/lru-cache.js +0 -813
  296. package/dist/storage/lru-cache.js.map +0 -1
  297. package/dist/storage/object-index.d.ts +0 -585
  298. package/dist/storage/object-index.d.ts.map +0 -1
  299. package/dist/storage/object-index.js +0 -532
  300. package/dist/storage/object-index.js.map +0 -1
  301. package/dist/storage/r2-pack.d.ts +0 -1257
  302. package/dist/storage/r2-pack.d.ts.map +0 -1
  303. package/dist/storage/r2-pack.js +0 -1773
  304. package/dist/storage/r2-pack.js.map +0 -1
  305. package/dist/tiered/cdc-pipeline.d.ts +0 -1888
  306. package/dist/tiered/cdc-pipeline.d.ts.map +0 -1
  307. package/dist/tiered/cdc-pipeline.js +0 -1880
  308. package/dist/tiered/cdc-pipeline.js.map +0 -1
  309. package/dist/tiered/migration.d.ts +0 -1104
  310. package/dist/tiered/migration.d.ts.map +0 -1
  311. package/dist/tiered/migration.js +0 -1217
  312. package/dist/tiered/migration.js.map +0 -1
  313. package/dist/tiered/parquet-writer.d.ts +0 -1145
  314. package/dist/tiered/parquet-writer.d.ts.map +0 -1
  315. package/dist/tiered/parquet-writer.js +0 -1183
  316. package/dist/tiered/parquet-writer.js.map +0 -1
  317. package/dist/tiered/read-path.d.ts +0 -835
  318. package/dist/tiered/read-path.d.ts.map +0 -1
  319. package/dist/tiered/read-path.js +0 -487
  320. package/dist/tiered/read-path.js.map +0 -1
  321. package/dist/types/capability.d.ts +0 -1385
  322. package/dist/types/capability.d.ts.map +0 -1
  323. package/dist/types/capability.js +0 -36
  324. package/dist/types/capability.js.map +0 -1
  325. package/dist/types/index.d.ts +0 -13
  326. package/dist/types/index.d.ts.map +0 -1
  327. package/dist/types/index.js +0 -18
  328. package/dist/types/index.js.map +0 -1
  329. package/dist/types/interfaces.d.ts +0 -673
  330. package/dist/types/interfaces.d.ts.map +0 -1
  331. package/dist/types/interfaces.js +0 -26
  332. package/dist/types/interfaces.js.map +0 -1
  333. package/dist/types/objects.d.ts +0 -692
  334. package/dist/types/objects.d.ts.map +0 -1
  335. package/dist/types/objects.js +0 -837
  336. package/dist/types/objects.js.map +0 -1
  337. package/dist/types/storage.d.ts +0 -603
  338. package/dist/types/storage.d.ts.map +0 -1
  339. package/dist/types/storage.js +0 -191
  340. package/dist/types/storage.js.map +0 -1
  341. package/dist/types/worker-loader.d.ts +0 -60
  342. package/dist/types/worker-loader.d.ts.map +0 -1
  343. package/dist/types/worker-loader.js +0 -62
  344. package/dist/types/worker-loader.js.map +0 -1
  345. package/dist/utils/hash.d.ts +0 -198
  346. package/dist/utils/hash.d.ts.map +0 -1
  347. package/dist/utils/hash.js +0 -272
  348. package/dist/utils/hash.js.map +0 -1
  349. package/dist/utils/sha1.d.ts +0 -325
  350. package/dist/utils/sha1.d.ts.map +0 -1
  351. package/dist/utils/sha1.js +0 -635
  352. package/dist/utils/sha1.js.map +0 -1
  353. package/dist/wire/capabilities.d.ts +0 -1044
  354. package/dist/wire/capabilities.d.ts.map +0 -1
  355. package/dist/wire/capabilities.js +0 -941
  356. package/dist/wire/capabilities.js.map +0 -1
  357. package/dist/wire/path-security.d.ts +0 -157
  358. package/dist/wire/path-security.d.ts.map +0 -1
  359. package/dist/wire/path-security.js +0 -307
  360. package/dist/wire/path-security.js.map +0 -1
  361. package/dist/wire/pkt-line.d.ts +0 -345
  362. package/dist/wire/pkt-line.d.ts.map +0 -1
  363. package/dist/wire/pkt-line.js +0 -381
  364. package/dist/wire/pkt-line.js.map +0 -1
  365. package/dist/wire/receive-pack.d.ts +0 -1059
  366. package/dist/wire/receive-pack.d.ts.map +0 -1
  367. package/dist/wire/receive-pack.js +0 -1414
  368. package/dist/wire/receive-pack.js.map +0 -1
  369. package/dist/wire/smart-http.d.ts +0 -799
  370. package/dist/wire/smart-http.d.ts.map +0 -1
  371. package/dist/wire/smart-http.js +0 -945
  372. package/dist/wire/smart-http.js.map +0 -1
  373. package/dist/wire/upload-pack.d.ts +0 -727
  374. package/dist/wire/upload-pack.d.ts.map +0 -1
  375. package/dist/wire/upload-pack.js +0 -1141
  376. package/dist/wire/upload-pack.js.map +0 -1
@@ -1,387 +0,0 @@
1
- /**
2
- * @fileoverview CLI Entry Point for gitx
3
- *
4
- * This module provides the main command-line interface for gitx, a git-compatible
5
- * version control system. It handles argument parsing, command routing, and
6
- * provides the foundation for all CLI subcommands.
7
- *
8
- * @module cli/index
9
- *
10
- * @example
11
- * // Create and run CLI programmatically
12
- * import { createCLI, runCLI } from './cli'
13
- *
14
- * const cli = createCLI({ name: 'gitx', version: '1.0.0' })
15
- * cli.registerCommand('status', statusHandler)
16
- * await cli.run(['status', '--short'])
17
- *
18
- * @example
19
- * // Parse arguments without running
20
- * import { parseArgs } from './cli'
21
- *
22
- * const parsed = parseArgs(['status', '--short', '--branch'])
23
- * console.log(parsed.command) // 'status'
24
- * console.log(parsed.options) // { short: true, branch: true }
25
- */
26
- /**
27
- * Options for configuring CLI behavior.
28
- *
29
- * @description Allows customization of CLI execution including working directory,
30
- * and output streams for testing or embedding scenarios.
31
- *
32
- * @property cwd - Working directory for command execution. Defaults to process.cwd().
33
- * @property stdout - Custom function for standard output. Defaults to console.log.
34
- * @property stderr - Custom function for error output. Defaults to console.error.
35
- *
36
- * @example
37
- * const options: CLIOptions = {
38
- * cwd: '/path/to/repo',
39
- * stdout: (msg) => output.push(msg),
40
- * stderr: (msg) => errors.push(msg)
41
- * }
42
- */
43
- export interface CLIOptions {
44
- /** Working directory for command execution */
45
- cwd?: string;
46
- /** Custom function for standard output */
47
- stdout?: (msg: string) => void;
48
- /** Custom function for error output */
49
- stderr?: (msg: string) => void;
50
- }
51
- /**
52
- * Result returned from CLI command execution.
53
- *
54
- * @description Contains the exit code, executed command name, and any error
55
- * that occurred during execution. Used to determine success/failure of CLI operations.
56
- *
57
- * @property exitCode - Exit code (0 for success, non-zero for failure)
58
- * @property command - The command that was executed, if any
59
- * @property error - Error object if command failed
60
- *
61
- * @example
62
- * const result = await cli.run(['status'])
63
- * if (result.exitCode !== 0) {
64
- * console.error(`Command ${result.command} failed:`, result.error?.message)
65
- * }
66
- */
67
- export interface CLIResult {
68
- /** Exit code (0 for success, non-zero for failure) */
69
- exitCode: number;
70
- /** The command that was executed, if any */
71
- command?: string;
72
- /** Error object if command failed */
73
- error?: Error;
74
- }
75
- /**
76
- * Parsed command-line arguments structure.
77
- *
78
- * @description Contains the parsed representation of CLI arguments including
79
- * the command name, positional arguments, options/flags, and working directory.
80
- *
81
- * @property command - The subcommand to execute (e.g., 'status', 'diff')
82
- * @property args - Positional arguments after the command
83
- * @property options - Key-value pairs of parsed options/flags
84
- * @property rawArgs - Arguments after '--' separator (passed through unchanged)
85
- * @property cwd - Working directory for command execution
86
- *
87
- * @example
88
- * // Parsing 'gitx status --short file.txt'
89
- * const parsed: ParsedArgs = {
90
- * command: 'status',
91
- * args: ['file.txt'],
92
- * options: { short: true },
93
- * rawArgs: [],
94
- * cwd: '/path/to/repo'
95
- * }
96
- */
97
- export interface ParsedArgs {
98
- /** The subcommand to execute (e.g., 'status', 'diff') */
99
- command?: string;
100
- /** Positional arguments after the command */
101
- args: string[];
102
- /** Key-value pairs of parsed options/flags */
103
- options: Record<string, any>;
104
- /** Arguments after '--' separator (passed through unchanged) */
105
- rawArgs: string[];
106
- /** Working directory for command execution */
107
- cwd: string;
108
- }
109
- /**
110
- * Context object passed to command handlers.
111
- *
112
- * @description Provides command handlers with all necessary context including
113
- * the working directory, arguments, options, and I/O functions.
114
- *
115
- * @property cwd - Current working directory for the command
116
- * @property args - Positional arguments passed to the command
117
- * @property options - Parsed options/flags for the command
118
- * @property rawArgs - Raw arguments after '--' separator
119
- * @property stdout - Function to write to standard output
120
- * @property stderr - Function to write to standard error
121
- *
122
- * @example
123
- * async function statusHandler(ctx: CommandContext): Promise<void> {
124
- * const { cwd, options, stdout } = ctx
125
- * const status = await getStatus(cwd)
126
- * if (options.short) {
127
- * stdout(formatShort(status))
128
- * } else {
129
- * stdout(formatLong(status))
130
- * }
131
- * }
132
- */
133
- export interface CommandContext {
134
- /** Current working directory for the command */
135
- cwd: string;
136
- /** Positional arguments passed to the command */
137
- args: string[];
138
- /** Parsed options/flags for the command */
139
- options: Record<string, any>;
140
- /** Raw arguments after '--' separator */
141
- rawArgs: string[];
142
- /** Function to write to standard output */
143
- stdout: (msg: string) => void;
144
- /** Function to write to standard error */
145
- stderr: (msg: string) => void;
146
- }
147
- /**
148
- * Function type for command handlers.
149
- *
150
- * @description Command handlers receive a CommandContext and may return
151
- * void or a Promise for async operations. Errors should be thrown
152
- * to indicate failure.
153
- *
154
- * @param ctx - The command context with args, options, and I/O
155
- * @returns void or Promise<void>
156
- *
157
- * @example
158
- * const myHandler: CommandHandler = async (ctx) => {
159
- * ctx.stdout('Hello from command!')
160
- * }
161
- */
162
- type CommandHandler = (ctx: CommandContext) => void | Promise<void>;
163
- /**
164
- * Main CLI class for gitx command-line interface.
165
- *
166
- * @description Provides command registration, argument parsing, help generation,
167
- * and command execution. Supports custom output streams for testing.
168
- *
169
- * @example
170
- * const cli = new CLI({ name: 'gitx', version: '1.0.0' })
171
- * cli.registerCommand('status', statusHandler)
172
- * const result = await cli.run(['status', '--short'])
173
- *
174
- * @example
175
- * // With custom output streams for testing
176
- * const output: string[] = []
177
- * const cli = new CLI({
178
- * stdout: (msg) => output.push(msg),
179
- * stderr: (msg) => output.push(`ERROR: ${msg}`)
180
- * })
181
- */
182
- export declare class CLI {
183
- /** The name of the CLI tool */
184
- name: string;
185
- /** The version of the CLI tool */
186
- version: string;
187
- /** Registered command handlers */
188
- private handlers;
189
- /** Function for standard output */
190
- private stdout;
191
- /** Function for error output */
192
- private stderr;
193
- /**
194
- * Creates a new CLI instance.
195
- *
196
- * @description Initializes the CLI with optional name, version, and I/O functions.
197
- * Defaults are provided for all options.
198
- *
199
- * @param options - Configuration options
200
- * @param options.name - CLI name (default: 'gitx')
201
- * @param options.version - CLI version (default: '0.0.1')
202
- * @param options.stdout - Standard output function (default: console.log)
203
- * @param options.stderr - Error output function (default: console.error)
204
- *
205
- * @example
206
- * const cli = new CLI({ name: 'my-tool', version: '2.0.0' })
207
- */
208
- constructor(options?: {
209
- name?: string;
210
- version?: string;
211
- stdout?: (msg: string) => void;
212
- stderr?: (msg: string) => void;
213
- });
214
- /**
215
- * Registers a command handler for a subcommand.
216
- *
217
- * @description Associates a handler function with a command name. The handler
218
- * will be invoked when that command is executed.
219
- *
220
- * @param name - The command name (e.g., 'status', 'diff')
221
- * @param handler - The function to handle the command
222
- *
223
- * @example
224
- * cli.registerCommand('status', async (ctx) => {
225
- * const status = await getStatus(ctx.cwd)
226
- * ctx.stdout(formatStatus(status))
227
- * })
228
- */
229
- registerCommand(name: string, handler: CommandHandler): void;
230
- /**
231
- * Runs the CLI with the provided arguments.
232
- *
233
- * @description Parses arguments, handles help/version flags, validates commands,
234
- * and executes the appropriate handler. Returns a result object with exit code.
235
- *
236
- * @param args - Command-line arguments (excluding 'node' and script name)
237
- * @param options - Run options
238
- * @param options.skipCwdCheck - Skip validation of --cwd directory existence
239
- * @returns Promise<CLIResult> with exitCode, command, and potential error
240
- *
241
- * @throws Never throws directly - errors are captured in CLIResult.error
242
- *
243
- * @example
244
- * const result = await cli.run(['status', '--short'])
245
- * if (result.exitCode === 0) {
246
- * console.log('Success!')
247
- * } else {
248
- * console.error('Failed:', result.error?.message)
249
- * }
250
- *
251
- * @example
252
- * // Skip cwd validation for testing
253
- * const result = await cli.run(['status'], { skipCwdCheck: true })
254
- */
255
- run(args: string[], options?: {
256
- skipCwdCheck?: boolean;
257
- }): Promise<CLIResult>;
258
- /**
259
- * Generates the main help text for the CLI.
260
- *
261
- * @description Creates formatted help output showing available commands,
262
- * options, and usage information.
263
- *
264
- * @returns Formatted help string
265
- */
266
- private getHelp;
267
- /**
268
- * Generates help text for a specific subcommand.
269
- *
270
- * @description Creates formatted help output for a specific command
271
- * including its description and usage pattern.
272
- *
273
- * @param command - The command name to get help for
274
- * @returns Formatted help string for the command
275
- */
276
- private getSubcommandHelp;
277
- /**
278
- * Suggests a command based on a misspelled input.
279
- *
280
- * @description Uses Levenshtein distance to find the closest matching
281
- * command when the user enters an unknown command. Only suggests
282
- * commands within a distance of 3 edits.
283
- *
284
- * @param input - The misspelled command input
285
- * @returns The suggested command name, or null if no close match
286
- */
287
- private suggestCommand;
288
- }
289
- /**
290
- * Creates a new CLI instance with the provided options.
291
- *
292
- * @description Factory function for creating CLI instances. Provides a
293
- * convenient way to instantiate the CLI with custom configuration.
294
- *
295
- * @param options - Configuration options for the CLI
296
- * @param options.name - CLI name (default: 'gitx')
297
- * @param options.version - CLI version (default: '0.0.1')
298
- * @param options.stdout - Standard output function (default: console.log)
299
- * @param options.stderr - Error output function (default: console.error)
300
- * @returns A new CLI instance
301
- *
302
- * @example
303
- * const cli = createCLI({ name: 'my-git', version: '1.0.0' })
304
- * cli.registerCommand('status', statusHandler)
305
- * await cli.run(['status'])
306
- *
307
- * @example
308
- * // For testing with captured output
309
- * const output: string[] = []
310
- * const cli = createCLI({
311
- * stdout: (msg) => output.push(msg)
312
- * })
313
- */
314
- export declare function createCLI(options?: {
315
- name?: string;
316
- version?: string;
317
- stdout?: (msg: string) => void;
318
- stderr?: (msg: string) => void;
319
- }): CLI;
320
- /**
321
- * Parses command-line arguments into a structured format.
322
- *
323
- * @description Uses the cac library to parse arguments, extracting the command,
324
- * positional arguments, options/flags, and handling special cases like --cwd
325
- * and the '--' separator for raw arguments.
326
- *
327
- * @param args - Array of command-line arguments (excluding 'node' and script name)
328
- * @returns ParsedArgs object with command, args, options, rawArgs, and cwd
329
- *
330
- * @example
331
- * const parsed = parseArgs(['status', '--short', '--branch'])
332
- * // Returns: {
333
- * // command: 'status',
334
- * // args: [],
335
- * // options: { short: true, branch: true },
336
- * // rawArgs: [],
337
- * // cwd: process.cwd()
338
- * // }
339
- *
340
- * @example
341
- * const parsed = parseArgs(['--cwd', '/repo', 'diff', '--staged'])
342
- * // Returns: {
343
- * // command: 'diff',
344
- * // args: [],
345
- * // options: { staged: true, cwd: '/repo' },
346
- * // rawArgs: [],
347
- * // cwd: '/repo'
348
- * // }
349
- *
350
- * @example
351
- * // With raw args after '--'
352
- * const parsed = parseArgs(['commit', '-m', 'msg', '--', 'file.txt'])
353
- * // Returns: {
354
- * // command: 'commit',
355
- * // args: [],
356
- * // options: { m: 'msg' },
357
- * // rawArgs: ['file.txt'],
358
- * // cwd: process.cwd()
359
- * // }
360
- */
361
- export declare function parseArgs(args: string[]): ParsedArgs;
362
- /**
363
- * Convenience function to create a CLI and run it with the provided arguments.
364
- *
365
- * @description Creates a new CLI instance with the provided options and
366
- * immediately runs it with the given arguments. Useful for simple one-off
367
- * CLI executions.
368
- *
369
- * @param args - Command-line arguments to run
370
- * @param options - CLI options including output streams
371
- * @returns Promise<CLIResult> with exitCode, command, and potential error
372
- *
373
- * @example
374
- * const result = await runCLI(['status', '--short'])
375
- * console.log(result.exitCode) // 0 or 1
376
- *
377
- * @example
378
- * // With custom output handling
379
- * const output: string[] = []
380
- * const result = await runCLI(['status'], {
381
- * stdout: (msg) => output.push(msg),
382
- * stderr: (msg) => console.error(msg)
383
- * })
384
- */
385
- export declare function runCLI(args: string[], options?: CLIOptions): Promise<CLIResult>;
386
- export {};
387
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"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"}