@indigoai-us/hq-cli 5.345.253 → 5.345.254
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/CHANGELOG.md +32 -0
- package/contracts/host-canary-release.json +11 -5
- package/dist/command-catalog.generated.d.ts +61 -0
- package/dist/command-catalog.generated.js +75 -0
- package/dist/commands/ci-intake.d.ts +17 -0
- package/dist/commands/ci-intake.js +43 -1
- package/dist/commands/ci-priorities.d.ts +56 -0
- package/dist/commands/ci-priorities.js +144 -0
- package/dist/commands/ci.js +2 -1
- package/dist/commands/cloud.d.ts +11 -0
- package/dist/commands/cloud.js +76 -0
- package/dist/lib/daemon/verified-jq.d.ts +6 -0
- package/dist/lib/daemon/verified-jq.js +17 -5
- package/dist/lib/hook-engine/fleet-registration.d.ts +4 -0
- package/dist/lib/hook-engine/fleet-registration.js +25 -3
- package/dist/lib/smart-ci/priorities.d.ts +331 -0
- package/dist/lib/smart-ci/priorities.js +964 -0
- package/dist/lib/smart-ci/priority-refresh.d.ts +192 -0
- package/dist/lib/smart-ci/priority-refresh.js +366 -0
- package/dist/lib/smart-ci/priority-snapshots.d.ts +88 -0
- package/dist/lib/smart-ci/priority-snapshots.js +233 -0
- package/dist/lib/smart-ci/sources.d.ts +294 -0
- package/dist/lib/smart-ci/sources.js +659 -0
- package/dist/lib/smart-ci/text.d.ts +24 -0
- package/dist/lib/smart-ci/text.js +83 -0
- package/dist/lib/smart-ci/work-in-flight.d.ts +68 -0
- package/dist/lib/smart-ci/work-in-flight.js +154 -0
- package/dist/lib/sync/cli-manifest-reconcile.d.ts +20 -0
- package/dist/lib/sync/cli-manifest-reconcile.js +170 -0
- package/dist/utils/host-registration.d.ts +1 -0
- package/dist/utils/host-registration.js +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Priority map snapshots in the Smart CI ledger (smart-ci US-002).
|
|
3
|
+
*
|
|
4
|
+
* The priority map has no store of its own. It is one scope of US-001's
|
|
5
|
+
* ledger (src/lib/smart-ci/ledger.ts): company = the map's company,
|
|
6
|
+
* namespace = "priorities". Its records are:
|
|
7
|
+
*
|
|
8
|
+
* - `map-snapshot`: one per stored map. The body names the map (built-at
|
|
9
|
+
* time, digest, degraded or not); the map itself is the record's blob, kept
|
|
10
|
+
* by the ledger beside the record and checked against its sha256 on read.
|
|
11
|
+
* - `refresh-failed`: one per refresh that kept the previous map, naming each
|
|
12
|
+
* source that was down. That is the durable log of the failure.
|
|
13
|
+
* - `refresh-attempt`: one record, id "last", holding the time of the last
|
|
14
|
+
* attempt whatever came of it, so refreshDue backs off after a failure.
|
|
15
|
+
*
|
|
16
|
+
* Scope keys carry the company, so one company's records are never read for
|
|
17
|
+
* another. Snapshots are pruned to the newest 20 (their blobs go with them),
|
|
18
|
+
* failures to the newest 200.
|
|
19
|
+
*
|
|
20
|
+
* One writer (the M5 rule of US-001's review). The ledger has one owner
|
|
21
|
+
* process at a time. The priority map writes in one of two ways:
|
|
22
|
+
*
|
|
23
|
+
* - Hosted: inside the process that already owns the ledger (the intake,
|
|
24
|
+
* `hq ci intake --priorities <company>`), through that process's
|
|
25
|
+
* SmartCiLedger. Nothing is opened a second time.
|
|
26
|
+
* - Standalone: `hq ci priorities` with no owner running opens the ledger
|
|
27
|
+
* for the length of one write and closes it again.
|
|
28
|
+
*
|
|
29
|
+
* When another live process owns the ledger a standalone write is refused
|
|
30
|
+
* with LEDGER_HELD and nothing is written; reads never need ownership
|
|
31
|
+
* (readSmartCiSnapshot), so the stored map can always be printed. A store
|
|
32
|
+
* that has delivery workers enrolled is refused by SmartCiLedger.open before
|
|
33
|
+
* anything, blob included, is written.
|
|
34
|
+
*/
|
|
35
|
+
import { randomBytes } from "node:crypto";
|
|
36
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
37
|
+
import { hostname } from "node:os";
|
|
38
|
+
import { join } from "node:path";
|
|
39
|
+
import { DeliveryStoreError, parseStoreText } from "../delivery/migrations.js";
|
|
40
|
+
import { STATE_FILE } from "../delivery/store.js";
|
|
41
|
+
import { SmartCiLedger, SmartCiView, readSmartCiSnapshot } from "./ledger.js";
|
|
42
|
+
import { PRIORITY_MAP_SCHEMA } from "./priorities.js";
|
|
43
|
+
import { assertCompanySlug } from "./sources.js";
|
|
44
|
+
import { clip } from "./text.js";
|
|
45
|
+
export const PRIORITIES_NAMESPACE = "priorities";
|
|
46
|
+
export const SNAPSHOT_KIND = "map-snapshot";
|
|
47
|
+
export const FAILURE_KIND = "refresh-failed";
|
|
48
|
+
export const ATTEMPT_KIND = "refresh-attempt";
|
|
49
|
+
const ATTEMPT_ID = "last";
|
|
50
|
+
const DEFAULT_KEEP_SNAPSHOTS = 20;
|
|
51
|
+
const DEFAULT_KEEP_FAILURES = 200;
|
|
52
|
+
const READ_WAIT_MS = 2000;
|
|
53
|
+
/** Thrown, with nothing written, when another live process owns the ledger. */
|
|
54
|
+
export class LedgerHeldError extends Error {
|
|
55
|
+
dir;
|
|
56
|
+
code = "LEDGER_HELD";
|
|
57
|
+
constructor(dir, detail) {
|
|
58
|
+
super(`LEDGER_HELD: the Smart CI ledger in ${dir} is owned by another process, so the priority map was not stored there. That process stores it when it hosts the refresh (hq ci intake --priorities <company>). Nothing was written. (${detail.split("\n")[0]})`);
|
|
59
|
+
this.dir = dir;
|
|
60
|
+
this.name = "LedgerHeldError";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function scopeRef(company) {
|
|
64
|
+
assertCompanySlug(company);
|
|
65
|
+
return { company, namespace: PRIORITIES_NAMESPACE };
|
|
66
|
+
}
|
|
67
|
+
/** How many delivery workers the store in `dir` has on record. 0 when there is no store. Reads without any lock or ownership. */
|
|
68
|
+
export function enrolledWorkers(dir) {
|
|
69
|
+
const path = join(dir, STATE_FILE);
|
|
70
|
+
if (!existsSync(path))
|
|
71
|
+
return 0;
|
|
72
|
+
return parseStoreText(readFileSync(path, "utf8"), path).state.workers.length;
|
|
73
|
+
}
|
|
74
|
+
/** The records of the priorities scope, without taking ownership. */
|
|
75
|
+
function readScope(opts) {
|
|
76
|
+
const ref = scopeRef(opts.company);
|
|
77
|
+
if (opts.target.ledger)
|
|
78
|
+
return opts.target.ledger.view().scope(ref);
|
|
79
|
+
const dir = opts.target.dir;
|
|
80
|
+
return new SmartCiView(readSmartCiSnapshot(dir, READ_WAIT_MS), dir).scope(ref);
|
|
81
|
+
}
|
|
82
|
+
/** Run `fn` with a writer of the priorities scope: the hosting ledger, or this module's own short ownership of the directory. */
|
|
83
|
+
function withWriter(opts, fn) {
|
|
84
|
+
const ref = scopeRef(opts.company);
|
|
85
|
+
if (opts.target.ledger)
|
|
86
|
+
return fn(opts.target.ledger.scope(ref));
|
|
87
|
+
const dir = opts.target.dir;
|
|
88
|
+
let ledger;
|
|
89
|
+
try {
|
|
90
|
+
ledger = SmartCiLedger.open({ dir, controllerId: opts.controllerId ?? `smart-ci-priorities@${hostname()}`, clock: opts.clock });
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
if (err instanceof DeliveryStoreError && (err.code === "CONTROLLER_OWNED" || err.code === "CONTROLLER_AMBIGUOUS"))
|
|
94
|
+
throw new LedgerHeldError(dir, err.message);
|
|
95
|
+
throw err;
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
return fn(ledger.scope(ref));
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
ledger.close();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Whether this process can write the priority map now: true when it hosts the
|
|
106
|
+
* ledger, or when no other live process owns the directory. Answering costs one
|
|
107
|
+
* open and close of the ledger. Never throws.
|
|
108
|
+
*/
|
|
109
|
+
export function ledgerWritable(opts) {
|
|
110
|
+
if (opts.target.ledger)
|
|
111
|
+
return { writable: true, reason: "this process owns the ledger" };
|
|
112
|
+
try {
|
|
113
|
+
withWriter({ ...opts }, () => undefined);
|
|
114
|
+
return { writable: true, reason: "no other process owns the ledger" };
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
return { writable: false, reason: err instanceof Error ? err.message : String(err) };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const stamp = (ms) => new Date(ms).toISOString().replace(/[-:.]/g, "");
|
|
121
|
+
/** Store a new map as the last good one, and note the attempt, in one commit. Prunes old snapshots after. */
|
|
122
|
+
export function recordSnapshot(opts, map) {
|
|
123
|
+
if (map.company !== opts.company)
|
|
124
|
+
throw new Error(`the map is for company ${map.company}, not ${opts.company}; nothing was written`);
|
|
125
|
+
const text = JSON.stringify(map);
|
|
126
|
+
const nowMs = (opts.clock ?? Date.now)();
|
|
127
|
+
const builtMs = Number.isNaN(Date.parse(map.builtAt)) ? nowMs : Date.parse(map.builtAt);
|
|
128
|
+
return withWriter(opts, (scope) => {
|
|
129
|
+
// The id carries the build time and a nonce; the digest is the blob's sha256, set by the ledger.
|
|
130
|
+
const id = `${stamp(builtMs)}-${randomBytes(4).toString("hex")}`;
|
|
131
|
+
scope.putMany([
|
|
132
|
+
{ kind: SNAPSHOT_KIND, id, body: { builtAt: map.builtAt, degraded: map.degraded, priorities: map.priorities.length }, blob: text },
|
|
133
|
+
{ kind: ATTEMPT_KIND, id: ATTEMPT_ID, body: { at: new Date(nowMs).toISOString(), outcome: "stored" } },
|
|
134
|
+
]);
|
|
135
|
+
const stored = scope.records(SNAPSHOT_KIND).find((r) => r.id === id);
|
|
136
|
+
try {
|
|
137
|
+
scope.prune(SNAPSHOT_KIND, { keepLatest: Math.max(1, opts.keepSnapshots ?? DEFAULT_KEEP_SNAPSHOTS) });
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
// Pruning is housekeeping. The snapshot is already stored.
|
|
141
|
+
opts.log?.(`smart-ci priorities: old snapshots were not pruned: ${err instanceof Error ? err.message : String(err)}`);
|
|
142
|
+
}
|
|
143
|
+
return { id, status: "succeeded", at: stored?.updatedAt ?? new Date(nowMs).toISOString(), digest: blobDigest(stored?.body), failures: [] };
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/** Log a refresh that kept the previous map: one record naming each source that was down. Also notes the attempt. */
|
|
147
|
+
export function recordFailure(opts, failures) {
|
|
148
|
+
const nowMs = (opts.clock ?? Date.now)();
|
|
149
|
+
const list = (failures.length > 0 ? failures : [{ source: "unknown", message: "no reason given" }]).map((f) => ({ source: f.source, message: clip(f.message, 300) }));
|
|
150
|
+
return withWriter(opts, (scope) => {
|
|
151
|
+
const id = `${stamp(nowMs)}-${randomBytes(4).toString("hex")}`;
|
|
152
|
+
scope.putMany([
|
|
153
|
+
{ kind: FAILURE_KIND, id, body: { failures: list } },
|
|
154
|
+
{ kind: ATTEMPT_KIND, id: ATTEMPT_ID, body: { at: new Date(nowMs).toISOString(), outcome: "kept" } },
|
|
155
|
+
]);
|
|
156
|
+
const stored = scope.records(FAILURE_KIND).find((r) => r.id === id);
|
|
157
|
+
try {
|
|
158
|
+
scope.prune(FAILURE_KIND, { keepLatest: Math.max(1, opts.keepFailures ?? DEFAULT_KEEP_FAILURES) });
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
// Housekeeping only. The failure is already stored.
|
|
162
|
+
opts.log?.(`smart-ci priorities: old failure records were not pruned: ${err instanceof Error ? err.message : String(err)}`);
|
|
163
|
+
}
|
|
164
|
+
return { id, status: "failed", at: stored?.updatedAt ?? new Date(nowMs).toISOString(), digest: "", failures: list };
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Note the time of a refresh attempt, whatever came of it. Best effort:
|
|
169
|
+
* returns false, with nothing written, when the ledger cannot be written
|
|
170
|
+
* (another owner, or a store with delivery workers).
|
|
171
|
+
*/
|
|
172
|
+
export function noteAttempt(opts) {
|
|
173
|
+
const nowMs = (opts.clock ?? Date.now)();
|
|
174
|
+
try {
|
|
175
|
+
withWriter(opts, (scope) => scope.put(ATTEMPT_KIND, ATTEMPT_ID, { at: new Date(nowMs).toISOString(), outcome: "attempted" }));
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
opts.log?.(`smart-ci priorities: the attempt time was not noted in the ledger: ${err instanceof Error ? err.message : String(err)}`);
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/** When the last refresh attempt was noted (epoch milliseconds), or NaN when none was. */
|
|
184
|
+
export function lastAttemptMs(opts) {
|
|
185
|
+
try {
|
|
186
|
+
const at = readScope(opts).get(ATTEMPT_KIND, ATTEMPT_ID)?.at;
|
|
187
|
+
return typeof at === "string" ? Date.parse(at) : Number.NaN;
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
// An unreadable ledger has no attempt on record; refreshDue also checks this process's own note.
|
|
191
|
+
return Number.NaN;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function blobDigest(body) {
|
|
195
|
+
const ref = body?.$blob;
|
|
196
|
+
return typeof ref?.sha256 === "string" ? ref.sha256 : "";
|
|
197
|
+
}
|
|
198
|
+
function toRefresh(r, status) {
|
|
199
|
+
const failures = status === "failed" && Array.isArray(r.body.failures) ? r.body.failures : [];
|
|
200
|
+
return { id: r.id, status, at: r.updatedAt, digest: status === "succeeded" ? blobDigest(r.body) : "", failures };
|
|
201
|
+
}
|
|
202
|
+
/** Every stored or failed refresh of the company that is still kept, oldest first. Empty when there is no ledger yet. */
|
|
203
|
+
export function readRefreshLog(opts) {
|
|
204
|
+
const scope = readScope(opts);
|
|
205
|
+
const all = [...scope.records(SNAPSHOT_KIND).map((r) => toRefresh(r, "succeeded")), ...scope.records(FAILURE_KIND).map((r) => toRefresh(r, "failed"))];
|
|
206
|
+
return all.sort((a, b) => Date.parse(a.at) - Date.parse(b.at) || a.id.localeCompare(b.id));
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The newest map stored for the company, or null. Reads the ledger and one
|
|
210
|
+
* blob; calls no source. A snapshot whose blob is missing, does not match its
|
|
211
|
+
* hash, or is not a map of this company is passed over for the one before it.
|
|
212
|
+
*/
|
|
213
|
+
export function readLastGood(opts) {
|
|
214
|
+
const scope = readScope(opts);
|
|
215
|
+
const snapshots = scope.records(SNAPSHOT_KIND).sort((a, b) => Date.parse(b.updatedAt) - Date.parse(a.updatedAt) || b.id.localeCompare(a.id));
|
|
216
|
+
for (const r of snapshots) {
|
|
217
|
+
let map;
|
|
218
|
+
try {
|
|
219
|
+
const bytes = scope.blob(SNAPSHOT_KIND, r.id);
|
|
220
|
+
if (bytes === null)
|
|
221
|
+
continue;
|
|
222
|
+
map = JSON.parse(bytes.toString("utf8"));
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (map.schema !== PRIORITY_MAP_SCHEMA || map.company !== opts.company)
|
|
228
|
+
continue;
|
|
229
|
+
return { map, record: toRefresh(r, "succeeded") };
|
|
230
|
+
}
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=priority-snapshots.js.map
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
export type SourceName = "standups" | "work-mesh" | "sessions" | "ontology" | "pull-requests";
|
|
2
|
+
export declare const PRIORITY_SOURCES: readonly SourceName[];
|
|
3
|
+
/**
|
|
4
|
+
* The kinds of record these readers return: a standup or meeting, a Work Mesh
|
|
5
|
+
* thread, project, lane and story, and a session. Every source is full of
|
|
6
|
+
* these words whatever the company works on (thread ids, session ids, "the
|
|
7
|
+
* lane", "this project"), so they describe the tooling the map reads from and
|
|
8
|
+
* never a piece of the company's work. The map does not take them as topic
|
|
9
|
+
* terms. A project whose name is made of them is still listed, under its id.
|
|
10
|
+
*/
|
|
11
|
+
export declare const RECORD_KIND_WORDS: ReadonlySet<string>;
|
|
12
|
+
/** Thrown by a reader when its source cannot be read. The refresh logs it and keeps the last good map. */
|
|
13
|
+
export declare class SourceUnavailableError extends Error {
|
|
14
|
+
readonly source: SourceName;
|
|
15
|
+
constructor(source: SourceName, message: string);
|
|
16
|
+
}
|
|
17
|
+
/** Refuse anything that is not a plain company slug before it reaches a path or a command. */
|
|
18
|
+
export declare function assertCompanySlug(company: unknown): asserts company is string;
|
|
19
|
+
export interface CommandResult {
|
|
20
|
+
stdout: string;
|
|
21
|
+
/** The program's exit code. A runner resolves for any exit code. */
|
|
22
|
+
exitCode: number;
|
|
23
|
+
}
|
|
24
|
+
/** Runs a program and resolves with its stdout and exit code, or rejects when it cannot be run or times out. */
|
|
25
|
+
export type CommandRunner = (file: string, args: string[], opts: {
|
|
26
|
+
timeoutMs: number;
|
|
27
|
+
env?: NodeJS.ProcessEnv;
|
|
28
|
+
}) => Promise<CommandResult>;
|
|
29
|
+
export declare const execRunner: CommandRunner;
|
|
30
|
+
/** How to start the `hq` CLI: a program and the arguments that go before the subcommand. */
|
|
31
|
+
export interface HqCommand {
|
|
32
|
+
file: string;
|
|
33
|
+
prefix: string[];
|
|
34
|
+
}
|
|
35
|
+
/** The running CLI itself, so the readers use the same build and login as the caller. */
|
|
36
|
+
export declare function defaultHqCommand(): HqCommand;
|
|
37
|
+
export interface Utterance {
|
|
38
|
+
speaker: string;
|
|
39
|
+
/** Offset range inside the recording, as written in the transcript. */
|
|
40
|
+
at: string;
|
|
41
|
+
text: string;
|
|
42
|
+
}
|
|
43
|
+
export interface StandupTranscript {
|
|
44
|
+
id: string;
|
|
45
|
+
/** Path relative to the HQ root. */
|
|
46
|
+
file: string;
|
|
47
|
+
title: string;
|
|
48
|
+
/** Calendar day of the meeting (YYYY-MM-DD). */
|
|
49
|
+
date: string;
|
|
50
|
+
startedAt: string;
|
|
51
|
+
/** True when the file had no usable title and was taken as a standup from who spoke in it. */
|
|
52
|
+
titleInferred: boolean;
|
|
53
|
+
utterances: Utterance[];
|
|
54
|
+
}
|
|
55
|
+
/** How often each term is said outside standups, counted per utterance. */
|
|
56
|
+
export interface BackgroundStats {
|
|
57
|
+
utterances: number;
|
|
58
|
+
termUtterances: Record<string, number>;
|
|
59
|
+
transcripts: number;
|
|
60
|
+
}
|
|
61
|
+
export interface StandupRead {
|
|
62
|
+
standups: StandupTranscript[];
|
|
63
|
+
background: BackgroundStats;
|
|
64
|
+
/** Transcripts skipped because their frontmatter named another company. */
|
|
65
|
+
skippedOtherCompany: number;
|
|
66
|
+
gaps: string[];
|
|
67
|
+
}
|
|
68
|
+
interface MeetingHeader {
|
|
69
|
+
title: string;
|
|
70
|
+
scheduledStart: string;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
companyId: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The fields the map needs from a transcript's header. The fence is split by
|
|
76
|
+
* the shared helper and the YAML is parsed as YAML (timestamps stay text).
|
|
77
|
+
* Null when the text has no header or the header is not a YAML mapping.
|
|
78
|
+
*/
|
|
79
|
+
export declare function readMeetingHeader(text: string): MeetingHeader | null;
|
|
80
|
+
/**
|
|
81
|
+
* The company's own cloud uid, from its company.yaml. Used to skip
|
|
82
|
+
* transcripts of another company when Work Mesh is not there to say the uid.
|
|
83
|
+
* "" when the file is missing or names no uid.
|
|
84
|
+
*/
|
|
85
|
+
export declare function companyUidFromFile(hqRoot: string, company: string): string;
|
|
86
|
+
export declare function parseUtterances(text: string): Utterance[];
|
|
87
|
+
export interface StandupReadOptions {
|
|
88
|
+
hqRoot: string;
|
|
89
|
+
company: string;
|
|
90
|
+
/** Window of standups to read, as epoch milliseconds: from <= start < to. */
|
|
91
|
+
fromMs: number;
|
|
92
|
+
toMs: number;
|
|
93
|
+
/** The company's uid. Transcripts naming another uid are skipped. Default: read from the company's own company.yaml. */
|
|
94
|
+
companyUid?: string;
|
|
95
|
+
/** How far back non-standup meetings are read for the background counts. Default 30 days. */
|
|
96
|
+
backgroundDays?: number;
|
|
97
|
+
/** Most background transcripts to read. Default 400. */
|
|
98
|
+
backgroundLimit?: number;
|
|
99
|
+
/** Share of an untitled meeting's speakers that must also speak in titled standups. Default 0.6. */
|
|
100
|
+
speakerOverlap?: number;
|
|
101
|
+
}
|
|
102
|
+
/** The meetings folder of one company. The slug is checked before it is put in a path. */
|
|
103
|
+
export declare function meetingsDir(hqRoot: string, company: string): string;
|
|
104
|
+
/**
|
|
105
|
+
* Read the standup transcripts in the window, plus term counts from the same
|
|
106
|
+
* company's other meetings (the background that tells a standup topic from
|
|
107
|
+
* ordinary talk). Standups are found by title and start time in the
|
|
108
|
+
* frontmatter. A meeting stored without a title is taken as a standup when
|
|
109
|
+
* most of its speakers also speak in the titled standups, and is reported as
|
|
110
|
+
* a gap.
|
|
111
|
+
*/
|
|
112
|
+
export declare function readStandups(opts: StandupReadOptions): StandupRead;
|
|
113
|
+
/** Ids of standup-titled transcripts that started at or after `sinceMs`, read from frontmatter only. */
|
|
114
|
+
export declare function listStandupIdsSince(hqRoot: string, company: string, sinceMs: number): string[];
|
|
115
|
+
export interface MeshThread {
|
|
116
|
+
threadId: string;
|
|
117
|
+
kind: "project" | "lane" | "work-session" | "other";
|
|
118
|
+
projectId: string;
|
|
119
|
+
status: string;
|
|
120
|
+
ownerUid: string;
|
|
121
|
+
priority: string;
|
|
122
|
+
createdAt: string;
|
|
123
|
+
lastActivityAt: string;
|
|
124
|
+
/** Session the thread belongs to (work sessions and lanes), or "". */
|
|
125
|
+
sessionId: string;
|
|
126
|
+
summary: string;
|
|
127
|
+
}
|
|
128
|
+
export interface MeshStory {
|
|
129
|
+
id: string;
|
|
130
|
+
title: string;
|
|
131
|
+
status: string;
|
|
132
|
+
assignee: string;
|
|
133
|
+
updatedAt: string;
|
|
134
|
+
}
|
|
135
|
+
export interface MeshProject {
|
|
136
|
+
projectId: string;
|
|
137
|
+
name: string;
|
|
138
|
+
description: string;
|
|
139
|
+
repos: string[];
|
|
140
|
+
updatedAt: string;
|
|
141
|
+
stories: MeshStory[];
|
|
142
|
+
}
|
|
143
|
+
export interface WorkMeshRead {
|
|
144
|
+
companyUid: string;
|
|
145
|
+
threads: MeshThread[];
|
|
146
|
+
projects: MeshProject[];
|
|
147
|
+
/** Person or agent uid to display name, from the project cache. */
|
|
148
|
+
names: Record<string, string>;
|
|
149
|
+
}
|
|
150
|
+
export interface CliReadOptions {
|
|
151
|
+
company: string;
|
|
152
|
+
run?: CommandRunner;
|
|
153
|
+
hq?: HqCommand;
|
|
154
|
+
timeoutMs?: number;
|
|
155
|
+
}
|
|
156
|
+
export declare function normalizeThread(raw: unknown): MeshThread | null;
|
|
157
|
+
export declare function normalizeProject(raw: unknown, names: Record<string, string>): MeshProject | null;
|
|
158
|
+
export interface WorkMeshReadOptions extends CliReadOptions {
|
|
159
|
+
/** Folder holding the Work Mesh cache. Default ~/.hq/work-mesh/cache. */
|
|
160
|
+
cacheDir?: string;
|
|
161
|
+
}
|
|
162
|
+
/** Threads from `hq mesh check`, and project detail from the cache folder of the uid Work Mesh returned. */
|
|
163
|
+
export declare function readWorkMesh(opts: WorkMeshReadOptions): Promise<WorkMeshRead>;
|
|
164
|
+
export interface LiveSession {
|
|
165
|
+
sessionId: string;
|
|
166
|
+
owner: string;
|
|
167
|
+
ownerType: string;
|
|
168
|
+
status: string;
|
|
169
|
+
repo: string;
|
|
170
|
+
branch: string;
|
|
171
|
+
folder: string;
|
|
172
|
+
startedAt: string;
|
|
173
|
+
lastTurnAt: string;
|
|
174
|
+
}
|
|
175
|
+
export interface SessionsRead {
|
|
176
|
+
generatedAt: string;
|
|
177
|
+
sessions: LiveSession[];
|
|
178
|
+
/** Actor uid to display name. */
|
|
179
|
+
names: Record<string, string>;
|
|
180
|
+
}
|
|
181
|
+
/** Open HQ sessions for the company, from the company-wide live read. */
|
|
182
|
+
export declare function readSessions(opts: CliReadOptions): Promise<SessionsRead>;
|
|
183
|
+
export interface OntologyEdge {
|
|
184
|
+
verb: string;
|
|
185
|
+
target: string;
|
|
186
|
+
name: string;
|
|
187
|
+
src: string;
|
|
188
|
+
date: string;
|
|
189
|
+
}
|
|
190
|
+
export interface OntologyEntity {
|
|
191
|
+
id: string;
|
|
192
|
+
name: string;
|
|
193
|
+
aliases: string[];
|
|
194
|
+
repo: string;
|
|
195
|
+
status: string;
|
|
196
|
+
summary: string;
|
|
197
|
+
owner: string;
|
|
198
|
+
ownerSource: string;
|
|
199
|
+
/** Newest date on any fact or edge. */
|
|
200
|
+
date: string;
|
|
201
|
+
edges: OntologyEdge[];
|
|
202
|
+
}
|
|
203
|
+
export interface OntologyRead {
|
|
204
|
+
/** Project names from the brief, most recently active first. */
|
|
205
|
+
activeProjects: string[];
|
|
206
|
+
customers: string[];
|
|
207
|
+
/** Entities looked up, keyed by the name asked for. */
|
|
208
|
+
entities: Record<string, OntologyEntity>;
|
|
209
|
+
/** Names that did not resolve, and resolved entities with no relationships. */
|
|
210
|
+
gaps: string[];
|
|
211
|
+
}
|
|
212
|
+
export interface OntologyReadOptions extends CliReadOptions {
|
|
213
|
+
/** Names to look up after the brief (project slugs). */
|
|
214
|
+
lookups?: string[];
|
|
215
|
+
/**
|
|
216
|
+
* When the whole read has to be over (epoch milliseconds, real clock). Each
|
|
217
|
+
* `hq` call is started with what is left, so no child outlives it. Names
|
|
218
|
+
* not reached in time are reported as gaps.
|
|
219
|
+
*/
|
|
220
|
+
deadlineMs?: number;
|
|
221
|
+
}
|
|
222
|
+
/** The ontology brief, then lookup and neighbors for each name asked for. */
|
|
223
|
+
export declare function readOntology(opts: OntologyReadOptions): Promise<OntologyRead>;
|
|
224
|
+
export interface PullRequest {
|
|
225
|
+
/** owner/name */
|
|
226
|
+
repo: string;
|
|
227
|
+
number: number;
|
|
228
|
+
title: string;
|
|
229
|
+
branch: string;
|
|
230
|
+
labels: string[];
|
|
231
|
+
author: string;
|
|
232
|
+
draft: boolean;
|
|
233
|
+
createdAt: string;
|
|
234
|
+
updatedAt: string;
|
|
235
|
+
url: string;
|
|
236
|
+
body: string;
|
|
237
|
+
/** Commit at the head of the branch. The changed paths are cached under it. */
|
|
238
|
+
headSha: string;
|
|
239
|
+
/**
|
|
240
|
+
* Paths of the files the pull request changes, when they have been read
|
|
241
|
+
* (readPullRequestPaths: one request per pull request, so the refresh reads
|
|
242
|
+
* them only for pull requests nothing else matched, and caches them).
|
|
243
|
+
*/
|
|
244
|
+
paths?: string[];
|
|
245
|
+
}
|
|
246
|
+
export interface PullRequestReadOptions {
|
|
247
|
+
repos: string[];
|
|
248
|
+
run?: CommandRunner;
|
|
249
|
+
/** The gh program. Default "gh". */
|
|
250
|
+
gh?: string;
|
|
251
|
+
timeoutMs?: number;
|
|
252
|
+
}
|
|
253
|
+
/** The caller's environment without the shared GitHub token variables. */
|
|
254
|
+
export declare function ghEnvironment(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
255
|
+
/** The exact arguments of the one GitHub call this module makes per repo. A GET; it changes nothing. */
|
|
256
|
+
export declare function pullRequestArgs(repo: string): string[];
|
|
257
|
+
/** Open pull requests of each repo, read with one paginated GET per repo. */
|
|
258
|
+
export declare function readPullRequests(opts: PullRequestReadOptions): Promise<PullRequest[]>;
|
|
259
|
+
/** The exact arguments of the one GitHub call made per pull request for its changed files. A GET; it changes nothing. */
|
|
260
|
+
export declare function pullRequestFilesArgs(repo: string, number: number): string[];
|
|
261
|
+
/**
|
|
262
|
+
* The paths of the files one pull request changes: its first 100, in one GET.
|
|
263
|
+
* Null when they could not be read; the pull request is then matched without
|
|
264
|
+
* them.
|
|
265
|
+
*/
|
|
266
|
+
export declare function readPullRequestPaths(opts: {
|
|
267
|
+
repo: string;
|
|
268
|
+
number: number;
|
|
269
|
+
run?: CommandRunner;
|
|
270
|
+
gh?: string;
|
|
271
|
+
timeoutMs?: number;
|
|
272
|
+
}): Promise<string[] | null>;
|
|
273
|
+
/** What a project's own plan says about where its work lands. */
|
|
274
|
+
export interface ProjectPlan {
|
|
275
|
+
projectId: string;
|
|
276
|
+
/** Repo name without the owner, or "" when the plan names none. */
|
|
277
|
+
repo: string;
|
|
278
|
+
/** The branch the plan names for the project, or "". */
|
|
279
|
+
branch: string;
|
|
280
|
+
/** Files and folders in the project's repo that its stories list, as repo-relative paths. */
|
|
281
|
+
files: string[];
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Read the plans (prd.json) of the named projects from the company's own
|
|
285
|
+
* projects folder. A project with no plan, or an unreadable one, is left out:
|
|
286
|
+
* the plan is supporting evidence, not a source the map depends on.
|
|
287
|
+
*/
|
|
288
|
+
export declare function readProjectPlans(opts: {
|
|
289
|
+
hqRoot: string;
|
|
290
|
+
company: string;
|
|
291
|
+
projectIds: string[];
|
|
292
|
+
}): Record<string, ProjectPlan>;
|
|
293
|
+
export {};
|
|
294
|
+
//# sourceMappingURL=sources.d.ts.map
|