@indigoai-us/hq-cli 5.15.0 → 5.17.0-sources-rc.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.
- 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/cloud-provision.d.ts +25 -0
- package/dist/commands/cloud-provision.js +75 -9
- 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/cloud-provision.test.ts +27 -2
- package/src/commands/cloud-provision.ts +122 -7
- 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 +160 -0
- package/test/sources-signals/smoke.test.ts +226 -0
- package/vitest.config.ts +11 -0
|
@@ -0,0 +1,240 @@
|
|
|
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
|
+
!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]="2088e3af-a005-57eb-b642-90aca198460b")}catch(e){}}();
|
|
24
|
+
import * as fs from "node:fs";
|
|
25
|
+
import * as path from "node:path";
|
|
26
|
+
import chalk from "chalk";
|
|
27
|
+
import { SIGNAL_TYPES, assertSignalType, resolveEntity, listAvailableEntities, listSignals, getSignal, } from "@indigoai-us/hq-cloud";
|
|
28
|
+
import { ensureCognitoToken, buildVaultConfig, DEFAULT_HQ_ROOT, } from "../utils/cognito-session.js";
|
|
29
|
+
import { Sentry } from "../sentry.js";
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
// Access token resolution — honors HQ_ACCESS_TOKEN for tests + CI smoke
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
async function resolveAccessToken() {
|
|
34
|
+
if (process.env.HQ_ACCESS_TOKEN)
|
|
35
|
+
return process.env.HQ_ACCESS_TOKEN;
|
|
36
|
+
return ensureCognitoToken();
|
|
37
|
+
}
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Entity resolution — flag → .hq/config.json activeCompany fallback
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
function readActiveCompanySlug(hqRoot) {
|
|
42
|
+
const configPath = path.join(hqRoot, ".hq", "config.json");
|
|
43
|
+
if (!fs.existsSync(configPath))
|
|
44
|
+
return undefined;
|
|
45
|
+
try {
|
|
46
|
+
const cfg = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
47
|
+
const slug = cfg.activeCompany;
|
|
48
|
+
return typeof slug === "string" && slug.length > 0 ? slug : undefined;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function requireEntitySlug(flag, hqRoot) {
|
|
55
|
+
const slug = flag ?? readActiveCompanySlug(hqRoot);
|
|
56
|
+
if (!slug) {
|
|
57
|
+
throw new Error("No entity specified. Pass --entity <slug> or run `hq signals entities` to see your options.");
|
|
58
|
+
}
|
|
59
|
+
return slug;
|
|
60
|
+
}
|
|
61
|
+
function defaultListFormat() {
|
|
62
|
+
return process.stdout.isTTY ? "table" : "json";
|
|
63
|
+
}
|
|
64
|
+
function defaultGetFormat() {
|
|
65
|
+
return process.stdout.isTTY ? "markdown" : "json";
|
|
66
|
+
}
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
// Rendering helpers
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
function renderListTable(entries, includeFrontmatter) {
|
|
71
|
+
if (entries.length === 0)
|
|
72
|
+
return "(no signals)";
|
|
73
|
+
// sourceRef column is only meaningful when --include-frontmatter was passed;
|
|
74
|
+
// omit it otherwise so the table doesn't lie with empty cells.
|
|
75
|
+
const rows = entries.map((e) => ({
|
|
76
|
+
signalId: e.signalId,
|
|
77
|
+
...(includeFrontmatter ? { sourceRef: e.sourceRef ?? "" } : {}),
|
|
78
|
+
lastModified: e.lastModified.toISOString(),
|
|
79
|
+
size: String(e.size),
|
|
80
|
+
}));
|
|
81
|
+
const headers = Object.keys(rows[0]);
|
|
82
|
+
const widths = headers.map((h) => Math.max(h.length, ...rows.map((r) => String(r[h]).length)));
|
|
83
|
+
const pad = (s, w) => s + " ".repeat(Math.max(0, w - s.length));
|
|
84
|
+
const headerLine = headers.map((h, i) => pad(h, widths[i])).join(" ");
|
|
85
|
+
const sep = widths.map((w) => "-".repeat(w)).join(" ");
|
|
86
|
+
const body = rows
|
|
87
|
+
.map((r) => headers.map((h, i) => pad(String(r[h]), widths[i])).join(" "))
|
|
88
|
+
.join("\n");
|
|
89
|
+
return [headerLine, sep, body].join("\n");
|
|
90
|
+
}
|
|
91
|
+
async function runList(options) {
|
|
92
|
+
if (!options.type) {
|
|
93
|
+
throw new Error(`--type <signalType> is required. Valid types: ${SIGNAL_TYPES.join(", ")}`);
|
|
94
|
+
}
|
|
95
|
+
// Throws InvalidSignalTypeError with the list of valid types if not in enum.
|
|
96
|
+
assertSignalType(options.type);
|
|
97
|
+
const signalType = options.type;
|
|
98
|
+
const slug = requireEntitySlug(options.entity, options.hqRoot);
|
|
99
|
+
const limit = options.limit ? Number.parseInt(options.limit, 10) : 50;
|
|
100
|
+
if (!Number.isFinite(limit) || limit <= 0) {
|
|
101
|
+
throw new Error(`--limit must be a positive integer (got '${options.limit}')`);
|
|
102
|
+
}
|
|
103
|
+
const format = options.format ?? defaultListFormat();
|
|
104
|
+
const accessToken = await resolveAccessToken();
|
|
105
|
+
const vaultConfig = buildVaultConfig(accessToken);
|
|
106
|
+
const entity = await resolveEntity({ slug, vaultConfig });
|
|
107
|
+
const result = await listSignals({
|
|
108
|
+
entity,
|
|
109
|
+
signalType,
|
|
110
|
+
limit,
|
|
111
|
+
continuationToken: options.pageToken,
|
|
112
|
+
includeFrontmatter: options.includeFrontmatter,
|
|
113
|
+
});
|
|
114
|
+
if (format === "json") {
|
|
115
|
+
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
process.stdout.write(renderListTable(result.entries, !!options.includeFrontmatter) + "\n");
|
|
119
|
+
if (result.nextToken) {
|
|
120
|
+
process.stdout.write(`\nNext page token: ${result.nextToken}\n`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async function runGet(options) {
|
|
124
|
+
if (!options.type) {
|
|
125
|
+
throw new Error(`--type <signalType> is required. Valid types: ${SIGNAL_TYPES.join(", ")}`);
|
|
126
|
+
}
|
|
127
|
+
if (!options.id) {
|
|
128
|
+
throw new Error("--id <signalId> is required.");
|
|
129
|
+
}
|
|
130
|
+
assertSignalType(options.type);
|
|
131
|
+
const signalType = options.type;
|
|
132
|
+
const slug = requireEntitySlug(options.entity, options.hqRoot);
|
|
133
|
+
const format = options.format ?? defaultGetFormat();
|
|
134
|
+
const accessToken = await resolveAccessToken();
|
|
135
|
+
const vaultConfig = buildVaultConfig(accessToken);
|
|
136
|
+
const entity = await resolveEntity({ slug, vaultConfig });
|
|
137
|
+
const doc = await getSignal({
|
|
138
|
+
entity,
|
|
139
|
+
signalType,
|
|
140
|
+
signalId: options.id,
|
|
141
|
+
});
|
|
142
|
+
if (format === "json") {
|
|
143
|
+
process.stdout.write(JSON.stringify(doc, null, 2) + "\n");
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
// markdown: reconstruct frontmatter block + body so the output round-trips.
|
|
147
|
+
if (doc.frontmatter) {
|
|
148
|
+
const yamlLines = Object.entries(doc.frontmatter).map(([k, v]) => `${k}: ${typeof v === "string" ? v : JSON.stringify(v)}`);
|
|
149
|
+
process.stdout.write(`---\n${yamlLines.join("\n")}\n---\n\n${doc.body}\n`);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
process.stdout.write(doc.body + "\n");
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// ---------------------------------------------------------------------------
|
|
156
|
+
// Subcommand: types
|
|
157
|
+
// ---------------------------------------------------------------------------
|
|
158
|
+
function runTypes() {
|
|
159
|
+
const sorted = [...SIGNAL_TYPES].sort();
|
|
160
|
+
process.stdout.write(sorted.join("\n") + "\n");
|
|
161
|
+
}
|
|
162
|
+
// ---------------------------------------------------------------------------
|
|
163
|
+
// Subcommand: entities (alias — identical to `hq sources entities`)
|
|
164
|
+
// ---------------------------------------------------------------------------
|
|
165
|
+
async function runEntities(options) {
|
|
166
|
+
const format = options.format ?? defaultListFormat();
|
|
167
|
+
const accessToken = await resolveAccessToken();
|
|
168
|
+
const vaultConfig = buildVaultConfig(accessToken);
|
|
169
|
+
const entities = await listAvailableEntities({ vaultConfig });
|
|
170
|
+
if (format === "json") {
|
|
171
|
+
process.stdout.write(JSON.stringify(entities, null, 2) + "\n");
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (entities.length === 0) {
|
|
175
|
+
process.stdout.write("(no entities — your account has no active memberships)\n");
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const headers = ["slug", "role", "uid"];
|
|
179
|
+
const widths = headers.map((h, i) => Math.max(h.length, ...entities.map((e) => String([e.slug, e.role, e.uid][i]).length)));
|
|
180
|
+
const pad = (s, w) => s + " ".repeat(Math.max(0, w - s.length));
|
|
181
|
+
const headerLine = headers.map((h, i) => pad(h, widths[i])).join(" ");
|
|
182
|
+
const sep = widths.map((w) => "-".repeat(w)).join(" ");
|
|
183
|
+
const body = entities
|
|
184
|
+
.map((e) => [e.slug, e.role, e.uid].map((cell, i) => pad(cell, widths[i])).join(" "))
|
|
185
|
+
.join("\n");
|
|
186
|
+
process.stdout.write([headerLine, sep, body].join("\n") + "\n");
|
|
187
|
+
}
|
|
188
|
+
// ---------------------------------------------------------------------------
|
|
189
|
+
// Registration
|
|
190
|
+
// ---------------------------------------------------------------------------
|
|
191
|
+
/** Wrap an action so caught errors print red + capture to Sentry + exit 1. */
|
|
192
|
+
function withErrorHandling(fn) {
|
|
193
|
+
return async (...args) => {
|
|
194
|
+
try {
|
|
195
|
+
await fn(...args);
|
|
196
|
+
}
|
|
197
|
+
catch (err) {
|
|
198
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
199
|
+
process.stderr.write(chalk.red(`✗ ${message}\n`));
|
|
200
|
+
Sentry.captureException(err);
|
|
201
|
+
process.exit(1);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
export function registerSignalsCommand(program) {
|
|
206
|
+
const signals = program
|
|
207
|
+
.command("signals")
|
|
208
|
+
.description("Read signals (action_items, decisions, etc.) from a vault entity");
|
|
209
|
+
signals
|
|
210
|
+
.command("list")
|
|
211
|
+
.description("List signals of a given type for an entity")
|
|
212
|
+
.option("--entity <slug>", "Entity slug (defaults to .hq/config.json activeCompany)")
|
|
213
|
+
.option("--type <signalType>", `Signal type: ${SIGNAL_TYPES.join(" | ")}`)
|
|
214
|
+
.option("--limit <n>", "Max entries per page (default 50)")
|
|
215
|
+
.option("--page-token <token>", "Continuation token from a prior page")
|
|
216
|
+
.option("--format <fmt>", "Output format: table | json (default: table for TTY, json piped)")
|
|
217
|
+
.option("--include-frontmatter", "Fetch + parse each entry's frontmatter (extra GETs)")
|
|
218
|
+
.option("--hq-root <path>", `Local HQ tree root (for .hq/config.json lookup; default: ${DEFAULT_HQ_ROOT})`, DEFAULT_HQ_ROOT)
|
|
219
|
+
.action(withErrorHandling(async (options) => runList(options)));
|
|
220
|
+
signals
|
|
221
|
+
.command("get")
|
|
222
|
+
.description("Fetch a single signal by id")
|
|
223
|
+
.option("--entity <slug>", "Entity slug (defaults to .hq/config.json activeCompany)")
|
|
224
|
+
.option("--type <signalType>", `Signal type: ${SIGNAL_TYPES.join(" | ")}`)
|
|
225
|
+
.option("--id <signalId>", "Signal id (filename minus .md)")
|
|
226
|
+
.option("--format <fmt>", "Output format: markdown | json (default: markdown for TTY, json piped)")
|
|
227
|
+
.option("--hq-root <path>", `Local HQ tree root (for .hq/config.json lookup; default: ${DEFAULT_HQ_ROOT})`, DEFAULT_HQ_ROOT)
|
|
228
|
+
.action(withErrorHandling(async (options) => runGet(options)));
|
|
229
|
+
signals
|
|
230
|
+
.command("types")
|
|
231
|
+
.description("Print the canonical signal types (one per line)")
|
|
232
|
+
.action(withErrorHandling(() => runTypes()));
|
|
233
|
+
signals
|
|
234
|
+
.command("entities")
|
|
235
|
+
.description("List entities (companies/personal) your account has access to")
|
|
236
|
+
.option("--format <fmt>", "Output format: table | json (default: table for TTY, json piped)")
|
|
237
|
+
.action(withErrorHandling(async (options) => runEntities(options)));
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=signals.js.map
|
|
240
|
+
//# debugId=2088e3af-a005-57eb-b642-90aca198460b
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hq sources` subcommand group (US-006).
|
|
3
|
+
*
|
|
4
|
+
* Read-side surface over the sources written by sources-pipeline. Each
|
|
5
|
+
* invocation resolves a Cognito access token (or honors HQ_ACCESS_TOKEN),
|
|
6
|
+
* vends STS-scoped credentials via vault-service for the requested entity,
|
|
7
|
+
* and delegates to hq-cloud's listSources/getSource primitives.
|
|
8
|
+
*
|
|
9
|
+
* Subcommands:
|
|
10
|
+
* hq sources list List sources of a given channel for an entity.
|
|
11
|
+
* hq sources get Fetch one source by id.
|
|
12
|
+
* hq sources channels Print the canonical SOURCE_CHANNELS enum.
|
|
13
|
+
* hq sources entities List entities the caller has access to.
|
|
14
|
+
*
|
|
15
|
+
* Defaults:
|
|
16
|
+
* --entity falls back to .hq/config.json activeCompany (per sync.ts).
|
|
17
|
+
* --format 'table' when stdout is a TTY, 'json' when piped.
|
|
18
|
+
* --limit 50.
|
|
19
|
+
*/
|
|
20
|
+
import { Command } from "commander";
|
|
21
|
+
export declare function registerSourcesCommand(program: Command): void;
|
|
22
|
+
//# sourceMappingURL=sources.d.ts.map
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hq sources` subcommand group (US-006).
|
|
3
|
+
*
|
|
4
|
+
* Read-side surface over the sources written by sources-pipeline. Each
|
|
5
|
+
* invocation resolves a Cognito access token (or honors HQ_ACCESS_TOKEN),
|
|
6
|
+
* vends STS-scoped credentials via vault-service for the requested entity,
|
|
7
|
+
* and delegates to hq-cloud's listSources/getSource primitives.
|
|
8
|
+
*
|
|
9
|
+
* Subcommands:
|
|
10
|
+
* hq sources list List sources of a given channel for an entity.
|
|
11
|
+
* hq sources get Fetch one source by id.
|
|
12
|
+
* hq sources channels Print the canonical SOURCE_CHANNELS enum.
|
|
13
|
+
* hq sources entities List entities the caller has access to.
|
|
14
|
+
*
|
|
15
|
+
* Defaults:
|
|
16
|
+
* --entity falls back to .hq/config.json activeCompany (per sync.ts).
|
|
17
|
+
* --format 'table' when stdout is a TTY, 'json' when piped.
|
|
18
|
+
* --limit 50.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
!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]="df18b298-4724-5557-a579-edfa0f468361")}catch(e){}}();
|
|
22
|
+
import * as fs from "node:fs";
|
|
23
|
+
import * as path from "node:path";
|
|
24
|
+
import chalk from "chalk";
|
|
25
|
+
import { SOURCE_CHANNELS, assertSourceChannel, resolveEntity, listAvailableEntities, listSources, getSource, } from "@indigoai-us/hq-cloud";
|
|
26
|
+
import { ensureCognitoToken, buildVaultConfig, DEFAULT_HQ_ROOT, } from "../utils/cognito-session.js";
|
|
27
|
+
import { Sentry } from "../sentry.js";
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
// Access token resolution — honors HQ_ACCESS_TOKEN for tests + CI smoke
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
/**
|
|
32
|
+
* Returns a usable access token. Tests and CI smoke scripts can set
|
|
33
|
+
* HQ_ACCESS_TOKEN to bypass the interactive Cognito flow; otherwise we fall
|
|
34
|
+
* back to the cached/refresh/browser-login pipeline in cognito-session.ts.
|
|
35
|
+
*/
|
|
36
|
+
async function resolveAccessToken() {
|
|
37
|
+
if (process.env.HQ_ACCESS_TOKEN)
|
|
38
|
+
return process.env.HQ_ACCESS_TOKEN;
|
|
39
|
+
return ensureCognitoToken();
|
|
40
|
+
}
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
// Entity resolution — flag → .hq/config.json activeCompany fallback
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
/**
|
|
45
|
+
* Read the active company slug from .hq/config.json (mirrors sync.ts /
|
|
46
|
+
* cloud.ts behaviour). Returns undefined when the file is missing or the
|
|
47
|
+
* key isn't set; never throws.
|
|
48
|
+
*/
|
|
49
|
+
function readActiveCompanySlug(hqRoot) {
|
|
50
|
+
const configPath = path.join(hqRoot, ".hq", "config.json");
|
|
51
|
+
if (!fs.existsSync(configPath))
|
|
52
|
+
return undefined;
|
|
53
|
+
try {
|
|
54
|
+
const cfg = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
55
|
+
const slug = cfg.activeCompany;
|
|
56
|
+
return typeof slug === "string" && slug.length > 0 ? slug : undefined;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function requireEntitySlug(flag, hqRoot) {
|
|
63
|
+
const slug = flag ?? readActiveCompanySlug(hqRoot);
|
|
64
|
+
if (!slug) {
|
|
65
|
+
throw new Error("No entity specified. Pass --entity <slug> or run `hq sources entities` to see your options.");
|
|
66
|
+
}
|
|
67
|
+
return slug;
|
|
68
|
+
}
|
|
69
|
+
function defaultListFormat() {
|
|
70
|
+
return process.stdout.isTTY ? "table" : "json";
|
|
71
|
+
}
|
|
72
|
+
function defaultGetFormat() {
|
|
73
|
+
return process.stdout.isTTY ? "markdown" : "json";
|
|
74
|
+
}
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
// Rendering helpers
|
|
77
|
+
// ---------------------------------------------------------------------------
|
|
78
|
+
function renderListTable(entries, includeFrontmatter) {
|
|
79
|
+
if (entries.length === 0)
|
|
80
|
+
return "(no sources)";
|
|
81
|
+
const rows = entries.map((e) => ({
|
|
82
|
+
sourceId: e.sourceId,
|
|
83
|
+
lastModified: e.lastModified.toISOString(),
|
|
84
|
+
size: String(e.size),
|
|
85
|
+
...(includeFrontmatter
|
|
86
|
+
? { title: typeof e.frontmatter?.title === "string" ? e.frontmatter.title : "" }
|
|
87
|
+
: {}),
|
|
88
|
+
}));
|
|
89
|
+
const headers = Object.keys(rows[0]);
|
|
90
|
+
const widths = headers.map((h) => Math.max(h.length, ...rows.map((r) => String(r[h]).length)));
|
|
91
|
+
const pad = (s, w) => s + " ".repeat(Math.max(0, w - s.length));
|
|
92
|
+
const headerLine = headers.map((h, i) => pad(h, widths[i])).join(" ");
|
|
93
|
+
const sep = widths.map((w) => "-".repeat(w)).join(" ");
|
|
94
|
+
const body = rows
|
|
95
|
+
.map((r) => headers.map((h, i) => pad(String(r[h]), widths[i])).join(" "))
|
|
96
|
+
.join("\n");
|
|
97
|
+
return [headerLine, sep, body].join("\n");
|
|
98
|
+
}
|
|
99
|
+
async function runList(options) {
|
|
100
|
+
if (!options.type) {
|
|
101
|
+
throw new Error(`--type <channel> is required. Valid channels: ${SOURCE_CHANNELS.join(", ")}`);
|
|
102
|
+
}
|
|
103
|
+
// Throws InvalidSourceChannelError with the list of valid channels if not in enum.
|
|
104
|
+
assertSourceChannel(options.type);
|
|
105
|
+
const channel = options.type;
|
|
106
|
+
const slug = requireEntitySlug(options.entity, options.hqRoot);
|
|
107
|
+
const limit = options.limit ? Number.parseInt(options.limit, 10) : 50;
|
|
108
|
+
if (!Number.isFinite(limit) || limit <= 0) {
|
|
109
|
+
throw new Error(`--limit must be a positive integer (got '${options.limit}')`);
|
|
110
|
+
}
|
|
111
|
+
const format = options.format ?? defaultListFormat();
|
|
112
|
+
const accessToken = await resolveAccessToken();
|
|
113
|
+
const vaultConfig = buildVaultConfig(accessToken);
|
|
114
|
+
const entity = await resolveEntity({ slug, vaultConfig });
|
|
115
|
+
const result = await listSources({
|
|
116
|
+
entity,
|
|
117
|
+
channel,
|
|
118
|
+
limit,
|
|
119
|
+
continuationToken: options.pageToken,
|
|
120
|
+
includeFrontmatter: options.includeFrontmatter,
|
|
121
|
+
});
|
|
122
|
+
if (format === "json") {
|
|
123
|
+
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
process.stdout.write(renderListTable(result.entries, !!options.includeFrontmatter) + "\n");
|
|
127
|
+
if (result.nextToken) {
|
|
128
|
+
process.stdout.write(`\nNext page token: ${result.nextToken}\n`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async function runGet(options) {
|
|
132
|
+
if (!options.type) {
|
|
133
|
+
throw new Error(`--type <channel> is required. Valid channels: ${SOURCE_CHANNELS.join(", ")}`);
|
|
134
|
+
}
|
|
135
|
+
if (!options.id) {
|
|
136
|
+
throw new Error("--id <sourceId> is required.");
|
|
137
|
+
}
|
|
138
|
+
assertSourceChannel(options.type);
|
|
139
|
+
const channel = options.type;
|
|
140
|
+
const slug = requireEntitySlug(options.entity, options.hqRoot);
|
|
141
|
+
const format = options.format ?? defaultGetFormat();
|
|
142
|
+
const accessToken = await resolveAccessToken();
|
|
143
|
+
const vaultConfig = buildVaultConfig(accessToken);
|
|
144
|
+
const entity = await resolveEntity({ slug, vaultConfig });
|
|
145
|
+
const doc = await getSource({
|
|
146
|
+
entity,
|
|
147
|
+
channel,
|
|
148
|
+
sourceId: options.id,
|
|
149
|
+
includeRaw: options.includeRaw,
|
|
150
|
+
});
|
|
151
|
+
if (format === "json") {
|
|
152
|
+
process.stdout.write(JSON.stringify(doc, null, 2) + "\n");
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
// markdown: reconstruct frontmatter block + body so the output round-trips.
|
|
156
|
+
if (doc.frontmatter) {
|
|
157
|
+
const yamlLines = Object.entries(doc.frontmatter).map(([k, v]) => `${k}: ${typeof v === "string" ? v : JSON.stringify(v)}`);
|
|
158
|
+
process.stdout.write(`---\n${yamlLines.join("\n")}\n---\n\n${doc.body}\n`);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
process.stdout.write(doc.body + "\n");
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// ---------------------------------------------------------------------------
|
|
165
|
+
// Subcommand: channels
|
|
166
|
+
// ---------------------------------------------------------------------------
|
|
167
|
+
function runChannels() {
|
|
168
|
+
const sorted = [...SOURCE_CHANNELS].sort();
|
|
169
|
+
process.stdout.write(sorted.join("\n") + "\n");
|
|
170
|
+
}
|
|
171
|
+
// ---------------------------------------------------------------------------
|
|
172
|
+
// Subcommand: entities
|
|
173
|
+
// ---------------------------------------------------------------------------
|
|
174
|
+
async function runEntities(options) {
|
|
175
|
+
const format = options.format ?? defaultListFormat();
|
|
176
|
+
const accessToken = await resolveAccessToken();
|
|
177
|
+
const vaultConfig = buildVaultConfig(accessToken);
|
|
178
|
+
const entities = await listAvailableEntities({ vaultConfig });
|
|
179
|
+
if (format === "json") {
|
|
180
|
+
process.stdout.write(JSON.stringify(entities, null, 2) + "\n");
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (entities.length === 0) {
|
|
184
|
+
process.stdout.write("(no entities — your account has no active memberships)\n");
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const headers = ["slug", "role", "uid"];
|
|
188
|
+
const widths = headers.map((h, i) => Math.max(h.length, ...entities.map((e) => String([e.slug, e.role, e.uid][i]).length)));
|
|
189
|
+
const pad = (s, w) => s + " ".repeat(Math.max(0, w - s.length));
|
|
190
|
+
const headerLine = headers.map((h, i) => pad(h, widths[i])).join(" ");
|
|
191
|
+
const sep = widths.map((w) => "-".repeat(w)).join(" ");
|
|
192
|
+
const body = entities
|
|
193
|
+
.map((e) => [e.slug, e.role, e.uid].map((cell, i) => pad(cell, widths[i])).join(" "))
|
|
194
|
+
.join("\n");
|
|
195
|
+
process.stdout.write([headerLine, sep, body].join("\n") + "\n");
|
|
196
|
+
}
|
|
197
|
+
// ---------------------------------------------------------------------------
|
|
198
|
+
// Registration
|
|
199
|
+
// ---------------------------------------------------------------------------
|
|
200
|
+
/** Wrap an action so caught errors print red + capture to Sentry + exit 1. */
|
|
201
|
+
function withErrorHandling(fn) {
|
|
202
|
+
return async (...args) => {
|
|
203
|
+
try {
|
|
204
|
+
await fn(...args);
|
|
205
|
+
}
|
|
206
|
+
catch (err) {
|
|
207
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
208
|
+
process.stderr.write(chalk.red(`✗ ${message}\n`));
|
|
209
|
+
Sentry.captureException(err);
|
|
210
|
+
process.exit(1);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
export function registerSourcesCommand(program) {
|
|
215
|
+
const sources = program
|
|
216
|
+
.command("sources")
|
|
217
|
+
.description("Read sources (meetings, emails, etc.) from a vault entity");
|
|
218
|
+
sources
|
|
219
|
+
.command("list")
|
|
220
|
+
.description("List sources of a given channel for an entity")
|
|
221
|
+
.option("--entity <slug>", "Entity slug (defaults to .hq/config.json activeCompany)")
|
|
222
|
+
.option("--type <channel>", `Source channel: ${SOURCE_CHANNELS.join(" | ")}`)
|
|
223
|
+
.option("--limit <n>", "Max entries per page (default 50)")
|
|
224
|
+
.option("--page-token <token>", "Continuation token from a prior page")
|
|
225
|
+
.option("--format <fmt>", "Output format: table | json (default: table for TTY, json piped)")
|
|
226
|
+
.option("--include-frontmatter", "Fetch + parse each entry's frontmatter (extra GETs)")
|
|
227
|
+
.option("--hq-root <path>", `Local HQ tree root (for .hq/config.json lookup; default: ${DEFAULT_HQ_ROOT})`, DEFAULT_HQ_ROOT)
|
|
228
|
+
.action(withErrorHandling(async (options) => runList(options)));
|
|
229
|
+
sources
|
|
230
|
+
.command("get")
|
|
231
|
+
.description("Fetch a single source by id")
|
|
232
|
+
.option("--entity <slug>", "Entity slug (defaults to .hq/config.json activeCompany)")
|
|
233
|
+
.option("--type <channel>", `Source channel: ${SOURCE_CHANNELS.join(" | ")}`)
|
|
234
|
+
.option("--id <sourceId>", "Source id (filename minus .md)")
|
|
235
|
+
.option("--format <fmt>", "Output format: markdown | json (default: markdown for TTY, json piped)")
|
|
236
|
+
.option("--include-raw", "Also fetch the .raw.json sibling")
|
|
237
|
+
.option("--hq-root <path>", `Local HQ tree root (for .hq/config.json lookup; default: ${DEFAULT_HQ_ROOT})`, DEFAULT_HQ_ROOT)
|
|
238
|
+
.action(withErrorHandling(async (options) => runGet(options)));
|
|
239
|
+
sources
|
|
240
|
+
.command("channels")
|
|
241
|
+
.description("Print the canonical source channels (one per line)")
|
|
242
|
+
.action(withErrorHandling(() => runChannels()));
|
|
243
|
+
sources
|
|
244
|
+
.command("entities")
|
|
245
|
+
.description("List entities (companies/personal) your account has access to")
|
|
246
|
+
.option("--format <fmt>", "Output format: table | json (default: table for TTY, json piped)")
|
|
247
|
+
.action(withErrorHandling(async (options) => runEntities(options)));
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=sources.js.map
|
|
250
|
+
//# debugId=df18b298-4724-5557-a579-edfa0f468361
|
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]="
|
|
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]="2fc192b3-daa6-5939-a152-1422a7908e87")}catch(e){}}();
|
|
7
7
|
import { Command } from "commander";
|
|
8
8
|
import { initSentry, Sentry } from "./sentry.js";
|
|
9
9
|
import { registerAddCommand } from "./commands/add.js";
|
|
@@ -30,6 +30,8 @@ import { registerFilesCommand } from "./commands/files.js";
|
|
|
30
30
|
import { registerMembersCommand } from "./commands/members.js";
|
|
31
31
|
import { registerFeedbackCommand } from "./commands/feedback.js";
|
|
32
32
|
import { registerMeetingsCommand } from "./commands/meetings.js";
|
|
33
|
+
import { registerSourcesCommand } from "./commands/sources.js";
|
|
34
|
+
import { registerSignalsCommand } from "./commands/signals.js";
|
|
33
35
|
import { sanitizeArgv } from "./utils/feedback-diagnostics.js";
|
|
34
36
|
import { maybeWarnNewVersion, refreshVersionCache, } from "./utils/version-check.js";
|
|
35
37
|
import { CLI_VERSION } from "./cli-version.js";
|
|
@@ -105,6 +107,10 @@ registerOnboardCommand(program);
|
|
|
105
107
|
registerFeedbackCommand(program);
|
|
106
108
|
// Meetings (subcommand group — hq meetings list|get|search|transcript|notes)
|
|
107
109
|
registerMeetingsCommand(program);
|
|
110
|
+
// Sources read surface (subcommand group — hq sources list|get|channels|entities)
|
|
111
|
+
registerSourcesCommand(program);
|
|
112
|
+
// Signals read surface (subcommand group — hq signals list|get|types|entities)
|
|
113
|
+
registerSignalsCommand(program);
|
|
108
114
|
(async () => {
|
|
109
115
|
try {
|
|
110
116
|
Sentry.addBreadcrumb({
|
|
@@ -123,4 +129,4 @@ registerMeetingsCommand(program);
|
|
|
123
129
|
}
|
|
124
130
|
})();
|
|
125
131
|
//# sourceMappingURL=index.js.map
|
|
126
|
-
//# debugId=
|
|
132
|
+
//# debugId=2fc192b3-daa6-5939-a152-1422a7908e87
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* HQ_COGNITO_CALLBACK_PORT — Loopback OAuth callback port
|
|
19
19
|
* HQ_VAULT_API_URL — vault-service API Gateway URL
|
|
20
20
|
*/
|
|
21
|
-
import { type CognitoAuthConfig, type VaultServiceConfig } from "@indigoai-us/hq-cloud";
|
|
21
|
+
import { type CognitoAuthConfig, type ClientInfo, type VaultServiceConfig } from "@indigoai-us/hq-cloud";
|
|
22
22
|
export declare const DEFAULT_COGNITO: CognitoAuthConfig;
|
|
23
23
|
export declare const DEFAULT_VAULT_API_URL: string;
|
|
24
24
|
/**
|
|
@@ -58,6 +58,15 @@ export declare const DEFAULT_HQ_ROOT: string;
|
|
|
58
58
|
export declare function ensureCognitoToken(options?: {
|
|
59
59
|
interactive?: boolean;
|
|
60
60
|
}): Promise<string>;
|
|
61
|
+
/**
|
|
62
|
+
* The CLI's own ClientInfo. Resolved once at module load so every VaultClient
|
|
63
|
+
* built in this process stamps the same name/version onto its requests.
|
|
64
|
+
*
|
|
65
|
+
* `hqCoreVersion` is filled in lazily by walking up from cwd to find
|
|
66
|
+
* `core/core.yaml` — present only when the CLI is invoked from inside an
|
|
67
|
+
* hq-core checkout, so the server can see scaffold-generation skew.
|
|
68
|
+
*/
|
|
69
|
+
export declare const CLI_CLIENT_INFO: ClientInfo;
|
|
61
70
|
/** Build a VaultServiceConfig with the given access token. */
|
|
62
71
|
export declare function buildVaultConfig(authToken: string): VaultServiceConfig;
|
|
63
72
|
/**
|
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
* HQ_VAULT_API_URL — vault-service API Gateway URL
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
!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]="
|
|
22
|
+
!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]="d16ef3c7-eead-5307-aaa7-ca5fc828102b")}catch(e){}}();
|
|
23
23
|
import * as fs from "fs";
|
|
24
24
|
import * as os from "os";
|
|
25
25
|
import * as path from "path";
|
|
26
26
|
import chalk from "chalk";
|
|
27
|
-
import { loadCachedTokens, isExpiring, refreshTokens, browserLogin, } from "@indigoai-us/hq-cloud";
|
|
27
|
+
import { loadCachedTokens, isExpiring, refreshTokens, browserLogin, detectHqCoreVersion, } from "@indigoai-us/hq-cloud";
|
|
28
|
+
import { CLI_NAME, CLI_VERSION } from "../cli-version.js";
|
|
28
29
|
export const DEFAULT_COGNITO = {
|
|
29
30
|
region: process.env.AWS_REGION ?? "us-east-1",
|
|
30
31
|
userPoolDomain: process.env.HQ_COGNITO_DOMAIN ?? "vault-indigo-hq-prod",
|
|
@@ -124,12 +125,26 @@ export async function ensureCognitoToken(options = {}) {
|
|
|
124
125
|
const tokens = await browserLogin(DEFAULT_COGNITO);
|
|
125
126
|
return tokens.accessToken;
|
|
126
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* The CLI's own ClientInfo. Resolved once at module load so every VaultClient
|
|
130
|
+
* built in this process stamps the same name/version onto its requests.
|
|
131
|
+
*
|
|
132
|
+
* `hqCoreVersion` is filled in lazily by walking up from cwd to find
|
|
133
|
+
* `core/core.yaml` — present only when the CLI is invoked from inside an
|
|
134
|
+
* hq-core checkout, so the server can see scaffold-generation skew.
|
|
135
|
+
*/
|
|
136
|
+
export const CLI_CLIENT_INFO = {
|
|
137
|
+
name: CLI_NAME,
|
|
138
|
+
version: CLI_VERSION,
|
|
139
|
+
hqCoreVersion: detectHqCoreVersion(),
|
|
140
|
+
};
|
|
127
141
|
/** Build a VaultServiceConfig with the given access token. */
|
|
128
142
|
export function buildVaultConfig(authToken) {
|
|
129
143
|
return {
|
|
130
144
|
apiUrl: DEFAULT_VAULT_API_URL,
|
|
131
145
|
authToken,
|
|
132
146
|
region: DEFAULT_COGNITO.region,
|
|
147
|
+
clientInfo: CLI_CLIENT_INFO,
|
|
133
148
|
};
|
|
134
149
|
}
|
|
135
150
|
/**
|
|
@@ -155,4 +170,4 @@ export async function refreshCachedSession() {
|
|
|
155
170
|
}
|
|
156
171
|
}
|
|
157
172
|
//# sourceMappingURL=cognito-session.js.map
|
|
158
|
-
//# debugId=
|
|
173
|
+
//# debugId=d16ef3c7-eead-5307-aaa7-ca5fc828102b
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indigoai-us/hq-cli",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.17.0-sources-rc.0",
|
|
4
4
|
"description": "HQ by Indigo management CLI — modules and cloud sync",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -15,18 +15,19 @@
|
|
|
15
15
|
"clean": "rm -rf dist"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@
|
|
19
|
-
"@indigoai-us/hq-cloud": "^5.1.0",
|
|
18
|
+
"@indigoai-us/hq-cloud": "^5.20.0",
|
|
20
19
|
"@indigoai-us/hq-onboarding": "^0.1.0",
|
|
20
|
+
"@sentry/node": "^10.49.0",
|
|
21
21
|
"chalk": "^5.3.0",
|
|
22
22
|
"commander": "^12.1.0",
|
|
23
23
|
"js-yaml": "^4.1.0",
|
|
24
24
|
"open": "^10.1.0",
|
|
25
|
-
"simple-git": "^3.27.0",
|
|
26
25
|
"semver": "^7.6.3",
|
|
26
|
+
"simple-git": "^3.27.0",
|
|
27
27
|
"varlock": "1.0.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
+
"@aws-sdk/client-s3": "^3.1049.0",
|
|
30
31
|
"@types/js-yaml": "^4.0.9",
|
|
31
32
|
"@types/node": "^22.0.0",
|
|
32
33
|
"@types/semver": "^7.5.8",
|