@indigoai-us/hq-cli 5.49.0 → 5.50.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 (40) 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/pack-install.d.ts +62 -0
  6. package/dist/commands/pack-install.js +422 -14
  7. package/dist/commands/packs.js +28 -4
  8. package/dist/commands/pkg-install.js +5 -2
  9. package/dist/index.js +20 -3
  10. package/dist/types.d.ts +8 -1
  11. package/dist/utils/contribution-table.d.ts +103 -0
  12. package/dist/utils/contribution-table.js +65 -0
  13. package/dist/utils/environmental-error.d.ts +10 -0
  14. package/dist/utils/environmental-error.js +40 -0
  15. package/dist/utils/pack-contributions.d.ts +86 -10
  16. package/dist/utils/pack-contributions.js +130 -48
  17. package/dist/utils/secrets-cache.d.ts +9 -0
  18. package/dist/utils/secrets-cache.js +24 -2
  19. package/package.json +3 -2
  20. package/scripts/generate-scan-packages-table.mjs +113 -0
  21. package/src/commands/mcp-registration.test.ts +2787 -0
  22. package/src/commands/mcp-registration.ts +2612 -0
  23. package/src/commands/mcp-status.test.ts +483 -0
  24. package/src/commands/mcp-status.ts +575 -0
  25. package/src/commands/mcp-status.us011.test.ts +243 -0
  26. package/src/commands/pack-install.test.ts +589 -0
  27. package/src/commands/pack-install.ts +497 -13
  28. package/src/commands/packs.ts +26 -1
  29. package/src/commands/pkg-install.ts +4 -1
  30. package/src/index.ts +18 -1
  31. package/src/types.ts +9 -8
  32. package/src/utils/contribution-table.ts +83 -0
  33. package/src/utils/environmental-error.test.ts +45 -0
  34. package/src/utils/environmental-error.ts +39 -0
  35. package/src/utils/pack-contributions.test.ts +257 -25
  36. package/src/utils/pack-contributions.ts +177 -47
  37. package/src/utils/secrets-cache.ts +22 -0
  38. package/test/e2e/smoke-install-mcp.sh +113 -0
  39. package/test/fixtures/hq-pack-smoke-mcp/mcp/smoke-http.json +1 -0
  40. package/test/fixtures/hq-pack-smoke-mcp/package.yaml +11 -0
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * HQ CLI - Module management, package management, and cloud sync for HQ
4
4
  */
5
5
 
6
- !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]="60f911e0-ddd5-5a2d-91c7-18ba47457b57")}catch(e){}}();
6
+ !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]="34e9e978-4c0a-5113-82af-9a33e30686c6")}catch(e){}}();
7
7
  import { Command } from "commander";
8
8
  import { initSentry, Sentry } from "./sentry.js";
9
9
  import { registerAddCommand } from "./commands/add.js";
@@ -44,7 +44,9 @@ import { registerSourcesCommand } from "./commands/sources.js";
44
44
  import { registerSignalsCommand } from "./commands/signals.js";
45
45
  import { registerReindexCommand } from "./commands/reindex.js";
46
46
  import { registerRescueCommand } from "./commands/rescue.js";
47
+ import { registerMcpCommand } from "./commands/mcp-status.js";
47
48
  import { sanitizeArgv } from "./utils/feedback-diagnostics.js";
49
+ import { environmentalFsErrorMessage } from "./utils/environmental-error.js";
48
50
  import { maybeWarnNewVersion, refreshVersionCache, } from "./utils/version-check.js";
49
51
  import { enforceVersionGate, shouldSkipGate, } from "./utils/version-gate.js";
50
52
  import { CLI_VERSION } from "./cli-version.js";
@@ -158,6 +160,10 @@ registerReindexCommand(program);
158
160
  // the HQ Sync app's "Update / Restore" pill; drives the same replace-rescue.sh
159
161
  // shipped from @indigoai-us/hq-cloud.
160
162
  registerRescueCommand(program);
163
+ // MCP pack observability (subcommand group — `hq mcp status`). Read-only
164
+ // provenance-based status across BOTH Claude + Codex runtimes (reads `_hqPack`
165
+ // off the configs, NOT linkStatus), with secret-redacted output + `--json`.
166
+ registerMcpCommand(program);
161
167
  (async () => {
162
168
  try {
163
169
  Sentry.addBreadcrumb({
@@ -176,7 +182,18 @@ registerRescueCommand(program);
176
182
  await program.parseAsync();
177
183
  }
178
184
  catch (err) {
179
- Sentry.captureException(err);
185
+ // A full disk / exhausted quota / read-only filesystem is the user's
186
+ // machine, not an HQ code defect. Surface a clear, actionable message and
187
+ // skip Sentry capture so one full disk doesn't flood the tracker with
188
+ // identical, unfixable crash reports (HQ-CLI-2). Genuine errors still go
189
+ // to Sentry and still exit 1.
190
+ const envMsg = environmentalFsErrorMessage(err);
191
+ if (envMsg) {
192
+ process.stderr.write(`hq: ${envMsg}\n`);
193
+ }
194
+ else {
195
+ Sentry.captureException(err);
196
+ }
180
197
  process.exitCode = 1;
181
198
  }
182
199
  finally {
@@ -186,4 +203,4 @@ registerRescueCommand(program);
186
203
  }
187
204
  })();
188
205
  //# sourceMappingURL=index.js.map
189
- //# debugId=60f911e0-ddd5-5a2d-91c7-18ba47457b57
206
+ //# debugId=34e9e978-4c0a-5113-82af-9a33e30686c6
package/dist/types.d.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  * (new in hq-core v12.0.0; see
8
8
  * knowledge/public/hq-core/package-yaml-spec.md)
9
9
  */
10
+ import type { ContributionKey } from './utils/contribution-table.js';
10
11
  export type LegacyStrategy = 'link' | 'merge' | 'copy';
11
12
  export type SyncStrategy = LegacyStrategy | 'package';
12
13
  export type AccessLevel = 'public' | 'team' | `role:${string}`;
@@ -56,7 +57,13 @@ export interface SyncResult {
56
57
  message?: string;
57
58
  filesChanged?: number;
58
59
  }
59
- export type PackContributeKey = 'workers' | 'knowledge' | 'skills' | 'commands' | 'hooks' | 'policies' | 'scripts';
60
+ /**
61
+ * The `contributes.*` keys a pack may declare. DERIVED (US-003) from the single
62
+ * declarative contribution registry in `utils/contribution-table.ts` -- adding
63
+ * a contribution type is one row there, and this union updates automatically.
64
+ * Do NOT restate the keys here.
65
+ */
66
+ export type PackContributeKey = ContributionKey;
60
67
  /**
61
68
  * Pack authorship attribution (US-001). OPTIONAL and backwards-compatible —
62
69
  * packs published before this field still validate. When present, install can
@@ -0,0 +1,103 @@
1
+ /**
2
+ * The contribution registry -- the SINGLE declarative source of truth (US-003)
3
+ * for the `contributes.* -> host` mapping. Every other surface DERIVES from
4
+ * this table:
5
+ *
6
+ * - `PackContributeKey` (types.ts) = `keyof typeof CONTRIBUTION_TABLE`
7
+ * - `linkFor` / `contributionLinks` read `payload` + `host`
8
+ * - `validateManifest`'s payload check reads `payload`
9
+ * - `core/scripts/scan-packages.sh` reads a data block GENERATED
10
+ * from this table
11
+ * (scripts/generate-scan-packages-table.mjs)
12
+ *
13
+ * Adding a contribution type is ONE row here, not a five-site edit. The parity
14
+ * test (`pack-contributions.test.ts`) asserts every surface agrees on the full
15
+ * key-set, the payload suffix, and the wire mode.
16
+ *
17
+ * Row fields:
18
+ * - `payload`: path INSIDE the pack, with the literal token `{item}` for the
19
+ * declared name. The suffix after `{item}` (e.g. `.md`, `.json`, or none)
20
+ * IS the load-bearing per-key shape.
21
+ * - `host`: for `wire: 'symlink'`, the host DIRECTORY (relative to the HQ
22
+ * root) the symlink is created under -- the symlink dst is
23
+ * `<host>/<expanded-item-basename>`. For `wire: 'merge'`, a non-path
24
+ * SENTINEL describing the merge target (e.g. `merge:claude+codex`); it is
25
+ * NEVER used as a filesystem path.
26
+ * - `wire`: `symlink` (a single `ln -s` into `host`) or `merge` (merged into
27
+ * a shared host config; see US-004/US-005). Symlink-only readers MUST skip
28
+ * `merge` rows.
29
+ *
30
+ * NOTE: the `mcp` row is DECLARED here as data only. US-003 does NOT wire any
31
+ * MCP behavior -- the merge engine lands in US-004/US-005. Declaring it now
32
+ * makes the table the single source so adding the merge wiring is a code change
33
+ * against an already-present row, and the parity test guards it from day one.
34
+ */
35
+ export type WireMode = 'symlink' | 'merge';
36
+ export interface ContributionRow {
37
+ /** Path inside the pack, with `{item}` substituted for the declared name. */
38
+ payload: string;
39
+ /**
40
+ * `wire: 'symlink'` -> host directory the symlink lives under (HQ-root
41
+ * relative). `wire: 'merge'` -> a non-path sentinel for the merge target.
42
+ */
43
+ host: string;
44
+ wire: WireMode;
45
+ }
46
+ /**
47
+ * The 8-key contribution registry. `as const` so `keyof typeof` yields the
48
+ * exact literal key union consumed by `PackContributeKey`.
49
+ */
50
+ export declare const CONTRIBUTION_TABLE: {
51
+ readonly workers: {
52
+ readonly payload: "workers/{item}";
53
+ readonly host: "core/workers/public";
54
+ readonly wire: "symlink";
55
+ };
56
+ readonly knowledge: {
57
+ readonly payload: "knowledge/{item}";
58
+ readonly host: "core/knowledge/public";
59
+ readonly wire: "symlink";
60
+ };
61
+ readonly skills: {
62
+ readonly payload: "skills/{item}";
63
+ readonly host: ".claude/skills";
64
+ readonly wire: "symlink";
65
+ };
66
+ readonly commands: {
67
+ readonly payload: "commands/{item}.md";
68
+ readonly host: ".claude/commands";
69
+ readonly wire: "symlink";
70
+ };
71
+ readonly hooks: {
72
+ readonly payload: "hooks/{item}.sh";
73
+ readonly host: ".claude/hooks";
74
+ readonly wire: "symlink";
75
+ };
76
+ readonly policies: {
77
+ readonly payload: "policies/{item}.md";
78
+ readonly host: "core/policies";
79
+ readonly wire: "symlink";
80
+ };
81
+ readonly scripts: {
82
+ readonly payload: "scripts/{item}";
83
+ readonly host: "core/scripts";
84
+ readonly wire: "symlink";
85
+ };
86
+ readonly mcp: {
87
+ readonly payload: "mcp/{item}.json";
88
+ readonly host: "merge:claude+codex";
89
+ readonly wire: "merge";
90
+ };
91
+ };
92
+ /** The declared contribution keys, derived once from the table. */
93
+ export type ContributionKey = keyof typeof CONTRIBUTION_TABLE;
94
+ /** All contribution keys, in declaration order. */
95
+ export declare const CONTRIBUTION_KEYS: ContributionKey[];
96
+ /**
97
+ * Expand a row's `payload` template for a concrete item name. Returns the
98
+ * pack-relative path of the contribution's payload (e.g. `commands/foo.md`).
99
+ */
100
+ export declare function payloadFor(key: ContributionKey, item: string): string;
101
+ /** Keys whose contributions are wired by a host symlink (skip `merge` rows). */
102
+ export declare const SYMLINK_KEYS: ("workers" | "knowledge" | "skills" | "commands" | "hooks" | "policies" | "scripts" | "mcp")[];
103
+ //# sourceMappingURL=contribution-table.d.ts.map
@@ -0,0 +1,65 @@
1
+ /**
2
+ * The contribution registry -- the SINGLE declarative source of truth (US-003)
3
+ * for the `contributes.* -> host` mapping. Every other surface DERIVES from
4
+ * this table:
5
+ *
6
+ * - `PackContributeKey` (types.ts) = `keyof typeof CONTRIBUTION_TABLE`
7
+ * - `linkFor` / `contributionLinks` read `payload` + `host`
8
+ * - `validateManifest`'s payload check reads `payload`
9
+ * - `core/scripts/scan-packages.sh` reads a data block GENERATED
10
+ * from this table
11
+ * (scripts/generate-scan-packages-table.mjs)
12
+ *
13
+ * Adding a contribution type is ONE row here, not a five-site edit. The parity
14
+ * test (`pack-contributions.test.ts`) asserts every surface agrees on the full
15
+ * key-set, the payload suffix, and the wire mode.
16
+ *
17
+ * Row fields:
18
+ * - `payload`: path INSIDE the pack, with the literal token `{item}` for the
19
+ * declared name. The suffix after `{item}` (e.g. `.md`, `.json`, or none)
20
+ * IS the load-bearing per-key shape.
21
+ * - `host`: for `wire: 'symlink'`, the host DIRECTORY (relative to the HQ
22
+ * root) the symlink is created under -- the symlink dst is
23
+ * `<host>/<expanded-item-basename>`. For `wire: 'merge'`, a non-path
24
+ * SENTINEL describing the merge target (e.g. `merge:claude+codex`); it is
25
+ * NEVER used as a filesystem path.
26
+ * - `wire`: `symlink` (a single `ln -s` into `host`) or `merge` (merged into
27
+ * a shared host config; see US-004/US-005). Symlink-only readers MUST skip
28
+ * `merge` rows.
29
+ *
30
+ * NOTE: the `mcp` row is DECLARED here as data only. US-003 does NOT wire any
31
+ * MCP behavior -- the merge engine lands in US-004/US-005. Declaring it now
32
+ * makes the table the single source so adding the merge wiring is a code change
33
+ * against an already-present row, and the parity test guards it from day one.
34
+ */
35
+ /**
36
+ * The 8-key contribution registry. `as const` so `keyof typeof` yields the
37
+ * exact literal key union consumed by `PackContributeKey`.
38
+ */
39
+
40
+ !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]="154fb78d-60ba-508f-b6e7-6889858f1841")}catch(e){}}();
41
+ export const CONTRIBUTION_TABLE = {
42
+ workers: { payload: 'workers/{item}', host: 'core/workers/public', wire: 'symlink' },
43
+ knowledge: { payload: 'knowledge/{item}', host: 'core/knowledge/public', wire: 'symlink' },
44
+ skills: { payload: 'skills/{item}', host: '.claude/skills', wire: 'symlink' },
45
+ commands: { payload: 'commands/{item}.md', host: '.claude/commands', wire: 'symlink' },
46
+ hooks: { payload: 'hooks/{item}.sh', host: '.claude/hooks', wire: 'symlink' },
47
+ policies: { payload: 'policies/{item}.md', host: 'core/policies', wire: 'symlink' },
48
+ scripts: { payload: 'scripts/{item}', host: 'core/scripts', wire: 'symlink' },
49
+ // wire:merge -- DECLARED as data (US-003); the merge engine ships in
50
+ // US-004/US-005. Symlink readers skip this row.
51
+ mcp: { payload: 'mcp/{item}.json', host: 'merge:claude+codex', wire: 'merge' },
52
+ };
53
+ /** All contribution keys, in declaration order. */
54
+ export const CONTRIBUTION_KEYS = Object.keys(CONTRIBUTION_TABLE);
55
+ /**
56
+ * Expand a row's `payload` template for a concrete item name. Returns the
57
+ * pack-relative path of the contribution's payload (e.g. `commands/foo.md`).
58
+ */
59
+ export function payloadFor(key, item) {
60
+ return CONTRIBUTION_TABLE[key].payload.replace('{item}', item);
61
+ }
62
+ /** Keys whose contributions are wired by a host symlink (skip `merge` rows). */
63
+ export const SYMLINK_KEYS = CONTRIBUTION_KEYS.filter((k) => CONTRIBUTION_TABLE[k].wire === 'symlink');
64
+ //# sourceMappingURL=contribution-table.js.map
65
+ //# debugId=154fb78d-60ba-508f-b6e7-6889858f1841
@@ -0,0 +1,10 @@
1
+ /**
2
+ * If `err` is an environmental disk/quota/read-only filesystem error, return a
3
+ * short, user-facing message explaining it; otherwise return `null`.
4
+ *
5
+ * A non-null result means the caller should print the message and SKIP Sentry
6
+ * capture — the condition is the user's machine, not a bug HQ can fix. A null
7
+ * result means "this is a normal error; handle it as usual (capture to Sentry)".
8
+ */
9
+ export declare function environmentalFsErrorMessage(err: unknown): string | null;
10
+ //# sourceMappingURL=environmental-error.d.ts.map
@@ -0,0 +1,40 @@
1
+ // src/utils/environmental-error.ts
2
+ //
3
+ // Classify errors that stem from the user's machine/filesystem state rather
4
+ // than an HQ code defect. These are unactionable from our side: a full disk, an
5
+ // exhausted quota, or a read-only filesystem. The CLI surfaces a clear,
6
+ // actionable message and does NOT report them to Sentry — otherwise a single
7
+ // full disk floods the issue tracker with identical, unfixable crash reports.
8
+ //
9
+ // HQ-CLI-2: `hq reindex` hit ENOSPC in the operation-lock temp-file write
10
+ // (`fs.openSync` → "ENOSPC: no space left on device, open") and the raw error
11
+ // propagated uncaught to the CLI's top-level handler, which captured it to
12
+ // Sentry and exited silently — 5 stack-trace crashes in 6 seconds, with no
13
+ // message telling the user their disk was full.
14
+ /**
15
+ * Node errno codes for "the filesystem cannot accept this write" — purely
16
+ * environmental, never a code bug. Mapped to the message shown to the user.
17
+ */
18
+
19
+ !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]="03976a9c-d4c3-57dc-bd1d-40c9d025193d")}catch(e){}}();
20
+ const ENVIRONMENTAL_FS_CODES = {
21
+ ENOSPC: "No space left on device. Free up disk space and try again.",
22
+ EDQUOT: "Disk quota exceeded. Free up space (or raise your quota) and try again.",
23
+ EROFS: "The filesystem is read-only, so HQ can't write here. Check the mount/permissions and try again.",
24
+ };
25
+ /**
26
+ * If `err` is an environmental disk/quota/read-only filesystem error, return a
27
+ * short, user-facing message explaining it; otherwise return `null`.
28
+ *
29
+ * A non-null result means the caller should print the message and SKIP Sentry
30
+ * capture — the condition is the user's machine, not a bug HQ can fix. A null
31
+ * result means "this is a normal error; handle it as usual (capture to Sentry)".
32
+ */
33
+ export function environmentalFsErrorMessage(err) {
34
+ const code = err?.code;
35
+ if (typeof code !== "string")
36
+ return null;
37
+ return ENVIRONMENTAL_FS_CODES[code] ?? null;
38
+ }
39
+ //# sourceMappingURL=environmental-error.js.map
40
+ //# debugId=03976a9c-d4c3-57dc-bd1d-40c9d025193d
@@ -1,22 +1,65 @@
1
1
  /**
2
- * Content-pack contribution helpers -- the single source of truth (in TS) for
3
- * the `contributes.* -> host-path` symlink mapping that `hq install` wires via
2
+ * Content-pack contribution helpers -- the SINGLE SOURCE OF TRUTH (US-003) for
3
+ * the `contributes.* -> host` mapping that `hq install` wires via
4
4
  * `core/scripts/scan-packages.sh`.
5
5
  *
6
6
  * `pack-install.ts` only INSTALLS content packs (into `core/packages/<name>/`,
7
7
  * tracked by filesystem presence -- there is no registry file). The list /
8
8
  * update / uninstall lifecycle in `commands/packs.ts` needs to reason about the
9
9
  * SAME mapping so it can report link health and cleanly un-wire a pack without
10
- * leaving dangling symlinks. That mapping is duplicated today in two places:
10
+ * leaving dangling symlinks.
11
11
  *
12
- * - core/scripts/scan-packages.sh (bash `case`, the wiring authority)
13
- * - pack-install.ts validateManifest's `subpaths` record (payload validation)
12
+ * Historically that mapping was RESTATED in five places (the scan-packages.sh
13
+ * bash `case`, pack-install.ts:validateManifest's `subpaths` record,
14
+ * `linkFor`'s switch, `contributionLinks`, and the `PackContributeKey` union),
15
+ * drift-guarded only by a substring check. US-003 collapses it to ONE
16
+ * declarative table -- `CONTRIBUTION_TABLE` below -- with a row per key
17
+ * `{ payload, host, wire }`:
14
18
  *
15
- * This module re-encodes it once for TS callers. A parity test
16
- * (`pack-contributions.test.ts`) asserts it matches scan-packages.sh's `case`
17
- * arms so the three copies cannot drift.
19
+ * - `PackContributeKey` is DERIVED from the table keys (see types.ts).
20
+ * - `linkFor` / `contributionLinks` / the `subpaths` validator READ the table.
21
+ * - `core/scripts/scan-packages.sh` reads a generated data block emitted from
22
+ * this same table (regenerate via `scripts/generate-scan-packages-table.mjs`).
23
+ *
24
+ * A parity test (`pack-contributions.test.ts`) asserts FULL key-set +
25
+ * payload-suffix + wire-mode equivalence across every surface, so the copies
26
+ * cannot drift.
27
+ *
28
+ * `wire` discriminates HOW a contribution reaches the host:
29
+ * - `symlink`: a single `ln -s` into a well-known host directory (every
30
+ * contribution type that shipped before MCP).
31
+ * - `merge`: the contribution is MERGED into a shared host config rather than
32
+ * symlinked (the `mcp` row -- registered into the Claude + Codex agent
33
+ * configs). The merge WIRING is delivered in US-004/US-005; US-003 only
34
+ * DECLARES the row as data so the table is the single source and the parity
35
+ * test guards the real invariant. `symlink`-only readers (linkFor,
36
+ * contributionLinks, the symlink validator, scan-packages) must SKIP
37
+ * `merge` rows -- they never produce a symlink.
18
38
  */
19
39
  import type { PackManifest, PackContributeKey } from '../types.js';
40
+ import { CONTRIBUTION_TABLE, type WireMode } from './contribution-table.js';
41
+ import { type UnregisterServerResult, type SafeWriteEnv, type AcquireLockOptions } from '../commands/mcp-registration.js';
42
+ export { CONTRIBUTION_TABLE };
43
+ export type { WireMode };
44
+ /**
45
+ * Where a contributes key is ROUTED (US-005). Reads the single-source table's
46
+ * `wire` field — `'symlink'` keys go through `linkFor`/`contributionLinks` (a
47
+ * host `ln -s`); `'merge'` keys (e.g. `mcp`) go through the `registerMcpServers`
48
+ * seam in `commands/mcp-registration.ts` and are NEVER symlinked.
49
+ *
50
+ * This is the explicit, code-enforced discriminator behind the invariant that
51
+ * merge keys never reach the symlink path: callers fan out on the return value
52
+ * rather than relying on `linkFor` happening to return `null`.
53
+ */
54
+ export declare function routeContribution(key: PackContributeKey): WireMode;
55
+ /**
56
+ * The subset of a pack's declared `contributes` keys that are `wire: 'merge'`
57
+ * (e.g. `mcp`) — the keys that MUST be routed to `registerMcpServers` (US-006)
58
+ * and MUST NOT be symlinked. Unknown keys and non-array/empty values are
59
+ * ignored, mirroring `contributionLinks`. Returned in `contributes` iteration
60
+ * order, de-duplicated.
61
+ */
62
+ export declare function mergeKeys(contributes: Partial<Record<PackContributeKey, string[]>>): PackContributeKey[];
20
63
  /** A single symlink a pack contributes: dst (host path) -> src (inside pack). */
21
64
  export interface WiredLink {
22
65
  key: PackContributeKey;
@@ -26,8 +69,10 @@ export interface WiredLink {
26
69
  }
27
70
  export type LinkStatus = 'live' | 'broken' | 'missing' | 'foreign';
28
71
  /**
29
- * Every symlink a pack's `contributes` block declares. Empty subfields and
30
- * non-array values are ignored, mirroring scan-packages.sh.
72
+ * Every SYMLINK a pack's `contributes` block declares. Empty subfields and
73
+ * non-array values are ignored, mirroring scan-packages.sh. `wire: 'merge'`
74
+ * keys (e.g. `mcp`) produce no symlink and are skipped here -- their host
75
+ * effect (a config merge) is handled separately (US-004/US-005).
31
76
  */
32
77
  export declare function contributionLinks(hqRoot: string, packDir: string, contributes: Partial<Record<PackContributeKey, string[]>>): WiredLink[];
33
78
  /** Classify a host path against the link that should own it. */
@@ -75,6 +120,37 @@ export interface UnwireResult {
75
120
  * uninstall from leaving dangling symlinks behind.
76
121
  */
77
122
  export declare function unwirePack(hqRoot: string, packDir: string, contributes: Partial<Record<PackContributeKey, string[]>>): UnwireResult;
123
+ /** The result of {@link unwirePackMcp}: the per-server un-registration outcomes (empty when no `mcp` keys). */
124
+ export interface UnwireMcpResult {
125
+ /** One {@link UnregisterServerResult} per declared `contributes.mcp` server, in declaration order. */
126
+ servers: UnregisterServerResult[];
127
+ }
128
+ /** Tuning passthrough for {@link unwirePackMcp} (tests inject a tmpdir `env.home` + tiny lock timeouts). */
129
+ export interface UnwirePackMcpOptions {
130
+ /** Injectable env — tests MUST pass a tmpdir `home` so the real ~/.claude.json / ~/.codex are untouched. */
131
+ env?: Partial<SafeWriteEnv>;
132
+ /** Lock tuning (tests use tiny timeouts). */
133
+ lock?: AcquireLockOptions;
134
+ /** Backup timestamp override (deterministic tests). */
135
+ stamp?: string;
136
+ }
137
+ /**
138
+ * Un-register the `wire: 'merge'` (MCP) servers a pack declares — the parallel to
139
+ * {@link unwirePack}'s symlink removal. For each name in `mergeKeys(contributes)` →
140
+ * `contributes.<mergeKey>` (today only `mcp`), this delegates to
141
+ * {@link unregisterMcpServers}, which removes ONLY entries stamped with THIS pack's
142
+ * `_hqPack` provenance and SKIPS-AND-WARNS on a foreign/unstamped same-named entry.
143
+ *
144
+ * No-ops cleanly when the pack declares no merge keys (returns `{ servers: [] }`),
145
+ * when the runtime config is absent (Codex-less host → first-class skip; missing
146
+ * ~/.claude.json → `absent`), and on a re-run (already-removed → `absent`). It does
147
+ * NOT throw on a foreign entry — uninstall of one pack must not abort on a server
148
+ * another pack (or the user) owns.
149
+ *
150
+ * @param packName the pack being uninstalled — the provenance to match
151
+ * @param contributes the pack's `contributes` block (its `mcp` list drives removal)
152
+ */
153
+ export declare function unwirePackMcp(packName: string, contributes: Partial<Record<PackContributeKey, string[]>>, options?: UnwirePackMcpOptions): UnwireMcpResult;
78
154
  export declare function readHqVersion(hqRoot: string): string | null;
79
155
  export interface CatalogEntry {
80
156
  source: string;