@indigoai-us/hq-cli 5.345.247 → 5.345.248

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.
Files changed (239) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/assets/lanes-hooks/hq-lanes-drain.sh +1 -1
  3. package/contracts/host-canary-release.json +14 -0
  4. package/dist/command-catalog.generated.d.ts +1113 -0
  5. package/dist/command-catalog.generated.js +1370 -0
  6. package/dist/command-registration-plan.d.ts +6 -0
  7. package/dist/command-registration-plan.js +1 -0
  8. package/dist/commands/lanes-hold.js +7 -7
  9. package/dist/commands/lanes-resume.js +2 -2
  10. package/dist/commands/lanes-review.js +1 -1
  11. package/dist/commands/lanes-session-start.d.ts +1 -1
  12. package/dist/commands/lanes-session-start.js +3 -3
  13. package/dist/commands/lanes-shared.d.ts +1 -1
  14. package/dist/commands/lanes.d.ts +2 -2
  15. package/dist/commands/lanes.js +50 -50
  16. package/dist/commands/mesh.d.ts +25 -0
  17. package/dist/commands/mesh.js +48 -8
  18. package/dist/commands/ontology-graph.d.ts +62 -0
  19. package/dist/commands/ontology-graph.js +439 -0
  20. package/dist/index.js +1 -1
  21. package/dist/lanes-monitor-check-argv.d.ts +1 -1
  22. package/dist/lanes-monitor-check-argv.js +1 -1
  23. package/dist/lanes-monitor-check-fast.d.ts +1 -1
  24. package/dist/lanes-monitor-check-fast.js +1 -1
  25. package/dist/lanes-session-start-argv.d.ts +1 -1
  26. package/dist/lanes-session-start-argv.js +1 -1
  27. package/dist/lib/capacity/sign-in.d.ts +1 -1
  28. package/dist/lib/capacity/sign-in.js +1 -1
  29. package/dist/lib/daemon/hook-requests-conduct-link.js +2 -2
  30. package/dist/lib/daemon/lanes-monitor-state.d.ts +2 -2
  31. package/dist/lib/daemon/lanes-monitor-state.js +2 -2
  32. package/dist/lib/daemon/merge-sections.d.ts +3 -3
  33. package/dist/lib/daemon/merge-sections.js +7 -7
  34. package/dist/lib/daemon/remote-control-pools.js +1 -1
  35. package/dist/lib/daemon/run.js +1 -1
  36. package/dist/lib/daemon/state-file.d.ts +1 -1
  37. package/dist/lib/daemon/state-file.js +1 -1
  38. package/dist/lib/flag-snapshot-file.d.ts +2 -0
  39. package/dist/lib/flag-snapshot-file.js +118 -48
  40. package/dist/lib/hook-engine/canary-gate.d.ts +57 -3
  41. package/dist/lib/hook-engine/canary-gate.js +138 -6
  42. package/dist/lib/hot-channels/graph-context.d.ts +105 -0
  43. package/dist/lib/hot-channels/graph-context.js +377 -0
  44. package/dist/lib/hot-channels/signals-pass.js +27 -1
  45. package/dist/lib/lanes/claude-credential.d.ts +1 -1
  46. package/dist/lib/lanes/claude-credential.js +1 -1
  47. package/dist/lib/lanes/delivery-core.d.ts +1 -1
  48. package/dist/lib/lanes/delivery-core.js +1 -1
  49. package/dist/lib/lanes/delivery.d.ts +10 -10
  50. package/dist/lib/lanes/delivery.js +8 -8
  51. package/dist/lib/lanes/dropbox.d.ts +1 -1
  52. package/dist/lib/lanes/dropbox.js +1 -1
  53. package/dist/lib/lanes/hooks-install.js +2 -2
  54. package/dist/lib/lanes/index.d.ts +1 -1
  55. package/dist/lib/lanes/index.js +1 -1
  56. package/dist/lib/lanes/monitor.js +1 -1
  57. package/dist/lib/lanes/quota-notice.js +1 -1
  58. package/dist/lib/lanes/quota.d.ts +1 -1
  59. package/dist/lib/lanes/quota.js +1 -1
  60. package/dist/lib/lanes/repo-merge-hold.d.ts +2 -2
  61. package/dist/lib/lanes/repo-merge-hold.js +2 -2
  62. package/dist/lib/lanes/spawn.d.ts +4 -4
  63. package/dist/lib/lanes/spawn.js +5 -5
  64. package/dist/lib/mesh/live/company-flag-refresh.d.ts +61 -0
  65. package/dist/lib/mesh/live/company-flag-refresh.js +159 -0
  66. package/dist/lib/mesh/live/company-reporting-gaps.d.ts +61 -0
  67. package/dist/lib/mesh/live/company-reporting-gaps.js +238 -0
  68. package/dist/lib/mesh/live/daemon/duplicate-unit.d.ts +156 -0
  69. package/dist/lib/mesh/live/daemon/duplicate-unit.js +616 -0
  70. package/dist/lib/mesh/live/daemon/run.d.ts +13 -0
  71. package/dist/lib/mesh/live/daemon/run.js +35 -2
  72. package/dist/lib/mesh/live/direct-drain.js +1 -1
  73. package/dist/lib/mesh/live/emit.d.ts +3 -0
  74. package/dist/lib/mesh/live/emit.js +32 -9
  75. package/dist/lib/mesh/live/flush.d.ts +3 -0
  76. package/dist/lib/mesh/live/flush.js +115 -32
  77. package/dist/lib/mesh/live/liveness-carry.d.ts +1 -1
  78. package/dist/lib/mesh/live/liveness-carry.js +1 -1
  79. package/dist/lib/mesh/live/reporting-privacy.d.ts +119 -3
  80. package/dist/lib/mesh/live/reporting-privacy.js +235 -11
  81. package/dist/lib/mesh/live/spool.d.ts +17 -2
  82. package/dist/lib/mesh/live/spool.js +22 -6
  83. package/dist/lib/ontology-graph/legacy/coverage.d.ts +67 -0
  84. package/dist/lib/ontology-graph/legacy/coverage.js +192 -0
  85. package/dist/lib/ontology-graph/legacy/index.d.ts +199 -0
  86. package/dist/lib/ontology-graph/legacy/index.js +1150 -0
  87. package/dist/lib/ontology-graph/legacy/parse.d.ts +49 -0
  88. package/dist/lib/ontology-graph/legacy/parse.js +126 -0
  89. package/dist/lib/ontology-graph/legacy/report.d.ts +14 -0
  90. package/dist/lib/ontology-graph/legacy/report.js +254 -0
  91. package/dist/lib/ontology-graph/legacy/verb-map.d.ts +35 -0
  92. package/dist/lib/ontology-graph/legacy/verb-map.js +84 -0
  93. package/dist/lib/ontology-graph/lint/checks.d.ts +140 -0
  94. package/dist/lib/ontology-graph/lint/checks.js +717 -0
  95. package/dist/lib/ontology-graph/lint/coverage.d.ts +106 -0
  96. package/dist/lib/ontology-graph/lint/coverage.js +241 -0
  97. package/dist/lib/ontology-graph/lint/daily-job.d.ts +259 -0
  98. package/dist/lib/ontology-graph/lint/daily-job.js +595 -0
  99. package/dist/lib/ontology-graph/lint/index.d.ts +65 -0
  100. package/dist/lib/ontology-graph/lint/index.js +176 -0
  101. package/dist/lib/ontology-graph/model/files.d.ts +20 -0
  102. package/dist/lib/ontology-graph/model/files.js +89 -0
  103. package/dist/lib/ontology-graph/model/index.d.ts +65 -0
  104. package/dist/lib/ontology-graph/model/index.js +100 -0
  105. package/dist/lib/ontology-graph/model/pass-tasks.d.ts +156 -0
  106. package/dist/lib/ontology-graph/model/pass-tasks.js +345 -0
  107. package/dist/lib/ontology-graph/model/pass.d.ts +109 -0
  108. package/dist/lib/ontology-graph/model/pass.js +958 -0
  109. package/dist/lib/ontology-graph/model/runner.d.ts +50 -0
  110. package/dist/lib/ontology-graph/model/runner.js +160 -0
  111. package/dist/lib/ontology-graph/model/step.d.ts +195 -0
  112. package/dist/lib/ontology-graph/model/step.js +523 -0
  113. package/dist/lib/ontology-graph/model/tasks.d.ts +183 -0
  114. package/dist/lib/ontology-graph/model/tasks.js +349 -0
  115. package/dist/lib/ontology-graph/not-implemented.d.ts +5 -0
  116. package/dist/lib/ontology-graph/not-implemented.js +8 -0
  117. package/dist/lib/ontology-graph/org/compare.d.ts +28 -0
  118. package/dist/lib/ontology-graph/org/compare.js +239 -0
  119. package/dist/lib/ontology-graph/org/derive.d.ts +65 -0
  120. package/dist/lib/ontology-graph/org/derive.js +352 -0
  121. package/dist/lib/ontology-graph/org/index.d.ts +73 -0
  122. package/dist/lib/ontology-graph/org/index.js +513 -0
  123. package/dist/lib/ontology-graph/org/load.d.ts +31 -0
  124. package/dist/lib/ontology-graph/org/load.js +476 -0
  125. package/dist/lib/ontology-graph/org/role.d.ts +38 -0
  126. package/dist/lib/ontology-graph/org/role.js +268 -0
  127. package/dist/lib/ontology-graph/org/structure.d.ts +63 -0
  128. package/dist/lib/ontology-graph/org/structure.js +437 -0
  129. package/dist/lib/ontology-graph/org/text.d.ts +95 -0
  130. package/dist/lib/ontology-graph/org/text.js +315 -0
  131. package/dist/lib/ontology-graph/org/types.d.ts +452 -0
  132. package/dist/lib/ontology-graph/org/types.js +80 -0
  133. package/dist/lib/ontology-graph/pages/index.d.ts +64 -0
  134. package/dist/lib/ontology-graph/pages/index.js +193 -0
  135. package/dist/lib/ontology-graph/pages/render.d.ts +142 -0
  136. package/dist/lib/ontology-graph/pages/render.js +682 -0
  137. package/dist/lib/ontology-graph/proposals/apply.d.ts +109 -0
  138. package/dist/lib/ontology-graph/proposals/apply.js +468 -0
  139. package/dist/lib/ontology-graph/proposals/group.d.ts +63 -0
  140. package/dist/lib/ontology-graph/proposals/group.js +232 -0
  141. package/dist/lib/ontology-graph/proposals/index.d.ts +173 -0
  142. package/dist/lib/ontology-graph/proposals/index.js +474 -0
  143. package/dist/lib/ontology-graph/proposals/model.d.ts +162 -0
  144. package/dist/lib/ontology-graph/proposals/model.js +196 -0
  145. package/dist/lib/ontology-graph/proposals/org-chart.d.ts +82 -0
  146. package/dist/lib/ontology-graph/proposals/org-chart.js +340 -0
  147. package/dist/lib/ontology-graph/read/brief.d.ts +26 -0
  148. package/dist/lib/ontology-graph/read/brief.js +251 -0
  149. package/dist/lib/ontology-graph/read/graph-index.d.ts +76 -0
  150. package/dist/lib/ontology-graph/read/graph-index.js +198 -0
  151. package/dist/lib/ontology-graph/read/index.d.ts +59 -0
  152. package/dist/lib/ontology-graph/read/index.js +792 -0
  153. package/dist/lib/ontology-graph/read/member.d.ts +7 -0
  154. package/dist/lib/ontology-graph/read/member.js +34 -0
  155. package/dist/lib/ontology-graph/read/names.d.ts +44 -0
  156. package/dist/lib/ontology-graph/read/names.js +292 -0
  157. package/dist/lib/ontology-graph/read/reader-setting.d.ts +19 -0
  158. package/dist/lib/ontology-graph/read/reader-setting.js +62 -0
  159. package/dist/lib/ontology-graph/read/test-graph.d.ts +37 -0
  160. package/dist/lib/ontology-graph/read/test-graph.js +150 -0
  161. package/dist/lib/ontology-graph/replay/buffered-store.d.ts +33 -0
  162. package/dist/lib/ontology-graph/replay/buffered-store.js +50 -0
  163. package/dist/lib/ontology-graph/replay/config.d.ts +41 -0
  164. package/dist/lib/ontology-graph/replay/config.js +105 -0
  165. package/dist/lib/ontology-graph/replay/engine.d.ts +100 -0
  166. package/dist/lib/ontology-graph/replay/engine.js +1174 -0
  167. package/dist/lib/ontology-graph/replay/extractors.d.ts +59 -0
  168. package/dist/lib/ontology-graph/replay/extractors.js +1555 -0
  169. package/dist/lib/ontology-graph/replay/index.d.ts +90 -0
  170. package/dist/lib/ontology-graph/replay/index.js +220 -0
  171. package/dist/lib/ontology-graph/replay/listing-manifest.d.ts +66 -0
  172. package/dist/lib/ontology-graph/replay/listing-manifest.js +242 -0
  173. package/dist/lib/ontology-graph/replay/member.d.ts +19 -0
  174. package/dist/lib/ontology-graph/replay/member.js +65 -0
  175. package/dist/lib/ontology-graph/replay/mentions.d.ts +58 -0
  176. package/dist/lib/ontology-graph/replay/mentions.js +239 -0
  177. package/dist/lib/ontology-graph/replay/readers.d.ts +98 -0
  178. package/dist/lib/ontology-graph/replay/readers.js +1251 -0
  179. package/dist/lib/ontology-graph/replay/rules.d.ts +127 -0
  180. package/dist/lib/ontology-graph/replay/rules.js +374 -0
  181. package/dist/lib/ontology-graph/replay/scope.d.ts +35 -0
  182. package/dist/lib/ontology-graph/replay/scope.js +115 -0
  183. package/dist/lib/ontology-graph/replay/transcripts.d.ts +39 -0
  184. package/dist/lib/ontology-graph/replay/transcripts.js +224 -0
  185. package/dist/lib/ontology-graph/replay/util.d.ts +55 -0
  186. package/dist/lib/ontology-graph/replay/util.js +256 -0
  187. package/dist/lib/ontology-graph/resolve/entity-index.d.ts +159 -0
  188. package/dist/lib/ontology-graph/resolve/entity-index.js +652 -0
  189. package/dist/lib/ontology-graph/resolve/index.d.ts +113 -0
  190. package/dist/lib/ontology-graph/resolve/index.js +214 -0
  191. package/dist/lib/ontology-graph/resolve/machine.d.ts +34 -0
  192. package/dist/lib/ontology-graph/resolve/machine.js +95 -0
  193. package/dist/lib/ontology-graph/resolve/normalize.d.ts +35 -0
  194. package/dist/lib/ontology-graph/resolve/normalize.js +124 -0
  195. package/dist/lib/ontology-graph/resolve/org-chart.d.ts +107 -0
  196. package/dist/lib/ontology-graph/resolve/org-chart.js +578 -0
  197. package/dist/lib/ontology-graph/resolve/org-layer.d.ts +78 -0
  198. package/dist/lib/ontology-graph/resolve/org-layer.js +159 -0
  199. package/dist/lib/ontology-graph/resolve/org-seed.d.ts +141 -0
  200. package/dist/lib/ontology-graph/resolve/org-seed.js +631 -0
  201. package/dist/lib/ontology-graph/resolve/org-sources.d.ts +165 -0
  202. package/dist/lib/ontology-graph/resolve/org-sources.js +634 -0
  203. package/dist/lib/ontology-graph/resolve/roster.d.ts +76 -0
  204. package/dist/lib/ontology-graph/resolve/roster.js +226 -0
  205. package/dist/lib/ontology-graph/resolve/seed.d.ts +267 -0
  206. package/dist/lib/ontology-graph/resolve/seed.js +1198 -0
  207. package/dist/lib/ontology-graph/resolve/upsert.d.ts +58 -0
  208. package/dist/lib/ontology-graph/resolve/upsert.js +139 -0
  209. package/dist/lib/ontology-graph/resolve/writer.d.ts +128 -0
  210. package/dist/lib/ontology-graph/resolve/writer.js +351 -0
  211. package/dist/lib/ontology-graph/schema/authority.d.ts +73 -0
  212. package/dist/lib/ontology-graph/schema/authority.js +157 -0
  213. package/dist/lib/ontology-graph/schema/default-schema.d.ts +10 -0
  214. package/dist/lib/ontology-graph/schema/default-schema.js +242 -0
  215. package/dist/lib/ontology-graph/schema/grammar.d.ts +57 -0
  216. package/dist/lib/ontology-graph/schema/grammar.js +409 -0
  217. package/dist/lib/ontology-graph/schema/index.d.ts +12 -0
  218. package/dist/lib/ontology-graph/schema/index.js +10 -0
  219. package/dist/lib/ontology-graph/schema/validate.d.ts +13 -0
  220. package/dist/lib/ontology-graph/schema/validate.js +132 -0
  221. package/dist/lib/ontology-graph/store/files.d.ts +34 -0
  222. package/dist/lib/ontology-graph/store/files.js +207 -0
  223. package/dist/lib/ontology-graph/store/fs.d.ts +30 -0
  224. package/dist/lib/ontology-graph/store/fs.js +101 -0
  225. package/dist/lib/ontology-graph/store/graph-store.d.ts +14 -0
  226. package/dist/lib/ontology-graph/store/graph-store.js +520 -0
  227. package/dist/lib/ontology-graph/store/index.d.ts +18 -0
  228. package/dist/lib/ontology-graph/store/index.js +15 -0
  229. package/dist/lib/ontology-graph/store/ingest.d.ts +37 -0
  230. package/dist/lib/ontology-graph/store/ingest.js +323 -0
  231. package/dist/lib/ontology-graph/store/paths.d.ts +114 -0
  232. package/dist/lib/ontology-graph/store/paths.js +232 -0
  233. package/dist/lib/ontology-graph/types.d.ts +1183 -0
  234. package/dist/lib/ontology-graph/types.js +131 -0
  235. package/dist/lib/secret-scan/gitleaks-rules.generated.js +1 -1
  236. package/dist/utils/frontmatter.d.ts +14 -0
  237. package/dist/utils/frontmatter.js +18 -0
  238. package/dist/utils/interactive-caller.js +1 -1
  239. package/package.json +8 -8
@@ -0,0 +1,196 @@
1
+ /**
2
+ * WP-F: what a proposal is, beyond the contract types.
3
+ *
4
+ * `types.ts` fixes `Proposal` and `ProposalAction`. Lint and the resolver need
5
+ * four actions it does not have yet (keep one of two contradicting rows,
6
+ * retype an edge, split an entity, and a merge that remembers the identity it
7
+ * absorbed), so they are declared here as `GraphProposalAction`. On disk they
8
+ * are plain JSON lines in `proposals/open.jsonl`; a reader that only knows the
9
+ * contract type still gets id, kind, entity, rows, summary and evidence.
10
+ *
11
+ * Every action carries what it needs to be applied again on an empty graph,
12
+ * because accepted decisions are replayed at the start of every rebuild.
13
+ */
14
+ import { createHash } from "node:crypto";
15
+ /** The set name as typed or stored: case and spacing do not matter. */
16
+ export function normalizeSetName(name) {
17
+ return name.trim().replace(/^\[|\]$/g, "").trim().toLowerCase().replace(/[\s_-]+/g, " ");
18
+ }
19
+ /**
20
+ * The set a proposal belongs to: its `set` field, else the name in square
21
+ * brackets its summary starts with (`[org chart draft] ...`). Null for a
22
+ * proposal in no set.
23
+ */
24
+ export function proposalSet(proposal) {
25
+ if (typeof proposal.set === "string" && proposal.set.trim() !== "")
26
+ return normalizeSetName(proposal.set);
27
+ const match = /^\s*\[([^\]\n]{2,60})\]/.exec(proposal.summary ?? "");
28
+ return match ? normalizeSetName(match[1]) : null;
29
+ }
30
+ /** The set every grouped name-variant proposal is filed in. */
31
+ export const NAME_VARIANT_SET = "name variants";
32
+ /**
33
+ * True when `proposal` can no longer be applied as filed once the entities in
34
+ * `gone` have been merged away or removed: it would merge from or into one of
35
+ * them, or it addresses rows on one of them.
36
+ */
37
+ export function namesGoneEntity(proposal, gone) {
38
+ if (gone.size === 0)
39
+ return false;
40
+ const action = proposal.action;
41
+ if (action.type === "merge")
42
+ return gone.has(action.from) || gone.has(action.into);
43
+ if (action.type === "merge_group")
44
+ return gone.has(action.into) || action.from.every((ref) => gone.has(ref));
45
+ if ("entity" in action && typeof action.entity === "string" && gone.has(action.entity))
46
+ return true;
47
+ return proposal.entity !== undefined && gone.has(proposal.entity);
48
+ }
49
+ /** The source ref rows and closures written by a decision cite. */
50
+ export function proposalRef(id) {
51
+ return `record:proposal:${id}`;
52
+ }
53
+ /** 12 hex from kind, entity and rows (plus `extra` for merges, splits and retypes), so re-filing never duplicates. */
54
+ export function proposalId(kind, entity, rows, extra = "") {
55
+ const text = [kind, entity ?? "", [...rows].sort().join(","), extra].join("\u0000");
56
+ return createHash("sha256").update(text).digest("hex").slice(0, 12);
57
+ }
58
+ const stamp = (filing) => filing.filedAt ?? new Date().toISOString();
59
+ const unique = (values) => [...new Set(values)];
60
+ /** Merge `from` into `into`: aliases, keys and rows move, `from` is removed. */
61
+ export function mergeProposal(from, into, reason, filing = {}) {
62
+ return {
63
+ id: proposalId("merge", from, [], into),
64
+ kind: "merge",
65
+ entity: from,
66
+ rows: [],
67
+ summary: filing.summary ?? `Merge ${from} into ${into} (${reason})`,
68
+ action: { type: "merge", from, into },
69
+ evidence: unique(filing.evidence ?? []),
70
+ filedAt: stamp(filing),
71
+ };
72
+ }
73
+ /**
74
+ * One proposal for several names of one person: accept merges every entity in
75
+ * `from` into `into`. `where` says what ties them together (the company they
76
+ * are all placed at). The id depends on the members, so the same group is
77
+ * never filed twice and a different group is a different proposal.
78
+ */
79
+ export function mergeGroupProposal(into, from, where, filing = {}) {
80
+ const members = unique([...from].filter((ref) => ref !== into)).sort();
81
+ return {
82
+ id: proposalId("merge", into, [], `group\u0000${where}\u0000${members.join(",")}`),
83
+ kind: "merge",
84
+ entity: into,
85
+ rows: [],
86
+ set: NAME_VARIANT_SET,
87
+ summary: filing.summary ?? `[${NAME_VARIANT_SET}] Merge ${members.join(", ")} into ${into} (${where})`,
88
+ action: { type: "merge_group", into, from: members },
89
+ evidence: unique(filing.evidence ?? []),
90
+ filedAt: stamp(filing),
91
+ ...(filing.replaces && filing.replaces.length > 0 ? { replaces: filing.replaces.map((proposal) => ({ ...proposal })) } : {}),
92
+ };
93
+ }
94
+ /** Split `entity`: the listed rows move to a new entity of the same type. */
95
+ export function splitProposal(entity, into, rows, reason, filing = {}) {
96
+ const ids = rows.map((address) => address.row);
97
+ return {
98
+ id: proposalId("split", entity, ids, into.slug),
99
+ kind: "split",
100
+ entity,
101
+ rows: ids,
102
+ summary: filing.summary ?? `Split ${entity}: move ${ids.length} row${ids.length === 1 ? "" : "s"} to ${into.canonical_name} (${reason})`,
103
+ action: { type: "split", entity, into, rows: rows.map((address) => ({ ...address })) },
104
+ evidence: unique(filing.evidence ?? []),
105
+ filedAt: stamp(filing),
106
+ };
107
+ }
108
+ /** Close one open fact or edge. */
109
+ export function closeFactProposal(entity, audience, row, reason, filing = {}) {
110
+ const kind = filing.kind ?? "close_fact";
111
+ return {
112
+ id: proposalId(kind, entity, [row], audience),
113
+ kind,
114
+ entity,
115
+ audience,
116
+ rows: [row],
117
+ summary: filing.summary ?? `Close row ${row} on ${entity} (${reason})`,
118
+ action: { type: "close_row", entity, audience, row },
119
+ evidence: unique(filing.evidence ?? []),
120
+ filedAt: stamp(filing),
121
+ };
122
+ }
123
+ /** Retype an edge: the old row is closed and a human-origin row with `verb` is written. */
124
+ export function retypeProposal(entity, audience, row, edge, verb, filing = {}) {
125
+ return {
126
+ id: proposalId("retype", entity, [row], `${audience}\u0000${verb}`),
127
+ kind: "retype",
128
+ entity,
129
+ audience,
130
+ rows: [row],
131
+ summary: filing.summary ?? `Retype ${entity} ${edge.verb} -> ${edge.target} as ${verb}`,
132
+ action: { type: "retype_edge", entity, audience, row, edge, verb },
133
+ evidence: unique(filing.evidence ?? [edge.src]),
134
+ filedAt: stamp(filing),
135
+ };
136
+ }
137
+ /** Two or more open rows disagree on a single-valued field or verb: keep `keep`, close the rest. */
138
+ export function contradictionProposal(entity, key, keep, rivals, filing = {}) {
139
+ const rows = [keep.id, ...rivals.map((rival) => rival.id)];
140
+ // Long values (a project summary) are cut in the one-line summary; the action carries the full row.
141
+ const clip = (value) => (value.length > 80 ? `${value.slice(0, 77)}...` : value);
142
+ const say = (row) => (row.kind === "F" ? `"${clip(row.value)}"` : row.target);
143
+ return {
144
+ id: proposalId("contradiction", entity, rows, key),
145
+ kind: "contradiction",
146
+ entity,
147
+ audience: keep.audience,
148
+ rows,
149
+ summary: filing.summary ??
150
+ `${entity} has ${rows.length} open values for ${key}: keep ${say(keep.row)} (by ${keep.row.by}), close ${rivals
151
+ .map((rival) => `${say(rival.row)} (by ${rival.row.by})`)
152
+ .join(", ")}`,
153
+ action: {
154
+ type: "keep_fact",
155
+ entity,
156
+ audience: keep.audience,
157
+ keep: keep.row,
158
+ close: rivals.map((rival) => ({ audience: rival.audience, row: rival.id })),
159
+ },
160
+ evidence: unique(filing.evidence ?? [keep.row.src, ...rivals.map((rival) => rival.row.src)]),
161
+ filedAt: stamp(filing),
162
+ };
163
+ }
164
+ /**
165
+ * Turns the contradictions `applyIngest` returns into proposals (CONTRACT
166
+ * section 4: the caller passes them to `fileProposals`). `lookup` reads a row
167
+ * by id; a contradiction whose rows cannot be read is skipped. So is a
168
+ * challenger dated on or before the human row it loses to: a person's answer
169
+ * is asked about again only when something later disagrees with it.
170
+ */
171
+ export function proposalsFromContradictions(contradictions, lookup, filing = {}) {
172
+ const out = [];
173
+ const seen = new Set();
174
+ for (const item of contradictions) {
175
+ const kept = lookup(item.entity, item.audience, item.kept);
176
+ const challenger = lookup(item.entity, item.audience, item.challenger);
177
+ if (!kept || !challenger)
178
+ continue;
179
+ // A person already answered this key, and the challenger describes a day no later than that answer:
180
+ // it is the claim the person decided against (a rebuild writes it again), not news.
181
+ if (kept.by.startsWith("human:") && challenger.valid.from <= kept.valid.from)
182
+ continue;
183
+ const proposal = contradictionProposal(item.entity, item.key, { audience: item.audience, id: item.kept, row: kept }, [{ audience: item.audience, id: item.challenger, row: challenger }], filing);
184
+ if (seen.has(proposal.id))
185
+ continue;
186
+ seen.add(proposal.id);
187
+ out.push(proposal);
188
+ }
189
+ return out;
190
+ }
191
+ /** `human:<prs id>` for a decider, or null when the id cannot be an origin. */
192
+ export function humanOrigin(personUid) {
193
+ const id = personUid.trim().replace(/^human:/, "");
194
+ return id === "" || /[\s|]/.test(id) ? null : `human:${id}`;
195
+ }
196
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1,82 @@
1
+ import { type OrgChartDraft, type OrgChartRow } from "../resolve/org-chart.js";
2
+ import type { CommandOutput, GraphContext, IsoDate, MemberIdentity } from "../types.js";
3
+ export declare class OrgChartUsageError extends Error {
4
+ constructor(message: string);
5
+ }
6
+ declare const FIELDS: readonly ["role", "team", "manager"];
7
+ type Field = (typeof FIELDS)[number];
8
+ /** Absolute path of the confirmed org chart for the company. */
9
+ export declare function orgChartFile(context: Pick<GraphContext, "companyRoot">): string;
10
+ /** The draft the last rebuild kept, or null. */
11
+ export declare function readOrgChartDraft(context: Pick<GraphContext, "graphRoot">): OrgChartDraft | null;
12
+ /** `hq ontology org-chart draft`. */
13
+ export declare function orgChartDraftCommand(context: GraphContext): Promise<CommandOutput>;
14
+ /**
15
+ * Rows from a corrected file: the draft's markdown table, or YAML with a
16
+ * `people` list (the confirmed file's own format). A cell that is empty or
17
+ * says `none` states nothing.
18
+ */
19
+ export declare function parseOrgChartInput(text: string, fileName?: string): OrgChartRow[];
20
+ export interface OrgChartChange {
21
+ name: string;
22
+ field: Field;
23
+ change: "add" | "change" | "remove";
24
+ before?: string;
25
+ after?: string;
26
+ }
27
+ export interface OrgChartPlan {
28
+ /** The rows the file would hold after the write, sorted by name. */
29
+ rows: OrgChartRow[];
30
+ changes: OrgChartChange[];
31
+ /** Confirmed lines the write leaves as they are. */
32
+ unchanged: number;
33
+ /** People in the confirmed file the input does not mention, kept as they are. */
34
+ kept: string[];
35
+ /** People in the confirmed file the input does not mention, dropped because `--replace` was given. */
36
+ dropped: string[];
37
+ }
38
+ /**
39
+ * What a confirm would do to the confirmed chart. A person the input names
40
+ * takes the input's three cells (an emptied cell removes that line). A person
41
+ * the input does not name is kept, unless `replace` is set.
42
+ */
43
+ export declare function planOrgChartConfirm(existing: readonly OrgChartRow[], input: readonly OrgChartRow[], options?: {
44
+ replace?: boolean;
45
+ }): OrgChartPlan;
46
+ export type ResolveMember = (context: GraphContext) => MemberIdentity | null;
47
+ export interface OrgChartConfirmOptions {
48
+ /** Path of the corrected draft (markdown table) or a YAML file with a `people` list. */
49
+ from: string;
50
+ /** Write the file. Without it the change is only shown. */
51
+ yes?: boolean;
52
+ /** Drop people the input does not mention instead of keeping them. */
53
+ replace?: boolean;
54
+ /** Person uid of whoever confirms. Default: the run's member, HQ_ONTOLOGY_MEMBER, the person signed in. */
55
+ as?: string;
56
+ /** Default: the clock. */
57
+ now?: Date;
58
+ resolveMember?: ResolveMember;
59
+ }
60
+ export interface OrgChartConfirmResult {
61
+ file: string;
62
+ from: string;
63
+ exists: boolean;
64
+ /** True when the confirmed file already says what the input says. */
65
+ identical: boolean;
66
+ written: boolean;
67
+ /** True when the file exists, differs, and `--yes` was not given. */
68
+ refused: boolean;
69
+ confirmedBy: string;
70
+ confirmedOn: IsoDate;
71
+ plan: OrgChartPlan;
72
+ /** Names the last rebuild's roster does not hold. A warning only. */
73
+ notOnRoster: string[];
74
+ }
75
+ /** Plans the confirm and, with `yes`, writes `people/org-chart.yaml`. */
76
+ export declare function confirmOrgChart(context: GraphContext, options: OrgChartConfirmOptions): Promise<OrgChartConfirmResult>;
77
+ /** `hq ontology org-chart confirm --from <file> [--yes] [--replace]`. */
78
+ export declare function orgChartConfirmCommand(context: GraphContext, options: OrgChartConfirmOptions): Promise<CommandOutput>;
79
+ /** `hq ontology org-chart show`. */
80
+ export declare function orgChartShowCommand(context: GraphContext): Promise<CommandOutput>;
81
+ export {};
82
+ //# sourceMappingURL=org-chart.d.ts.map
@@ -0,0 +1,340 @@
1
+ /**
2
+ * WP-F: `hq ontology org-chart draft | confirm | show`.
3
+ *
4
+ * The second door for an org chart line to become a fact (the first is
5
+ * accepting its proposal): a person corrects the draft table and confirms it.
6
+ * The confirmed chart is one file in the company folder,
7
+ * `people/org-chart.yaml`, signed with the person uid of whoever confirmed it.
8
+ * The identity seed reads that file on every rebuild and update and writes
9
+ * each line as origin `human:<prs id>`, confidence 1, source
10
+ * `doc:people/org-chart.yaml`: above every other source, and written again
11
+ * from an empty graph folder with no dependency on `proposals/decided.jsonl`.
12
+ *
13
+ * draft prints the current draft table (kept by the last rebuild in `.state/org-chart-draft.json`)
14
+ * confirm --from <markdown or yaml file> [--yes] [--replace] [--as <prs id>]
15
+ * reads the corrected table, prints what would change, and writes only with --yes
16
+ * show prints the confirmed chart
17
+ *
18
+ * `confirm` never writes without `--yes`. Without it, a file that exists and
19
+ * differs is a refusal (exit 1); otherwise the change is only shown. People
20
+ * the input does not mention keep their confirmed lines, and the output says
21
+ * so; `--replace` drops them, and the output lists every line dropped.
22
+ * Parsing and the file format are WP-C's (`parseOrgChartDraft`,
23
+ * `orgChartYaml`, `readConfirmedOrgChart` in resolve/).
24
+ */
25
+ import * as fs from "node:fs";
26
+ import * as path from "node:path";
27
+ import yaml from "js-yaml";
28
+ import { ORG_CHART_FILE, ORG_CHART_STATE, orgChartYaml, parseOrgChartDraft, readConfirmedOrgChart, renderOrgChartDraft, } from "../resolve/org-chart.js";
29
+ import { atomicWriteFile, graphPath, readTextIfExists, assertGraphWritableFor, claimGraphRootFor } from "../store/index.js";
30
+ export class OrgChartUsageError extends Error {
31
+ constructor(message) {
32
+ super(`ontology org-chart: ${message}`);
33
+ this.name = "OrgChartUsageError";
34
+ }
35
+ }
36
+ const MEMBER_ENV = "HQ_ONTOLOGY_MEMBER";
37
+ const PERSON_UID = /^prs_[0-9A-Za-z]+$/;
38
+ const FIELDS = ["role", "team", "manager"];
39
+ const compareText = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
40
+ const nameKey = (name) => name.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
41
+ const blank = (value) => {
42
+ const text = typeof value === "string" ? value.trim() : "";
43
+ return /^(?:none|n\/a|-|—|\?)?$/i.test(text) ? "" : text;
44
+ };
45
+ /** Absolute path of the confirmed org chart for the company. */
46
+ export function orgChartFile(context) {
47
+ return path.join(context.companyRoot, ...ORG_CHART_FILE.split("/"));
48
+ }
49
+ /** The draft the last rebuild kept, or null. */
50
+ export function readOrgChartDraft(context) {
51
+ const text = readTextIfExists(graphPath(context.graphRoot, ORG_CHART_STATE));
52
+ if (text === null)
53
+ return null;
54
+ try {
55
+ const parsed = JSON.parse(text);
56
+ return Array.isArray(parsed.lines) ? parsed : null;
57
+ }
58
+ catch {
59
+ return null;
60
+ }
61
+ }
62
+ /** `hq ontology org-chart draft`. */
63
+ export async function orgChartDraftCommand(context) {
64
+ const draft = readOrgChartDraft(context);
65
+ if (!draft) {
66
+ return {
67
+ text: `No org chart draft in ${context.graphRoot}. A rebuild writes one: hq ontology rebuild --company ${context.company}`,
68
+ json: { draft: null },
69
+ exitCode: 1,
70
+ };
71
+ }
72
+ const intro = [
73
+ "To confirm: save this table to a file, correct the Proposed role, Team and Manager cells, then run",
74
+ `\`hq ontology org-chart confirm --company ${context.company} --from <file>\` to see the change and add \`--yes\` to write it.`,
75
+ ];
76
+ return { text: renderOrgChartDraft(draft, { intro }), json: { draft } };
77
+ }
78
+ /**
79
+ * Rows from a corrected file: the draft's markdown table, or YAML with a
80
+ * `people` list (the confirmed file's own format). A cell that is empty or
81
+ * says `none` states nothing.
82
+ */
83
+ export function parseOrgChartInput(text, fileName = "") {
84
+ const looksYaml = /\.ya?ml$/i.test(fileName) || (!/^\s*\|/m.test(text) && /^people\s*:/m.test(text));
85
+ let rows;
86
+ if (looksYaml) {
87
+ let loaded;
88
+ try {
89
+ loaded = yaml.load(text, { schema: yaml.CORE_SCHEMA });
90
+ }
91
+ catch (error) {
92
+ throw new OrgChartUsageError(`the file is not valid YAML: ${error instanceof Error ? error.message.split("\n")[0] : String(error)}`);
93
+ }
94
+ const people = loaded && typeof loaded === "object" && !Array.isArray(loaded) ? loaded.people : loaded;
95
+ if (!Array.isArray(people))
96
+ throw new OrgChartUsageError("the YAML file needs a `people` list (name, role, team, manager)");
97
+ rows = people
98
+ .map((entry) => (entry && typeof entry === "object" ? entry : {}))
99
+ .map((entry) => ({ name: typeof entry.name === "string" ? entry.name.trim() : "", role: blank(entry.role), team: blank(entry.team), manager: blank(entry.manager) }))
100
+ .filter((row) => row.name !== "");
101
+ }
102
+ else {
103
+ rows = parseOrgChartDraft(text);
104
+ }
105
+ // One row per person: a name given twice is a mistake in the file, not two statements.
106
+ const seen = new Map();
107
+ for (const row of rows) {
108
+ const key = nameKey(row.name);
109
+ if (seen.has(key))
110
+ throw new OrgChartUsageError(`"${row.name}" is in the file twice`);
111
+ seen.set(key, row.name);
112
+ }
113
+ return rows;
114
+ }
115
+ /**
116
+ * What a confirm would do to the confirmed chart. A person the input names
117
+ * takes the input's three cells (an emptied cell removes that line). A person
118
+ * the input does not name is kept, unless `replace` is set.
119
+ */
120
+ export function planOrgChartConfirm(existing, input, options = {}) {
121
+ const before = new Map(existing.map((row) => [nameKey(row.name), row]));
122
+ const named = new Set(input.map((row) => nameKey(row.name)));
123
+ const plan = { rows: [], changes: [], unchanged: 0, kept: [], dropped: [] };
124
+ for (const row of input) {
125
+ const was = before.get(nameKey(row.name));
126
+ for (const field of FIELDS) {
127
+ const old = was?.[field] ?? "";
128
+ const next = row[field];
129
+ if (old === next) {
130
+ if (next !== "")
131
+ plan.unchanged += 1;
132
+ }
133
+ else if (old === "")
134
+ plan.changes.push({ name: row.name, field, change: "add", after: next });
135
+ else if (next === "")
136
+ plan.changes.push({ name: row.name, field, change: "remove", before: old });
137
+ else
138
+ plan.changes.push({ name: row.name, field, change: "change", before: old, after: next });
139
+ }
140
+ if (FIELDS.some((field) => row[field] !== ""))
141
+ plan.rows.push({ ...row });
142
+ }
143
+ for (const row of existing) {
144
+ if (named.has(nameKey(row.name)))
145
+ continue;
146
+ if (options.replace) {
147
+ plan.dropped.push(row.name);
148
+ for (const field of FIELDS)
149
+ if (row[field] !== "")
150
+ plan.changes.push({ name: row.name, field, change: "remove", before: row[field] });
151
+ }
152
+ else {
153
+ plan.kept.push(row.name);
154
+ plan.unchanged += FIELDS.filter((field) => row[field] !== "").length;
155
+ plan.rows.push({ ...row });
156
+ }
157
+ }
158
+ plan.rows.sort((a, b) => compareText(nameKey(a.name), nameKey(b.name)));
159
+ plan.kept.sort(compareText);
160
+ plan.dropped.sort(compareText);
161
+ return plan;
162
+ }
163
+ function renderChange(change) {
164
+ if (change.change === "add")
165
+ return `+ ${change.name}: ${change.field} "${change.after}"`;
166
+ if (change.change === "remove")
167
+ return `- ${change.name}: ${change.field} "${change.before}"`;
168
+ return `~ ${change.name}: ${change.field} "${change.before}" -> "${change.after}"`;
169
+ }
170
+ /** Names the roster kept by the last rebuild does not hold: the seed would report them unresolved. */
171
+ function unknownNames(context, rows) {
172
+ const text = readTextIfExists(graphPath(context.graphRoot, ".state/roster.json"));
173
+ if (text === null)
174
+ return [];
175
+ let members;
176
+ try {
177
+ const parsed = JSON.parse(text);
178
+ members = Array.isArray(parsed.members) ? parsed.members : [];
179
+ }
180
+ catch {
181
+ return [];
182
+ }
183
+ const full = new Set();
184
+ const first = new Map();
185
+ for (const member of members) {
186
+ if (typeof member.name !== "string")
187
+ continue;
188
+ const key = nameKey(member.name);
189
+ full.add(key);
190
+ const word = key.split(" ")[0] ?? "";
191
+ first.set(word, (first.get(word) ?? 0) + 1);
192
+ }
193
+ if (full.size === 0)
194
+ return [];
195
+ const known = (name) => {
196
+ const key = nameKey(name);
197
+ return full.has(key) || (!key.includes(" ") && first.get(key) === 1);
198
+ };
199
+ const out = new Set();
200
+ for (const row of rows) {
201
+ if (!known(row.name))
202
+ out.add(row.name);
203
+ if (row.manager !== "" && !known(row.manager))
204
+ out.add(`${row.manager} (manager of ${row.name})`);
205
+ }
206
+ return [...out].sort(compareText);
207
+ }
208
+ async function confirmer(context, options) {
209
+ let given = (options.as ?? context.member?.personUid ?? process.env[MEMBER_ENV] ?? "").trim();
210
+ if (given === "") {
211
+ const resolve = options.resolveMember ?? (await import("../replay/member.js")).resolveSignedInMember;
212
+ given = resolve(context)?.personUid ?? "";
213
+ }
214
+ given = given.replace(/^human:/, "");
215
+ if (given === "")
216
+ throw new OrgChartUsageError("who is confirming? Sign in (hq login), or pass --as <prs id>");
217
+ // The seed reads the file only when it is signed with a person uid; anything else would state nothing.
218
+ if (!PERSON_UID.test(given))
219
+ throw new OrgChartUsageError(`"${given}" is not a person uid (prs_...); the confirmed chart must be signed with one`);
220
+ return given;
221
+ }
222
+ /** Plans the confirm and, with `yes`, writes `people/org-chart.yaml`. */
223
+ export async function confirmOrgChart(context, options) {
224
+ const from = path.resolve(options.from);
225
+ let text;
226
+ try {
227
+ text = fs.readFileSync(from, "utf8");
228
+ }
229
+ catch {
230
+ throw new OrgChartUsageError(`cannot read ${from}`);
231
+ }
232
+ const input = parseOrgChartInput(text, from);
233
+ if (input.length === 0) {
234
+ throw new OrgChartUsageError(`no org chart rows in ${from}: it needs the draft's table (| Person | Proposed role | Team | Manager | ...) or a YAML \`people\` list`);
235
+ }
236
+ const file = orgChartFile(context);
237
+ const exists = fs.existsSync(file);
238
+ const existing = readConfirmedOrgChart(context.companyRoot);
239
+ if (exists && !existing) {
240
+ throw new OrgChartUsageError(`${file} exists and is not a signed org chart (it needs confirmed_by: prs_... and confirmed_on). Fix or move it first; it is not overwritten`);
241
+ }
242
+ const plan = planOrgChartConfirm(existing?.people ?? [], input, { ...(options.replace ? { replace: true } : {}) });
243
+ const confirmedBy = await confirmer(context, options);
244
+ const confirmedOn = (options.now ?? new Date()).toISOString().slice(0, 10);
245
+ const identical = exists && plan.changes.length === 0;
246
+ const result = {
247
+ file,
248
+ from,
249
+ exists,
250
+ identical,
251
+ written: false,
252
+ refused: false,
253
+ confirmedBy,
254
+ confirmedOn,
255
+ plan,
256
+ notOnRoster: unknownNames(context, plan.rows),
257
+ };
258
+ if (identical)
259
+ return result;
260
+ if (!options.yes) {
261
+ result.refused = exists;
262
+ return result;
263
+ }
264
+ // The confirmed chart is what the company's graph is built from. A graph folder that is another company's
265
+ // (a shared root) is refused before anything is written; one that is there is this company's from now on.
266
+ assertGraphWritableFor(context.graphRoot, context.company, context.companyRoot);
267
+ if (fs.existsSync(context.graphRoot))
268
+ claimGraphRootFor(context.graphRoot, context.company, context.companyRoot);
269
+ atomicWriteFile(file, orgChartYaml(plan.rows, confirmedBy, confirmedOn));
270
+ result.written = true;
271
+ return result;
272
+ }
273
+ /** `hq ontology org-chart confirm --from <file> [--yes] [--replace]`. */
274
+ export async function orgChartConfirmCommand(context, options) {
275
+ const result = await confirmOrgChart(context, options);
276
+ const { plan } = result;
277
+ const count = (kind) => plan.changes.filter((change) => change.change === kind).length;
278
+ const lines = [
279
+ `Org chart for ${context.company}: ${result.file}`,
280
+ `From ${result.from}: ${plan.rows.length} people, ${plan.rows.reduce((sum, row) => sum + FIELDS.filter((field) => row[field] !== "").length, 0)} lines.`,
281
+ result.exists ? "The confirmed file exists." : "There is no confirmed file yet.",
282
+ "",
283
+ ];
284
+ if (plan.changes.length === 0)
285
+ lines.push("No change.");
286
+ else {
287
+ lines.push(`Changes: ${count("add")} added, ${count("change")} changed, ${count("remove")} removed, ${plan.unchanged} unchanged.`);
288
+ for (const change of plan.changes)
289
+ lines.push(` ${renderChange(change)}`);
290
+ }
291
+ if (plan.kept.length > 0) {
292
+ lines.push("", `Kept as they are, because the input does not mention them (${plan.kept.length}): ${plan.kept.join(", ")}.`, "To drop them instead, add --replace.");
293
+ }
294
+ if (plan.dropped.length > 0) {
295
+ lines.push("", `Dropped, because the input does not mention them and --replace was given (${plan.dropped.length}): ${plan.dropped.join(", ")}.`);
296
+ }
297
+ if (result.notOnRoster.length > 0) {
298
+ lines.push("", `Not on the roster the last rebuild kept (${result.notOnRoster.length}); the rebuild will report these as unresolved: ${result.notOnRoster.join("; ")}.`);
299
+ }
300
+ lines.push("");
301
+ if (result.written) {
302
+ lines.push(`Written, signed ${result.confirmedBy} on ${result.confirmedOn}.`, `Each line becomes your own statement (origin human, confidence 1) on the next run: hq ontology rebuild --company ${context.company}`);
303
+ }
304
+ else if (result.identical) {
305
+ lines.push("The confirmed file already says this. Nothing written.");
306
+ }
307
+ else if (result.refused) {
308
+ lines.push(`Refused: ${result.file} exists and differs. Nothing written. Read the changes above, then add --yes to write them.`);
309
+ }
310
+ else {
311
+ lines.push("Nothing written. Add --yes to write the file.");
312
+ }
313
+ return { text: lines.join("\n"), json: result, ...(result.refused ? { exitCode: 1 } : {}) };
314
+ }
315
+ /** `hq ontology org-chart show`. */
316
+ export async function orgChartShowCommand(context) {
317
+ const file = orgChartFile(context);
318
+ const confirmed = readConfirmedOrgChart(context.companyRoot);
319
+ if (!confirmed) {
320
+ const exists = fs.existsSync(file);
321
+ return {
322
+ text: exists
323
+ ? `${file} exists and is not signed (it needs confirmed_by: prs_... and confirmed_on: YYYY-MM-DD). It states nothing.`
324
+ : `No confirmed org chart for ${context.company} (${file} does not exist). Start from the draft: hq ontology org-chart draft --company ${context.company}`,
325
+ json: { file, exists, confirmed: null },
326
+ };
327
+ }
328
+ const rows = [...confirmed.people].sort((a, b) => compareText(nameKey(a.name), nameKey(b.name)));
329
+ const cell = (value) => value.replace(/\|/g, "/");
330
+ const lines = [
331
+ `Confirmed org chart for ${context.company}: ${file}`,
332
+ `Confirmed by ${confirmed.confirmedBy} on ${confirmed.confirmedOn}. ${rows.length} people. Every line is written to the graph as origin human, confidence 1, on each rebuild and update.`,
333
+ "",
334
+ "| Person | Role | Team | Manager |",
335
+ "| --- | --- | --- | --- |",
336
+ ...rows.map((row) => `| ${cell(row.name)} | ${cell(row.role)} | ${cell(row.team)} | ${cell(row.manager)} |`),
337
+ ];
338
+ return { text: lines.join("\n"), json: { file, exists: true, confirmed: { ...confirmed, people: rows } } };
339
+ }
340
+ //# sourceMappingURL=org-chart.js.map
@@ -0,0 +1,26 @@
1
+ import { type AudienceKey, type BriefOptions, type CommandOutput, type GraphContext, type GraphStore } from "../types.js";
2
+ export declare const BRIEF_MAX_TOKENS = 1500;
3
+ export declare const BRIEF_MAX_PROJECTS = 15;
4
+ export declare const BRIEF_MAX_CUSTOMERS = 8;
5
+ export declare const BRIEF_MAX_CHANGES = 12;
6
+ export declare const BRIEF_WINDOW_DAYS = 7;
7
+ /**
8
+ * Upper estimate of the token count. English prose runs near four characters
9
+ * a token; ids, dates and slugs run shorter, so three is used.
10
+ */
11
+ export declare function estimateTokens(text: string): number;
12
+ export interface BriefExtras {
13
+ /** The clock. Default: now. */
14
+ now?: Date;
15
+ /** The member's own entity, `person/<slug>`. Default: the reader setting, then `context.member`. */
16
+ memberEntity?: string;
17
+ audiences?: readonly AudienceKey[];
18
+ store?: GraphStore;
19
+ /** Token cap. Default `BRIEF_MAX_TOKENS`; a caller may only lower it. */
20
+ maxTokens?: number;
21
+ }
22
+ /** Builds the brief text. Pure apart from reads through the store. */
23
+ export declare function buildBrief(context: GraphContext, extras?: BriefExtras): string;
24
+ /** `hq ontology brief`: writes brief.md (1,500 tokens max). */
25
+ export declare function briefCommand(context: GraphContext, options: BriefOptions & BriefExtras): Promise<CommandOutput>;
26
+ //# sourceMappingURL=brief.d.ts.map