@indigoai-us/hq-cli 5.50.0 → 5.50.2

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 (46) hide show
  1. package/dist/commands/mcp-registration.d.ts +905 -0
  2. package/dist/commands/mcp-registration.js +2001 -0
  3. package/dist/commands/mcp-status.d.ts +130 -0
  4. package/dist/commands/mcp-status.js +406 -0
  5. package/dist/commands/onboard-warning.d.ts +7 -0
  6. package/dist/commands/onboard-warning.js +14 -0
  7. package/dist/commands/onboard.js +5 -5
  8. package/dist/commands/pack-install.d.ts +74 -0
  9. package/dist/commands/pack-install.js +493 -14
  10. package/dist/commands/packs.js +42 -4
  11. package/dist/commands/pkg-install.js +5 -2
  12. package/dist/index.js +7 -2
  13. package/dist/types.d.ts +26 -1
  14. package/dist/utils/contribution-table.d.ts +103 -0
  15. package/dist/utils/contribution-table.js +65 -0
  16. package/dist/utils/pack-contributions.d.ts +93 -10
  17. package/dist/utils/pack-contributions.js +140 -48
  18. package/dist/utils/secrets-cache.d.ts +9 -0
  19. package/dist/utils/secrets-cache.js +24 -2
  20. package/dist/utils/version-gate.d.ts +40 -1
  21. package/dist/utils/version-gate.js +91 -20
  22. package/package.json +3 -2
  23. package/scripts/generate-scan-packages-table.mjs +113 -0
  24. package/src/commands/mcp-registration.test.ts +2787 -0
  25. package/src/commands/mcp-registration.ts +2612 -0
  26. package/src/commands/mcp-status.test.ts +483 -0
  27. package/src/commands/mcp-status.ts +575 -0
  28. package/src/commands/mcp-status.us011.test.ts +243 -0
  29. package/src/commands/onboard-warning.test.ts +26 -0
  30. package/src/commands/onboard-warning.ts +12 -0
  31. package/src/commands/onboard.ts +4 -7
  32. package/src/commands/pack-install.test.ts +733 -0
  33. package/src/commands/pack-install.ts +582 -13
  34. package/src/commands/packs.ts +45 -1
  35. package/src/commands/pkg-install.ts +4 -1
  36. package/src/index.ts +6 -0
  37. package/src/types.ts +28 -9
  38. package/src/utils/contribution-table.ts +83 -0
  39. package/src/utils/pack-contributions.test.ts +310 -25
  40. package/src/utils/pack-contributions.ts +194 -47
  41. package/src/utils/secrets-cache.ts +22 -0
  42. package/src/utils/version-gate.test.ts +122 -0
  43. package/src/utils/version-gate.ts +109 -13
  44. package/test/e2e/smoke-install-mcp.sh +113 -0
  45. package/test/fixtures/hq-pack-smoke-mcp/mcp/smoke-http.json +1 -0
  46. package/test/fixtures/hq-pack-smoke-mcp/package.yaml +11 -0
@@ -0,0 +1,130 @@
1
+ import { Command } from 'commander';
2
+ import { type SafeWriteEnv } from './mcp-registration.js';
3
+ /** A server's presence on ONE runtime surface. */
4
+ export type PresenceState =
5
+ /** The server def is present (and parsed) on this runtime. */
6
+ 'present'
7
+ /** The runtime parsed fine but this server is not registered there. */
8
+ | 'absent'
9
+ /** The runtime's config is malformed (unparseable) — presence is unknowable. */
10
+ | 'unparseable'
11
+ /** The runtime is not installed (Codex only: `~/.codex` missing). */
12
+ | 'not-installed';
13
+ /** Per-runtime, per-server status. */
14
+ export interface RuntimeServerStatus {
15
+ /** present / absent / unparseable / not-installed. */
16
+ presence: PresenceState;
17
+ /** The transport read off this runtime's def (undefined when absent). */
18
+ transport?: string;
19
+ /** The target (url or command+args) read off this runtime's def (undefined when absent). */
20
+ target?: string;
21
+ /** Header KEYS present on this runtime's def (values are NEVER captured). */
22
+ headerKeys?: string[];
23
+ /** Env KEYS present on this runtime's def (values are NEVER captured). */
24
+ envKeys?: string[];
25
+ }
26
+ /** A single HQ-owned MCP server's cross-runtime status. */
27
+ export interface McpServerStatus {
28
+ /** The bare server name (the `mcpServers` / `mcp_servers` key). */
29
+ server: string;
30
+ /** The pack that owns it (`_hqPack` provenance). */
31
+ pack: string;
32
+ /** The transport (from whichever runtime has the def; '' when neither). */
33
+ transport: string;
34
+ /** The target — url (http/sse) or command+args (stdio); '' when unknown. NEVER a secret. */
35
+ target: string;
36
+ /** Claude-runtime status. */
37
+ claude: RuntimeServerStatus;
38
+ /** Codex-runtime status. */
39
+ codex: RuntimeServerStatus;
40
+ /**
41
+ * True iff the server is present on EXACTLY ONE of the two runtimes (a partial
42
+ * registration). When Codex is not installed and the server is Claude-only, this
43
+ * is still PARTIAL — `partialReason` names the missing runtime.
44
+ */
45
+ partial: boolean;
46
+ /** Human-readable reason naming the missing runtime when `partial`. */
47
+ partialReason?: string;
48
+ /**
49
+ * True iff the server is present on BOTH runtimes but the transport-relevant
50
+ * content differs (transport, target, or header/env KEY sets). Header VALUES are
51
+ * never compared.
52
+ */
53
+ drifted: boolean;
54
+ }
55
+ /** A runtime's top-level status. */
56
+ export interface RuntimeStatus {
57
+ /** Whether the runtime is installed (Claude is always; Codex iff `~/.codex` exists). */
58
+ installed: boolean;
59
+ /** Whether the runtime's config parsed (false => unparseable). */
60
+ parses: boolean;
61
+ /** The config file path inspected. */
62
+ configPath: string;
63
+ }
64
+ /** The structured `hq mcp status` report. */
65
+ export interface McpStatusReport {
66
+ /** Every HQ-owned server, keyed by name, with cross-runtime status. */
67
+ servers: McpServerStatus[];
68
+ /** Per-runtime top-level status. */
69
+ runtimes: {
70
+ claude: RuntimeStatus;
71
+ codex: RuntimeStatus;
72
+ };
73
+ /** The backup root + the most-recent backup directory names (restore targets). */
74
+ backups: {
75
+ /** `~/.hq/backups/mcp` — where US-006 writes pre-write snapshots. */
76
+ root: string;
77
+ /** The most-recent backup dir NAMES (`<iso>-<pack>`), newest first (capped). */
78
+ recent: string[];
79
+ };
80
+ }
81
+ /**
82
+ * Compute the cross-runtime MCP status report. PURE (modulo filesystem reads):
83
+ * reads `~/.claude.json` + `~/.codex/config.toml` (Codex only when installed),
84
+ * enumerates HQ-owned servers (those with a non-empty `_hqPack`), and annotates
85
+ * each with per-runtime presence, PARTIAL (present in exactly one runtime, missing
86
+ * runtime named), and DRIFT (present in both but transport/target/header-keys
87
+ * differ). A malformed config marks that runtime `parses:false`/`unparseable`
88
+ * rather than throwing. Header VALUES are never read into the report.
89
+ */
90
+ export declare function computeMcpStatus(env: SafeWriteEnv): McpStatusReport;
91
+ /**
92
+ * Render the report as human-readable text. Per server: name, pack, transport,
93
+ * target, and a per-runtime line. PARTIAL servers are marked loudly with the
94
+ * missing runtime NAMED; DRIFT is flagged. Header/env VALUES are rendered as
95
+ * {@link SECRET_REDACTION} — never the value. Ends with the backup restore hint.
96
+ */
97
+ export declare function renderMcpStatus(report: McpStatusReport): string;
98
+ /** The structured capability advertisement for this hq-cli. */
99
+ export interface McpCapabilities {
100
+ /** This hq-cli supports MCP pack registration. */
101
+ supportsMcp: boolean;
102
+ /** The pack contribution types this CLI can register (currently just `mcp`). */
103
+ contributes: string[];
104
+ /** The agent runtimes MCP servers are registered into. */
105
+ runtimes: string[];
106
+ /** The MCP transports this CLI can emit. */
107
+ transports: string[];
108
+ }
109
+ /**
110
+ * Compute this hq-cli's MCP capability advertisement. PURE — no IO, no env: the
111
+ * answer is a property of the CLI build itself (it supports `contributes.mcp`
112
+ * dual-runtime registration), so it returns a static structured object. Kept as a
113
+ * helper (not inlined into the action) so tests / CI can assert the advert shape
114
+ * without commander, mirroring {@link computeMcpStatus}.
115
+ */
116
+ export declare function computeMcpCapabilities(): McpCapabilities;
117
+ /** Render the capability advert as human-readable text. */
118
+ export declare function renderMcpCapabilities(caps: McpCapabilities): string;
119
+ /**
120
+ * Wire the `hq mcp` command group with a read-only `status` subcommand and a
121
+ * `capabilities` advertisement subcommand (US-012). `status` resolves the
122
+ * production env (real home), computes the report, and prints either
123
+ * `JSON.stringify(report, null, 2)` (`--json`, for CI / US-013) or the
124
+ * human-readable {@link renderMcpStatus} text. `capabilities` advertises that this
125
+ * hq-cli supports `contributes.mcp` ({@link computeMcpCapabilities} /
126
+ * {@link renderMcpCapabilities}). Follows the commander pattern used by
127
+ * {@link registerReindexCommand} and the subcommand-group pattern in index.ts.
128
+ */
129
+ export declare function registerMcpCommand(program: Command): void;
130
+ //# sourceMappingURL=mcp-status.d.ts.map
@@ -0,0 +1,406 @@
1
+ /**
2
+ * hq mcp status — read-only observability over installed MCP packs across BOTH
3
+ * runtimes (Claude + Codex). US-011.
4
+ *
5
+ * This closes the US-009 gap: the old symlink-only `linkStatus` structurally
6
+ * cannot see a JSON/TOML *merge* (an MCP server is MERGED into the shared agent
7
+ * configs, never symlinked). So status reads the PROVENANCE marker `_hqPack`
8
+ * directly off the server defs in `~/.claude.json` + `~/.codex/config.toml`,
9
+ * enumerates every HQ-owned server, and reports — PER runtime — present? parses?
10
+ * matches-or-drifted? It surfaces PARTIAL explicitly (registered in one runtime
11
+ * but not the other, naming the missing runtime) and lists the most-recent
12
+ * backups so a corrupted config has a discoverable restore target.
13
+ *
14
+ * SECRET SAFETY (hard rule): header/env VALUES are NEVER rendered in the clear.
15
+ * Status reads configs that hold RESOLVED secrets (the runtime needs real
16
+ * headers), and we do NOT have the raw secret-set at status time — so we redact
17
+ * by KEY presence: header/env KEYS are shown, every value is rendered as
18
+ * {@link SECRET_REDACTION}, and no value is ever compared in the clear.
19
+ *
20
+ * The pure {@link computeMcpStatus} + {@link renderMcpStatus} functions are
21
+ * exported so tests (and CI / US-013) can drive them WITHOUT going through
22
+ * commander; {@link registerMcpCommand} wires the `hq mcp status` command group.
23
+ */
24
+
25
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="518fe2be-89c1-53a6-b2fd-263fccc128ba")}catch(e){}}();
26
+ import * as fs from 'fs';
27
+ import { HQ_PACK_PROVENANCE_KEY, SECRET_REDACTION, backupRoot, claudeConfigFormat, claudeConfigPath, codexConfigFormat, codexConfigPath, CODEX_MCP_SERVERS_KEY, ConfigParseError, isCodexInstalled, readConfigDoc, resolveEnv, } from './mcp-registration.js';
28
+ // ---------------------------------------------------------------------------
29
+ // Pure status computation.
30
+ // ---------------------------------------------------------------------------
31
+ /** How many recent backup dirs to surface. */
32
+ const MAX_RECENT_BACKUPS = 5;
33
+ /** Read provenance (`_hqPack`) off a def; non-empty string => HQ-owned. */
34
+ function provenanceOf(def) {
35
+ if (def === null || typeof def !== 'object' || Array.isArray(def))
36
+ return undefined;
37
+ const stamp = def[HQ_PACK_PROVENANCE_KEY];
38
+ return typeof stamp === 'string' && stamp.length > 0 ? stamp : undefined;
39
+ }
40
+ /** The transport string off a def (`type`), or '' when not a string. */
41
+ function transportOf(def) {
42
+ return typeof def.type === 'string' ? def.type : '';
43
+ }
44
+ /**
45
+ * The target off a def — url (http/sse) or command(+args) (stdio). NEVER a
46
+ * header/secret. '' when neither a url nor a command is present.
47
+ */
48
+ function targetOf(def) {
49
+ const type = transportOf(def);
50
+ if ((type === 'http' || type === 'sse') && typeof def.url === 'string')
51
+ return def.url;
52
+ if (typeof def.command === 'string') {
53
+ const args = Array.isArray(def.args) && def.args.length > 0 ? ` ${def.args.join(' ')}` : '';
54
+ return `${def.command}${args}`;
55
+ }
56
+ if (typeof def.url === 'string')
57
+ return def.url;
58
+ return '';
59
+ }
60
+ /** Header KEYS off a def (values NEVER captured). */
61
+ function headerKeysOf(def) {
62
+ const h = def.headers;
63
+ if (!h || typeof h !== 'object' || Array.isArray(h))
64
+ return [];
65
+ return Object.keys(h).sort();
66
+ }
67
+ /** Env KEYS off a def (values NEVER captured). */
68
+ function envKeysOf(def) {
69
+ const e = def.env;
70
+ if (!e || typeof e !== 'object' || Array.isArray(e))
71
+ return [];
72
+ return Object.keys(e).sort();
73
+ }
74
+ /** Summarize a def into its transport-relevant, value-FREE content (for drift). */
75
+ function summarizeDef(def) {
76
+ return {
77
+ transport: transportOf(def),
78
+ target: targetOf(def),
79
+ headerKeys: headerKeysOf(def),
80
+ envKeys: envKeysOf(def),
81
+ };
82
+ }
83
+ /** True iff two def summaries differ in any transport-relevant field (header VALUES never compared). */
84
+ function summariesDiffer(a, b) {
85
+ return JSON.stringify(a) !== JSON.stringify(b);
86
+ }
87
+ /** Scan the Claude runtime: read `~/.claude.json`, collect HQ-owned servers. */
88
+ function scanClaude(env) {
89
+ const configPath = claudeConfigPath(env);
90
+ const hqServers = new Map();
91
+ let parses = true;
92
+ try {
93
+ const { doc } = readConfigDoc(configPath, claudeConfigFormat);
94
+ const servers = doc.mcpServers;
95
+ if (servers && typeof servers === 'object' && !Array.isArray(servers)) {
96
+ for (const [name, def] of Object.entries(servers)) {
97
+ const pack = provenanceOf(def);
98
+ if (pack !== undefined) {
99
+ hqServers.set(name, { def: def, pack });
100
+ }
101
+ }
102
+ }
103
+ }
104
+ catch (e) {
105
+ if (e instanceof ConfigParseError) {
106
+ parses = false; // malformed — report unparseable, do NOT crash the command.
107
+ }
108
+ else {
109
+ throw e; // ConfigPermissionError or anything unexpected — surface it.
110
+ }
111
+ }
112
+ return { installed: true, parses, configPath, hqServers };
113
+ }
114
+ /** Scan the Codex runtime: only when installed; read `~/.codex/config.toml`. */
115
+ function scanCodex(env) {
116
+ const configPath = codexConfigPath(env);
117
+ const hqServers = new Map();
118
+ if (!isCodexInstalled(env)) {
119
+ return { installed: false, parses: true, configPath, hqServers };
120
+ }
121
+ let parses = true;
122
+ try {
123
+ const { doc } = readConfigDoc(configPath, codexConfigFormat);
124
+ const servers = doc.value[CODEX_MCP_SERVERS_KEY];
125
+ if (servers && typeof servers === 'object' && !Array.isArray(servers)) {
126
+ for (const [name, def] of Object.entries(servers)) {
127
+ const pack = provenanceOf(def);
128
+ if (pack !== undefined) {
129
+ hqServers.set(name, { def: def, pack });
130
+ }
131
+ }
132
+ }
133
+ }
134
+ catch (e) {
135
+ if (e instanceof ConfigParseError) {
136
+ parses = false;
137
+ }
138
+ else {
139
+ throw e;
140
+ }
141
+ }
142
+ return { installed: true, parses, configPath, hqServers };
143
+ }
144
+ /** Build the per-runtime, per-server status from a scan (or its absence). */
145
+ function runtimeServerStatus(scan, name) {
146
+ if (!scan.installed)
147
+ return { presence: 'not-installed' };
148
+ if (!scan.parses)
149
+ return { presence: 'unparseable' };
150
+ const found = scan.hqServers.get(name);
151
+ if (!found)
152
+ return { presence: 'absent' };
153
+ return {
154
+ presence: 'present',
155
+ transport: transportOf(found.def),
156
+ target: targetOf(found.def),
157
+ headerKeys: headerKeysOf(found.def),
158
+ envKeys: envKeysOf(found.def),
159
+ };
160
+ }
161
+ /** List the most-recent backup dir names under `backupRoot` (newest first, capped). */
162
+ function recentBackups(env) {
163
+ const root = backupRoot(env);
164
+ let entries;
165
+ try {
166
+ entries = fs.readdirSync(root, { withFileTypes: true });
167
+ }
168
+ catch {
169
+ // ENOENT (no backups yet) or unreadable — surface an empty list.
170
+ return [];
171
+ }
172
+ return entries
173
+ .filter((e) => e.isDirectory())
174
+ .map((e) => e.name)
175
+ // Names are `<iso>-<pack>` with a sortable UTC stamp prefix — desc = newest first.
176
+ .sort((a, b) => (a < b ? 1 : a > b ? -1 : 0))
177
+ .slice(0, MAX_RECENT_BACKUPS);
178
+ }
179
+ /**
180
+ * Compute the cross-runtime MCP status report. PURE (modulo filesystem reads):
181
+ * reads `~/.claude.json` + `~/.codex/config.toml` (Codex only when installed),
182
+ * enumerates HQ-owned servers (those with a non-empty `_hqPack`), and annotates
183
+ * each with per-runtime presence, PARTIAL (present in exactly one runtime, missing
184
+ * runtime named), and DRIFT (present in both but transport/target/header-keys
185
+ * differ). A malformed config marks that runtime `parses:false`/`unparseable`
186
+ * rather than throwing. Header VALUES are never read into the report.
187
+ */
188
+ export function computeMcpStatus(env) {
189
+ const claudeScan = scanClaude(env);
190
+ const codexScan = scanCodex(env);
191
+ // Union of every HQ-owned server name across both runtimes.
192
+ const names = new Set([...claudeScan.hqServers.keys(), ...codexScan.hqServers.keys()]);
193
+ const servers = [];
194
+ for (const name of [...names].sort()) {
195
+ const claude = runtimeServerStatus(claudeScan, name);
196
+ const codex = runtimeServerStatus(codexScan, name);
197
+ // Prefer whichever runtime has the def for the top-level transport/target.
198
+ const claudeFound = claudeScan.hqServers.get(name);
199
+ const codexFound = codexScan.hqServers.get(name);
200
+ const repDef = claudeFound?.def ?? codexFound?.def;
201
+ const pack = claudeFound?.pack ?? codexFound?.pack ?? '';
202
+ const transport = repDef ? transportOf(repDef) : '';
203
+ const target = repDef ? targetOf(repDef) : '';
204
+ const onClaude = claude.presence === 'present';
205
+ const onCodex = codex.presence === 'present';
206
+ // PARTIAL = present in exactly one runtime. Name the missing runtime.
207
+ let partial = false;
208
+ let partialReason;
209
+ if (onClaude && !onCodex) {
210
+ partial = true;
211
+ partialReason = codexScan.installed
212
+ ? 'registered in Claude but NOT in Codex'
213
+ : 'registered in Claude; Codex runtime not installed (server not registered in Codex)';
214
+ }
215
+ else if (onCodex && !onClaude) {
216
+ partial = true;
217
+ partialReason = 'registered in Codex but NOT in Claude';
218
+ }
219
+ // DRIFT = present in both but transport-relevant content differs (no header VALUES).
220
+ let drifted = false;
221
+ if (onClaude && onCodex && claudeFound && codexFound) {
222
+ drifted = summariesDiffer(summarizeDef(claudeFound.def), summarizeDef(codexFound.def));
223
+ }
224
+ servers.push({
225
+ server: name,
226
+ pack,
227
+ transport,
228
+ target,
229
+ claude,
230
+ codex,
231
+ partial,
232
+ partialReason,
233
+ drifted,
234
+ });
235
+ }
236
+ return {
237
+ servers,
238
+ runtimes: {
239
+ claude: {
240
+ installed: claudeScan.installed,
241
+ parses: claudeScan.parses,
242
+ configPath: claudeScan.configPath,
243
+ },
244
+ codex: {
245
+ installed: codexScan.installed,
246
+ parses: codexScan.parses,
247
+ configPath: codexScan.configPath,
248
+ },
249
+ },
250
+ backups: {
251
+ root: backupRoot(env),
252
+ recent: recentBackups(env),
253
+ },
254
+ };
255
+ }
256
+ // ---------------------------------------------------------------------------
257
+ // Human-readable rendering.
258
+ // ---------------------------------------------------------------------------
259
+ /** Render one runtime's per-server line. Header/env VALUES are NEVER printed. */
260
+ function renderRuntimeLine(label, st) {
261
+ switch (st.presence) {
262
+ case 'present': {
263
+ const parts = [`present`];
264
+ if (st.headerKeys && st.headerKeys.length > 0) {
265
+ parts.push(`headers: ${st.headerKeys.map((k) => `${k}=${SECRET_REDACTION}`).join(', ')}`);
266
+ }
267
+ if (st.envKeys && st.envKeys.length > 0) {
268
+ parts.push(`env: ${st.envKeys.map((k) => `${k}=${SECRET_REDACTION}`).join(', ')}`);
269
+ }
270
+ return ` ${label}: ${parts.join(' | ')}`;
271
+ }
272
+ case 'absent':
273
+ return ` ${label}: absent`;
274
+ case 'unparseable':
275
+ return ` ${label}: UNPARSEABLE (config malformed)`;
276
+ case 'not-installed':
277
+ return ` ${label}: not installed`;
278
+ }
279
+ }
280
+ /**
281
+ * Render the report as human-readable text. Per server: name, pack, transport,
282
+ * target, and a per-runtime line. PARTIAL servers are marked loudly with the
283
+ * missing runtime NAMED; DRIFT is flagged. Header/env VALUES are rendered as
284
+ * {@link SECRET_REDACTION} — never the value. Ends with the backup restore hint.
285
+ */
286
+ export function renderMcpStatus(report) {
287
+ const lines = [];
288
+ lines.push('HQ MCP status — installed packs across Claude + Codex');
289
+ lines.push('');
290
+ // Runtime header.
291
+ const c = report.runtimes.claude;
292
+ const x = report.runtimes.codex;
293
+ lines.push(`Runtimes: Claude [${c.parses ? 'ok' : 'UNPARSEABLE'}] ` +
294
+ `Codex [${!x.installed ? 'not installed' : x.parses ? 'ok' : 'UNPARSEABLE'}]`);
295
+ lines.push('');
296
+ if (report.servers.length === 0) {
297
+ lines.push('No HQ-owned MCP servers registered (no _hqPack provenance found in either runtime).');
298
+ }
299
+ else {
300
+ for (const s of report.servers) {
301
+ const flags = [];
302
+ if (s.partial)
303
+ flags.push('PARTIAL');
304
+ if (s.drifted)
305
+ flags.push('DRIFTED');
306
+ const flagStr = flags.length > 0 ? ` <<< ${flags.join(' + ')}` : '';
307
+ lines.push(`• ${s.server} (pack: ${s.pack})${flagStr}`);
308
+ lines.push(` transport: ${s.transport || '(unknown)'} target: ${s.target || '(none)'}`);
309
+ lines.push(renderRuntimeLine('Claude', s.claude));
310
+ lines.push(renderRuntimeLine('Codex ', s.codex));
311
+ if (s.partial && s.partialReason) {
312
+ lines.push(` PARTIAL: ${s.partialReason}`);
313
+ }
314
+ if (s.drifted) {
315
+ lines.push(` DRIFTED: Claude and Codex defs differ (transport/target/header-keys)`);
316
+ }
317
+ lines.push('');
318
+ }
319
+ }
320
+ // Backups (restore targets for a corrupted config).
321
+ lines.push(`Backups: ${report.backups.root}`);
322
+ if (report.backups.recent.length > 0) {
323
+ lines.push(` Most recent:`);
324
+ for (const b of report.backups.recent) {
325
+ lines.push(` - ${b}`);
326
+ }
327
+ lines.push(` To restore a corrupted config, copy the snapshot from the newest dir above back into place.`);
328
+ }
329
+ else {
330
+ lines.push(` (no backups yet)`);
331
+ }
332
+ return lines.join('\n');
333
+ }
334
+ /**
335
+ * Compute this hq-cli's MCP capability advertisement. PURE — no IO, no env: the
336
+ * answer is a property of the CLI build itself (it supports `contributes.mcp`
337
+ * dual-runtime registration), so it returns a static structured object. Kept as a
338
+ * helper (not inlined into the action) so tests / CI can assert the advert shape
339
+ * without commander, mirroring {@link computeMcpStatus}.
340
+ */
341
+ export function computeMcpCapabilities() {
342
+ return {
343
+ supportsMcp: true,
344
+ contributes: ['mcp'],
345
+ runtimes: ['claude', 'codex'],
346
+ transports: ['http', 'stdio', 'sse'],
347
+ };
348
+ }
349
+ /** Render the capability advert as human-readable text. */
350
+ export function renderMcpCapabilities(caps) {
351
+ const lines = [];
352
+ lines.push('HQ MCP capabilities — what this hq-cli supports');
353
+ lines.push('');
354
+ lines.push(` supports MCP: ${caps.supportsMcp ? 'yes' : 'no'}`);
355
+ lines.push(` contributes: ${caps.contributes.join(', ')}`);
356
+ lines.push(` runtimes: ${caps.runtimes.join(', ')}`);
357
+ lines.push(` transports: ${caps.transports.join(', ')}`);
358
+ return lines.join('\n');
359
+ }
360
+ // ---------------------------------------------------------------------------
361
+ // Command wiring.
362
+ // ---------------------------------------------------------------------------
363
+ /**
364
+ * Wire the `hq mcp` command group with a read-only `status` subcommand and a
365
+ * `capabilities` advertisement subcommand (US-012). `status` resolves the
366
+ * production env (real home), computes the report, and prints either
367
+ * `JSON.stringify(report, null, 2)` (`--json`, for CI / US-013) or the
368
+ * human-readable {@link renderMcpStatus} text. `capabilities` advertises that this
369
+ * hq-cli supports `contributes.mcp` ({@link computeMcpCapabilities} /
370
+ * {@link renderMcpCapabilities}). Follows the commander pattern used by
371
+ * {@link registerReindexCommand} and the subcommand-group pattern in index.ts.
372
+ */
373
+ export function registerMcpCommand(program) {
374
+ const mcp = program
375
+ .command('mcp')
376
+ .description('MCP pack observability (read-only) across Claude + Codex');
377
+ mcp
378
+ .command('status')
379
+ .description('Show installed MCP packs/servers and their health in BOTH Claude and Codex (PARTIAL/DRIFT flagged; secrets redacted)')
380
+ .option('--json', 'Emit the structured report as JSON (for CI / scripting)')
381
+ .action((opts) => {
382
+ const env = resolveEnv();
383
+ const report = computeMcpStatus(env);
384
+ if (opts.json) {
385
+ process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
386
+ }
387
+ else {
388
+ process.stdout.write(`${renderMcpStatus(report)}\n`);
389
+ }
390
+ });
391
+ mcp
392
+ .command('capabilities')
393
+ .description('Advertise that this hq-cli supports contributes.mcp (dual-runtime Claude+Codex registration)')
394
+ .option('--json', 'Emit the structured capability object as JSON (for CI / scripting)')
395
+ .action((opts) => {
396
+ const caps = computeMcpCapabilities();
397
+ if (opts.json) {
398
+ process.stdout.write(`${JSON.stringify(caps, null, 2)}\n`);
399
+ }
400
+ else {
401
+ process.stdout.write(`${renderMcpCapabilities(caps)}\n`);
402
+ }
403
+ });
404
+ }
405
+ //# sourceMappingURL=mcp-status.js.map
406
+ //# debugId=518fe2be-89c1-53a6-b2fd-263fccc128ba
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Builds the static create-time warning surfaced by both `create-company` and
3
+ * `dry-run`, because users may accidentally create duplicate companies instead
4
+ * of joining the existing company they were invited to.
5
+ */
6
+ export declare function buildCreateCompanyWarning(): string;
7
+ //# sourceMappingURL=onboard-warning.d.ts.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Builds the static create-time warning surfaced by both `create-company` and
3
+ * `dry-run`, because users may accidentally create duplicate companies instead
4
+ * of joining the existing company they were invited to.
5
+ */
6
+
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="853f43ae-d902-54b9-9279-8a4b1d5f7693")}catch(e){}}();
8
+ export function buildCreateCompanyWarning() {
9
+ return (" This creates a NEW company that you own — it does NOT join an existing one.\n" +
10
+ " If your company already uses HQ, do NOT create it again: ask your admin or owner to send you an invite, then accept it and run `hq sync` to pull the existing company.\n" +
11
+ " Creating a same-named company makes a separate one you'd be alone in.\n");
12
+ }
13
+ //# sourceMappingURL=onboard-warning.js.map
14
+ //# debugId=853f43ae-d902-54b9-9279-8a4b1d5f7693
@@ -19,13 +19,14 @@
19
19
  * browser-OAuth flow opens automatically.
20
20
  */
21
21
 
22
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="05a49c9b-23bc-5b96-b5e1-cc2e573b11c3")}catch(e){}}();
22
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="235a4623-0834-5428-957c-0c8bbe96d089")}catch(e){}}();
23
23
  import chalk from "chalk";
24
24
  import { runOnboardCli, readCheckpoint } from "@indigoai-us/hq-onboarding";
25
25
  import { DEFAULT_HQ_ROOT, DEFAULT_VAULT_API_URL, ensureCognitoToken, buildVaultConfig, } from "../utils/cognito-session.js";
26
26
  import { createDefaultVaultClient } from "./cloud-provision.js";
27
27
  import { detectOnboardingIdentityMismatch } from "./onboard-identity-guard.js";
28
28
  import { planOnboardJoin } from "./onboard-join.js";
29
+ import { buildCreateCompanyWarning } from "./onboard-warning.js";
29
30
  // ---------------------------------------------------------------------------
30
31
  // Command registration
31
32
  // ---------------------------------------------------------------------------
@@ -49,9 +50,7 @@ export function registerOnboardCommand(program) {
49
50
  console.log(` Company: ${options.name} (${options.slug})`);
50
51
  console.log(` Person: ${options.personName} <${options.email}>`);
51
52
  console.log(` HQ root: ${options.hqRoot}\n`);
52
- console.log(chalk.gray(" This creates a NEW company you own. Joining a teammate's existing\n" +
53
- " company? Stop — accept your invite, then run `hq sync` to pull it.\n" +
54
- " Creating a same-named company leaves you alone in a separate one.\n"));
53
+ console.log(chalk.gray(buildCreateCompanyWarning()));
55
54
  const accessToken = await ensureCognitoToken();
56
55
  const result = await runOnboardCli({
57
56
  mode: "create-company",
@@ -179,6 +178,7 @@ export function registerOnboardCommand(program) {
179
178
  .option("--hq-root <path>", `Local HQ tree root (default: ${DEFAULT_HQ_ROOT})`, DEFAULT_HQ_ROOT)
180
179
  .action(async (options) => {
181
180
  try {
181
+ console.log(chalk.gray(buildCreateCompanyWarning()));
182
182
  // No auth needed for dry-run — runOnboardCli handles this branch
183
183
  // without touching the vault-service.
184
184
  const result = await runOnboardCli({
@@ -198,4 +198,4 @@ export function registerOnboardCommand(program) {
198
198
  });
199
199
  }
200
200
  //# sourceMappingURL=onboard.js.map
201
- //# debugId=05a49c9b-23bc-5b96-b5e1-cc2e573b11c3
201
+ //# debugId=235a4623-0834-5428-957c-0c8bbe96d089