@indigoai-us/hq-cli 5.345.250 → 5.345.252
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 +214 -0
- package/assets/scaffold/core/scripts/hq-session.sh +9 -0
- package/contracts/host-canary-release.json +9 -3
- package/dist/command-catalog.generated.d.ts +316 -2
- package/dist/command-catalog.generated.js +389 -2
- package/dist/commands/bot.js +12 -3
- package/dist/commands/core-bucket-c-work-mesh-offer-native.js +1 -1
- package/dist/commands/core-hq-session-binding.d.ts +140 -0
- package/dist/commands/core-hq-session-binding.js +363 -0
- package/dist/commands/core-hq-session-native.d.ts +23 -0
- package/dist/commands/core-hq-session-native.js +59 -9
- package/dist/commands/core-stop-autosave.js +1 -1
- package/dist/commands/core.js +10 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +42 -5
- package/dist/commands/files.js +1 -1
- package/dist/commands/install-global.js +4 -2
- package/dist/commands/lanes.d.ts +2 -0
- package/dist/commands/lanes.js +9 -4
- package/dist/commands/logout.js +4 -0
- package/dist/commands/ontology-graph.d.ts +11 -2
- package/dist/commands/ontology-graph.js +130 -4
- package/dist/commands/report.js +35 -2
- package/dist/commands/sources.js +26 -8
- package/dist/commands/storage-gate.js +1 -1
- package/dist/commands/vault-retention-flag.js +2 -1
- package/dist/commands/whoami.js +1 -1
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +238 -221
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/agent-kit/inbox-poll-backoff-flag.js +1 -1
- package/dist/lib/agent-kit/mcp/tools.js +48 -0
- package/dist/lib/bot/fleet-bots-update-pass.js +1 -1
- package/dist/lib/bot/fleet-cron.d.ts +37 -0
- package/dist/lib/bot/fleet-cron.js +59 -12
- package/dist/lib/bot/fleet-local.d.ts +18 -0
- package/dist/lib/bot/fleet-local.js +51 -5
- package/dist/lib/bot/inbox-poll-backoff-flag.js +1 -1
- package/dist/lib/bot/signals-engine-flag.d.ts +1 -1
- package/dist/lib/bot/signals-engine-flag.js +1 -1
- package/dist/lib/cli-invite-nudge.js +1 -1
- package/dist/lib/client-version.d.ts +2 -0
- package/dist/lib/client-version.js +24 -0
- package/dist/lib/company-flag-gate.d.ts +30 -0
- package/dist/lib/company-flag-gate.js +104 -0
- package/dist/lib/core-utils/hook-timeout-debug-context-flag.js +1 -1
- package/dist/lib/daemon/flag.js +2 -1
- package/dist/lib/daemon/legacy-journal-gate.js +3 -1
- package/dist/lib/daemon/shared-flag-reads.js +1 -1
- package/dist/lib/doctor/checks/host-core.js +22 -4
- package/dist/lib/doctor/checks/jq.d.ts +27 -6
- package/dist/lib/doctor/checks/jq.js +46 -8
- package/dist/lib/doctor/client-health-reason-codes-flag.js +1 -1
- package/dist/lib/doctor/fix/refresh-sync-handoff.d.ts +1 -1
- package/dist/lib/doctor/fix/refresh-sync-handoff.js +1 -1
- package/dist/lib/flag-client-gate-headers.d.ts +38 -0
- package/dist/lib/flag-client-gate-headers.js +62 -0
- package/dist/lib/flag-client-headers.d.ts +15 -0
- package/dist/lib/flag-client-headers.js +25 -0
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/flag-registry-worker.js +35 -0
- package/dist/lib/flag-registry.d.ts +1 -20
- package/dist/lib/flag-registry.js +5 -81
- package/dist/lib/hook-engine/adapter-core-pin.d.ts +29 -0
- package/dist/lib/hook-engine/adapter-core-pin.js +29 -0
- package/dist/lib/hook-engine/coverage.d.ts +68 -8
- package/dist/lib/hook-engine/coverage.js +167 -25
- package/dist/lib/hook-engine/native-stop-compatibility.json +9 -4
- package/dist/lib/hook-engine/reconcile.js +3 -2
- package/dist/lib/hot-channels/graph-context.d.ts +26 -1
- package/dist/lib/hot-channels/graph-context.js +76 -9
- package/dist/lib/hot-channels/prompts/signals-pass.md +20 -0
- package/dist/lib/hot-channels/run.d.ts +1 -0
- package/dist/lib/hot-channels/signal-changes.d.ts +228 -0
- package/dist/lib/hot-channels/signal-changes.js +683 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +24 -0
- package/dist/lib/hot-channels/signals-pass.js +240 -15
- package/dist/lib/lanes/outpost-worktree-pruner-flag.d.ts +1 -1
- package/dist/lib/lanes/outpost-worktree-pruner-flag.js +1 -1
- package/dist/lib/lanes/registry-flag.js +2 -1
- package/dist/lib/lanes/spawn.js +11 -1
- package/dist/lib/mesh/live/binding-intent.d.ts +61 -0
- package/dist/lib/mesh/live/binding-intent.js +201 -0
- package/dist/lib/mesh/live/binding-receipt.d.ts +157 -0
- package/dist/lib/mesh/live/binding-receipt.js +365 -0
- package/dist/lib/mesh/live/company-flag-refresh.js +1 -1
- package/dist/lib/mesh/live/daemon/doctor-telemetry.d.ts +39 -0
- package/dist/lib/mesh/live/daemon/doctor-telemetry.js +58 -0
- package/dist/lib/mesh/live/daemon/install.js +2 -1
- package/dist/lib/mesh/live/daemon/presence.js +9 -0
- package/dist/lib/mesh/live/daemon/run.d.ts +3 -0
- package/dist/lib/mesh/live/daemon/run.js +33 -1
- package/dist/lib/ontology-graph/lineage/index.d.ts +401 -0
- package/dist/lib/ontology-graph/lineage/index.js +1027 -0
- package/dist/lib/ontology-graph/model/files.d.ts +4 -0
- package/dist/lib/ontology-graph/model/files.js +23 -0
- package/dist/lib/ontology-graph/model/index.d.ts +65 -1
- package/dist/lib/ontology-graph/model/index.js +154 -18
- package/dist/lib/ontology-graph/model/pass-tasks.d.ts +84 -1
- package/dist/lib/ontology-graph/model/pass-tasks.js +173 -4
- package/dist/lib/ontology-graph/model/pass.d.ts +11 -0
- package/dist/lib/ontology-graph/model/pass.js +17 -10
- package/dist/lib/ontology-graph/model/pending-items.d.ts +39 -0
- package/dist/lib/ontology-graph/model/pending-items.js +136 -0
- package/dist/lib/ontology-graph/model/step.d.ts +47 -2
- package/dist/lib/ontology-graph/model/step.js +202 -36
- package/dist/lib/ontology-graph/model/tasks.d.ts +28 -4
- package/dist/lib/ontology-graph/model/tasks.js +48 -15
- package/dist/lib/ontology-graph/pages/render.d.ts +1 -1
- package/dist/lib/ontology-graph/pages/render.js +4 -3
- package/dist/lib/ontology-graph/read/brief.d.ts +13 -3
- package/dist/lib/ontology-graph/read/brief.js +349 -67
- package/dist/lib/ontology-graph/read/index.d.ts +5 -1
- package/dist/lib/ontology-graph/read/index.js +174 -30
- package/dist/lib/ontology-graph/read/lineage.d.ts +101 -0
- package/dist/lib/ontology-graph/read/lineage.js +262 -0
- package/dist/lib/ontology-graph/read/reader-setting.d.ts +2 -0
- package/dist/lib/ontology-graph/read/reader-setting.js +4 -1
- package/dist/lib/ontology-graph/remodel/index.d.ts +174 -0
- package/dist/lib/ontology-graph/remodel/index.js +450 -0
- package/dist/lib/ontology-graph/replay/buffered-store.js +17 -0
- package/dist/lib/ontology-graph/replay/engine.d.ts +32 -1
- package/dist/lib/ontology-graph/replay/engine.js +213 -8
- package/dist/lib/ontology-graph/replay/extractors.d.ts +26 -0
- package/dist/lib/ontology-graph/replay/extractors.js +25 -1
- package/dist/lib/ontology-graph/replay/index.d.ts +2 -0
- package/dist/lib/ontology-graph/replay/index.js +120 -8
- package/dist/lib/ontology-graph/replay/signal-changes.d.ts +118 -0
- package/dist/lib/ontology-graph/replay/signal-changes.js +687 -0
- package/dist/lib/ontology-graph/schema/authority.d.ts +14 -5
- package/dist/lib/ontology-graph/schema/authority.js +13 -3
- package/dist/lib/ontology-graph/schema/decision-status.d.ts +18 -0
- package/dist/lib/ontology-graph/schema/decision-status.js +20 -0
- package/dist/lib/ontology-graph/schema/index.d.ts +2 -1
- package/dist/lib/ontology-graph/schema/index.js +2 -1
- package/dist/lib/ontology-graph/setup/index.d.ts +88 -0
- package/dist/lib/ontology-graph/setup/index.js +499 -0
- package/dist/lib/ontology-graph/types.d.ts +21 -0
- package/dist/lib/ontology-graph/types.js +5 -0
- package/dist/lib/search-index/index.d.ts +33 -1
- package/dist/lib/search-index/index.js +180 -25
- package/dist/lib/search-index/qmd-exit-diagnostics.d.ts +7 -0
- package/dist/lib/search-index/qmd-exit-diagnostics.js +25 -1
- package/dist/lib/signals/adapters-catalog.js +1 -1
- package/dist/lib/signals/failure-alert.js +4 -5
- package/dist/lib/signals/steps/adapters.js +3 -0
- package/dist/lib/sync-core/engine-holds.d.ts +1 -0
- package/dist/lib/sync-core/engine-holds.js +26 -0
- package/dist/lib/sync-core/engine-home.d.ts +3 -0
- package/dist/lib/sync-core/engine-home.js +41 -1
- package/dist/lib/sync-core/flag.js +2 -1
- package/dist/lib/sync-core/legacy-journal-export-child.js +5 -3
- package/dist/lib/sync-core/legacy-journal-export.d.ts +23 -4
- package/dist/lib/sync-core/legacy-journal-export.js +120 -55
- package/dist/lib/sync-core/reconcile.d.ts +2 -1
- package/dist/lib/sync-core/reconcile.js +30 -5
- package/dist/lib/sync-invalid-entity-warning.js +2 -1
- package/dist/lib/windows/install-followup.d.ts +41 -0
- package/dist/lib/windows/install-followup.js +87 -0
- package/dist/lib/windows/jq.d.ts +59 -0
- package/dist/lib/windows/jq.js +154 -3
- package/dist/lib/windows/user-path.d.ts +5 -0
- package/dist/lib/windows/user-path.js +1 -1
- package/dist/lib/work-context/auto-bind.d.ts +12 -0
- package/dist/lib/work-context/auto-bind.js +49 -3
- package/dist/lib/work-context/organize.d.ts +4 -2
- package/dist/lib/work-context/organize.js +18 -8
- package/dist/lib/work-context/reconcile.js +16 -1
- package/dist/main.js +12 -1
- package/dist/utils/client-health-contract.d.ts +30 -0
- package/dist/utils/client-health-contract.js +111 -0
- package/dist/utils/client-health.d.ts +5 -2
- package/dist/utils/client-health.js +74 -5
- package/dist/utils/exclusive-lock.d.ts +5 -1
- package/dist/utils/exclusive-lock.js +9 -2
- package/dist/utils/host-registration.d.ts +7 -0
- package/dist/utils/host-registration.js +10 -1
- package/dist/utils/pid.d.ts +31 -0
- package/dist/utils/pid.js +65 -0
- package/dist/utils/resident-package-preload.js +12 -4
- package/dist/utils/sentry-fingerprint.js +3 -0
- package/dist/utils/sync-person.d.ts +15 -0
- package/dist/utils/sync-person.js +74 -0
- package/package.json +8 -8
- package/scripts/install-hook-engine.mjs +5 -3
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Setup commands: the two settings a member used to write by hand, and one
|
|
3
|
+
* screen that says what state this machine is in.
|
|
4
|
+
*
|
|
5
|
+
* hq ontology reader [graph|entities] --company <slug>
|
|
6
|
+
* hq ontology model [<model>] --company <slug>
|
|
7
|
+
* hq ontology status --company <slug>
|
|
8
|
+
*
|
|
9
|
+
* `reader` shows or sets `personal/settings/ontology-reader.yaml` (see
|
|
10
|
+
* read/reader-setting.ts). `model` shows or sets `model:` in the company's
|
|
11
|
+
* `settings/ontology.yaml` (see `resolveModel` in model/index.ts). `status`
|
|
12
|
+
* reads and writes nothing.
|
|
13
|
+
*
|
|
14
|
+
* None of the three opens a graph folder for reading rows through the store,
|
|
15
|
+
* and none stamps one. `reader graph` is refused unless the company's own
|
|
16
|
+
* graph folder exists and is stamped for that company, so a session is never
|
|
17
|
+
* pointed at a graph that is missing or is another company's. The isolation,
|
|
18
|
+
* audience and stamp rules of the other commands are unchanged.
|
|
19
|
+
*/
|
|
20
|
+
import * as fs from "node:fs";
|
|
21
|
+
import * as path from "node:path";
|
|
22
|
+
import yaml from "js-yaml";
|
|
23
|
+
import { MODEL_STATE_PATHS, ONTOLOGY_MODEL_ENV, ONTOLOGY_SETTINGS_FILE, estimateTokens, isOntologyModelName, heldMarkerCounts, modelTasksLine, modelTasksNotes, peekPendingMarkers, readModelSetting, readModelTasks, resolveModelStateDir } from "../model/index.js";
|
|
24
|
+
import { DEFAULT_ONTOLOGY_MODEL } from "../model/runner.js";
|
|
25
|
+
import { graphExists } from "../read/graph-index.js";
|
|
26
|
+
import { READER_SETTING_RELATIVE, parseReaderSetting, readReaderSetting, readerSettingFile } from "../read/reader-setting.js";
|
|
27
|
+
import { GRAPH_PATHS, GRAPH_ROOT_RELATIVE, defaultGraphRoot, graphPath, readGraphCompany } from "../store/paths.js";
|
|
28
|
+
import { GRAPH_ENTITY_TYPES } from "../types.js";
|
|
29
|
+
/** A request the command refuses. The command file turns it into a usage error. */
|
|
30
|
+
export class OntologySetupError extends Error {
|
|
31
|
+
constructor(message) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.name = "OntologySetupError";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** The reader file is read by the session hook with shell builtins and by `readReaderSetting`, which ignores a file over this size. */
|
|
37
|
+
const MAX_READER_SETTING_BYTES = 4096;
|
|
38
|
+
const MAX_MODEL_SETTING_BYTES = 64 * 1024;
|
|
39
|
+
const NEW_READER_FILE_HEADER = [
|
|
40
|
+
"# Which ontology this machine reads. Written by `hq ontology reader`.",
|
|
41
|
+
"# reader: entities the old entity files (companies/<co>/ontology/entities). Default.",
|
|
42
|
+
"# reader: graph the graph (companies/<co>/.hq/ontology-graph).",
|
|
43
|
+
"# One \"key: value\" per line. Any value other than \"graph\", or no file, means the old reader.",
|
|
44
|
+
];
|
|
45
|
+
const NEW_MODEL_FILE_HEADER = [
|
|
46
|
+
"# Model used by the ontology graph's model step for this company (rebuild, update, remodel).",
|
|
47
|
+
"# Written by `hq ontology model`. This file is per machine: settings/ is not synced.",
|
|
48
|
+
];
|
|
49
|
+
function rel(hqRoot, file) {
|
|
50
|
+
const relative = path.relative(hqRoot, file);
|
|
51
|
+
return relative.startsWith("..") || path.isAbsolute(relative) ? file : relative.split(path.sep).join("/");
|
|
52
|
+
}
|
|
53
|
+
/** Temp file plus rename, in the same folder. */
|
|
54
|
+
function writeAtomic(file, text) {
|
|
55
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
56
|
+
const temp = `${file}.tmp-${String(process.pid)}-${String(Date.now())}`;
|
|
57
|
+
try {
|
|
58
|
+
fs.writeFileSync(temp, text, { flag: "wx" });
|
|
59
|
+
fs.renameSync(temp, file);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
fs.rmSync(temp, { force: true });
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The text of a settings file that a command may rewrite, or null when there
|
|
68
|
+
* is none. A symlink, a folder or a file over `maxBytes` is refused: the
|
|
69
|
+
* command writes only a plain file it can read whole.
|
|
70
|
+
*/
|
|
71
|
+
function readOwnSettingFile(file, label, maxBytes) {
|
|
72
|
+
let stat;
|
|
73
|
+
try {
|
|
74
|
+
stat = fs.lstatSync(file);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
if (error.code === "ENOENT")
|
|
78
|
+
return null;
|
|
79
|
+
throw new OntologySetupError(`ontology: ${label} cannot be read (${error.code ?? "error"}); nothing was changed`);
|
|
80
|
+
}
|
|
81
|
+
if (!stat.isFile())
|
|
82
|
+
throw new OntologySetupError(`ontology: ${label} is not a plain file (a link or a folder); nothing was changed`);
|
|
83
|
+
if (stat.size > maxBytes)
|
|
84
|
+
throw new OntologySetupError(`ontology: ${label} is larger than ${String(maxBytes)} bytes; nothing was changed. Shorten it by hand and run again.`);
|
|
85
|
+
return fs.readFileSync(file, "utf8");
|
|
86
|
+
}
|
|
87
|
+
/** Says whether a graph folder exists and whose it says it is. Never throws and never writes. */
|
|
88
|
+
export function inspectGraphFolder(root, company) {
|
|
89
|
+
const present = graphExists(root);
|
|
90
|
+
if (!present)
|
|
91
|
+
return { root, present, stamp: null, state: "missing", detail: "no graph has been built here" };
|
|
92
|
+
let stamp;
|
|
93
|
+
try {
|
|
94
|
+
stamp = readGraphCompany(root);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
return { root, present, stamp: null, state: "unreadable", detail: error.message.replace(/^ontology graph: /, "") };
|
|
98
|
+
}
|
|
99
|
+
if (stamp === null)
|
|
100
|
+
return { root, present, stamp, state: "unstamped", detail: "the folder holds a graph and says no company" };
|
|
101
|
+
if (stamp !== company)
|
|
102
|
+
return { root, present, stamp, state: "other-company", detail: `the folder holds the graph of company ${stamp}` };
|
|
103
|
+
return { root, present, stamp, state: "ok", detail: `stamped for ${company}` };
|
|
104
|
+
}
|
|
105
|
+
/** The reader a session of this company gets: `graph` only when the one setting says graph for this company. */
|
|
106
|
+
function effectiveReader(setting, company) {
|
|
107
|
+
return setting.reader === "graph" && setting.company === company ? "graph" : "entities";
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The setting text with `reader:` and `company:` set. Every other line is
|
|
111
|
+
* kept as it is (comments, `member:`). The first line of each key is
|
|
112
|
+
* replaced and a repeated one is dropped, so the two readers of the file
|
|
113
|
+
* (line by line in the shell hook, `parseReaderSetting` here) cannot disagree.
|
|
114
|
+
*/
|
|
115
|
+
export function renderReaderSetting(existing, reader, company) {
|
|
116
|
+
const lines = existing === null ? [...NEW_READER_FILE_HEADER] : existing.replace(/\r\n/g, "\n").replace(/\n$/, "").split("\n");
|
|
117
|
+
const out = [];
|
|
118
|
+
const seen = { reader: false, company: false };
|
|
119
|
+
for (const line of lines) {
|
|
120
|
+
const key = /^(reader|company):/.exec(line)?.[1];
|
|
121
|
+
if (!key) {
|
|
122
|
+
out.push(line);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (seen[key])
|
|
126
|
+
continue;
|
|
127
|
+
seen[key] = true;
|
|
128
|
+
out.push(key === "reader" ? `reader: ${reader}` : `company: ${company}`);
|
|
129
|
+
}
|
|
130
|
+
if (!seen.reader)
|
|
131
|
+
out.push(`reader: ${reader}`);
|
|
132
|
+
if (!seen.company)
|
|
133
|
+
out.push(`company: ${company}`);
|
|
134
|
+
return `${out.join("\n")}\n`;
|
|
135
|
+
}
|
|
136
|
+
function readerLines(context, setting, effective) {
|
|
137
|
+
const file = READER_SETTING_RELATIVE;
|
|
138
|
+
const lines = [`reader for ${context.company}: ${effective}`];
|
|
139
|
+
if (!setting.present)
|
|
140
|
+
lines.push(`setting: none (${file} is not there; the default is entities)`);
|
|
141
|
+
else if (setting.reader === "graph" && setting.company !== context.company) {
|
|
142
|
+
lines.push(`setting: graph for ${setting.company === "" ? "no company" : setting.company} (${file}); it does not apply to ${context.company}`);
|
|
143
|
+
}
|
|
144
|
+
else
|
|
145
|
+
lines.push(`setting: ${setting.reader}${setting.company ? ` for ${setting.company}` : ""} (${file})`);
|
|
146
|
+
return lines;
|
|
147
|
+
}
|
|
148
|
+
/** `hq ontology reader [graph|entities]`: show or set which ontology this machine's sessions read for the company. */
|
|
149
|
+
export async function readerCommand(context, options = {}) {
|
|
150
|
+
const file = readerSettingFile(context.hqRoot);
|
|
151
|
+
const before = readReaderSetting(context.hqRoot);
|
|
152
|
+
const was = effectiveReader(before, context.company);
|
|
153
|
+
const switchTo = (reader) => `hq ontology reader ${reader} --company ${context.company}`;
|
|
154
|
+
if (options.value === undefined) {
|
|
155
|
+
const lines = readerLines(context, before, was);
|
|
156
|
+
lines.push(was === "graph" ? `to switch back to the old files: ${switchTo("entities")}` : `to read the graph: ${switchTo("graph")}`);
|
|
157
|
+
return { text: lines.join("\n"), json: { company: context.company, reader: was, setting: { ...before, file: rel(context.hqRoot, file) }, changed: false } };
|
|
158
|
+
}
|
|
159
|
+
if (options.value !== "graph" && options.value !== "entities")
|
|
160
|
+
throw new OntologySetupError(`ontology: reader is graph or entities, not ${options.value}`);
|
|
161
|
+
const want = options.value;
|
|
162
|
+
if (want === "graph") {
|
|
163
|
+
// The sessions and the signals pass read the company's own folder, so that is the one checked.
|
|
164
|
+
const own = defaultGraphRoot(context.companyRoot);
|
|
165
|
+
const graph = inspectGraphFolder(own, context.company);
|
|
166
|
+
if (graph.state !== "ok") {
|
|
167
|
+
const where = `companies/${context.company}/${GRAPH_ROOT_RELATIVE}`;
|
|
168
|
+
const fix = graph.state === "missing"
|
|
169
|
+
? `Build it first: hq ontology rebuild --company ${context.company}`
|
|
170
|
+
: graph.state === "unstamped"
|
|
171
|
+
? `A build stamps it: hq ontology update --company ${context.company}`
|
|
172
|
+
: "It is not this company's graph and is not used.";
|
|
173
|
+
throw new OntologySetupError(`ontology: reader not set to graph: ${where}: ${graph.detail}. ${fix}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const base = { company: context.company, file: rel(context.hqRoot, file) };
|
|
177
|
+
if (want === was) {
|
|
178
|
+
// Already so. `entities` for a company the setting does not name leaves another company's setting alone.
|
|
179
|
+
const lines = [`reader for ${context.company}: ${want} (unchanged)`];
|
|
180
|
+
if (want === "entities" && before.reader === "graph" && before.company !== context.company) {
|
|
181
|
+
lines.push(`the setting says graph for ${before.company === "" ? "no company" : before.company} and was left as it is (${READER_SETTING_RELATIVE})`);
|
|
182
|
+
}
|
|
183
|
+
lines.push(want === "graph" ? `to switch back to the old files: ${switchTo("entities")}` : `to read the graph: ${switchTo("graph")}`);
|
|
184
|
+
return { text: lines.join("\n"), json: { ...base, reader: want, was, changed: false } };
|
|
185
|
+
}
|
|
186
|
+
const existing = readOwnSettingFile(file, READER_SETTING_RELATIVE, MAX_READER_SETTING_BYTES);
|
|
187
|
+
const text = renderReaderSetting(existing, want, context.company);
|
|
188
|
+
if (Buffer.byteLength(text) > MAX_READER_SETTING_BYTES)
|
|
189
|
+
throw new OntologySetupError(`ontology: ${READER_SETTING_RELATIVE} would be larger than ${String(MAX_READER_SETTING_BYTES)} bytes; nothing was changed`);
|
|
190
|
+
const check = parseReaderSetting(text);
|
|
191
|
+
if (check.reader !== want || check.company !== context.company)
|
|
192
|
+
throw new OntologySetupError(`ontology: ${READER_SETTING_RELATIVE} could not be rewritten safely; nothing was changed`);
|
|
193
|
+
writeAtomic(file, text);
|
|
194
|
+
const lines = [`reader for ${context.company}: ${want} (was ${was})`, `written: ${READER_SETTING_RELATIVE}`];
|
|
195
|
+
if (before.reader === "graph" && before.company !== "" && before.company !== context.company) {
|
|
196
|
+
lines.push(`the setting named ${before.company} before; one machine reads the graph of one company, so ${before.company} is back on the old files`);
|
|
197
|
+
if (before.member)
|
|
198
|
+
lines.push(`the member line (${before.member}) was kept; check that it is right for ${context.company}`);
|
|
199
|
+
}
|
|
200
|
+
if (want === "graph") {
|
|
201
|
+
lines.push("new sessions pick it up at start; this session is not changed");
|
|
202
|
+
lines.push(`to switch back to the old files: ${switchTo("entities")}`);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
lines.push("the graph folder is kept; nothing was deleted");
|
|
206
|
+
lines.push(`to read the graph again: ${switchTo("graph")}`);
|
|
207
|
+
}
|
|
208
|
+
return { text: lines.join("\n"), json: { ...base, reader: want, was, changed: true } };
|
|
209
|
+
}
|
|
210
|
+
function modelSettingFile(companyRoot) {
|
|
211
|
+
return path.join(companyRoot, ...ONTOLOGY_SETTINGS_FILE.split("/"));
|
|
212
|
+
}
|
|
213
|
+
/** The model the step would call on this machine and where that comes from. Reads only. */
|
|
214
|
+
export function readModelState(context, env = process.env) {
|
|
215
|
+
const setting = readModelSetting(context.companyRoot);
|
|
216
|
+
const rawEnv = env[ONTOLOGY_MODEL_ENV];
|
|
217
|
+
const fromEnv = isOntologyModelName(rawEnv) ? rawEnv.trim() : null;
|
|
218
|
+
if (fromEnv)
|
|
219
|
+
return { model: fromEnv, source: "env", setting, env: fromEnv };
|
|
220
|
+
if (setting)
|
|
221
|
+
return { model: setting, source: "setting", setting, env: null };
|
|
222
|
+
return { model: DEFAULT_ONTOLOGY_MODEL, source: "default", setting: null, env: null };
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* The settings text with the top-level `model:` set. Every other line is
|
|
226
|
+
* kept. A top-level `model:` wins over `ontology.model` when the step reads
|
|
227
|
+
* the file, so a file that only has the nested key gets the top-level one.
|
|
228
|
+
*/
|
|
229
|
+
export function renderModelSetting(existing, model) {
|
|
230
|
+
const lines = existing === null ? [...NEW_MODEL_FILE_HEADER] : existing.replace(/\r\n/g, "\n").replace(/\n$/, "").split("\n");
|
|
231
|
+
const out = [];
|
|
232
|
+
let seen = false;
|
|
233
|
+
for (const line of lines) {
|
|
234
|
+
if (!/^model[ \t]*:/.test(line)) {
|
|
235
|
+
out.push(line);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
if (seen)
|
|
239
|
+
continue;
|
|
240
|
+
seen = true;
|
|
241
|
+
out.push(`model: ${model}`);
|
|
242
|
+
}
|
|
243
|
+
if (!seen)
|
|
244
|
+
out.push(`model: ${model}`);
|
|
245
|
+
return `${out.join("\n")}\n`;
|
|
246
|
+
}
|
|
247
|
+
const PER_MACHINE_NOTE = "this setting is per machine: settings/ is not synced, so every teammate sets it on their own machine";
|
|
248
|
+
function sourceWords(state, company) {
|
|
249
|
+
if (state.source === "env")
|
|
250
|
+
return `from ${ONTOLOGY_MODEL_ENV} in this shell`;
|
|
251
|
+
if (state.source === "setting")
|
|
252
|
+
return `from companies/${company}/${ONTOLOGY_SETTINGS_FILE}`;
|
|
253
|
+
return `the default; companies/${company}/${ONTOLOGY_SETTINGS_FILE} names none`;
|
|
254
|
+
}
|
|
255
|
+
/** `hq ontology model [<model>]`: show or set the model the graph's model step calls for the company on this machine. */
|
|
256
|
+
export async function modelCommand(context, options = {}) {
|
|
257
|
+
const env = options.env ?? process.env;
|
|
258
|
+
const file = modelSettingFile(context.companyRoot);
|
|
259
|
+
const shown = `companies/${context.company}/${ONTOLOGY_SETTINGS_FILE}`;
|
|
260
|
+
const before = readModelState(context, env);
|
|
261
|
+
if (options.value === undefined) {
|
|
262
|
+
const lines = [`model for ${context.company}: ${before.model} (${sourceWords(before, context.company)})`];
|
|
263
|
+
if (before.source === "env" && before.setting)
|
|
264
|
+
lines.push(`setting: ${before.setting} (${shown}); ${ONTOLOGY_MODEL_ENV} wins over it in this shell`);
|
|
265
|
+
lines.push(PER_MACHINE_NOTE);
|
|
266
|
+
lines.push(`to set it: hq ontology model <model> --company ${context.company}`);
|
|
267
|
+
return { text: lines.join("\n"), json: { company: context.company, ...before, file: rel(context.hqRoot, file), perMachine: true, changed: false } };
|
|
268
|
+
}
|
|
269
|
+
const model = options.value.trim();
|
|
270
|
+
if (!isOntologyModelName(model)) {
|
|
271
|
+
throw new OntologySetupError("ontology: not a model name. Use a name the claude CLI takes, for example haiku, sonnet, opus or a full model id (letters, digits, dots, dashes and square brackets; 64 characters at most)");
|
|
272
|
+
}
|
|
273
|
+
const base = { company: context.company, file: rel(context.hqRoot, file), perMachine: true };
|
|
274
|
+
const envNote = before.env && before.env !== model ? `${ONTOLOGY_MODEL_ENV} is set to ${before.env} in this shell and wins over the setting until it is unset` : null;
|
|
275
|
+
if (before.setting === model) {
|
|
276
|
+
const lines = [`model for ${context.company}: ${model} (unchanged, ${shown})`, ...(envNote ? [envNote] : []), PER_MACHINE_NOTE];
|
|
277
|
+
return { text: lines.join("\n"), json: { ...base, model, was: before.setting, changed: false } };
|
|
278
|
+
}
|
|
279
|
+
const existing = readOwnSettingFile(file, shown, MAX_MODEL_SETTING_BYTES);
|
|
280
|
+
if (existing !== null) {
|
|
281
|
+
let parsed;
|
|
282
|
+
try {
|
|
283
|
+
parsed = yaml.load(existing);
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
throw new OntologySetupError(`ontology: ${shown} does not parse as YAML; nothing was changed. Fix it by hand and run again.`);
|
|
287
|
+
}
|
|
288
|
+
if (parsed !== null && parsed !== undefined && (typeof parsed !== "object" || Array.isArray(parsed))) {
|
|
289
|
+
throw new OntologySetupError(`ontology: ${shown} is not a list of keys; nothing was changed. Fix it by hand and run again.`);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
const text = renderModelSetting(existing, model);
|
|
293
|
+
// The file as the step will read it: if it would not give this model, nothing is written.
|
|
294
|
+
let readBack;
|
|
295
|
+
try {
|
|
296
|
+
readBack = yaml.load(text)?.model;
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
readBack = undefined;
|
|
300
|
+
}
|
|
301
|
+
if (readBack !== model)
|
|
302
|
+
throw new OntologySetupError(`ontology: ${shown} could not be rewritten safely; nothing was changed`);
|
|
303
|
+
writeAtomic(file, text);
|
|
304
|
+
const lines = [`model for ${context.company}: ${model} (was ${before.setting ?? `${DEFAULT_ONTOLOGY_MODEL}, the default`})`, `written: ${shown}`];
|
|
305
|
+
if (envNote)
|
|
306
|
+
lines.push(envNote);
|
|
307
|
+
lines.push(PER_MACHINE_NOTE);
|
|
308
|
+
if (graphExists(defaultGraphRoot(context.companyRoot))) {
|
|
309
|
+
const old = before.setting ?? DEFAULT_ONTOLOGY_MODEL;
|
|
310
|
+
lines.push(`a graph is already built here: rows ${old} wrote stay until they are asked again (hq ontology remodel --company ${context.company} --from ${old} --dry-run shows how many)`);
|
|
311
|
+
}
|
|
312
|
+
else
|
|
313
|
+
lines.push(`next: hq ontology rebuild --company ${context.company}`);
|
|
314
|
+
return { text: lines.join("\n"), json: { ...base, model, was: before.setting, changed: true } };
|
|
315
|
+
}
|
|
316
|
+
function dirEntries(dir) {
|
|
317
|
+
try {
|
|
318
|
+
return fs.readdirSync(dir, { withFileTypes: true });
|
|
319
|
+
}
|
|
320
|
+
catch {
|
|
321
|
+
return [];
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Counts entity files and row lines straight from the folder. It opens no
|
|
326
|
+
* store, builds no index and prints no row: only how many there are. Links
|
|
327
|
+
* are not followed.
|
|
328
|
+
*/
|
|
329
|
+
export function countGraph(root) {
|
|
330
|
+
const counts = { entities: 0, entitiesByType: {}, rows: 0, facts: 0, relationships: 0, datedLines: 0, audienceFolders: 0 };
|
|
331
|
+
const types = new Set(GRAPH_ENTITY_TYPES);
|
|
332
|
+
for (const type of dirEntries(graphPath(root, GRAPH_PATHS.entities))) {
|
|
333
|
+
if (!type.isDirectory() || !types.has(type.name))
|
|
334
|
+
continue;
|
|
335
|
+
const files = dirEntries(path.join(root, GRAPH_PATHS.entities, type.name)).filter((entry) => entry.isFile() && entry.name.endsWith(".md")).length;
|
|
336
|
+
if (files === 0)
|
|
337
|
+
continue;
|
|
338
|
+
counts.entitiesByType[type.name] = files;
|
|
339
|
+
counts.entities += files;
|
|
340
|
+
}
|
|
341
|
+
const factsRoot = graphPath(root, GRAPH_PATHS.facts);
|
|
342
|
+
for (const audience of dirEntries(factsRoot)) {
|
|
343
|
+
if (!audience.isDirectory() || !audience.name.startsWith("@"))
|
|
344
|
+
continue;
|
|
345
|
+
counts.audienceFolders += 1;
|
|
346
|
+
for (const type of dirEntries(path.join(factsRoot, audience.name))) {
|
|
347
|
+
if (!type.isDirectory() || !types.has(type.name))
|
|
348
|
+
continue;
|
|
349
|
+
const dir = path.join(factsRoot, audience.name, type.name);
|
|
350
|
+
for (const entry of dirEntries(dir)) {
|
|
351
|
+
if (!entry.isFile() || !entry.name.endsWith(".md"))
|
|
352
|
+
continue;
|
|
353
|
+
let text;
|
|
354
|
+
try {
|
|
355
|
+
text = fs.readFileSync(path.join(dir, entry.name), "utf8");
|
|
356
|
+
}
|
|
357
|
+
catch {
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
for (let at = 0; at < text.length;) {
|
|
361
|
+
if (text.startsWith("- F ", at))
|
|
362
|
+
counts.facts += 1;
|
|
363
|
+
else if (text.startsWith("- E ", at))
|
|
364
|
+
counts.relationships += 1;
|
|
365
|
+
else if (text.startsWith("- T ", at))
|
|
366
|
+
counts.datedLines += 1;
|
|
367
|
+
const next = text.indexOf("\n", at);
|
|
368
|
+
if (next === -1)
|
|
369
|
+
break;
|
|
370
|
+
at = next + 1;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
counts.rows = counts.facts + counts.relationships + counts.datedLines;
|
|
376
|
+
return counts;
|
|
377
|
+
}
|
|
378
|
+
function readCursorLook(root) {
|
|
379
|
+
try {
|
|
380
|
+
const parsed = JSON.parse(fs.readFileSync(graphPath(root, GRAPH_PATHS.cursor), "utf8"));
|
|
381
|
+
const days = Object.values(parsed.days ?? {}).filter((day) => typeof day === "string" && /^\d{4}-\d{2}-\d{2}$/.test(day)).sort();
|
|
382
|
+
return {
|
|
383
|
+
updatedAt: typeof parsed.updatedAt === "string" ? parsed.updatedAt : null,
|
|
384
|
+
lastDay: days.length > 0 ? days[days.length - 1] : null,
|
|
385
|
+
run: typeof parsed.run === "string" ? parsed.run : null,
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
catch {
|
|
389
|
+
return { updatedAt: null, lastDay: null, run: null };
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
function readBriefLook(root) {
|
|
393
|
+
const file = graphPath(root, GRAPH_PATHS.brief);
|
|
394
|
+
try {
|
|
395
|
+
const stat = fs.lstatSync(file);
|
|
396
|
+
if (!stat.isFile())
|
|
397
|
+
return { present: false, bytes: 0, tokens: 0, writtenAt: null };
|
|
398
|
+
const text = fs.readFileSync(file, "utf8");
|
|
399
|
+
return { present: true, bytes: stat.size, tokens: estimateTokens(text), writtenAt: stat.mtime.toISOString() };
|
|
400
|
+
}
|
|
401
|
+
catch {
|
|
402
|
+
return { present: false, bytes: 0, tokens: 0, writtenAt: null };
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function pendingLook(context, env) {
|
|
406
|
+
const dir = resolveModelStateDir(context, undefined, env);
|
|
407
|
+
const file = path.join(dir, ...MODEL_STATE_PATHS.pending.replace(/^\.state\//, "").split("/"));
|
|
408
|
+
const byKind = {};
|
|
409
|
+
const markers = peekPendingMarkers(file);
|
|
410
|
+
for (const marker of markers) {
|
|
411
|
+
const kind = typeof marker.kind === "string" ? marker.kind : "other";
|
|
412
|
+
byKind[kind] = (byKind[kind] ?? 0) + 1;
|
|
413
|
+
}
|
|
414
|
+
return { items: markers.length, byKind, held: { ...heldMarkerCounts(markers, readModelTasks(context.companyRoot).tasks) } };
|
|
415
|
+
}
|
|
416
|
+
const number = (value) => value.toLocaleString("en-US");
|
|
417
|
+
/** `hq ontology status`: reader, model, graph, counts, pending model work, last update and brief, on one screen. Reads only. */
|
|
418
|
+
export async function statusCommand(context, options = {}) {
|
|
419
|
+
const env = options.env ?? process.env;
|
|
420
|
+
const setting = readReaderSetting(context.hqRoot);
|
|
421
|
+
const reader = effectiveReader(setting, context.company);
|
|
422
|
+
const model = readModelState(context, env);
|
|
423
|
+
const graph = inspectGraphFolder(context.graphRoot, context.company);
|
|
424
|
+
// Nothing inside a folder that is another company's, or that cannot say whose it is, is counted or read.
|
|
425
|
+
const usable = graph.state === "ok" || (graph.state === "unstamped" && path.resolve(context.graphRoot) === path.resolve(defaultGraphRoot(context.companyRoot)));
|
|
426
|
+
const counts = usable ? countGraph(context.graphRoot) : null;
|
|
427
|
+
const cursor = usable ? readCursorLook(context.graphRoot) : null;
|
|
428
|
+
const brief = usable ? readBriefLook(context.graphRoot) : null;
|
|
429
|
+
const pending = usable ? pendingLook(context, env) : null;
|
|
430
|
+
// The effective `model_tasks` setting, read the way a run reads it. It is shown whether or not a run would call a
|
|
431
|
+
// model at all (`--no-model`), so a person can check the file before a run sends anything.
|
|
432
|
+
const tasks = readModelTasks(context.companyRoot);
|
|
433
|
+
const shownRoot = rel(context.hqRoot, context.graphRoot);
|
|
434
|
+
const next = [];
|
|
435
|
+
if (graph.state === "missing") {
|
|
436
|
+
if (model.source === "default")
|
|
437
|
+
next.push(`choose the model before the first build (the default is ${DEFAULT_ONTOLOGY_MODEL}): hq ontology model <model> --company ${context.company}`);
|
|
438
|
+
next.push(`build the graph: hq ontology rebuild --company ${context.company}`);
|
|
439
|
+
}
|
|
440
|
+
else if (!usable)
|
|
441
|
+
next.push("this folder is not used for this company; point --graph-root elsewhere or remove the folder by hand");
|
|
442
|
+
else {
|
|
443
|
+
if (graph.state === "unstamped")
|
|
444
|
+
next.push(`stamp the folder with a build: hq ontology update --company ${context.company}`);
|
|
445
|
+
if (pending && pending.items - Object.values(pending.held).reduce((sum, count) => sum + count, 0) > 0)
|
|
446
|
+
next.push(`send pending model work: hq ontology update --company ${context.company} --follow-up`);
|
|
447
|
+
if (brief && !brief.present)
|
|
448
|
+
next.push(`write the brief: hq ontology brief --company ${context.company}`);
|
|
449
|
+
if (reader !== "graph" && graph.state === "ok")
|
|
450
|
+
next.push(`read the graph in sessions: hq ontology reader graph --company ${context.company}`);
|
|
451
|
+
}
|
|
452
|
+
const lines = [`ontology status for ${context.company}`];
|
|
453
|
+
lines.push(`reader: ${reader}${setting.present ? "" : " (no setting; the default)"}${setting.present && setting.reader === "graph" && setting.company !== context.company ? ` (the setting says graph for ${setting.company === "" ? "no company" : setting.company})` : ""}`);
|
|
454
|
+
lines.push(`model: ${model.model} (${sourceWords(model, context.company)}; per machine, not synced)`);
|
|
455
|
+
lines.push(`tasks: ${modelTasksLine(tasks.tasks)} (${tasks.source === "default" ? "no model_tasks setting; the default" : tasks.source === "setting" ? `model_tasks in ${ONTOLOGY_SETTINGS_FILE}` : `${ONTOLOGY_SETTINGS_FILE} could not be read as written; the setting fails closed`})`);
|
|
456
|
+
for (const note of modelTasksNotes(tasks))
|
|
457
|
+
lines.push(` ${note}`);
|
|
458
|
+
lines.push(`graph: ${graph.present ? "present" : "missing"}, ${graph.detail} (${shownRoot})`);
|
|
459
|
+
if (counts) {
|
|
460
|
+
const byType = Object.entries(counts.entitiesByType)
|
|
461
|
+
.sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1))
|
|
462
|
+
.map(([type, count]) => `${type} ${number(count)}`)
|
|
463
|
+
.join(", ");
|
|
464
|
+
lines.push(`entities: ${number(counts.entities)}${byType ? ` (${byType})` : ""}`);
|
|
465
|
+
lines.push(`rows: ${number(counts.rows)} (facts ${number(counts.facts)}, relationships ${number(counts.relationships)}, dated lines ${number(counts.datedLines)}) in ${number(counts.audienceFolders)} audience ${counts.audienceFolders === 1 ? "folder" : "folders"}`);
|
|
466
|
+
}
|
|
467
|
+
if (pending) {
|
|
468
|
+
const kinds = Object.entries(pending.byKind)
|
|
469
|
+
.sort((a, b) => (a[0] < b[0] ? -1 : 1))
|
|
470
|
+
.map(([kind, count]) => `${kind} ${number(count)}`)
|
|
471
|
+
.join(", ");
|
|
472
|
+
lines.push(`pending: ${pending.items === 0 ? "no model work pending" : `${number(pending.items)} model ${pending.items === 1 ? "item" : "items"} pending (${kinds})`}`);
|
|
473
|
+
for (const [task, count] of Object.entries(pending.held).sort((a, b) => (a[0] < b[0] ? -1 : 1))) {
|
|
474
|
+
lines.push(` ${number(count)} ${count === 1 ? "item" : "items"} pending for ${task} ${count === 1 ? "is" : "are"} held because the task is off`);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
if (cursor)
|
|
478
|
+
lines.push(`updated: ${cursor.updatedAt ? `${cursor.updatedAt}${cursor.lastDay ? `, replayed through ${cursor.lastDay}` : ""}` : "never"}`);
|
|
479
|
+
if (brief)
|
|
480
|
+
lines.push(`brief: ${brief.present ? `${number(brief.bytes)} bytes, about ${number(brief.tokens)} tokens, written ${brief.writtenAt ?? "unknown"}` : "not written"}`);
|
|
481
|
+
for (const [index, step] of next.entries())
|
|
482
|
+
lines.push(`${index === 0 ? "next: " : " "} ${step}`);
|
|
483
|
+
return {
|
|
484
|
+
text: lines.join("\n"),
|
|
485
|
+
json: {
|
|
486
|
+
company: context.company,
|
|
487
|
+
reader: { effective: reader, setting: { ...setting, file: READER_SETTING_RELATIVE } },
|
|
488
|
+
model: { ...model, perMachine: true },
|
|
489
|
+
modelTasks: { ...tasks.tasks, source: tasks.source, problems: tasks.problems, warnings: tasks.warnings, file: ONTOLOGY_SETTINGS_FILE },
|
|
490
|
+
graph: { root: shownRoot, present: graph.present, stamp: graph.stamp, state: graph.state },
|
|
491
|
+
counts,
|
|
492
|
+
pending,
|
|
493
|
+
lastUpdate: cursor,
|
|
494
|
+
brief,
|
|
495
|
+
next,
|
|
496
|
+
},
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1114,6 +1114,13 @@ export interface RebuildOptions {
|
|
|
1114
1114
|
budgetTokens?: number;
|
|
1115
1115
|
/** Rules only: no model call is made and model work is left pending (`--no-model`). */
|
|
1116
1116
|
noModel?: boolean;
|
|
1117
|
+
/**
|
|
1118
|
+
* Cap on model input tokens per day for this run (`--max-input-tokens`), as on `update`. The day's earlier
|
|
1119
|
+
* calls on the same model count toward it. Default 150,000.
|
|
1120
|
+
*/
|
|
1121
|
+
maxInputTokens?: number;
|
|
1122
|
+
/** Cap on model output tokens per day for this run (`--max-output-tokens`). Default 20,000. */
|
|
1123
|
+
maxOutputTokens?: number;
|
|
1117
1124
|
dryRun: boolean;
|
|
1118
1125
|
}
|
|
1119
1126
|
export interface UpdateOptions {
|
|
@@ -1132,6 +1139,12 @@ export interface UpdateOptions {
|
|
|
1132
1139
|
maxInputTokens?: number;
|
|
1133
1140
|
/** Cap on model output tokens per day for this run (`--max-output-tokens`). Default 20,000. */
|
|
1134
1141
|
maxOutputTokens?: number;
|
|
1142
|
+
/**
|
|
1143
|
+
* Also send the follow-up model work an earlier run left pending (`--follow-up`): profiles, retyped links,
|
|
1144
|
+
* decisions that replace each other, page summaries, digests. Off by default, so an update with nothing
|
|
1145
|
+
* new makes no model call; the summary says how many items are pending.
|
|
1146
|
+
*/
|
|
1147
|
+
followUp?: boolean;
|
|
1135
1148
|
dryRun: boolean;
|
|
1136
1149
|
}
|
|
1137
1150
|
export interface LookupOptions {
|
|
@@ -1154,9 +1167,17 @@ export interface TraverseOptions {
|
|
|
1154
1167
|
depth: number;
|
|
1155
1168
|
asOf?: IsoDate;
|
|
1156
1169
|
}
|
|
1170
|
+
/**
|
|
1171
|
+
* The two shapes of the brief. `map` (the default): what the graph holds, how to look things up, and names
|
|
1172
|
+
* worth looking up, with no facts. `full`: the earlier summary, which prints facts.
|
|
1173
|
+
*/
|
|
1174
|
+
export declare const BRIEF_STYLES: readonly ["map", "full"];
|
|
1175
|
+
export type BriefStyle = (typeof BRIEF_STYLES)[number];
|
|
1157
1176
|
export interface BriefOptions {
|
|
1158
1177
|
/** Print the brief without writing brief.md. */
|
|
1159
1178
|
stdout: boolean;
|
|
1179
|
+
/** Default: `brief_style` in the reader setting, else `map`. */
|
|
1180
|
+
style?: BriefStyle;
|
|
1160
1181
|
}
|
|
1161
1182
|
export interface LintOptions {
|
|
1162
1183
|
/** File a proposal per finding. Default true. */
|
|
@@ -128,4 +128,9 @@ export class MemberIdentityRequiredError extends Error {
|
|
|
128
128
|
this.name = "MemberIdentityRequiredError";
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* The two shapes of the brief. `map` (the default): what the graph holds, how to look things up, and names
|
|
133
|
+
* worth looking up, with no facts. `full`: the earlier summary, which prints facts.
|
|
134
|
+
*/
|
|
135
|
+
export const BRIEF_STYLES = ["map", "full"];
|
|
131
136
|
//# sourceMappingURL=types.js.map
|
|
@@ -93,6 +93,25 @@ export declare class QmdBinaryMissingError extends Error {
|
|
|
93
93
|
readonly spawnDiagnostics?: QmdSpawnDiagnostics;
|
|
94
94
|
constructor(message: string, spawnDiagnostics?: QmdSpawnDiagnostics);
|
|
95
95
|
}
|
|
96
|
+
/** Bounded reason a qmd usability probe failed. Safe to use as a Sentry tag. */
|
|
97
|
+
export type QmdProbeFailureKind = 'spawn-failed' | 'native-bindings' | 'timed-out' | 'unusable';
|
|
98
|
+
/**
|
|
99
|
+
* Neither the bundled qmd nor the qmd on PATH passed the usability probe, so
|
|
100
|
+
* hq used neither (HQ-CLI-J4, HQ-CLI-HH). The message is the user-facing
|
|
101
|
+
* remedy: what happened and the one step that fixes it, with no raw qmd or
|
|
102
|
+
* cmd.exe output. Both probe reasons are kept as bounded kinds (for Sentry
|
|
103
|
+
* tags) and as redacted, length-bounded detail (for local debugging).
|
|
104
|
+
*/
|
|
105
|
+
export declare class QmdUnusableError extends QmdBinaryMissingError {
|
|
106
|
+
readonly bundledBin: string | undefined;
|
|
107
|
+
readonly bundledProbe: QmdProbeFailureKind | 'not-found';
|
|
108
|
+
readonly pathBin: string;
|
|
109
|
+
readonly pathProbe: QmdProbeFailureKind;
|
|
110
|
+
name: string;
|
|
111
|
+
readonly bundledDetail: string;
|
|
112
|
+
readonly pathDetail: string;
|
|
113
|
+
constructor(bundledBin: string | undefined, bundledProbe: QmdProbeFailureKind | 'not-found', bundledDetail: string, pathBin: string, pathProbe: QmdProbeFailureKind, pathDetail: string);
|
|
114
|
+
}
|
|
96
115
|
/**
|
|
97
116
|
* qmd could not be SPAWNED because its working directory does not exist:
|
|
98
117
|
* spawnSync returned ENOENT while chdir-ing into `cwd` (the resolved hq root at
|
|
@@ -121,6 +140,10 @@ export declare class QmdExitError extends Error {
|
|
|
121
140
|
entryPath?: QmdUpdateEntryPath;
|
|
122
141
|
/** Present only when the invoked executable is the bundled qmd. */
|
|
123
142
|
qmdVersion?: string;
|
|
143
|
+
/** `path-fallback` when hq ran the PATH qmd because the bundled copy failed its probe. */
|
|
144
|
+
qmdSource?: 'path-fallback';
|
|
145
|
+
/** Why the bundled qmd was skipped, when {@link qmdSource} is `path-fallback`. */
|
|
146
|
+
bundledProbe?: QmdProbeFailureKind;
|
|
124
147
|
constructor(message: string, args: string[], status: number | null, stdout: string, stderr: string);
|
|
125
148
|
}
|
|
126
149
|
export declare class QmdCollectionMissingError extends QmdExitError {
|
|
@@ -490,7 +513,9 @@ export declare function ensureQmdStoreDir(env?: NodeJS.ProcessEnv, options?: Ens
|
|
|
490
513
|
export declare function __resetQmdProbeStateForTests(): void;
|
|
491
514
|
/** Backwards-compatible string form: probe a bare bin path shell-free (or via
|
|
492
515
|
* the shell plan when it is a Windows `.cmd`/`.bat`). */
|
|
493
|
-
export declare function isUsableQmd(bin: string
|
|
516
|
+
export declare function isUsableQmd(bin: string, options?: {
|
|
517
|
+
keepHome?: boolean;
|
|
518
|
+
}): boolean;
|
|
494
519
|
/**
|
|
495
520
|
* Honest one-line reason a package-local qmd probe failed, for the resolver's
|
|
496
521
|
* probes note. A spawn-level failure — the binary could not be executed at all
|
|
@@ -499,6 +524,13 @@ export declare function isUsableQmd(bin: string): boolean;
|
|
|
499
524
|
* the native-bindings story. Only a genuine better-sqlite3 load failure keeps it.
|
|
500
525
|
*/
|
|
501
526
|
export declare function describeProbeFailure(detail: string): string;
|
|
527
|
+
/** Bounded kind of a probe failure, from the same detail {@link describeProbeFailure} reads. */
|
|
528
|
+
export declare function qmdProbeFailureKind(detail: string): QmdProbeFailureKind;
|
|
529
|
+
/**
|
|
530
|
+
* The bundled qmd's failure kind when `bin` is a PATH copy hq chose because the
|
|
531
|
+
* bundled copy failed its probe; undefined otherwise.
|
|
532
|
+
*/
|
|
533
|
+
export declare function qmdPathFallbackReason(bin: string): QmdProbeFailureKind | undefined;
|
|
502
534
|
/**
|
|
503
535
|
* Derive the better-sqlite3 PACKAGE directory qmd tried to load, from a bindings
|
|
504
536
|
* failure. `bindings` lists every path it tried, each ending in
|