@indigoai-us/hq-cli 5.16.0 → 5.17.0-sources-rc.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.
- package/.github/workflows/ci.yml +8 -4
- package/.github/workflows/publish.yml +8 -3
- package/dist/cli-version.d.ts +1 -0
- package/dist/cli-version.js +3 -2
- package/dist/commands/groups.js +6 -6
- package/dist/commands/meetings.js +8 -8
- package/dist/commands/members.d.ts +4 -2
- package/dist/commands/members.js +30 -14
- package/dist/commands/signals.d.ts +24 -0
- package/dist/commands/signals.js +240 -0
- package/dist/commands/sources.d.ts +22 -0
- package/dist/commands/sources.js +250 -0
- package/dist/index.js +8 -2
- package/dist/utils/cognito-session.d.ts +10 -1
- package/dist/utils/cognito-session.js +18 -3
- package/package.json +5 -4
- package/scripts/smoke-sources-signals.sh +103 -0
- package/src/cli-version.ts +5 -1
- package/src/commands/groups.ts +4 -4
- package/src/commands/meetings.ts +6 -6
- package/src/commands/members.test.ts +56 -0
- package/src/commands/members.ts +44 -13
- package/src/commands/signals.ts +345 -0
- package/src/commands/sources.ts +356 -0
- package/src/index.ts +8 -0
- package/src/utils/cognito-session.test.ts +24 -1
- package/src/utils/cognito-session.ts +18 -0
- package/test/commands/signals.test.ts +200 -0
- package/test/commands/sources.test.ts +225 -0
- package/test/fixtures/signals/action_item/sample.md +16 -0
- package/test/fixtures/signals/summary/sample.md +12 -0
- package/test/fixtures/sources/meetings/sample.md +25 -0
- package/test/helpers/cli-runner.ts +150 -0
- package/test/helpers/s3-list-mock.ts +79 -0
- package/test/helpers/vault-service-mock.ts +161 -0
- package/test/sources-signals/smoke.test.ts +228 -0
- package/vitest.config.ts +11 -0
package/src/commands/members.ts
CHANGED
|
@@ -41,7 +41,7 @@ export interface InviteOptions {
|
|
|
41
41
|
export interface InviteResult {
|
|
42
42
|
inviteToken: string;
|
|
43
43
|
magicLink: string;
|
|
44
|
-
membership: { role: string; status: string };
|
|
44
|
+
membership: { role: string; status: string; inviteToken?: string };
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export interface DetectedTarget {
|
|
@@ -132,30 +132,53 @@ export async function inviteMember(
|
|
|
132
132
|
throw new InviteHttpError(
|
|
133
133
|
res.status,
|
|
134
134
|
err.message ?? err.error ?? res.statusText,
|
|
135
|
+
err.code,
|
|
135
136
|
);
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
const data = (await res.json()) as {
|
|
139
|
-
membership
|
|
140
|
-
inviteToken
|
|
140
|
+
membership?: { role: string; status: string; inviteToken?: string };
|
|
141
|
+
inviteToken?: string;
|
|
141
142
|
};
|
|
143
|
+
// The token may arrive at the response root OR nested on the membership row,
|
|
144
|
+
// depending on vault-service version. Resolve from either; never emit
|
|
145
|
+
// `hq://accept/undefined` (a broken link that looks like success).
|
|
146
|
+
const inviteToken = data.inviteToken ?? data.membership?.inviteToken;
|
|
147
|
+
if (!inviteToken) {
|
|
148
|
+
const keys = Object.keys(data ?? {}).join(", ") || "<empty>";
|
|
149
|
+
throw new Error(
|
|
150
|
+
`Invite was created but the server response did not include an invite token (response keys: ${keys}). ` +
|
|
151
|
+
"Run `hq members list` to retrieve the pending invite, or upgrade hq.",
|
|
152
|
+
);
|
|
153
|
+
}
|
|
142
154
|
return {
|
|
143
|
-
inviteToken
|
|
144
|
-
magicLink: `hq://accept/${
|
|
145
|
-
membership: data.membership,
|
|
155
|
+
inviteToken,
|
|
156
|
+
magicLink: `hq://accept/${inviteToken}`,
|
|
157
|
+
membership: data.membership ?? { role: options.role, status: "pending" },
|
|
146
158
|
};
|
|
147
159
|
}
|
|
148
160
|
|
|
149
161
|
export class InviteHttpError extends Error {
|
|
150
|
-
constructor(
|
|
162
|
+
constructor(
|
|
163
|
+
public status: number,
|
|
164
|
+
message: string,
|
|
165
|
+
public code?: string,
|
|
166
|
+
) {
|
|
151
167
|
super(message);
|
|
152
168
|
this.name = "InviteHttpError";
|
|
153
169
|
}
|
|
154
170
|
}
|
|
155
171
|
|
|
156
|
-
export function formatInviteHttpError(
|
|
172
|
+
export function formatInviteHttpError(
|
|
173
|
+
status: number,
|
|
174
|
+
fallback: string,
|
|
175
|
+
code?: string,
|
|
176
|
+
): string {
|
|
157
177
|
if (status === 401) return "Not authenticated — please run `hq login`";
|
|
158
178
|
if (status === 403) {
|
|
179
|
+
if (code === "ADMIN_ROLE_TARGET_RESTRICTED") {
|
|
180
|
+
return "Admin can only invite at role=member; ask an owner to invite at this role";
|
|
181
|
+
}
|
|
159
182
|
return "Not authorized — only admins and owners can invite members";
|
|
160
183
|
}
|
|
161
184
|
if (status === 409) {
|
|
@@ -178,10 +201,11 @@ export async function listPendingInvites(
|
|
|
178
201
|
throw new InviteHttpError(
|
|
179
202
|
res.status,
|
|
180
203
|
err.message ?? err.error ?? res.statusText,
|
|
204
|
+
err.code,
|
|
181
205
|
);
|
|
182
206
|
}
|
|
183
|
-
const data = (await res.json()) as { invites
|
|
184
|
-
return data
|
|
207
|
+
const data = (await res.json()) as { invites?: PendingInvite[] | null };
|
|
208
|
+
return data?.invites ?? [];
|
|
185
209
|
}
|
|
186
210
|
|
|
187
211
|
export async function revokeInvite(
|
|
@@ -200,6 +224,7 @@ export async function revokeInvite(
|
|
|
200
224
|
throw new InviteHttpError(
|
|
201
225
|
res.status,
|
|
202
226
|
err.message ?? err.error ?? res.statusText,
|
|
227
|
+
err.code,
|
|
203
228
|
);
|
|
204
229
|
}
|
|
205
230
|
}
|
|
@@ -260,7 +285,11 @@ export function registerMembersCommand(program: Command): void {
|
|
|
260
285
|
);
|
|
261
286
|
} catch (err) {
|
|
262
287
|
if (err instanceof InviteHttpError) {
|
|
263
|
-
console.error(
|
|
288
|
+
console.error(
|
|
289
|
+
chalk.red(
|
|
290
|
+
formatInviteHttpError(err.status, err.message, err.code),
|
|
291
|
+
),
|
|
292
|
+
);
|
|
264
293
|
process.exit(1);
|
|
265
294
|
}
|
|
266
295
|
console.error(
|
|
@@ -350,10 +379,12 @@ export function registerMembersCommand(program: Command): void {
|
|
|
350
379
|
if (err instanceof InviteHttpError) {
|
|
351
380
|
const msg =
|
|
352
381
|
err.status === 403
|
|
353
|
-
?
|
|
382
|
+
? err.code === "ADMIN_ROLE_TARGET_RESTRICTED"
|
|
383
|
+
? "Admin can only revoke role=member; ask an owner to revoke this membership"
|
|
384
|
+
: "Not authorized — only admins and owners can revoke invites"
|
|
354
385
|
: err.status === 404
|
|
355
386
|
? "Invite not found — it may have already been accepted or revoked"
|
|
356
|
-
: formatInviteHttpError(err.status, err.message);
|
|
387
|
+
: formatInviteHttpError(err.status, err.message, err.code);
|
|
357
388
|
console.error(chalk.red(msg));
|
|
358
389
|
process.exit(1);
|
|
359
390
|
}
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hq signals` subcommand group (US-007).
|
|
3
|
+
*
|
|
4
|
+
* Read-side surface over the signals written by sources-pipeline (and any
|
|
5
|
+
* future signal producer). Each invocation resolves a Cognito access
|
|
6
|
+
* token (or honors HQ_ACCESS_TOKEN), vends STS-scoped credentials via
|
|
7
|
+
* vault-service for the requested entity, and delegates to hq-cloud's
|
|
8
|
+
* listSignals/getSignal primitives.
|
|
9
|
+
*
|
|
10
|
+
* Subcommands:
|
|
11
|
+
* hq signals list List signals of a given type for an entity.
|
|
12
|
+
* hq signals get Fetch one signal by id.
|
|
13
|
+
* hq signals types Print the canonical SIGNAL_TYPES enum.
|
|
14
|
+
* hq signals entities List entities the caller has access to.
|
|
15
|
+
*
|
|
16
|
+
* Mirrors `hq sources` exactly — same flags, same TTY-aware defaults,
|
|
17
|
+
* same error/Sentry plumbing. Defense-in-depth signal-type validation
|
|
18
|
+
* (assertSignalType) runs at the CLI layer as well as in hq-cloud, so
|
|
19
|
+
* agents can't fabricate a signal type even if they bypass the CLI's
|
|
20
|
+
* --type flag parsing.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import * as fs from "node:fs";
|
|
24
|
+
import * as path from "node:path";
|
|
25
|
+
import { Command } from "commander";
|
|
26
|
+
import chalk from "chalk";
|
|
27
|
+
import {
|
|
28
|
+
SIGNAL_TYPES,
|
|
29
|
+
assertSignalType,
|
|
30
|
+
resolveEntity,
|
|
31
|
+
listAvailableEntities,
|
|
32
|
+
listSignals,
|
|
33
|
+
getSignal,
|
|
34
|
+
type SignalType,
|
|
35
|
+
type SignalSummary,
|
|
36
|
+
type SignalDocument,
|
|
37
|
+
type AvailableEntity,
|
|
38
|
+
type EntityContext,
|
|
39
|
+
} from "@indigoai-us/hq-cloud";
|
|
40
|
+
import {
|
|
41
|
+
ensureCognitoToken,
|
|
42
|
+
buildVaultConfig,
|
|
43
|
+
DEFAULT_HQ_ROOT,
|
|
44
|
+
} from "../utils/cognito-session.js";
|
|
45
|
+
import { Sentry } from "../sentry.js";
|
|
46
|
+
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
// Access token resolution — honors HQ_ACCESS_TOKEN for tests + CI smoke
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
|
|
51
|
+
async function resolveAccessToken(): Promise<string> {
|
|
52
|
+
if (process.env.HQ_ACCESS_TOKEN) return process.env.HQ_ACCESS_TOKEN;
|
|
53
|
+
return ensureCognitoToken();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
// Entity resolution — flag → .hq/config.json activeCompany fallback
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
|
|
60
|
+
function readActiveCompanySlug(hqRoot: string): string | undefined {
|
|
61
|
+
const configPath = path.join(hqRoot, ".hq", "config.json");
|
|
62
|
+
if (!fs.existsSync(configPath)) return undefined;
|
|
63
|
+
try {
|
|
64
|
+
const cfg = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
65
|
+
const slug = (cfg as { activeCompany?: unknown }).activeCompany;
|
|
66
|
+
return typeof slug === "string" && slug.length > 0 ? slug : undefined;
|
|
67
|
+
} catch {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function requireEntitySlug(flag: string | undefined, hqRoot: string): string {
|
|
73
|
+
const slug = flag ?? readActiveCompanySlug(hqRoot);
|
|
74
|
+
if (!slug) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
"No entity specified. Pass --entity <slug> or run `hq signals entities` to see your options.",
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
return slug;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
// Format defaults — TTY-aware (humans get table, agents get JSON)
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
|
|
86
|
+
type ListFormat = "table" | "json";
|
|
87
|
+
type GetFormat = "markdown" | "json";
|
|
88
|
+
|
|
89
|
+
function defaultListFormat(): ListFormat {
|
|
90
|
+
return process.stdout.isTTY ? "table" : "json";
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function defaultGetFormat(): GetFormat {
|
|
94
|
+
return process.stdout.isTTY ? "markdown" : "json";
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
// Rendering helpers
|
|
99
|
+
// ---------------------------------------------------------------------------
|
|
100
|
+
|
|
101
|
+
function renderListTable(entries: SignalSummary[], includeFrontmatter: boolean): string {
|
|
102
|
+
if (entries.length === 0) return "(no signals)";
|
|
103
|
+
// sourceRef column is only meaningful when --include-frontmatter was passed;
|
|
104
|
+
// omit it otherwise so the table doesn't lie with empty cells.
|
|
105
|
+
const rows = entries.map((e) => ({
|
|
106
|
+
signalId: e.signalId,
|
|
107
|
+
...(includeFrontmatter ? { sourceRef: e.sourceRef ?? "" } : {}),
|
|
108
|
+
lastModified: e.lastModified.toISOString(),
|
|
109
|
+
size: String(e.size),
|
|
110
|
+
}));
|
|
111
|
+
const headers = Object.keys(rows[0]);
|
|
112
|
+
const widths = headers.map((h) =>
|
|
113
|
+
Math.max(h.length, ...rows.map((r) => String((r as Record<string, string>)[h]).length)),
|
|
114
|
+
);
|
|
115
|
+
const pad = (s: string, w: number): string => s + " ".repeat(Math.max(0, w - s.length));
|
|
116
|
+
const headerLine = headers.map((h, i) => pad(h, widths[i])).join(" ");
|
|
117
|
+
const sep = widths.map((w) => "-".repeat(w)).join(" ");
|
|
118
|
+
const body = rows
|
|
119
|
+
.map((r) =>
|
|
120
|
+
headers.map((h, i) => pad(String((r as Record<string, string>)[h]), widths[i])).join(" "),
|
|
121
|
+
)
|
|
122
|
+
.join("\n");
|
|
123
|
+
return [headerLine, sep, body].join("\n");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
// Subcommand: list
|
|
128
|
+
// ---------------------------------------------------------------------------
|
|
129
|
+
|
|
130
|
+
interface ListOptions {
|
|
131
|
+
entity?: string;
|
|
132
|
+
type?: string;
|
|
133
|
+
limit?: string;
|
|
134
|
+
pageToken?: string;
|
|
135
|
+
format?: ListFormat;
|
|
136
|
+
includeFrontmatter?: boolean;
|
|
137
|
+
hqRoot: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async function runList(options: ListOptions): Promise<void> {
|
|
141
|
+
if (!options.type) {
|
|
142
|
+
throw new Error(
|
|
143
|
+
`--type <signalType> is required. Valid types: ${SIGNAL_TYPES.join(", ")}`,
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
// Throws InvalidSignalTypeError with the list of valid types if not in enum.
|
|
147
|
+
assertSignalType(options.type);
|
|
148
|
+
const signalType: SignalType = options.type;
|
|
149
|
+
|
|
150
|
+
const slug = requireEntitySlug(options.entity, options.hqRoot);
|
|
151
|
+
const limit = options.limit ? Number.parseInt(options.limit, 10) : 50;
|
|
152
|
+
if (!Number.isFinite(limit) || limit <= 0) {
|
|
153
|
+
throw new Error(`--limit must be a positive integer (got '${options.limit}')`);
|
|
154
|
+
}
|
|
155
|
+
const format = options.format ?? defaultListFormat();
|
|
156
|
+
|
|
157
|
+
const accessToken = await resolveAccessToken();
|
|
158
|
+
const vaultConfig = buildVaultConfig(accessToken);
|
|
159
|
+
const entity: EntityContext = await resolveEntity({ slug, vaultConfig });
|
|
160
|
+
|
|
161
|
+
const result = await listSignals({
|
|
162
|
+
entity,
|
|
163
|
+
signalType,
|
|
164
|
+
limit,
|
|
165
|
+
continuationToken: options.pageToken,
|
|
166
|
+
includeFrontmatter: options.includeFrontmatter,
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
if (format === "json") {
|
|
170
|
+
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
process.stdout.write(renderListTable(result.entries, !!options.includeFrontmatter) + "\n");
|
|
175
|
+
if (result.nextToken) {
|
|
176
|
+
process.stdout.write(`\nNext page token: ${result.nextToken}\n`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// ---------------------------------------------------------------------------
|
|
181
|
+
// Subcommand: get
|
|
182
|
+
// ---------------------------------------------------------------------------
|
|
183
|
+
|
|
184
|
+
interface GetOptions {
|
|
185
|
+
entity?: string;
|
|
186
|
+
type?: string;
|
|
187
|
+
id?: string;
|
|
188
|
+
format?: GetFormat;
|
|
189
|
+
hqRoot: string;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async function runGet(options: GetOptions): Promise<void> {
|
|
193
|
+
if (!options.type) {
|
|
194
|
+
throw new Error(
|
|
195
|
+
`--type <signalType> is required. Valid types: ${SIGNAL_TYPES.join(", ")}`,
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
if (!options.id) {
|
|
199
|
+
throw new Error("--id <signalId> is required.");
|
|
200
|
+
}
|
|
201
|
+
assertSignalType(options.type);
|
|
202
|
+
const signalType: SignalType = options.type;
|
|
203
|
+
|
|
204
|
+
const slug = requireEntitySlug(options.entity, options.hqRoot);
|
|
205
|
+
const format = options.format ?? defaultGetFormat();
|
|
206
|
+
|
|
207
|
+
const accessToken = await resolveAccessToken();
|
|
208
|
+
const vaultConfig = buildVaultConfig(accessToken);
|
|
209
|
+
const entity: EntityContext = await resolveEntity({ slug, vaultConfig });
|
|
210
|
+
|
|
211
|
+
const doc: SignalDocument = await getSignal({
|
|
212
|
+
entity,
|
|
213
|
+
signalType,
|
|
214
|
+
signalId: options.id,
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
if (format === "json") {
|
|
218
|
+
process.stdout.write(JSON.stringify(doc, null, 2) + "\n");
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// markdown: reconstruct frontmatter block + body so the output round-trips.
|
|
223
|
+
if (doc.frontmatter) {
|
|
224
|
+
const yamlLines = Object.entries(doc.frontmatter).map(
|
|
225
|
+
([k, v]) => `${k}: ${typeof v === "string" ? v : JSON.stringify(v)}`,
|
|
226
|
+
);
|
|
227
|
+
process.stdout.write(`---\n${yamlLines.join("\n")}\n---\n\n${doc.body}\n`);
|
|
228
|
+
} else {
|
|
229
|
+
process.stdout.write(doc.body + "\n");
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// ---------------------------------------------------------------------------
|
|
234
|
+
// Subcommand: types
|
|
235
|
+
// ---------------------------------------------------------------------------
|
|
236
|
+
|
|
237
|
+
function runTypes(): void {
|
|
238
|
+
const sorted = [...SIGNAL_TYPES].sort();
|
|
239
|
+
process.stdout.write(sorted.join("\n") + "\n");
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// ---------------------------------------------------------------------------
|
|
243
|
+
// Subcommand: entities (alias — identical to `hq sources entities`)
|
|
244
|
+
// ---------------------------------------------------------------------------
|
|
245
|
+
|
|
246
|
+
async function runEntities(options: { format?: ListFormat }): Promise<void> {
|
|
247
|
+
const format = options.format ?? defaultListFormat();
|
|
248
|
+
const accessToken = await resolveAccessToken();
|
|
249
|
+
const vaultConfig = buildVaultConfig(accessToken);
|
|
250
|
+
const entities: AvailableEntity[] = await listAvailableEntities({ vaultConfig });
|
|
251
|
+
|
|
252
|
+
if (format === "json") {
|
|
253
|
+
process.stdout.write(JSON.stringify(entities, null, 2) + "\n");
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (entities.length === 0) {
|
|
258
|
+
process.stdout.write("(no entities — your account has no active memberships)\n");
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const headers = ["slug", "role", "uid"];
|
|
263
|
+
const widths = headers.map((h, i) =>
|
|
264
|
+
Math.max(
|
|
265
|
+
h.length,
|
|
266
|
+
...entities.map((e) => String([e.slug, e.role, e.uid][i]).length),
|
|
267
|
+
),
|
|
268
|
+
);
|
|
269
|
+
const pad = (s: string, w: number): string => s + " ".repeat(Math.max(0, w - s.length));
|
|
270
|
+
const headerLine = headers.map((h, i) => pad(h, widths[i])).join(" ");
|
|
271
|
+
const sep = widths.map((w) => "-".repeat(w)).join(" ");
|
|
272
|
+
const body = entities
|
|
273
|
+
.map((e) =>
|
|
274
|
+
[e.slug, e.role, e.uid].map((cell, i) => pad(cell, widths[i])).join(" "),
|
|
275
|
+
)
|
|
276
|
+
.join("\n");
|
|
277
|
+
process.stdout.write([headerLine, sep, body].join("\n") + "\n");
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// ---------------------------------------------------------------------------
|
|
281
|
+
// Registration
|
|
282
|
+
// ---------------------------------------------------------------------------
|
|
283
|
+
|
|
284
|
+
/** Wrap an action so caught errors print red + capture to Sentry + exit 1. */
|
|
285
|
+
function withErrorHandling<T extends unknown[]>(
|
|
286
|
+
fn: (...args: T) => Promise<void> | void,
|
|
287
|
+
): (...args: T) => Promise<void> {
|
|
288
|
+
return async (...args: T) => {
|
|
289
|
+
try {
|
|
290
|
+
await fn(...args);
|
|
291
|
+
} catch (err) {
|
|
292
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
293
|
+
process.stderr.write(chalk.red(`✗ ${message}\n`));
|
|
294
|
+
Sentry.captureException(err);
|
|
295
|
+
process.exit(1);
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export function registerSignalsCommand(program: Command): void {
|
|
301
|
+
const signals = program
|
|
302
|
+
.command("signals")
|
|
303
|
+
.description("Read signals (action_items, decisions, etc.) from a vault entity");
|
|
304
|
+
|
|
305
|
+
signals
|
|
306
|
+
.command("list")
|
|
307
|
+
.description("List signals of a given type for an entity")
|
|
308
|
+
.option("--entity <slug>", "Entity slug (defaults to .hq/config.json activeCompany)")
|
|
309
|
+
.option("--type <signalType>", `Signal type: ${SIGNAL_TYPES.join(" | ")}`)
|
|
310
|
+
.option("--limit <n>", "Max entries per page (default 50)")
|
|
311
|
+
.option("--page-token <token>", "Continuation token from a prior page")
|
|
312
|
+
.option("--format <fmt>", "Output format: table | json (default: table for TTY, json piped)")
|
|
313
|
+
.option("--include-frontmatter", "Fetch + parse each entry's frontmatter (extra GETs)")
|
|
314
|
+
.option(
|
|
315
|
+
"--hq-root <path>",
|
|
316
|
+
`Local HQ tree root (for .hq/config.json lookup; default: ${DEFAULT_HQ_ROOT})`,
|
|
317
|
+
DEFAULT_HQ_ROOT,
|
|
318
|
+
)
|
|
319
|
+
.action(withErrorHandling(async (options: ListOptions) => runList(options)));
|
|
320
|
+
|
|
321
|
+
signals
|
|
322
|
+
.command("get")
|
|
323
|
+
.description("Fetch a single signal by id")
|
|
324
|
+
.option("--entity <slug>", "Entity slug (defaults to .hq/config.json activeCompany)")
|
|
325
|
+
.option("--type <signalType>", `Signal type: ${SIGNAL_TYPES.join(" | ")}`)
|
|
326
|
+
.option("--id <signalId>", "Signal id (filename minus .md)")
|
|
327
|
+
.option("--format <fmt>", "Output format: markdown | json (default: markdown for TTY, json piped)")
|
|
328
|
+
.option(
|
|
329
|
+
"--hq-root <path>",
|
|
330
|
+
`Local HQ tree root (for .hq/config.json lookup; default: ${DEFAULT_HQ_ROOT})`,
|
|
331
|
+
DEFAULT_HQ_ROOT,
|
|
332
|
+
)
|
|
333
|
+
.action(withErrorHandling(async (options: GetOptions) => runGet(options)));
|
|
334
|
+
|
|
335
|
+
signals
|
|
336
|
+
.command("types")
|
|
337
|
+
.description("Print the canonical signal types (one per line)")
|
|
338
|
+
.action(withErrorHandling(() => runTypes()));
|
|
339
|
+
|
|
340
|
+
signals
|
|
341
|
+
.command("entities")
|
|
342
|
+
.description("List entities (companies/personal) your account has access to")
|
|
343
|
+
.option("--format <fmt>", "Output format: table | json (default: table for TTY, json piped)")
|
|
344
|
+
.action(withErrorHandling(async (options: { format?: ListFormat }) => runEntities(options)));
|
|
345
|
+
}
|