@indigoai-us/hq-cli 5.345.247 → 5.345.250
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 +95 -0
- package/assets/lanes-hooks/hq-lanes-drain.sh +1 -1
- package/contracts/host-canary-release.json +14 -0
- package/dist/command-catalog.generated.d.ts +1198 -0
- package/dist/command-catalog.generated.js +1476 -0
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/core-job-run-native.js +4 -0
- package/dist/commands/core-knowledge-prefs.d.ts +1 -1
- package/dist/commands/core-knowledge-prefs.js +1 -16
- package/dist/commands/core.js +0 -2
- package/dist/commands/daemon.js +21 -0
- package/dist/commands/lanes-hold.js +7 -7
- package/dist/commands/lanes-resume.js +2 -2
- package/dist/commands/lanes-review.js +1 -1
- package/dist/commands/lanes-session-start.d.ts +1 -1
- package/dist/commands/lanes-session-start.js +3 -3
- package/dist/commands/lanes-shared.d.ts +1 -1
- package/dist/commands/lanes.d.ts +2 -2
- package/dist/commands/lanes.js +50 -50
- package/dist/commands/mesh.d.ts +25 -0
- package/dist/commands/mesh.js +48 -8
- package/dist/commands/ontology-graph.d.ts +63 -0
- package/dist/commands/ontology-graph.js +470 -0
- package/dist/commands/sync-core.js +6 -0
- package/dist/fast-scaffold.js +1 -3
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +281 -256
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +48 -1
- package/dist/lanes-monitor-check-argv.d.ts +1 -1
- package/dist/lanes-monitor-check-argv.js +1 -1
- package/dist/lanes-monitor-check-fast.d.ts +1 -1
- package/dist/lanes-monitor-check-fast.js +1 -1
- package/dist/lanes-session-start-argv.d.ts +1 -1
- package/dist/lanes-session-start-argv.js +1 -1
- package/dist/lib/capacity/sign-in.d.ts +1 -1
- package/dist/lib/capacity/sign-in.js +1 -1
- package/dist/lib/daemon/hook-requests-conduct-link.js +2 -2
- package/dist/lib/daemon/installed-cli-restart.d.ts +57 -0
- package/dist/lib/daemon/installed-cli-restart.js +114 -0
- package/dist/lib/daemon/lanes-monitor-state.d.ts +2 -2
- package/dist/lib/daemon/lanes-monitor-state.js +2 -2
- package/dist/lib/daemon/legacy-journal-gate.d.ts +32 -0
- package/dist/lib/daemon/legacy-journal-gate.js +102 -0
- package/dist/lib/daemon/machine-checks.d.ts +7 -0
- package/dist/lib/daemon/machine-checks.js +10 -0
- package/dist/lib/daemon/merge-sections.d.ts +3 -3
- package/dist/lib/daemon/merge-sections.js +7 -7
- package/dist/lib/daemon/remote-control-pools.js +1 -1
- package/dist/lib/daemon/run.d.ts +3 -1
- package/dist/lib/daemon/run.js +49 -6
- package/dist/lib/daemon/state-file.d.ts +1 -1
- package/dist/lib/daemon/state-file.js +1 -1
- 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-snapshot-file.d.ts +2 -0
- package/dist/lib/flag-snapshot-file.js +118 -48
- package/dist/lib/hook-engine/canary-gate.d.ts +57 -3
- package/dist/lib/hook-engine/canary-gate.js +138 -6
- package/dist/lib/hook-engine/coverage.d.ts +82 -13
- package/dist/lib/hook-engine/coverage.js +214 -18
- package/dist/lib/hook-engine/registration-identity.d.ts +5 -0
- package/dist/lib/hook-engine/registration-identity.js +1 -1
- package/dist/lib/hook-engine/resolve.d.ts +23 -0
- package/dist/lib/hook-engine/resolve.js +48 -1
- package/dist/lib/hook-engine/stable-heal.d.ts +87 -0
- package/dist/lib/hook-engine/stable-heal.js +214 -0
- package/dist/lib/hot-channels/graph-context.d.ts +105 -0
- package/dist/lib/hot-channels/graph-context.js +380 -0
- package/dist/lib/hot-channels/signals-pass.js +27 -1
- package/dist/lib/lanes/claude-credential.d.ts +1 -1
- package/dist/lib/lanes/claude-credential.js +1 -1
- package/dist/lib/lanes/delivery-core.d.ts +1 -1
- package/dist/lib/lanes/delivery-core.js +1 -1
- package/dist/lib/lanes/delivery.d.ts +10 -10
- package/dist/lib/lanes/delivery.js +8 -8
- package/dist/lib/lanes/dropbox.d.ts +1 -1
- package/dist/lib/lanes/dropbox.js +1 -1
- package/dist/lib/lanes/hooks-install.js +2 -2
- package/dist/lib/lanes/index.d.ts +1 -1
- package/dist/lib/lanes/index.js +1 -1
- package/dist/lib/lanes/monitor.js +1 -1
- package/dist/lib/lanes/quota-notice.js +1 -1
- package/dist/lib/lanes/quota.d.ts +1 -1
- package/dist/lib/lanes/quota.js +1 -1
- package/dist/lib/lanes/repo-merge-hold.d.ts +2 -2
- package/dist/lib/lanes/repo-merge-hold.js +2 -2
- package/dist/lib/lanes/spawn.d.ts +4 -4
- package/dist/lib/lanes/spawn.js +5 -5
- package/dist/lib/mesh/live/company-flag-refresh.d.ts +61 -0
- package/dist/lib/mesh/live/company-flag-refresh.js +159 -0
- package/dist/lib/mesh/live/company-reporting-gaps.d.ts +61 -0
- package/dist/lib/mesh/live/company-reporting-gaps.js +238 -0
- package/dist/lib/mesh/live/daemon/duplicate-unit.d.ts +156 -0
- package/dist/lib/mesh/live/daemon/duplicate-unit.js +616 -0
- package/dist/lib/mesh/live/daemon/run.d.ts +13 -0
- package/dist/lib/mesh/live/daemon/run.js +35 -2
- package/dist/lib/mesh/live/direct-drain.js +1 -1
- package/dist/lib/mesh/live/emit.d.ts +3 -0
- package/dist/lib/mesh/live/emit.js +32 -9
- package/dist/lib/mesh/live/flush.d.ts +3 -0
- package/dist/lib/mesh/live/flush.js +115 -32
- package/dist/lib/mesh/live/liveness-carry.d.ts +1 -1
- package/dist/lib/mesh/live/liveness-carry.js +1 -1
- package/dist/lib/mesh/live/reporting-privacy.d.ts +119 -3
- package/dist/lib/mesh/live/reporting-privacy.js +235 -11
- package/dist/lib/mesh/live/spool.d.ts +17 -2
- package/dist/lib/mesh/live/spool.js +22 -6
- package/dist/lib/ontology-graph/legacy/coverage.d.ts +67 -0
- package/dist/lib/ontology-graph/legacy/coverage.js +192 -0
- package/dist/lib/ontology-graph/legacy/index.d.ts +199 -0
- package/dist/lib/ontology-graph/legacy/index.js +1150 -0
- package/dist/lib/ontology-graph/legacy/parse.d.ts +49 -0
- package/dist/lib/ontology-graph/legacy/parse.js +126 -0
- package/dist/lib/ontology-graph/legacy/report.d.ts +14 -0
- package/dist/lib/ontology-graph/legacy/report.js +254 -0
- package/dist/lib/ontology-graph/legacy/verb-map.d.ts +35 -0
- package/dist/lib/ontology-graph/legacy/verb-map.js +84 -0
- package/dist/lib/ontology-graph/lint/checks.d.ts +140 -0
- package/dist/lib/ontology-graph/lint/checks.js +717 -0
- package/dist/lib/ontology-graph/lint/coverage.d.ts +106 -0
- package/dist/lib/ontology-graph/lint/coverage.js +241 -0
- package/dist/lib/ontology-graph/lint/daily-job.d.ts +259 -0
- package/dist/lib/ontology-graph/lint/daily-job.js +595 -0
- package/dist/lib/ontology-graph/lint/index.d.ts +65 -0
- package/dist/lib/ontology-graph/lint/index.js +176 -0
- package/dist/lib/ontology-graph/model/files.d.ts +20 -0
- package/dist/lib/ontology-graph/model/files.js +89 -0
- package/dist/lib/ontology-graph/model/index.d.ts +65 -0
- package/dist/lib/ontology-graph/model/index.js +100 -0
- package/dist/lib/ontology-graph/model/pass-tasks.d.ts +156 -0
- package/dist/lib/ontology-graph/model/pass-tasks.js +345 -0
- package/dist/lib/ontology-graph/model/pass.d.ts +109 -0
- package/dist/lib/ontology-graph/model/pass.js +958 -0
- package/dist/lib/ontology-graph/model/runner.d.ts +50 -0
- package/dist/lib/ontology-graph/model/runner.js +160 -0
- package/dist/lib/ontology-graph/model/step.d.ts +197 -0
- package/dist/lib/ontology-graph/model/step.js +526 -0
- package/dist/lib/ontology-graph/model/tasks.d.ts +183 -0
- package/dist/lib/ontology-graph/model/tasks.js +349 -0
- package/dist/lib/ontology-graph/not-implemented.d.ts +5 -0
- package/dist/lib/ontology-graph/not-implemented.js +8 -0
- package/dist/lib/ontology-graph/org/compare.d.ts +28 -0
- package/dist/lib/ontology-graph/org/compare.js +239 -0
- package/dist/lib/ontology-graph/org/derive.d.ts +67 -0
- package/dist/lib/ontology-graph/org/derive.js +359 -0
- package/dist/lib/ontology-graph/org/index.d.ts +102 -0
- package/dist/lib/ontology-graph/org/index.js +630 -0
- package/dist/lib/ontology-graph/org/load.d.ts +31 -0
- package/dist/lib/ontology-graph/org/load.js +476 -0
- package/dist/lib/ontology-graph/org/role.d.ts +38 -0
- package/dist/lib/ontology-graph/org/role.js +268 -0
- package/dist/lib/ontology-graph/org/structure.d.ts +63 -0
- package/dist/lib/ontology-graph/org/structure.js +437 -0
- package/dist/lib/ontology-graph/org/text.d.ts +97 -0
- package/dist/lib/ontology-graph/org/text.js +321 -0
- package/dist/lib/ontology-graph/org/types.d.ts +457 -0
- package/dist/lib/ontology-graph/org/types.js +80 -0
- package/dist/lib/ontology-graph/pages/index.d.ts +64 -0
- package/dist/lib/ontology-graph/pages/index.js +193 -0
- package/dist/lib/ontology-graph/pages/render.d.ts +144 -0
- package/dist/lib/ontology-graph/pages/render.js +688 -0
- package/dist/lib/ontology-graph/proposals/apply.d.ts +109 -0
- package/dist/lib/ontology-graph/proposals/apply.js +468 -0
- package/dist/lib/ontology-graph/proposals/group.d.ts +63 -0
- package/dist/lib/ontology-graph/proposals/group.js +232 -0
- package/dist/lib/ontology-graph/proposals/index.d.ts +173 -0
- package/dist/lib/ontology-graph/proposals/index.js +474 -0
- package/dist/lib/ontology-graph/proposals/model.d.ts +162 -0
- package/dist/lib/ontology-graph/proposals/model.js +196 -0
- package/dist/lib/ontology-graph/proposals/org-chart.d.ts +82 -0
- package/dist/lib/ontology-graph/proposals/org-chart.js +340 -0
- package/dist/lib/ontology-graph/read/brief.d.ts +26 -0
- package/dist/lib/ontology-graph/read/brief.js +254 -0
- package/dist/lib/ontology-graph/read/graph-index.d.ts +76 -0
- package/dist/lib/ontology-graph/read/graph-index.js +198 -0
- package/dist/lib/ontology-graph/read/index.d.ts +59 -0
- package/dist/lib/ontology-graph/read/index.js +803 -0
- package/dist/lib/ontology-graph/read/member.d.ts +7 -0
- package/dist/lib/ontology-graph/read/member.js +34 -0
- package/dist/lib/ontology-graph/read/names.d.ts +49 -0
- package/dist/lib/ontology-graph/read/names.js +297 -0
- package/dist/lib/ontology-graph/read/reader-setting.d.ts +19 -0
- package/dist/lib/ontology-graph/read/reader-setting.js +62 -0
- package/dist/lib/ontology-graph/read/test-graph.d.ts +37 -0
- package/dist/lib/ontology-graph/read/test-graph.js +150 -0
- package/dist/lib/ontology-graph/replay/buffered-store.d.ts +33 -0
- package/dist/lib/ontology-graph/replay/buffered-store.js +50 -0
- package/dist/lib/ontology-graph/replay/config.d.ts +41 -0
- package/dist/lib/ontology-graph/replay/config.js +105 -0
- package/dist/lib/ontology-graph/replay/engine.d.ts +146 -0
- package/dist/lib/ontology-graph/replay/engine.js +1240 -0
- package/dist/lib/ontology-graph/replay/extractors.d.ts +59 -0
- package/dist/lib/ontology-graph/replay/extractors.js +1555 -0
- package/dist/lib/ontology-graph/replay/index.d.ts +91 -0
- package/dist/lib/ontology-graph/replay/index.js +220 -0
- package/dist/lib/ontology-graph/replay/listing-manifest.d.ts +66 -0
- package/dist/lib/ontology-graph/replay/listing-manifest.js +242 -0
- package/dist/lib/ontology-graph/replay/member.d.ts +19 -0
- package/dist/lib/ontology-graph/replay/member.js +65 -0
- package/dist/lib/ontology-graph/replay/mentions.d.ts +58 -0
- package/dist/lib/ontology-graph/replay/mentions.js +239 -0
- package/dist/lib/ontology-graph/replay/readers.d.ts +98 -0
- package/dist/lib/ontology-graph/replay/readers.js +1251 -0
- package/dist/lib/ontology-graph/replay/rules.d.ts +127 -0
- package/dist/lib/ontology-graph/replay/rules.js +374 -0
- package/dist/lib/ontology-graph/replay/scope.d.ts +35 -0
- package/dist/lib/ontology-graph/replay/scope.js +115 -0
- package/dist/lib/ontology-graph/replay/transcripts.d.ts +39 -0
- package/dist/lib/ontology-graph/replay/transcripts.js +224 -0
- package/dist/lib/ontology-graph/replay/util.d.ts +55 -0
- package/dist/lib/ontology-graph/replay/util.js +256 -0
- package/dist/lib/ontology-graph/resolve/entity-index.d.ts +159 -0
- package/dist/lib/ontology-graph/resolve/entity-index.js +652 -0
- package/dist/lib/ontology-graph/resolve/index.d.ts +113 -0
- package/dist/lib/ontology-graph/resolve/index.js +214 -0
- package/dist/lib/ontology-graph/resolve/machine.d.ts +34 -0
- package/dist/lib/ontology-graph/resolve/machine.js +95 -0
- package/dist/lib/ontology-graph/resolve/normalize.d.ts +35 -0
- package/dist/lib/ontology-graph/resolve/normalize.js +124 -0
- package/dist/lib/ontology-graph/resolve/org-chart.d.ts +107 -0
- package/dist/lib/ontology-graph/resolve/org-chart.js +578 -0
- package/dist/lib/ontology-graph/resolve/org-layer.d.ts +78 -0
- package/dist/lib/ontology-graph/resolve/org-layer.js +159 -0
- package/dist/lib/ontology-graph/resolve/org-seed.d.ts +141 -0
- package/dist/lib/ontology-graph/resolve/org-seed.js +631 -0
- package/dist/lib/ontology-graph/resolve/org-sources.d.ts +165 -0
- package/dist/lib/ontology-graph/resolve/org-sources.js +634 -0
- package/dist/lib/ontology-graph/resolve/roster.d.ts +76 -0
- package/dist/lib/ontology-graph/resolve/roster.js +226 -0
- package/dist/lib/ontology-graph/resolve/seed.d.ts +267 -0
- package/dist/lib/ontology-graph/resolve/seed.js +1198 -0
- package/dist/lib/ontology-graph/resolve/upsert.d.ts +58 -0
- package/dist/lib/ontology-graph/resolve/upsert.js +139 -0
- package/dist/lib/ontology-graph/resolve/writer.d.ts +128 -0
- package/dist/lib/ontology-graph/resolve/writer.js +351 -0
- package/dist/lib/ontology-graph/schema/authority.d.ts +107 -0
- package/dist/lib/ontology-graph/schema/authority.js +186 -0
- package/dist/lib/ontology-graph/schema/default-schema.d.ts +10 -0
- package/dist/lib/ontology-graph/schema/default-schema.js +242 -0
- package/dist/lib/ontology-graph/schema/grammar.d.ts +57 -0
- package/dist/lib/ontology-graph/schema/grammar.js +409 -0
- package/dist/lib/ontology-graph/schema/index.d.ts +12 -0
- package/dist/lib/ontology-graph/schema/index.js +10 -0
- package/dist/lib/ontology-graph/schema/validate.d.ts +13 -0
- package/dist/lib/ontology-graph/schema/validate.js +132 -0
- package/dist/lib/ontology-graph/store/files.d.ts +34 -0
- package/dist/lib/ontology-graph/store/files.js +207 -0
- package/dist/lib/ontology-graph/store/fs.d.ts +30 -0
- package/dist/lib/ontology-graph/store/fs.js +101 -0
- package/dist/lib/ontology-graph/store/graph-store.d.ts +14 -0
- package/dist/lib/ontology-graph/store/graph-store.js +520 -0
- package/dist/lib/ontology-graph/store/index.d.ts +18 -0
- package/dist/lib/ontology-graph/store/index.js +15 -0
- package/dist/lib/ontology-graph/store/ingest.d.ts +37 -0
- package/dist/lib/ontology-graph/store/ingest.js +323 -0
- package/dist/lib/ontology-graph/store/paths.d.ts +114 -0
- package/dist/lib/ontology-graph/store/paths.js +232 -0
- package/dist/lib/ontology-graph/types.d.ts +1190 -0
- package/dist/lib/ontology-graph/types.js +131 -0
- package/dist/lib/secret-scan/gitleaks-rules.generated.js +1 -1
- package/dist/lib/sync-core/engine-holds.d.ts +1 -1
- package/dist/lib/sync-core/engine-holds.js +12 -2
- package/dist/lib/sync-core/hand-back.d.ts +2 -1
- package/dist/lib/sync-core/hand-back.js +16 -2
- package/dist/lib/sync-core/legacy-journal-export-child.d.ts +2 -0
- package/dist/lib/sync-core/legacy-journal-export-child.js +24 -0
- package/dist/lib/sync-core/legacy-journal-export.d.ts +39 -0
- package/dist/lib/sync-core/legacy-journal-export.js +241 -0
- package/dist/lib/sync-core/legacy-journal-reader.d.ts +15 -0
- package/dist/lib/sync-core/legacy-journal-reader.js +56 -0
- package/dist/lib/sync-core/reconcile.d.ts +3 -0
- package/dist/lib/sync-core/reconcile.js +43 -3
- package/dist/utils/cli-telemetry.d.ts +1 -0
- package/dist/utils/cli-telemetry.js +6 -3
- package/dist/utils/frontmatter.d.ts +14 -0
- package/dist/utils/frontmatter.js +18 -0
- package/dist/utils/hook-engine-rollup.d.ts +96 -0
- package/dist/utils/hook-engine-rollup.js +725 -0
- package/dist/utils/interactive-caller.js +1 -1
- package/package.json +9 -9
- package/scripts/install-hook-engine.mjs +4 -0
- package/assets/scaffold/core/scripts/knowledge-prefs.sh +0 -55
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hq ontology ...`: the ontology graph (sourced facts, typed edges, replay
|
|
3
|
+
* rebuild). This file only parses flags, resolves the company and graph
|
|
4
|
+
* folder, and prints. Each subcommand calls one entry point of a package under
|
|
5
|
+
* src/lib/ontology-graph/ (see CONTRACT.md there), imported on demand so a
|
|
6
|
+
* read command never loads the replay engine.
|
|
7
|
+
*
|
|
8
|
+
* hq ontology rebuild --company <slug> [--from D --to D] [--resume] [--budget-tokens N] [--no-model] [--dry-run]
|
|
9
|
+
* hq ontology update --company <slug> [--input <path>] [--budget-tokens N] [--no-model]
|
|
10
|
+
* hq ontology lookup <name> [--page] | neighbors <id> [--depth N] | search <text> | traverse <from> [<to>]
|
|
11
|
+
* hq ontology lint [--strict] [--coverage] | proposals list|accept|nope|undo [--set <name>] | brief
|
|
12
|
+
* hq ontology org-chart draft | confirm --from <file> [--yes] | show
|
|
13
|
+
* hq ontology activity [<person>] [--roles] [--compare] [--write] [--view company|member] [--as-of D] [--model]
|
|
14
|
+
* (`hq ontology org observed|compare|person <name>` is the same thing under its first name, kept hidden)
|
|
15
|
+
* hq ontology daily | job install|uninstall|status
|
|
16
|
+
*
|
|
17
|
+
* No identity flag is needed (correction C5). Without `--member` the read
|
|
18
|
+
* commands and the brief take the member signed in to the CLI, and the
|
|
19
|
+
* audience keys are the `facts/@<key>` folders the member's graph holds.
|
|
20
|
+
* `rebuild`, `update`, `daily` and the proposals commands find the signed-in
|
|
21
|
+
* member in their own packages.
|
|
22
|
+
*
|
|
23
|
+
* The graph lives in `companies/<slug>/.hq/ontology-graph/` (a `.hq` folder is
|
|
24
|
+
* ignored by sync and by git), is local to this machine and is never uploaded.
|
|
25
|
+
* `--graph-root` or HQ_ONTOLOGY_GRAPH_ROOT points it elsewhere. `hq core ontology` (the checkpoint steps over
|
|
26
|
+
* the old `ontology/entities/` folder) is a different command and is unchanged.
|
|
27
|
+
*/
|
|
28
|
+
import { InvalidArgumentError } from "commander";
|
|
29
|
+
import { resolveOntologyCompany } from "../lib/checkpoint-ontology/company.js";
|
|
30
|
+
import { GraphCompanyMismatchError, GraphCompanyStampError, GraphCompanyUnclaimedError, assertGraphWritableFor, resolveGraphRoot } from "../lib/ontology-graph/store/paths.js";
|
|
31
|
+
import { resolveLiveRoot } from "../utils/hq-roots.js";
|
|
32
|
+
export class OntologyGraphUsageError extends Error {
|
|
33
|
+
constructor(message) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.name = "OntologyGraphUsageError";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** Environment variables for the member identity (correction C2). */
|
|
39
|
+
export const MEMBER_ENV = "HQ_ONTOLOGY_MEMBER";
|
|
40
|
+
export const MEMBER_AUDIENCE_KEYS_ENV = "HQ_ONTOLOGY_AUDIENCE_KEYS";
|
|
41
|
+
const PERSON_UID = /^[A-Za-z0-9][A-Za-z0-9_-]{2,}$/;
|
|
42
|
+
const AUDIENCE_KEY_HEX = /^[0-9a-f]{16}$/;
|
|
43
|
+
/**
|
|
44
|
+
* The member a run is for: `--member <person uid>` (else HQ_ONTOLOGY_MEMBER)
|
|
45
|
+
* and the audience keys the member holds from repeated `--audience-key` (else
|
|
46
|
+
* the comma-separated HQ_ONTOLOGY_AUDIENCE_KEYS). Undefined when no member is
|
|
47
|
+
* given; readers then read company scope only or refuse.
|
|
48
|
+
*/
|
|
49
|
+
export function resolveMemberIdentity(options, env = process.env) {
|
|
50
|
+
const personUid = (options.member ?? env[MEMBER_ENV] ?? "").trim();
|
|
51
|
+
const rawKeys = options.audienceKey && options.audienceKey.length > 0
|
|
52
|
+
? options.audienceKey
|
|
53
|
+
: (env[MEMBER_AUDIENCE_KEYS_ENV] ?? "").split(",");
|
|
54
|
+
const keys = [...new Set(rawKeys.map((key) => key.trim()).filter((key) => key !== "" && key !== "company"))].sort();
|
|
55
|
+
if (personUid === "") {
|
|
56
|
+
if (keys.length > 0)
|
|
57
|
+
throw new OntologyGraphUsageError("ontology: --audience-key needs --member <person uid>");
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
if (!PERSON_UID.test(personUid))
|
|
61
|
+
throw new OntologyGraphUsageError("ontology: --member is not a person uid");
|
|
62
|
+
for (const key of keys) {
|
|
63
|
+
if (!AUDIENCE_KEY_HEX.test(key))
|
|
64
|
+
throw new OntologyGraphUsageError(`ontology: not an audience key (16 hex): ${key}`);
|
|
65
|
+
}
|
|
66
|
+
return { personUid, audienceKeys: keys };
|
|
67
|
+
}
|
|
68
|
+
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
69
|
+
function isoDateArg(value) {
|
|
70
|
+
if (!ISO_DATE.test(value) || Number.isNaN(Date.parse(`${value}T00:00:00Z`))) {
|
|
71
|
+
throw new InvalidArgumentError("expected a date as YYYY-MM-DD");
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
function positiveIntArg(value) {
|
|
76
|
+
const parsed = Number(value);
|
|
77
|
+
if (!Number.isInteger(parsed) || parsed < 1)
|
|
78
|
+
throw new InvalidArgumentError("expected a positive whole number");
|
|
79
|
+
return parsed;
|
|
80
|
+
}
|
|
81
|
+
/** A token budget. 0 is allowed and means rules only: no model call is made. */
|
|
82
|
+
function budgetArg(value) {
|
|
83
|
+
const parsed = Number(value);
|
|
84
|
+
if (value.trim() === "" || !Number.isInteger(parsed) || parsed < 0)
|
|
85
|
+
throw new InvalidArgumentError("expected a whole number, 0 or more");
|
|
86
|
+
return parsed;
|
|
87
|
+
}
|
|
88
|
+
function capArg(value) {
|
|
89
|
+
const parsed = Number(value);
|
|
90
|
+
if (value.trim() === "" || !Number.isSafeInteger(parsed) || parsed < 1)
|
|
91
|
+
throw new InvalidArgumentError("expected a whole number, 1 or more");
|
|
92
|
+
return parsed;
|
|
93
|
+
}
|
|
94
|
+
function clockArg(value) {
|
|
95
|
+
if (!/^([01]?\d|2[0-3]):[0-5]\d$/.test(value))
|
|
96
|
+
throw new InvalidArgumentError("expected a time as HH:MM");
|
|
97
|
+
return value;
|
|
98
|
+
}
|
|
99
|
+
function depthArg(value) {
|
|
100
|
+
const parsed = Number(value);
|
|
101
|
+
if (!Number.isInteger(parsed) || parsed < 1 || parsed > 3)
|
|
102
|
+
throw new InvalidArgumentError("expected 1, 2 or 3");
|
|
103
|
+
return parsed;
|
|
104
|
+
}
|
|
105
|
+
/** Resolves the company and the graph folder for one invocation. */
|
|
106
|
+
export function resolveGraphContext(options) {
|
|
107
|
+
const hqRoot = resolveLiveRoot({ hqRoot: options.hqRoot });
|
|
108
|
+
const resolution = resolveOntologyCompany(hqRoot, options.company);
|
|
109
|
+
if (!resolution.ok) {
|
|
110
|
+
throw new OntologyGraphUsageError(options.company
|
|
111
|
+
? `ontology: company rejected: ${resolution.reason}`
|
|
112
|
+
: "ontology: --company <slug> is required");
|
|
113
|
+
}
|
|
114
|
+
const companyRoot = resolution.company.dir;
|
|
115
|
+
const member = resolveMemberIdentity(options);
|
|
116
|
+
const graphRoot = resolveGraphRoot({ companyRoot, flag: options.graphRoot });
|
|
117
|
+
// The root can be shared between companies (the flag, the env var): a folder stamped for another company,
|
|
118
|
+
// with a stamp that cannot be trusted, or at a shared root with a graph and no stamp, is refused for reads
|
|
119
|
+
// and writes alike. Nothing is stamped here: only a writer stamps.
|
|
120
|
+
try {
|
|
121
|
+
assertGraphWritableFor(graphRoot, resolution.company.slug, companyRoot);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
if (error instanceof GraphCompanyMismatchError || error instanceof GraphCompanyStampError || error instanceof GraphCompanyUnclaimedError) {
|
|
125
|
+
throw new OntologyGraphUsageError(error.message);
|
|
126
|
+
}
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
hqRoot,
|
|
131
|
+
company: resolution.company.slug,
|
|
132
|
+
companyRoot,
|
|
133
|
+
graphRoot,
|
|
134
|
+
json: Boolean(options.json),
|
|
135
|
+
...(member ? { member } : {}),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function orgViewArg(value) {
|
|
139
|
+
if (value !== "company" && value !== "member")
|
|
140
|
+
throw new InvalidArgumentError("expected company or member");
|
|
141
|
+
return value;
|
|
142
|
+
}
|
|
143
|
+
function scoped(command) {
|
|
144
|
+
return command
|
|
145
|
+
.option("--company <slug>", "company whose graph to use")
|
|
146
|
+
.option("--hq-root <path>", "HQ installation to operate on")
|
|
147
|
+
.option("--graph-root <path>", "graph folder to use instead of companies/<slug>/.hq/ontology-graph (env HQ_ONTOLOGY_GRAPH_ROOT)")
|
|
148
|
+
.option("--member <person uid>", "member the graph is built or read for (env HQ_ONTOLOGY_MEMBER)")
|
|
149
|
+
.option("--audience-key <key>", "audience key the member holds; repeat for more (env HQ_ONTOLOGY_AUDIENCE_KEYS, comma-separated)", (value, previous = []) => [...previous, value])
|
|
150
|
+
.option("--json", "print JSON");
|
|
151
|
+
}
|
|
152
|
+
/** Options given on a subcommand or on any of its parents, nearest first. */
|
|
153
|
+
function mergedOptions(command) {
|
|
154
|
+
const chain = [];
|
|
155
|
+
for (let current = command; current; current = current.parent)
|
|
156
|
+
chain.unshift(current);
|
|
157
|
+
return Object.assign({}, ...chain.map((entry) => entry.opts()));
|
|
158
|
+
}
|
|
159
|
+
export function registerOntologyCommand(program, deps = {}) {
|
|
160
|
+
const write = deps.write ?? ((text) => void process.stdout.write(text));
|
|
161
|
+
const setExitCode = deps.setExitCode ?? ((code) => void (process.exitCode = code));
|
|
162
|
+
const emit = (context, output) => {
|
|
163
|
+
const text = context.json ? JSON.stringify(output.json, null, 2) : output.text;
|
|
164
|
+
write(text.endsWith("\n") ? text : `${text}\n`);
|
|
165
|
+
if (output.exitCode)
|
|
166
|
+
setExitCode(output.exitCode);
|
|
167
|
+
};
|
|
168
|
+
/** Wraps an action: resolve the context, run the entry point, print. */
|
|
169
|
+
const run = (entry, mode = "plain") => async function action(...raw) {
|
|
170
|
+
const args = raw.filter((value) => typeof value === "string");
|
|
171
|
+
const options = mergedOptions(this);
|
|
172
|
+
let context = resolveGraphContext(options);
|
|
173
|
+
if (mode === "read") {
|
|
174
|
+
// No identity flags needed (correction C5): the signed-in member and the keys their graph holds.
|
|
175
|
+
const { resolveReadMember } = await import("../lib/ontology-graph/read/member.js");
|
|
176
|
+
context = (deps.resolveReadMember ?? resolveReadMember)(context);
|
|
177
|
+
}
|
|
178
|
+
emit(context, await entry(context, options, args));
|
|
179
|
+
};
|
|
180
|
+
/** A read command: `run` with the member filled in from the sign-in when no flag names one. */
|
|
181
|
+
const read = (entry) => run(entry, "read");
|
|
182
|
+
const ontology = program
|
|
183
|
+
.command("ontology")
|
|
184
|
+
.description("Ontology graph: sourced facts, typed relationships, rebuilt from the files on this machine (local only)");
|
|
185
|
+
scoped(ontology.command("rebuild"))
|
|
186
|
+
.description("Rebuild the graph: import the old entity files, then replay the vault day by day")
|
|
187
|
+
.option("--from <date>", "first day to replay (YYYY-MM-DD)", isoDateArg)
|
|
188
|
+
.option("--to <date>", "last day to replay (YYYY-MM-DD)", isoDateArg)
|
|
189
|
+
.option("--resume", "continue from the last replayed day")
|
|
190
|
+
.option("--budget-tokens <n>", "stop model calls after this many input tokens; 0 runs rules only", budgetArg)
|
|
191
|
+
.option("--no-model", "rules only: make no model call and leave model work pending")
|
|
192
|
+
.option("--dry-run", "read and count, write nothing")
|
|
193
|
+
.action(run(async (context, options) => {
|
|
194
|
+
const { rebuildCommand } = await import("../lib/ontology-graph/replay/index.js");
|
|
195
|
+
return rebuildCommand(context, {
|
|
196
|
+
...(options.from ? { from: options.from } : {}),
|
|
197
|
+
...(options.to ? { to: options.to } : {}),
|
|
198
|
+
resume: Boolean(options.resume),
|
|
199
|
+
...(options.budgetTokens !== undefined ? { budgetTokens: options.budgetTokens } : {}),
|
|
200
|
+
...(options.model === false ? { noModel: true } : {}),
|
|
201
|
+
dryRun: Boolean(options.dryRun),
|
|
202
|
+
});
|
|
203
|
+
}));
|
|
204
|
+
scoped(ontology.command("update"))
|
|
205
|
+
.description("Replay the days after the last replayed day (the daily job), or one input file")
|
|
206
|
+
.option("--input <path>", "replay this one signal, source or document")
|
|
207
|
+
.option("--budget-tokens <n>", "stop model calls after this many input tokens; 0 runs rules only", budgetArg)
|
|
208
|
+
.option("--no-model", "rules only: make no model call and leave model work pending")
|
|
209
|
+
.option("--full-listing", "list the whole corpus again instead of only new and changed files")
|
|
210
|
+
.option("--max-input-tokens <n>", "model input tokens allowed per day for this run, counting the day's earlier runs (default 150000)", capArg)
|
|
211
|
+
.option("--max-output-tokens <n>", "model output tokens allowed per day for this run (default 20000)", capArg)
|
|
212
|
+
.option("--dry-run", "read and count, write nothing")
|
|
213
|
+
.action(run(async (context, options) => {
|
|
214
|
+
const { updateCommand } = await import("../lib/ontology-graph/replay/index.js");
|
|
215
|
+
return updateCommand(context, {
|
|
216
|
+
...(options.input ? { input: options.input } : {}),
|
|
217
|
+
...(options.budgetTokens !== undefined ? { budgetTokens: options.budgetTokens } : {}),
|
|
218
|
+
...(options.model === false ? { noModel: true } : {}),
|
|
219
|
+
...(options.fullListing ? { fullListing: true } : {}),
|
|
220
|
+
...(options.maxInputTokens !== undefined ? { maxInputTokens: options.maxInputTokens } : {}),
|
|
221
|
+
...(options.maxOutputTokens !== undefined ? { maxOutputTokens: options.maxOutputTokens } : {}),
|
|
222
|
+
dryRun: Boolean(options.dryRun),
|
|
223
|
+
});
|
|
224
|
+
}));
|
|
225
|
+
scoped(ontology.command("lookup"))
|
|
226
|
+
.description("Find an entity by name and print its facts, each with a source and date")
|
|
227
|
+
.argument("<name>", "name, alias, email or <type>/<slug>")
|
|
228
|
+
.option("--as-of <date>", "facts open on this day (YYYY-MM-DD)", isoDateArg)
|
|
229
|
+
.option("--limit <n>", "most relationships to print", positiveIntArg)
|
|
230
|
+
.option("--page", "print the compiled page instead, with lines outside your audiences removed")
|
|
231
|
+
.action(read(async (context, options, [name]) => {
|
|
232
|
+
const { lookupCommand } = await import("../lib/ontology-graph/read/index.js");
|
|
233
|
+
return lookupCommand(context, {
|
|
234
|
+
name,
|
|
235
|
+
...(options.asOf ? { asOf: options.asOf } : {}),
|
|
236
|
+
...(options.limit !== undefined ? { limit: options.limit } : {}),
|
|
237
|
+
...(options.page ? { page: true } : {}),
|
|
238
|
+
});
|
|
239
|
+
}));
|
|
240
|
+
scoped(ontology.command("neighbors"))
|
|
241
|
+
.description("List the entities one relationship away, with the source beside each")
|
|
242
|
+
.argument("<id>", "entity as <type>/<slug>, or a name")
|
|
243
|
+
.option("--verb <verb>", "only this relationship")
|
|
244
|
+
.option("--depth <n>", "how many steps away, 1 to 3 (default 1)", depthArg)
|
|
245
|
+
.option("--limit <n>", "most relationships to print", positiveIntArg)
|
|
246
|
+
.option("--as-of <date>", "relationships open on this day (YYYY-MM-DD)", isoDateArg)
|
|
247
|
+
.action(read(async (context, options, [id]) => {
|
|
248
|
+
const { neighborsCommand } = await import("../lib/ontology-graph/read/index.js");
|
|
249
|
+
return neighborsCommand(context, {
|
|
250
|
+
id,
|
|
251
|
+
...(options.verb ? { verb: options.verb } : {}),
|
|
252
|
+
...(options.depth !== undefined ? { depth: options.depth } : {}),
|
|
253
|
+
...(options.limit !== undefined ? { limit: options.limit } : {}),
|
|
254
|
+
...(options.asOf ? { asOf: options.asOf } : {}),
|
|
255
|
+
});
|
|
256
|
+
}));
|
|
257
|
+
scoped(ontology.command("search"))
|
|
258
|
+
.description("Search the compiled entity pages")
|
|
259
|
+
.argument("<text>", "text to search for")
|
|
260
|
+
.option("--limit <n>", "most results to print", positiveIntArg)
|
|
261
|
+
.action(read(async (context, options, [text]) => {
|
|
262
|
+
const { searchCommand } = await import("../lib/ontology-graph/read/index.js");
|
|
263
|
+
return searchCommand(context, { text, ...(options.limit !== undefined ? { limit: options.limit } : {}) });
|
|
264
|
+
}));
|
|
265
|
+
scoped(ontology.command("traverse"))
|
|
266
|
+
.description("Follow relationships outward from an entity, or find the shortest path between two")
|
|
267
|
+
.argument("<from>", "entity as <type>/<slug>, or a name")
|
|
268
|
+
.argument("[to]", "second entity: print the shortest path from the first to this one")
|
|
269
|
+
.option("--verb <verb>", "relationship to follow; a comma list follows several")
|
|
270
|
+
.option("--depth <n>", "how many steps to follow, 1 to 3 (default 1, or 3 with a second entity)", depthArg)
|
|
271
|
+
.option("--limit <n>", "most steps to print", positiveIntArg)
|
|
272
|
+
.option("--as-of <date>", "relationships open on this day (YYYY-MM-DD)", isoDateArg)
|
|
273
|
+
.action(read(async (context, options, [id, to]) => {
|
|
274
|
+
const { traverseCommand } = await import("../lib/ontology-graph/read/index.js");
|
|
275
|
+
return traverseCommand(context, {
|
|
276
|
+
id,
|
|
277
|
+
// A path between two entities is looked for as far as a walk may go unless --depth says less.
|
|
278
|
+
depth: options.depth ?? (to ? 3 : 1),
|
|
279
|
+
...(to ? { to } : {}),
|
|
280
|
+
...(options.verb ? { verb: options.verb } : {}),
|
|
281
|
+
...(options.limit !== undefined ? { limit: options.limit } : {}),
|
|
282
|
+
...(options.asOf ? { asOf: options.asOf } : {}),
|
|
283
|
+
});
|
|
284
|
+
}));
|
|
285
|
+
scoped(ontology.command("brief"))
|
|
286
|
+
.description("Write brief.md, the short summary every session starts with")
|
|
287
|
+
.option("--stdout", "print the brief without writing it")
|
|
288
|
+
.action(read(async (context, options) => {
|
|
289
|
+
const { briefCommand } = await import("../lib/ontology-graph/read/index.js");
|
|
290
|
+
return briefCommand(context, { stdout: Boolean(options.stdout) });
|
|
291
|
+
}));
|
|
292
|
+
scoped(ontology.command("lint"))
|
|
293
|
+
.description("Check the graph and print a count per kind of problem")
|
|
294
|
+
.option("--no-proposals", "report only; do not file proposals")
|
|
295
|
+
.option("--strict", "exit 1 when an error-class finding exists")
|
|
296
|
+
.option("--coverage", "print the org-coverage measures (a table, or JSON with --json) and write nothing")
|
|
297
|
+
.action(run(async (context, options) => {
|
|
298
|
+
const { lintCommand } = await import("../lib/ontology-graph/lint/index.js");
|
|
299
|
+
return lintCommand(context, {
|
|
300
|
+
fileProposals: options.proposals !== false,
|
|
301
|
+
strict: Boolean(options.strict),
|
|
302
|
+
...(options.coverage ? { coverage: true } : {}),
|
|
303
|
+
});
|
|
304
|
+
}));
|
|
305
|
+
const proposals = ontology.command("proposals").description("Review the changes lint and the replay propose");
|
|
306
|
+
scoped(proposals.command("list"))
|
|
307
|
+
.description("List open proposals")
|
|
308
|
+
.option("--kind <kind>", "only this kind")
|
|
309
|
+
.option("--set <name>", "only this reviewed set, for example \"org chart draft\"")
|
|
310
|
+
.option("--limit <n>", "most proposals to print", positiveIntArg)
|
|
311
|
+
.action(run(async (context, options) => {
|
|
312
|
+
const { proposalsListCommand } = await import("../lib/ontology-graph/proposals/index.js");
|
|
313
|
+
return proposalsListCommand(context, {
|
|
314
|
+
...(options.kind ? { kind: options.kind } : {}),
|
|
315
|
+
...(options.set ? { set: options.set } : {}),
|
|
316
|
+
...(options.limit !== undefined ? { limit: options.limit } : {}),
|
|
317
|
+
});
|
|
318
|
+
}));
|
|
319
|
+
for (const decision of ["accept", "nope"]) {
|
|
320
|
+
scoped(proposals.command(decision))
|
|
321
|
+
.description(decision === "accept"
|
|
322
|
+
? "Accept a proposal and apply its change, or a whole reviewed set with --set"
|
|
323
|
+
: "Decline a proposal, or a whole reviewed set with --set")
|
|
324
|
+
.argument("[id]", "proposal id")
|
|
325
|
+
.option("--set <name>", `${decision} every open proposal in this set`)
|
|
326
|
+
.option("--as <person>", "member making the decision (default: the signed-in member)")
|
|
327
|
+
.action(run(async (context, options, [id]) => {
|
|
328
|
+
const { proposalsDecideCommand } = await import("../lib/ontology-graph/proposals/index.js");
|
|
329
|
+
return proposalsDecideCommand(context, {
|
|
330
|
+
decision,
|
|
331
|
+
...(id ? { id } : {}),
|
|
332
|
+
...(options.set ? { set: options.set } : {}),
|
|
333
|
+
...(options.as ? { as: options.as } : {}),
|
|
334
|
+
});
|
|
335
|
+
}));
|
|
336
|
+
}
|
|
337
|
+
scoped(proposals.command("undo"))
|
|
338
|
+
.description("Undo an accepted proposal: remove the rows it added and reopen the rows it closed")
|
|
339
|
+
.argument("[id]", "proposal id")
|
|
340
|
+
.option("--set <name>", "take back every answer given to this set")
|
|
341
|
+
.option("--as <person>", "member undoing the decision (default: the signed-in member)")
|
|
342
|
+
.action(run(async (context, options, [id]) => {
|
|
343
|
+
const { proposalsUndoCommand } = await import("../lib/ontology-graph/proposals/index.js");
|
|
344
|
+
return proposalsUndoCommand(context, {
|
|
345
|
+
...(id ? { id } : {}),
|
|
346
|
+
...(options.set ? { set: options.set } : {}),
|
|
347
|
+
...(options.as ? { as: options.as } : {}),
|
|
348
|
+
});
|
|
349
|
+
}));
|
|
350
|
+
const orgChart = ontology
|
|
351
|
+
.command("org-chart")
|
|
352
|
+
.description("The org chart a person confirms: role, team and manager per person, above every other source");
|
|
353
|
+
scoped(orgChart.command("draft"))
|
|
354
|
+
.description("Print the current org chart draft as a table to correct")
|
|
355
|
+
.action(run(async (context) => {
|
|
356
|
+
const { orgChartDraftCommand } = await import("../lib/ontology-graph/proposals/org-chart.js");
|
|
357
|
+
return orgChartDraftCommand(context);
|
|
358
|
+
}));
|
|
359
|
+
scoped(orgChart.command("confirm"))
|
|
360
|
+
.description("Show what a corrected table would change in people/org-chart.yaml; write it with --yes")
|
|
361
|
+
.requiredOption("--from <file>", "the corrected draft (markdown table) or a YAML file with a people list")
|
|
362
|
+
.option("--yes", "write the file; without it the change is only shown")
|
|
363
|
+
.option("--replace", "drop people the file does not mention instead of keeping their confirmed lines")
|
|
364
|
+
.option("--as <person>", "person uid of whoever confirms (default: the signed-in member)")
|
|
365
|
+
.action(run(async (context, options) => {
|
|
366
|
+
const { orgChartConfirmCommand } = await import("../lib/ontology-graph/proposals/org-chart.js");
|
|
367
|
+
return orgChartConfirmCommand(context, {
|
|
368
|
+
from: options.from,
|
|
369
|
+
yes: Boolean(options.yes),
|
|
370
|
+
replace: Boolean(options.replace),
|
|
371
|
+
...(options.as ? { as: options.as } : {}),
|
|
372
|
+
});
|
|
373
|
+
}));
|
|
374
|
+
scoped(orgChart.command("show"))
|
|
375
|
+
.description("Print the confirmed org chart")
|
|
376
|
+
.action(run(async (context) => {
|
|
377
|
+
const { orgChartShowCommand } = await import("../lib/ontology-graph/proposals/org-chart.js");
|
|
378
|
+
return orgChartShowCommand(context);
|
|
379
|
+
}));
|
|
380
|
+
// The first name of the activity view. Hidden, and kept so nothing that calls it breaks.
|
|
381
|
+
const org = ontology
|
|
382
|
+
.command("org", { hidden: true })
|
|
383
|
+
.description("Earlier name of `hq ontology activity`. Inferred from behavior, never a confirmed fact");
|
|
384
|
+
/** The options the activity commands share. */
|
|
385
|
+
const orgScoped = (command) => scoped(command)
|
|
386
|
+
.option("--view <view>", "company (company-wide rows only) or member (also the rows only this member may read)", orgViewArg)
|
|
387
|
+
.option("--as-of <date>", "the day the 30, 90 and 365 day windows end on (YYYY-MM-DD; default today)", isoDateArg)
|
|
388
|
+
.option("--roles", "also show the inferred role line and who appears to direct whom")
|
|
389
|
+
.option("--model", "with --roles, phrase each active person's role line with one small model call");
|
|
390
|
+
const orgOptions = (options) => ({
|
|
391
|
+
...(options.view ? { view: options.view } : {}),
|
|
392
|
+
...(options.asOf ? { asOf: options.asOf } : {}),
|
|
393
|
+
// The model only phrases role lines, so it is never called for output that shows none.
|
|
394
|
+
model: Boolean(options.model) && Boolean(options.roles),
|
|
395
|
+
roles: Boolean(options.roles),
|
|
396
|
+
});
|
|
397
|
+
orgScoped(ontology.command("activity"))
|
|
398
|
+
.description("What each person does, from behavior in the graph: kinds of work with counts, what they ship and own, who they work with, change over time. Inferred; stores nothing without --write")
|
|
399
|
+
.argument("[person]", "one person's name or slug; without it, everyone")
|
|
400
|
+
.option("--compare", "print stated beside observed instead: title, manager and listed owner against behavior")
|
|
401
|
+
.option("--write", "also store the derived rows in the graph folder, marked as inferred")
|
|
402
|
+
.action(read(async (context, options, args) => {
|
|
403
|
+
const lib = await import("../lib/ontology-graph/org/index.js");
|
|
404
|
+
if (options.compare) {
|
|
405
|
+
if (args[0] !== undefined)
|
|
406
|
+
throw new OntologyGraphUsageError("--compare covers everyone; leave the person out");
|
|
407
|
+
return lib.orgCompareCommand(context, { ...orgOptions(options), model: Boolean(options.model) });
|
|
408
|
+
}
|
|
409
|
+
if (args[0] !== undefined)
|
|
410
|
+
return lib.orgPersonCommand(context, { ...orgOptions(options), name: args[0], write: options.write === true });
|
|
411
|
+
return lib.orgObservedCommand(context, { ...orgOptions(options), write: options.write === true });
|
|
412
|
+
}));
|
|
413
|
+
orgScoped(org.command("observed"))
|
|
414
|
+
.description("Same as `hq ontology activity`")
|
|
415
|
+
.option("--write", "also store the derived rows in the graph folder, marked as inferred")
|
|
416
|
+
.action(read(async (context, options) => {
|
|
417
|
+
const { orgObservedCommand } = await import("../lib/ontology-graph/org/index.js");
|
|
418
|
+
return orgObservedCommand(context, { ...orgOptions(options), write: options.write === true });
|
|
419
|
+
}));
|
|
420
|
+
orgScoped(org.command("compare"))
|
|
421
|
+
.description("Same as `hq ontology activity --compare`")
|
|
422
|
+
.action(read(async (context, options) => {
|
|
423
|
+
const { orgCompareCommand } = await import("../lib/ontology-graph/org/index.js");
|
|
424
|
+
return orgCompareCommand(context, { ...orgOptions(options), model: Boolean(options.model) });
|
|
425
|
+
}));
|
|
426
|
+
orgScoped(org.command("person"))
|
|
427
|
+
.description("Same as `hq ontology activity <person>`")
|
|
428
|
+
.argument("<name>", "the person's name or slug")
|
|
429
|
+
.action(read(async (context, options, args) => {
|
|
430
|
+
const { orgPersonCommand } = await import("../lib/ontology-graph/org/index.js");
|
|
431
|
+
return orgPersonCommand(context, { ...orgOptions(options), name: args[0] ?? "" });
|
|
432
|
+
}));
|
|
433
|
+
scoped(ontology.command("daily"))
|
|
434
|
+
.description("The daily job: update, lint, brief, once a day unless --force")
|
|
435
|
+
.option("--force", "run even when today's run is already done")
|
|
436
|
+
.option("--budget-tokens <n>", "stop model calls after this many input tokens; 0 runs rules only", budgetArg)
|
|
437
|
+
.action(run(async (context, options) => {
|
|
438
|
+
const { dailyCommand } = await import("../lib/ontology-graph/lint/daily-job.js");
|
|
439
|
+
return dailyCommand(context, {
|
|
440
|
+
force: Boolean(options.force),
|
|
441
|
+
...(options.budgetTokens !== undefined ? { budgetTokens: options.budgetTokens } : {}),
|
|
442
|
+
});
|
|
443
|
+
}));
|
|
444
|
+
const job = ontology.command("job").description("The scheduled daily job on this machine");
|
|
445
|
+
scoped(job.command("install"))
|
|
446
|
+
.description("Schedule the daily job for this company")
|
|
447
|
+
.option("--at <HH:MM>", "local time of day to run", clockArg)
|
|
448
|
+
.option("--budget-tokens <n>", "token budget the scheduled run passes on; 0 runs rules only", budgetArg)
|
|
449
|
+
.action(run(async (context, options) => {
|
|
450
|
+
const { jobInstallCommand } = await import("../lib/ontology-graph/lint/daily-job.js");
|
|
451
|
+
return jobInstallCommand(context, {
|
|
452
|
+
...(options.at ? { at: options.at } : {}),
|
|
453
|
+
...(options.budgetTokens !== undefined ? { budgetTokens: options.budgetTokens } : {}),
|
|
454
|
+
});
|
|
455
|
+
}));
|
|
456
|
+
scoped(job.command("uninstall"))
|
|
457
|
+
.description("Remove the scheduled daily job for this company")
|
|
458
|
+
.action(run(async (context) => {
|
|
459
|
+
const { jobUninstallCommand } = await import("../lib/ontology-graph/lint/daily-job.js");
|
|
460
|
+
return jobUninstallCommand(context);
|
|
461
|
+
}));
|
|
462
|
+
scoped(job.command("status"))
|
|
463
|
+
.description("Say whether the daily job is scheduled and when it last ran")
|
|
464
|
+
.action(run(async (context) => {
|
|
465
|
+
const { jobStatusCommand } = await import("../lib/ontology-graph/lint/daily-job.js");
|
|
466
|
+
return jobStatusCommand(context);
|
|
467
|
+
}));
|
|
468
|
+
return ontology;
|
|
469
|
+
}
|
|
470
|
+
//# sourceMappingURL=ontology-graph.js.map
|
|
@@ -91,6 +91,11 @@ export async function runSyncCoreReconcile(opts, d = defaultDeps()) {
|
|
|
91
91
|
if (!fs.existsSync(tokenFile))
|
|
92
92
|
throw new Error(`the token file ${tokenFile} does not exist`);
|
|
93
93
|
const client = new VaultClient(buildVaultConfig(token));
|
|
94
|
+
const [{ bundledHqCloud, currentHqCloud }, { loadLegacyJournalReader }] = await Promise.all([
|
|
95
|
+
import("../lib/daemon/hq-cloud.js"),
|
|
96
|
+
import("../lib/sync-core/legacy-journal-reader.js"),
|
|
97
|
+
]);
|
|
98
|
+
const journal = await loadLegacyJournalReader([currentHqCloud(daemonPaths(d.home, d.env).root), bundledHqCloud()]);
|
|
94
99
|
const { resolveCanonicalPersonUid } = await import("./cloud.js");
|
|
95
100
|
const result = await reconcileSyncCore({
|
|
96
101
|
home: d.home,
|
|
@@ -105,6 +110,7 @@ export async function runSyncCoreReconcile(opts, d = defaultDeps()) {
|
|
|
105
110
|
}),
|
|
106
111
|
readRolloutFlag: (companyUid) => readCompanyRolloutFlag(companyUid, token, { env: d.env }),
|
|
107
112
|
resolveCompany: (companyUid) => client.entity.get(companyUid),
|
|
113
|
+
...(journal.reader ? { readLegacyJournal: journal.reader } : { legacyJournalUnavailable: journal.reason }),
|
|
108
114
|
machineType: await machineTypeHere(d),
|
|
109
115
|
readDownloadStreams: (companyUid) => readCompanyDownloadStreams(companyUid, token, { env: d.env }),
|
|
110
116
|
ensureBinary: (release) => ensureSyncCoreBinary({ home: d.home, platform: d.platform, arch: d.arch, release, env: d.env }),
|
package/dist/fast-scaffold.js
CHANGED
|
@@ -483,10 +483,8 @@ export const FAST_SCAFFOLD_SCRIPTS = [
|
|
|
483
483
|
exportName: "runKnowledgePrefsFast",
|
|
484
484
|
flagKey: "hq-core-native-fast-route",
|
|
485
485
|
familyFlagKey: "core-native-policy",
|
|
486
|
-
asset: "core/scripts/knowledge-prefs.sh",
|
|
487
486
|
root: "live",
|
|
488
|
-
|
|
489
|
-
shellHqRoot: "live",
|
|
487
|
+
fallbackToCommandGraph: true,
|
|
490
488
|
},
|
|
491
489
|
...["finalize", "post", "open-steps"].map((name) => ({
|
|
492
490
|
name: `handoff ${name}`,
|