@indigoai-us/hq-cli 5.14.0 → 5.15.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.
@@ -0,0 +1,487 @@
1
+ import { Command } from "commander";
2
+ import chalk from "chalk";
3
+ import { ensureCognitoToken } from "../utils/cognito-session.js";
4
+ import { vaultApiFetch } from "../utils/vault-api.js";
5
+
6
+ interface MeetingListItem {
7
+ meetingId: string;
8
+ title: string;
9
+ startTime: string;
10
+ endTime: string;
11
+ duration: number;
12
+ participantCount: number;
13
+ status: string;
14
+ hasTranscript: boolean;
15
+ hasNotes: boolean;
16
+ }
17
+
18
+ interface MeetingDetail {
19
+ meetingId: string;
20
+ title: string;
21
+ startTime: string;
22
+ endTime: string;
23
+ duration: number;
24
+ participants: Array<{ email: string; name: string | null; role: string }>;
25
+ calendarEventId: string | null;
26
+ botProvider: string;
27
+ sourceApp: string;
28
+ companyId: string;
29
+ status: string;
30
+ recallBotId: string | null;
31
+ isShared: boolean;
32
+ createdAt: string;
33
+ updatedAt: string;
34
+ documentUrl: string;
35
+ hasTranscript: boolean;
36
+ hasNotes: boolean;
37
+ }
38
+
39
+ interface TranscriptSegment {
40
+ speaker: string;
41
+ text: string;
42
+ startTime: number;
43
+ endTime: number;
44
+ }
45
+
46
+ interface MeetingNotes {
47
+ summary: string;
48
+ keyPoints: string[];
49
+ decisions: string[];
50
+ actionItems: Array<{ task: string; assignee: string | null }>;
51
+ participantContributions: Array<{
52
+ name: string;
53
+ speakingTimePercent: number;
54
+ topicsSummary: string;
55
+ }>;
56
+ model: string;
57
+ generatedAt: string;
58
+ }
59
+
60
+ interface MeetingDocument {
61
+ meetingId: string;
62
+ title: string;
63
+ startTime: string;
64
+ endTime: string;
65
+ duration: number;
66
+ participants: Array<{ email: string; name: string | null; role: string }>;
67
+ status: string;
68
+ transcript: TranscriptSegment[] | null;
69
+ notes: MeetingNotes | null;
70
+ }
71
+
72
+ function formatDuration(seconds: number): string {
73
+ const h = Math.floor(seconds / 3600);
74
+ const m = Math.floor((seconds % 3600) / 60);
75
+ const s = Math.floor(seconds % 60);
76
+ if (h > 0) return `${h}h ${m}m`;
77
+ if (m > 0) return `${m}m ${s}s`;
78
+ return `${s}s`;
79
+ }
80
+
81
+ function formatTimestamp(ts: number): string {
82
+ const m = Math.floor(ts / 60);
83
+ const s = Math.floor(ts % 60);
84
+ return `${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`;
85
+ }
86
+
87
+ function statusBadge(status: string): string {
88
+ switch (status) {
89
+ case "completed":
90
+ return chalk.green(status);
91
+ case "recording":
92
+ return chalk.red(status);
93
+ case "processing":
94
+ return chalk.yellow(status);
95
+ case "failed":
96
+ return chalk.red(status);
97
+ default:
98
+ return chalk.dim(status);
99
+ }
100
+ }
101
+
102
+ async function resolveShortId(
103
+ token: string,
104
+ prefix: string,
105
+ query: Record<string, string>,
106
+ ): Promise<string> {
107
+ if (prefix.includes("-") && prefix.length > 8) return prefix;
108
+ const res = await vaultApiFetch({ token, path: "/v1/meetings", query });
109
+ if (!res.ok) return prefix;
110
+ const data = (await res.json()) as { meetings: MeetingListItem[] };
111
+ const matches = data.meetings.filter((m) => m.meetingId.startsWith(prefix));
112
+ if (matches.length === 1) return matches[0].meetingId;
113
+ if (matches.length > 1) {
114
+ console.error(chalk.red(`Ambiguous ID prefix "${prefix}" — matches ${matches.length} meetings. Use a longer prefix.`));
115
+ process.exit(1);
116
+ }
117
+ return prefix;
118
+ }
119
+
120
+ async function handleApiError(res: Response): Promise<never> {
121
+ const body = (await res.json().catch(() => ({}))) as Record<string, string>;
122
+ if (res.status === 401) {
123
+ console.error(chalk.red("Not authenticated — run `hq login` first"));
124
+ } else if (res.status === 403) {
125
+ console.error(chalk.red(body.error ?? "Not authorized"));
126
+ } else if (res.status === 404) {
127
+ console.error(chalk.red(body.error ?? "Not found"));
128
+ } else {
129
+ console.error(chalk.red(`API error (${res.status}): ${body.error ?? res.statusText}`));
130
+ }
131
+ process.exit(1);
132
+ }
133
+
134
+ function printMeetingTable(meetings: MeetingListItem[]): void {
135
+ if (meetings.length === 0) {
136
+ console.log(chalk.dim(" No meetings found."));
137
+ return;
138
+ }
139
+
140
+ const ID_W = 8;
141
+ const TITLE_W = Math.min(40, Math.max(10, ...meetings.map((m) => m.title.length)));
142
+ const DATE_W = 16;
143
+ const DUR_W = 8;
144
+ const STATUS_W = 12;
145
+ const PARTS_W = 6;
146
+ const FLAGS_W = 5;
147
+
148
+ console.log(
149
+ chalk.bold(
150
+ [
151
+ "ID".padEnd(ID_W),
152
+ "TITLE".padEnd(TITLE_W),
153
+ "DATE".padEnd(DATE_W),
154
+ "DUR".padEnd(DUR_W),
155
+ "STATUS".padEnd(STATUS_W),
156
+ "PARTS".padEnd(PARTS_W),
157
+ "FLAGS",
158
+ ].join(" "),
159
+ ),
160
+ );
161
+
162
+ for (const m of meetings) {
163
+ const id = m.meetingId.slice(0, 8);
164
+ const title = m.title.length > TITLE_W ? m.title.slice(0, TITLE_W - 1) + "…" : m.title;
165
+ const date = new Date(m.startTime).toLocaleDateString("en-US", {
166
+ month: "short",
167
+ day: "numeric",
168
+ hour: "2-digit",
169
+ minute: "2-digit",
170
+ });
171
+ const dur = formatDuration(m.duration);
172
+ const flags = [
173
+ m.hasTranscript ? "T" : "",
174
+ m.hasNotes ? "N" : "",
175
+ ].filter(Boolean).join("") || "-";
176
+
177
+ console.log(
178
+ [
179
+ chalk.cyan(id.padEnd(ID_W)),
180
+ title.padEnd(TITLE_W),
181
+ chalk.dim(date.padEnd(DATE_W)),
182
+ dur.padEnd(DUR_W),
183
+ statusBadge(m.status).padEnd(STATUS_W + 10), // chalk adds escape chars
184
+ String(m.participantCount).padEnd(PARTS_W),
185
+ flags,
186
+ ].join(" "),
187
+ );
188
+ }
189
+ }
190
+
191
+ export function registerMeetingsCommand(program: Command): void {
192
+ const meetings = program
193
+ .command("meetings")
194
+ .description("View and search meeting recordings, transcripts, and notes")
195
+ .option("--company <slug>", "Company slug (for multi-company users)")
196
+ .option("--json", "Output raw JSON instead of formatted text");
197
+
198
+ // ── hq meetings list ──────────────────────────────────────────────
199
+
200
+ meetings
201
+ .command("list")
202
+ .description("List recorded meetings (newest first)")
203
+ .option("--limit <n>", "Number of meetings to return (default: 20)")
204
+ .option("--next <token>", "Pagination token from a previous response")
205
+ .action(async (opts: { limit?: string; next?: string }) => {
206
+ try {
207
+ const token = await ensureCognitoToken();
208
+ const query: Record<string, string> = {};
209
+ const companySlug = meetings.opts().company as string | undefined;
210
+
211
+ if (opts.limit) query.limit = opts.limit;
212
+ if (opts.next) query.nextToken = opts.next;
213
+ if (companySlug) query.companyId = companySlug;
214
+
215
+ const res = await vaultApiFetch({ token, path: "/v1/meetings", query });
216
+ if (!res.ok) await handleApiError(res);
217
+
218
+ const data = (await res.json()) as {
219
+ meetings: MeetingListItem[];
220
+ nextToken?: string;
221
+ };
222
+
223
+ if (meetings.opts().json) {
224
+ console.log(JSON.stringify(data, null, 2));
225
+ return;
226
+ }
227
+
228
+ console.log(chalk.bold(`\nMeetings (${data.meetings.length}):\n`));
229
+ printMeetingTable(data.meetings);
230
+
231
+ if (data.nextToken) {
232
+ console.log(
233
+ chalk.dim(`\n More results available. Run with --next ${data.nextToken}`),
234
+ );
235
+ }
236
+ console.log();
237
+ } catch (err) {
238
+ console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
239
+ process.exit(1);
240
+ }
241
+ });
242
+
243
+ // ── hq meetings get <id> ──────────────────────────────────────────
244
+
245
+ meetings
246
+ .command("get <meetingId>")
247
+ .description("Show meeting details")
248
+ .action(async (rawId: string) => {
249
+ try {
250
+ const token = await ensureCognitoToken();
251
+ const query: Record<string, string> = {};
252
+ const companySlug = meetings.opts().company as string | undefined;
253
+ if (companySlug) query.companyId = companySlug;
254
+
255
+ const meetingId = await resolveShortId(token, rawId, query);
256
+ const res = await vaultApiFetch({
257
+ token,
258
+ path: `/v1/meetings/${encodeURIComponent(meetingId)}`,
259
+ query,
260
+ });
261
+ if (!res.ok) await handleApiError(res);
262
+
263
+ const detail = (await res.json()) as MeetingDetail;
264
+
265
+ if (meetings.opts().json) {
266
+ console.log(JSON.stringify(detail, null, 2));
267
+ return;
268
+ }
269
+
270
+ console.log(chalk.bold(`\n${detail.title}\n`));
271
+ console.log(` ID: ${chalk.cyan(detail.meetingId)}`);
272
+ console.log(` Status: ${statusBadge(detail.status)}`);
273
+ console.log(` Date: ${new Date(detail.startTime).toLocaleString()}`);
274
+ console.log(` Duration: ${formatDuration(detail.duration)}`);
275
+ console.log(` Source: ${detail.sourceApp} (${detail.botProvider})`);
276
+ console.log(` Shared: ${detail.isShared ? "yes" : "no"}`);
277
+
278
+ if (detail.participants.length > 0) {
279
+ console.log(chalk.bold("\n Participants:"));
280
+ for (const p of detail.participants) {
281
+ const name = p.name ?? p.email;
282
+ const role = p.role === "organizer" ? chalk.yellow(" (organizer)") : "";
283
+ console.log(` - ${name}${role}`);
284
+ }
285
+ }
286
+
287
+ const flags = [];
288
+ if (detail.hasTranscript) flags.push("transcript");
289
+ if (detail.hasNotes) flags.push("notes");
290
+ if (flags.length > 0) {
291
+ console.log(
292
+ chalk.dim(`\n Available: ${flags.join(", ")}. Use \`hq meetings transcript ${detail.meetingId.slice(0, 8)}\` or \`hq meetings notes ${detail.meetingId.slice(0, 8)}\`.`),
293
+ );
294
+ }
295
+ console.log();
296
+ } catch (err) {
297
+ console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
298
+ process.exit(1);
299
+ }
300
+ });
301
+
302
+ // ── hq meetings search <query> ─────────────────────────────────────
303
+
304
+ meetings
305
+ .command("search <query>")
306
+ .description("Search meetings by title or participant name")
307
+ .action(async (query: string) => {
308
+ try {
309
+ const token = await ensureCognitoToken();
310
+ const params: Record<string, string> = { q: query };
311
+ const companySlug = meetings.opts().company as string | undefined;
312
+ if (companySlug) params.companyId = companySlug;
313
+
314
+ const res = await vaultApiFetch({
315
+ token,
316
+ path: "/v1/meetings/search",
317
+ query: params,
318
+ });
319
+ if (!res.ok) await handleApiError(res);
320
+
321
+ const data = (await res.json()) as {
322
+ results: MeetingListItem[];
323
+ query: string;
324
+ };
325
+
326
+ if (meetings.opts().json) {
327
+ console.log(JSON.stringify(data, null, 2));
328
+ return;
329
+ }
330
+
331
+ console.log(chalk.bold(`\nSearch results for "${data.query}" (${data.results.length}):\n`));
332
+ printMeetingTable(data.results);
333
+ console.log();
334
+ } catch (err) {
335
+ console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
336
+ process.exit(1);
337
+ }
338
+ });
339
+
340
+ // ── hq meetings transcript <id> ────────────────────────────────────
341
+
342
+ meetings
343
+ .command("transcript <meetingId>")
344
+ .description("Print the meeting transcript")
345
+ .action(async (rawId: string) => {
346
+ try {
347
+ const token = await ensureCognitoToken();
348
+ const query: Record<string, string> = {};
349
+ const companySlug = meetings.opts().company as string | undefined;
350
+ if (companySlug) query.companyId = companySlug;
351
+
352
+ const meetingId = await resolveShortId(token, rawId, query);
353
+ const res = await vaultApiFetch({
354
+ token,
355
+ path: `/v1/meetings/${encodeURIComponent(meetingId)}`,
356
+ query,
357
+ });
358
+ if (!res.ok) await handleApiError(res);
359
+
360
+ const detail = (await res.json()) as MeetingDetail;
361
+ if (!detail.documentUrl) {
362
+ console.error(chalk.red("No document URL available for this meeting."));
363
+ process.exit(1);
364
+ }
365
+
366
+ const docRes = await fetch(detail.documentUrl);
367
+ if (!docRes.ok) {
368
+ console.error(chalk.red(`Failed to download meeting document (${docRes.status})`));
369
+ process.exit(1);
370
+ }
371
+
372
+ const doc = (await docRes.json()) as MeetingDocument;
373
+
374
+ if (meetings.opts().json) {
375
+ console.log(JSON.stringify(doc.transcript, null, 2));
376
+ return;
377
+ }
378
+
379
+ if (!doc.transcript || doc.transcript.length === 0) {
380
+ console.log(chalk.yellow("No transcript available for this meeting."));
381
+ return;
382
+ }
383
+
384
+ console.log(chalk.bold(`\nTranscript: ${doc.title}\n`));
385
+ for (const seg of doc.transcript) {
386
+ const time = formatTimestamp(seg.startTime);
387
+ console.log(`${chalk.dim(time)} ${chalk.cyan(seg.speaker)}`);
388
+ console.log(` ${seg.text}\n`);
389
+ }
390
+ } catch (err) {
391
+ console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
392
+ process.exit(1);
393
+ }
394
+ });
395
+
396
+ // ── hq meetings notes <id> ─────────────────────────────────────────
397
+
398
+ meetings
399
+ .command("notes <meetingId>")
400
+ .description("Print AI-generated meeting notes")
401
+ .action(async (rawId: string) => {
402
+ try {
403
+ const token = await ensureCognitoToken();
404
+ const query: Record<string, string> = {};
405
+ const companySlug = meetings.opts().company as string | undefined;
406
+ if (companySlug) query.companyId = companySlug;
407
+
408
+ const meetingId = await resolveShortId(token, rawId, query);
409
+ const res = await vaultApiFetch({
410
+ token,
411
+ path: `/v1/meetings/${encodeURIComponent(meetingId)}`,
412
+ query,
413
+ });
414
+ if (!res.ok) await handleApiError(res);
415
+
416
+ const detail = (await res.json()) as MeetingDetail;
417
+ if (!detail.documentUrl) {
418
+ console.error(chalk.red("No document URL available for this meeting."));
419
+ process.exit(1);
420
+ }
421
+
422
+ const docRes = await fetch(detail.documentUrl);
423
+ if (!docRes.ok) {
424
+ console.error(chalk.red(`Failed to download meeting document (${docRes.status})`));
425
+ process.exit(1);
426
+ }
427
+
428
+ const doc = (await docRes.json()) as MeetingDocument;
429
+
430
+ if (meetings.opts().json) {
431
+ console.log(JSON.stringify(doc.notes, null, 2));
432
+ return;
433
+ }
434
+
435
+ if (!doc.notes) {
436
+ console.log(chalk.yellow("No notes available for this meeting."));
437
+ return;
438
+ }
439
+
440
+ const notes = doc.notes;
441
+ console.log(chalk.bold(`\nMeeting Notes: ${doc.title}\n`));
442
+
443
+ console.log(chalk.bold("Summary"));
444
+ console.log(` ${notes.summary}\n`);
445
+
446
+ if (notes.keyPoints.length > 0) {
447
+ console.log(chalk.bold("Key Points"));
448
+ for (const point of notes.keyPoints) {
449
+ console.log(` • ${point}`);
450
+ }
451
+ console.log();
452
+ }
453
+
454
+ if (notes.decisions.length > 0) {
455
+ console.log(chalk.bold("Decisions"));
456
+ for (const d of notes.decisions) {
457
+ console.log(` ✓ ${d}`);
458
+ }
459
+ console.log();
460
+ }
461
+
462
+ if (notes.actionItems.length > 0) {
463
+ console.log(chalk.bold("Action Items"));
464
+ for (const item of notes.actionItems) {
465
+ const assignee = item.assignee ? chalk.dim(` → ${item.assignee}`) : "";
466
+ console.log(` □ ${item.task}${assignee}`);
467
+ }
468
+ console.log();
469
+ }
470
+
471
+ if (notes.participantContributions.length > 0) {
472
+ console.log(chalk.bold("Participant Contributions"));
473
+ for (const p of notes.participantContributions) {
474
+ console.log(` ${p.name} (${p.speakingTimePercent}%)`);
475
+ console.log(` ${chalk.dim(p.topicsSummary)}`);
476
+ }
477
+ console.log();
478
+ }
479
+
480
+ console.log(chalk.dim(`Generated by ${notes.model} at ${notes.generatedAt}`));
481
+ console.log();
482
+ } catch (err) {
483
+ console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
484
+ process.exit(1);
485
+ }
486
+ });
487
+ }
@@ -0,0 +1,148 @@
1
+ /**
2
+ * pack-install layout tests — guards the boundary between hq-cli and the
3
+ * HQ template's on-disk layout.
4
+ *
5
+ * The HQ template (hq-core / hq-core-staging) ships:
6
+ * - `core/packages/` as the install root for content packs
7
+ * - `core/scripts/scan-packages.sh` as the post-install wirer
8
+ * - NO top-level `modules/` directory under the new layout
9
+ *
10
+ * Earlier `pack-install` wrote to `packages/<name>/` (top-level), called
11
+ * `scripts/scan-packages.sh` (top-level), and appended entries to
12
+ * `modules/modules.yaml` — leaving three orphan trees alongside the real
13
+ * `core/packages/`. This file pins the new contract end-to-end.
14
+ *
15
+ * Uses real `rsync` (POSIX-available on macOS / Linux runners) so the test
16
+ * exercises the same shell-out the production path does — no hand-rolled
17
+ * mocks of payload-copy behavior.
18
+ */
19
+
20
+ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
21
+ import * as fs from 'fs';
22
+ import * as os from 'os';
23
+ import * as path from 'path';
24
+ import { installToPackages, runScanPackages } from './pack-install.js';
25
+ import type { PackManifest } from '../types.js';
26
+
27
+ // ---------------------------------------------------------------------------
28
+ // Fixtures
29
+ // ---------------------------------------------------------------------------
30
+
31
+ function mkFakeHq(): string {
32
+ return fs.mkdtempSync(path.join(os.tmpdir(), 'hq-cli-test-hq-'));
33
+ }
34
+
35
+ function mkFakePackPayload(files: Record<string, string>): string {
36
+ const payload = fs.mkdtempSync(path.join(os.tmpdir(), 'hq-cli-test-pack-'));
37
+ for (const [rel, body] of Object.entries(files)) {
38
+ const abs = path.join(payload, rel);
39
+ fs.mkdirSync(path.dirname(abs), { recursive: true });
40
+ fs.writeFileSync(abs, body);
41
+ }
42
+ return payload;
43
+ }
44
+
45
+ function fakeManifest(overrides?: Partial<PackManifest>): PackManifest {
46
+ return {
47
+ name: 'hq-pack-test',
48
+ version: '1.0.0',
49
+ contributes: {},
50
+ ...overrides,
51
+ } as PackManifest;
52
+ }
53
+
54
+ // ---------------------------------------------------------------------------
55
+ // Tests
56
+ // ---------------------------------------------------------------------------
57
+
58
+ describe('pack-install: install path layout', () => {
59
+ let hqRoot: string;
60
+ let payload: string;
61
+
62
+ beforeEach(() => {
63
+ hqRoot = mkFakeHq();
64
+ payload = mkFakePackPayload({
65
+ 'README.md': '# pack readme',
66
+ 'package.yaml': 'name: hq-pack-test\nversion: 1.0.0\n',
67
+ 'hooks/pre.sh': '#!/bin/sh\necho hi\n',
68
+ });
69
+ });
70
+
71
+ afterEach(() => {
72
+ fs.rmSync(hqRoot, { recursive: true, force: true });
73
+ fs.rmSync(payload, { recursive: true, force: true });
74
+ });
75
+
76
+ // ---- 1. install destination ---------------------------------------------
77
+ it('installToPackages writes the payload under core/packages/<name>/, NOT top-level packages/', () => {
78
+ const dest = installToPackages(payload, fakeManifest({ name: 'hq-pack-test' }), hqRoot);
79
+
80
+ // New layout: core/packages/<name>/
81
+ expect(dest).toBe(path.join(hqRoot, 'core', 'packages', 'hq-pack-test'));
82
+ expect(fs.existsSync(path.join(hqRoot, 'core', 'packages', 'hq-pack-test', 'README.md'))).toBe(
83
+ true,
84
+ );
85
+ expect(
86
+ fs.existsSync(path.join(hqRoot, 'core', 'packages', 'hq-pack-test', 'hooks', 'pre.sh')),
87
+ ).toBe(true);
88
+
89
+ // Top-level packages/ must NOT be created — that was the old buggy layout.
90
+ expect(fs.existsSync(path.join(hqRoot, 'packages'))).toBe(false);
91
+ });
92
+
93
+ // ---- 2. re-install idempotency -----------------------------------------
94
+ it('installToPackages replaces an existing core/packages/<name> destination cleanly', () => {
95
+ // Seed a stale install with a file the new payload doesn't have. A clean
96
+ // re-install must wipe it — otherwise stale contributions linger and
97
+ // scan-packages.sh wires them back into host paths.
98
+ const dest = path.join(hqRoot, 'core', 'packages', 'hq-pack-test');
99
+ fs.mkdirSync(dest, { recursive: true });
100
+ fs.writeFileSync(path.join(dest, 'STALE-FILE.md'), 'old content');
101
+
102
+ installToPackages(payload, fakeManifest({ name: 'hq-pack-test' }), hqRoot);
103
+
104
+ expect(fs.existsSync(path.join(dest, 'README.md'))).toBe(true); // new content
105
+ expect(fs.existsSync(path.join(dest, 'STALE-FILE.md'))).toBe(false); // wiped
106
+ });
107
+
108
+ // ---- 3. scan-packages.sh resolution -------------------------------------
109
+ it('runScanPackages invokes core/scripts/scan-packages.sh when present', () => {
110
+ const scriptDir = path.join(hqRoot, 'core', 'scripts');
111
+ fs.mkdirSync(scriptDir, { recursive: true });
112
+ const sentinel = path.join(hqRoot, '.scan-ran');
113
+ // Self-attesting script: writes a sentinel file when invoked. Lets us
114
+ // verify path resolution without spying on spawnSync.
115
+ fs.writeFileSync(
116
+ path.join(scriptDir, 'scan-packages.sh'),
117
+ `#!/bin/sh\ntouch "${sentinel}"\n`,
118
+ { mode: 0o755 },
119
+ );
120
+
121
+ runScanPackages(hqRoot);
122
+
123
+ expect(fs.existsSync(sentinel)).toBe(true);
124
+ });
125
+
126
+ it('runScanPackages skips with a dim warning when core/scripts/scan-packages.sh is absent', () => {
127
+ // No script anywhere — runScanPackages must not throw, must not invoke
128
+ // the old top-level scripts/scan-packages.sh either.
129
+ const logSpy = vi.spyOn(console, 'log').mockImplementation(() => undefined);
130
+
131
+ expect(() => runScanPackages(hqRoot)).not.toThrow();
132
+
133
+ expect(logSpy).toHaveBeenCalled();
134
+ // The "skipping auto-wire" message goes through chalk.dim, so just match
135
+ // the human-readable substring rather than the ANSI sequence.
136
+ const allLogs = logSpy.mock.calls.map((c) => String(c[0])).join('\n');
137
+ expect(allLogs).toMatch(/scan-packages\.sh not present/);
138
+ logSpy.mockRestore();
139
+ });
140
+
141
+ // ---- 4. no modules/ directory -------------------------------------------
142
+ it('regression: installing a pack does not create top-level modules/ or modules.yaml', () => {
143
+ installToPackages(payload, fakeManifest({ name: 'hq-pack-test' }), hqRoot);
144
+
145
+ expect(fs.existsSync(path.join(hqRoot, 'modules'))).toBe(false);
146
+ expect(fs.existsSync(path.join(hqRoot, 'modules.yaml'))).toBe(false);
147
+ });
148
+ });