@modootoday/pmcp 0.22.12 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/.agents/plugins/marketplace.json +1 -1
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/.mcp.json +1 -1
  5. package/dist/affected-D6FRJPPI.js +836 -0
  6. package/dist/{apply-LPKZZ6EL.js → apply-3PWUO4J5.js} +27 -22
  7. package/dist/{available-BFXLII4A.js → available-74CMIBPD.js} +9 -9
  8. package/dist/{broadcast-DZGMSZRG.js → broadcast-VKZY7WSD.js} +6 -5
  9. package/dist/chunk-2GZKA33O.js +173 -0
  10. package/dist/chunk-2HL2MFNI.js +159 -0
  11. package/dist/{chunk-OAX6MIOZ.js → chunk-2K4WYN4C.js} +2 -2
  12. package/dist/{chunk-PEMMV5YQ.js → chunk-2MX5C7B2.js} +3 -3
  13. package/dist/{chunk-7I7O7ZNT.js → chunk-3V37OZQH.js} +5 -3
  14. package/dist/chunk-43MXRTKH.js +134 -0
  15. package/dist/chunk-4VVQLWTS.js +93 -0
  16. package/dist/{chunk-DYZVHO2L.js → chunk-5HNLHI5F.js} +2 -2
  17. package/dist/{chunk-JEL35P7S.js → chunk-5NDUWEMW.js} +2 -2
  18. package/dist/chunk-65BW7Y6O.js +40 -0
  19. package/dist/{chunk-HUBJWC7T.js → chunk-6NRLBSEG.js} +7 -7
  20. package/dist/chunk-6QJ3F445.js +166 -0
  21. package/dist/{chunk-2OOWAGBE.js → chunk-72V6U7CZ.js} +3 -3
  22. package/dist/{chunk-RPCIROW7.js → chunk-7CHUMF3E.js} +2 -2
  23. package/dist/{chunk-INT7QLEU.js → chunk-7DJQASH3.js} +25 -6
  24. package/dist/chunk-7IRXUPM2.js +7 -0
  25. package/dist/{chunk-UDVYVRGJ.js → chunk-DNSHJIS4.js} +2 -2
  26. package/dist/{chunk-UMQLIRSU.js → chunk-DZTSCJOZ.js} +3 -3
  27. package/dist/{chunk-KEHB4FZP.js → chunk-E2E4HIEN.js} +49 -3
  28. package/dist/{chunk-SUJCVEBM.js → chunk-EQF64INS.js} +3 -3
  29. package/dist/chunk-F3R5HEUB.js +39 -0
  30. package/dist/chunk-FOLA4EUJ.js +261 -0
  31. package/dist/chunk-FQLCD4HU.js +24 -0
  32. package/dist/{chunk-OEH47H6A.js → chunk-GUHOEIHP.js} +3 -20
  33. package/dist/{chunk-B2WRYGHJ.js → chunk-HES44LTA.js} +5 -5
  34. package/dist/{chunk-RHJEGLYM.js → chunk-HF5D6B2U.js} +45 -6
  35. package/dist/{chunk-R5MT42JS.js → chunk-HYXOJYVR.js} +2 -2
  36. package/dist/chunk-JANBBPKP.js +50 -0
  37. package/dist/{chunk-ITOTOC6Y.js → chunk-JJFPSFDU.js} +3 -3
  38. package/dist/{chunk-XNML2KIC.js → chunk-JPYQDOEW.js} +3 -3
  39. package/dist/{chunk-SPZQRLL5.js → chunk-KYGGQPAH.js} +18 -6
  40. package/dist/{chunk-EX4YXPVW.js → chunk-LGRFYN5T.js} +2 -2
  41. package/dist/{chunk-DP326AER.js → chunk-LO54UUDE.js} +2 -2
  42. package/dist/{chunk-5QKXEWDB.js → chunk-MHKY6TNF.js} +6 -4
  43. package/dist/chunk-N7ANFMA5.js +171 -0
  44. package/dist/{chunk-KPKMEUUH.js → chunk-OGCJO6HQ.js} +9 -8
  45. package/dist/{chunk-N63QCJHX.js → chunk-P25V6NEX.js} +5 -5
  46. package/dist/{chunk-PUIWESU3.js → chunk-Q6V274OB.js} +8 -6
  47. package/dist/chunk-QR6A3TYP.js +315 -0
  48. package/dist/{chunk-EIDIVIAD.js → chunk-QYLOIM4U.js} +9 -2
  49. package/dist/{chunk-MIFPPUWY.js → chunk-RRKA3GF5.js} +4 -4
  50. package/dist/{chunk-7CSUKCU7.js → chunk-RZYZILU4.js} +17 -96
  51. package/dist/{chunk-FODUHLZM.js → chunk-SDQYZDHS.js} +2 -2
  52. package/dist/chunk-SGFTHKKS.js +86 -0
  53. package/dist/chunk-T6C3TSTO.js +99 -0
  54. package/dist/chunk-UVTGY2R3.js +78 -0
  55. package/dist/{chunk-LLT5FQBE.js → chunk-VBVNOLRR.js} +7 -3
  56. package/dist/{chunk-ABTJQ4QV.js → chunk-WBPVNCQO.js} +20 -5
  57. package/dist/{chunk-63RZGEVI.js → chunk-WQBKQTNT.js} +98 -26
  58. package/dist/{chunk-YGOWIJPE.js → chunk-WZYGM3FR.js} +6 -2
  59. package/dist/chunk-Y6NFETNG.js +232 -0
  60. package/dist/{chunk-D5MIZM6L.js → chunk-YRNFMPZB.js} +7 -8
  61. package/dist/{chunk-2GRECE6B.js → chunk-ZXMECZBI.js} +4 -4
  62. package/dist/{cli-34EDFXJA.js → cli-GFDT4YXM.js} +14 -15
  63. package/dist/{cli-JXPJFHUA.js → cli-YWV7FLYO.js} +24 -12
  64. package/dist/cli.js +317 -51
  65. package/dist/{completion-KTECNPVY.js → completion-OKGNN7DE.js} +25 -21
  66. package/dist/{diagnostics-I5VZHK42.js → diagnostics-N4XRRCQG.js} +10 -6
  67. package/dist/{doctor-JJ2VUNHT.js → doctor-3H6UYNEA.js} +27 -23
  68. package/dist/{entry-OT7BN3ID.js → entry-KDLLG6ED.js} +19 -15
  69. package/dist/{exec-mcp-3E4SRJUY.js → exec-mcp-AENALAHJ.js} +15 -11
  70. package/dist/{harness-Q236VJSU.js → harness-GRYTNUF2.js} +26 -44
  71. package/dist/harness-launch-gate.js +8 -4
  72. package/dist/harness-worker.js +10 -6
  73. package/dist/heavy-BGXKJKYB.js +1965 -0
  74. package/dist/hook-body.js +69 -21
  75. package/dist/hooks-V25ANQ4Q.js +24 -0
  76. package/dist/{host-LT5JMUFJ.js → host-4EGPADOJ.js} +11 -7
  77. package/dist/{host-UDC4HVX3.js → host-MLSWY7D7.js} +24 -17
  78. package/dist/{host-run-LD63JGN7.js → host-run-VI52IUKF.js} +10 -6
  79. package/dist/http.js +1 -1
  80. package/dist/{import-mcp-URVONIZ3.js → import-mcp-FIXFLUDM.js} +18 -14
  81. package/dist/index.d.ts +1 -1
  82. package/dist/index.js +17 -12
  83. package/dist/init-ALTBFUPP.js +14 -0
  84. package/dist/{install-7V6NIA7W.js → install-5JH4DSFF.js} +10 -10
  85. package/dist/{invoke-JW5OC2HO.js → invoke-7T7UY57O.js} +12 -8
  86. package/dist/{list-UM4DYJRL.js → list-JFZ7UZLV.js} +18 -14
  87. package/dist/{list-WK2IYUK7.js → list-LV5EKCF6.js} +11 -7
  88. package/dist/{logout-H5X4D26I.js → logout-7CNBO76Z.js} +15 -11
  89. package/dist/{logs-UHJM7ZCL.js → logs-2JEMSNSG.js} +11 -10
  90. package/dist/{mailbox-NIMBOQPA.js → mailbox-5FVFMQ2J.js} +12 -44
  91. package/dist/{mailbox-YN6PG66A.js → mailbox-ZHZWZMAY.js} +14 -21
  92. package/dist/{mainline-74WCH4T4.js → mainline-6PBT3VNR.js} +75 -126
  93. package/dist/{marketplace-G4VQET5W.js → marketplace-2X3OOEPW.js} +10 -9
  94. package/dist/{mcp-6P3MVT4V.js → mcp-MVQVMAKJ.js} +4 -4
  95. package/dist/{mcp-AXHV547W.js → mcp-PBTQ5SJW.js} +2 -2
  96. package/dist/{models-ISU4DCMA.js → models-XSF45MCD.js} +9 -5
  97. package/dist/{pause-CBZ3BTJL.js → pause-CMZOIHTJ.js} +6 -5
  98. package/dist/{preview-DT7DWG5F.js → preview-465CQJBQ.js} +4 -4
  99. package/dist/{project-6QUIC73W.js → project-FZGJRG2U.js} +14 -12
  100. package/dist/{reindex-I7RYWCUR.js → reindex-D62HQAN2.js} +7 -7
  101. package/dist/{report-ZHOHQ4PZ.js → report-UB7MXAUB.js} +14 -13
  102. package/dist/{resume-UJEWQ66P.js → resume-PAKIT4TT.js} +6 -5
  103. package/dist/{run-HQTB7N2R.js → run-TOP37ZQC.js} +14 -10
  104. package/dist/run-VGJDMA2O.js +23 -0
  105. package/dist/{serve-APEVIJD2.js → serve-LR7SJHNH.js} +13 -13
  106. package/dist/{session-YZVX4NGN.js → session-3YVVO2GR.js} +6 -6
  107. package/dist/{setup-SOUBEZ3H.js → setup-6AQUOWOH.js} +7 -4
  108. package/dist/{smoke-2FI5D74B.js → smoke-6X6IXQIQ.js} +4 -4
  109. package/dist/{start-login-ER7DEGYN.js → start-login-X37KGCCB.js} +16 -12
  110. package/dist/{status-KN2ZE64O.js → status-4PYPTYUB.js} +7 -6
  111. package/dist/{status-7NYXRZ3R.js → status-E4AFUOQO.js} +24 -13
  112. package/dist/{status-OGABWCPO.js → status-LBRK37GA.js} +35 -30
  113. package/dist/stdio.js +2 -2
  114. package/dist/{sweep-EPZCW63Q.js → sweep-VURZU6DI.js} +6 -5
  115. package/dist/{test-WRZQERYC.js → test-D2EEFUN2.js} +18 -14
  116. package/dist/{tui-YUHQ36FC.js → tui-D7E3MD3X.js} +45 -19
  117. package/dist/{unbroadcast-N6LXHAMT.js → unbroadcast-7AMLURCG.js} +6 -5
  118. package/dist/{validate-KFBCUFI4.js → validate-YXR7FJJX.js} +11 -9
  119. package/dist/wait-HEODT7KV.js +141 -0
  120. package/dist/{worker-OKBJNDEI.js → worker-WTBC6VYO.js} +12 -8
  121. package/dist/{worktree-create-KMXPQXIQ.js → worktree-create-FTSLMZWS.js} +2 -2
  122. package/docs/commands.md +108 -36
  123. package/docs/git-workflow.md +51 -0
  124. package/docs/hooks.md +11 -4
  125. package/docs/project-configuration.md +136 -20
  126. package/docs/terminal-workspace.md +2 -0
  127. package/docs/upgrading.md +54 -0
  128. package/gemini-extension.json +2 -2
  129. package/mcp.json +1 -1
  130. package/package.json +5 -5
  131. package/plugin.json +1 -1
  132. package/plugins/pmcp/.claude-plugin/plugin.json +1 -1
  133. package/plugins/pmcp/.mcp.json +1 -1
  134. package/plugins/pmcp/gemini-extension.json +2 -2
  135. package/plugins/pmcp/mcp.json +1 -1
  136. package/plugins/pmcp/plugin.json +1 -1
  137. package/plugins/pmcp/skills/headless-agents-ci-scaffold/SKILL.md +1 -1
  138. package/plugins/pmcp/skills/pmcp-project-init/SKILL.md +1 -1
  139. package/plugins/pmcp/skills/pmcp-sessions-and-git/SKILL.md +3 -2
  140. package/skills/headless-agents-ci-scaffold/SKILL.md +1 -1
  141. package/skills/pmcp-project-init/SKILL.md +1 -1
  142. package/skills/pmcp-sessions-and-git/SKILL.md +3 -2
  143. package/dist/chunk-2P4Z2NUX.js +0 -28
  144. package/dist/chunk-3C5FVHQ3.js +0 -7
  145. package/dist/chunk-3Y3HDMHA.js +0 -108
  146. package/dist/chunk-A4PKLESO.js +0 -112
  147. package/dist/chunk-E3DQB5LS.js +0 -48
  148. package/dist/chunk-GFOQDLPL.js +0 -35
  149. package/dist/chunk-JWRZDYB5.js +0 -59
  150. package/dist/chunk-LMUBBIE2.js +0 -83
  151. package/dist/chunk-SMZPYJQI.js +0 -151
  152. package/dist/hooks-PABOEQO6.js +0 -24
  153. package/dist/init-4O24ZNUQ.js +0 -14
  154. package/dist/run-GZK3XJ62.js +0 -19
package/dist/cli.js CHANGED
@@ -1,40 +1,107 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- entryMode
4
- } from "./chunk-LMT3PPXJ.js";
5
2
  import {
6
3
  COMMANDS,
7
4
  PLANNED,
8
5
  commandNamed
9
- } from "./chunk-SMZPYJQI.js";
10
- import "./chunk-2P4Z2NUX.js";
11
- import "./chunk-JWRZDYB5.js";
12
- import "./chunk-3Y3HDMHA.js";
13
- import "./chunk-GFOQDLPL.js";
14
- import "./chunk-E3DQB5LS.js";
15
- import "./chunk-LMUBBIE2.js";
16
- import "./chunk-YGOWIJPE.js";
17
- import "./chunk-ABTJQ4QV.js";
18
- import "./chunk-RHJEGLYM.js";
19
- import "./chunk-LLT5FQBE.js";
20
- import "./chunk-INT7QLEU.js";
21
- import "./chunk-JEL35P7S.js";
22
- import "./chunk-EIDIVIAD.js";
23
- import "./chunk-KEHB4FZP.js";
24
- import "./chunk-XNML2KIC.js";
6
+ } from "./chunk-6QJ3F445.js";
7
+ import {
8
+ entryMode
9
+ } from "./chunk-LMT3PPXJ.js";
10
+ import "./chunk-QR6A3TYP.js";
11
+ import "./chunk-JANBBPKP.js";
12
+ import "./chunk-UVTGY2R3.js";
13
+ import "./chunk-2HL2MFNI.js";
14
+ import "./chunk-4VVQLWTS.js";
15
+ import "./chunk-43MXRTKH.js";
16
+ import "./chunk-F3R5HEUB.js";
17
+ import "./chunk-2GZKA33O.js";
18
+ import "./chunk-WZYGM3FR.js";
19
+ import "./chunk-WBPVNCQO.js";
20
+ import "./chunk-HF5D6B2U.js";
21
+ import "./chunk-VBVNOLRR.js";
22
+ import "./chunk-7DJQASH3.js";
23
+ import "./chunk-5NDUWEMW.js";
24
+ import "./chunk-QYLOIM4U.js";
25
+ import {
26
+ invocation
27
+ } from "./chunk-J7UYNJCR.js";
28
+ import "./chunk-E2E4HIEN.js";
29
+ import "./chunk-JPYQDOEW.js";
30
+ import "./chunk-V4NPDK6X.js";
25
31
  import {
26
32
  ArgumentError,
27
33
  EXIT,
34
+ didYouMean,
28
35
  parseArgs,
29
36
  printCommandHelp,
30
- printHelp
31
- } from "./chunk-A4PKLESO.js";
32
- import "./chunk-V4NPDK6X.js";
37
+ printHelp,
38
+ printSubcommandHelp,
39
+ subcommandNamed,
40
+ unknownSubcommand
41
+ } from "./chunk-Y6NFETNG.js";
33
42
  import {
34
43
  VERSION
35
- } from "./chunk-3C5FVHQ3.js";
44
+ } from "./chunk-7IRXUPM2.js";
45
+
46
+ // src/cli/envelope.ts
47
+ var CODE_NAMES = {
48
+ 1: "failure",
49
+ 2: "usage",
50
+ 3: "missing_optional",
51
+ 4: "differences",
52
+ 75: "busy"
53
+ };
54
+ function exitName(code) {
55
+ return CODE_NAMES[code] ?? "failure";
56
+ }
57
+ function schemaName(words) {
58
+ return `pmcp.${words.join(".")}.v1`;
59
+ }
60
+ function parseData(text) {
61
+ const trimmed = text.trim();
62
+ if (trimmed === "") return null;
63
+ try {
64
+ return JSON.parse(trimmed);
65
+ } catch {
66
+ const lines = trimmed.split("\n").filter((line) => line.trim() !== "");
67
+ try {
68
+ return lines.map((line) => JSON.parse(line));
69
+ } catch {
70
+ return trimmed;
71
+ }
72
+ }
73
+ }
74
+ function envelope(words, code, printed, messages) {
75
+ return {
76
+ schema: schemaName(words),
77
+ ok: code === 0,
78
+ data: parseData(printed),
79
+ errors: messages.map((message) => ({ code: exitName(code), message }))
80
+ };
81
+ }
36
82
 
37
83
  // src/cli/ui.ts
84
+ var HELP_WIDTH = 80;
85
+ var MIN_DESCRIBE = 20;
86
+ function clampWidth(columns) {
87
+ return Math.min(120, Math.max(40, columns));
88
+ }
89
+ function wrap(text, width, indent) {
90
+ if (width === void 0) return [text];
91
+ const room = Math.max(1, width - indent);
92
+ const lines = [];
93
+ let current = "";
94
+ for (const word of text.split(/ +/u)) {
95
+ if (current === "") current = word;
96
+ else if (current.length + 1 + word.length <= room) current += ` ${word}`;
97
+ else {
98
+ lines.push(current);
99
+ current = word;
100
+ }
101
+ }
102
+ lines.push(current);
103
+ return lines;
104
+ }
38
105
  var ESC = String.fromCharCode(27);
39
106
  var CODES = {
40
107
  reset: `${ESC}[0m`,
@@ -59,17 +126,57 @@ var KIND_COLOUR = {
59
126
  info: "cyan",
60
127
  prompt: "cyan"
61
128
  };
62
- var Ui = class {
129
+ var ASCII = {
130
+ "\xB7": "/",
131
+ "\u2026": "...",
132
+ "\u2717": "x"
133
+ };
134
+ function colourFrom(env, tty) {
135
+ const force = env["FORCE_COLOR"];
136
+ if (force !== void 0 && force !== "") {
137
+ return force !== "0" && force !== "false";
138
+ }
139
+ return tty && (env["NO_COLOR"] ?? "") === "" && env["TERM"] !== "dumb";
140
+ }
141
+ function asciiOnly(env) {
142
+ if (env["TERM"] === "dumb") return true;
143
+ const locale = env["LC_ALL"] || env["LC_CTYPE"] || env["LANG"] || "";
144
+ return locale !== "" && !/utf-?8/iu.test(locale);
145
+ }
146
+ var Ui = class _Ui {
63
147
  out;
64
148
  err;
65
149
  quiet;
150
+ options;
151
+ view;
152
+ captured;
153
+ noted;
66
154
  colour;
155
+ ascii;
67
156
  constructor(options = {}) {
157
+ this.options = options;
68
158
  this.out = options.stdout ?? process.stdout;
69
159
  this.err = options.stderr ?? process.stderr;
70
160
  this.quiet = options.quiet ?? false;
71
161
  const env = options.env ?? process.env;
72
- this.colour = options.color ?? (this.err.isTTY === true && (env["NO_COLOR"] ?? "") === "" && env["TERM"] !== "dumb");
162
+ this.colour = options.color ?? colourFrom(env, this.err.isTTY === true);
163
+ this.ascii = asciiOnly(env);
164
+ }
165
+ // The same formatting aimed at stdout and never silenced: a command's result, which
166
+ // -q must not erase and a pipe must receive. Diagnostics stay on this Ui (stderr).
167
+ get results() {
168
+ const stdout = {
169
+ write: (text) => this.data(text),
170
+ isTTY: this.out.isTTY === true,
171
+ ...this.out.columns ? { columns: this.out.columns } : {}
172
+ };
173
+ this.view ??= new _Ui({
174
+ ...this.options,
175
+ stdout,
176
+ stderr: stdout,
177
+ quiet: false
178
+ });
179
+ return this.view;
73
180
  }
74
181
  paint(text, ...colours) {
75
182
  if (!this.colour || colours.length === 0) return text;
@@ -77,19 +184,61 @@ var Ui = class {
77
184
  }
78
185
  // Separate diagnostics so redirected data stays machine-readable.
79
186
  data(text) {
187
+ if (this.captured) {
188
+ this.captured.push(text);
189
+ return;
190
+ }
80
191
  this.out.write(text);
81
192
  }
193
+ // Under --json the command's stdout is held and its errors noted, so one envelope
194
+ // can carry both; release() hands them back and writes again go straight out.
195
+ capture() {
196
+ this.captured = [];
197
+ this.noted = [];
198
+ }
199
+ release() {
200
+ const result = {
201
+ printed: (this.captured ?? []).join(""),
202
+ errors: this.noted ?? []
203
+ };
204
+ this.captured = void 0;
205
+ this.noted = void 0;
206
+ return result;
207
+ }
82
208
  line(text = "") {
83
209
  if (this.quiet) return;
84
- this.err.write(`${text}
210
+ this.err.write(`${this.text(text)}
211
+ `);
212
+ }
213
+ // Replace the few typographic characters pmcp prints when the terminal cannot show them.
214
+ text(value) {
215
+ if (!this.ascii) return value;
216
+ return value.replace(/[—–·…✗]/gu, (char) => ASCII[char] ?? "-");
217
+ }
218
+ // k of N on one rewritten line on a TTY; elsewhere a plain line every tenth, so logs stay readable.
219
+ progress(total, label) {
220
+ const step = Math.max(1, Math.ceil(total / 10));
221
+ const tty = this.err.isTTY === true;
222
+ return (done) => {
223
+ if (this.quiet || total === 0) return;
224
+ const text = ` ${done}/${total} ${label}`;
225
+ if (tty) {
226
+ this.err.write(`\r${text}${ESC}[K${done === total ? "\n" : ""}`);
227
+ return;
228
+ }
229
+ if (done === total || done % step === 0) this.err.write(`${text}
85
230
  `);
231
+ };
86
232
  }
87
233
  message(kind, text, detail) {
88
234
  const mark = this.paint(SYMBOL[kind], KIND_COLOUR[kind], "bold");
89
235
  const tail = detail === void 0 ? "" : ` ${this.paint(detail, "dim")}`;
236
+ if (kind === "error" && this.noted) {
237
+ this.noted.push(detail === void 0 ? text : `${text}: ${detail}`);
238
+ }
90
239
  if (kind === "error" && this.quiet) {
91
- this.err.write(`${mark} ${text}${tail}
92
- `);
240
+ this.err.write(this.text(`${mark} ${text}${tail}
241
+ `));
93
242
  return;
94
243
  }
95
244
  this.line(`${mark} ${text}${tail}`);
@@ -106,29 +255,66 @@ var Ui = class {
106
255
  info(text, detail) {
107
256
  this.message("info", text, detail);
108
257
  }
109
- table(rows, indent = " ") {
110
- const width = rows.reduce((n, [left]) => Math.max(n, left.length), 0);
258
+ // Help wraps at the terminal width, or 80 off a terminal; a table off a terminal is
259
+ // one plain record per line so grep and cut see whole records.
260
+ width(kind) {
261
+ const env = this.options.env ?? process.env;
262
+ const columns = Number.parseInt(env["COLUMNS"] ?? "", 10);
263
+ if (Number.isFinite(columns) && columns > 0) return clampWidth(columns);
264
+ if (this.err.isTTY === true) return clampWidth(this.err.columns || 80);
265
+ return kind === "help" ? HELP_WIDTH : void 0;
266
+ }
267
+ // A paragraph wrapped to the width, continuation lines under the first word.
268
+ wrapped(text, indent = " ", ...colours) {
269
+ for (const line of wrap(text, this.width("help"), indent.length))
270
+ this.line(`${indent}${this.paint(line, ...colours)}`);
271
+ }
272
+ table(rows, indent = " ", width = this.width("table")) {
273
+ if (width === void 0) {
274
+ for (const [left, right] of rows)
275
+ this.line(
276
+ `${indent}${this.paint(left, "cyan")} ${this.paint(right, "dim")}`
277
+ );
278
+ return;
279
+ }
280
+ const longest = rows.reduce((n, [left]) => Math.max(n, left.length), 0);
281
+ const column = Math.min(longest, Math.floor(width * 0.4));
282
+ const room = width - indent.length - column - 2;
111
283
  for (const [left, right] of rows) {
284
+ if (left.length > column || room < MIN_DESCRIBE) {
285
+ this.line(`${indent}${this.paint(left, "cyan")}`);
286
+ for (const line of wrap(right, width, indent.length + 4))
287
+ this.line(`${indent} ${this.paint(line, "dim")}`);
288
+ continue;
289
+ }
290
+ const lines = wrap(right, room, 0);
291
+ const pad = " ".repeat(indent.length + column + 2);
112
292
  this.line(
113
- `${indent}${this.paint(left.padEnd(width), "cyan")} ${this.paint(right, "dim")}`
293
+ `${indent}${this.paint(left.padEnd(column), "cyan")} ${this.paint(lines[0] ?? "", "dim")}`
114
294
  );
295
+ for (const line of lines.slice(1))
296
+ this.line(`${pad}${this.paint(line, "dim")}`);
115
297
  }
116
298
  }
117
299
  heading(text) {
118
- this.line(this.paint(text, "bold"));
300
+ this.wrapped(text, "", "bold");
119
301
  }
120
302
  };
121
303
 
122
304
  // src/commands/dispatch.ts
123
305
  var GLOBAL = /* @__PURE__ */ new Set(["-q", "--quiet", "--no-color", "--color"]);
306
+ var VERSION_WORDS = /* @__PURE__ */ new Set(["--version", "-v", "-V", "version"]);
124
307
  function colourChoice(global) {
125
308
  if (global.includes("--no-color")) return { color: false };
126
309
  if (global.includes("--color")) return { color: true };
127
310
  return {};
128
311
  }
129
312
  function dispatch(argv, options = {}) {
130
- const global = argv.filter((arg) => GLOBAL.has(arg));
131
- const rest0 = argv.filter((arg) => !GLOBAL.has(arg));
313
+ const cut = argv.indexOf("--");
314
+ const head = cut < 0 ? argv : argv.slice(0, cut);
315
+ const tail = cut < 0 ? [] : argv.slice(cut);
316
+ const global = head.filter((arg) => GLOBAL.has(arg));
317
+ const rest0 = [...head.filter((arg) => !GLOBAL.has(arg)), ...tail];
132
318
  const env = options.env ?? process.env;
133
319
  const cwd = options.cwd ?? process.cwd();
134
320
  const ui = options.ui ?? new Ui({
@@ -141,33 +327,79 @@ function dispatch(argv, options = {}) {
141
327
  return defaultEntry(options, { ui, env, cwd });
142
328
  }
143
329
  if (verb === "--help" || verb === "-h" || verb === "help") {
330
+ if (rest[0] === void 0) {
331
+ printHelp(ui.results, COMMANDS, PLANNED);
332
+ return EXIT.ok;
333
+ }
144
334
  const named = commandNamed(rest[0]);
145
- if (named) printCommandHelp(ui, named);
146
- if (!named) printHelp(ui, COMMANDS, PLANNED);
335
+ if (named === void 0) return unknownCommand(rest[0], { ui, env, cwd });
336
+ printCommandHelp(ui.results, named);
147
337
  return EXIT.ok;
148
338
  }
149
- if (verb === "--version") {
339
+ if (VERSION_WORDS.has(verb)) {
340
+ if (rest.length > 0) {
341
+ ui.error(`${verb} takes no arguments, got ${rest[0]}`);
342
+ return EXIT.usage;
343
+ }
150
344
  ui.data(`${VERSION}
151
345
  `);
152
346
  return EXIT.ok;
153
347
  }
154
348
  if (verb.startsWith("-")) {
155
- return run(required("serve"), rest0, { ui, env, cwd });
349
+ const serve = required("serve");
350
+ if (!leadsServe(verb, serve)) {
351
+ const name = verb.split("=")[0];
352
+ const known = ["--version", "--help", "--quiet", "--color", "--no-color"];
353
+ ui.error(`unknown option ${name}${didYouMean(name, known, plain)}`);
354
+ ui.line(`Run ${invocation(env)} --help for the commands and options.`);
355
+ return EXIT.usage;
356
+ }
357
+ return run(serve, rest0, { ui, env, cwd });
156
358
  }
157
359
  const command = commandNamed(verb);
158
- if (command === void 0) {
159
- if (PLANNED.includes(verb))
160
- ui.error(`"${verb}" is designed but not implemented yet`);
161
- if (!PLANNED.includes(verb)) ui.error(`unknown command "${verb}"`);
162
- printHelp(ui, COMMANDS, PLANNED);
163
- return EXIT.usage;
164
- }
165
- if (rest.includes("--help") || rest.includes("-h")) {
166
- printCommandHelp(ui, command);
167
- return EXIT.ok;
360
+ if (command === void 0) return unknownCommand(verb, { ui, env, cwd });
361
+ const own = rest.includes("--") ? rest.slice(0, rest.indexOf("--")) : rest;
362
+ if (own.includes("--help") || own.includes("-h")) {
363
+ return help(command, positionalWords(own), { ui, env, cwd });
168
364
  }
169
365
  return run(command, rest, { ui, env, cwd });
170
366
  }
367
+ function help(command, words, context) {
368
+ const subs = command.subcommands ?? [];
369
+ const sub = subcommandNamed(command, words);
370
+ if (sub !== void 0) {
371
+ printSubcommandHelp(context.ui.results, command, sub);
372
+ return EXIT.ok;
373
+ }
374
+ const group = subs.some((entry) => entry.name.startsWith(`${words[0]} `));
375
+ if (words.length === 0 || subs.length === 0 || group) {
376
+ printCommandHelp(context.ui.results, command);
377
+ return EXIT.ok;
378
+ }
379
+ const names = subs.map((entry) => entry.name);
380
+ context.ui.error(unknownSubcommand(command.name, words[0], names).message);
381
+ context.ui.line(
382
+ `Run ${invocation(context.env)} ${command.name} --help for its subcommands.`
383
+ );
384
+ return EXIT.usage;
385
+ }
386
+ var plain = (word) => word;
387
+ function unknownCommand(verb, context) {
388
+ if (PLANNED.includes(verb)) {
389
+ context.ui.error(`"${verb}" is designed but not implemented yet`);
390
+ } else {
391
+ const names = COMMANDS.map((command) => command.name);
392
+ context.ui.error(`unknown command "${verb}"${didYouMean(verb, names)}`);
393
+ }
394
+ context.ui.line(`Run ${invocation(context.env)} --help for the commands.`);
395
+ return EXIT.usage;
396
+ }
397
+ function leadsServe(arg, serve) {
398
+ if (!arg.startsWith("--")) return false;
399
+ const eq = arg.indexOf("=");
400
+ const name = eq === -1 ? arg.slice(2) : arg.slice(2, eq);
401
+ return (serve.options ?? []).some((option) => option.name === name);
402
+ }
171
403
  function required(name) {
172
404
  const entry = commandNamed(name);
173
405
  if (entry === void 0) throw new Error(`${name} is not registered`);
@@ -185,7 +417,7 @@ async function defaultEntry(options, context) {
185
417
  });
186
418
  if (mode === "server") return run(required("serve"), [], context);
187
419
  if (mode === "terminal") {
188
- const { terminalSupport } = await import("./host-LT5JMUFJ.js");
420
+ const { terminalSupport } = await import("./host-4EGPADOJ.js");
189
421
  const support = terminalSupport();
190
422
  if (support.supported) return run(required("tui"), [], context);
191
423
  context.ui.info(`Terminal workspace unavailable: ${support.reason}`);
@@ -193,11 +425,25 @@ async function defaultEntry(options, context) {
193
425
  "Run pmcp tui doctor for prerequisites, or pmcp serve for MCP."
194
426
  );
195
427
  }
196
- printHelp(context.ui, COMMANDS, PLANNED);
428
+ printHelp(context.ui.results, COMMANDS, PLANNED);
197
429
  return EXIT.ok;
198
430
  }
199
431
  async function run(entry, argv, context) {
200
432
  const command = await entry.load();
433
+ const own = argv.includes("--") ? argv.slice(0, argv.indexOf("--")) : argv;
434
+ const json = own.includes("--json") && command.protocol !== true;
435
+ if (json) context.ui.capture();
436
+ const code = await runCaught(command, argv, context);
437
+ if (!json) return code;
438
+ const { printed, errors } = context.ui.release();
439
+ const words = schemaWords(command, positionalWords(own));
440
+ context.ui.data(
441
+ `${JSON.stringify(envelope(words, code, printed, errors))}
442
+ `
443
+ );
444
+ return code;
445
+ }
446
+ async function runCaught(command, argv, context) {
201
447
  try {
202
448
  return await command.run({
203
449
  ...context,
@@ -206,13 +452,33 @@ async function run(entry, argv, context) {
206
452
  } catch (error) {
207
453
  if (error instanceof ArgumentError) {
208
454
  context.ui.error(error.message);
209
- printCommandHelp(context.ui, command);
455
+ context.ui.line(
456
+ `Run ${invocation(context.env)} ${command.name} --help for its usage.`
457
+ );
210
458
  return EXIT.usage;
211
459
  }
212
460
  context.ui.error(error instanceof Error ? error.message : "command failed");
213
461
  return EXIT.failure;
214
462
  }
215
463
  }
464
+ function positionalWords(argv) {
465
+ const words = [];
466
+ for (const arg of argv) {
467
+ if (arg.startsWith("-")) break;
468
+ words.push(arg);
469
+ }
470
+ return words;
471
+ }
472
+ function schemaWords(command, words) {
473
+ const names = (command.subcommands ?? []).map((sub) => sub.name);
474
+ const two = words.slice(0, 2).join(" ");
475
+ const one = words[0];
476
+ if (names.includes(two)) return [command.name, ...two.split(" ")];
477
+ if (one !== void 0 && names.includes(one)) return [command.name, one];
478
+ if (one === void 0 && command.defaultSubcommand !== void 0)
479
+ return [command.name, command.defaultSubcommand];
480
+ return [command.name];
481
+ }
216
482
 
217
483
  // src/cli.ts
218
484
  process.exitCode = await dispatch(process.argv.slice(2));
@@ -1,27 +1,30 @@
1
1
  import {
2
2
  COMMANDS,
3
3
  completionSpec
4
- } from "./chunk-SMZPYJQI.js";
5
- import "./chunk-2P4Z2NUX.js";
6
- import "./chunk-JWRZDYB5.js";
7
- import "./chunk-3Y3HDMHA.js";
8
- import "./chunk-GFOQDLPL.js";
9
- import "./chunk-E3DQB5LS.js";
10
- import "./chunk-LMUBBIE2.js";
11
- import "./chunk-YGOWIJPE.js";
12
- import "./chunk-ABTJQ4QV.js";
13
- import "./chunk-RHJEGLYM.js";
14
- import "./chunk-LLT5FQBE.js";
15
- import "./chunk-INT7QLEU.js";
16
- import "./chunk-JEL35P7S.js";
17
- import "./chunk-EIDIVIAD.js";
18
- import "./chunk-KEHB4FZP.js";
19
- import "./chunk-XNML2KIC.js";
4
+ } from "./chunk-6QJ3F445.js";
5
+ import "./chunk-QR6A3TYP.js";
6
+ import "./chunk-JANBBPKP.js";
7
+ import "./chunk-UVTGY2R3.js";
8
+ import "./chunk-2HL2MFNI.js";
9
+ import "./chunk-4VVQLWTS.js";
10
+ import "./chunk-43MXRTKH.js";
11
+ import "./chunk-F3R5HEUB.js";
12
+ import "./chunk-2GZKA33O.js";
13
+ import "./chunk-WZYGM3FR.js";
14
+ import "./chunk-WBPVNCQO.js";
15
+ import "./chunk-HF5D6B2U.js";
16
+ import "./chunk-VBVNOLRR.js";
17
+ import "./chunk-7DJQASH3.js";
18
+ import "./chunk-5NDUWEMW.js";
19
+ import "./chunk-QYLOIM4U.js";
20
+ import "./chunk-E2E4HIEN.js";
21
+ import "./chunk-JPYQDOEW.js";
22
+ import "./chunk-V4NPDK6X.js";
20
23
  import {
21
24
  ArgumentError,
22
- EXIT
23
- } from "./chunk-A4PKLESO.js";
24
- import "./chunk-V4NPDK6X.js";
25
+ EXIT,
26
+ didYouMean
27
+ } from "./chunk-Y6NFETNG.js";
25
28
 
26
29
  // src/commands/completion/scripts.ts
27
30
  var SHELLS = ["bash", "zsh", "fish"];
@@ -130,7 +133,8 @@ var completionCommand = {
130
133
  run(context) {
131
134
  const [shell, ...extra] = context.args.positional;
132
135
  if (!isShell(shell) || extra.length > 0) {
133
- throw new ArgumentError(`choose one shell: ${SHELLS.join(", ")}`);
136
+ const hint = shell === void 0 ? "" : didYouMean(shell, SHELLS);
137
+ throw new ArgumentError(`choose one shell: ${SHELLS.join(", ")}${hint}`);
134
138
  }
135
139
  context.ui.data(completionScript(shell, COMMANDS));
136
140
  return EXIT.ok;
@@ -139,4 +143,4 @@ var completionCommand = {
139
143
  export {
140
144
  completionCommand
141
145
  };
142
- //# sourceMappingURL=completion-KTECNPVY.js.map
146
+ //# sourceMappingURL=completion-OKGNN7DE.js.map
@@ -1,23 +1,27 @@
1
1
  import {
2
2
  dependencies
3
- } from "./chunk-EX4YXPVW.js";
3
+ } from "./chunk-LGRFYN5T.js";
4
4
  import {
5
5
  assertNativeHost
6
- } from "./chunk-FODUHLZM.js";
6
+ } from "./chunk-SDQYZDHS.js";
7
7
  import {
8
8
  locateExecutable
9
9
  } from "./chunk-R2GPCZUX.js";
10
10
  import "./chunk-34DECPVC.js";
11
11
  import {
12
12
  missingBinary
13
- } from "./chunk-SPZQRLL5.js";
13
+ } from "./chunk-KYGGQPAH.js";
14
+ import "./chunk-FOLA4EUJ.js";
15
+ import "./chunk-N7ANFMA5.js";
14
16
  import "./chunk-TYY5TYHF.js";
15
- import "./chunk-OEH47H6A.js";
17
+ import "./chunk-T6C3TSTO.js";
18
+ import "./chunk-FQLCD4HU.js";
19
+ import "./chunk-GUHOEIHP.js";
16
20
  import "./chunk-IJBSOWHK.js";
17
21
  import "./chunk-XWLMZKH2.js";
18
22
  import {
19
23
  VERSION
20
- } from "./chunk-3C5FVHQ3.js";
24
+ } from "./chunk-7IRXUPM2.js";
21
25
  import "./chunk-GJXOFDJT.js";
22
26
  import "./chunk-PMJG2CXF.js";
23
27
  import {
@@ -92,4 +96,4 @@ function inspectTerminalHost() {
92
96
  export {
93
97
  inspectTerminalHost
94
98
  };
95
- //# sourceMappingURL=diagnostics-I5VZHK42.js.map
99
+ //# sourceMappingURL=diagnostics-N4XRRCQG.js.map