@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,113 @@
1
+ #!/usr/bin/env bash
2
+ # ---------------------------------------------------------------------------
3
+ # smoke-install-mcp.sh — TRUE end-to-end smoke test of `hq install` for
4
+ # MCP-bearing packs, in a fully isolated sandbox.
5
+ #
6
+ # Unlike the vitest suite (which unit-tests mcp-registration.ts against an
7
+ # injected $HOME), this drives the REAL built `hq` CLI through a REAL
8
+ # `hq install` against REAL packs, so it catches WIRING gaps unit tests miss —
9
+ # e.g. "registerMcpServers is implemented + tested but installPack never calls
10
+ # it" (the exact bug this harness first caught).
11
+ #
12
+ # It NEVER touches the developer's real ~/.claude.json, ~/.mcp.json, or
13
+ # ~/.codex/config.toml — everything lives under a mktemp sandbox HOME, and the
14
+ # install targets a sandbox HQ root.
15
+ #
16
+ # Two packs, two paths:
17
+ # A) hq-pack-smoke-mcp (no-secret fixture) → MUST register into both configs
18
+ # B) vyg-shopify-hq-pack (needs ${secret:VYG_API_KEY}) → MUST defer gracefully
19
+ # (install succeeds, server NOT registered, "connect first" warning shown)
20
+ #
21
+ # Usage: bash test/e2e/smoke-install-mcp.sh [--keep]
22
+ # Exit 0 = all checks pass. Exit 1 = at least one failed.
23
+ # ---------------------------------------------------------------------------
24
+ set -uo pipefail
25
+
26
+ CLI_REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
27
+ HQ_ROOT_REAL="$(cd "$CLI_REPO/../../.." && pwd)" # …/HQ
28
+ CLI="$CLI_REPO/dist/index.js"
29
+ FIXTURE="$CLI_REPO/test/fixtures/hq-pack-smoke-mcp" # no-secret pack
30
+ VYG="$HQ_ROOT_REAL/repos/private/vyg-shopify-hq-pack" # secret-bearing pack
31
+ KEEP=0; [ "${1:-}" = "--keep" ] && KEEP=1
32
+
33
+ pass=0; fail=0
34
+ ok() { echo " ✓ $1"; pass=$((pass+1)); }
35
+ bad() { echo " ✗ $1"; fail=$((fail+1)); }
36
+
37
+ [ -f "$CLI" ] || { echo "FATAL: build first (npm run build) — missing $CLI"; exit 2; }
38
+ [ -d "$FIXTURE" ] || { echo "FATAL: fixture pack missing at $FIXTURE"; exit 2; }
39
+ command -v node >/dev/null || { echo "FATAL: node not on PATH"; exit 2; }
40
+
41
+ SBX="$(mktemp -d -t hq-smoke-mcp.XXXXXX)"
42
+ SBX_HOME="$SBX/home"; SBX_HQ="$SBX/hq"
43
+ cleanup() { [ "$KEEP" = 1 ] && { echo "sandbox kept: $SBX"; return; }; rm -rf "$SBX"; }
44
+ trap cleanup EXIT
45
+
46
+ mkdir -p "$SBX_HOME/.codex" "$SBX_HQ/core/packages" "$SBX_HQ/core/workers/public" \
47
+ "$SBX_HQ/core/knowledge/public/hq-core" "$SBX_HQ/core/policies" \
48
+ "$SBX_HQ/core/hooks" "$SBX_HQ/.claude/skills" "$SBX_HQ/.claude/commands" \
49
+ "$SBX_HQ/companies"
50
+ cp -R "$HQ_ROOT_REAL/core/scripts" "$SBX_HQ/core/scripts"
51
+ # Pin the sandbox host version at the M1 floor (>=15.1.0). Copying the live
52
+ # core.yaml is unreliable — hq-sync can reset it below the floor (e.g. 15.0.24),
53
+ # which makes the floor check CORRECTLY refuse the test packs (they require
54
+ # >=15.1.0). This harness exercises the install path; floor-refusal has its own
55
+ # unit test. Pin a satisfying version so the install path is what's under test.
56
+ printf 'hqVersion: "15.1.0"\n' > "$SBX_HQ/core/core.yaml"
57
+ cp "$HQ_ROOT_REAL/core/knowledge/public/hq-core/mcp-manifest.schema.json" \
58
+ "$SBX_HQ/core/knowledge/public/hq-core/mcp-manifest.schema.json"
59
+ printf 'companies: {}\n' > "$SBX_HQ/companies/manifest.yaml"
60
+
61
+ # pre-existing non-HQ servers that MUST survive every install/uninstall
62
+ echo '{ "mcpServers": { "figma": { "type": "http", "url": "https://figma.example.test/mcp" } } }' > "$SBX_HOME/.claude.json"
63
+ printf '# user existing codex config\n[mcp_servers.node_repl]\ncommand = "node"\nargs = ["--repl"]\n' > "$SBX_HOME/.codex/config.toml"
64
+
65
+ # Always run from inside the sandbox HQ root. The CLI resolves the HQ root by
66
+ # walking up from cwd (utils/manifest.js findHqRoot), NOT from $HQ_ROOT — so the
67
+ # cwd is what actually scopes install/uninstall. (We still export HQ_ROOT for the
68
+ # code paths that DO honor it, e.g. scan-packages.) Without the cd, `packs
69
+ # uninstall` resolves the developer's real HQ root and silently no-ops.
70
+ run_hq() { ( cd "$SBX_HQ" && HOME="$SBX_HOME" HQ_ROOT="$SBX_HQ" node "$CLI" "$@" ); }
71
+ claude_has() { node -e "try{const j=require('$SBX_HOME/.claude.json');process.stdout.write(j.mcpServers&&j.mcpServers['$1']?'1':'0')}catch(e){process.stdout.write('0')}"; }
72
+ codex_has() { c=$(grep -c "\[mcp_servers.$1\]" "$SBX_HOME/.codex/config.toml" 2>/dev/null); echo "${c:-0}"; }
73
+
74
+ echo "=== HQ MCP install smoke test ==="
75
+ echo "sandbox: $SBX"; echo
76
+
77
+ # ---- A) NO-SECRET FIXTURE → must register ---------------------------------
78
+ echo "[A] install no-secret fixture (hq-pack-smoke-mcp) — must REGISTER"
79
+ OUT="$(cd "$SBX_HQ" && run_hq install "$FIXTURE" --allow-mcp --allow-hooks 2>&1)"; rc=$?
80
+ echo "$OUT" | sed 's/^/ /'
81
+ [ $rc -eq 0 ] && ok "install exited 0" || bad "install exited $rc"
82
+ [ "$(claude_has smoke-http)" = "1" ] && ok "smoke-http registered in ~/.claude.json" || bad "smoke-http MISSING from ~/.claude.json"
83
+ [ "$(codex_has smoke-http)" -ge 1 ] && ok "smoke-http registered in ~/.codex/config.toml" || bad "smoke-http MISSING from ~/.codex/config.toml"
84
+ [ "$(claude_has figma)" = "1" ] && ok "figma preserved" || bad "figma LOST"
85
+ [ "$(codex_has node_repl)" -ge 1 ] && ok "node_repl table preserved" || bad "node_repl LOST"
86
+ if grep -rqiE 'X-Smoke.*static-not-a-secret' "$SBX_HOME/.claude.json"; then ok "static header written (http client usable)"; else bad "static header missing from registered server"; fi
87
+
88
+ echo "[A.2] hq mcp status --json reports it"
89
+ ST="$(run_hq mcp status --json 2>&1)"
90
+ echo "$ST" | grep -q 'smoke-http' && ok "mcp status reports smoke-http" || bad "mcp status missing smoke-http"
91
+
92
+ echo "[A.3] uninstall round-trip"
93
+ run_hq packs uninstall hq-pack-smoke-mcp --yes >/dev/null 2>&1 || run_hq packs uninstall hq-pack-smoke-mcp >/dev/null 2>&1
94
+ [ "$(claude_has smoke-http)" = "0" ] && ok "smoke-http removed on uninstall" || bad "smoke-http still present after uninstall"
95
+ [ "$(claude_has figma)" = "1" ] && ok "figma still preserved after uninstall" || bad "figma lost during uninstall"
96
+
97
+ # ---- B) VYG PACK (needs a vault secret) → must DEFER gracefully -----------
98
+ echo
99
+ echo "[B] install vyg pack (needs \${secret:VYG_API_KEY}, not in vault) — must DEFER gracefully"
100
+ if [ -d "$VYG" ]; then
101
+ OUT="$(cd "$SBX_HQ" && run_hq install "$VYG" --allow-mcp --allow-hooks 2>&1)"; rc=$?
102
+ echo "$OUT" | sed 's/^/ /'
103
+ [ $rc -eq 0 ] && ok "install exited 0 (did not abort on the missing secret)" || bad "install aborted (rc=$rc) on missing secret"
104
+ [ "$(claude_has vyg-shopify)" = "0" ] && ok "vyg-shopify correctly DEFERRED (not registered without its key)" || bad "vyg-shopify registered despite missing secret"
105
+ echo "$OUT" | grep -qiE "VYG_API_KEY|connect-shopify|needs secret" && ok "clear 'provision the key' guidance shown" || bad "no deferral guidance shown to the user"
106
+ [ "$(claude_has figma)" = "1" ] && ok "figma still preserved through the deferred install" || bad "figma LOST during deferred install"
107
+ else
108
+ echo " · vyg pack not present — skipping deferral checks"
109
+ fi
110
+
111
+ echo
112
+ echo "=== RESULT: $pass passed · $fail failed ==="
113
+ [ $fail -eq 0 ] && exit 0 || exit 1
@@ -0,0 +1 @@
1
+ { "type": "http", "url": "https://smoke.example.test/mcp", "headers": { "X-Smoke": "static-not-a-secret" } }
@@ -0,0 +1,11 @@
1
+ name: hq-pack-smoke-mcp
2
+ version: 0.0.1
3
+ publisher: '@indigoai-us'
4
+ access: public
5
+ description: 'No-secret MCP pack — e2e smoke fixture for install registration.'
6
+ requires:
7
+ hqCore: '>=15.1.0'
8
+ capabilities: [network]
9
+ contributes:
10
+ mcp:
11
+ - smoke-http