@modootoday/pmcp 0.22.13 → 0.24.0

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 (146) 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/CONTRIBUTING.md +8 -0
  6. package/dist/{affected-ZWO2F5EM.js → affected-D6FRJPPI.js} +2 -2
  7. package/dist/{apply-OIKQ5SIY.js → apply-6JVJ7FDZ.js} +21 -20
  8. package/dist/{available-Z5MIDFPH.js → available-74CMIBPD.js} +9 -9
  9. package/dist/{broadcast-BF2QL3O7.js → broadcast-VKZY7WSD.js} +3 -3
  10. package/dist/{chunk-K2VU3B4W.js → chunk-25M2YWBH.js} +4 -4
  11. package/dist/chunk-2GZKA33O.js +173 -0
  12. package/dist/chunk-2HL2MFNI.js +159 -0
  13. package/dist/{chunk-4O4ZOSBQ.js → chunk-2MX5C7B2.js} +3 -3
  14. package/dist/chunk-2W2F5BWF.js +166 -0
  15. package/dist/chunk-43MXRTKH.js +134 -0
  16. package/dist/chunk-4VVQLWTS.js +93 -0
  17. package/dist/{chunk-ZKB7ZNKY.js → chunk-56VBB3H7.js} +4 -4
  18. package/dist/{chunk-JEL35P7S.js → chunk-5NDUWEMW.js} +2 -2
  19. package/dist/{chunk-5PNS6V5C.js → chunk-5QBOGEVE.js} +2 -2
  20. package/dist/{chunk-NNGGNXF2.js → chunk-62BC3K4Z.js} +2 -2
  21. package/dist/{chunk-7ZOQELXR.js → chunk-644GNYMB.js} +3 -3
  22. package/dist/{chunk-GNVME5AD.js → chunk-6UGHVU5B.js} +2 -2
  23. package/dist/{chunk-733WVP2R.js → chunk-7A6QIROT.js} +3 -3
  24. package/dist/{chunk-J3QUG6O5.js → chunk-7CHUMF3E.js} +2 -2
  25. package/dist/{chunk-INT7QLEU.js → chunk-7DJQASH3.js} +25 -6
  26. package/dist/{chunk-VNZTULFD.js → chunk-D2MHB5EF.js} +3 -3
  27. package/dist/{chunk-KEHB4FZP.js → chunk-E2E4HIEN.js} +49 -3
  28. package/dist/{chunk-G4ATQPQI.js → chunk-F3R5HEUB.js} +5 -1
  29. package/dist/{chunk-JW5NMQTU.js → chunk-HES44LTA.js} +4 -4
  30. package/dist/{chunk-RHJEGLYM.js → chunk-HF5D6B2U.js} +45 -6
  31. package/dist/{chunk-5OFQVW2K.js → chunk-HYXOJYVR.js} +2 -2
  32. package/dist/{chunk-UED3RH53.js → chunk-ISGHJHVH.js} +2 -2
  33. package/dist/chunk-JANBBPKP.js +50 -0
  34. package/dist/{chunk-XNML2KIC.js → chunk-JPYQDOEW.js} +3 -3
  35. package/dist/{chunk-ZS5IDQFJ.js → chunk-K6ATERWS.js} +4 -4
  36. package/dist/{chunk-737BENAU.js → chunk-LB2WXBPA.js} +5 -5
  37. package/dist/{chunk-5IZFEVPW.js → chunk-LI3BII4F.js} +2 -2
  38. package/dist/chunk-LTMHE5VL.js +7 -0
  39. package/dist/{chunk-XSWF7APE.js → chunk-OGCJO6HQ.js} +9 -8
  40. package/dist/{chunk-A7XCUR2C.js → chunk-Q6V274OB.js} +8 -6
  41. package/dist/{chunk-ISGBOJT7.js → chunk-QR4GXET7.js} +3 -3
  42. package/dist/chunk-QR6A3TYP.js +315 -0
  43. package/dist/{chunk-FOLA4EUJ.js → chunk-QY2P54Z2.js} +10 -2
  44. package/dist/{chunk-EIDIVIAD.js → chunk-QYLOIM4U.js} +9 -2
  45. package/dist/{chunk-P5D6RKMT.js → chunk-RZYZILU4.js} +5 -3
  46. package/dist/{chunk-A6DARDQ4.js → chunk-S6G7YWNE.js} +2 -2
  47. package/dist/{chunk-24L4MO7H.js → chunk-TIH7JFPJ.js} +2 -2
  48. package/dist/{chunk-5KWDQFVY.js → chunk-UFWW4H6V.js} +7 -8
  49. package/dist/chunk-UVTGY2R3.js +78 -0
  50. package/dist/{chunk-LLT5FQBE.js → chunk-VBVNOLRR.js} +7 -3
  51. package/dist/{chunk-ABTJQ4QV.js → chunk-WBPVNCQO.js} +20 -5
  52. package/dist/{chunk-T4GVN7XO.js → chunk-WNP2BXR7.js} +5 -5
  53. package/dist/{chunk-YGOWIJPE.js → chunk-WZYGM3FR.js} +6 -2
  54. package/dist/chunk-Y6NFETNG.js +232 -0
  55. package/dist/{cli-IHVNE3WL.js → cli-GFDT4YXM.js} +14 -15
  56. package/dist/{cli-FSSYFCV3.js → cli-WWNTQJPV.js} +18 -12
  57. package/dist/cli.js +307 -47
  58. package/dist/{completion-ZTTJVV4C.js → completion-I63UIDZ7.js} +25 -23
  59. package/dist/{diagnostics-XC5L6Z3E.js → diagnostics-RUJZBPNZ.js} +6 -6
  60. package/dist/{doctor-FGDSUBR3.js → doctor-CLUFTEFO.js} +21 -21
  61. package/dist/{entry-NNB2CQLZ.js → entry-QSJCFI5Z.js} +10 -10
  62. package/dist/{exec-mcp-ZU3Z3XT6.js → exec-mcp-AFPUJTN7.js} +9 -9
  63. package/dist/{harness-B7ANLH5M.js → harness-PPM32AI5.js} +26 -44
  64. package/dist/harness-launch-gate.js +4 -4
  65. package/dist/harness-worker.js +6 -6
  66. package/dist/{heavy-IIZBO4YM.js → heavy-TEHP5PHT.js} +112 -27
  67. package/dist/hooks-L4PXVEGR.js +24 -0
  68. package/dist/{host-5P4D7GSE.js → host-LBTL47X7.js} +18 -15
  69. package/dist/{host-XXWQ23LD.js → host-MU2GRH57.js} +7 -7
  70. package/dist/{host-run-AEWHFVQL.js → host-run-IRSAQA5Z.js} +6 -6
  71. package/dist/http.js +1 -1
  72. package/dist/{import-mcp-BQM5DKYH.js → import-mcp-QVPW6A2Q.js} +12 -12
  73. package/dist/index.d.ts +1 -1
  74. package/dist/index.js +11 -10
  75. package/dist/init-46STH6FP.js +14 -0
  76. package/dist/{install-OFVLR7TI.js → install-5JH4DSFF.js} +10 -10
  77. package/dist/{invoke-3BQ5NG3P.js → invoke-I6C6UT6Q.js} +8 -8
  78. package/dist/{list-EU4MJOXA.js → list-HXG6EB7V.js} +12 -12
  79. package/dist/{list-WWYCGD3X.js → list-LV5EKCF6.js} +11 -7
  80. package/dist/{logout-6DFDYJUI.js → logout-SSUXJ6SE.js} +9 -9
  81. package/dist/{logs-BRF6DBKG.js → logs-2JEMSNSG.js} +7 -7
  82. package/dist/{mailbox-QYA2LQSE.js → mailbox-5FVFMQ2J.js} +6 -6
  83. package/dist/{mailbox-AQCTXO3H.js → mailbox-ZHZWZMAY.js} +14 -21
  84. package/dist/{mainline-O5AEHG3J.js → mainline-4XP6ZORU.js} +9 -8
  85. package/dist/{marketplace-TI5HFAHB.js → marketplace-2X3OOEPW.js} +10 -9
  86. package/dist/{mcp-HR5JFUW7.js → mcp-L6X45IOS.js} +4 -4
  87. package/dist/{mcp-4R53HSGY.js → mcp-PBTQ5SJW.js} +2 -2
  88. package/dist/{models-63NQBSV3.js → models-XSF45MCD.js} +9 -5
  89. package/dist/{pause-UF7FQDJX.js → pause-CMZOIHTJ.js} +3 -3
  90. package/dist/{preview-WSESS2UN.js → preview-465CQJBQ.js} +4 -4
  91. package/dist/{project-JXXL24WN.js → project-4JPKU2D7.js} +14 -12
  92. package/dist/{reindex-3GPKAFBW.js → reindex-D62HQAN2.js} +7 -7
  93. package/dist/{report-JUSKQPAC.js → report-UB7MXAUB.js} +10 -10
  94. package/dist/{resume-3WAROOQ3.js → resume-PAKIT4TT.js} +3 -3
  95. package/dist/run-OW7436TY.js +23 -0
  96. package/dist/{run-XRWU4L73.js → run-PMASXIGY.js} +8 -8
  97. package/dist/{serve-OEX5V5CD.js → serve-P3HJN6AF.js} +13 -13
  98. package/dist/{session-YZVX4NGN.js → session-3YVVO2GR.js} +6 -6
  99. package/dist/{setup-SWNAC2C7.js → setup-6AQUOWOH.js} +3 -2
  100. package/dist/{smoke-5BGJXAHX.js → smoke-6X6IXQIQ.js} +4 -4
  101. package/dist/{start-login-MG26NDE3.js → start-login-P7YDRTA3.js} +10 -10
  102. package/dist/{status-GKCIVAAR.js → status-4PYPTYUB.js} +4 -4
  103. package/dist/{status-LH7Q255G.js → status-DAXQKT35.js} +28 -27
  104. package/dist/{status-APADL7O2.js → status-DLGZDYEP.js} +18 -11
  105. package/dist/stdio.js +2 -2
  106. package/dist/{sweep-VTVPDAPY.js → sweep-VURZU6DI.js} +3 -3
  107. package/dist/{test-TK2J3IB7.js → test-H243OTSK.js} +12 -12
  108. package/dist/{tui-YTPHHKCW.js → tui-P6XTSTQO.js} +45 -19
  109. package/dist/{unbroadcast-CH7BAQ2G.js → unbroadcast-7AMLURCG.js} +3 -3
  110. package/dist/{validate-5QVZBE6W.js → validate-YXR7FJJX.js} +11 -9
  111. package/dist/{wait-4HYJJAWO.js → wait-HEODT7KV.js} +3 -3
  112. package/dist/{worker-RBXYAMR4.js → worker-5YJLIGTU.js} +8 -8
  113. package/dist/{worktree-create-FEZNQUQ6.js → worktree-create-FTSLMZWS.js} +2 -2
  114. package/docs/commands.md +65 -29
  115. package/docs/hooks.md +3 -3
  116. package/docs/project-configuration.md +54 -38
  117. package/docs/terminal-workspace.md +2 -0
  118. package/docs/upgrading.md +67 -0
  119. package/gemini-extension.json +2 -2
  120. package/mcp.json +1 -1
  121. package/package.json +5 -5
  122. package/plugin.json +1 -1
  123. package/plugins/pmcp/.claude-plugin/plugin.json +1 -1
  124. package/plugins/pmcp/.mcp.json +1 -1
  125. package/plugins/pmcp/gemini-extension.json +2 -2
  126. package/plugins/pmcp/mcp.json +1 -1
  127. package/plugins/pmcp/plugin.json +1 -1
  128. package/plugins/pmcp/skills/headless-agents-ci-scaffold/SKILL.md +1 -1
  129. package/plugins/pmcp/skills/pmcp-project-init/SKILL.md +1 -1
  130. package/plugins/pmcp/skills/pmcp-sessions-and-git/SKILL.md +3 -2
  131. package/skills/headless-agents-ci-scaffold/SKILL.md +1 -1
  132. package/skills/pmcp-project-init/SKILL.md +1 -1
  133. package/skills/pmcp-sessions-and-git/SKILL.md +3 -2
  134. package/dist/chunk-2P4Z2NUX.js +0 -28
  135. package/dist/chunk-3Y3HDMHA.js +0 -108
  136. package/dist/chunk-74O7KZUH.js +0 -45
  137. package/dist/chunk-BN4XAXMQ.js +0 -65
  138. package/dist/chunk-E3DQB5LS.js +0 -48
  139. package/dist/chunk-JWRZDYB5.js +0 -59
  140. package/dist/chunk-LMUBBIE2.js +0 -83
  141. package/dist/chunk-QBSJL3SP.js +0 -162
  142. package/dist/chunk-VSTUKACC.js +0 -7
  143. package/dist/chunk-WFY7ATSZ.js +0 -116
  144. package/dist/hooks-IEJTW7BV.js +0 -24
  145. package/dist/init-L6GUO3PW.js +0 -14
  146. package/dist/run-VUUQS4WY.js +0 -19
package/dist/cli.js CHANGED
@@ -3,40 +3,105 @@ import {
3
3
  COMMANDS,
4
4
  PLANNED,
5
5
  commandNamed
6
- } from "./chunk-QBSJL3SP.js";
6
+ } from "./chunk-2W2F5BWF.js";
7
7
  import {
8
8
  entryMode
9
9
  } from "./chunk-LMT3PPXJ.js";
10
- import "./chunk-3Y3HDMHA.js";
11
- import "./chunk-2P4Z2NUX.js";
12
- import "./chunk-E3DQB5LS.js";
13
- import "./chunk-JWRZDYB5.js";
14
- import "./chunk-74O7KZUH.js";
15
- import "./chunk-BN4XAXMQ.js";
16
- import "./chunk-G4ATQPQI.js";
17
- import "./chunk-LMUBBIE2.js";
18
- import "./chunk-YGOWIJPE.js";
19
- import "./chunk-ABTJQ4QV.js";
20
- import "./chunk-RHJEGLYM.js";
21
- import "./chunk-LLT5FQBE.js";
22
- import "./chunk-INT7QLEU.js";
23
- import "./chunk-JEL35P7S.js";
24
- import "./chunk-EIDIVIAD.js";
25
- import "./chunk-KEHB4FZP.js";
26
- import "./chunk-XNML2KIC.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";
27
31
  import {
28
32
  ArgumentError,
29
33
  EXIT,
34
+ didYouMean,
30
35
  parseArgs,
31
36
  printCommandHelp,
32
- printHelp
33
- } from "./chunk-WFY7ATSZ.js";
34
- import "./chunk-V4NPDK6X.js";
37
+ printHelp,
38
+ printSubcommandHelp,
39
+ subcommandNamed,
40
+ unknownSubcommand
41
+ } from "./chunk-Y6NFETNG.js";
35
42
  import {
36
43
  VERSION
37
- } from "./chunk-VSTUKACC.js";
44
+ } from "./chunk-LTMHE5VL.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
+ }
38
82
 
39
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
+ }
40
105
  var ESC = String.fromCharCode(27);
41
106
  var CODES = {
42
107
  reset: `${ESC}[0m`,
@@ -61,17 +126,57 @@ var KIND_COLOUR = {
61
126
  info: "cyan",
62
127
  prompt: "cyan"
63
128
  };
64
- 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 {
65
147
  out;
66
148
  err;
67
149
  quiet;
150
+ options;
151
+ view;
152
+ captured;
153
+ noted;
68
154
  colour;
155
+ ascii;
69
156
  constructor(options = {}) {
157
+ this.options = options;
70
158
  this.out = options.stdout ?? process.stdout;
71
159
  this.err = options.stderr ?? process.stderr;
72
160
  this.quiet = options.quiet ?? false;
73
161
  const env = options.env ?? process.env;
74
- 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;
75
180
  }
76
181
  paint(text, ...colours) {
77
182
  if (!this.colour || colours.length === 0) return text;
@@ -79,19 +184,61 @@ var Ui = class {
79
184
  }
80
185
  // Separate diagnostics so redirected data stays machine-readable.
81
186
  data(text) {
187
+ if (this.captured) {
188
+ this.captured.push(text);
189
+ return;
190
+ }
82
191
  this.out.write(text);
83
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
+ }
84
208
  line(text = "") {
85
209
  if (this.quiet) return;
86
- 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}
87
230
  `);
231
+ };
88
232
  }
89
233
  message(kind, text, detail) {
90
234
  const mark = this.paint(SYMBOL[kind], KIND_COLOUR[kind], "bold");
91
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
+ }
92
239
  if (kind === "error" && this.quiet) {
93
- this.err.write(`${mark} ${text}${tail}
94
- `);
240
+ this.err.write(this.text(`${mark} ${text}${tail}
241
+ `));
95
242
  return;
96
243
  }
97
244
  this.line(`${mark} ${text}${tail}`);
@@ -108,21 +255,55 @@ var Ui = class {
108
255
  info(text, detail) {
109
256
  this.message("info", text, detail);
110
257
  }
111
- table(rows, indent = " ") {
112
- 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;
113
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);
114
292
  this.line(
115
- `${indent}${this.paint(left.padEnd(width), "cyan")} ${this.paint(right, "dim")}`
293
+ `${indent}${this.paint(left.padEnd(column), "cyan")} ${this.paint(lines[0] ?? "", "dim")}`
116
294
  );
295
+ for (const line of lines.slice(1))
296
+ this.line(`${pad}${this.paint(line, "dim")}`);
117
297
  }
118
298
  }
119
299
  heading(text) {
120
- this.line(this.paint(text, "bold"));
300
+ this.wrapped(text, "", "bold");
121
301
  }
122
302
  };
123
303
 
124
304
  // src/commands/dispatch.ts
125
305
  var GLOBAL = /* @__PURE__ */ new Set(["-q", "--quiet", "--no-color", "--color"]);
306
+ var VERSION_WORDS = /* @__PURE__ */ new Set(["--version", "-v", "-V", "version"]);
126
307
  function colourChoice(global) {
127
308
  if (global.includes("--no-color")) return { color: false };
128
309
  if (global.includes("--color")) return { color: true };
@@ -146,34 +327,79 @@ function dispatch(argv, options = {}) {
146
327
  return defaultEntry(options, { ui, env, cwd });
147
328
  }
148
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
+ }
149
334
  const named = commandNamed(rest[0]);
150
- if (named) printCommandHelp(ui, named);
151
- if (!named) printHelp(ui, COMMANDS, PLANNED);
335
+ if (named === void 0) return unknownCommand(rest[0], { ui, env, cwd });
336
+ printCommandHelp(ui.results, named);
152
337
  return EXIT.ok;
153
338
  }
154
- 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
+ }
155
344
  ui.data(`${VERSION}
156
345
  `);
157
346
  return EXIT.ok;
158
347
  }
159
348
  if (verb.startsWith("-")) {
160
- 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 });
161
358
  }
162
359
  const command = commandNamed(verb);
163
- if (command === void 0) {
164
- if (PLANNED.includes(verb))
165
- ui.error(`"${verb}" is designed but not implemented yet`);
166
- if (!PLANNED.includes(verb)) ui.error(`unknown command "${verb}"`);
167
- printHelp(ui, COMMANDS, PLANNED);
168
- return EXIT.usage;
169
- }
360
+ if (command === void 0) return unknownCommand(verb, { ui, env, cwd });
170
361
  const own = rest.includes("--") ? rest.slice(0, rest.indexOf("--")) : rest;
171
362
  if (own.includes("--help") || own.includes("-h")) {
172
- printCommandHelp(ui, command);
173
- return EXIT.ok;
363
+ return help(command, positionalWords(own), { ui, env, cwd });
174
364
  }
175
365
  return run(command, rest, { ui, env, cwd });
176
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
+ }
177
403
  function required(name) {
178
404
  const entry = commandNamed(name);
179
405
  if (entry === void 0) throw new Error(`${name} is not registered`);
@@ -191,7 +417,7 @@ async function defaultEntry(options, context) {
191
417
  });
192
418
  if (mode === "server") return run(required("serve"), [], context);
193
419
  if (mode === "terminal") {
194
- const { terminalSupport } = await import("./host-XXWQ23LD.js");
420
+ const { terminalSupport } = await import("./host-MU2GRH57.js");
195
421
  const support = terminalSupport();
196
422
  if (support.supported) return run(required("tui"), [], context);
197
423
  context.ui.info(`Terminal workspace unavailable: ${support.reason}`);
@@ -199,11 +425,25 @@ async function defaultEntry(options, context) {
199
425
  "Run pmcp tui doctor for prerequisites, or pmcp serve for MCP."
200
426
  );
201
427
  }
202
- printHelp(context.ui, COMMANDS, PLANNED);
428
+ printHelp(context.ui.results, COMMANDS, PLANNED);
203
429
  return EXIT.ok;
204
430
  }
205
431
  async function run(entry, argv, context) {
206
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) {
207
447
  try {
208
448
  return await command.run({
209
449
  ...context,
@@ -212,13 +452,33 @@ async function run(entry, argv, context) {
212
452
  } catch (error) {
213
453
  if (error instanceof ArgumentError) {
214
454
  context.ui.error(error.message);
215
- printCommandHelp(context.ui, command);
455
+ context.ui.line(
456
+ `Run ${invocation(context.env)} ${command.name} --help for its usage.`
457
+ );
216
458
  return EXIT.usage;
217
459
  }
218
460
  context.ui.error(error instanceof Error ? error.message : "command failed");
219
461
  return EXIT.failure;
220
462
  }
221
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
+ }
222
482
 
223
483
  // src/cli.ts
224
484
  process.exitCode = await dispatch(process.argv.slice(2));
@@ -1,29 +1,30 @@
1
1
  import {
2
2
  COMMANDS,
3
3
  completionSpec
4
- } from "./chunk-QBSJL3SP.js";
5
- import "./chunk-3Y3HDMHA.js";
6
- import "./chunk-2P4Z2NUX.js";
7
- import "./chunk-E3DQB5LS.js";
8
- import "./chunk-JWRZDYB5.js";
9
- import "./chunk-74O7KZUH.js";
10
- import "./chunk-BN4XAXMQ.js";
11
- import "./chunk-G4ATQPQI.js";
12
- import "./chunk-LMUBBIE2.js";
13
- import "./chunk-YGOWIJPE.js";
14
- import "./chunk-ABTJQ4QV.js";
15
- import "./chunk-RHJEGLYM.js";
16
- import "./chunk-LLT5FQBE.js";
17
- import "./chunk-INT7QLEU.js";
18
- import "./chunk-JEL35P7S.js";
19
- import "./chunk-EIDIVIAD.js";
20
- import "./chunk-KEHB4FZP.js";
21
- import "./chunk-XNML2KIC.js";
4
+ } from "./chunk-2W2F5BWF.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";
22
23
  import {
23
24
  ArgumentError,
24
- EXIT
25
- } from "./chunk-WFY7ATSZ.js";
26
- import "./chunk-V4NPDK6X.js";
25
+ EXIT,
26
+ didYouMean
27
+ } from "./chunk-Y6NFETNG.js";
27
28
 
28
29
  // src/commands/completion/scripts.ts
29
30
  var SHELLS = ["bash", "zsh", "fish"];
@@ -132,7 +133,8 @@ var completionCommand = {
132
133
  run(context) {
133
134
  const [shell, ...extra] = context.args.positional;
134
135
  if (!isShell(shell) || extra.length > 0) {
135
- 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}`);
136
138
  }
137
139
  context.ui.data(completionScript(shell, COMMANDS));
138
140
  return EXIT.ok;
@@ -141,4 +143,4 @@ var completionCommand = {
141
143
  export {
142
144
  completionCommand
143
145
  };
144
- //# sourceMappingURL=completion-ZTTJVV4C.js.map
146
+ //# sourceMappingURL=completion-I63UIDZ7.js.map
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  dependencies
3
- } from "./chunk-NNGGNXF2.js";
3
+ } from "./chunk-62BC3K4Z.js";
4
4
  import {
5
5
  assertNativeHost
6
- } from "./chunk-5IZFEVPW.js";
6
+ } from "./chunk-LI3BII4F.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-733WVP2R.js";
14
- import "./chunk-FOLA4EUJ.js";
13
+ } from "./chunk-7A6QIROT.js";
14
+ import "./chunk-QY2P54Z2.js";
15
15
  import "./chunk-N7ANFMA5.js";
16
16
  import "./chunk-TYY5TYHF.js";
17
17
  import "./chunk-T6C3TSTO.js";
@@ -21,7 +21,7 @@ import "./chunk-IJBSOWHK.js";
21
21
  import "./chunk-XWLMZKH2.js";
22
22
  import {
23
23
  VERSION
24
- } from "./chunk-VSTUKACC.js";
24
+ } from "./chunk-LTMHE5VL.js";
25
25
  import "./chunk-GJXOFDJT.js";
26
26
  import "./chunk-PMJG2CXF.js";
27
27
  import {
@@ -96,4 +96,4 @@ function inspectTerminalHost() {
96
96
  export {
97
97
  inspectTerminalHost
98
98
  };
99
- //# sourceMappingURL=diagnostics-XC5L6Z3E.js.map
99
+ //# sourceMappingURL=diagnostics-RUJZBPNZ.js.map
@@ -1,24 +1,24 @@
1
1
  import {
2
2
  specFrom
3
- } from "./chunk-5KWDQFVY.js";
4
- import "./chunk-J3QUG6O5.js";
3
+ } from "./chunk-UFWW4H6V.js";
4
+ import "./chunk-7CHUMF3E.js";
5
5
  import {
6
6
  doctor,
7
7
  spawnRunner
8
- } from "./chunk-737BENAU.js";
9
- import "./chunk-A6DARDQ4.js";
8
+ } from "./chunk-LB2WXBPA.js";
9
+ import "./chunk-S6G7YWNE.js";
10
10
  import "./chunk-JQVSDPFL.js";
11
11
  import "./chunk-VJFEN6DJ.js";
12
12
  import "./chunk-NHUMPEPV.js";
13
13
  import "./chunk-TIA4SPU2.js";
14
- import "./chunk-ZS5IDQFJ.js";
14
+ import "./chunk-K6ATERWS.js";
15
15
  import "./chunk-ANJMLKBR.js";
16
- import "./chunk-7ZOQELXR.js";
16
+ import "./chunk-644GNYMB.js";
17
17
  import {
18
18
  FEATURES,
19
19
  GUARDS,
20
20
  customEvent
21
- } from "./chunk-K2VU3B4W.js";
21
+ } from "./chunk-25M2YWBH.js";
22
22
  import "./chunk-UYBWUOLR.js";
23
23
  import "./chunk-UKR64U7J.js";
24
24
  import "./chunk-42SO7KYX.js";
@@ -28,7 +28,7 @@ import "./chunk-LFFIQBNY.js";
28
28
  import "./chunk-HQOB7OQS.js";
29
29
  import "./chunk-73AKO4UL.js";
30
30
  import "./chunk-M6X6HVQK.js";
31
- import "./chunk-P5D6RKMT.js";
31
+ import "./chunk-RZYZILU4.js";
32
32
  import "./chunk-SUDG7B6S.js";
33
33
  import "./chunk-3V37OZQH.js";
34
34
  import "./chunk-Z6WRFOFT.js";
@@ -44,18 +44,18 @@ import {
44
44
  } from "./chunk-ARXCYFFZ.js";
45
45
  import {
46
46
  doctorSpec
47
- } from "./chunk-RHJEGLYM.js";
48
- import "./chunk-JEL35P7S.js";
49
- import "./chunk-XNML2KIC.js";
50
- import {
51
- ArgumentError,
52
- many
53
- } from "./chunk-WFY7ATSZ.js";
47
+ } from "./chunk-HF5D6B2U.js";
48
+ import "./chunk-5NDUWEMW.js";
49
+ import "./chunk-JPYQDOEW.js";
54
50
  import {
55
51
  TOOLS
56
52
  } from "./chunk-V4NPDK6X.js";
57
- import "./chunk-733WVP2R.js";
58
- import "./chunk-FOLA4EUJ.js";
53
+ import {
54
+ ArgumentError,
55
+ many
56
+ } from "./chunk-Y6NFETNG.js";
57
+ import "./chunk-7A6QIROT.js";
58
+ import "./chunk-QY2P54Z2.js";
59
59
  import "./chunk-N7ANFMA5.js";
60
60
  import "./chunk-TYY5TYHF.js";
61
61
  import "./chunk-T6C3TSTO.js";
@@ -63,7 +63,7 @@ import "./chunk-FQLCD4HU.js";
63
63
  import "./chunk-GUHOEIHP.js";
64
64
  import "./chunk-IJBSOWHK.js";
65
65
  import "./chunk-XWLMZKH2.js";
66
- import "./chunk-VSTUKACC.js";
66
+ import "./chunk-LTMHE5VL.js";
67
67
  import "./chunk-GJXOFDJT.js";
68
68
  import "./chunk-PMJG2CXF.js";
69
69
  import "./chunk-J6KL3COD.js";
@@ -534,13 +534,13 @@ var doctorCommand = {
534
534
  context.ui.data(`${JSON.stringify({ findings, ...extra }, null, 2)}
535
535
  `);
536
536
  } else {
537
- context.ui.table(
537
+ context.ui.results.table(
538
538
  findings.map((f) => [
539
539
  `${MARKS[f.status]} ${f.tool}`,
540
540
  f.detail ? `${f.check} (${f.detail})` : f.check
541
541
  ])
542
542
  );
543
- printFeatures(context.ui, features);
543
+ printFeatures(context.ui.results, features);
544
544
  }
545
545
  return findings.some((f) => f.status === "fail") ? 1 : 0;
546
546
  }
@@ -548,4 +548,4 @@ var doctorCommand = {
548
548
  export {
549
549
  doctorCommand
550
550
  };
551
- //# sourceMappingURL=doctor-FGDSUBR3.js.map
551
+ //# sourceMappingURL=doctor-CLUFTEFO.js.map