@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
|
@@ -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.1",
|
|
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.21.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",
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# smoke-sources-signals.sh — end-to-end verification of `hq sources` /
|
|
4
|
+
# `hq signals` against a real vault bucket. Owned by US-008 of the
|
|
5
|
+
# hq-cli-sources-signals PRD.
|
|
6
|
+
#
|
|
7
|
+
# Usage:
|
|
8
|
+
# # 1. Make sure you have a working Cognito session OR export a token:
|
|
9
|
+
# hq whoami # interactive Cognito login if needed
|
|
10
|
+
# # or: export HQ_ACCESS_TOKEN="$(...)" # service-account JWT bypass
|
|
11
|
+
#
|
|
12
|
+
# # 2. Run the smoke against an entity slug you have access to (default: indigo):
|
|
13
|
+
# ./scripts/smoke-sources-signals.sh # uses ENTITY=indigo
|
|
14
|
+
# ENTITY=personal ./scripts/smoke-sources-signals.sh
|
|
15
|
+
#
|
|
16
|
+
# Behavior:
|
|
17
|
+
# Runs four CLI invocations, each asserted to exit 0 AND produce parseable
|
|
18
|
+
# JSON (where --format json is used). Stdout from each invocation is
|
|
19
|
+
# appended to a temp file; the script prints a summary table at the end.
|
|
20
|
+
#
|
|
21
|
+
# Exit codes:
|
|
22
|
+
# 0 all four invocations succeeded and produced valid JSON
|
|
23
|
+
# 1 one or more invocations failed (script aborts on first failure with set -e)
|
|
24
|
+
#
|
|
25
|
+
# Dependencies:
|
|
26
|
+
# - hq (built locally via `pnpm --filter @indigoai-us/hq-cli build`, or
|
|
27
|
+
# `npx @indigoai-us/hq-cli@rc ...` against a published rc)
|
|
28
|
+
# - jq (for JSON validation)
|
|
29
|
+
#
|
|
30
|
+
|
|
31
|
+
set -euo pipefail
|
|
32
|
+
|
|
33
|
+
ENTITY="${ENTITY:-indigo}"
|
|
34
|
+
LIMIT="${LIMIT:-5}"
|
|
35
|
+
HQ_BIN="${HQ_BIN:-hq}"
|
|
36
|
+
|
|
37
|
+
# Resolve workspace-local journal location for capturing output. The
|
|
38
|
+
# operator running this script may redirect the script's stdout to a journal
|
|
39
|
+
# file under companies/indigo/projects/hq-cli-sources-signals/journal/.
|
|
40
|
+
SMOKE_TMP="$(mktemp -d -t hq-smoke-XXXXXX)"
|
|
41
|
+
trap 'rm -rf "$SMOKE_TMP"' EXIT
|
|
42
|
+
|
|
43
|
+
echo "==> hq sources/signals smoke for entity=$ENTITY limit=$LIMIT"
|
|
44
|
+
echo " binary: $HQ_BIN"
|
|
45
|
+
echo " tmpdir: $SMOKE_TMP"
|
|
46
|
+
echo
|
|
47
|
+
|
|
48
|
+
require_cmd() {
|
|
49
|
+
if ! command -v "$1" >/dev/null 2>&1; then
|
|
50
|
+
echo "ERROR: required command '$1' not found in PATH" >&2
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
require_cmd "$HQ_BIN"
|
|
56
|
+
require_cmd jq
|
|
57
|
+
|
|
58
|
+
# --- 1. entities -----------------------------------------------------------
|
|
59
|
+
echo "[1/4] hq sources entities"
|
|
60
|
+
"$HQ_BIN" sources entities --format json > "$SMOKE_TMP/entities.json"
|
|
61
|
+
jq -e 'type == "array"' "$SMOKE_TMP/entities.json" > /dev/null
|
|
62
|
+
ENTITY_COUNT=$(jq 'length' "$SMOKE_TMP/entities.json")
|
|
63
|
+
echo " ok — $ENTITY_COUNT entity/entities visible"
|
|
64
|
+
echo
|
|
65
|
+
|
|
66
|
+
# --- 2. sources channels (no auth required) --------------------------------
|
|
67
|
+
echo "[2/4] hq sources channels"
|
|
68
|
+
"$HQ_BIN" sources channels > "$SMOKE_TMP/channels.txt"
|
|
69
|
+
grep -qx 'meeting' "$SMOKE_TMP/channels.txt"
|
|
70
|
+
grep -qx 'email' "$SMOKE_TMP/channels.txt"
|
|
71
|
+
grep -qx 'slack' "$SMOKE_TMP/channels.txt"
|
|
72
|
+
grep -qx 'linear' "$SMOKE_TMP/channels.txt"
|
|
73
|
+
grep -qx 'notion' "$SMOKE_TMP/channels.txt"
|
|
74
|
+
echo " ok — all five canonical channels present"
|
|
75
|
+
echo
|
|
76
|
+
|
|
77
|
+
# --- 3. sources list --type meeting (the headline acceptance criterion) ---
|
|
78
|
+
echo "[3/4] hq sources list --entity $ENTITY --type meeting --limit $LIMIT --format json"
|
|
79
|
+
"$HQ_BIN" sources list \
|
|
80
|
+
--entity "$ENTITY" \
|
|
81
|
+
--type meeting \
|
|
82
|
+
--limit "$LIMIT" \
|
|
83
|
+
--format json > "$SMOKE_TMP/sources-list.json"
|
|
84
|
+
jq -e '.entries | type == "array"' "$SMOKE_TMP/sources-list.json" > /dev/null
|
|
85
|
+
SOURCE_COUNT=$(jq '.entries | length' "$SMOKE_TMP/sources-list.json")
|
|
86
|
+
echo " ok — $SOURCE_COUNT meeting source(s) listed"
|
|
87
|
+
echo
|
|
88
|
+
|
|
89
|
+
# --- 4. signals list --type action_item (the other headline) --------------
|
|
90
|
+
echo "[4/4] hq signals list --entity $ENTITY --type action_item --limit $LIMIT --format json"
|
|
91
|
+
"$HQ_BIN" signals list \
|
|
92
|
+
--entity "$ENTITY" \
|
|
93
|
+
--type action_item \
|
|
94
|
+
--limit "$LIMIT" \
|
|
95
|
+
--format json > "$SMOKE_TMP/signals-list.json"
|
|
96
|
+
jq -e '.entries | type == "array"' "$SMOKE_TMP/signals-list.json" > /dev/null
|
|
97
|
+
SIGNAL_COUNT=$(jq '.entries | length' "$SMOKE_TMP/signals-list.json")
|
|
98
|
+
echo " ok — $SIGNAL_COUNT action_item signal(s) listed"
|
|
99
|
+
echo
|
|
100
|
+
|
|
101
|
+
echo "==> SMOKE PASSED"
|
|
102
|
+
echo " entities=$ENTITY_COUNT meeting_sources=$SOURCE_COUNT action_item_signals=$SIGNAL_COUNT"
|
|
103
|
+
echo " raw outputs preserved in $SMOKE_TMP until process exit"
|
package/src/cli-version.ts
CHANGED
|
@@ -4,6 +4,10 @@ import path from "node:path";
|
|
|
4
4
|
|
|
5
5
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
6
6
|
const pkgPath = path.resolve(here, "..", "package.json");
|
|
7
|
-
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8")) as {
|
|
7
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8")) as {
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
};
|
|
8
11
|
|
|
12
|
+
export const CLI_NAME: string = pkg.name;
|
|
9
13
|
export const CLI_VERSION: string = pkg.version;
|
package/src/commands/groups.ts
CHANGED
|
@@ -66,7 +66,7 @@ export function registerGroupsCommand(program: Command): void {
|
|
|
66
66
|
if (res.status === 401) {
|
|
67
67
|
console.error(chalk.red("Not authenticated — please run `hq login`"));
|
|
68
68
|
} else if (res.status === 403) {
|
|
69
|
-
console.error(chalk.red("Not authorized — owner
|
|
69
|
+
console.error(chalk.red("Not authorized — owner role required"));
|
|
70
70
|
} else if (res.status === 409) {
|
|
71
71
|
console.error(chalk.red(`Group already exists: ${groupId}`));
|
|
72
72
|
} else if (res.status >= 500) {
|
|
@@ -110,7 +110,7 @@ export function registerGroupsCommand(program: Command): void {
|
|
|
110
110
|
if (res.status === 401) {
|
|
111
111
|
console.error(chalk.red("Not authenticated — please run `hq login`"));
|
|
112
112
|
} else if (res.status === 403) {
|
|
113
|
-
console.error(chalk.red("Not authorized — owner
|
|
113
|
+
console.error(chalk.red("Not authorized — owner role required"));
|
|
114
114
|
} else if (res.status === 404) {
|
|
115
115
|
console.error(chalk.red(`Group not found: ${groupId}`));
|
|
116
116
|
} else if (res.status >= 500) {
|
|
@@ -160,7 +160,7 @@ export function registerGroupsCommand(program: Command): void {
|
|
|
160
160
|
if (res.status === 401) {
|
|
161
161
|
console.error(chalk.red("Not authenticated — please run `hq login`"));
|
|
162
162
|
} else if (res.status === 403) {
|
|
163
|
-
console.error(chalk.red("Not authorized — owner
|
|
163
|
+
console.error(chalk.red("Not authorized — owner role or group creator required"));
|
|
164
164
|
} else if (res.status === 404) {
|
|
165
165
|
// Server provides a helpful message (email not found vs group not found)
|
|
166
166
|
console.error(chalk.red(err.error ?? `Not found`));
|
|
@@ -215,7 +215,7 @@ export function registerGroupsCommand(program: Command): void {
|
|
|
215
215
|
if (res.status === 401) {
|
|
216
216
|
console.error(chalk.red("Not authenticated — please run `hq login`"));
|
|
217
217
|
} else if (res.status === 403) {
|
|
218
|
-
console.error(chalk.red("Not authorized — owner
|
|
218
|
+
console.error(chalk.red("Not authorized — owner role or group creator required"));
|
|
219
219
|
} else if (res.status === 404) {
|
|
220
220
|
console.error(chalk.red(err.error ?? `Not found`));
|
|
221
221
|
} else if (res.status >= 500) {
|
package/src/commands/meetings.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import { ensureCognitoToken } from "../utils/cognito-session.js";
|
|
4
|
-
import { vaultApiFetch } from "../utils/vault-api.js";
|
|
4
|
+
import { vaultApiFetch, getCompanyUid } from "../utils/vault-api.js";
|
|
5
5
|
|
|
6
6
|
interface MeetingListItem {
|
|
7
7
|
meetingId: string;
|
|
@@ -210,7 +210,7 @@ export function registerMeetingsCommand(program: Command): void {
|
|
|
210
210
|
|
|
211
211
|
if (opts.limit) query.limit = opts.limit;
|
|
212
212
|
if (opts.next) query.nextToken = opts.next;
|
|
213
|
-
if (companySlug) query.companyId = companySlug;
|
|
213
|
+
if (companySlug) query.companyId = await getCompanyUid(token, companySlug);
|
|
214
214
|
|
|
215
215
|
const res = await vaultApiFetch({ token, path: "/v1/meetings", query });
|
|
216
216
|
if (!res.ok) await handleApiError(res);
|
|
@@ -250,7 +250,7 @@ export function registerMeetingsCommand(program: Command): void {
|
|
|
250
250
|
const token = await ensureCognitoToken();
|
|
251
251
|
const query: Record<string, string> = {};
|
|
252
252
|
const companySlug = meetings.opts().company as string | undefined;
|
|
253
|
-
if (companySlug) query.companyId = companySlug;
|
|
253
|
+
if (companySlug) query.companyId = await getCompanyUid(token, companySlug);
|
|
254
254
|
|
|
255
255
|
const meetingId = await resolveShortId(token, rawId, query);
|
|
256
256
|
const res = await vaultApiFetch({
|
|
@@ -309,7 +309,7 @@ export function registerMeetingsCommand(program: Command): void {
|
|
|
309
309
|
const token = await ensureCognitoToken();
|
|
310
310
|
const params: Record<string, string> = { q: query };
|
|
311
311
|
const companySlug = meetings.opts().company as string | undefined;
|
|
312
|
-
if (companySlug) params.companyId = companySlug;
|
|
312
|
+
if (companySlug) params.companyId = await getCompanyUid(token, companySlug);
|
|
313
313
|
|
|
314
314
|
const res = await vaultApiFetch({
|
|
315
315
|
token,
|
|
@@ -347,7 +347,7 @@ export function registerMeetingsCommand(program: Command): void {
|
|
|
347
347
|
const token = await ensureCognitoToken();
|
|
348
348
|
const query: Record<string, string> = {};
|
|
349
349
|
const companySlug = meetings.opts().company as string | undefined;
|
|
350
|
-
if (companySlug) query.companyId = companySlug;
|
|
350
|
+
if (companySlug) query.companyId = await getCompanyUid(token, companySlug);
|
|
351
351
|
|
|
352
352
|
const meetingId = await resolveShortId(token, rawId, query);
|
|
353
353
|
const res = await vaultApiFetch({
|
|
@@ -403,7 +403,7 @@ export function registerMeetingsCommand(program: Command): void {
|
|
|
403
403
|
const token = await ensureCognitoToken();
|
|
404
404
|
const query: Record<string, string> = {};
|
|
405
405
|
const companySlug = meetings.opts().company as string | undefined;
|
|
406
|
-
if (companySlug) query.companyId = companySlug;
|
|
406
|
+
if (companySlug) query.companyId = await getCompanyUid(token, companySlug);
|
|
407
407
|
|
|
408
408
|
const meetingId = await resolveShortId(token, rawId, query);
|
|
409
409
|
const res = await vaultApiFetch({
|
|
@@ -222,6 +222,47 @@ describe("inviteMember", () => {
|
|
|
222
222
|
}),
|
|
223
223
|
).rejects.toBeInstanceOf(InviteHttpError);
|
|
224
224
|
});
|
|
225
|
+
|
|
226
|
+
it("resolves the token when it is nested on the membership row", async () => {
|
|
227
|
+
fetchSpy.mockResolvedValueOnce(
|
|
228
|
+
jsonResponse(200, {
|
|
229
|
+
membership: {
|
|
230
|
+
role: "admin",
|
|
231
|
+
status: "pending",
|
|
232
|
+
inviteToken: "tok_nested",
|
|
233
|
+
},
|
|
234
|
+
}),
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
const result = await inviteMember({
|
|
238
|
+
target: "alice@example.com",
|
|
239
|
+
role: "admin",
|
|
240
|
+
companyUid: "cmp_acme",
|
|
241
|
+
callerUid: "prs_admin",
|
|
242
|
+
token: "test-token",
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
expect(result.inviteToken).toBe("tok_nested");
|
|
246
|
+
expect(result.magicLink).toBe("hq://accept/tok_nested");
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it("throws instead of emitting hq://accept/undefined when no token is present", async () => {
|
|
250
|
+
fetchSpy.mockResolvedValueOnce(
|
|
251
|
+
jsonResponse(200, {
|
|
252
|
+
membership: { role: "admin", status: "pending" },
|
|
253
|
+
}),
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
await expect(
|
|
257
|
+
inviteMember({
|
|
258
|
+
target: "alice@example.com",
|
|
259
|
+
role: "admin",
|
|
260
|
+
companyUid: "cmp_acme",
|
|
261
|
+
callerUid: "prs_admin",
|
|
262
|
+
token: "test-token",
|
|
263
|
+
}),
|
|
264
|
+
).rejects.toThrow(/did not include an invite token/);
|
|
265
|
+
});
|
|
225
266
|
});
|
|
226
267
|
|
|
227
268
|
// ---------------------------------------------------------------------------
|
|
@@ -257,6 +298,21 @@ describe("listPendingInvites", () => {
|
|
|
257
298
|
InviteHttpError,
|
|
258
299
|
);
|
|
259
300
|
});
|
|
301
|
+
|
|
302
|
+
it("returns [] for an empty invites array", async () => {
|
|
303
|
+
fetchSpy.mockResolvedValueOnce(jsonResponse(200, { invites: [] }));
|
|
304
|
+
await expect(listPendingInvites("test-token", "cmp_acme")).resolves.toEqual([]);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it("returns [] when invites is null", async () => {
|
|
308
|
+
fetchSpy.mockResolvedValueOnce(jsonResponse(200, { invites: null }));
|
|
309
|
+
await expect(listPendingInvites("test-token", "cmp_acme")).resolves.toEqual([]);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it("returns [] when the invites key is missing", async () => {
|
|
313
|
+
fetchSpy.mockResolvedValueOnce(jsonResponse(200, {}));
|
|
314
|
+
await expect(listPendingInvites("test-token", "cmp_acme")).resolves.toEqual([]);
|
|
315
|
+
});
|
|
260
316
|
});
|
|
261
317
|
|
|
262
318
|
// ---------------------------------------------------------------------------
|