@getmateo/cli 0.0.0-stage → 0.19.7

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 (304) hide show
  1. package/LICENSE +211 -0
  2. package/bin/mateo +3 -0
  3. package/dist/classify.d.ts +19 -0
  4. package/dist/classify.js +49 -0
  5. package/dist/cli.d.ts +3 -0
  6. package/dist/cli.js +143 -0
  7. package/dist/commands/agent/archive.d.ts +27 -0
  8. package/dist/commands/agent/archive.js +88 -0
  9. package/dist/commands/agent/attach.d.ts +8 -0
  10. package/dist/commands/agent/attach.js +160 -0
  11. package/dist/commands/agent/delete.d.ts +15 -0
  12. package/dist/commands/agent/delete.js +104 -0
  13. package/dist/commands/agent/detach.d.ts +16 -0
  14. package/dist/commands/agent/detach.js +44 -0
  15. package/dist/commands/agent/import.d.ts +14 -0
  16. package/dist/commands/agent/import.js +108 -0
  17. package/dist/commands/agent/index.d.ts +3 -0
  18. package/dist/commands/agent/index.js +56 -0
  19. package/dist/commands/agent/inspect.d.ts +15 -0
  20. package/dist/commands/agent/inspect.js +196 -0
  21. package/dist/commands/agent/logs.d.ts +39 -0
  22. package/dist/commands/agent/logs.js +369 -0
  23. package/dist/commands/agent/ls.d.ts +61 -0
  24. package/dist/commands/agent/ls.js +201 -0
  25. package/dist/commands/agent/mode.d.ts +18 -0
  26. package/dist/commands/agent/mode.js +100 -0
  27. package/dist/commands/agent/open.d.ts +11 -0
  28. package/dist/commands/agent/open.js +74 -0
  29. package/dist/commands/agent/reload.d.ts +25 -0
  30. package/dist/commands/agent/reload.js +64 -0
  31. package/dist/commands/agent/run.d.ts +77 -0
  32. package/dist/commands/agent/run.js +556 -0
  33. package/dist/commands/agent/send.d.ts +21 -0
  34. package/dist/commands/agent/send.js +187 -0
  35. package/dist/commands/agent/stop.d.ts +17 -0
  36. package/dist/commands/agent/stop.js +102 -0
  37. package/dist/commands/agent/update.d.ts +51 -0
  38. package/dist/commands/agent/update.js +173 -0
  39. package/dist/commands/agent/wait.d.ts +31 -0
  40. package/dist/commands/agent/wait.js +161 -0
  41. package/dist/commands/clone.d.ts +17 -0
  42. package/dist/commands/clone.js +59 -0
  43. package/dist/commands/daemon/config.d.ts +3 -0
  44. package/dist/commands/daemon/config.js +103 -0
  45. package/dist/commands/daemon/index.d.ts +3 -0
  46. package/dist/commands/daemon/index.js +28 -0
  47. package/dist/commands/daemon/local-daemon.d.ts +13 -0
  48. package/dist/commands/daemon/local-daemon.js +105 -0
  49. package/dist/commands/daemon/pair.d.ts +30 -0
  50. package/dist/commands/daemon/pair.js +145 -0
  51. package/dist/commands/daemon/reload.d.ts +12 -0
  52. package/dist/commands/daemon/reload.js +44 -0
  53. package/dist/commands/daemon/restart.d.ts +29 -0
  54. package/dist/commands/daemon/restart.js +169 -0
  55. package/dist/commands/daemon/runtime-toolchain.d.ts +6 -0
  56. package/dist/commands/daemon/runtime-toolchain.js +87 -0
  57. package/dist/commands/daemon/set-password.d.ts +17 -0
  58. package/dist/commands/daemon/set-password.js +89 -0
  59. package/dist/commands/daemon/start.d.ts +20 -0
  60. package/dist/commands/daemon/start.js +52 -0
  61. package/dist/commands/daemon/status.d.ts +13 -0
  62. package/dist/commands/daemon/status.js +119 -0
  63. package/dist/commands/daemon/stop.d.ts +20 -0
  64. package/dist/commands/daemon/stop.js +58 -0
  65. package/dist/commands/fleet/index.d.ts +4 -0
  66. package/dist/commands/fleet/index.js +57 -0
  67. package/dist/commands/heartbeat/index.d.ts +3 -0
  68. package/dist/commands/heartbeat/index.js +139 -0
  69. package/dist/commands/hooks.d.ts +19 -0
  70. package/dist/commands/hooks.js +89 -0
  71. package/dist/commands/hub/authority.d.ts +17 -0
  72. package/dist/commands/hub/authority.js +18 -0
  73. package/dist/commands/hub/connect.d.ts +24 -0
  74. package/dist/commands/hub/connect.js +44 -0
  75. package/dist/commands/hub/credentials.d.ts +21 -0
  76. package/dist/commands/hub/credentials.js +143 -0
  77. package/dist/commands/hub/daemon-client.d.ts +41 -0
  78. package/dist/commands/hub/daemon-client.js +14 -0
  79. package/dist/commands/hub/deploy-bundle.d.ts +16 -0
  80. package/dist/commands/hub/deploy-bundle.js +248 -0
  81. package/dist/commands/hub/deploy-triggers.d.ts +6 -0
  82. package/dist/commands/hub/deploy-triggers.js +116 -0
  83. package/dist/commands/hub/deploy.d.ts +50 -0
  84. package/dist/commands/hub/deploy.js +159 -0
  85. package/dist/commands/hub/disconnect.d.ts +17 -0
  86. package/dist/commands/hub/disconnect.js +24 -0
  87. package/dist/commands/hub/error.d.ts +6 -0
  88. package/dist/commands/hub/error.js +9 -0
  89. package/dist/commands/hub/export.d.ts +28 -0
  90. package/dist/commands/hub/export.js +80 -0
  91. package/dist/commands/hub/help.d.ts +3 -0
  92. package/dist/commands/hub/help.js +5 -0
  93. package/dist/commands/hub/hub-client/index.d.ts +22 -0
  94. package/dist/commands/hub/hub-client/index.js +135 -0
  95. package/dist/commands/hub/hub-client/internal/contracts.d.ts +126 -0
  96. package/dist/commands/hub/hub-client/internal/contracts.js +85 -0
  97. package/dist/commands/hub/hub-client/internal/problem.d.ts +3 -0
  98. package/dist/commands/hub/hub-client/internal/problem.js +85 -0
  99. package/dist/commands/hub/hub-client/internal/transport.d.ts +15 -0
  100. package/dist/commands/hub/hub-client/internal/transport.js +30 -0
  101. package/dist/commands/hub/index.d.ts +20 -0
  102. package/dist/commands/hub/index.js +94 -0
  103. package/dist/commands/hub/init-plan.d.ts +33 -0
  104. package/dist/commands/hub/init-plan.js +94 -0
  105. package/dist/commands/hub/init.d.ts +37 -0
  106. package/dist/commands/hub/init.js +525 -0
  107. package/dist/commands/hub/login-flow.d.ts +34 -0
  108. package/dist/commands/hub/login-flow.js +78 -0
  109. package/dist/commands/hub/login.d.ts +23 -0
  110. package/dist/commands/hub/login.js +40 -0
  111. package/dist/commands/hub/logout.d.ts +33 -0
  112. package/dist/commands/hub/logout.js +71 -0
  113. package/dist/commands/hub/origin.d.ts +2 -0
  114. package/dist/commands/hub/origin.js +27 -0
  115. package/dist/commands/hub/permissions.d.ts +22 -0
  116. package/dist/commands/hub/permissions.js +61 -0
  117. package/dist/commands/hub/projects.d.ts +24 -0
  118. package/dist/commands/hub/projects.js +49 -0
  119. package/dist/commands/hub/reporter.d.ts +10 -0
  120. package/dist/commands/hub/reporter.js +11 -0
  121. package/dist/commands/hub/starter-agent-runtime.d.ts +37 -0
  122. package/dist/commands/hub/starter-agent-runtime.js +49 -0
  123. package/dist/commands/hub/starter-trigger.d.ts +10 -0
  124. package/dist/commands/hub/starter-trigger.js +30 -0
  125. package/dist/commands/hub/status-output.d.ts +13 -0
  126. package/dist/commands/hub/status-output.js +30 -0
  127. package/dist/commands/onboard.d.ts +14 -0
  128. package/dist/commands/onboard.js +169 -0
  129. package/dist/commands/open.d.ts +4 -0
  130. package/dist/commands/open.js +91 -0
  131. package/dist/commands/permit/allow.d.ts +38 -0
  132. package/dist/commands/permit/allow.js +138 -0
  133. package/dist/commands/permit/deny.d.ts +13 -0
  134. package/dist/commands/permit/deny.js +100 -0
  135. package/dist/commands/permit/index.d.ts +3 -0
  136. package/dist/commands/permit/index.js +27 -0
  137. package/dist/commands/permit/ls.d.ts +21 -0
  138. package/dist/commands/permit/ls.js +54 -0
  139. package/dist/commands/plugin/index.d.ts +23 -0
  140. package/dist/commands/plugin/index.js +174 -0
  141. package/dist/commands/plugin/scaffold.d.ts +6 -0
  142. package/dist/commands/plugin/scaffold.js +212 -0
  143. package/dist/commands/plugin/shared.d.ts +7 -0
  144. package/dist/commands/plugin/shared.js +34 -0
  145. package/dist/commands/plugin/update.d.ts +37 -0
  146. package/dist/commands/plugin/update.js +58 -0
  147. package/dist/commands/project/create.d.ts +10 -0
  148. package/dist/commands/project/create.js +43 -0
  149. package/dist/commands/project/delete.d.ts +9 -0
  150. package/dist/commands/project/delete.js +35 -0
  151. package/dist/commands/project/index.d.ts +3 -0
  152. package/dist/commands/project/index.js +28 -0
  153. package/dist/commands/project/ls.d.ts +5 -0
  154. package/dist/commands/project/ls.js +19 -0
  155. package/dist/commands/project/rename.d.ts +15 -0
  156. package/dist/commands/project/rename.js +52 -0
  157. package/dist/commands/project/shared.d.ts +11 -0
  158. package/dist/commands/project/shared.js +18 -0
  159. package/dist/commands/provider/diagnostic.d.ts +12 -0
  160. package/dist/commands/provider/diagnostic.js +31 -0
  161. package/dist/commands/provider/index.d.ts +3 -0
  162. package/dist/commands/provider/index.js +21 -0
  163. package/dist/commands/provider/ls.d.ts +19 -0
  164. package/dist/commands/provider/ls.js +46 -0
  165. package/dist/commands/provider/models.d.ts +20 -0
  166. package/dist/commands/provider/models.js +53 -0
  167. package/dist/commands/schedule/create.d.ts +19 -0
  168. package/dist/commands/schedule/create.js +41 -0
  169. package/dist/commands/schedule/delete.d.ts +10 -0
  170. package/dist/commands/schedule/delete.js +32 -0
  171. package/dist/commands/schedule/index.d.ts +3 -0
  172. package/dist/commands/schedule/index.js +66 -0
  173. package/dist/commands/schedule/inspect.d.ts +6 -0
  174. package/dist/commands/schedule/inspect.js +27 -0
  175. package/dist/commands/schedule/logs.d.ts +6 -0
  176. package/dist/commands/schedule/logs.js +24 -0
  177. package/dist/commands/schedule/ls.d.ts +5 -0
  178. package/dist/commands/schedule/ls.js +25 -0
  179. package/dist/commands/schedule/pause.d.ts +5 -0
  180. package/dist/commands/schedule/pause.js +24 -0
  181. package/dist/commands/schedule/resume.d.ts +5 -0
  182. package/dist/commands/schedule/resume.js +24 -0
  183. package/dist/commands/schedule/run-once.d.ts +5 -0
  184. package/dist/commands/schedule/run-once.js +24 -0
  185. package/dist/commands/schedule/schema.d.ts +21 -0
  186. package/dist/commands/schedule/schema.js +67 -0
  187. package/dist/commands/schedule/shared.d.ts +61 -0
  188. package/dist/commands/schedule/shared.js +360 -0
  189. package/dist/commands/schedule/types.d.ts +165 -0
  190. package/dist/commands/schedule/types.js +2 -0
  191. package/dist/commands/schedule/update.d.ts +19 -0
  192. package/dist/commands/schedule/update.js +40 -0
  193. package/dist/commands/script/index.d.ts +3 -0
  194. package/dist/commands/script/index.js +19 -0
  195. package/dist/commands/script/ls.d.ts +6 -0
  196. package/dist/commands/script/ls.js +20 -0
  197. package/dist/commands/script/schema.d.ts +5 -0
  198. package/dist/commands/script/schema.js +13 -0
  199. package/dist/commands/script/shared.d.ts +12 -0
  200. package/dist/commands/script/shared.js +59 -0
  201. package/dist/commands/script/start.d.ts +6 -0
  202. package/dist/commands/script/start.js +23 -0
  203. package/dist/commands/script/stop.d.ts +6 -0
  204. package/dist/commands/script/stop.js +23 -0
  205. package/dist/commands/terminal/capture.d.ts +10 -0
  206. package/dist/commands/terminal/capture.js +67 -0
  207. package/dist/commands/terminal/create.d.ts +11 -0
  208. package/dist/commands/terminal/create.js +29 -0
  209. package/dist/commands/terminal/index.d.ts +3 -0
  210. package/dist/commands/terminal/index.js +51 -0
  211. package/dist/commands/terminal/kill.d.ts +6 -0
  212. package/dist/commands/terminal/kill.js +36 -0
  213. package/dist/commands/terminal/ls.d.ts +11 -0
  214. package/dist/commands/terminal/ls.js +21 -0
  215. package/dist/commands/terminal/schema.d.ts +10 -0
  216. package/dist/commands/terminal/schema.js +17 -0
  217. package/dist/commands/terminal/send-keys.d.ts +7 -0
  218. package/dist/commands/terminal/send-keys.js +44 -0
  219. package/dist/commands/terminal/shared.d.ts +13 -0
  220. package/dist/commands/terminal/shared.js +64 -0
  221. package/dist/commands/terminal/upgrade-hosts.d.ts +11 -0
  222. package/dist/commands/terminal/upgrade-hosts.js +46 -0
  223. package/dist/commands/usage/index.d.ts +29 -0
  224. package/dist/commands/usage/index.js +62 -0
  225. package/dist/commands/usage/presentation.d.ts +4 -0
  226. package/dist/commands/usage/presentation.js +146 -0
  227. package/dist/commands/workspace/archive.d.ts +13 -0
  228. package/dist/commands/workspace/archive.js +43 -0
  229. package/dist/commands/workspace/create.d.ts +50 -0
  230. package/dist/commands/workspace/create.js +132 -0
  231. package/dist/commands/workspace/index.d.ts +3 -0
  232. package/dist/commands/workspace/index.js +50 -0
  233. package/dist/commands/workspace/ls.d.ts +11 -0
  234. package/dist/commands/workspace/ls.js +33 -0
  235. package/dist/commands/workspace/rename.d.ts +23 -0
  236. package/dist/commands/workspace/rename.js +63 -0
  237. package/dist/commands/workspace/setup.d.ts +12 -0
  238. package/dist/commands/workspace/setup.js +41 -0
  239. package/dist/commands/workspace/shared.d.ts +15 -0
  240. package/dist/commands/workspace/shared.js +29 -0
  241. package/dist/commands/worktree/archive.d.ts +21 -0
  242. package/dist/commands/worktree/archive.js +108 -0
  243. package/dist/commands/worktree/create-input.d.ts +15 -0
  244. package/dist/commands/worktree/create-input.js +56 -0
  245. package/dist/commands/worktree/create.d.ts +11 -0
  246. package/dist/commands/worktree/create.js +50 -0
  247. package/dist/commands/worktree/index.d.ts +3 -0
  248. package/dist/commands/worktree/index.js +29 -0
  249. package/dist/commands/worktree/ls.d.ts +18 -0
  250. package/dist/commands/worktree/ls.js +73 -0
  251. package/dist/commands/worktree/repository-directory.d.ts +6 -0
  252. package/dist/commands/worktree/repository-directory.js +9 -0
  253. package/dist/index.d.ts +2 -0
  254. package/dist/index.js +6 -0
  255. package/dist/output/index.d.ts +45 -0
  256. package/dist/output/index.js +47 -0
  257. package/dist/output/json.d.ts +11 -0
  258. package/dist/output/json.js +37 -0
  259. package/dist/output/pairing.d.ts +9 -0
  260. package/dist/output/pairing.js +36 -0
  261. package/dist/output/quiet.d.ts +9 -0
  262. package/dist/output/quiet.js +22 -0
  263. package/dist/output/render.d.ts +15 -0
  264. package/dist/output/render.js +84 -0
  265. package/dist/output/table.d.ts +13 -0
  266. package/dist/output/table.js +135 -0
  267. package/dist/output/types.d.ts +73 -0
  268. package/dist/output/types.js +8 -0
  269. package/dist/output/with-output.d.ts +43 -0
  270. package/dist/output/with-output.js +85 -0
  271. package/dist/output/yaml.d.ts +11 -0
  272. package/dist/output/yaml.js +38 -0
  273. package/dist/run.d.ts +14 -0
  274. package/dist/run.js +62 -0
  275. package/dist/ssh/ssh-tunnel.d.ts +2 -0
  276. package/dist/ssh/ssh-tunnel.js +3 -0
  277. package/dist/utils/agent-directory.d.ts +31 -0
  278. package/dist/utils/agent-directory.js +48 -0
  279. package/dist/utils/caller-agent.d.ts +14 -0
  280. package/dist/utils/caller-agent.js +16 -0
  281. package/dist/utils/client-id.d.ts +2 -0
  282. package/dist/utils/client-id.js +31 -0
  283. package/dist/utils/client.d.ts +57 -0
  284. package/dist/utils/client.js +360 -0
  285. package/dist/utils/command-options.d.ts +8 -0
  286. package/dist/utils/command-options.js +49 -0
  287. package/dist/utils/daemon-target.d.ts +13 -0
  288. package/dist/utils/daemon-target.js +51 -0
  289. package/dist/utils/duration.d.ts +7 -0
  290. package/dist/utils/duration.js +39 -0
  291. package/dist/utils/errors.d.ts +5 -0
  292. package/dist/utils/errors.js +10 -0
  293. package/dist/utils/paths.d.ts +12 -0
  294. package/dist/utils/paths.js +22 -0
  295. package/dist/utils/provider-model.d.ts +11 -0
  296. package/dist/utils/provider-model.js +49 -0
  297. package/dist/utils/timeline.d.ts +12 -0
  298. package/dist/utils/timeline.js +16 -0
  299. package/dist/utils/wait-for-stop.d.ts +2 -0
  300. package/dist/utils/wait-for-stop.js +28 -0
  301. package/dist/version.d.ts +5 -0
  302. package/dist/version.js +24 -0
  303. package/package.json +58 -4
  304. package/README.md +0 -3
@@ -0,0 +1,50 @@
1
+ import path from "node:path";
2
+ import { connectToDaemon } from "../../utils/client.js";
3
+ import { buildCreateWorktreeRequest } from "./create-input.js";
4
+ export const createSchema = {
5
+ idField: "worktreePath",
6
+ columns: [
7
+ { header: "NAME", field: "name", width: 24 },
8
+ { header: "BRANCH", field: "branchName", width: 28 },
9
+ { header: "PATH", field: "worktreePath", width: 50 },
10
+ ],
11
+ };
12
+ function cmdError(code, message, details) {
13
+ return details ? { code, message, details } : { code, message };
14
+ }
15
+ export async function runCreateCommand(options, _command) {
16
+ const cwd = options.cwd ?? process.cwd();
17
+ const request = buildCreateWorktreeRequest(options, cwd);
18
+ const client = await connectToDaemon({ target: options.daemonTarget });
19
+ try {
20
+ const response = await client.createMateoWorktree(request);
21
+ const workspace = response.workspace;
22
+ if (!workspace || response.error) {
23
+ throw cmdError("WORKTREE_CREATE_FAILED", `Failed to create worktree: ${response.error ?? "no workspace returned"}`);
24
+ }
25
+ if (!workspace.workspaceDirectory) {
26
+ throw cmdError("WORKTREE_CREATE_FAILED", "Failed to create worktree: workspace directory missing from daemon response");
27
+ }
28
+ const worktreePath = workspace.workspaceDirectory;
29
+ return {
30
+ type: "single",
31
+ data: {
32
+ name: path.basename(worktreePath),
33
+ branchName: workspace.name,
34
+ worktreePath,
35
+ },
36
+ schema: createSchema,
37
+ };
38
+ }
39
+ catch (err) {
40
+ if (err && typeof err === "object" && "code" in err) {
41
+ throw err;
42
+ }
43
+ const message = err instanceof Error ? err.message : String(err);
44
+ throw cmdError("WORKTREE_CREATE_FAILED", `Failed to create worktree: ${message}`);
45
+ }
46
+ finally {
47
+ await client.close().catch(() => { });
48
+ }
49
+ }
50
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function createWorktreeCommand(): Command;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { Command } from "commander";
2
+ import { runLsCommand } from "./ls.js";
3
+ import { runArchiveCommand } from "./archive.js";
4
+ import { runCreateCommand } from "./create.js";
5
+ import { withOutput } from "../../output/index.js";
6
+ import { addJsonAndDaemonHostOptions } from "../../utils/command-options.js";
7
+ export function createWorktreeCommand() {
8
+ const worktree = new Command("worktree").description("Manage Mateo-managed git worktrees");
9
+ addJsonAndDaemonHostOptions(worktree
10
+ .command("ls")
11
+ .description("List Mateo-managed git worktrees")
12
+ .option("--cwd <path>", "Repository directory (default: current)")).action(withOutput(runLsCommand));
13
+ addJsonAndDaemonHostOptions(worktree
14
+ .command("create")
15
+ .description("Create a Mateo-managed git worktree")
16
+ .option("--mode <mode>", "Creation mode: branch-off, checkout-branch, or checkout-pr")
17
+ .option("--new-branch <name>", "New branch name (--mode branch-off)")
18
+ .option("--base <ref>", "Base ref for new branch (--mode branch-off, defaults to repo default)")
19
+ .option("--branch <name>", "Existing branch to check out (--mode checkout-branch)")
20
+ .option("--pr-number <n>", "Pull request number (--mode checkout-pr)")
21
+ .option("--cwd <path>", "Repository directory (default: current)")).action(withOutput(runCreateCommand));
22
+ addJsonAndDaemonHostOptions(worktree
23
+ .command("archive")
24
+ .description("Archive a worktree (removes worktree and associated branch)")
25
+ .argument("<name>", "Worktree name or branch name")
26
+ .option("--cwd <path>", "Repository directory (default: current)")).action(withOutput(runArchiveCommand));
27
+ return worktree;
28
+ }
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,18 @@
1
+ import type { Command } from "commander";
2
+ import type { CommandOptions, ListResult, OutputSchema } from "../../output/index.js";
3
+ /** Worktree list item for display */
4
+ export interface WorktreeListItem {
5
+ name: string;
6
+ branch: string;
7
+ cwd: string;
8
+ agent: string;
9
+ }
10
+ /** Schema for worktree ls output */
11
+ export declare const worktreeLsSchema: OutputSchema<WorktreeListItem>;
12
+ export type WorktreeLsResult = ListResult<WorktreeListItem>;
13
+ export interface WorktreeLsOptions extends CommandOptions {
14
+ host?: string;
15
+ cwd?: string;
16
+ }
17
+ export declare function runLsCommand(options: WorktreeLsOptions, _command: Command): Promise<WorktreeLsResult>;
18
+ //# sourceMappingURL=ls.d.ts.map
@@ -0,0 +1,73 @@
1
+ import { basename } from "node:path";
2
+ import { connectToDaemon } from "../../utils/client.js";
3
+ import { resolveRepositoryDirectory } from "./repository-directory.js";
4
+ /** Shorten home directory in path */
5
+ function shortenPath(path) {
6
+ const home = process.env.HOME;
7
+ if (home && path.startsWith(home)) {
8
+ return "~" + path.slice(home.length);
9
+ }
10
+ return path;
11
+ }
12
+ /** Extract worktree name from path */
13
+ function extractWorktreeName(path) {
14
+ return basename(path);
15
+ }
16
+ /** Schema for worktree ls output */
17
+ export const worktreeLsSchema = {
18
+ idField: "name",
19
+ columns: [
20
+ { header: "NAME", field: "name", width: 20 },
21
+ { header: "BRANCH", field: "branch", width: 25 },
22
+ { header: "CWD", field: "cwd", width: 45 },
23
+ { header: "AGENT", field: "agent", width: 10 },
24
+ ],
25
+ };
26
+ export async function runLsCommand(options, _command) {
27
+ const cwd = resolveRepositoryDirectory(options);
28
+ const client = await connectToDaemon({ target: options.daemonTarget });
29
+ try {
30
+ const agentsPayload = await client.fetchAgents({ filter: { includeArchived: true } });
31
+ const agents = agentsPayload.entries.map((entry) => entry.agent);
32
+ // Get worktree list from daemon
33
+ const response = await client.getMateoWorktreeList({ cwd });
34
+ await client.close();
35
+ if (response.error) {
36
+ const error = {
37
+ code: "WORKTREE_LIST_FAILED",
38
+ message: `Failed to list worktrees: ${response.error.message}`,
39
+ };
40
+ throw error;
41
+ }
42
+ // Build a map of worktree paths to agent IDs
43
+ const worktreeAgentMap = new Map();
44
+ for (const agent of agents) {
45
+ worktreeAgentMap.set(agent.cwd, agent.id.slice(0, 7));
46
+ }
47
+ const items = response.worktrees.map((wt) => ({
48
+ name: extractWorktreeName(wt.worktreePath),
49
+ branch: wt.branchName ?? "-",
50
+ cwd: shortenPath(wt.worktreePath),
51
+ agent: worktreeAgentMap.get(wt.worktreePath) ?? "-",
52
+ }));
53
+ return {
54
+ type: "list",
55
+ data: items,
56
+ schema: worktreeLsSchema,
57
+ };
58
+ }
59
+ catch (err) {
60
+ await client.close().catch(() => { });
61
+ // Re-throw CommandError as-is
62
+ if (err && typeof err === "object" && "code" in err) {
63
+ throw err;
64
+ }
65
+ const message = err instanceof Error ? err.message : String(err);
66
+ const error = {
67
+ code: "WORKTREE_LIST_FAILED",
68
+ message: `Failed to list worktrees: ${message}`,
69
+ };
70
+ throw error;
71
+ }
72
+ }
73
+ //# sourceMappingURL=ls.js.map
@@ -0,0 +1,6 @@
1
+ import type { DaemonTarget } from "../../utils/daemon-target.js";
2
+ export declare function resolveRepositoryDirectory(options: {
3
+ cwd?: string;
4
+ daemonTarget: DaemonTarget;
5
+ }): string;
6
+ //# sourceMappingURL=repository-directory.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { resolve } from "node:path";
2
+ export function resolveRepositoryDirectory(options) {
3
+ const cwd = options.cwd ?? process.cwd();
4
+ if (options.daemonTarget.kind === "instance") {
5
+ return resolve(cwd);
6
+ }
7
+ return cwd;
8
+ }
9
+ //# sourceMappingURL=repository-directory.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import { runCli } from "./run.js";
2
+ const exitCode = await runCli(process.argv.slice(2), {
3
+ nodeArgv: [process.argv[0] ?? "node", process.argv[1] ?? "mateo"],
4
+ });
5
+ process.exitCode = exitCode;
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Output abstraction layer for the Mateo CLI.
3
+ *
4
+ * This module provides structured output rendering with support for multiple formats:
5
+ * - table: Human-readable aligned tables (default)
6
+ * - json: Machine-readable JSON
7
+ * - yaml: Machine-readable YAML
8
+ * - quiet: Minimal output (IDs only)
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { withOutput, render, type ListResult, type OutputSchema } from './output/index.js'
13
+ *
14
+ * // Define your data type
15
+ * interface Agent { id: string; title: string; status: string }
16
+ *
17
+ * // Define how to render it
18
+ * const schema: OutputSchema<Agent> = {
19
+ * idField: 'id',
20
+ * columns: [
21
+ * { header: 'ID', field: 'id' },
22
+ * { header: 'TITLE', field: 'title' },
23
+ * { header: 'STATUS', field: 'status', color: (v) => v === 'running' ? 'green' : undefined },
24
+ * ],
25
+ * }
26
+ *
27
+ * // Return structured data from commands
28
+ * const result: ListResult<Agent> = {
29
+ * type: 'list',
30
+ * data: agents,
31
+ * schema,
32
+ * }
33
+ *
34
+ * // Render with options
35
+ * const output = render(result, { format: 'json' })
36
+ * ```
37
+ */
38
+ export type { OutputFormat, OutputOptions, ColumnDef, OutputSchema, CommandResult, SingleResult, ListResult, AnyCommandResult, CommandError, } from "./types.js";
39
+ export { renderTable, renderTableHeader, renderTableRow } from "./table.js";
40
+ export { renderJson, renderJsonLine } from "./json.js";
41
+ export { renderYaml, renderYamlDoc } from "./yaml.js";
42
+ export { renderQuiet } from "./quiet.js";
43
+ export { render, renderError, toCommandError, defaultOutputOptions } from "./render.js";
44
+ export { withOutput, createOutputOptions, type CommandOptions } from "./with-output.js";
45
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Output abstraction layer for the Mateo CLI.
3
+ *
4
+ * This module provides structured output rendering with support for multiple formats:
5
+ * - table: Human-readable aligned tables (default)
6
+ * - json: Machine-readable JSON
7
+ * - yaml: Machine-readable YAML
8
+ * - quiet: Minimal output (IDs only)
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { withOutput, render, type ListResult, type OutputSchema } from './output/index.js'
13
+ *
14
+ * // Define your data type
15
+ * interface Agent { id: string; title: string; status: string }
16
+ *
17
+ * // Define how to render it
18
+ * const schema: OutputSchema<Agent> = {
19
+ * idField: 'id',
20
+ * columns: [
21
+ * { header: 'ID', field: 'id' },
22
+ * { header: 'TITLE', field: 'title' },
23
+ * { header: 'STATUS', field: 'status', color: (v) => v === 'running' ? 'green' : undefined },
24
+ * ],
25
+ * }
26
+ *
27
+ * // Return structured data from commands
28
+ * const result: ListResult<Agent> = {
29
+ * type: 'list',
30
+ * data: agents,
31
+ * schema,
32
+ * }
33
+ *
34
+ * // Render with options
35
+ * const output = render(result, { format: 'json' })
36
+ * ```
37
+ */
38
+ // Renderers
39
+ export { renderTable, renderTableHeader, renderTableRow } from "./table.js";
40
+ export { renderJson, renderJsonLine } from "./json.js";
41
+ export { renderYaml, renderYamlDoc } from "./yaml.js";
42
+ export { renderQuiet } from "./quiet.js";
43
+ // Main render function
44
+ export { render, renderError, toCommandError, defaultOutputOptions } from "./render.js";
45
+ // Command wrapper
46
+ export { withOutput, createOutputOptions } from "./with-output.js";
47
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,11 @@
1
+ /**
2
+ * JSON renderer for CLI output.
3
+ *
4
+ * Renders structured data as formatted JSON for machine consumption.
5
+ */
6
+ import type { AnyCommandResult, OutputOptions } from "./types.js";
7
+ /** Render command result as JSON */
8
+ export declare function renderJson<T>(result: AnyCommandResult<T>, _options: OutputOptions): string;
9
+ /** Render a single item as JSON line (for NDJSON streaming) */
10
+ export declare function renderJsonLine<T>(item: T, serialize?: (data: T) => unknown): string;
11
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1,37 @@
1
+ /**
2
+ * JSON renderer for CLI output.
3
+ *
4
+ * Renders structured data as formatted JSON for machine consumption.
5
+ */
6
+ /** Render command result as JSON */
7
+ export function renderJson(result, _options) {
8
+ const { schema } = result;
9
+ // Apply custom serializer if provided
10
+ if (schema.serialize) {
11
+ if (result.type === "list") {
12
+ // If all items serialize to the same object, return just one
13
+ // This handles the case where a list of key-value rows should serialize
14
+ // to a single structured object
15
+ const serialized = result.data.map((item) => schema.serialize(item));
16
+ if (serialized.length > 0) {
17
+ const first = JSON.stringify(serialized[0]);
18
+ const allSame = serialized.every((s) => JSON.stringify(s) === first);
19
+ if (allSame) {
20
+ return JSON.stringify(serialized[0], null, 2);
21
+ }
22
+ }
23
+ return JSON.stringify(serialized, null, 2);
24
+ }
25
+ else {
26
+ const serialized = schema.serialize(result.data);
27
+ return JSON.stringify(serialized, null, 2);
28
+ }
29
+ }
30
+ return JSON.stringify(result.data, null, 2);
31
+ }
32
+ /** Render a single item as JSON line (for NDJSON streaming) */
33
+ export function renderJsonLine(item, serialize) {
34
+ const output = serialize ? serialize(item) : item;
35
+ return JSON.stringify(output);
36
+ }
37
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1,9 @@
1
+ interface PairingInstructions {
2
+ url: string;
3
+ qr: string | null;
4
+ connectionUri?: string | null;
5
+ columns?: number;
6
+ }
7
+ export declare function formatPairingInstructions({ url, qr, columns, connectionUri, }: PairingInstructions): string;
8
+ export {};
9
+ //# sourceMappingURL=pairing.d.ts.map
@@ -0,0 +1,36 @@
1
+ const ANSI_PATTERN = new RegExp(`${String.fromCharCode(0x1b)}\\[[0-9;]*m`, "g");
2
+ function visibleWidth(value) {
3
+ return Math.max(...value
4
+ .replace(ANSI_PATTERN, "")
5
+ .split("\n")
6
+ .map((line) => line.length));
7
+ }
8
+ function formatQr(qr, columns) {
9
+ if (!qr) {
10
+ return "QR code is unavailable. Use the pairing link below.";
11
+ }
12
+ if (columns === undefined) {
13
+ return "QR code not shown because terminal width could not be detected.";
14
+ }
15
+ const width = visibleWidth(qr);
16
+ if (columns <= width) {
17
+ return `QR code not shown. Resize the terminal to at least ${width + 1} columns, then run this command again.`;
18
+ }
19
+ return qr;
20
+ }
21
+ function redactConnectionUri(uri) {
22
+ try {
23
+ const parsed = new URL(uri);
24
+ if (parsed.searchParams.has("password")) {
25
+ parsed.searchParams.set("password", "[redacted]");
26
+ }
27
+ return parsed.toString();
28
+ }
29
+ catch {
30
+ return "Invalid connection URI";
31
+ }
32
+ }
33
+ export function formatPairingInstructions({ url, qr, columns, connectionUri, }) {
34
+ return `\nScan to pair:\n${formatQr(qr, columns)}\n\nPairing link:\n${url}${connectionUri ? `\n\nConnection URI:\n${redactConnectionUri(connectionUri)}` : ""}\n\nTreat this pairing link like a password. Anyone with it can access this daemon.\n`;
35
+ }
36
+ //# sourceMappingURL=pairing.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Quiet renderer for CLI output.
3
+ *
4
+ * Outputs only ID fields, one per line. Useful for scripting and pipelines.
5
+ */
6
+ import type { AnyCommandResult, OutputOptions } from "./types.js";
7
+ /** Render command result in quiet mode (IDs only) */
8
+ export declare function renderQuiet<T>(result: AnyCommandResult<T>, _options: OutputOptions): string;
9
+ //# sourceMappingURL=quiet.d.ts.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Quiet renderer for CLI output.
3
+ *
4
+ * Outputs only ID fields, one per line. Useful for scripting and pipelines.
5
+ */
6
+ /** Extract ID from item using schema definition */
7
+ function getId(item, idField) {
8
+ if (typeof idField === "function") {
9
+ return idField(item);
10
+ }
11
+ return String(item[idField]);
12
+ }
13
+ /** Render command result in quiet mode (IDs only) */
14
+ export function renderQuiet(result, _options) {
15
+ if (result.type === "single") {
16
+ return getId(result.data, result.schema.idField);
17
+ }
18
+ else {
19
+ return result.data.map((item) => getId(item, result.schema.idField)).join("\n");
20
+ }
21
+ }
22
+ //# sourceMappingURL=quiet.js.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Main render dispatcher for CLI output.
3
+ *
4
+ * Selects the appropriate renderer based on output options.
5
+ */
6
+ import type { AnyCommandResult, CommandError, OutputOptions } from "./types.js";
7
+ /** Default output options */
8
+ export declare const defaultOutputOptions: OutputOptions;
9
+ /** Render command result to string based on output options */
10
+ export declare function render<T>(result: AnyCommandResult<T>, options?: Partial<OutputOptions>): string;
11
+ /** Convert an unknown error to a CommandError */
12
+ export declare function toCommandError(error: unknown): CommandError;
13
+ /** Render an error to string based on output options */
14
+ export declare function renderError(error: CommandError, options?: Partial<OutputOptions>): string;
15
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Main render dispatcher for CLI output.
3
+ *
4
+ * Selects the appropriate renderer based on output options.
5
+ */
6
+ import chalk from "chalk";
7
+ import YAML from "yaml";
8
+ import { renderTable } from "./table.js";
9
+ import { renderJson } from "./json.js";
10
+ import { renderYaml } from "./yaml.js";
11
+ import { renderQuiet } from "./quiet.js";
12
+ /** Default output options */
13
+ export const defaultOutputOptions = {
14
+ format: "table",
15
+ quiet: false,
16
+ noHeaders: false,
17
+ noColor: false,
18
+ };
19
+ /** Render command result to string based on output options */
20
+ export function render(result, options = {}) {
21
+ const opts = { ...defaultOutputOptions, ...options };
22
+ // Quiet mode takes precedence
23
+ if (opts.quiet) {
24
+ return renderQuiet(result, opts);
25
+ }
26
+ // Dispatch to format-specific renderer
27
+ switch (opts.format) {
28
+ case "json":
29
+ return renderJson(result, opts);
30
+ case "yaml":
31
+ return renderYaml(result, opts);
32
+ case "table":
33
+ default:
34
+ if (result.schema.renderHuman) {
35
+ return result.schema.renderHuman(result, opts);
36
+ }
37
+ return renderTable(result, opts);
38
+ }
39
+ }
40
+ /** Convert an unknown error to a CommandError */
41
+ export function toCommandError(error) {
42
+ if (isCommandError(error)) {
43
+ // Error.message and class getters are not enumerable; materialize the output contract.
44
+ return { ...error, code: error.code, message: error.message, details: error.details };
45
+ }
46
+ if (error instanceof Error) {
47
+ return {
48
+ code: "UNKNOWN_ERROR",
49
+ message: error.message,
50
+ details: error.stack,
51
+ };
52
+ }
53
+ return {
54
+ code: "UNKNOWN_ERROR",
55
+ message: String(error),
56
+ };
57
+ }
58
+ /** Type guard for CommandError */
59
+ function isCommandError(error) {
60
+ return (typeof error === "object" &&
61
+ error !== null &&
62
+ "code" in error &&
63
+ "message" in error &&
64
+ typeof error.code === "string" &&
65
+ typeof error.message === "string");
66
+ }
67
+ /** Render an error to string based on output options */
68
+ export function renderError(error, options = {}) {
69
+ const opts = { ...defaultOutputOptions, ...options };
70
+ if (opts.format === "json") {
71
+ return JSON.stringify({ error }, null, 2);
72
+ }
73
+ if (opts.format === "yaml") {
74
+ return YAML.stringify({ error });
75
+ }
76
+ // Table/default format: human-readable error
77
+ const prefix = opts.noColor ? "Error: " : chalk.red("Error: ");
78
+ const message = error.message;
79
+ if (error.details && typeof error.details === "string") {
80
+ return `${prefix}${message}\n${error.details}`;
81
+ }
82
+ return `${prefix}${message}`;
83
+ }
84
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Table renderer for CLI output.
3
+ *
4
+ * Renders structured data as aligned ASCII tables with optional color support.
5
+ */
6
+ import type { AnyCommandResult, OutputOptions, OutputSchema } from "./types.js";
7
+ /** Render a list result as a table */
8
+ export declare function renderTable<T>(result: AnyCommandResult<T>, options: OutputOptions): string;
9
+ /** Render just a table header (for streaming) */
10
+ export declare function renderTableHeader<T>(schema: OutputSchema<T>, options: OutputOptions, widths?: number[]): string;
11
+ /** Render just a table row (for streaming) */
12
+ export declare function renderTableRow<T>(item: T, schema: OutputSchema<T>, options: OutputOptions, widths?: number[]): string;
13
+ //# sourceMappingURL=table.d.ts.map