@indigoai-us/hq-cli 5.50.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 (36) 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 +7 -2
  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/pack-contributions.d.ts +86 -10
  14. package/dist/utils/pack-contributions.js +130 -48
  15. package/dist/utils/secrets-cache.d.ts +9 -0
  16. package/dist/utils/secrets-cache.js +24 -2
  17. package/package.json +3 -2
  18. package/scripts/generate-scan-packages-table.mjs +113 -0
  19. package/src/commands/mcp-registration.test.ts +2787 -0
  20. package/src/commands/mcp-registration.ts +2612 -0
  21. package/src/commands/mcp-status.test.ts +483 -0
  22. package/src/commands/mcp-status.ts +575 -0
  23. package/src/commands/mcp-status.us011.test.ts +243 -0
  24. package/src/commands/pack-install.test.ts +589 -0
  25. package/src/commands/pack-install.ts +497 -13
  26. package/src/commands/packs.ts +26 -1
  27. package/src/commands/pkg-install.ts +4 -1
  28. package/src/index.ts +6 -0
  29. package/src/types.ts +9 -8
  30. package/src/utils/contribution-table.ts +83 -0
  31. package/src/utils/pack-contributions.test.ts +257 -25
  32. package/src/utils/pack-contributions.ts +177 -47
  33. package/src/utils/secrets-cache.ts +22 -0
  34. package/test/e2e/smoke-install-mcp.sh +113 -0
  35. package/test/fixtures/hq-pack-smoke-mcp/mcp/smoke-http.json +1 -0
  36. package/test/fixtures/hq-pack-smoke-mcp/package.yaml +11 -0
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * generate-scan-packages-table.mjs (US-003)
4
+ *
5
+ * Emits the bash data block that `core/scripts/scan-packages.sh` reads, from the
6
+ * single-source `src/utils/contribution-table.ts`. This keeps the bash wirer
7
+ * GENERATED FROM the table rather than restating the mapping -- the US-003
8
+ * single-source-of-truth invariant.
9
+ *
10
+ * The TS table is the authority; this script transcribes it to bash. It does
11
+ * NOT parse TypeScript -- it imports the same literal data by re-declaring the
12
+ * rows is avoided by reading the table via a tiny regex extraction of the
13
+ * `CONTRIBUTION_TABLE` object literal, so the table file stays the only place
14
+ * the rows live.
15
+ *
16
+ * Output: a bash snippet (to stdout, or written in place into scan-packages.sh
17
+ * between the BEGIN/END GENERATED markers when --write <path> is passed).
18
+ *
19
+ * Usage:
20
+ * node scripts/generate-scan-packages-table.mjs # print block
21
+ * node scripts/generate-scan-packages-table.mjs --check <path> # verify in-sync
22
+ * node scripts/generate-scan-packages-table.mjs --write <path> # rewrite in place
23
+ */
24
+
25
+ import * as fs from 'fs';
26
+ import * as path from 'path';
27
+ import { fileURLToPath } from 'url';
28
+
29
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
30
+ const TABLE_TS = path.resolve(__dirname, '../src/utils/contribution-table.ts');
31
+
32
+ const BEGIN = '# >>> BEGIN GENERATED contribution table (US-003) — do not edit by hand';
33
+ const END = '# <<< END GENERATED contribution table';
34
+
35
+ /**
36
+ * Extract the rows from the `CONTRIBUTION_TABLE` object literal in the TS file.
37
+ * Each row line looks like:
38
+ * key: { payload: 'p/{item}', host: 'h', wire: 'symlink' },
39
+ */
40
+ function readTable() {
41
+ const ts = fs.readFileSync(TABLE_TS, 'utf-8');
42
+ const open = ts.indexOf('export const CONTRIBUTION_TABLE');
43
+ if (open < 0) throw new Error('CONTRIBUTION_TABLE not found in ' + TABLE_TS);
44
+ const body = ts.slice(open, ts.indexOf('} as const', open));
45
+ const rowRe =
46
+ /^\s*([A-Za-z_][A-Za-z0-9_]*):\s*\{\s*payload:\s*'([^']+)'\s*,\s*host:\s*'([^']+)'\s*,\s*wire:\s*'([^']+)'\s*\}/gm;
47
+ const rows = [];
48
+ let m;
49
+ while ((m = rowRe.exec(body)) !== null) {
50
+ rows.push({ key: m[1], payload: m[2], host: m[3], wire: m[4] });
51
+ }
52
+ if (rows.length === 0) throw new Error('No rows parsed from CONTRIBUTION_TABLE');
53
+ return rows;
54
+ }
55
+
56
+ function renderBlock(rows) {
57
+ const lines = [];
58
+ lines.push(BEGIN);
59
+ lines.push('# Generated from hq-cli/src/utils/contribution-table.ts by');
60
+ lines.push('# hq-cli/scripts/generate-scan-packages-table.mjs. Regenerate with:');
61
+ lines.push('# node scripts/generate-scan-packages-table.mjs --write core/scripts/scan-packages.sh');
62
+ lines.push('# Each row is "payload|host|wire" (payload uses {item} for the name).');
63
+ lines.push('# bash 3.2-compatible (macOS default bash has no associative arrays):');
64
+ lines.push('# a plain indexed key list + a generated case-lookup function.');
65
+ lines.push('CONTRIB_KEYS=(' + rows.map((r) => r.key).join(' ') + ')');
66
+ lines.push('# contrib_row <key> -> echoes "payload|host|wire", empty if unknown.');
67
+ lines.push('contrib_row() {');
68
+ lines.push(' case "$1" in');
69
+ for (const r of rows) {
70
+ lines.push(` ${r.key}) printf '%s' '${r.payload}|${r.host}|${r.wire}' ;;`);
71
+ }
72
+ lines.push(" *) return 0 ;;");
73
+ lines.push(' esac');
74
+ lines.push('}');
75
+ lines.push(END);
76
+ return lines.join('\n');
77
+ }
78
+
79
+ function splice(scriptText, block) {
80
+ const b = scriptText.indexOf(BEGIN);
81
+ const e = scriptText.indexOf(END);
82
+ if (b < 0 || e < 0) {
83
+ throw new Error('BEGIN/END GENERATED markers not found in target script');
84
+ }
85
+ const before = scriptText.slice(0, b);
86
+ const after = scriptText.slice(e + END.length);
87
+ return before + block + after;
88
+ }
89
+
90
+ const rows = readTable();
91
+ const block = renderBlock(rows);
92
+
93
+ const arg = process.argv[2];
94
+ const target = process.argv[3];
95
+
96
+ if (arg === '--write') {
97
+ const text = fs.readFileSync(target, 'utf-8');
98
+ fs.writeFileSync(target, splice(text, block));
99
+ console.error(`Wrote generated contribution table into ${target}`);
100
+ } else if (arg === '--check') {
101
+ const text = fs.readFileSync(target, 'utf-8');
102
+ const expected = splice(text, block);
103
+ if (expected !== text) {
104
+ console.error(
105
+ `OUT OF SYNC: ${target} differs from contribution-table.ts. ` +
106
+ `Run: node scripts/generate-scan-packages-table.mjs --write ${target}`,
107
+ );
108
+ process.exit(1);
109
+ }
110
+ console.error(`${target} is in sync with the contribution table.`);
111
+ } else {
112
+ process.stdout.write(block + '\n');
113
+ }