@indigoai-us/hq-cli 5.345.246 → 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.
- package/CHANGELOG.md +63 -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 +1116 -3
- package/dist/command-catalog.generated.js +1373 -3
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/install-global.d.ts +15 -0
- package/dist/commands/install-global.js +98 -4
- 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/mcp-registration.d.ts +17 -0
- package/dist/commands/mcp-registration.js +119 -0
- package/dist/commands/mesh.d.ts +25 -0
- package/dist/commands/mesh.js +48 -8
- package/dist/commands/ontology-graph.d.ts +62 -0
- package/dist/commands/ontology-graph.js +439 -0
- package/dist/commands/pkg-install.js +1 -1
- package/dist/commands/reindex.js +1 -1
- package/dist/index.js +1 -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/lanes-monitor-state.d.ts +2 -2
- package/dist/lib/daemon/lanes-monitor-state.js +2 -2
- 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.js +1 -1
- package/dist/lib/daemon/state-file.d.ts +1 -1
- package/dist/lib/daemon/state-file.js +1 -1
- package/dist/lib/doctor/checks/antigravity-wiring.d.ts +21 -0
- package/dist/lib/doctor/checks/antigravity-wiring.js +75 -0
- package/dist/lib/doctor/checks/anywhere.js +30 -0
- package/dist/lib/doctor/checks/runtime-probe.js +13 -0
- package/dist/lib/doctor/platform.d.ts +1 -1
- package/dist/lib/doctor/platform.js +5 -0
- package/dist/lib/doctor/registry.js +3 -0
- 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 +91 -0
- package/dist/lib/hook-engine/coverage.js +184 -0
- package/dist/lib/hot-channels/graph-context.d.ts +105 -0
- package/dist/lib/hot-channels/graph-context.js +377 -0
- package/dist/lib/hot-channels/signals-pass.js +27 -1
- package/dist/lib/install/antigravity-targets.d.ts +39 -0
- package/dist/lib/install/antigravity-targets.js +122 -0
- 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 +195 -0
- package/dist/lib/ontology-graph/model/step.js +523 -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 +65 -0
- package/dist/lib/ontology-graph/org/derive.js +352 -0
- package/dist/lib/ontology-graph/org/index.d.ts +73 -0
- package/dist/lib/ontology-graph/org/index.js +513 -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 +95 -0
- package/dist/lib/ontology-graph/org/text.js +315 -0
- package/dist/lib/ontology-graph/org/types.d.ts +452 -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 +142 -0
- package/dist/lib/ontology-graph/pages/render.js +682 -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 +251 -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 +792 -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 +44 -0
- package/dist/lib/ontology-graph/read/names.js +292 -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 +100 -0
- package/dist/lib/ontology-graph/replay/engine.js +1174 -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 +90 -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 +73 -0
- package/dist/lib/ontology-graph/schema/authority.js +157 -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 +1183 -0
- package/dist/lib/ontology-graph/types.js +131 -0
- package/dist/lib/secret-scan/gitleaks-rules.generated.js +1 -1
- package/dist/utils/frontmatter.d.ts +14 -0
- package/dist/utils/frontmatter.js +18 -0
- package/dist/utils/interactive-caller.js +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WP-B round 2: rules shared by the input readers and the rule extractors
|
|
3
|
+
* (corrections C7 and C8). Pure text and date functions. Nothing here reads a
|
|
4
|
+
* file or names a company.
|
|
5
|
+
*/
|
|
6
|
+
import type { AudienceKey, IsoDate } from "../types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Source classes whose files the company publishes to every member as a
|
|
9
|
+
* record: a class in this list is its own audience statement, so its rows are
|
|
10
|
+
* company-wide. Every other class needs an audience key on the source. A
|
|
11
|
+
* source with none is filed under the member's local audience, never under
|
|
12
|
+
* `company`: conversations (meetings, Slack, the signals made from them, the
|
|
13
|
+
* commitments and action items heard in them), session logs and the
|
|
14
|
+
* projections that exist only on the member's machine (CRM, KPIs).
|
|
15
|
+
*/
|
|
16
|
+
export declare const COMPANY_PUBLISHED_CLASSES: ReadonlySet<string>;
|
|
17
|
+
export declare function isCompanyPublishedClass(cls: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The audience an input's rows are filed under (correction C7). An audience
|
|
20
|
+
* key on the source is kept. `company` is kept only for a class the company
|
|
21
|
+
* publishes as a record; for every other class it means "no audience key was
|
|
22
|
+
* found", and the rows go to the member's local audience. Null: nothing may
|
|
23
|
+
* be written (no audience, or no member to hold the local rows).
|
|
24
|
+
*/
|
|
25
|
+
export declare function audienceForInput(cls: string, audience: AudienceKey | null | undefined, localKey: AudienceKey | null): AudienceKey | null;
|
|
26
|
+
/**
|
|
27
|
+
* Company slugs a text names as a scope: a `companies/<slug>` path, a
|
|
28
|
+
* `--company <slug>` flag, `bind company <slug>`, or a `company: <slug>` tag.
|
|
29
|
+
* Lower case, distinct, sorted. A plain word is never a scope: company slugs
|
|
30
|
+
* are common words, so a word match would be wrong in both directions.
|
|
31
|
+
* `pathsOnly` keeps to `companies/<slug>` paths, for text that is prose.
|
|
32
|
+
*/
|
|
33
|
+
export declare function companyScopesIn(text: string, options?: {
|
|
34
|
+
pathsOnly?: boolean;
|
|
35
|
+
}): string[];
|
|
36
|
+
/** True when any named scope is a company other than `company`. */
|
|
37
|
+
export declare function namesAnotherCompany(scopes: readonly string[], company: string): boolean;
|
|
38
|
+
/** A first prompt that says nothing about the work: a brief pointer, a sub-agent preamble, a bare go-ahead. */
|
|
39
|
+
export declare function isBoilerplatePrompt(text: string): boolean;
|
|
40
|
+
/** A title or summary that is one of the lifecycle phrases, whatever its length. An empty text is not. */
|
|
41
|
+
export declare function isLifecycleText(text: string): boolean;
|
|
42
|
+
/** The first prompt that describes work, or null when the session has none. */
|
|
43
|
+
export declare function firstRealPrompt(prompts: readonly string[]): string | null;
|
|
44
|
+
export interface PathEvidence {
|
|
45
|
+
/** Repo folder names (`repos/private/<name>`, `repos/public/<name>`). */
|
|
46
|
+
repos: string[];
|
|
47
|
+
/** Worktree folder names (`workspace/worktrees/<name>`), each a hint for a repo. */
|
|
48
|
+
worktrees: string[];
|
|
49
|
+
/** Project folder names under `companies/<company>/projects/`. */
|
|
50
|
+
projects: string[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Work a session touched, read from paths only: its working directories, the
|
|
54
|
+
* files it changed and the paths its prompts name. Words are not evidence.
|
|
55
|
+
*/
|
|
56
|
+
export declare function pathEvidence(texts: readonly string[], company: string): PathEvidence;
|
|
57
|
+
/** `app-web-auth-fix` could be a worktree of `app-web-auth`, `app-web` or `app`: longest first. */
|
|
58
|
+
export declare function worktreeRepoCandidates(name: string): string[];
|
|
59
|
+
export declare const CHATTER_MIN_CHARS = 40;
|
|
60
|
+
/** A line too short to say anything about the work ("fair play", "ya"). */
|
|
61
|
+
export declare function isChatter(text: string): boolean;
|
|
62
|
+
export interface SlackMessage {
|
|
63
|
+
user: string;
|
|
64
|
+
at: string;
|
|
65
|
+
text: string;
|
|
66
|
+
}
|
|
67
|
+
/** The messages of a Slack thread file body (`### U123 · \`[time]\`` blocks, replies quoted with `>`). */
|
|
68
|
+
export declare function slackMessages(body: string): SlackMessage[];
|
|
69
|
+
/** `[[folder/name|label]]` and `[[name]]` links as their words: a timeline line is read, not followed. */
|
|
70
|
+
export declare function plainLinks(text: string): string;
|
|
71
|
+
/** Slack user ids in a text, distinct, in order of first appearance. */
|
|
72
|
+
export declare function slackIdsIn(text: string): string[];
|
|
73
|
+
/** Replaces each Slack id `nameOf` knows with the name. An unknown id stays as written. */
|
|
74
|
+
export declare function replaceSlackIds(text: string, nameOf: (id: string) => string | null): string;
|
|
75
|
+
/** The part of a timeline line two copies of one statement share: no trailing ellipsis or stop, first 70 characters. */
|
|
76
|
+
export declare function timelinePrefix(text: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* True when `incoming` repeats `existing`: the same line, or a cut copy of it
|
|
79
|
+
* (one starts with the other's first 70 characters). Lines under 30
|
|
80
|
+
* characters are compared whole.
|
|
81
|
+
*/
|
|
82
|
+
export declare function isTimelineRepeat(existing: string, incoming: string): boolean;
|
|
83
|
+
/** The Monday of the day's week (UTC). */
|
|
84
|
+
export declare function weekStart(day: IsoDate): IsoDate;
|
|
85
|
+
/** The Sunday that ends the week starting on `monday`. */
|
|
86
|
+
export declare function weekEnd(monday: IsoDate): IsoDate;
|
|
87
|
+
/** A commit subject without the PR number and the conventional-commit prefix noise. */
|
|
88
|
+
export declare function cleanSubject(subject: string): string;
|
|
89
|
+
export interface EndOfWork {
|
|
90
|
+
/** What the person is off, as the note says it (`app work`). */
|
|
91
|
+
what: string;
|
|
92
|
+
since: IsoDate;
|
|
93
|
+
}
|
|
94
|
+
/** A roster note that says the person stopped the work on a day ("Off the app work since 2026-10-21"). */
|
|
95
|
+
export declare function endOfWorkNote(text: string): EndOfWork | null;
|
|
96
|
+
export interface Turn {
|
|
97
|
+
speaker: string;
|
|
98
|
+
text: string;
|
|
99
|
+
}
|
|
100
|
+
/** Speaker turns of a meeting transcript body (`**Name** · \`[00:01–00:02]\`` then the words). */
|
|
101
|
+
export declare function transcriptTurns(body: string): Turn[];
|
|
102
|
+
export interface TranscriptCandidate {
|
|
103
|
+
/** The name as said. */
|
|
104
|
+
text: string;
|
|
105
|
+
/** Times it was said. */
|
|
106
|
+
count: number;
|
|
107
|
+
/** Said at least once inside a sentence. A word only ever seen opening a sentence is a capital letter, not a name. */
|
|
108
|
+
inside: boolean;
|
|
109
|
+
/** Index of the first turn that says it. */
|
|
110
|
+
turn: number;
|
|
111
|
+
/** Index of the longest turn that says it: the one with the most around the name. */
|
|
112
|
+
best: number;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Names said in a transcript, most said first: runs of two to four
|
|
116
|
+
* capitalized words and single capitalized words that do not open a sentence.
|
|
117
|
+
* A single word must be said twice. Nobody says a dash-joined slug out loud:
|
|
118
|
+
* one in a transcript was put there by a later edit of the file, so it is not
|
|
119
|
+
* a candidate. The resolver decides which are entities; this only keeps the
|
|
120
|
+
* question list short.
|
|
121
|
+
*/
|
|
122
|
+
export declare function transcriptCandidates(turns: readonly Turn[], limit?: number): TranscriptCandidate[];
|
|
123
|
+
/** The words around the first place `name` is said in `text`, as one line. */
|
|
124
|
+
export declare function excerptAround(text: string, name: string, max?: number): string;
|
|
125
|
+
/** How many times `name` appears in `text` as whole words, case-insensitive. */
|
|
126
|
+
export declare function countMentions(text: string, name: string): number;
|
|
127
|
+
//# sourceMappingURL=rules.d.ts.map
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Audience of a source class (correction C7)
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
/**
|
|
5
|
+
* Source classes whose files the company publishes to every member as a
|
|
6
|
+
* record: a class in this list is its own audience statement, so its rows are
|
|
7
|
+
* company-wide. Every other class needs an audience key on the source. A
|
|
8
|
+
* source with none is filed under the member's local audience, never under
|
|
9
|
+
* `company`: conversations (meetings, Slack, the signals made from them, the
|
|
10
|
+
* commitments and action items heard in them), session logs and the
|
|
11
|
+
* projections that exist only on the member's machine (CRM, KPIs).
|
|
12
|
+
*/
|
|
13
|
+
export const COMPANY_PUBLISHED_CLASSES = new Set([
|
|
14
|
+
"board",
|
|
15
|
+
"people",
|
|
16
|
+
"policies",
|
|
17
|
+
"knowledge",
|
|
18
|
+
"projects.prd",
|
|
19
|
+
"projects.readme",
|
|
20
|
+
"clients.md",
|
|
21
|
+
"git.history",
|
|
22
|
+
]);
|
|
23
|
+
export function isCompanyPublishedClass(cls) {
|
|
24
|
+
return COMPANY_PUBLISHED_CLASSES.has(cls);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The audience an input's rows are filed under (correction C7). An audience
|
|
28
|
+
* key on the source is kept. `company` is kept only for a class the company
|
|
29
|
+
* publishes as a record; for every other class it means "no audience key was
|
|
30
|
+
* found", and the rows go to the member's local audience. Null: nothing may
|
|
31
|
+
* be written (no audience, or no member to hold the local rows).
|
|
32
|
+
*/
|
|
33
|
+
export function audienceForInput(cls, audience, localKey) {
|
|
34
|
+
if (!audience)
|
|
35
|
+
return null;
|
|
36
|
+
if (audience !== "company" || isCompanyPublishedClass(cls))
|
|
37
|
+
return audience;
|
|
38
|
+
return localKey;
|
|
39
|
+
}
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Other-company scope (correction C7)
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
const COMPANY_PATH = /(?:^|[^A-Za-z0-9_-])companies\/([A-Za-z0-9][A-Za-z0-9_-]*)(?![A-Za-z0-9_.-])/g;
|
|
44
|
+
const COMPANY_TAGS = [
|
|
45
|
+
/\b(?:bind|add|lock|locked|switch(?:ed)? to) company[:\s]+`?([A-Za-z0-9][A-Za-z0-9_-]*)/gi,
|
|
46
|
+
/--company[=\s]+["'`]?([A-Za-z0-9][A-Za-z0-9_-]*)/g,
|
|
47
|
+
/\bcompany_slugs?\s*[:=]\s*\[?\s*["'`]?([A-Za-z0-9][A-Za-z0-9_-]*)/gi,
|
|
48
|
+
/"company"\s*:\s*\[?\s*"([A-Za-z0-9][A-Za-z0-9_-]*)"/g,
|
|
49
|
+
/^company:[ \t]*["'`]?([a-z0-9][a-z0-9_-]*)["'`]?[ \t]*$/gm,
|
|
50
|
+
];
|
|
51
|
+
const NOT_A_SLUG = new Set(["manifest", "the", "a", "an", "and", "or", "is", "in", "to", "of", "that", "this", "it", "set", "scope", "slug", "name", "wide", "folder", "context", "level", "s"]);
|
|
52
|
+
/**
|
|
53
|
+
* Company slugs a text names as a scope: a `companies/<slug>` path, a
|
|
54
|
+
* `--company <slug>` flag, `bind company <slug>`, or a `company: <slug>` tag.
|
|
55
|
+
* Lower case, distinct, sorted. A plain word is never a scope: company slugs
|
|
56
|
+
* are common words, so a word match would be wrong in both directions.
|
|
57
|
+
* `pathsOnly` keeps to `companies/<slug>` paths, for text that is prose.
|
|
58
|
+
*/
|
|
59
|
+
export function companyScopesIn(text, options = {}) {
|
|
60
|
+
const found = new Set();
|
|
61
|
+
const add = (slug) => {
|
|
62
|
+
const value = (slug ?? "").toLowerCase().replace(/[-_]+$/g, "");
|
|
63
|
+
if (value === "" || value.startsWith("_") || NOT_A_SLUG.has(value))
|
|
64
|
+
return;
|
|
65
|
+
found.add(value);
|
|
66
|
+
};
|
|
67
|
+
for (const match of text.matchAll(COMPANY_PATH))
|
|
68
|
+
add(match[1]);
|
|
69
|
+
if (!options.pathsOnly)
|
|
70
|
+
for (const pattern of COMPANY_TAGS)
|
|
71
|
+
for (const match of text.matchAll(pattern))
|
|
72
|
+
add(match[1]);
|
|
73
|
+
return [...found].sort();
|
|
74
|
+
}
|
|
75
|
+
/** True when any named scope is a company other than `company`. */
|
|
76
|
+
export function namesAnotherCompany(scopes, company) {
|
|
77
|
+
const own = company.toLowerCase();
|
|
78
|
+
return scopes.some((scope) => scope.toLowerCase() !== own);
|
|
79
|
+
}
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Sessions: boilerplate prompts and path evidence (correction C8)
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
const BOILERPLATE = [
|
|
84
|
+
/^read (?:your|the) brief\b/i,
|
|
85
|
+
/^you are (?:a |an |the )?(?:builder|worker|lane|sub-?agent|agent|critic|reviewer|runner|conductor|child)\b/i,
|
|
86
|
+
/^you are [a-z]+ (?:wp-|lane|worker)/i,
|
|
87
|
+
/^(?:continue|resume|go on|proceed|keep going|carry on)\b[\s.!]*$/i,
|
|
88
|
+
/^this session is being continued\b/i,
|
|
89
|
+
/^working directory for this task\b/i,
|
|
90
|
+
/^you are launched\b/i,
|
|
91
|
+
/^\/(?:resumework|startwork|handoff|checkpoint|clear|compact|loop|conduct-join|pin|capacity)\b/i,
|
|
92
|
+
/^agent ritual handoff\b/i,
|
|
93
|
+
/^auto-?checkpoint\b/i,
|
|
94
|
+
/^queue-idle lifecycle ritual\b/i,
|
|
95
|
+
/^(?:yes|no|ok|okay|sure|thanks|thank you|go|do it|approved?|lgtm)\b[\s.!]*$/i,
|
|
96
|
+
];
|
|
97
|
+
/** A first prompt that says nothing about the work: a brief pointer, a sub-agent preamble, a bare go-ahead. */
|
|
98
|
+
export function isBoilerplatePrompt(text) {
|
|
99
|
+
const trimmed = text.trim();
|
|
100
|
+
if (trimmed.length < 12)
|
|
101
|
+
return true;
|
|
102
|
+
return BOILERPLATE.some((pattern) => pattern.test(trimmed));
|
|
103
|
+
}
|
|
104
|
+
/** A title or summary that is one of the lifecycle phrases, whatever its length. An empty text is not. */
|
|
105
|
+
export function isLifecycleText(text) {
|
|
106
|
+
const trimmed = text.trim();
|
|
107
|
+
return trimmed !== "" && BOILERPLATE.some((pattern) => pattern.test(trimmed));
|
|
108
|
+
}
|
|
109
|
+
/** The first prompt that describes work, or null when the session has none. */
|
|
110
|
+
export function firstRealPrompt(prompts) {
|
|
111
|
+
for (const prompt of prompts)
|
|
112
|
+
if (!isBoilerplatePrompt(prompt))
|
|
113
|
+
return prompt.trim();
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Work a session touched, read from paths only: its working directories, the
|
|
118
|
+
* files it changed and the paths its prompts name. Words are not evidence.
|
|
119
|
+
*/
|
|
120
|
+
export function pathEvidence(texts, company) {
|
|
121
|
+
const repos = new Set();
|
|
122
|
+
const worktrees = new Set();
|
|
123
|
+
const projects = new Set();
|
|
124
|
+
const escaped = company.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
125
|
+
const projectPath = new RegExp(`companies/${escaped}/projects/([A-Za-z0-9][A-Za-z0-9._-]*)`, "g");
|
|
126
|
+
for (const text of texts) {
|
|
127
|
+
for (const match of text.matchAll(/(?:^|[^A-Za-z0-9_-])repos\/(?:private|public)\/([A-Za-z0-9][A-Za-z0-9._-]*)/g))
|
|
128
|
+
repos.add(match[1]);
|
|
129
|
+
for (const match of text.matchAll(/workspace\/worktrees\/([A-Za-z0-9][A-Za-z0-9._-]*)/g))
|
|
130
|
+
worktrees.add(match[1]);
|
|
131
|
+
for (const match of text.matchAll(projectPath))
|
|
132
|
+
projects.add(match[1].replace(/\.(?:md|json)$/, ""));
|
|
133
|
+
}
|
|
134
|
+
const sorted = (set) => [...set].sort();
|
|
135
|
+
return { repos: sorted(repos), worktrees: sorted(worktrees), projects: sorted(projects) };
|
|
136
|
+
}
|
|
137
|
+
/** `app-web-auth-fix` could be a worktree of `app-web-auth`, `app-web` or `app`: longest first. */
|
|
138
|
+
export function worktreeRepoCandidates(name) {
|
|
139
|
+
const parts = name.split("-");
|
|
140
|
+
const out = [];
|
|
141
|
+
for (let size = parts.length; size >= 1; size--)
|
|
142
|
+
out.push(parts.slice(0, size).join("-"));
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
// ---------------------------------------------------------------------------
|
|
146
|
+
// Slack chatter and ids (correction C8)
|
|
147
|
+
// ---------------------------------------------------------------------------
|
|
148
|
+
export const CHATTER_MIN_CHARS = 40;
|
|
149
|
+
/** A line too short to say anything about the work ("fair play", "ya"). */
|
|
150
|
+
export function isChatter(text) {
|
|
151
|
+
const words = text.replace(/<[^>]*>/g, " ").replace(/:[a-z0-9_+-]+:/g, " ").trim();
|
|
152
|
+
return words.length < CHATTER_MIN_CHARS;
|
|
153
|
+
}
|
|
154
|
+
/** The messages of a Slack thread file body (`### U123 · \`[time]\`` blocks, replies quoted with `>`). */
|
|
155
|
+
export function slackMessages(body) {
|
|
156
|
+
const messages = [];
|
|
157
|
+
let current = null;
|
|
158
|
+
for (const raw of body.split("\n")) {
|
|
159
|
+
const line = raw.replace(/^>\s?/, "");
|
|
160
|
+
const head = /^###\s+(\S+)\s+·\s+`\[([^\]]*)\]`/.exec(line);
|
|
161
|
+
if (head) {
|
|
162
|
+
current = { user: head[1], at: head[2], text: "" };
|
|
163
|
+
messages.push(current);
|
|
164
|
+
}
|
|
165
|
+
else if (current && line.trim() !== "") {
|
|
166
|
+
current.text = current.text === "" ? line.trim() : `${current.text} ${line.trim()}`;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return messages;
|
|
170
|
+
}
|
|
171
|
+
const SLACK_ID = /<@([UW][A-Z0-9]{7,11})(?:\|[^>]*)?>|\b([UW](?=[A-Z0-9]*\d)[A-Z0-9]{8,11})\b/g;
|
|
172
|
+
/** `[[folder/name|label]]` and `[[name]]` links as their words: a timeline line is read, not followed. */
|
|
173
|
+
export function plainLinks(text) {
|
|
174
|
+
return text.replace(/\[\[[^\]|]*\\?\|([^\]]*)\]\]/g, "$1").replace(/\[\[([^\]|]*)\]\]/g, "$1");
|
|
175
|
+
}
|
|
176
|
+
/** Slack user ids in a text, distinct, in order of first appearance. */
|
|
177
|
+
export function slackIdsIn(text) {
|
|
178
|
+
const ids = [];
|
|
179
|
+
for (const match of text.matchAll(SLACK_ID)) {
|
|
180
|
+
const id = match[1] ?? match[2];
|
|
181
|
+
if (id && !ids.includes(id))
|
|
182
|
+
ids.push(id);
|
|
183
|
+
}
|
|
184
|
+
return ids;
|
|
185
|
+
}
|
|
186
|
+
/** Replaces each Slack id `nameOf` knows with the name. An unknown id stays as written. */
|
|
187
|
+
export function replaceSlackIds(text, nameOf) {
|
|
188
|
+
return text.replace(SLACK_ID, (whole, mention, bare) => {
|
|
189
|
+
const name = nameOf(mention ?? bare ?? "");
|
|
190
|
+
return name ?? whole;
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
// ---------------------------------------------------------------------------
|
|
194
|
+
// Timeline duplicates (correction C8)
|
|
195
|
+
// ---------------------------------------------------------------------------
|
|
196
|
+
const PREFIX_CHARS = 70;
|
|
197
|
+
const PREFIX_MIN = 30;
|
|
198
|
+
/** The part of a timeline line two copies of one statement share: no trailing ellipsis or stop, first 70 characters. */
|
|
199
|
+
export function timelinePrefix(text) {
|
|
200
|
+
return text.replace(/[.…\s]+$/u, "").slice(0, PREFIX_CHARS);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* True when `incoming` repeats `existing`: the same line, or a cut copy of it
|
|
204
|
+
* (one starts with the other's first 70 characters). Lines under 30
|
|
205
|
+
* characters are compared whole.
|
|
206
|
+
*/
|
|
207
|
+
export function isTimelineRepeat(existing, incoming) {
|
|
208
|
+
if (existing === incoming)
|
|
209
|
+
return true;
|
|
210
|
+
const a = timelinePrefix(existing);
|
|
211
|
+
const b = timelinePrefix(incoming);
|
|
212
|
+
if (a.length < PREFIX_MIN || b.length < PREFIX_MIN)
|
|
213
|
+
return false;
|
|
214
|
+
return existing.startsWith(b) || incoming.startsWith(a);
|
|
215
|
+
}
|
|
216
|
+
// ---------------------------------------------------------------------------
|
|
217
|
+
// Git weeks (correction C8)
|
|
218
|
+
// ---------------------------------------------------------------------------
|
|
219
|
+
/** The Monday of the day's week (UTC). */
|
|
220
|
+
export function weekStart(day) {
|
|
221
|
+
const date = new Date(`${day}T00:00:00Z`);
|
|
222
|
+
const offset = (date.getUTCDay() + 6) % 7;
|
|
223
|
+
date.setUTCDate(date.getUTCDate() - offset);
|
|
224
|
+
return date.toISOString().slice(0, 10);
|
|
225
|
+
}
|
|
226
|
+
/** The Sunday that ends the week starting on `monday`. */
|
|
227
|
+
export function weekEnd(monday) {
|
|
228
|
+
const date = new Date(`${monday}T00:00:00Z`);
|
|
229
|
+
date.setUTCDate(date.getUTCDate() + 6);
|
|
230
|
+
return date.toISOString().slice(0, 10);
|
|
231
|
+
}
|
|
232
|
+
/** A commit subject without the PR number and the conventional-commit prefix noise. */
|
|
233
|
+
export function cleanSubject(subject) {
|
|
234
|
+
return subject.replace(/\s*\(#\d+\)\s*$/, "").replace(/\s+/g, " ").trim();
|
|
235
|
+
}
|
|
236
|
+
const END_NOTES = [
|
|
237
|
+
/\boff (?:the )?([A-Za-z0-9][A-Za-z0-9 &/-]{0,40}?(?:work|project|team|account)?) since (\d{4}-\d{2}-\d{2})/i,
|
|
238
|
+
/\bno longer (?:on|with|at|working on) (?:the )?([A-Za-z0-9][A-Za-z0-9 &/-]{0,40}?) (?:since|as of|from) (\d{4}-\d{2}-\d{2})/i,
|
|
239
|
+
/\bleft (?:the )?([A-Za-z0-9][A-Za-z0-9 &/-]{0,40}?) (?:on|since|as of) (\d{4}-\d{2}-\d{2})/i,
|
|
240
|
+
/\b(stopped working|ended|last day)\b[^.]{0,40}? (?:on|since|as of|was) (\d{4}-\d{2}-\d{2})/i,
|
|
241
|
+
];
|
|
242
|
+
/** A roster note that says the person stopped the work on a day ("Off the app work since 2026-10-21"). */
|
|
243
|
+
export function endOfWorkNote(text) {
|
|
244
|
+
for (const pattern of END_NOTES) {
|
|
245
|
+
const match = pattern.exec(text);
|
|
246
|
+
if (!match)
|
|
247
|
+
continue;
|
|
248
|
+
const since = match[2];
|
|
249
|
+
const date = new Date(`${since}T00:00:00Z`);
|
|
250
|
+
if (Number.isNaN(date.getTime()) || date.toISOString().slice(0, 10) !== since)
|
|
251
|
+
continue;
|
|
252
|
+
return { what: match[1].trim(), since };
|
|
253
|
+
}
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
/** Speaker turns of a meeting transcript body (`**Name** · \`[00:01–00:02]\`` then the words). */
|
|
257
|
+
export function transcriptTurns(body) {
|
|
258
|
+
const turns = [];
|
|
259
|
+
let current = null;
|
|
260
|
+
for (const line of body.split("\n")) {
|
|
261
|
+
const head = /^\*\*(.+?)\*\* · `\[/.exec(line);
|
|
262
|
+
if (head) {
|
|
263
|
+
const label = head[1].trim();
|
|
264
|
+
const link = /^\[\[[^|\]]+\|([^\]]+)\]\]$/.exec(label);
|
|
265
|
+
current = { speaker: link ? link[1] : label, text: "" };
|
|
266
|
+
turns.push(current);
|
|
267
|
+
}
|
|
268
|
+
else if (current && line.trim() !== "" && !line.startsWith("#")) {
|
|
269
|
+
// An enriched transcript links names into the old entity folder: keep the words, drop the link.
|
|
270
|
+
const words = plainLinks(line.trim());
|
|
271
|
+
current.text = current.text === "" ? words : `${current.text} ${words}`;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return turns;
|
|
275
|
+
}
|
|
276
|
+
const TRANSCRIPT_STOP = new Set([
|
|
277
|
+
"yeah", "okay", "right", "well", "like", "just", "sure", "cool", "nice", "good", "great", "thanks", "thank", "sorry", "what", "when", "where", "which",
|
|
278
|
+
"there", "then", "that", "this", "they", "them", "these", "those", "have", "with", "from", "because", "also", "actually", "basically", "literally",
|
|
279
|
+
"maybe", "probably", "really", "still", "about", "after", "before", "today", "tomorrow", "yesterday", "monday", "tuesday", "wednesday", "thursday",
|
|
280
|
+
"friday", "saturday", "sunday", "january", "february", "march", "april", "june", "july", "august", "september", "october", "november", "december",
|
|
281
|
+
"exactly", "awesome", "perfect", "amazing", "yes", "yep", "nope", "hello", "anyway", "obviously", "honestly", "definitely", "absolutely", "something",
|
|
282
|
+
"everything", "anything", "nothing", "everyone", "someone", "here", "now", "let", "lets", "does", "did", "can", "could", "would", "should", "will",
|
|
283
|
+
"and", "but", "the", "for", "not", "you", "your", "our", "its", "one", "two", "all", "any", "how", "why", "who", "was", "were", "are", "has", "had",
|
|
284
|
+
"so", "oh", "um", "uh", "hey", "hi", "look", "see", "got", "get", "think", "know", "mean", "if", "is", "it", "we", "he", "she", "my", "on", "in", "at",
|
|
285
|
+
"to", "of", "or", "as", "be", "do", "no", "me", "us", "an", "by", "up", "go", "am", "ok", "his", "her", "their", "some", "more", "most", "very", "much",
|
|
286
|
+
"i'm", "i've", "i'll", "it's", "that's", "we're", "we've", "don't", "can't", "there's", "what's", "let's", "you're", "they're", "he's", "she's",
|
|
287
|
+
]);
|
|
288
|
+
/**
|
|
289
|
+
* Names said in a transcript, most said first: runs of two to four
|
|
290
|
+
* capitalized words and single capitalized words that do not open a sentence.
|
|
291
|
+
* A single word must be said twice. Nobody says a dash-joined slug out loud:
|
|
292
|
+
* one in a transcript was put there by a later edit of the file, so it is not
|
|
293
|
+
* a candidate. The resolver decides which are entities; this only keeps the
|
|
294
|
+
* question list short.
|
|
295
|
+
*/
|
|
296
|
+
export function transcriptCandidates(turns, limit = 120) {
|
|
297
|
+
const found = new Map();
|
|
298
|
+
const note = (text, turn, inside) => {
|
|
299
|
+
const key = text.toLowerCase();
|
|
300
|
+
const known = found.get(key);
|
|
301
|
+
if (known) {
|
|
302
|
+
known.count += 1;
|
|
303
|
+
if (turns[turn].text.length > turns[known.best].text.length)
|
|
304
|
+
known.best = turn;
|
|
305
|
+
if (inside && !known.inside) {
|
|
306
|
+
known.inside = true;
|
|
307
|
+
known.text = text;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
else
|
|
311
|
+
found.set(key, { text, count: 1, turn, best: turn, inside });
|
|
312
|
+
};
|
|
313
|
+
turns.forEach((turn, index) => {
|
|
314
|
+
const words = turn.text.split(/\s+/);
|
|
315
|
+
let run = [];
|
|
316
|
+
let runOpensSentence = false;
|
|
317
|
+
let sentenceStart = true;
|
|
318
|
+
const flush = () => {
|
|
319
|
+
if (run.length >= 2)
|
|
320
|
+
note(run.slice(0, 4).join(" "), index, true);
|
|
321
|
+
else if (run.length === 1)
|
|
322
|
+
note(run[0], index, !runOpensSentence);
|
|
323
|
+
run = [];
|
|
324
|
+
};
|
|
325
|
+
for (const raw of words) {
|
|
326
|
+
const word = raw.replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, "").replace(/['’]s$/u, "");
|
|
327
|
+
const capital = /^\p{Lu}[\p{L}\p{N}.-]*$/u.test(word) && word.length >= 2 && !TRANSCRIPT_STOP.has(word.toLowerCase());
|
|
328
|
+
if (capital) {
|
|
329
|
+
if (run.length === 0)
|
|
330
|
+
runOpensSentence = sentenceStart;
|
|
331
|
+
run.push(word);
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
flush();
|
|
335
|
+
}
|
|
336
|
+
sentenceStart = /[.!?]["')\]]*$/.test(raw);
|
|
337
|
+
}
|
|
338
|
+
flush();
|
|
339
|
+
});
|
|
340
|
+
return [...found.values()]
|
|
341
|
+
.filter((candidate) => candidate.inside && (candidate.count >= 2 || candidate.text.includes(" ")))
|
|
342
|
+
.filter((candidate) => candidate.text.length >= 3)
|
|
343
|
+
.sort((a, b) => b.count - a.count || (a.text < b.text ? -1 : a.text > b.text ? 1 : 0))
|
|
344
|
+
.slice(0, limit);
|
|
345
|
+
}
|
|
346
|
+
/** The words around the first place `name` is said in `text`, as one line. */
|
|
347
|
+
export function excerptAround(text, name, max = 200) {
|
|
348
|
+
const at = text.toLowerCase().indexOf(name.toLowerCase());
|
|
349
|
+
if (at < 0)
|
|
350
|
+
return text.slice(0, max).trim();
|
|
351
|
+
let start = Math.max(0, at - Math.floor(max / 2));
|
|
352
|
+
let end = Math.min(text.length, start + max);
|
|
353
|
+
start = Math.max(0, end - max);
|
|
354
|
+
if (start > 0) {
|
|
355
|
+
const space = text.indexOf(" ", start);
|
|
356
|
+
if (space >= 0 && space < at)
|
|
357
|
+
start = space + 1;
|
|
358
|
+
}
|
|
359
|
+
if (end < text.length) {
|
|
360
|
+
const space = text.lastIndexOf(" ", end);
|
|
361
|
+
if (space > at + name.length)
|
|
362
|
+
end = space;
|
|
363
|
+
}
|
|
364
|
+
return `${start > 0 ? "…" : ""}${text.slice(start, end).trim()}${end < text.length ? "…" : ""}`;
|
|
365
|
+
}
|
|
366
|
+
/** How many times `name` appears in `text` as whole words, case-insensitive. */
|
|
367
|
+
export function countMentions(text, name) {
|
|
368
|
+
const needle = name.trim();
|
|
369
|
+
if (needle.length < 3)
|
|
370
|
+
return 0;
|
|
371
|
+
const pattern = new RegExp(`(?<![\\p{L}\\p{N}])${needle.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/[\s-]+/g, "[\\s-]+")}(?![\\p{L}\\p{N}])`, "giu");
|
|
372
|
+
return (text.match(pattern) ?? []).length;
|
|
373
|
+
}
|
|
374
|
+
//# sourceMappingURL=rules.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AudienceKey, GraphContext, MemberIdentity } from "../types.js";
|
|
2
|
+
import type { ReplayConfig } from "./config.js";
|
|
3
|
+
/** The principal that marks the local audience of a member. Not a person, not an email. */
|
|
4
|
+
export declare const LOCAL_AUDIENCE_PRINCIPAL = "@local";
|
|
5
|
+
/**
|
|
6
|
+
* The audience of sources that carry no audience key (correction C7): visible
|
|
7
|
+
* to the member who built the graph and to nobody else, never `company`.
|
|
8
|
+
* The row grammar admits `company` or 16 hex, so the key is `local` when the
|
|
9
|
+
* grammar takes that word and otherwise the 16 hex key of the audience
|
|
10
|
+
* `[<person uid>, @local]`, which no real audience list can produce.
|
|
11
|
+
*/
|
|
12
|
+
export declare function localAudienceKey(personUid: string): AudienceKey;
|
|
13
|
+
export interface MemberScope {
|
|
14
|
+
readonly member: MemberIdentity | null;
|
|
15
|
+
readonly personUid: string | null;
|
|
16
|
+
/** The member's person uid, emails (lower case) and configured principal ids. */
|
|
17
|
+
readonly principals: ReadonlySet<string>;
|
|
18
|
+
readonly emails: readonly string[];
|
|
19
|
+
/** Keys the member holds, without `company`. */
|
|
20
|
+
readonly keys: ReadonlySet<AudienceKey>;
|
|
21
|
+
/** The key of an audience of exactly this member. Rows from personal files live here. */
|
|
22
|
+
readonly personalKey: AudienceKey | null;
|
|
23
|
+
/** The member's local audience: where a source with no audience key is filed (C7). Null with no member. */
|
|
24
|
+
readonly localKey: AudienceKey | null;
|
|
25
|
+
holds(key: AudienceKey): boolean;
|
|
26
|
+
owns(personUid: unknown): boolean;
|
|
27
|
+
/** The key for an audience list, or null when the list is empty or does not name the member. */
|
|
28
|
+
audienceFor(principals: readonly string[]): AudienceKey | null;
|
|
29
|
+
/** `company` plus every held key, sorted. */
|
|
30
|
+
audiences(): AudienceKey[];
|
|
31
|
+
}
|
|
32
|
+
/** Normalizes `sha256:<64 hex>` or 16 hex to a 16 hex audience key. */
|
|
33
|
+
export declare function toAudienceKey(value: unknown): AudienceKey | null;
|
|
34
|
+
export declare function resolveMemberScope(context: GraphContext, config: ReplayConfig): MemberScope;
|
|
35
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WP-B: what one member may read (correction C2).
|
|
3
|
+
*
|
|
4
|
+
* - Company-scope classes are readable by every member.
|
|
5
|
+
* - A per-audience folder or source is readable only for a key the member
|
|
6
|
+
* holds: a key passed in `MemberIdentity.audienceKeys`, a key whose
|
|
7
|
+
* `_audience.yaml` lists the member as a principal, or the key of an
|
|
8
|
+
* audience list that names the member.
|
|
9
|
+
* - A personal-scope file is readable only when its owner is the member.
|
|
10
|
+
* - With no member, nothing personal and nothing per-audience is readable.
|
|
11
|
+
* - A source with no audience key is filed under the member's local audience
|
|
12
|
+
* (correction C7), never under `company`. With no member it is not read.
|
|
13
|
+
*/
|
|
14
|
+
import * as path from "node:path";
|
|
15
|
+
import { audienceKey as hashAudience } from "../../hot-channels/audience.js";
|
|
16
|
+
import { isAudienceKey } from "../schema/index.js";
|
|
17
|
+
import { asRecord, asString, listFolders, readYamlFile, stringList } from "./util.js";
|
|
18
|
+
const HEX16 = /^[0-9a-f]{16}$/;
|
|
19
|
+
/** The principal that marks the local audience of a member. Not a person, not an email. */
|
|
20
|
+
export const LOCAL_AUDIENCE_PRINCIPAL = "@local";
|
|
21
|
+
/**
|
|
22
|
+
* The audience of sources that carry no audience key (correction C7): visible
|
|
23
|
+
* to the member who built the graph and to nobody else, never `company`.
|
|
24
|
+
* The row grammar admits `company` or 16 hex, so the key is `local` when the
|
|
25
|
+
* grammar takes that word and otherwise the 16 hex key of the audience
|
|
26
|
+
* `[<person uid>, @local]`, which no real audience list can produce.
|
|
27
|
+
*/
|
|
28
|
+
export function localAudienceKey(personUid) {
|
|
29
|
+
if (isAudienceKey("local"))
|
|
30
|
+
return "local";
|
|
31
|
+
return hashAudience([personUid, LOCAL_AUDIENCE_PRINCIPAL]);
|
|
32
|
+
}
|
|
33
|
+
function normalizePrincipal(value) {
|
|
34
|
+
const trimmed = value.trim();
|
|
35
|
+
return trimmed.includes("@") ? trimmed.toLowerCase() : trimmed;
|
|
36
|
+
}
|
|
37
|
+
/** Normalizes `sha256:<64 hex>` or 16 hex to a 16 hex audience key. */
|
|
38
|
+
export function toAudienceKey(value) {
|
|
39
|
+
const text = asString(value).toLowerCase().replace(/^sha256[:-]/, "");
|
|
40
|
+
if (text === "company")
|
|
41
|
+
return "company";
|
|
42
|
+
if (/^[0-9a-f]{16,64}$/.test(text))
|
|
43
|
+
return text.slice(0, 16);
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
export function resolveMemberScope(context, config) {
|
|
47
|
+
const member = context.member ?? null;
|
|
48
|
+
const personUid = member?.personUid ?? null;
|
|
49
|
+
const principals = new Set();
|
|
50
|
+
const emails = [];
|
|
51
|
+
const keys = new Set();
|
|
52
|
+
let personalKey = null;
|
|
53
|
+
let localKey = null;
|
|
54
|
+
if (member && personUid) {
|
|
55
|
+
principals.add(personUid);
|
|
56
|
+
for (const principal of config.memberPrincipals)
|
|
57
|
+
principals.add(normalizePrincipal(principal));
|
|
58
|
+
// The roster entry that names this person uid gives the member's email.
|
|
59
|
+
for (const slug of listFolders(path.join(context.companyRoot, "people"))) {
|
|
60
|
+
if (slug.startsWith("_"))
|
|
61
|
+
continue;
|
|
62
|
+
const meta = readYamlFile(path.join(context.companyRoot, "people", slug, "meta.yaml"));
|
|
63
|
+
if (asString(asRecord(meta.handles).hq_person_uid) !== personUid)
|
|
64
|
+
continue;
|
|
65
|
+
const email = asString(meta.email).toLowerCase();
|
|
66
|
+
if (email.includes("@")) {
|
|
67
|
+
emails.push(email);
|
|
68
|
+
principals.add(email);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for (const key of member.audienceKeys)
|
|
72
|
+
if (HEX16.test(key))
|
|
73
|
+
keys.add(key);
|
|
74
|
+
personalKey = hashAudience([personUid]);
|
|
75
|
+
keys.add(personalKey);
|
|
76
|
+
localKey = localAudienceKey(personUid);
|
|
77
|
+
keys.add(localKey);
|
|
78
|
+
// Keys whose audience file lists the member.
|
|
79
|
+
for (const folder of listFolders(path.join(context.companyRoot, "signals"))) {
|
|
80
|
+
if (!folder.startsWith("@"))
|
|
81
|
+
continue;
|
|
82
|
+
const key = folder.slice(1);
|
|
83
|
+
if (!HEX16.test(key) || keys.has(key))
|
|
84
|
+
continue;
|
|
85
|
+
const audience = readYamlFile(path.join(context.companyRoot, "signals", folder, "_audience.yaml"));
|
|
86
|
+
if (stringList(audience.principals).map(normalizePrincipal).some((principal) => principals.has(principal)))
|
|
87
|
+
keys.add(key);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
member,
|
|
92
|
+
personUid,
|
|
93
|
+
principals,
|
|
94
|
+
emails,
|
|
95
|
+
keys,
|
|
96
|
+
personalKey,
|
|
97
|
+
localKey,
|
|
98
|
+
holds: (key) => key === "company" || keys.has(key),
|
|
99
|
+
owns: (owner) => personUid !== null && typeof owner === "string" && owner.trim() === personUid,
|
|
100
|
+
audienceFor(list) {
|
|
101
|
+
if (!personUid)
|
|
102
|
+
return null;
|
|
103
|
+
const normalized = list.map(normalizePrincipal).filter((entry) => entry !== "");
|
|
104
|
+
if (normalized.length === 0)
|
|
105
|
+
return null;
|
|
106
|
+
if (normalized.length === 1 && normalized[0] === "company")
|
|
107
|
+
return "company";
|
|
108
|
+
if (!normalized.some((entry) => principals.has(entry)))
|
|
109
|
+
return null;
|
|
110
|
+
return hashAudience(normalized);
|
|
111
|
+
},
|
|
112
|
+
audiences: () => ["company", ...[...keys].sort()],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=scope.js.map
|