From 1dfbad59b904930505f2d2fac73aeac567266d85 Mon Sep 17 00:00:00 2001 From: leemour Date: Mon, 23 Nov 2026 23:09:17 +0100 Subject: [PATCH 01/48] refactor!: drop the deprecated search and sync names, bound the peers, read commander internals in one place - Remove searchAllIncludingMeetings and its five types, SyncOptions.limitError and MeetingTranscriptDocumentStore.transcriptMeetings. No downstream CLI names them on main. - Peer ranges: @wirecat/cli-base ">=0.125.0 <1.0.0 || ^1.0.0-0" so cli-base 1.0 can come first; commander "^15.0.0" instead of ">=15". - src/cli/commander-internals.ts is the only reader of commander fields with no public accessor (_actionHandler, _hidden, _getHelpOption, unknownOption). It is not exported from any entry point; its test fails when a commander release renames one. Co-Authored-By: Claude Opus 5.5 --- biome.json | 4 +- changes/1.0-surface.md | 15 +++++ docs/dev/BACKLOG.md | 2 - package.json | 4 +- src/cli/commander-internals.test.ts | 55 +++++++++++++++ src/cli/commander-internals.ts | 43 ++++++++++++ src/cli/guide.ts | 5 +- src/cli/help/command-help.ts | 6 +- src/cli/messenger/lacks.ts | 8 +-- src/cli/messenger/search-answers.ts | 3 +- src/cli/option-hints.ts | 7 +- src/kit/run-scope.ts | 3 +- src/meetings/cli/query-options.ts | 7 +- src/meetings/transcript-store.ts | 1 - src/services/documents/ports.ts | 2 - src/services/index.ts | 8 --- src/services/search-all-deprecated.ts | 78 ---------------------- src/services/search-all-meetings.test.ts | 28 +++----- src/store/sqlite/meeting-documents.test.ts | 1 - src/store/sqlite/meeting-documents.ts | 5 -- 20 files changed, 143 insertions(+), 142 deletions(-) create mode 100644 changes/1.0-surface.md create mode 100644 src/cli/commander-internals.test.ts create mode 100644 src/cli/commander-internals.ts delete mode 100644 src/services/search-all-deprecated.ts diff --git a/biome.json b/biome.json index 2c6745cc4..a7177ef92 100644 --- a/biome.json +++ b/biome.json @@ -565,8 +565,8 @@ }, "patterns": [ { - "group": ["../../**", "!../../services/moment.js"], - "message": "src/meetings/ depends on nothing else in cli-core but the time grammar every past-time flag shares (src/services/moment.ts): the rest of the package calls it, never the other way round" + "group": ["../../**", "!../../services/moment.js", "!../../cli/commander-internals.js"], + "message": "src/meetings/ depends on nothing else in cli-core but the time grammar every past-time flag shares (src/services/moment.ts) and the one reader of commander's private fields (src/cli/commander-internals.ts): the rest of the package calls it, never the other way round" }, { "group": ["better-sqlite3", "drizzle-orm", "drizzle-orm/*"], diff --git a/changes/1.0-surface.md b/changes/1.0-surface.md new file mode 100644 index 000000000..83eebaa10 --- /dev/null +++ b/changes/1.0-surface.md @@ -0,0 +1,15 @@ +### Changed — may break callers + +- **The peer ranges are bounded for 1.0.** `@wirecat/cli-base` is `>=0.125.0 <1.0.0 || ^1.0.0-0`, so cli-base 1.0 and + its release candidates install beside cli-core. `commander` is `^15.0.0` (it was `>=15`): the command skeleton reads + a few commander fields that have no public accessor, now all in one internal module with a test, and a new + commander major is accepted only after that test passes on it. + +### Removed + +- **`searchAllIncludingMeetings` and its types** (`ResourceWithMeetings`, `MeetingSearchCursor`, + `SearchAllIncludingMeetingsRequest`, `MeetingSearchCoverage`, `SearchAllIncludingMeetingsFound`) from + `@wirecat/cli-core/services`. Call `searchAll` with `scope.meetings` and read `SearchAllFound`. +- **`SyncOptions.limitError`** (document sync), which nothing called: a walk past `maxEntries` already goes on in the next sync. +- **`MeetingTranscriptDocumentStore.transcriptMeetings`**. `documentMeetings` gives each document's meeting with its + role; keep the entries whose role is `transcript`. diff --git a/docs/dev/BACKLOG.md b/docs/dev/BACKLOG.md index 9ab03e2a2..f795202aa 100644 --- a/docs/dev/BACKLOG.md +++ b/docs/dev/BACKLOG.md @@ -51,8 +51,6 @@ None open. - **CORE-59** · P2 · A meeting's `attached` link keeps pointing at a deleted document when Drive later stores the same file as a new document: only a link with no document is resolved again (`linkAttached`), so `meetings show` says `null`. Re-resolve links whose document is deleted. `src/store/sqlite/files.ts` (`linkAttached`). -- **CORE-60** · P3 · `MeetingTranscriptDocumentStore.transcriptMeetings` has no caller but tests since `search all` - reads `documentMeetings`. Drop it at the next breaking release. `src/meetings/transcript-store.ts`. - **CORE-61** · P2 · A shared Google sign-in module in `./google` (`accountEmail`, `session start`/`status`/`end`): gcal, drive and meet each copy ~450 lines of it. `src/google/`. - **CORE-52** · P2 · Tasks from an external task tool, Todoist first (owner, 2026-11-09: soon, not now). Import diff --git a/package.json b/package.json index dd92cdd9b..fd4e8b584 100644 --- a/package.json +++ b/package.json @@ -358,8 +358,8 @@ }, "peerDependencies": { "@napi-rs/canvas": ">=0.1.69 <2", - "@wirecat/cli-base": ">=0.125.0 <1.0.0", - "commander": ">=15", + "@wirecat/cli-base": ">=0.125.0 <1.0.0 || ^1.0.0-0", + "commander": "^15.0.0", "mysql2": "^3.24.6", "pg": "^8.23.1", "ssh2": "^1.17.0" diff --git a/src/cli/commander-internals.test.ts b/src/cli/commander-internals.test.ts new file mode 100644 index 000000000..931fce70d --- /dev/null +++ b/src/cli/commander-internals.test.ts @@ -0,0 +1,55 @@ +import { Command } from "commander" +import { describe, expect, it } from "vitest" +import { + hasOwnAction, + helpOptionOf, + hide, + isHidden, + onUnknownOption, + rejectUnknownOption, +} from "./commander-internals.js" + +const program = () => { + const root = new Command("app").exitOverride() + root + .command("group") + .command("leaf") + .action(() => {}) + return root +} + +describe("the commander fields the skeleton reads", () => { + it("tells a command with an action from a group", () => { + const root = program() + const group = root.commands[0] as Command + expect(hasOwnAction(group)).toBe(false) + expect(hasOwnAction(group.commands[0] as Command)).toBe(true) + }) + + it("hides a command after it was added, and commander's help leaves it out", () => { + const root = program() + const group = root.commands[0] as Command + expect(isHidden(group)).toBe(false) + hide(group) + expect(isHidden(group)).toBe(true) + expect(root.helpInformation()).not.toContain("group") + }) + + it("finds the help option", () => { + const help = helpOptionOf(program()) + expect(help?.long).toBe("--help") + expect([help?.is("-h"), help?.is("--help"), help?.is("--nope")]).toEqual([true, true, false]) + }) + + it("fails on an unknown option, and lets a handler replace that failure", () => { + const root = program().configureOutput({ writeErr: () => {} }) + expect(() => rejectUnknownOption(root, "--nope")).toThrow( + expect.objectContaining({ code: "commander.unknownOption" }), + ) + onUnknownOption(root, (flag, fallback) => (flag === "--nope" ? root.error("hinted") : fallback(flag))) + expect(() => rejectUnknownOption(root, "--nope")).toThrow("hinted") + expect(() => rejectUnknownOption(root, "--other")).toThrow( + expect.objectContaining({ code: "commander.unknownOption" }), + ) + }) +}) diff --git a/src/cli/commander-internals.ts b/src/cli/commander-internals.ts new file mode 100644 index 000000000..b1183ae5b --- /dev/null +++ b/src/cli/commander-internals.ts @@ -0,0 +1,43 @@ +import type { Command, Option } from "commander" + +/** + * The commander fields with no public accessor that the command skeleton relies on. They are read here only, so a + * commander release that renames one fails `commander-internals.test.ts` rather than a CLI at run time. Not exported + * from any entry point. + */ +interface Internals { + _actionHandler?: unknown + _hidden?: boolean + _getHelpOption(): HelpOption | null + unknownOption(flag: string): never +} + +/** `is` matches the long or short flag, as commander checks it. */ +type HelpOption = Option & { is(word: string): boolean } + +const internals = (command: Command): Internals => command as unknown as Internals + +/** Whether the command runs an action of its own, rather than only grouping others. */ +export const hasOwnAction = (command: Command): boolean => internals(command)._actionHandler != null + +export const isHidden = (command: Command): boolean => internals(command)._hidden === true + +/** Hides a command already added, as `{ hidden: true }` does when it is added. */ +export const hide = (command: Command): void => { + internals(command)._hidden = true +} + +export const helpOptionOf = (command: Command): HelpOption | null => internals(command)._getHelpOption() + +/** Fails as commander does for an option the command does not take. */ +export const rejectUnknownOption = (command: Command, flag: string): never => internals(command).unknownOption(flag) + +/** Replaces commander's failure for an unknown option; `fallback` is commander's own. */ +export const onUnknownOption = ( + command: Command, + handle: (flag: string, fallback: (flag: string) => never) => never, +) => { + const own = internals(command) + const fallback = own.unknownOption.bind(command) + own.unknownOption = (flag) => handle(flag, fallback) +} diff --git a/src/cli/guide.ts b/src/cli/guide.ts index 8a7788436..0553bf3cf 100644 --- a/src/cli/guide.ts +++ b/src/cli/guide.ts @@ -4,6 +4,7 @@ import { CliError } from "@wirecat/cli-base" import { annotate } from "@wirecat/cli-base/commands" import { Command, type Option } from "commander" import type { AppIdentity } from "../ports/app.js" +import { hasOwnAction, helpOptionOf } from "./commander-internals.js" import { environmentOf, outputFor } from "./context.js" import { NO_EFFECTS } from "./effects.js" import { itemOf, listOf, renderAnswer } from "./envelope.js" @@ -319,11 +320,11 @@ export const checkStep = (program: Command, run: string): string[] => { } // A mistyped command reads like a profile word; when nothing follows that is a command, name the first word. if (at === program) return [`no command "${rest[0] ?? ""}"`] - const help = (at as unknown as { _getHelpOption: () => Option | null })._getHelpOption() + const help = helpOptionOf(at) const beforeDashes = rest.slice(index, rest.includes("--") ? rest.indexOf("--") : undefined) if (help && beforeDashes.some((word) => word === help.long || word === help.short)) return [] // A group with an action of its own runs as typed rather than asking for one of its children. - const runsItself = (at as unknown as { _actionHandler: unknown })._actionHandler != null + const runsItself = hasOwnAction(at) if (at.commands.length > 0 && !runsItself) return [`needs one of: ${at.commands.map((one) => one.name()).join(", ")}`] for (const command of chain) silent(command) const problems: string[] = [] diff --git a/src/cli/help/command-help.ts b/src/cli/help/command-help.ts index ecae64061..6cb47bfa4 100644 --- a/src/cli/help/command-help.ts +++ b/src/cli/help/command-help.ts @@ -2,6 +2,7 @@ import { metaOf } from "@wirecat/cli-base/commands" import { writes } from "@wirecat/cli-base/standards" import type { Argument, Command } from "commander" import { commandPathOf, outputOf } from "../command-contract.js" +import { hasOwnAction, isHidden } from "../commander-internals.js" import { environmentOf } from "../context.js" import { takesProfile } from "../profile.js" import { commandAt } from "../steps.js" @@ -104,13 +105,12 @@ export const nextUsually = (command: T, choice: NextChoice): const kindOfArgument = (argument: Argument): Kind | undefined => ARGUMENT_KINDS[argument.name()] -const runs = (command: Command): boolean => - command.commands.length === 0 || Boolean((command as Command & { _actionHandler?: unknown })._actionHandler) +const runs = (command: Command): boolean => command.commands.length === 0 || hasOwnAction(command) /** Every command that runs: the leaves, and a group that also runs on its own, such as `doctor`. */ const leaves = (command: Command): Command[] => command.commands - .filter((child) => !(child as Command & { _hidden?: boolean })._hidden) + .filter((child) => !isHidden(child)) .flatMap((child) => [...(runs(child) ? [child] : []), ...leaves(child)]) const rootOf = (command: Command): Command => { diff --git a/src/cli/messenger/lacks.ts b/src/cli/messenger/lacks.ts index 6c78e94e9..24de1f25c 100644 --- a/src/cli/messenger/lacks.ts +++ b/src/cli/messenger/lacks.ts @@ -1,6 +1,7 @@ import { CliError } from "@wirecat/cli-base" import type { Command } from "commander" import type { MessengerAdapter } from "../../ports/messenger.js" +import { hide, isHidden } from "../commander-internals.js" type Need = readonly [method: keyof MessengerAdapter, what: string] @@ -68,8 +69,6 @@ export const refuseLacking = (messenger: Lacking | undefined, path: readonly str if (need) throw new CliError("validation_error", `this messenger cannot ${need[1]}`) } -type Hideable = Command & { _hidden: boolean } - /** * Hides under `group` each command whose one method this messenger can `never` have, from help, `commands` and MCP; * typed anyway, it still refuses. A group left with nothing in sight is hidden too, since an empty group lists @@ -80,10 +79,9 @@ export const hideNever = (messenger: Lacking, group: T): T => for (const child of command.commands) { const at = [...path, child.name()] const need = COMMAND_NEEDS[at.join(" ")] - if (need && messenger.never?.includes(need[0])) (child as Hideable)._hidden = true + if (need && messenger.never?.includes(need[0])) hide(child) walk(child, at) - if (child.commands.length > 0 && child.commands.every((one) => (one as Hideable)._hidden)) - (child as Hideable)._hidden = true + if (child.commands.length > 0 && child.commands.every(isHidden)) hide(child) } } walk(group, [group.name()]) diff --git a/src/cli/messenger/search-answers.ts b/src/cli/messenger/search-answers.ts index 0236e5c03..474f15f1b 100644 --- a/src/cli/messenger/search-answers.ts +++ b/src/cli/messenger/search-answers.ts @@ -15,7 +15,6 @@ import { MAX_SEARCH_OFFSET } from "../../services/messages-archive-search.js" import type { MeaningSkipped } from "../../services/messages-discovery.js" import type { FoundNote, NotesFoundOf } from "../../services/notes-search.js" import type { SearchAllFound, SearchAllItem } from "../../services/search-all.js" -import type { SearchAllIncludingMeetingsFound } from "../../services/search-all-deprecated.js" import type { StoredHistorySkip } from "../../store/store.js" import { type ListBody, listOf } from "../envelope.js" import { nextStep } from "../steps.js" @@ -447,7 +446,7 @@ export const notesAnswer = ( /** `search all`, CLI and MCP alike. A meeting account whose index is still being built says so. */ export const allAnswer = ( command: string, - found: SearchAllFound | SearchAllIncludingMeetingsFound, + found: SearchAllFound, { limit, page, again }: Paging, exact = false, skips: StoredHistorySkip[] = [], diff --git a/src/cli/option-hints.ts b/src/cli/option-hints.ts index 6e0980f36..6b3b24c48 100644 --- a/src/cli/option-hints.ts +++ b/src/cli/option-hints.ts @@ -1,19 +1,18 @@ import { CliError, isCliError } from "@wirecat/cli-base" import type { Command } from "commander" import { commandPathOf } from "./command-contract.js" +import { onUnknownOption } from "./commander-internals.js" /** * A flag a command does not take, but an agent is likely to type, fails with what to type instead rather than * commander's bare "unknown option". */ export const withOptionHints = (command: Command, hints: Readonly>): Command => { - const unknown = command as unknown as { unknownOption: (flag: string) => never } - const fallback = unknown.unknownOption.bind(command) - unknown.unknownOption = (flag) => { + onUnknownOption(command, (flag, fallback) => { const hint = hints[flag.split("=")[0] as string] if (hint === undefined) return fallback(flag) return command.error(`unknown option '${flag}' — ${hint}`, { code: "commander.unknownOption" }) - } + }) return command } diff --git a/src/kit/run-scope.ts b/src/kit/run-scope.ts index 3a9b27c54..20857f030 100644 --- a/src/kit/run-scope.ts +++ b/src/kit/run-scope.ts @@ -4,6 +4,7 @@ import { tmpdir } from "node:os" import { join } from "node:path" import { metaOf } from "@wirecat/cli-base/commands" import type { Command } from "commander" +import { hasOwnAction } from "../cli/commander-internals.js" import { createProgram, type ProgramDefinition, type RunOptions, run } from "../cli/program.js" import { findRun, runsDirFor } from "../runs/run.js" @@ -47,7 +48,7 @@ interface Remote { } /** Commander keeps it private; a group with an action of its own, as `doctor` beside `doctor reports`, runs too. */ -const acts = (command: Command): boolean => (command as unknown as { _actionHandler?: unknown })._actionHandler != null +const acts = (command: Command): boolean => hasOwnAction(command) const remoteCommands = (program: Command, path: string[] = []): Remote[] => program.commands.flatMap((command) => { diff --git a/src/meetings/cli/query-options.ts b/src/meetings/cli/query-options.ts index 15c0d653f..384036038 100644 --- a/src/meetings/cli/query-options.ts +++ b/src/meetings/cli/query-options.ts @@ -1,4 +1,5 @@ import type { Command } from "commander" +import { helpOptionOf, rejectUnknownOption } from "../../cli/commander-internals.js" /** * Lets a query's `-kind:channel` through as a negated term while a mistyped `--limt` still fails as an unknown @@ -11,15 +12,13 @@ export const queryWordsAfterOptions = (command: Command): Command => { const parsed = parse(args) const end = parsed.unknown.indexOf("--") // Commander looks for --help in what parseOptions leaves unknown, after it returns. - const help = ( - command as unknown as { _getHelpOption: () => { is: (word: string) => boolean } | null } - )._getHelpOption() + const help = helpOptionOf(command) const typo = parsed.unknown .slice(0, end < 0 ? undefined : end) .find((word) => word.startsWith("--") && !help?.is(word)) if (typo !== undefined) { command.allowUnknownOption(false) - ;(command as unknown as { unknownOption: (flag: string) => never }).unknownOption(typo) + rejectUnknownOption(command, typo) } if (end >= 0) parsed.unknown.splice(end, 1) return parsed diff --git a/src/meetings/transcript-store.ts b/src/meetings/transcript-store.ts index 32a2be03d..82105e212 100644 --- a/src/meetings/transcript-store.ts +++ b/src/meetings/transcript-store.ts @@ -45,7 +45,6 @@ export interface DocumentMeeting { /** The meeting whose transcript a Drive document is, by the `driveFileId` the meeting's transcript named. */ export interface MeetingTranscriptDocumentStore { - transcriptMeetings(documentIds: readonly number[]): Promise> /** The meeting each document is a transcript, recording or notes of; a document of two meetings names the first. */ documentMeetings(documentIds: readonly number[]): Promise> } diff --git a/src/services/documents/ports.ts b/src/services/documents/ports.ts index 9062ea758..6114b3177 100644 --- a/src/services/documents/ports.ts +++ b/src/services/documents/ports.ts @@ -25,8 +25,6 @@ export interface SyncOptions { * sync goes on from there, so a tree of any size is synced over several calls. */ maxEntries: number - /** @deprecated No longer used: a walk past `maxEntries` stops and goes on in the next sync instead of failing. */ - limitError?(): CliError /** Asked before each folder listing and each file read: a stop ends the call with its work saved. */ budget?: { take(): "requests" | "deadline" | "cancelled" | null diff --git a/src/services/index.ts b/src/services/index.ts index 8d2b25408..a057925a6 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -634,14 +634,6 @@ export { type SearchedResource, searchAll, } from "./search-all.js" -export { - type MeetingSearchCoverage, - type MeetingSearchCursor, - type ResourceWithMeetings, - type SearchAllIncludingMeetingsFound, - type SearchAllIncludingMeetingsRequest, - searchAllIncludingMeetings, -} from "./search-all-deprecated.js" export { type MeetingAccountCoverage, type MeetingSearchItem, diff --git a/src/services/search-all-deprecated.ts b/src/services/search-all-deprecated.ts deleted file mode 100644 index 2ab8c5b19..000000000 --- a/src/services/search-all-deprecated.ts +++ /dev/null @@ -1,78 +0,0 @@ -import type { AccountKey, MessageStore } from "../store/store.js" -import type { SearchFound, SearchQuery } from "./messages.js" -import type { MeaningLane } from "./messages-discovery.js" -import { - type SearchAllFound, - type SearchAllMessenger, - type SearchAllRequest, - type SearchedResource, - searchAll, -} from "./search-all.js" - -/** @deprecated use `SearchedResource` — removed once zoom-cli moves (zoom-cli#344) */ -export type ResourceWithMeetings = SearchedResource - -/** @deprecated meetings are paged by `offset` — removed once zoom-cli moves (zoom-cli#344) */ -export interface MeetingSearchCursor { - accountId: number - query: string - meetingOffset: number - hitOffset: number -} - -/** @deprecated use `SearchAllRequest` — removed once zoom-cli moves (zoom-cli#344) */ -export interface SearchAllIncludingMeetingsRequest extends SearchAllRequest { - /** Read only this meeting account, as `scope.meetings`. */ - meetingAccount?: AccountKey - /** Ignored: every meeting of an account is read through its search index. */ - maxMeetings?: number | "all" - /** Ignored: the next page is `offset`. */ - meetingCursor?: MeetingSearchCursor -} - -/** @deprecated use `MeetingAccountCoverage` — removed once zoom-cli moves (zoom-cli#344) */ -export interface MeetingSearchCoverage { - accountId: number - by: "word-prefixes" - meetingsScanned: number - complete: boolean - nextCursor?: MeetingSearchCursor -} - -/** - * @deprecated use `SearchAllFound` — removed once zoom-cli moves (zoom-cli#344). `meetings` is never set: the index - * has no bounded scan to report. - */ -export interface SearchAllIncludingMeetingsFound extends Omit { - hasMore: boolean | null - meetings?: MeetingSearchCoverage -} - -/** @deprecated use `searchAll` with `scope.meetings` — removed once zoom-cli moves (zoom-cli#344) */ -export const searchAllIncludingMeetings = async ( - store: MessageStore, - account: AccountKey, - { - meetingAccount, - maxMeetings: _maxMeetings, - meetingCursor: _meetingCursor, - ...request - }: SearchAllIncludingMeetingsRequest, - messenger: SearchAllMessenger = {}, - searchMessages?: (query: SearchQuery) => Promise, - meaning?: MeaningLane, -): Promise => { - const { meetings: _meetings, ...found } = await searchAll( - store, - account, - { - ...request, - ...(meetingAccount === undefined ? {} : { scope: { ...request.scope, meetings: [meetingAccount] } }), - ...(request.only?.includes("meetings") ? { meetingsAsked: true } : {}), - }, - messenger, - searchMessages, - meaning, - ) - return found -} diff --git a/src/services/search-all-meetings.test.ts b/src/services/search-all-meetings.test.ts index 0c6c5bab4..264bcdfdd 100644 --- a/src/services/search-all-meetings.test.ts +++ b/src/services/search-all-meetings.test.ts @@ -15,7 +15,6 @@ import { refreshMeetingIndex } from "./meeting-hit-search.js" import { readMeetingPassage } from "./meeting-passage-format.js" import type { SearchFound } from "./messages.js" import { type SearchAllItem, type SearchAllRequest, searchAll } from "./search-all.js" -import { searchAllIncludingMeetings } from "./search-all-deprecated.js" import type { MeetingSearchItem } from "./search-all-meetings.js" const alice = { provider: "zoom", account: "zm-profile:alice" } @@ -517,21 +516,6 @@ describe("meetings in search all", () => { { source: `zoom:${alice.account}`, code: "validation_error", reason: READ_BUDGET_EXCEEDED }, ]) }) - - it("keeps the deprecated searchAllIncludingMeetings to the meeting account it names", async () => { - const { store, save } = await fixture() - await save(alice, "a", ["needle from alice"]) - await save(bob, "b", ["needle from bob"]) - const found = await searchAllIncludingMeetings(store, caller, { - text: "needle", - limit: 20, - only: ["meetings"], - meetingAccount: alice, - maxMeetings: 1, - }) - expect(texts(found.items)).toEqual(["needle from alice"]) - expect(found.meetings).toBeUndefined() - }) }) describe("a Meet transcript that Drive also imported", () => { @@ -591,6 +575,10 @@ describe("a Meet transcript that Drive also imported", () => { return saved } const asked = meetingsOnly({ only: ["notes", "meetings"] }) + const transcriptOf = async (store: MessageStore, id: number) => { + const found = (await store.meetings.documentMeetings([id])).get(id) + return found?.role === "transcript" ? found.meetingId : undefined + } it("shows the meeting once, whichever of the two the store holds first", async () => { for (const driveFirst of [true, false]) { @@ -598,7 +586,7 @@ describe("a Meet transcript that Drive also imported", () => { const document = driveFirst ? await transcriptDoc(store, "needle in the transcript") : undefined const saved = await withDocument(save, store) const id = document ?? (await transcriptDoc(store, "needle in the transcript")) - expect(await store.meetings.transcriptMeetings([id])).toEqual(new Map([[id, saved.meeting.id]])) + expect(await transcriptOf(store, id)).toBe(saved.meeting.id) const found = await searchAll(store, caller, asked) expect(found.items.filter((item) => item.ref === `document:${id}`)).toEqual([]) expect(meetingHits(found.items).length).toBeGreaterThan(0) @@ -609,9 +597,9 @@ describe("a Meet transcript that Drive also imported", () => { const { store, save } = await fixture() const saved = await withDocument(save, store) const id = await transcriptDoc(store, "needle in the transcript") - expect(await store.meetings.transcriptMeetings([id])).toEqual(new Map([[id, saved.meeting.id]])) + expect(await transcriptOf(store, id)).toBe(saved.meeting.id) await withDocument(save, store) - expect(await store.meetings.transcriptMeetings([id])).toEqual(new Map([[id, saved.meeting.id]])) + expect(await transcriptOf(store, id)).toBe(saved.meeting.id) const sample = sampleMeeting() await store.meetings.saveMeeting({ meeting: { ...sample.meeting, accountId: saved.accountId, externalId: "meet-1", title: "Invented call" }, @@ -626,7 +614,7 @@ describe("a Meet transcript that Drive also imported", () => { ], now: 5000, }) - expect(await store.meetings.transcriptMeetings([id])).toEqual(new Map()) + expect(await transcriptOf(store, id)).toBeUndefined() }) it("keeps the document's hit when the meeting is not among the hits", async () => { diff --git a/src/store/sqlite/meeting-documents.test.ts b/src/store/sqlite/meeting-documents.test.ts index 126351901..2d942b1fc 100644 --- a/src/store/sqlite/meeting-documents.test.ts +++ b/src/store/sqlite/meeting-documents.test.ts @@ -97,7 +97,6 @@ describe("a meeting's Drive documents", () => { [late, { meetingId, accountId, role: "notes" }], ]), ) - expect(await store.meetings.transcriptMeetings([early, late])).toEqual(new Map([[early, meetingId]])) }) it("a replay adds no second link and retitles; a list without a file, empty or failed keeps its link", async () => { diff --git a/src/store/sqlite/meeting-documents.ts b/src/store/sqlite/meeting-documents.ts index b303ec6a5..67f18aa05 100644 --- a/src/store/sqlite/meeting-documents.ts +++ b/src/store/sqlite/meeting-documents.ts @@ -147,11 +147,6 @@ export const meetingTranscriptDocumentsOver = ({ database }: StoreContext): Meet return found }) return { - async transcriptMeetings(documentIds) { - if (!documentIds.length) return new Map() - const found = await meetingsOf(documentIds, [TRANSCRIPT_ROLE]) - return new Map([...found].map(([document, { meetingId }]) => [document, meetingId])) - }, async documentMeetings(documentIds) { return documentIds.length ? meetingsOf(documentIds, MEETING_DOCUMENT_ROLES) : new Map() }, From 07a3443f19fab9cff14cce0ebe053befd7b1b121 Mon Sep 17 00:00:00 2001 From: leemour Date: Mon, 23 Nov 2026 23:18:56 +0100 Subject: [PATCH 02/48] refactor(store)!: ./store stops re-exporting the SQLite implementation ./store pointed at src/store/index.ts, the barrel cli-core's own modules use, so every row type, query constant and maintenance helper under src/store/sqlite/ was a public promise. ./store now points at src/store/public.ts: the same barrel without the ~390 names declared under src/store/sqlite/, except StoreOptions, which openStore takes. The 76 of those names that downstream CLIs import on main (mostly cli-memo; also drive, mail, zoom, beeline, notion) are re-exported from the new experimental entry ./store/areas under the same names. src/store/index.ts is unchanged for internal use. Checked with a TypeScript probe that copies dist away from drizzle-orm: no exported name of any entry has a member whose type fails to resolve (depth 5), before or after. Co-Authored-By: Claude Opus 5.5 --- changes/1.0-surface.md | 7 ++ package.json | 8 +- scripts/check-dist.ts | 2 +- src/store/areas.ts | 58 +++++++++ src/store/public.ts | 263 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 335 insertions(+), 3 deletions(-) create mode 100644 src/store/areas.ts create mode 100644 src/store/public.ts diff --git a/changes/1.0-surface.md b/changes/1.0-surface.md index 83eebaa10..7a82fd5ea 100644 --- a/changes/1.0-surface.md +++ b/changes/1.0-surface.md @@ -5,6 +5,13 @@ a few commander fields that have no public accessor, now all in one internal module with a test, and a new commander major is accepted only after that test passes on it. +- **`@wirecat/cli-core/store` no longer re-exports the SQLite implementation.** About 390 names declared under + `src/store/sqlite/` (maintenance helpers such as `resetAttachmentWords` and `backfillNormalized`, row types, + query constants and the area interfaces) left the entry. `openStore`, `StoreOptions`, `MessageStore`, `storePath` + and the other names declared outside `src/store/sqlite/` stay. The 76 of them that CLIs import moved to the new + experimental entry `@wirecat/cli-core/store/areas` under the same names: change the import path. The rest have no + importer; their types are still reachable as members of `MessageStore`, for example `MessageStore["mail"]`. + ### Removed - **`searchAllIncludingMeetings` and its types** (`ResourceWithMeetings`, `MeetingSearchCursor`, diff --git a/package.json b/package.json index fd4e8b584..20d6ad403 100644 --- a/package.json +++ b/package.json @@ -59,8 +59,12 @@ "default": "./dist/sqlite-runtime.js" }, "./store": { - "types": "./dist/store/index.d.ts", - "default": "./dist/store/index.js" + "types": "./dist/store/public.d.ts", + "default": "./dist/store/public.js" + }, + "./store/areas": { + "types": "./dist/store/areas.d.ts", + "default": "./dist/store/areas.js" }, "./cli": { "types": "./dist/cli/index.d.ts", diff --git a/scripts/check-dist.ts b/scripts/check-dist.ts index 003b88483..201713b69 100644 --- a/scripts/check-dist.ts +++ b/scripts/check-dist.ts @@ -34,7 +34,7 @@ const rows = await store.orm.select().from(accounts) store.database.close() if (rows.length !== 1) throw new Error(`bundled Drizzle read ${rows.length} rows, not 1`) -const { openStore } = await import(join(root, "store/index.js")) +const { openStore } = await import(join(root, "store/public.js")) const messages = await openStore({ path: join(scratch("cli-messaging-dist-"), "messages.db") }) const key = { provider: "telegram", account: "1" } const message = { diff --git a/src/store/areas.ts b/src/store/areas.ts new file mode 100644 index 000000000..2922fc33d --- /dev/null +++ b/src/store/areas.ts @@ -0,0 +1,58 @@ +/** + * Store area types and constants some CLIs use beyond the stable `@wirecat/cli-core/store`: experimental, so a + * minor release may change them. + */ +export { + type AddedSource, + type AddedSourceContent, + type AddedSourceInput, + addedSourceKeyOf, +} from "./sqlite/added-sources.js" +export type { ContractFilter } from "./sqlite/business-contracts.js" +export type { CatalogEntry, CatalogInput, CatalogQuery } from "./sqlite/catalog.js" +export type { CrmChange, CrmChangeKind } from "./sqlite/crm-changes.js" +export type { Deal, DealFilter, Pipeline, PipelineReport } from "./sqlite/deals.js" +export type { EmailInput, FolderEmail, MailboxInput } from "./sqlite/emails.js" +export { type EvidenceInput, QUOTE_LIMIT, quoteKept } from "./sqlite/evidence-signature.js" +export type { Fact } from "./sqlite/facts.js" +export type { Invoice, Payment as FinancePayment } from "./sqlite/finance.js" +export type { IdentityRekey } from "./sqlite/identity-rekey.js" +export { IMPORTED_DOCUMENT_QUERY } from "./sqlite/imported-documents.js" +export { + type KnowledgeRelation, + type KnowledgeTarget, + ORGANIZATION_KINDS, + type Organization, + PROJECT_TYPES, + type Project, + SCOPES, +} from "./sqlite/knowledge.js" +export type { MeetingVectors } from "./sqlite/meeting-vectors.js" +export type { Author, Memory } from "./sqlite/memories.js" +export type { TransactionFilter } from "./sqlite/money-transactions.js" +export type { Link, LinkInput, LinkListFilter, Note } from "./sqlite/notes.js" +export type { OrderFilter } from "./sqlite/orders.js" +export type { OrganizationErasure } from "./sqlite/organization-erase.js" +export { type ListedPerson, PEOPLE_SORTS, type PeopleSort } from "./sqlite/people-list.js" +export type { PersonDoubt } from "./sqlite/person-doubts.js" +export type { PersonErasure } from "./sqlite/person-erase.js" +export { type PersonMerge, parseMergeId } from "./sqlite/person-merges.js" +export type { ProductFilter } from "./sqlite/products.js" +export { PROPOSAL_STATUSES, type ProposedAction } from "./sqlite/proposed-actions.js" +export type { MatchRun, RecordKey } from "./sqlite/records.js" +export type { RelationListItem } from "./sqlite/relation-list.js" +export type { SubscriptionFilter } from "./sqlite/subscriptions.js" +export { PROJECT_TASK_FIELDS, TASK_SORTS, type TaskSort } from "./sqlite/task-board.js" +export { TASK_RELATION_KINDS, type TaskRelationKind } from "./sqlite/task-relations.js" +export type { TemplateAddress } from "./sqlite/templates.js" +export type { VocabularyKind, VocabularyOptions, VocabularyTarget } from "./sqlite/vocabulary.js" +export type { Wallet, WalletFilter } from "./sqlite/wallets.js" +export { + TASK_ROLES, + type TaskDetails, + type TaskFields, + type TaskRole, + type TaskType, + type WorkTaskType, +} from "./sqlite/work-tasks.js" +export { MENTION_QUERY, type StoredTag, type TagTarget } from "./store.js" diff --git a/src/store/public.ts b/src/store/public.ts new file mode 100644 index 000000000..fbfa0d79e --- /dev/null +++ b/src/store/public.ts @@ -0,0 +1,263 @@ +export type { + ContextEvidenceItem, + ContextEvidencePage, + ContextEvidenceReader, + ContextEvidenceRequest, + ContextEvidenceSender, + ContextSource, +} from "../context/evidence.js" +export { BUSINESS_KINDS, type BusinessKind } from "../domain/business.js" +export { + FACT_STATUSES, + FACT_TYPES, + MEMORY_KINDS, + MEMORY_SCOPES, + MEMORY_STATUSES, + TASK_TYPES, + WORK_TASK_TYPES, +} from "../domain/knowledge.js" +export { type KindSignal, PERSON_KINDS, type PersonKind } from "../domain/person-kinds.js" +export type { RefState, RefSummary, RefSummaryKind, RefsStore } from "../domain/ref-summaries.js" +export type { + TagConsolidationApplyOptions, + TagConsolidationOptions, + TagConsolidationPreview, + TagConsolidationReceipt, + TagConsolidationStore, +} from "../domain/tag-consolidation.js" +export type { TagRedirectIndex, TagRedirectResolution, TagRedirectSnapshot } from "../domain/tag-redirects.js" +export { createTagRedirectIndex } from "../domain/tag-redirects.js" +export { note } from "../entities/note.js" +export type { + FindingEvidence, + FindingOutcome, + MeetingContextReadCapabilities, + MeetingFactFinding, + MeetingFinding, + MeetingFindingsInput, + MeetingFindingsReceipt, + MeetingReadCapabilities, + MeetingReadScope, + MeetingTaskFinding, + TranscriptContextInput, + TranscriptContextPage, + TranscriptPage, + TranscriptReadScope, + TranscriptRowPage, +} from "../meetings/index.js" +export { PAYMENT_DIRECTIONS, PAYMENT_STATES, type Payment, paymentTitle, validatePayment } from "../meetings/index.js" +export { + CLOSED_STATES, + isClosedState, + PRIORITY_LABELS, + type PriorityLabel, + priorityLabel, + priorityOf, + priorityOption, + TASK_STATES, + type TaskState, +} from "../tasks/index.js" +export type { AccountMail, AccountMeetings, AccountStore } from "./account-store.js" +export { + type DamageCause, + type DamageFindings, + type RecoveryStep, + type StoreDamageReport, + storeDamageReport, +} from "./damage.js" +export { + CALLBACK_PREFIX, + callbackDataOf, + DECISION_ACTIONS, + DECISION_TTL_MS, + type DecisionAction, + isDecisionToken, + parseCallbackData, +} from "./decision-requests.js" +export { + assertMayDecide, + DEFAULT_DECISION_POLICY, + type Decider, + type DecisionPolicy, + isOwnerOnlyKind, + mayDecide, + type Proposer, + type Refusal, +} from "./decisions.js" +export type { + DocumentTransferOptions, + DocumentTransferPreview, + DocumentTransferReceipt, +} from "./document-transfer/index.js" +export { applyDocumentTransfer, previewDocumentTransfer } from "./document-transfer/index.js" +export type { CacheDatabase, CacheStatement, OpenDatabase, SqlValue } from "./driver.js" +export { PRAGMAS } from "./driver.js" +export { + type CitableRecord, + EVIDENCE_FINDINGS_KIND, + type EvidenceFindingsBatch, + type EvidenceFindingsDecider, + type EvidenceFindingsReceipt, + type EvidenceFindingsStore, + validateEvidenceFindings, +} from "./evidence-findings.js" +export { + type DamagedTable, + type InvalidJson, + QUICK_HEALTH_CHECKS, + type SearchIndexHealth, + type StoreHealth, + storeHealth, +} from "./health.js" +export { + type AgentLink, + type AgentLinkInput, + type AgentMerge, + IDENTITY_LINK_KIND, + IDENTITY_LINK_SIGNALS, + type IdentityLinkDecision, + type IdentityLinkFilter, + type IdentityLinkInput, + type IdentityLinkPayload, + type IdentityLinkRow, + type IdentityLinkSignal, + LINK_WEAKNESSES, + type LinkEvidence, + type LinkFact, + type LinkHold, + type LinkWeakness, + type MatchScan, + type SharedMailbox, +} from "./identity-links.js" +export { + IDENTITY_SPLIT_KIND, + type IdentitySplitDecision, + type IdentitySplitFilter, + type IdentitySplitInput, + type IdentitySplitMove, + type IdentitySplitPayload, + type IdentitySplitRow, +} from "./identity-splits.js" +export { + ORGANIZATIONS_QUERY, + organization, + PROJECTS_QUERY, + project, + REMINDERS_QUERY, + reminder, +} from "./knowledge-query.js" +export { + MAIL_FINDINGS_KIND, + type MailFindingsBatch, + type MailFindingsCheck, + type MailFindingsStore, +} from "./mail-findings.js" +export { + clearDamageMark, + type DamageMark, + damageMarkPath, + type HealthMark, + healthMarkPath, + type JournalMark, + journalMarkPath, + markStoreDamaged, + readDamageMark, + readHealthMark, + readJournalMark, + recordDeepCheck, +} from "./marks.js" +export type { MeetingFindingsBatch, MeetingFindingsStore } from "./meeting-findings.js" +export { MIGRATIONS, type Migration, migrate } from "./migrations.js" +export { openCache } from "./open.js" +export { storePath } from "./path.js" +export { + decodeProjectAnnotations, + PROJECT_ANNOTATIONS_MAX_BYTES, + type ProjectAnnotations, + projectAnnotationsFingerprint, +} from "./project-transfer/manifest.js" +export { + type ProjectAnnotationsPlan, + type ProjectAnnotationsTarget, + planProjectAnnotations, +} from "./project-transfer/plan.js" +export { + type ProjectAnnotationPreview, + type ProjectAnnotationPreviewOptions, + previewProjectAnnotationSnapshot, +} from "./project-transfer/preview.js" +export { + decodeProjectAnnotationSnapshot, + type ProjectAnnotationSnapshot, + type ProjectAnnotationSnapshotOptions, + type ProjectAnnotationSnapshotResult, + projectAnnotationSnapshotFingerprint, + projectAnnotationSnapshotSchema, + snapshotProjectAnnotations, +} from "./project-transfer/snapshot.js" +export { planProjectAnnotationSnapshot } from "./project-transfer/snapshot-plan.js" +export type { + ProjectAnnotationRestoreReceipt, + ProjectAnnotationRestoreRequest, + ProjectAnnotationStore, + ProjectAnnotationTargetRequest, +} from "./project-transfer/store.js" +export { registerProvider } from "./providers.js" +export { + type ChangedSource, + SOURCE_REVIEW_CAUSES, + SOURCE_REVIEW_KIND, + type SourceCheck, + type SourceReviewCause, + type SourceReviewChallenge, + type SourceReviewMarker, + type SourceReviewPayload, + type SourceReviewSource, + type SourceReviewText, +} from "./source-review.js" +export { + type AccountAccounts, + type AccountAttachments, + type AccountCounters, + type AccountGroupChange, + type AccountKey, + type AccountMentions, + type AccountMessageFilter, + type AccountMessages, + type AccountPeople, + type AccountsStore, + type AccountVectors, + type AttachmentsStore, + type ChatStats, + type ChatsStore, + type ConversationsStore, + type CountersStore, + type DeletionScope, + type Delta, + type IdentityRef, + type IngestedVia, + type LinkedIdentity, + type LinkOptions, + type MentionsStore, + type MessageFilter, + type MessageStore, + type MessagesStore, + openStore, + type PeopleStore, + type PersonFacts, + type PersonRecord, + type QueriesStore, + type Range, + type RosterStore, + type SearchesStore, + type SearchIndexStore, + type StoredAccount, + type StoredChatFilter, + type StoredHit, + type StoreOptions, + type SyncStore, + type TagsStore, + type TaskAnalysisMark, + type TaskAnalysisMarkWrite, + type VectorsStore, +} from "./store.js" From 57d5369586bc522cf4f8a021e4cd1a1d4c6dc3b8 Mon Sep 17 00:00:00 2001 From: leemour Date: Mon, 23 Nov 2026 23:22:36 +0100 Subject: [PATCH 03/48] docs: doc comments that ship in .d.ts say why instead of citing private ids MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit About 120 references to a private journal (NEED-…, SEC-…, BUG-…, FIND-…) sat in doc comments that tsc copies into the published .d.ts files, where readers cannot resolve them. Each is removed where the sentence already says why, or replaced by the plain reason. Plain // comments, which do not ship, are unchanged. docs:check now fails when a built .d.ts carries such an id. Co-Authored-By: Claude Opus 5.5 --- scripts/docs-check.ts | 17 +++++++++- src/attachments/extract.ts | 2 +- src/calendar/sync.ts | 2 +- src/cli/author.ts | 2 +- src/cli/config-command.ts | 7 ++-- src/cli/config-issues.ts | 2 +- src/cli/context.ts | 2 +- src/cli/early-refusal.ts | 8 ++--- src/cli/effects.ts | 12 +++---- src/cli/messenger/admin-moderation-command.ts | 2 +- src/cli/messenger/ask.ts | 2 +- src/cli/messenger/context.ts | 2 +- src/cli/messenger/inbox.ts | 4 +-- src/cli/messenger/mcp-command.ts | 2 +- src/cli/messenger/messages-delete-command.ts | 2 +- src/cli/messenger/serve-command.ts | 2 +- src/cli/messenger/serve-outdated.ts | 2 +- src/cli/messenger/serve-relay.ts | 2 +- src/cli/messenger/server-command.ts | 2 +- src/cli/permission-keys.ts | 2 +- src/cli/provider-refs.ts | 2 +- src/cli/search-left-out.ts | 2 +- src/cli/shadowed-options.ts | 2 +- src/cli/unknown-profile.ts | 2 +- src/content/writer.ts | 2 +- src/crm/cli/files.ts | 2 +- src/crm/cli/index.ts | 2 +- src/crm/cli/records.ts | 2 +- src/crm/digest.ts | 2 +- src/crm/foreign-contacts.ts | 4 +-- src/crm/source.ts | 4 +-- src/crm/viewer.ts | 6 ++-- src/crm/writes.ts | 6 ++-- src/domain/categories.ts | 2 +- src/domain/config-repair.ts | 2 +- src/domain/crm.ts | 2 +- src/domain/send-time.ts | 3 +- src/mcp/agent.ts | 2 +- src/mcp/all-profiles.ts | 2 +- src/mcp/http/oauth.ts | 2 +- src/mcp/http/serve.ts | 2 +- src/mcp/server.ts | 2 +- src/mcp/session.ts | 4 +-- src/mcp/surface.ts | 2 +- src/moderation/rules.ts | 6 ++-- src/readers/engine.ts | 4 +-- src/replies/rules.ts | 3 +- src/replies/serve.ts | 2 +- src/runs/events.ts | 2 +- src/search/question-plan.ts | 6 ++-- src/sends/permissions.ts | 8 ++--- src/sends/send-as.ts | 2 +- src/services/business-context.ts | 4 +-- src/services/deal-context.ts | 2 +- src/services/embeddings.ts | 6 ++-- src/services/moderation.ts | 2 +- src/services/organization-context.ts | 2 +- src/services/people.ts | 2 +- src/services/person-business.ts | 2 +- src/services/search-all.ts | 6 ++-- src/speech/hearing.ts | 2 +- src/speech/models.ts | 2 +- src/store/damage.ts | 2 +- src/store/identity-links.ts | 2 +- src/store/open.ts | 2 +- src/store/people.ts | 8 ++--- src/store/repair.ts | 4 +-- src/store/sqlite-warning.ts | 2 +- src/store/sqlite/completeness.ts | 2 +- src/store/sqlite/conversations.ts | 2 +- src/store/sqlite/copy-viewer.ts | 2 +- src/store/sqlite/crm-activities.ts | 2 +- src/store/sqlite/crm-changes.ts | 2 +- src/store/sqlite/crm-files.ts | 2 +- src/store/sqlite/crm-settings.ts | 2 +- src/store/sqlite/crm.ts | 4 +-- src/store/sqlite/identity-link-rows.ts | 2 +- src/store/sqlite/messages.ts | 2 +- src/store/sqlite/name-traces.ts | 2 +- src/store/sqlite/organization-categories.ts | 2 +- src/store/sqlite/person-links.ts | 6 ++-- src/store/sqlite/person-match-scan.ts | 34 +++++++++---------- src/store/sqlite/pipeline-period.ts | 2 +- src/store/sqlite/relation-list.ts | 2 +- src/store/sqlite/vectors.ts | 2 +- src/store/types.ts | 2 +- 86 files changed, 155 insertions(+), 143 deletions(-) diff --git a/scripts/docs-check.ts b/scripts/docs-check.ts index e1c018a63..5412fc39e 100644 --- a/scripts/docs-check.ts +++ b/scripts/docs-check.ts @@ -9,7 +9,7 @@ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs" import { dirname, join, relative, resolve, sep } from "node:path" import { fileURLToPath } from "node:url" import { fragmentProblems, readFragments } from "./changelog-fragments.ts" -import { changelogProblems, taggedVersions } from "./changelog-shape.ts" +import { changelogProblems, ID, taggedVersions } from "./changelog-shape.ts" const SKIPPED = new Set(["node_modules", "dist", "coverage", ".git", ".worktrees", "docs_ai"]) @@ -101,7 +101,22 @@ const linkProblems = (base: string): string[] => { return problems } +/** Doc comments ship in the `.d.ts` files of this public package, where a private journal's ids mean nothing. */ +const declarationIdProblems = (dist: string): string[] => + existsSync(dist) + ? readdirSync(dist, { recursive: true, encoding: "utf8" }) + .filter((name) => name.endsWith(".d.ts")) + .flatMap((name) => + readFileSync(join(dist, name), "utf8") + .split("\n") + .flatMap((line, index) => + (line.match(ID) ?? []).map((id) => `dist/${name}:${index + 1}: internal id ${id} — say why instead`), + ), + ) + : [] + const problems = [ + ...declarationIdProblems(join(root, "dist")), ...changelogProblems(readFileSync(join(root, "CHANGELOG.md"), "utf8"), taggedVersions(root)), ...readFragments(root).flatMap(fragmentProblems), ...linkProblems(root), diff --git a/src/attachments/extract.ts b/src/attachments/extract.ts index d273fdbe2..71226b4ea 100644 --- a/src/attachments/extract.ts +++ b/src/attachments/extract.ts @@ -15,7 +15,7 @@ const extensionOf = ({ name, path }: FileHint) => extname(name ?? path).toLowerC /** * Only an exact text layer: plain text, a Word document, a PDF that carries its text. A photo, a scan - * or a PDF of pictures is an agent's to read (owner, NEED-546: no OCR in the tool). + * or a PDF of pictures is an agent's to read (the owner's decision: no OCR in the tool). */ export const extractText = async ( bytes: Uint8Array, diff --git a/src/calendar/sync.ts b/src/calendar/sync.ts index a6132435c..7447206ae 100644 --- a/src/calendar/sync.ts +++ b/src/calendar/sync.ts @@ -136,7 +136,7 @@ export const parseCalendarCursor = (value: string | null): CalendarCursor | null } /** - * One year back and three months ahead (NEED-1706), from the start of today in UTC. Whole days, so the window moves + * One year back and three months ahead, from the start of today in UTC. Whole days, so the window moves * once a day: a source whose cursor holds the window lists everything again once a day, not on every run. */ export const calendarSyncWindow = (now: number): SyncWindow => { diff --git a/src/cli/author.ts b/src/cli/author.ts index 8be6f78bd..aaa71acbd 100644 --- a/src/cli/author.ts +++ b/src/cli/author.ts @@ -12,7 +12,7 @@ export const authorOf = (env: NodeJS.ProcessEnv, asOwner?: boolean): string => /** * Who holds a task claim — one agent session, not the agent's name, so two sessions of one agent do not share one - * claim (owner, NEED-1119). `--holder`, then `WIRECAT_HOLDER`, then the agent's own session id where it sets one + * claim (the owner's decision). `--holder`, then `WIRECAT_HOLDER`, then the agent's own session id where it sets one * (Claude Code, Codex, OpenCode, Hermes), else the agent's name. */ export const holderOf = (env: NodeJS.ProcessEnv, flag?: string): string => { diff --git a/src/cli/config-command.ts b/src/cli/config-command.ts index e05c95274..baed2062b 100644 --- a/src/cli/config-command.ts +++ b/src/cli/config-command.ts @@ -266,7 +266,7 @@ const migrateCommand = (app: AppIdentity, config: Configuration): Command => }) /** - * Mends JSON syntax with one reading and keeps every value (NEED-2178): no network, no AI, since the file may hold + * Mends JSON syntax with one reading and keeps every value: no network, no AI, since the file may hold * keys. Anything else is refused with nothing changed. */ const repairCommand = (app: AppIdentity, config: Configuration): Command => @@ -337,7 +337,7 @@ const repairCommand = (app: AppIdentity, config: Configuration): Command => }) /** - * A key no command or write is checked against would be saved and do nothing (BUG-137) — whether it + * A key no command or write is checked against would be saved and do nothing — whether it * comes as `permissions.` or inside a whole `permissions` object. */ export const refuseUnknownKey = ( @@ -372,8 +372,7 @@ export const refuseUnknownKey = ( /** * An agent may hold `mcp.authority` or `bot.api` and change other settings, but never the key that let it in: on any - * profile, in the defaults, or by replacing `permissions` whole. Only the owner, in a terminal, turns it on or off - * (NEED-1662, NEED-1679). + * profile, in the defaults, or by replacing `permissions` whole. Only the owner, in a terminal, turns it on or off. */ export const refuseGuardedKey = (setting: string, value: string | undefined, ownerOnly: OwnerOnlySettings): void => { if (ownerOnly.settings?.includes(setting)) diff --git a/src/cli/config-issues.ts b/src/cli/config-issues.ts index 8a766e594..9efb32e83 100644 --- a/src/cli/config-issues.ts +++ b/src/cli/config-issues.ts @@ -275,7 +275,7 @@ export const savedPermissionKeys = (raw: unknown): { key: string; at: string[] } : [], ) -/** A saved key no command checks would do nothing (BUG-137): one issue per key, wherever it is saved. */ +/** A saved key no command checks would do nothing: one issue per key, wherever it is saved. */ export const permissionIssues = ( saved: readonly { key: string; at: readonly string[] }[], known: ReadonlySet, diff --git a/src/cli/context.ts b/src/cli/context.ts index cabafcf53..c8e84dd0f 100644 --- a/src/cli/context.ts +++ b/src/cli/context.ts @@ -98,7 +98,7 @@ export interface BaseEnvironment { /** * The command's answer and error go to the MCP server as objects, never as text. A write at level `ask` goes - * ahead (NEED-773): nobody is at a terminal, and the profile's permissions already decided. + * ahead: nobody is at a terminal, and the profile's permissions already decided. */ export interface AgentRun { result: (value: unknown) => void diff --git a/src/cli/early-refusal.ts b/src/cli/early-refusal.ts index e68331181..42a7e9924 100644 --- a/src/cli/early-refusal.ts +++ b/src/cli/early-refusal.ts @@ -40,10 +40,10 @@ export const refuseOfflineCommand = (action: Command, app: AppIdentity, offline: type Resolve = (flags: object, options: { env: NodeJS.ProcessEnv; needsProfile: false; readOnly: true }) => object /** - * Refuses a change on the messenger the read-only lock or the profile's level stops, before anything connects - * (SEC-62). The send guard would refuse it too, but only after the command connected and found its chat. The journal + * Refuses a change on the messenger the read-only lock or the profile's level stops, before anything connects. + * The send guard would refuse it too, but only after the command connected and found its chat. The journal * gets the shorter line this knows: the command's key and kind, and the chat only when the command was given its id. - * A preview journals nothing, and the lock refuses it as well: it answers as the write would (SEC-65). + * A preview journals nothing, and the lock refuses it as well: it answers as the write would. */ export const refuseWriteBeforeConnecting = ( action: Command, @@ -107,7 +107,7 @@ export const refuseWriteBeforeConnecting = ( * the read-only lock stops a write to the service; a command that declares no effects counts as both. `ask` is left to the write * guard, which can put the question. A saved or `--permission` key that names no command stops every keyed command; * housekeeping still runs, so `config unset` can remove it. Under the lock a non-messenger CLI still previews a - * `--dry-run`, which sends nothing (WC-PERM-12); a messenger's preview stays refused (SEC-65). + * `--dry-run`, which sends nothing (WC-PERM-12); a messenger's preview stays refused. */ export const refuseByCommandPermissions = ( action: Command, diff --git a/src/cli/effects.ts b/src/cli/effects.ts index b2e2825ae..b156e109e 100644 --- a/src/cli/effects.ts +++ b/src/cli/effects.ts @@ -27,8 +27,8 @@ const AUTHORITY = new WeakMap() /** * Marks a local write that changes what a later run may do: a schedule, a setting, the recipient list, an * auto-reply, an agent's setup. `_READ_ONLY` refuses it, or an agent under the lock could hand an - * unlocked run the send it may not make itself (SEC-47). For the same reason an MCP server permits execution only where the - * profile allows `mcp.authority`, which is off until the owner turns it on (NEED-1662). + * unlocked run the send it may not make itself. For the same reason an MCP server permits execution only where the + * profile allows `mcp.authority`, which is off until the owner turns it on. * `unless` names a flag that makes the run only look (`upgrade --check`), which the lock lets through. */ export const grantsAuthority = (command: T, { unless }: { unless?: string } = {}): T => { @@ -273,8 +273,8 @@ const pathOf = (command: Command): string[] => { } /** - * A change on the messenger, judged from the command alone, so the read-only lock refuses it before anything connects - * (SEC-62): the send guard refuses it too, but only once the command has connected and found its chat. A server that runs until stopped, a call to another service and a login (no key) have rules of their own. + * A change on the messenger, judged from the command alone, so the read-only lock refuses it before anything connects: + * the send guard refuses it too, but only once the command has connected and found its chat. A server that runs until stopped, a call to another service and a login (no key) have rules of their own. */ export const changesMessenger = ( command: Command | Pick, @@ -309,7 +309,7 @@ export const ownerOnlyOption = (flags: string, description: string): Option => annotateOption(new Option(flags, description), { mcp: false }) /** - * The effects a retry or an unasked step is judged on (NEED-1073): only what the service sees. Running a sync or a + * The effects a retry or an unasked step is judged on: only what the service sees. Running a sync or a * cached read twice rewrites the same local rows, so a local write alone never makes either unsafe. Unknown stays * unknown, which cli-base counts as a write. */ @@ -319,7 +319,7 @@ export const judgedEffects = (effects: Effects | undefined): Effects | undefined /** * An unasked step is judged stricter than a retry: only a fetch's local write is incidental. A command that reads * nothing remotely and writes here (`server restart`, `store rebuild`) is the whole point of the step, so it waits - * to be asked (RISK-1211). + * to be asked. */ const judgedStepEffects = (effects: Effects | undefined): Effects | undefined => effects?.remote === "none" ? effects : judgedEffects(effects) diff --git a/src/cli/messenger/admin-moderation-command.ts b/src/cli/messenger/admin-moderation-command.ts index a217b54cb..35a25c51e 100644 --- a/src/cli/messenger/admin-moderation-command.ts +++ b/src/cli/messenger/admin-moderation-command.ts @@ -47,7 +47,7 @@ export const rulesCommand = (messenger: Messenger): Command => { } /** - * **The one command that acts on a group's rules** (max-cli `NEED-306`): typing it is the consent + * **The one command that acts on a group's rules**: typing it is the consent * for what the rules name, within each action's level in the group's rules. Nothing watches groups * in the background. */ diff --git a/src/cli/messenger/ask.ts b/src/cli/messenger/ask.ts index 97e63b264..588b17802 100644 --- a/src/cli/messenger/ask.ts +++ b/src/cli/messenger/ask.ts @@ -55,7 +55,7 @@ export const answerOf = async (command: Command, question: string): Promise(work: (adapter: MessengerAdapter) => Promise export interface MessengerContext extends BaseContext { profile: string - /** Run for an agent over MCP, where a write at level `ask` goes ahead: nobody is at a terminal (NEED-773). */ + /** Run for an agent over MCP, where a write at level `ask` goes ahead: nobody is at a terminal. */ agent: boolean stdin: NodeJS.ReadableStream & { isTTY?: boolean } /** The local speech recognizer, where a test hands one in. */ diff --git a/src/cli/messenger/inbox.ts b/src/cli/messenger/inbox.ts index f31c58929..cebe20820 100644 --- a/src/cli/messenger/inbox.ts +++ b/src/cli/messenger/inbox.ts @@ -21,13 +21,13 @@ export const PARTIAL_NOTE = "the messenger did not list every chat, and did not say how many it left out; one may have more" /** - * Two questions, one command — max-cli's `inbox` (its `NEED-171`). + * Two questions, one command — max-cli's `inbox`. * * **Plain `inbox` — what is unread**, as the messenger counts it. For a person. * * **`--new` — what arrived since the last check.** For a scheduled run: the point it starts from is * kept per chat and moved only by a run that printed, so each message shows once, and a run that - * fails shows it again rather than never (max-cli `NEED-162`). `lastCheckAt`, the first check, stays + * fails shows it again rather than never. `lastCheckAt`, the first check, stays * put: it is where a chat never read yet starts, so a chat skipped by one run is not lost. * `date>2h` is a one-off look from a time of your choosing and leaves the points where they were. */ diff --git a/src/cli/messenger/mcp-command.ts b/src/cli/messenger/mcp-command.ts index 5e754f31f..e212c756e 100644 --- a/src/cli/messenger/mcp-command.ts +++ b/src/cli/messenger/mcp-command.ts @@ -60,7 +60,7 @@ export interface ProfileSet { } /** - * The profile or profiles an MCP server is for, always named (NEED-1881, WC-MCP-9): a leading profile, or + * The profile or profiles an MCP server is for, always named (WC-MCP-9): a leading profile, or * `--profiles` with a list or `all`. Neither, or both, is refused with the profiles on this computer. `--profiles` * takes the place of `_PROFILE`; under `_PROFILE_LOCK` it may name the locked profile only * (WC-ACCT-5). diff --git a/src/cli/messenger/messages-delete-command.ts b/src/cli/messenger/messages-delete-command.ts index 48fdcfdfa..fb5e28106 100644 --- a/src/cli/messenger/messages-delete-command.ts +++ b/src/cli/messenger/messages-delete-command.ts @@ -11,7 +11,7 @@ import { type Messenger, messengerContext } from "./context.js" /** * Deletes without a question at the default level, `allow` (owner, 2026-11-14); a profile at `ask` gets the * question, and `--allow-dangerous` is the yes. For everyone only - * with `--for-everyone` (max-cli `NEED-239`), and never for an agent (NEED-1423). + * with `--for-everyone`, and never for an agent. */ export const deleteCommand = (messenger: Messenger): Command => { const command = annotate(new Command("delete"), { diff --git a/src/cli/messenger/serve-command.ts b/src/cli/messenger/serve-command.ts index fe70685c1..cc5d38f44 100644 --- a/src/cli/messenger/serve-command.ts +++ b/src/cli/messenger/serve-command.ts @@ -41,7 +41,7 @@ const CURRENT_EVERY_MS = 60_000 /** * Keeps the store current: every new message, edit, deletion and reaction, and on start what arrived * while nothing listened. **One per profile**, held by a lock file; a lock whose process is gone is - * taken over. Started by a person, a service unit or `server start` — never by itself (NEED-9). + * taken over. Started by a person, a service unit or `server start` — never by itself. */ export const serveCommand = (messenger: Messenger): Command => { const command = annotate(new Command("serve"), { diff --git a/src/cli/messenger/serve-outdated.ts b/src/cli/messenger/serve-outdated.ts index 05b84d648..1ef928985 100644 --- a/src/cli/messenger/serve-outdated.ts +++ b/src/cli/messenger/serve-outdated.ts @@ -40,7 +40,7 @@ const newer = (one: string, other: string): boolean => { } /** - * Why this serve should stop so its unit starts the installed build (BUG-643): the store moved past what this build + * Why this serve should stop so its unit starts the installed build: the store moved past what this build * may write, or a newer version was installed over it. A store that cannot be read now is not a reason. */ export const outdatedReason = async ({ diff --git a/src/cli/messenger/serve-relay.ts b/src/cli/messenger/serve-relay.ts index 6b1807c6e..d12d98803 100644 --- a/src/cli/messenger/serve-relay.ts +++ b/src/cli/messenger/serve-relay.ts @@ -49,7 +49,7 @@ export const lentConnection = ( } as unknown as MessengerAdapter) /** - * serve's side of the relay (NEED-1389): it keeps the raw connection its messenger opened and lends it to the + * serve's side of the relay: it keeps the raw connection its messenger opened and lends it to the * commands clients send it. A borrowed connection never closes serve's, never feeds the store a second time, and * listens through serve's own events instead of a second `watch`. */ diff --git a/src/cli/messenger/server-command.ts b/src/cli/messenger/server-command.ts index d47c5fbe2..7f35f96e5 100644 --- a/src/cli/messenger/server-command.ts +++ b/src/cli/messenger/server-command.ts @@ -107,7 +107,7 @@ const lockProcess = /** * `serve` in the background: `start`, `stop`, `restart`, `status`, `logs`. Without a unit, `start` * runs `serve` as a process of its own; with one — `install`, a systemd user unit or a launchd - * agent — it goes through systemd or launchd. **Nothing starts now until `start` is typed** (NEED-9): + * agent — it goes through systemd or launchd. **Nothing starts now until `start` is typed**: * `install` writes the file and enables it, so it starts with every session from the next login (or boot, * under linger) until `uninstall`. What the server does stays each CLI's; `options.process` says how to find, * start and stop it. diff --git a/src/cli/permission-keys.ts b/src/cli/permission-keys.ts index 1daa253c7..725cfa5ba 100644 --- a/src/cli/permission-keys.ts +++ b/src/cli/permission-keys.ts @@ -90,7 +90,7 @@ const everyCommand = (command: Command): Command[] => [command, ...command.comma /** * The keys `permissions` may name: every command of the program, every write key, and each of their - * parents. A key outside it is a typo that would otherwise do nothing (BUG-137). + * parents. A key outside it is a typo that would otherwise do nothing. */ export const knownPermissionKeys = ( command: Command, diff --git a/src/cli/provider-refs.ts b/src/cli/provider-refs.ts index aaaee9f1f..04fc6e53b 100644 --- a/src/cli/provider-refs.ts +++ b/src/cli/provider-refs.ts @@ -2,7 +2,7 @@ const HIDDEN = new Set(["providerRef", "provider_ref"]) /** * The value with every `providerRef` taken out, at any depth. An adapter keeps there what it needs to fetch a file - * again — WhatsApp's media path and decryption keys, a MAX bot's token — so it never leaves the process (SEC-54). + * again — WhatsApp's media path and decryption keys, a MAX bot's token — so it never leaves the process. */ export const withoutProviderRefs = (value: T): T => strip(value) as T diff --git a/src/cli/search-left-out.ts b/src/cli/search-left-out.ts index 3831f1218..1ee97130c 100644 --- a/src/cli/search-left-out.ts +++ b/src/cli/search-left-out.ts @@ -47,7 +47,7 @@ export const deniedKindsOf = ( /** * The kinds whose list the profile denies, so `search all` leaves them out rather than show their titles and excerpts - * under another key (SEC-144). Levels as the run judged the command: the profile's, `--permission`, and an MCP + * under another key. Levels as the run judged the command: the profile's, `--permission`, and an MCP * server's own stricter ones. */ export const deniedKinds = ( diff --git a/src/cli/shadowed-options.ts b/src/cli/shadowed-options.ts index d220e30d2..16f6a9050 100644 --- a/src/cli/shadowed-options.ts +++ b/src/cli/shadowed-options.ts @@ -5,7 +5,7 @@ const GIVEN = new Set(["cli", "env", "config"]) /** * commander gives a flag that the root and the command both declare (`--yes`, `--timeout`, `--dry-run`) to the root, - * so the command's own option stays empty (BUG-760). The value goes to the command's option too, through its own + * so the command's own option stays empty. The value goes to the command's option too, through its own * parser, so `--timeout 2m` on an option that takes seconds still arrives as seconds. */ export const shareShadowedOptions = (action: Command): void => { diff --git a/src/cli/unknown-profile.ts b/src/cli/unknown-profile.ts index a58e6f322..23eaaf0db 100644 --- a/src/cli/unknown-profile.ts +++ b/src/cli/unknown-profile.ts @@ -14,7 +14,7 @@ const typo = (source: string | undefined, here: readonly string[]) => /** * A "not signed in" failure for a first word this computer has never seen as a profile is most likely a typo: it - * answers `not_found` with the profiles here (FIND-2583), and keeps the sign-in hint for a profile that is new on + * answers `not_found` with the profiles here, and keeps the sign-in hint for a profile that is new on * purpose. Only after a command failed, and never for `setup` or `session start`, which make a new one. The first word and `_PROFILE` are checked, since a typo in either is as likely; a bot gets * its token with `bot auth set` under any new name. */ diff --git a/src/content/writer.ts b/src/content/writer.ts index 073a23c06..bf2ef25f7 100644 --- a/src/content/writer.ts +++ b/src/content/writer.ts @@ -63,7 +63,7 @@ export const CONTENT_WRITE_KEYS: readonly PermissionKey[] = [POSTS_PUBLISH_KEY, /** * Built in, and only ever tightening (WC-PERM-7). Every write asks: a draft is not public, but publishing is, and the - * owner chose `ask` for it too (NEED-2720 B). A deletion for good asks as well. + * owner chose `ask` for it too. A deletion for good asks as well. */ export const CONTENT_WRITE_DEFAULTS: Readonly> = { "posts.create": "ask", diff --git a/src/crm/cli/files.ts b/src/crm/cli/files.ts index a718bab2e..098c8aa65 100644 --- a/src/crm/cli/files.ts +++ b/src/crm/cli/files.ts @@ -453,7 +453,7 @@ export interface CrmFileCommandOptions { now: () => number } -/** `files list`, `files download` and `files sync` (NEED-2701 C, NEED-2708 B). */ +/** `files list`, `files download` and `files sync`. */ export const addCrmFileCommands = (program: Command, options: CrmFileCommandOptions): void => { const { within, example, app, now } = options const kinds = OWNER_FLAGS.filter(([kind]) => kind !== "lead" || options.leads !== false) diff --git a/src/crm/cli/index.ts b/src/crm/cli/index.ts index 50b069c7a..414e6dc27 100644 --- a/src/crm/cli/index.ts +++ b/src/crm/cli/index.ts @@ -100,7 +100,7 @@ export interface CrmRun { /** * The sign-in's own user id in the CRM, as the sign-in entry keeps it, read without the network. The copy's deals * and leads read offline are only this user's unless a sync found it the CRM's administrator; `null`, a CRM that - * limits its users shows none of them (SEC-197). A CRM that limits nobody passes `null`. + * limits its users shows none of them. A CRM that limits nobody passes `null`. */ user: string | null /** A profile lock pins the process (WC-ACCT-5): `search all` then reads only this account's deals. */ diff --git a/src/crm/cli/records.ts b/src/crm/cli/records.ts index c2a484b3c..69e57974e 100644 --- a/src/crm/cli/records.ts +++ b/src/crm/cli/records.ts @@ -265,7 +265,7 @@ export interface CrmRecordCommandOptions { now: () => number } -/** `people`, `organizations` and `users`: read live from the CRM, so `--offline` is refused (NEED-2661). */ +/** `people`, `organizations` and `users`: read live from the CRM, so `--offline` is refused. */ export const addCrmRecordCommands = (program: Command, options: CrmRecordCommandOptions): void => { const { within, example } = options const quotaOf = (run: CrmRun) => diff --git a/src/crm/digest.ts b/src/crm/digest.ts index b4f09a1ff..8493cda75 100644 --- a/src/crm/digest.ts +++ b/src/crm/digest.ts @@ -52,7 +52,7 @@ export interface CrmDigestOptions { language: string /** The profile's name, for the sync's age. */ profile: string - /** A profile that may read only part of the copy (SEC-197). */ + /** A profile that may read only part of the copy. */ viewer?: CopyViewer /** The viewer's rule hid rows it should not have: the summary says so. */ hidden?: boolean diff --git a/src/crm/foreign-contacts.ts b/src/crm/foreign-contacts.ts index fd7e52bda..3459196c8 100644 --- a/src/crm/foreign-contacts.ts +++ b/src/crm/foreign-contacts.ts @@ -9,7 +9,7 @@ import type { CrmLiveKind, CrmSource } from "./source.js" import { CRM_SHARED_FOLDERS } from "./state-folders.js" /** - * The owner's rule (NEED-2487, NEED-2703 B): a user sees at most this many other people's records a UTC day: a + * The owner's rule: a user sees at most this many other people's records a UTC day: a * contact's or company's details, or a deal's, lead's, contact's or company's files. */ export const DAILY_FOREIGN_CONTACTS = 100 @@ -146,7 +146,7 @@ export const foreignContacts = ( /** * `api call` of a method that returns contacts or companies or their contact data: only the CRM's administrator - * makes it (NEED-2488), since one raw list would hand over the whole client base past the day's limit. The CLI knows + * makes it, since one raw list would hand over the whole client base past the day's limit. The CLI knows * its methods and says which read clients; a source without `isAdmin` is not limited. */ export const refuseForeignClientReads = async (source: CrmSource, readsClients: boolean, method: string) => { diff --git a/src/crm/source.ts b/src/crm/source.ts index 7f6323e37..2178e5fd5 100644 --- a/src/crm/source.ts +++ b/src/crm/source.ts @@ -174,7 +174,7 @@ export interface CrmSource { /** Every user of the account, active or not; a CRM that cannot list them leaves it out, and its users stay. */ users?(context?: CrmCallContext): Promise /** - * Contacts or companies read live from the CRM, newest first: the copy holds only the owner's own (NEED-2661), so + * Contacts or companies read live from the CRM, newest first: the copy holds only the owner's own, so * `people list` finds another client here. Each record carries its custom values in `metadata` (`crmValuesOf`). */ list?(kind: K, query: CrmLiveQuery, context?: CrmCallContext): Promise> @@ -182,7 +182,7 @@ export interface CrmSource { get?(kind: K, id: string, context?: CrmCallContext): Promise /** * Whether the sign-in is the CRM's administrator. With it, anyone else sees the phones and e-mails only of their own - * clients and at most `DAILY_FOREIGN_CONTACTS` other contacts or companies a day (NEED-2487, `foreignContacts`); + * clients and at most `DAILY_FOREIGN_CONTACTS` other contacts or companies a day (`foreignContacts`); * left out, the rule does not apply. */ isAdmin?(): Promise diff --git a/src/crm/viewer.ts b/src/crm/viewer.ts index 29b75d197..fa11fe6c4 100644 --- a/src/crm/viewer.ts +++ b/src/crm/viewer.ts @@ -9,7 +9,7 @@ import type { CrmSource } from "./source.js" const VIEWERS = "crm:viewers" interface Viewers { - /** The CRM limits what its users see (NEED-2660): it names the sign-in's user or answers `isAdmin`. */ + /** The CRM limits what its users see: it names the sign-in's user or answers `isAdmin`. */ limited: boolean /** Each user a sync signed in as, and whether the CRM said it is the administrator then. */ admins: Record @@ -50,7 +50,7 @@ export interface CrmViewing { } /** - * Whose deals and leads of the copy a profile reads offline (SEC-197): every one when the CRM limits nobody or a sync + * Whose deals and leads of the copy a profile reads offline: every one when the CRM limits nobody or a sync * found `user` its administrator; otherwise, a copy no sync recorded the rule of too, only those assigned to `user`, * and none when `user` is unknown. The network is never asked. */ @@ -92,7 +92,7 @@ export const viewerOf = async (run: { store: MessageStore; account: AccountKey; } /** - * The row with `deal`, the deal a lead became, left out when a viewer may not read that deal (SEC-197): a lead the + * The row with `deal`, the deal a lead became, left out when a viewer may not read that deal: a lead the * profile reads must not name a colleague's deal. */ export const withReadableDeal = async ( diff --git a/src/crm/writes.ts b/src/crm/writes.ts index 92989637a..a9560736c 100644 --- a/src/crm/writes.ts +++ b/src/crm/writes.ts @@ -587,9 +587,9 @@ export interface CrmRecordInput { export interface CrmRecordWritten { operationId: string - /** The CRM's answer; one that is not the sign-in's client comes without its phones and e-mails (NEED-2487). */ + /** The CRM's answer; one that is not the sign-in's client comes without its phones and e-mails. */ record: K extends "person" ? CrmPerson : CrmOrganization - /** Whether the copy keeps it: only the sign-in's own clients are stored (NEED-2661). */ + /** Whether the copy keeps it: only the sign-in's own clients are stored. */ stored: boolean /** * After an update that gave it to someone else, whether the copy let it go: `false` when it stays, because the @@ -669,7 +669,7 @@ const keptRecord = async (context: CrmWriteContext, kind: CrmRecordKind, record: } /** - * A contact or company the update gave to someone else leaves the copy (NEED-2661), as `removeCrmItem` removes a deal: + * A contact or company the update gave to someone else leaves the copy, as `removeCrmItem` removes a deal: * a contact with its identity, which held the phones and e-mails it was saved with. */ const forgotten = async (context: CrmWriteContext, kind: CrmRecordKind, record: CrmPerson | CrmOrganization) => diff --git a/src/domain/categories.ts b/src/domain/categories.ts index 539af49e8..a75ab9250 100644 --- a/src/domain/categories.ts +++ b/src/domain/categories.ts @@ -1,3 +1,3 @@ -/** What an organization is to the owner, derived from relationships at read time and never stored (NEED-2377). */ +/** What an organization is to the owner, derived from relationships at read time and never stored. */ export const CATEGORIES = ["client", "supplier", "partner", "employer"] as const export type Category = (typeof CATEGORIES)[number] diff --git a/src/domain/config-repair.ts b/src/domain/config-repair.ts index e09af07d1..63d646bc6 100644 --- a/src/domain/config-repair.ts +++ b/src/domain/config-repair.ts @@ -1,5 +1,5 @@ /** - * Repairs a settings file whose JSON is broken only in its syntax, without AI and without guessing (NEED-2178): a + * Repairs a settings file whose JSON is broken only in its syntax, without AI and without guessing: a * file can hold keys and tokens, so it never leaves the machine. A damage with one reading is fixed; anything else * is refused, and the caller changes nothing. */ diff --git a/src/domain/crm.ts b/src/domain/crm.ts index 8c590eecc..3ad862d58 100644 --- a/src/domain/crm.ts +++ b/src/domain/crm.ts @@ -176,7 +176,7 @@ export interface CrmField { /** A list field's options in the CRM's order; absent on any other field. */ options?: { id: string; label: string }[] /** - * The field holds phones or e-mails: a foreign record's value is stripped (NEED-2487). amoCRM sets it for a + * The field holds phones or e-mails: a foreign record's value is stripped. amoCRM sets it for a * `multitext` field whose `field_code` is `PHONE` or `EMAIL`, Bitrix24 for its phone and e-mail field types. */ holds?: "phone" | "email" diff --git a/src/domain/send-time.ts b/src/domain/send-time.ts index 0e1e18279..bba718a7c 100644 --- a/src/domain/send-time.ts +++ b/src/domain/send-time.ts @@ -2,8 +2,7 @@ import { aheadOf, MINUTE, YEAR } from "./moment.js" /** * `--at-time`, a mute's `--until`, a link's `--expire-time`: `aheadOf` within the messenger's limits of a minute to a - * year, and never a date alone. Rounded down to the minute, because messengers send at the start of it (MAX measured, - * max-cli `FIND-141`), so the time printed is the time it goes. + * year, and never a date alone. Rounded down to the minute, because messengers send at the start of it (MAX measured), so the time printed is the time it goes. */ export const sendTime = (value: string, now = Date.now(), flag = "--at-time", zone?: string): string => { const at = aheadOf(value, flag, now, { diff --git a/src/mcp/agent.ts b/src/mcp/agent.ts index 70974eea9..2e66524aa 100644 --- a/src/mcp/agent.ts +++ b/src/mcp/agent.ts @@ -336,7 +336,7 @@ const argvOf = ( /** * Runs one command for an agent through the CLI itself, in this process: the same parsing, guard, answer and * error as on the command line. The answer comes back as the object the command rendered, and a failure as the - * error object the CLI would print. A write at level `ask` goes ahead (NEED-773); the server's stricter levels + * error object the CLI would print. A write at level `ask` goes ahead; the server's stricter levels * apply, to the check before the run and to the command's own guard. With `connection`, the command borrows the * server's open connection and never opens one of its own. Which commands are offered is the catalogue's * decision (`toolsFromCommands`); this runs what it is handed, except a command that never returns. diff --git a/src/mcp/all-profiles.ts b/src/mcp/all-profiles.ts index a7a5aad9d..d318da848 100644 --- a/src/mcp/all-profiles.ts +++ b/src/mcp/all-profiles.ts @@ -226,7 +226,7 @@ const refusal = (code: ErrorCode, text: string, details?: Record mcp` shows the tools ` mcp` shows, + * **One server for every profile of a tool**: ` mcp` shows the tools ` mcp` shows, * each with a required `profile`, and runs a call in that profile's own server, started as a child the first time * it is needed. The child applies the profile's permissions, keyring, store and audit log, so nothing here decides * what a profile may do; this only routes. diff --git a/src/mcp/http/oauth.ts b/src/mcp/http/oauth.ts index 16a96b9e1..97bd71e01 100644 --- a/src/mcp/http/oauth.ts +++ b/src/mcp/http/oauth.ts @@ -81,7 +81,7 @@ export interface OwnerLogin { } /** - * An OAuth 2.1 authorization server for exactly one owner (CLI-58). Anyone may register a client — + * An OAuth 2.1 authorization server for exactly one owner. Anyone may register a client — * the browser apps need dynamic registration — but nobody gets a token without the one-time code * printed in the owner's terminal. Five wrong codes delay further attempts for thirty seconds. */ diff --git a/src/mcp/http/serve.ts b/src/mcp/http/serve.ts index 718def9de..6d607dd89 100644 --- a/src/mcp/http/serve.ts +++ b/src/mcp/http/serve.ts @@ -127,7 +127,7 @@ export interface HttpOptions { } /** - * MCP over Streamable HTTP on 127.0.0.1, behind the owner's tunnel (CLI-58). Every MCP request needs + * MCP over Streamable HTTP on 127.0.0.1, behind the owner's tunnel. Every MCP request needs * a token from the owner login; the Host header must be the tunnel's or this machine's, so a page in * the owner's browser cannot reach the port through a rebound DNS name. */ diff --git a/src/mcp/server.ts b/src/mcp/server.ts index 4315f2d16..4f9a1d107 100644 --- a/src/mcp/server.ts +++ b/src/mcp/server.ts @@ -490,7 +490,7 @@ export const serveOverStdio = async ( } } -/** The same server over HTTP, until Ctrl-C (CLI-58). */ +/** The same server over HTTP, until Ctrl-C. */ export const serveOverHttpUntilStopped = async ( command: Invocation, context: MessengerContext, diff --git a/src/mcp/session.ts b/src/mcp/session.ts index 9a8e54f4c..99de42aa6 100644 --- a/src/mcp/session.ts +++ b/src/mcp/session.ts @@ -29,8 +29,8 @@ interface Held { } /** - * **One connection for the whole agent session, and never for long** — max-cli's `MaxSession` - * (its `NEED-152`), over any messenger. + * **One connection for the whole agent session, and never for long** — max-cli's `MaxSession`, + * over any messenger. * * A command connects once and exits. Here the process outlives the call, so the connection is kept * between calls — and dropped after `idleMs` of quiet, after `maxAgeMs` whatever the traffic, and diff --git a/src/mcp/surface.ts b/src/mcp/surface.ts index c1314f1bc..4fe0f387c 100644 --- a/src/mcp/surface.ts +++ b/src/mcp/surface.ts @@ -202,7 +202,7 @@ const sampleOf = (commands: Record): string => { } /** - * **Three tools in place of one per command** (CLI-74, NEED-766): search the commands, then run one + * **Three tools in place of one per command**: search the commands, then run one * with `read` or `write`. A command keeps its CLI path and its arguments, and runs as its own tool * did. The catalogue stays discoverable; current permissions annotate availability and are checked before execution. */ diff --git a/src/moderation/rules.ts b/src/moderation/rules.ts index 6d3914069..b974f7d5e 100644 --- a/src/moderation/rules.ts +++ b/src/moderation/rules.ts @@ -10,7 +10,7 @@ import { LEVELS, type Level } from "../sends/permissions.js" export const RULE_ACTIONS = ["report", "delete", "remove"] as const /** - * max-cli's first words for a group's consent (`NEED-308`), read as the profile's levels + * max-cli's first words for a group's consent, read as the profile's levels * (`NEED-462` B): `flag` and `confirm` both ask, `forbid` denies. */ const OLD_LEVELS: Record = { forbid: "deny", flag: "ask", confirm: "ask", allow: "allow" } @@ -23,7 +23,7 @@ const action = v.picklist(RULE_ACTIONS) const personIds = v.array(v.pipe(v.string(), v.regex(/^-?\d+$/, "a person id is digits"))) const atLeast = (min: number) => v.pipe(v.number(), v.integer(), v.minValue(min)) -/** `requests` and `consent.accept|decline` were for join requests (max-cli `FIND-249`); a file with them loads and drops them. */ +/** `requests` and `consent.accept|decline` were for join requests; a file with them loads and drops them. */ const groupRules = v.pipe( v.strictObject({ title: v.nullable(v.string()), @@ -59,7 +59,7 @@ const file = v.strictObject({ checkedUntil: v.optional(v.record(v.string(), v.string())), }) -/** Every key written out, so the file shows all there is to set (max-cli `NEED-314`). Nothing here acts. */ +/** Every key written out, so the file shows all there is to set. Nothing here acts. */ export const defaultRules = (title: string | null): GroupRules => ({ title, trusted: [], diff --git a/src/readers/engine.ts b/src/readers/engine.ts index b3485d823..38017dc48 100644 --- a/src/readers/engine.ts +++ b/src/readers/engine.ts @@ -8,8 +8,8 @@ import { MAX_TEXT_CHARS } from "../attachments/limits.js" import type { Extraction, FileHint, LoadEngine } from "./types.js" /** - * The packages that read formats. Reading documents is core, so the readers ship with this package (owner, - * 2026-10-12, replacing NEED-629 A); only the page renderer for OCR stays optional, a native binary. + * The packages that read formats. Reading documents is core, so the readers ship with this package (the owner's + * decision of 2026-10-12); only the page renderer for OCR stays optional, a native binary. */ export const BUILT_IN = ["unpdf", "mammoth", "word-extractor", "linkedom", "defuddle/node"] as const export const ENGINES = [...BUILT_IN, "@napi-rs/canvas"] as const diff --git a/src/replies/rules.ts b/src/replies/rules.ts index 6072d1c5d..39933f7b3 100644 --- a/src/replies/rules.ts +++ b/src/replies/rules.ts @@ -155,8 +155,7 @@ const file = v.pipe( ) /** - * Every key written out, so the file shows all there is to set, as moderation's does (max-cli - * `NEED-314`). Off until the owner turns it on, and the limits are the tightest worth having. + * Every key written out, so the file shows all there is to set, as moderation's does. Off until the owner turns it on, and the limits are the tightest worth having. */ export const defaultRule = (id: string): ReplyRuleFile => ({ id, diff --git a/src/replies/serve.ts b/src/replies/serve.ts index 916d5dc6f..0ebd73cdb 100644 --- a/src/replies/serve.ts +++ b/src/replies/serve.ts @@ -41,7 +41,7 @@ const FINAL = new Set(["permission_error", "confirmation_required", "rate_limite /** * One arriving message through the rules, in file order, the first that matches acting: a task opens - * for anyone (NEED-582), a reply goes only to a sender the file's audience allows and only with + * for anyone, a reply goes only to a sender the file's audience allows and only with * `replies.send` at `allow`. A send that fails is * tried once more with the same send id, so the messenger delivers at most one; a message whose * reply may have gone is kept as answered. diff --git a/src/runs/events.ts b/src/runs/events.ts index 519e9bc51..e2d5ac352 100644 --- a/src/runs/events.ts +++ b/src/runs/events.ts @@ -4,7 +4,7 @@ * * ⚠ **Nothing here may carry content.** An operation name, an id, a file or folder path, a count, a duration and an * error code are safe: a run record stays on the owner's machine, and keeping the ids that tell runs apart was the - * owner's choice (NEED-110, 2026-10-27). A chat title, a name, a message body, a phone number, a token, a URL as sent + * owner's choice (2026-10-27). A chat title, a name, a message body, a phone number, a token, a URL as sent * or a query string are not — not truncated and not hashed. The adapter builds `ids` and `counts` from fields it names, * never by copying a request, and never from what the person typed: a typed chat is often a title. Anything that * leaves the machine (a bug report) strips the ids too. diff --git a/src/search/question-plan.ts b/src/search/question-plan.ts index 5a7d23427..2603a59f5 100644 --- a/src/search/question-plan.ts +++ b/src/search/question-plan.ts @@ -168,9 +168,9 @@ export function planQuestion(text: string, strict = false) { } /** - * Text as a question is searched. Its own "?" would parse as a one-character wildcard and send it to strict search - * (BUG-395); the colon of a time or ratio ("22:00", "1:1") would parse as a field and fail the whole search, and - * escaped it is syntax again, so it splits the numbers (BUG-450). A quoted timestamp keeps its colons (BUG-458). + * Text as a question is searched. Its own "?" would parse as a one-character wildcard and send it to strict search; + * the colon of a time or ratio ("22:00", "1:1") would parse as a field and fail the whole search, and + * escaped it is syntax again, so it splits the numbers. A quoted timestamp keeps its colons. */ export const questionText = (text: string) => text diff --git a/src/sends/permissions.ts b/src/sends/permissions.ts index ba78c65ec..ea8db0638 100644 --- a/src/sends/permissions.ts +++ b/src/sends/permissions.ts @@ -19,11 +19,11 @@ const DANGEROUS = new Set([ "chats.clear", ]) -/** Deleting has its own word for "yes": the flag a person has to mean, not a habit (max-cli `NEED-238`). */ +/** Deleting has its own word for "yes": the flag a person has to mean, not a habit. */ export const skipFlagFor = (key: string): "--allow-dangerous" | "--yes" => DANGEROUS.has(key) ? "--allow-dangerous" : "--yes" -/** Only what cannot be undone asks; the tool is meant to work without questions (owner, NEED-460). */ +/** Only what cannot be undone asks; the tool is meant to work without questions (the owner's decision). */ export const DEFAULT_PERMISSIONS: Readonly> = { // Owner, 2026-11-14: deleting a message does not ask; a profile that wants the question sets `ask`. "messages.delete": "allow", @@ -80,7 +80,7 @@ export const authorityAllowed = (levels: Readonly>) return level === "allow" || level === "ask" } -/** Lets an MCP server offer `bot api`, whose calls skip the send guard and the bot's recipient list (NEED-1679). */ +/** Lets an MCP server offer `bot api`, whose calls skip the send guard and the bot's recipient list. */ export const BOT_API_KEY: PermissionKey = "bot.api" export const isBotApi = (path: readonly string[]): boolean => path[0] === "bot" && path[1] === "api" @@ -128,7 +128,7 @@ export const RESOURCES = [ /** * Layers come nearest first. A key a nearer layer sets hides that key and every key under it in the * farther layers, so a profile's `messages: readonly` is not undone by `messages.delete: allow` in - * `defaults` — the nearest section wins, as it does for every other setting (NEED-573). + * `defaults` — the nearest section wins, as it does for every other setting. */ export const layerPermissions = (layers: readonly [string, Readonly> | undefined][]) => { const levels: Record = {} diff --git a/src/sends/send-as.ts b/src/sends/send-as.ts index 0edf24cca..8e385591b 100644 --- a/src/sends/send-as.ts +++ b/src/sends/send-as.ts @@ -6,7 +6,7 @@ import { capability, type MessengerAdapter } from "../ports/messenger.js" * Found before the chat is resolved, so a messenger without identities refuses before any lookup; * the returned check runs once the chat id is known, in the same connection. With no identity named, * a chat whose saved sender is not the account is refused: the messenger would post as that sender, - * and nothing the owner typed said so (owner, NEED-796 C). + * and nothing the owner typed said so (the owner's decision). */ export const sendAsCheck = (connection: MessengerAdapter, sendAs: Id | undefined) => { if (sendAs === undefined) { diff --git a/src/services/business-context.ts b/src/services/business-context.ts index ec405b67f..b4b3dce1b 100644 --- a/src/services/business-context.ts +++ b/src/services/business-context.ts @@ -43,7 +43,7 @@ export const keyOf = ({ provider, account }: AccountKey): string => `${provider} * given. A row no account reported — the owner's, an agent's — is always in it. `left` collects every account whose * rows were kept out, so `coverage` can say so. `denied` holds the kinds the profile denies (`deals.list`, * `leads.list`): no row, title or count of them is answered, and `coverage` says they were denied. `viewers` are the - * CRM copies' rules for the profile (SEC-197, `crmViewerOf`): a deal or lead one may not read is never named, and each + * CRM copies' rules for the profile (`crmViewerOf`): a deal or lead one may not read is never named, and each * note on why a copy shows less goes to `coverage`. */ export interface Scope { @@ -211,7 +211,7 @@ export { CATEGORIES, type Category } const EMPLOYED = new Set(["employee", "contractor", "founder"]) /** - * Each organization's categories, derived from usable relationships in scope and never stored (NEED-2377): `client` + * Each organization's categories, derived from usable relationships in scope and never stored: `client` * is `customer-of` an own organization, `supplier` one an own organization is `customer-of`, `partner` `partner-of` * one, `employer` one the owner's person is `member-of` as employee, contractor or founder. Read once per answer. */ diff --git a/src/services/deal-context.ts b/src/services/deal-context.ts index f1fb227dc..4b09cb4df 100644 --- a/src/services/deal-context.ts +++ b/src/services/deal-context.ts @@ -58,7 +58,7 @@ export interface DealContextOptions { /** The kinds the profile denies: a deal or lead of one is not answered. */ deniedKinds?: readonly DealKind[] /** - * Each CRM copy's rule for the profile (`crmViewerOf`, SEC-197): a deal or lead it may not read is not found. + * Each CRM copy's rule for the profile (`crmViewerOf`): a deal or lead it may not read is not found. */ viewing?: readonly CrmViewing[] } diff --git a/src/services/embeddings.ts b/src/services/embeddings.ts index 48143a45c..4029e394d 100644 --- a/src/services/embeddings.ts +++ b/src/services/embeddings.ts @@ -52,7 +52,7 @@ export interface EmbeddingsService { clear(chat: string, model?: ModelChoice): Promise<{ chat: Id; cleared: number }> /** * The conversations nearest in meaning to `query`, in one chat or every one of the account (E7). With no - * local model downloaded it answers by words alone (NEED-552 A): never a download, never a remote model. + * local model downloaded it answers by words alone: never a download, never a remote model. */ search( query: string, @@ -89,7 +89,7 @@ export interface EmbeddingsService { }): Promise<{ model: string; chats: ChatReadiness[]; unbuiltGroups?: number }> /** * Builds and embeds, on this machine, the chats that changed or were never built — one chat, or every built - * chat and every group chat never built — within the bounds (NEED-551 A). Never downloads a model. + * chat and every group chat never built — within the bounds. Never downloads a model. */ refresh(options: RefreshOptions): Promise } @@ -192,7 +192,7 @@ export interface FoundConversation { /** `context`: the hit is an image, found by the messages around it; its message is `chunk`. */ matchedIn?: "context" by: ("meaning" | "words")[] - /** The chunk's text changed after it was embedded: the score is for what it said then (NEED-550 B). */ + /** The chunk's text changed after it was embedded: the score is for what it said then. */ stale: boolean /** The chunk's messages that share most words with the query, as "sender: text", so a reader need not open it. */ lines?: string[] diff --git a/src/services/moderation.ts b/src/services/moderation.ts index 278460e6d..74ac374b2 100644 --- a/src/services/moderation.ts +++ b/src/services/moderation.ts @@ -32,7 +32,7 @@ export interface ModerateOptions { confirm?: (finding: Finding) => Promise } -/** A group's rules, and the one command that acts on them (max-cli `NEED-306`). */ +/** A group's rules, and the one command that acts on them. */ export interface ModerationService { rules(chat: string): Promise set(chat: string, key: string, value: string): Promise diff --git a/src/services/organization-context.ts b/src/services/organization-context.ts index d7fcd6165..9bb71118c 100644 --- a/src/services/organization-context.ts +++ b/src/services/organization-context.ts @@ -93,7 +93,7 @@ export interface OrganizationContextOptions { /** The kinds the profile denies: none of their rows, titles or counts is answered. */ deniedKinds?: readonly DealKind[] /** - * Each CRM copy's rule for the profile (`crmViewerOf`, SEC-197): a deal or lead it may not read is left out, and + * Each CRM copy's rule for the profile (`crmViewerOf`): a deal or lead it may not read is left out, and * `coverage.notRead` carries the rule's note. */ viewing?: readonly CrmViewing[] diff --git a/src/services/people.ts b/src/services/people.ts index 87db37fa8..81a076bbb 100644 --- a/src/services/people.ts +++ b/src/services/people.ts @@ -35,7 +35,7 @@ export interface ContactSync { /** * A contact is somebody this account has a one-to-one chat with — a query over the chat list, never - * a flag somebody maintains (max-cli `NEED-105`). Where the store holds who is in each one-to-one + * a flag somebody maintains. Where the store holds who is in each one-to-one * chat, it answers; otherwise the dialogs themselves do, offline from the stored chats. */ export interface PeopleService { diff --git a/src/services/person-business.ts b/src/services/person-business.ts index b20fbf368..9aa2df9c4 100644 --- a/src/services/person-business.ts +++ b/src/services/person-business.ts @@ -54,7 +54,7 @@ export interface CanonicalContextOptions extends ContextOptions { /** The kinds the profile denies: no deal or lead of theirs is named. */ deniedKinds?: readonly DealKind[] /** - * Each CRM copy's rule for the profile (`crmViewerOf`, SEC-197): a deal or lead it may not read is not named, and + * Each CRM copy's rule for the profile (`crmViewerOf`): a deal or lead it may not read is not named, and * `coverage.notRead` carries the rule's note. */ viewing?: readonly CrmViewing[] diff --git a/src/services/search-all.ts b/src/services/search-all.ts index 05ac64480..7d3f12f13 100644 --- a/src/services/search-all.ts +++ b/src/services/search-all.ts @@ -196,7 +196,7 @@ export interface SearchAllRequest { meetingsAsked?: boolean /** The CRM kinds `crm` reads; absent, deals and leads. */ crmKinds?: readonly DealKind[] - /** The CRM accounts' copies a CRM CLI's profile may read only part of, each by its own rule (SEC-197). */ + /** The CRM accounts' copies a CRM CLI's profile may read only part of, each by its own rule. */ crmViewers?: CopyViewer[] /** `crm` also reads the text of downloaded CRM files under the same viewers; false when the profile denies it. */ crmFiles?: boolean @@ -340,7 +340,7 @@ const sourceScope = async ( return { only, scope, skipped: [...skipped, ...unnamed] } } -/** Each CRM copy's viewer for the user its own sync signed in as (SEC-197): what a run outside its CLI may read. */ +/** Each CRM copy's viewer for the user its own sync signed in as: what a run outside its CLI may read. */ const copyViewers = async (store: MessageStore): Promise => { const viewers: CopyViewer[] = [] for (const account of await crmAccounts(store)) { @@ -970,7 +970,7 @@ const hitKey = (item: SearchAllItem): string => /** * Every source's hits as one list: each source's best hit first, then every other hit by cosine, then by its rank in * its source. Taking turns by rank (MEMO-37) gave each of two sources half of a ten-hit page however weak its hits; - * one model scores every source, so cosine compares across them (IDEA-249). A hit only words found takes the cosine of + * one model scores every source, so cosine compares across them. A hit only words found takes the cosine of * the hit above it in its source: its source ranked it there, and with none it would follow every hit meaning found. */ const oneList = (lists: SearchAllItem[][], cosines: Map): SearchAllItem[] => { diff --git a/src/speech/hearing.ts b/src/speech/hearing.ts index a66535a5a..f5d185b6c 100644 --- a/src/speech/hearing.ts +++ b/src/speech/hearing.ts @@ -52,7 +52,7 @@ export interface Kept { /** * Transcripts already heard, in the shared store, for the account this profile last logged in as - * (owner, NEED-418 B). A profile that has never been online has no account yet: nothing is kept for + * (the owner's decision). A profile that has never been online has no account yet: nothing is kept for * it, and a voice message is heard again next time. */ export const openKept = async (messenger: Messenger, profile: string, env: NodeJS.ProcessEnv): Promise => { diff --git a/src/speech/models.ts b/src/speech/models.ts index 751c99a80..b6f544ed1 100644 --- a/src/speech/models.ts +++ b/src/speech/models.ts @@ -6,7 +6,7 @@ import { CliError } from "@wirecat/cli-base" * holds the owner's session. * * Measured 2026-09-24 through the WebAssembly build of sherpa-onnx, one thread, a Ryzen AI 9 HX 470 - * laptop, 5 minutes of Ogg Opus cut by VAD, Node 24 and Bun 1.3.14 alike (`FIND-131`, `FIND-133`): + * laptop, 5 minutes of Ogg Opus cut by VAD, Node 24 and Bun 1.3.14 alike: * `gigaam-v3` ×7 real time, `gigaam-v3-ctc` ×8, `parakeet-v3` ×5 and 1.3 GB of memory. Whisper small * ran at ×1.1 and is not offered. */ diff --git a/src/store/damage.ts b/src/store/damage.ts index e2ff8b2ca..66fb350a5 100644 --- a/src/store/damage.ts +++ b/src/store/damage.ts @@ -66,7 +66,7 @@ const journalSeen = (store: string, { seen, command, at }: JournalMark) => { : `the store's journal file (${wal}) was deleted or replaced by another program while \`${command}\` had the store open (${at})` } -/** How much may be gone and since when: nothing records a row that damage takes (BUG-627). */ +/** How much may be gone and since when: nothing records a row that damage takes. */ export const lossUnknown = (lastOkAt: string | null | undefined, gone = false): string => { const since = lastOkAt ? `since the last deep check that passed (${lastOkAt})` diff --git a/src/store/identity-links.ts b/src/store/identity-links.ts index e4f1797c5..0b9a54c5d 100644 --- a/src/store/identity-links.ts +++ b/src/store/identity-links.ts @@ -48,7 +48,7 @@ export interface IdentityLinkPayload { /** * Why a shared phone or address is not strong enough for an agent to merge on: an office's number, more people have * it, a company's line or mailbox, a role or no-reply address, only one source gives it, or for a phone no source that - * keeps its user's own number (a CRM's or a card's is someone's word, NEED-2445). + * keeps its user's own number (a CRM's or a card's is someone's word). */ export const LINK_WEAKNESSES = [ "landline", diff --git a/src/store/open.ts b/src/store/open.ts index c2f4643d2..229faee2f 100644 --- a/src/store/open.ts +++ b/src/store/open.ts @@ -11,7 +11,7 @@ import { quietSqliteWarning } from "./sqlite-warning.js" * import only inside the branch that can satisfy it is what makes one build serve both runtimes. * * Measured 2026-09-19: `node:sqlite` exists on Node 22.23.2 and 24 and not in Bun; `bun:sqlite` - * is the reverse (`NEED-11`). + * is the reverse. */ export const openCache = async (path: string): Promise => { const database = await openFile(path) diff --git a/src/store/people.ts b/src/store/people.ts index 31fff469c..085f948c2 100644 --- a/src/store/people.ts +++ b/src/store/people.ts @@ -153,7 +153,7 @@ export interface PeopleStore extends AccountPeople { * An agent's link. It merges at once only on strong evidence the store finds itself, never on the agent's word: * one value, a mobile number or a personal address, that no one else holds or that each of its holders has from a * different source, whatever their names; from two different sources; and for a phone at least one that keeps its - * user's own number (a messenger account or a call's number; NEED-2445, NEED-2600, NEED-2697). A landline, a value two + * user's own number (a messenger account or a call's number). A landline, a value two * records of one source share, a company's line, a role address, a name or a CRM's word alone is weak. The * merge is recorded as an `identity_link` the agent decided, with the evidence, the reason and the run, and the owner * undoes it with `undoMerge`. Weak evidence, the owner's person, a pair the owner rejected, or `apply: false` (the @@ -169,13 +169,13 @@ export interface PeopleStore extends AccountPeople { }): Promise<{ items: (PersonMerge & { agent: AgentMerge })[]; hasMore: boolean }> /** * The owner's decision on an `identity_link`; confirm is refused with `identity.stale` when either person changed. - * `company` turns down a shared-mailbox proposal and gives its address to an organization (NEED-2528); - * `organization` turns down a match whose two sides are a company's mailboxes and gives them all to it (NEED-2573). + * `company` turns down a shared-mailbox proposal and gives its address to an organization; + * `organization` turns down a match whose two sides are a company's mailboxes and gives them all to it. */ decideLink(id: string, decision: IdentityLinkDecision): Promise /** * One pass of the people matcher: the same address joins people in every scope, a phone two people have, or one each - * source has once whatever the names (NEED-2697), joins them, a phone more people of one source share, a role address such as `info@`, a meeting guest's typed address, and one + * source has once whatever the names, joins them, a phone more people of one source share, a role address such as `info@`, a meeting guest's typed address, and one * name with a shared phone, address, chat or company domain become proposals. Never over the owner's separation; a pair the owner rejected is proposed again only on new evidence. */ scanMatches(options?: { full?: boolean }): Promise diff --git a/src/store/repair.ts b/src/store/repair.ts index f7ceedf5f..400e30b9c 100644 --- a/src/store/repair.ts +++ b/src/store/repair.ts @@ -190,8 +190,8 @@ const expectedShapes = (fresh: CacheDatabase): Map => { } /** - * **Brings each table of the file to the shape this build's migrations give it, deleting nothing** - * (NEED-626). A table only missing columns it can take gets them added; any other difference keeps + * **Brings each table of the file to the shape this build's migrations give it, deleting nothing**. + * A table only missing columns it can take gets them added; any other difference keeps * the table as a copy named `__repair_` beside a new one holding every row that fits. * `messages` is never renamed — its search index and triggers hang off it — so a difference there * is reported, not rebuilt. With `dryRun` the same work runs and is rolled back, so the report is diff --git a/src/store/sqlite-warning.ts b/src/store/sqlite-warning.ts index c11de2f9d..cbffd314e 100644 --- a/src/store/sqlite-warning.ts +++ b/src/store/sqlite-warning.ts @@ -4,7 +4,7 @@ const quieted = new WeakSet() /** * Node 22 prints `ExperimentalWarning: SQLite is an experimental feature` when `node:sqlite` first loads; Node 24 does - * not. Agents read the two stderr lines as a failure (`NEED-1448`), so this drops that one warning and passes every + * not. Agents read the two stderr lines as a failure, so this drops that one warning and passes every * other one through. It must run before `node:sqlite` loads, and a builtin loads while its importer is linked — * before any statement of that importer runs — so callers call it before the dynamic import, never beside a static one. */ diff --git a/src/store/sqlite/completeness.ts b/src/store/sqlite/completeness.ts index 619fda0d2..5782c0e54 100644 --- a/src/store/sqlite/completeness.ts +++ b/src/store/sqlite/completeness.ts @@ -23,7 +23,7 @@ export interface ChatCompleteness { } /** - * Three facts per chat (NEED-455 A): the newest held against the chat list's, the stretches, and the start reached. + * Three facts per chat: the newest held against the chat list's, the stretches, and the start reached. * A start mark that a later fetch reached past was wrong, so it stops counting. */ export const chatCompleteness = ({ database }: StoreContext, accountKey: number, chatIds: Id[]): ChatCompleteness[] => { diff --git a/src/store/sqlite/conversations.ts b/src/store/sqlite/conversations.ts index 803da555f..a0a1581a9 100644 --- a/src/store/sqlite/conversations.ts +++ b/src/store/sqlite/conversations.ts @@ -126,7 +126,7 @@ const highestBuild = ({ orm }: StoreContext, chatKey: number): number => ) /** - * Plan C3–C4, corrected by NEED-475 A. The chat's provider and rule links and its conversations are + * The chat's provider and rule links and its conversations are * written under a new build number in short transactions; one more makes that build the one readers * see; older builds are then deleted, a batch at a time. Until the switch readers see the previous * build, so a failed build leaves it in place. Agent links have no build and stay; one whose message diff --git a/src/store/sqlite/copy-viewer.ts b/src/store/sqlite/copy-viewer.ts index 163874bf7..65bde239a 100644 --- a/src/store/sqlite/copy-viewer.ts +++ b/src/store/sqlite/copy-viewer.ts @@ -1,7 +1,7 @@ import type { AccountKey } from "../types.js" /** - * A profile that may read only part of one CRM account's copy (SEC-197): the deals and leads assigned to `assignee`, + * A profile that may read only part of one CRM account's copy: the deals and leads assigned to `assignee`, * the identity `/user/`, or none when it is `null`. */ export interface CopyViewer { diff --git a/src/store/sqlite/crm-activities.ts b/src/store/sqlite/crm-activities.ts index ba01daf91..1f017c6db 100644 --- a/src/store/sqlite/crm-activities.ts +++ b/src/store/sqlite/crm-activities.ts @@ -82,7 +82,7 @@ export interface ActivityFilter { /** The identity `/user/` it is assigned to; `null` is none. */ owner?: string | null /** - * A profile that may read only part of the copy (SEC-197): the activities on its deals and leads, and those on + * A profile that may read only part of the copy: the activities on its deals and leads, and those on * contacts or companies alone that are assigned to it. A hidden deal or lead is never named in `on`. */ viewer?: CopyViewer diff --git a/src/store/sqlite/crm-changes.ts b/src/store/sqlite/crm-changes.ts index 46e69a4bd..dfeb3e45c 100644 --- a/src/store/sqlite/crm-changes.ts +++ b/src/store/sqlite/crm-changes.ts @@ -55,7 +55,7 @@ export interface ChangeFilter { /** A pipeline's store id: only the changes of its deals or leads. */ pipeline?: number /** - * A profile that may read only part of the copy (SEC-197): the deals and leads assigned to it, the activities on + * A profile that may read only part of the copy: the deals and leads assigned to it, the activities on * them, and the contacts linked to them or assigned to it. */ viewer?: CopyViewer diff --git a/src/store/sqlite/crm-files.ts b/src/store/sqlite/crm-files.ts index 73ab2ad6b..ee91a5926 100644 --- a/src/store/sqlite/crm-files.ts +++ b/src/store/sqlite/crm-files.ts @@ -48,7 +48,7 @@ export interface CrmFileSearch { exact?: boolean /** Absent: every CRM account's. */ accounts?: AccountKey[] - /** Each limits its own account's rows to the files of records assigned to its user (NEED-2707 A). */ + /** Each limits its own account's rows to the files of records assigned to its user. */ viewers?: CopyViewer[] limit?: number } diff --git a/src/store/sqlite/crm-settings.ts b/src/store/sqlite/crm-settings.ts index 64aab04d1..ca324a5fc 100644 --- a/src/store/sqlite/crm-settings.ts +++ b/src/store/sqlite/crm-settings.ts @@ -19,7 +19,7 @@ export const CRM_SCOPES = ["mine", "all"] as const export const CRM_ACTIVITIES = ["on", "off"] as const /** - * What `files sync` and `files download` may take (NEED-2708 B): a run's files, a prefetched file's and a run's + * What `files sync` and `files download` may take: a run's files, a prefetched file's and a run's * megabytes, a run's minutes, how many days back a run looks, and the account's folder's megabytes. A value outside * its range is refused, never clamped. */ diff --git a/src/store/sqlite/crm.ts b/src/store/sqlite/crm.ts index 717022f81..ecf778b4e 100644 --- a/src/store/sqlite/crm.ts +++ b/src/store/sqlite/crm.ts @@ -131,7 +131,7 @@ const PENDING_DAYS = 30 const PENDING_MOST = 5000 /** - * A CRM account's copies in the store, written as the CRM has them: nothing waits for review (NEED-2271 A), and + * A CRM account's copies in the store, written as the CRM has them: nothing waits for review, and * nothing is ever matched by name (WC-DATA-6). Rows the CRM no longer has are marked deleted, never removed * (WC-DATA-7). Every write is one transaction per call. */ @@ -231,7 +231,7 @@ export interface CrmCopies extends CrmReads, CrmActivityWrites { ): Promise /** * Removes one contact from the copy, as `removeContacts` removes those outside the scope: a write made it another - * user's client, which the copy does not keep (NEED-2661). Answers what went. + * user's client, which the copy does not keep. Answers what went. */ removeContact(key: AccountKey, externalId: string): Promise /** How many of the kind the account holds, not deleted; every contact it ever saved. */ diff --git a/src/store/sqlite/identity-link-rows.ts b/src/store/sqlite/identity-link-rows.ts index 73e191a85..a047ad268 100644 --- a/src/store/sqlite/identity-link-rows.ts +++ b/src/store/sqlite/identity-link-rows.ts @@ -65,7 +65,7 @@ export const linkRows = ( /** * What a proposal rests on: its signal and the two identities it names, in either order. The owner's rejection - * holds against this evidence only (NEED-2444); a new signal or identity for the same people proposes them again. + * holds against this evidence only; a new signal or identity for the same people proposes them again. */ export const evidenceKeyOf = ({ signal, diff --git a/src/store/sqlite/messages.ts b/src/store/sqlite/messages.ts index f0b6b2897..c37a57c8c 100644 --- a/src/store/sqlite/messages.ts +++ b/src/store/sqlite/messages.ts @@ -336,7 +336,7 @@ export const countUnread = ({ database }: StoreContext, chatKey: number, message } /** - * The owner's ruling (NEED-393 A): a deleted message keeps its row, so a later sync cannot bring it + * The owner's ruling: a deleted message keeps its row, so a later sync cannot bring it * back, and leaves no text — not in the row, the search copy, the edit history, a transcript or a vector. */ export const tombstone = (context: StoreContext, pk: number): number => { diff --git a/src/store/sqlite/name-traces.ts b/src/store/sqlite/name-traces.ts index ccde5ab63..6a41089a5 100644 --- a/src/store/sqlite/name-traces.ts +++ b/src/store/sqlite/name-traces.ts @@ -8,7 +8,7 @@ import { referenceOfThing } from "./things.js" /** * People, owner aside, by the name they share once case, quotes, word order, script and spelling are set aside: - * `Светлана Кузнецова` and `Svetlana Kuznetsova` are one name here (BUG-678). + * `Светлана Кузнецова` and `Svetlana Kuznetsova` are one name here. */ export const peopleByNameKey = (database: CacheDatabase): Map => { const found = new Map() diff --git a/src/store/sqlite/organization-categories.ts b/src/store/sqlite/organization-categories.ts index aad61568b..c978e7358 100644 --- a/src/store/sqlite/organization-categories.ts +++ b/src/store/sqlite/organization-categories.ts @@ -15,7 +15,7 @@ const OWN = "(SELECT id FROM organizations WHERE deleted_at IS NULL AND json_ext const EMPLOYED = "('employee', 'contractor', 'founder')" /** - * The category as SQL over `organizations o`, derived from usable relationships at `now` (NEED-2377), as + * The category as SQL over `organizations o`, derived from usable relationships at `now`, as * `organizationCategories` derives it: `client` is `customer-of` an own organization, `supplier` one an own * organization is `customer-of`, `partner` `partner-of` one, `employer` one the owner's person is `member-of` as * employee, contractor or founder. diff --git a/src/store/sqlite/person-links.ts b/src/store/sqlite/person-links.ts index 3b5514538..329ff806f 100644 --- a/src/store/sqlite/person-links.ts +++ b/src/store/sqlite/person-links.ts @@ -254,7 +254,7 @@ export const mergePerson = (context: StoreContext, one: number, other: number, o } /** - * A company's mailbox joins no one at import: two or more other people hold it (NEED-2446), an organization holds it, + * A company's mailbox joins no one at import: two or more other people hold it, an organization holds it, * or another person of the identity's own list has it, such as a second CRM contact (`sharedLine` in the scan). */ const sharedAddress = ({ database }: StoreContext, key: string, found: { pk: number; personPk: number }): boolean => { @@ -299,7 +299,7 @@ export const noteAddress = (context: StoreContext, ref: IdentityRef, address: st * as `info@` and a company's mailbox join no one, here or in the scan. A pair the owner rejected is not joined either: it is * given back, so the caller proposes it when the evidence is new to the owner. Nothing joins the owner, or is * proposed to them, from an address: a mailbox the owner reads may be someone else's, and only the owner joins anyone - * to themselves (SEC-177). A bot or service account joins no one. + * to themselves. A bot or service account joins no one. */ export const joinByAddress = ( context: StoreContext, @@ -333,7 +333,7 @@ export const joinByAddress = ( /** * A person named after an identity that left them takes the name of the oldest identity they still have, or none: the - * owner merged with a partner's CRM contact kept the partner's name after the split (BUG-677). + * owner merged with a partner's CRM contact kept the partner's name after the split. */ export const renameAfterLeaving = (context: StoreContext, person: number, left: readonly number[]): void => { const { database } = context diff --git a/src/store/sqlite/person-match-scan.ts b/src/store/sqlite/person-match-scan.ts index 4f05ce383..eb0ccd62c 100644 --- a/src/store/sqlite/person-match-scan.ts +++ b/src/store/sqlite/person-match-scan.ts @@ -31,13 +31,13 @@ const CURSOR = "people.scan" const RULES = 7 /** - * NEED-2526: a shared mailbox says little alone, so its proposal is scored by what else the two people have in common. + * A shared mailbox says little alone, so its proposal is scored by what else the two people have in common. * The owner's word (2026-11-11): `hr@` is often one person's, so it starts below `info@`. */ const SHARED_SCORE = { alone: 0.1, personLike: 0.05, name: 0.4, trace: 0.3, weakTrace: 0.2 } /** - * NEED-2529: every rule's proposal on the scale of `SHARED_SCORE`, so the review lists the strongest first. A phone two + * Every rule's proposal on the scale of `SHARED_SCORE`, so the review lists the strongest first. A phone two * people alone have but that does not join (a CRM's or a card's), one name with a phone or an address only these two * hold, and a pair the owner rejected that meets new evidence of that kind are 0.7; one name with a chat or a company * domain in one source, and a meeting guest's typed address, 0.5; a phone or personal address 3–6 people share, 0.4; @@ -54,9 +54,9 @@ export const PROPOSAL_SCORE = { } /** - * NEED-2445, safe option until the owner rules: a number two people share joins them only when a messenger, which + * Safe option until the owner rules: a number two people share joins them only when a messenger, which * keeps its user's own number, holds it; a CRM's or a card's number is someone's word and waits as a proposal. - * NEED-2600: a call's other side, kept as `phone:`, is that number as the phone network gave it, as strong + * A call's other side, kept as `phone:`, is that number as the phone network gave it, as strong * as a messenger's; it joins only on a mobile number, since an office's landline is everyone's who works there. */ export const phonePairJoins = (phone: string, holders: Holder[]): boolean => @@ -64,13 +64,13 @@ export const phonePairJoins = (phone: string, holders: Holder[]): boolean => (holders.some(({ externalId }) => externalId === `phone:${phone}`) && isMobilePhone(phone)) /** - * BUG-774: holders that each come from a different source are one human seen by each of them (their CRM card, their + * Holders that each come from a different source are one human seen by each of them (their CRM card, their * WhatsApp, their call), not people on one line, however many person rows they still are. */ export const oneHolderPerSource = (holders: Holder[]): boolean => new Set(holders.map(({ list }) => list)).size === holders.length -/** NEED-2446, safe option until the owner rules: an address more than two people have is shared, so it proposes. */ +/** Safe option until the owner rules: an address more than two people have is shared, so it proposes. */ const addressGroupJoins = (people: number): boolean => people <= 2 export interface Holder { @@ -88,7 +88,7 @@ const NOT_A_BOT = "i.bot IS NOT 1 AND i.provider NOT LIKE '%-bot'" const COMPANY = "EXISTS (SELECT 1 FROM organization_identities o WHERE o.identity_id = i.id) AS company" /** - * SEC-177: a company's line or mailbox is everyone's who works there, so it never says two people are one. It is one + * A company's line or mailbox is everyone's who works there, so it never says two people are one. It is one * when an organization holds it, or when two people of one list have it, such as two CRM contacts with one number. A * CRM's contact and its user may be one person, so they are two lists. A messenger keeps one account per number, so * two of its accounts on one number are a number that changed hands, not a company's line. @@ -169,7 +169,7 @@ const add = (found: Holders, key: string | undefined, holder: Holder) => { } /** - * NEED-2600: a CRM keeps a number as someone typed it, `8 (912) 345-67-89`; without a `+` it is read in the store's + * A CRM keeps a number as someone typed it, `8 (912) 345-67-89`; without a `+` it is read in the store's * `phone_countries` (Russian by default), so a call from that number finds the contact. A messenger's bare digits stay * international (`storedPhone`). */ @@ -268,7 +268,7 @@ interface Pass { } /** - * Joins two people unless the owner separated them, or rejected the pair (NEED-2444): then the pair is proposed when + * Joins two people unless the owner separated them, or rejected the pair: then the pair is proposed when * this evidence is new to the owner. Gives the person that stays. */ const join = ( @@ -304,7 +304,7 @@ const join = ( } /** - * SEC-177: the scan never joins the owner or proposes anyone to them; a mailbox or number the owner reads may be + * The scan never joins the owner or proposes anyone to them; a mailbox or number the owner reads may be * someone else's, and only the owner joins anyone to themselves. */ const touchesOwner = ({ context, result }: Pass, from: number, to: number, signal: string): boolean => { @@ -353,9 +353,9 @@ const skipShared = (pass: Pass, people: Map, signal: string) => pass.result.skipped.push({ persons: [...people.keys()].map(String), signal, reason: `identity.shared-${signal}` }) /** - * A number two people have joins them (NEED-2445), and so does one each source has once (BUG-774); one that more - * share proposes. A company's line does neither. A proposal still open for the pair never keeps it from joining - * (BUG-775): the join settles it. + * A number two people have joins them, and so does one each source has once; one that more + * share proposes. A company's line does neither. A proposal still open for the pair never keeps it from joining: + * the join settles it. */ const samePhone = (pass: Pass, phone: string, holders: Holder[]) => { const people = peopleOf(pass.context, holders) @@ -404,7 +404,7 @@ const sharedMailboxCase = (context: StoreContext, address: string, from: number, } /** - * NEED-2526: a shared mailbox never joins anyone (SEC-177), but each pair on it is proposed to the owner, scored by + * A shared mailbox never joins anyone, but each pair on it is proposed to the owner, scored by * what else they share. */ const proposeShared = (pass: Pass, { address, holders, shared }: SharedGroup) => { @@ -428,8 +428,8 @@ const proposeShared = (pass: Pass, { address, holders, shared }: SharedGroup) => } /** - * One address is one person in any scope (NEED-2382), unless more than two people have it (NEED-2446). A no-reply - * address is no one's. A role address such as `info@` and a company's mailbox only propose (NEED-2526). + * One address is one person in any scope, unless more than two people have it. A no-reply + * address is no one's. A role address such as `info@` and a company's mailbox only propose. */ const sameEmail = (pass: Pass, address: string, holders: Holder[]) => { if (isNoReplyAddress(address)) return @@ -465,7 +465,7 @@ const providersOf = ({ database }: StoreContext, person: number): Set => ) /** - * SEC-177: a phone or address proves only when it is these two people's alone. A chat or a company's domain is weaker, + * A phone or address proves only when it is these two people's alone. A chat or a company's domain is weaker, * and is enough only between people of one source, whose names come from one place. */ const strongEnough = (context: StoreContext, from: number, to: number, trace: SharedTrace): boolean => { diff --git a/src/store/sqlite/pipeline-period.ts b/src/store/sqlite/pipeline-period.ts index 46d297679..1b6442ee3 100644 --- a/src/store/sqlite/pipeline-period.ts +++ b/src/store/sqlite/pipeline-period.ts @@ -33,7 +33,7 @@ export const boundOf = (value: string | undefined, what: string, zone: string, e } } -/** A stage the CRM removed stays in a pipeline only while a row stands in it (BUG-7). */ +/** A stage the CRM removed stays in a pipeline only while a row stands in it. */ export const SHOWN_STAGE = "(s.deleted_at IS NULL OR EXISTS (SELECT 1 FROM deals d WHERE d.stage_id = s.id AND d.deleted_at IS NULL) " + "OR EXISTS (SELECT 1 FROM leads l WHERE l.stage_id = s.id AND l.deleted_at IS NULL))" diff --git a/src/store/sqlite/relation-list.ts b/src/store/sqlite/relation-list.ts index 8c9f5c1be..25a9fd65b 100644 --- a/src/store/sqlite/relation-list.ts +++ b/src/store/sqlite/relation-list.ts @@ -42,7 +42,7 @@ export interface RelationFilter { accounts?: AccountKey[] /** No row with an end of these types, such as `deal` and `lead` a profile denies. */ deniedKinds?: string[] - /** No row with a deal or lead end that one of these may not read (SEC-197); each limits only its own account. */ + /** No row with a deal or lead end that one of these may not read; each limits only its own account. */ viewers?: readonly CopyViewer[] limit?: number /** 1-based. */ diff --git a/src/store/sqlite/vectors.ts b/src/store/sqlite/vectors.ts index bf75de4c4..60dbf61c2 100644 --- a/src/store/sqlite/vectors.ts +++ b/src/store/sqlite/vectors.ts @@ -76,7 +76,7 @@ const chunkLines = (orm: StoreContext["orm"], conversation: number, first: numbe /** * Whether a found chunk still says what its vector encodes. A build never makes a deleted message a member, - * so any deleted one in range went after the build: the hit goes, whatever text is left (NEED-393, NEED-550). + * so any deleted one in range went after the build: the hit goes, whatever text is left. */ export const chunkFreshness = ( { orm }: StoreContext, diff --git a/src/store/types.ts b/src/store/types.ts index f3c35117f..3c382be93 100644 --- a/src/store/types.ts +++ b/src/store/types.ts @@ -174,7 +174,7 @@ export interface ConversationBuild { /** * A conversation found by meaning: the chunk that matched best, and how near it is (−1 to 1). `stale` when - * the chunk's messages no longer read as they did when it was embedded (NEED-550 B). + * the chunk's messages no longer read as they did when it was embedded. */ export interface ConversationHit { summary: ConversationSummary From 4b7840d7802b09a0ba585b7236014819b6366571 Mon Sep 17 00:00:00 2001 From: leemour Date: Mon, 23 Nov 2026 23:41:21 +0100 Subject: [PATCH 04/48] feat!: wirecat.stable names the stable entry points; @experimental marks the rest inside them package.json lists the stable export subpaths in wirecat.stable: ".", ./cli, ./cli/start, ./mcp, ./sends, ./skill-validation, ./sqlite-runtime, ./store, ./testing and ./update. Every other entry point is experimental as a whole. Inside them, about 990 declarations carry @experimental: the values fewer than two CLIs import on main (cli-template counts as all of them), and the types no stable name reaches. MessageStore stays stable in accounts, chats, messages, people, tags and close; its other 56 areas are tagged, as their family entry points are experimental. MessageStore moves into src/store/message-store.ts (store.ts was at the 500-line cap), and ./cli stops re-exporting five cli-base names no CLI imports from it. README and REFERENCE describe the 1.0 promise. Co-Authored-By: Claude Opus 5.5 --- README.md | 15 +- changes/1.0-surface.md | 16 +- docs/REFERENCE.md | 31 ++- package.json | 12 + src/analysis/settings.ts | 4 +- src/background/deliver.ts | 3 + src/background/lock.ts | 2 +- src/background/schedules.ts | 16 +- src/background/when.ts | 24 +- src/cli/account-rename.ts | 3 + src/cli/after-dashes.ts | 1 + src/cli/agent-evaluation.ts | 9 +- src/cli/app-doctor-command.ts | 1 + src/cli/ask-before-write.ts | 1 + src/cli/base-stages-command.ts | 2 + src/cli/bot/api-http.ts | 10 +- src/cli/bot/api-input.ts | 3 +- src/cli/bot/api-rpc.ts | 2 + src/cli/bot/context.ts | 3 +- src/cli/bot/copy.ts | 1 + src/cli/bot/messages.ts | 7 +- src/cli/bot/port.ts | 16 +- src/cli/bot/registry.ts | 9 +- src/cli/bot/updates.ts | 3 +- src/cli/call-stats-command.ts | 3 + src/cli/command-contract.ts | 3 + src/cli/command-runs.ts | 4 +- src/cli/commands-command.ts | 1 + src/cli/compact.ts | 21 +- src/cli/config-command.ts | 1 + src/cli/config-issues.ts | 8 +- src/cli/config-keys.ts | 5 +- src/cli/context.ts | 6 +- src/cli/contract-evidence.ts | 1 + src/cli/csv.ts | 5 +- src/cli/default-config.ts | 2 + src/cli/doctor-reports-command.ts | 6 +- src/cli/effects.ts | 37 ++- src/cli/entry.ts | 5 +- src/cli/envelope.ts | 18 +- src/cli/execution.ts | 1 + src/cli/findings-input.ts | 12 +- src/cli/first-run.ts | 11 +- src/cli/group-lock.ts | 6 + src/cli/guide.ts | 7 +- src/cli/help/command-help.ts | 16 +- src/cli/help/first-screen.ts | 2 + src/cli/help/sections.ts | 1 + src/cli/index.ts | 10 +- src/cli/input-policy.ts | 3 + src/cli/json-fields.ts | 1 + src/cli/list-query.ts | 16 +- src/cli/listings.ts | 18 +- src/cli/local-times.ts | 5 +- src/cli/mcp-server-command.ts | 5 +- src/cli/meeting-batch.ts | 3 +- src/cli/meeting-evidence-answer.ts | 4 +- src/cli/meeting-meaning-command.ts | 5 + src/cli/meeting-passage-text.ts | 1 + src/cli/meeting-preparation-answer.ts | 1 + src/cli/meeting-preparation-read.ts | 2 + src/cli/meeting-project-candidates-read.ts | 1 + src/cli/meeting-results.ts | 5 +- src/cli/meeting-series-inventory-read.ts | 2 + src/cli/meeting-tags-command.ts | 2 + src/cli/messenger/context.ts | 1 + src/cli/messenger/doctor-command.ts | 3 +- src/cli/messenger/lacks.ts | 1 + src/cli/messenger/mcp-command.ts | 9 +- src/cli/messenger/message-items.ts | 4 +- src/cli/messenger/report.ts | 5 +- src/cli/messenger/search-answers.ts | 11 +- src/cli/messenger/searches-command.ts | 5 +- src/cli/messenger/serve-members.ts | 5 +- src/cli/messenger/serve-outdated.ts | 9 +- src/cli/messenger/serve-stems.ts | 4 + .../messenger/store-maintenance-command.ts | 1 + src/cli/messenger/stored.ts | 2 + src/cli/messenger/tasks-command.ts | 1 + src/cli/model-catalogue-command.ts | 1 + src/cli/oauth-session.ts | 16 +- src/cli/paging.ts | 1 + src/cli/permission-keys.ts | 12 +- src/cli/profile.ts | 6 +- src/cli/project-evidence.ts | 10 +- src/cli/project-status-rows.ts | 3 +- src/cli/project-status.ts | 16 +- src/cli/result-fields.ts | 2 + src/cli/schedule/harnesses.ts | 15 +- src/cli/schedule/schedule-command.ts | 22 +- src/cli/search-left-out.ts | 4 + src/cli/service-api-manifest.ts | 9 +- src/cli/service-api.ts | 5 +- src/cli/settings.ts | 12 +- src/cli/setup-answers.ts | 3 + src/cli/shared-command-exports.ts | 21 ++ src/cli/steps.ts | 6 +- src/cli/store-info.ts | 2 + src/cli/store-recover.ts | 12 +- src/cli/store-settings.ts | 9 +- src/cli/templates-command.ts | 1 + src/context/evidence.ts | 4 + src/domain/addresses.ts | 10 +- src/domain/business.ts | 25 +- src/domain/counters.ts | 4 + src/domain/crm.ts | 23 +- src/domain/deals.ts | 9 +- src/domain/display-names.ts | 4 +- src/domain/finance.ts | 10 +- src/domain/formatting.ts | 1 + src/domain/knowledge.ts | 7 +- src/domain/links.ts | 16 +- src/domain/locator.ts | 5 +- src/domain/markdown.ts | 1 + src/domain/models.ts | 53 ++-- src/domain/money.ts | 18 +- src/domain/orders.ts | 5 +- src/domain/person-kinds.ts | 4 +- src/domain/phones.ts | 2 + src/domain/polls.ts | 1 + src/domain/providers.ts | 29 ++- src/domain/rankings-graph.ts | 2 + src/domain/rankings-options.ts | 5 + src/domain/record-types.ts | 6 +- src/domain/records-table.ts | 21 +- src/domain/records.ts | 20 +- src/domain/ref-summaries.ts | 27 ++- src/domain/references.ts | 6 +- src/domain/relation-role-labels.ts | 6 +- src/domain/relations.ts | 40 ++- src/domain/tag-consolidation.ts | 5 + src/domain/tag-redirects.ts | 5 +- src/domain/tags.ts | 2 + src/domain/vcard.ts | 5 +- src/entities/business-context.ts | 14 +- src/entities/knowledge-lists.ts | 3 + src/entities/list-results.ts | 1 + src/entities/listings.ts | 17 +- src/entities/note.ts | 1 + src/entities/store-records.ts | 1 + src/errors/failures.ts | 4 +- src/errors/reasons.ts | 1 + src/http/link-fetch.ts | 1 + src/http/public-url.ts | 8 +- src/kit/contract.ts | 2 +- src/kit/fake.ts | 3 +- src/kit/search-recipes.ts | 2 + src/kit/seed.ts | 5 +- src/mail/findings.ts | 2 +- src/mcp/agent.ts | 3 + src/mcp/all-profiles.ts | 14 +- src/mcp/bot/instructions.ts | 5 +- src/mcp/caller.ts | 1 + src/mcp/http/oauth.ts | 1 + src/mcp/http/serve.ts | 3 + src/mcp/http/state.ts | 2 +- src/mcp/meeting-preparation.ts | 6 +- src/mcp/meeting-project-candidates.ts | 2 + src/mcp/meeting-series-inventory.ts | 2 + src/mcp/prompts.ts | 1 + src/mcp/surface.ts | 3 +- src/meetings/findings-rules.ts | 2 + src/meetings/findings.ts | 5 + src/meetings/mcp/agent-text.ts | 16 +- src/meetings/payment.ts | 18 +- src/meetings/read-store.ts | 8 + src/meetings/reference.ts | 3 + src/meetings/result-items.ts | 1 + src/moderation/check.ts | 4 +- src/moderation/rules.ts | 5 +- src/ports/app.ts | 1 + src/ports/messenger.ts | 82 ++++--- src/ports/traits.ts | 5 +- src/ports/wirecat-tools.ts | 2 +- src/render/messages.ts | 8 +- src/replies/dry-run.ts | 1 + src/replies/rendering.ts | 2 + src/replies/serve.ts | 8 +- src/replies/state.ts | 1 + src/resolve.ts | 6 +- src/runs/events.ts | 3 +- src/runs/log-events.ts | 5 +- src/runs/provider-log.ts | 10 +- src/runs/recording.ts | 10 +- src/runs/run-context.ts | 1 + src/runs/run.ts | 1 + src/runs/scope.ts | 1 + src/search/languages.ts | 5 +- src/search/service-query.ts | 9 +- src/sends/buttons.ts | 10 +- src/sends/flood.ts | 4 +- src/sends/guard.ts | 1 + src/sends/guarded.ts | 5 +- src/sends/journal.ts | 4 +- src/sends/pace.ts | 7 +- src/sends/permissions.ts | 17 +- src/sends/polls.ts | 9 +- src/sends/recipients.ts | 1 + src/sends/upload.ts | 8 +- src/services/inbox.ts | 8 +- src/services/moment.ts | 1 + src/services/people.ts | 2 +- src/services/questions.ts | 1 + src/services/task-rules.ts | 1 + src/services/tasks.ts | 2 + src/setup/document.ts | 24 +- src/sqlite-runtime.ts | 2 + src/store/account-store.ts | 5 +- src/store/accounts.ts | 1 + src/store/attachments.ts | 2 + src/store/conversations.ts | 1 + src/store/counters.ts | 2 + src/store/damage.ts | 3 + src/store/decision-requests.ts | 13 +- src/store/decisions.ts | 6 +- src/store/document-transfer/index.ts | 2 + src/store/document-transfer/model.ts | 3 + src/store/driver.ts | 2 + src/store/evidence-findings.ts | 12 +- src/store/health.ts | 5 +- src/store/identity-links.ts | 15 +- src/store/identity-splits.ts | 3 +- src/store/knowledge-query.ts | 3 + src/store/mail-findings.ts | 5 +- src/store/marks.ts | 23 +- src/store/meeting-findings.ts | 2 + src/store/mentions.ts | 2 + src/store/message-store.ts | 214 ++++++++++++++++ src/store/messages.ts | 1 + src/store/migrations.ts | 3 + src/store/people.ts | 1 + src/store/project-transfer/manifest.ts | 4 +- src/store/project-transfer/plan.ts | 4 +- src/store/project-transfer/preview.ts | 2 + src/store/project-transfer/schema.ts | 1 + src/store/project-transfer/snapshot-model.ts | 4 + src/store/project-transfer/snapshot-plan.ts | 3 +- src/store/project-transfer/snapshot.ts | 4 +- src/store/project-transfer/store.ts | 5 +- src/store/providers.ts | 1 + src/store/queries.ts | 2 +- src/store/roster.ts | 1 + src/store/search-index.ts | 1 + src/store/searches.ts | 1 + src/store/source-review.ts | 19 +- src/store/store.ts | 228 ++++-------------- src/store/sync.ts | 1 + src/store/types.ts | 6 +- src/store/vectors.ts | 2 + src/tasks/model.ts | 8 +- src/tasks/priority.ts | 13 +- src/terminal/qr.ts | 1 + src/update/index.ts | 6 +- 253 files changed, 1629 insertions(+), 545 deletions(-) create mode 100644 src/store/message-store.ts diff --git a/README.md b/README.md index 423609394..903b16d8f 100644 --- a/README.md +++ b/README.md @@ -50,9 +50,10 @@ Acme. The search found "are you coming?" from the word "come", with no network. npm install --save-exact @wirecat/cli-core ``` -npm 7+ and pnpm also install its peers: `@wirecat/cli-base` in the range `package.json` names, and `commander` 15 or -later. `@napi-rs/canvas` is optional, and charts need it only for PNG output. It runs on Node 22.16+ and 24+, and on -Bun. Pin an exact version, because any release before 1.0 may break a caller ([Build on it](#build-on-it)). +npm 7+ and pnpm also install its peers: `@wirecat/cli-base` in the range `package.json` names, and `commander` 15. +`@napi-rs/canvas` is optional, and charts need it only for PNG output. It runs on Node 22.16+ and 24+, and on Bun. +The stable API follows semver. Names marked `@experimental`, and the entry points outside `wirecat.stable`, may +change in a minor ([Build on it](#build-on-it)). [Architecture](docs/dev/ARCHITECTURE.md) · [Write an adapter](docs/dev/ADAPTERS.md) · [Query language](docs/search/query-language.md) · [Messenger rules](docs/dev/STANDARD.md) · @@ -157,9 +158,11 @@ describe("the adapter keeps the port's promises", () => { }) ``` -**Before 1.0, any release may break a caller.** Releases are frequent, sometimes several a day, and any of them may -change any entry point. The [changelog](CHANGELOG.md) lists every such change in its own section, with what to change. -tg-cli and max-cli pin an exact version and move to a new one in their own pull request. Pin an exact version too. +**The stable API follows semver from 1.0.0.** The entry points in `wirecat.stable` (`package.json`) are stable, +except the names whose doc comment says `@experimental`; a break of them needs a major. Everything else is +experimental and may change in a minor, and releases are frequent, sometimes several a day. The +[changelog](CHANGELOG.md) lists every change that needs one, with what to change. Using only stable names, `^1.0.0` is +safe; using experimental ones, pin an exact version, as tg-cli and max-cli do. The full list of entry points and what each holds is in the [API reference](docs/REFERENCE.md). ⚠ **Errors are recognised by shape, not by class** (`isCliFailure`). A package linked during development brings its diff --git a/changes/1.0-surface.md b/changes/1.0-surface.md index 7a82fd5ea..87648ab50 100644 --- a/changes/1.0-surface.md +++ b/changes/1.0-surface.md @@ -1,3 +1,13 @@ +### Added + +- **A stable API under semver.** `package.json` lists the stable entry points in `wirecat.stable`: `.`, `./cli`, + `./cli/start`, `./mcp`, `./sends`, `./skill-validation`, `./sqlite-runtime`, `./store`, `./testing` and `./update`. + Inside them, a name whose doc comment says `@experimental` is outside the promise, and so is every other entry point. + From 1.0.0 a break of the stable API needs a major; a change to experimental names needs only a minor. The stable + names are the ones two or more CLIs import (or the CLI template), and the types those names reach. `MessageStore` + is stable in `accounts`, `chats`, `messages`, `people`, `tags` and `close`; its other areas are experimental, like + the family entry points (`./meetings`, `./mail`, `./crm` and the rest) they belong to. + ### Changed — may break callers - **The peer ranges are bounded for 1.0.** `@wirecat/cli-base` is `>=0.125.0 <1.0.0 || ^1.0.0-0`, so cli-base 1.0 and @@ -8,10 +18,14 @@ - **`@wirecat/cli-core/store` no longer re-exports the SQLite implementation.** About 390 names declared under `src/store/sqlite/` (maintenance helpers such as `resetAttachmentWords` and `backfillNormalized`, row types, query constants and the area interfaces) left the entry. `openStore`, `StoreOptions`, `MessageStore`, `storePath` - and the other names declared outside `src/store/sqlite/` stay. The 76 of them that CLIs import moved to the new + and the other names declared outside `src/store/sqlite/` stay. The 78 of them that CLIs import moved to the new experimental entry `@wirecat/cli-core/store/areas` under the same names: change the import path. The rest have no importer; their types are still reachable as members of `MessageStore`, for example `MessageStore["mail"]`. +- **`./cli` no longer re-exports five cli-base names** that no CLI imports from it: `assertSharedContracts`, + `customizeSharedCommand`, `SharedContractOverride`, `sharedContractOverrides` and `sharedContracts`. Import them + from `@wirecat/cli-base/commands`. + ### Removed - **`searchAllIncludingMeetings` and its types** (`ResourceWithMeetings`, `MeetingSearchCursor`, diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index feffb2541..eccab3f06 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -804,20 +804,17 @@ fragments in `changes/` until then; there is no gap to keep between releases and jobs build tg-cli, max-cli and whatsapp-cli from their `main` against every pull request; a change that fails there, or passes only against a CLI branch made for it, needs those CLI branches ready before it is released. -**Before 1.0, any release may break a caller.** A change that does is listed in the changelog under -"Changed — may break callers", with what to change in a consumer. - -The exports below are the ones consumers lean on most. A change to them is made with the most care and -always says what to change. - -| Export | Stable | -|---|---| -| `.` | the domain types (`Chat`, `Message`, `Contact`, `Page`, …), the message locator | -| `./cli` | `Messenger`, `MessengerAdapter` and its method groups (`MessengerCore` required; `ServerReads` and the rest optional), `createProgram`, `run`, `messengerContext`, the command factories' names and arguments | -| `./store` | `openStore`, `MessageStore`, `storePath`, and the file format: `minCompatible` rises only in a release that lists it under "Changed — may break callers" | -| `./sends` | `sendGuard`, `SendJournal`, the journal's line format | -| `./speech` | The pinned speech-model catalogue, shared directories, verified installer and installed-only bounded PCM recognizer. Importing it does not load a recognizer or download a model | -| `./services` | `servicesFor`, `Override` and the service names | -| `./background` | `lockPath`, `readLock`, `holdLock`, `releaseLock`, `servingProfiles`, `alive`, `carries`, `holdersOf`, `ServerSystem`, `thisMachine`, `platformFor` and the systemd and launchd units · the serve relay: `listenRelay(path, run)`, `relayCommand(path, request, options)`, `relayPath(lockPath)`, `RELAY_PROTOCOL` | - -`./testing` and `./parity` are not on this list. tg-cli and max-cli take new versions through Dependabot pull requests. +**From 1.0.0, only the stable API follows semver.** `wirecat.stable` in `package.json` lists the stable entry +points: `.`, `./cli`, `./cli/start`, `./mcp`, `./sends`, `./skill-validation`, `./sqlite-runtime`, `./store`, +`./testing` and `./update`. Inside them, a name whose doc comment carries `@experimental` is outside the promise, and +every entry point not on the list is experimental as a whole (`./meetings`, `./mail`, `./crm`, `./store/areas`, …). + +- A break of a stable name raises the major, and comes first as a deprecation in a minor. It is listed under + "Changed — may break callers" or "Removed". +- A change to an experimental name raises the minor. Pin an exact version if you use one. +- `MessageStore` is stable in `accounts`, `chats`, `messages`, `people`, `tags` and `close`. Its other areas are + experimental, as are the family entry points they serve. +- The store file format is stable too: `minCompatible` rises only in a major. + +The stable names are the ones that two or more WireCat CLIs import, or the CLI template, plus every type those +names reach. tg-cli and max-cli take new versions through Dependabot pull requests. diff --git a/package.json b/package.json index 20d6ad403..50cc0ba50 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,18 @@ }, "type": "module", "wirecat": { + "stable": [ + ".", + "./cli", + "./cli/start", + "./mcp", + "./sends", + "./skill-validation", + "./sqlite-runtime", + "./store", + "./testing", + "./update" + ], "store": { "speaks": 72, "minCompatible": 56 diff --git a/src/analysis/settings.ts b/src/analysis/settings.ts index be8f0e6b8..53e3fccce 100644 --- a/src/analysis/settings.ts +++ b/src/analysis/settings.ts @@ -16,7 +16,7 @@ const AI_FIELDS = { } const fileKey = (key: string) => key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`) -/** The AI settings as the config file names them, in snake_case; `AISettings` is what the code reads. */ +/** The AI settings as the config file names them, in snake_case; `AISettings` is what the code reads. @experimental */ export const AI_ENTRIES = Object.fromEntries( Object.entries(AI_FIELDS).map(([key, schema]) => [fileKey(key), schema]), ) as { @@ -26,9 +26,11 @@ export const AI_ENTRIES = Object.fromEntries( embedding_dims: (typeof AI_FIELDS)["embeddingDims"] models: (typeof AI_FIELDS)["models"] } +/** @experimental */ export type AISettings = v.InferOutput> export const AI_DEFAULTS: AISettings = { embeddingProvider: "local" } +/** @experimental */ export const AI_SETTING_KEYS = Object.keys(AI_FIELDS) as (keyof AISettings)[] export const resolveAISettings = ( diff --git a/src/background/deliver.ts b/src/background/deliver.ts index 149c886ea..35cccd0df 100644 --- a/src/background/deliver.ts +++ b/src/background/deliver.ts @@ -25,8 +25,10 @@ const CHAT = /^(-?\d+|user:\d+)$/ const PROFILE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/ const ADDRESS = /^[^\s@/,<>"]+@[^\s@/,<>"]+\.[^\s@/,<>"]+$/ +/** @experimental */ export const ROUTE_HELP = "telegram-bot:/, or email:/
" +/** @experimental */ export const parseRoute = (text: string): Route => { const [, kind = "", profile = "", target = ""] = /^([a-z-]+):([^/]+)\/(.+)$/.exec(text.trim()) ?? [] const refuse = (why: string) => new CliError("validation_error", `--deliver-to ${text}: ${why} — ${ROUTE_HELP}`) @@ -40,6 +42,7 @@ export const parseRoute = (text: string): Route => { return { kind: "email", profile, address: target } } +/** @experimental */ export const routeText = (route: Route): string => `${route.kind}:${route.profile}/${route.kind === "telegram-bot" ? route.chat : route.address}` diff --git a/src/background/lock.ts b/src/background/lock.ts index 383a1b3d7..cf7f9fd23 100644 --- a/src/background/lock.ts +++ b/src/background/lock.ts @@ -80,7 +80,7 @@ export const readCurrent = (lock: string): string | undefined => { } } -/** The profiles a serve is running for now — what an update must restart for its new code to run. */ +/** The profiles a serve is running for now — what an update must restart for its new code to run. @experimental */ export const servingProfiles = (app: AppIdentity, env: NodeJS.ProcessEnv): string[] => { const dir = dirname(lockPath(app, "default", env)) if (!existsSync(dir)) return [] diff --git a/src/background/schedules.ts b/src/background/schedules.ts index 7aa12c2d4..e9f16f287 100644 --- a/src/background/schedules.ts +++ b/src/background/schedules.ts @@ -101,7 +101,10 @@ export type Notify = (typeof NOTIFY_WHEN)[number] export const notifyOf = (schedule: Pick): Notify => schedule.notify ?? (schedule.kind === "agent" && "every" in schedule.when ? "failures" : "always") -/** What a gated agent waits for, and what a day of its runs may cost, when neither its flags nor the config say. */ +/** + * What a gated agent waits for, and what a day of its runs may cost, when neither its flags nor the config say. + * @experimental + */ export const SCHEDULE_DEFAULTS = { mailWaitMinutes: 30, mailBatch: 10, maxCostPerDay: 5 } as const /** One local day's cost of a schedule's runs, as the harness reported it (`spend.json` beside the schedule). */ @@ -116,7 +119,7 @@ export const localDay = (at: Date): string => const spendFile = (file: string) => join(file, "..", "spend.json") -/** What the schedule's runs cost today; nothing before its first priced run of the day. */ +/** What the schedule's runs cost today; nothing before its first priced run of the day. @experimental */ export const spentToday = (file: string, now = new Date()): number => { try { const spend = JSON.parse(readFileSync(spendFile(file), "utf8")) as DaySpend @@ -171,7 +174,10 @@ const reportOf = (stdout: Buffer): { text: Buffer; costUsd?: number; failed?: tr */ export type AgentInput = (schedule: Schedule, run: (argv: string[]) => Promise) => Promise -/** The most an agent's input may hold; a longer one is cut, so a mailbox in flood cannot grow every turn's context. */ +/** + * The most an agent's input may hold; a longer one is cut, so a mailbox in flood cannot grow every turn's context. + * @experimental + */ export const AGENT_INPUT_MAX_CHARS = 60_000 const capped = (input: string): string => @@ -341,6 +347,7 @@ export const failingNotice = ( const NAME = /^[a-z0-9][a-z0-9-]{0,39}$/ +/** @experimental */ export const scheduleName = (name: string): string => { if (!NAME.test(name)) { throw new CliError("validation_error", `a schedule name is lowercase letters, digits and dashes — not "${name}"`) @@ -349,13 +356,16 @@ export const scheduleName = (name: string): string => { } export const schedulesDir = (state: string) => join(state, "schedules") +/** @experimental */ export const scheduleFile = (state: string, name: string) => join(schedulesDir(state), name, "schedule.json") +/** @experimental */ export const readSchedule = (file: string): Schedule => { if (!existsSync(file)) throw new CliError("not_found", `no schedule at ${file}`) return JSON.parse(readFileSync(file, "utf8")) as Schedule } +/** @experimental */ export const lastRun = (file: string): LastRun | undefined => readRun(join(file, "..", "last.json")) /** The CLI's own schedules with their last runs, for `failingNotice`; a broken file is skipped, not thrown. */ diff --git a/src/background/when.ts b/src/background/when.ts index d9c6d9a61..5fcbbd836 100644 --- a/src/background/when.ts +++ b/src/background/when.ts @@ -1,5 +1,6 @@ -/** The days `--on` takes, Monday first. */ +/** The days `--on` takes, Monday first. @experimental */ export const WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"] as const +/** @experimental */ export type Weekday = (typeof WEEKDAYS)[number] /** One calendar time: `HH:MM` local, every day or on one weekday. */ @@ -19,6 +20,7 @@ export type When = | { calendar: Slot[] } | { once: string } +/** @experimental */ export type CalendarWhen = Extract const SYSTEMD_DAYS: Record = { @@ -40,14 +42,18 @@ export const WINDOWS_DAYS: Record = { sun: "Sunday", } +/** @experimental */ export const isCalendar = (when: When): when is CalendarWhen => "daily" in when || "weekly" in when || "calendar" in when -/** A calendar schedule's times, whichever shape it was saved in. */ +/** A calendar schedule's times, whichever shape it was saved in. @experimental */ export const slotsOf = (when: CalendarWhen): Slot[] => "daily" in when ? [{ at: when.daily }] : "weekly" in when ? [{ at: when.weekly, on: when.on }] : when.calendar -/** The shape a schedule is saved in: one slot as `daily` or `weekly`, so files and their wording stay as they were. */ +/** + * The shape a schedule is saved in: one slot as `daily` or `weekly`, so files and their wording stay as they were. + * @experimental + */ export const calendarOf = (slots: readonly Slot[]): CalendarWhen => { const seen = new Map(slots.map((slot) => [`${slot.on ?? ""} ${slot.at}`, slot])) const unique = [...seen.values()].sort( @@ -67,6 +73,7 @@ const describeSlots = (slots: Slot[]): string => { return `at ${slots.map((slot) => (slot.on ? `${SYSTEMD_DAYS[slot.on]} ${slot.at}` : `daily ${slot.at}`)).join(", ")}` } +/** @experimental */ export const describeWhen = (when: When): string => "every" in when ? `every ${when.every % 1440 === 0 ? `${when.every / 1440}d` : when.every % 60 === 0 ? `${when.every / 60}h` : `${when.every}m`}` @@ -80,7 +87,10 @@ export const onCalendar = (when: Exclude): string[] => ? [localStamp(when.once)] : slotsOf(when).map((slot) => (slot.on ? `${SYSTEMD_DAYS[slot.on]} *-*-* ${slot.at}:00` : `*-*-* ${slot.at}:00`)) -/** The local moments of a calendar schedule's runs from `from` (inclusive) to `to` (exclusive), oldest first. */ +/** + * The local moments of a calendar schedule's runs from `from` (inclusive) to `to` (exclusive), oldest first. + * @experimental + */ export const runsBetween = (when: CalendarWhen, from: number, to: number): number[] => { const slots = slotsOf(when) const moments: number[] = [] @@ -105,9 +115,13 @@ const daysFrom = (at: number, days: number) => { return moved.getTime() } -/** The run a calendar schedule has next after `now`, or the one before or at it; eight days hold every slot. */ +/** + * The run a calendar schedule has next after `now`, or the one before or at it; eight days hold every slot. + * @experimental + */ export const nextRun = (when: CalendarWhen, now: number): number | undefined => runsBetween(when, now + 1, daysFrom(now, 8))[0] +/** @experimental */ export const previousRun = (when: CalendarWhen, now: number): number | undefined => runsBetween(when, daysFrom(now, -8), now + 1).at(-1) diff --git a/src/cli/account-rename.ts b/src/cli/account-rename.ts index 5239a3a34..e62be4f2c 100644 --- a/src/cli/account-rename.ts +++ b/src/cli/account-rename.ts @@ -30,8 +30,10 @@ import { usableProfileName } from "./profile.js" import { profileFiles } from "./profile-files.js" import type { GlobalFlags, ResolveOptions, Settings } from "./settings.js" +/** @experimental */ export type AccountRenaming = AccountRemoval & Required> +/** @experimental */ export interface AccountRenameOptions { /** Unset: the one `run()` set. */ resolveSettings?: (flags: GlobalFlags, options?: ResolveOptions) => Settings @@ -71,6 +73,7 @@ const withValue = (raw: unknown, path: readonly string[], value: unknown): unkno * ` account rename `: gives the profile another name and moves everything it owns on this * computer — the sign-in, its other keyring entries, its settings, its files and what the store records of it. The * account's data in the store is keyed by the account, not the name, and stays where it is. Asks first, or `--yes`. + * @experimental */ export const accountRenameCommand = ( app: AppIdentity, diff --git a/src/cli/after-dashes.ts b/src/cli/after-dashes.ts index 84136b35a..0797437bb 100644 --- a/src/cli/after-dashes.ts +++ b/src/cli/after-dashes.ts @@ -22,6 +22,7 @@ const optionsOf = (command: Command): Map => { * `messages sync -- -100 --json` as `messages sync --json -- -100`: agents copy `-- --json` from old skill * text, and a negative id needs no `--` anyway. Only a word that is exactly one of the command's options moves, with * the value it takes; a command marked `literal_after_dashes` keeps every word after `--` as it is. + * @experimental */ export const liftOptionsAfterDashes = ( argv: readonly string[], diff --git a/src/cli/agent-evaluation.ts b/src/cli/agent-evaluation.ts index d26771625..d34a403c6 100644 --- a/src/cli/agent-evaluation.ts +++ b/src/cli/agent-evaluation.ts @@ -2,12 +2,14 @@ import { captureStreams } from "@wirecat/cli-base" import type { ProgramDefinition, RunOptions } from "./program.js" import { run } from "./program.js" +/** @experimental */ export interface AgentTask { id: string request: string maxCalls: number check: (observations: readonly Observation[]) => boolean } +/** @experimental */ export interface Observation { argv: readonly string[] exitCode: number @@ -15,10 +17,12 @@ export interface Observation { stderr: readonly string[] outputBytes: number } +/** @experimental */ export type AgentPolicy = ( task: Pick, call: (argv: string[]) => Promise, ) => Promise +/** @experimental */ export interface EvaluationResult { task: string correct: boolean @@ -27,7 +31,10 @@ export interface EvaluationResult { failure?: "call_limit" | "agent_failed" | "incorrect" } -/** The harness records metrics, never message bodies, credentials, request operands or policy reasoning. */ +/** + * The harness records metrics, never message bodies, credentials, request operands or policy reasoning. + * @experimental + */ export const evaluateAgent = async ( tasks: readonly AgentTask[], agent: AgentPolicy, diff --git a/src/cli/app-doctor-command.ts b/src/cli/app-doctor-command.ts index 425dbd8a9..0dbc15807 100644 --- a/src/cli/app-doctor-command.ts +++ b/src/cli/app-doctor-command.ts @@ -100,6 +100,7 @@ const configFiles = (path: string) => { * Run when everything else is broken, so a problem in the config file or the OAuth setting is a field, never a throw. * It reads no keyring, opens no store and calls no service: each can hang or prompt. `fixes` are the `chmod` commands * that make the config private; they go to stderr, not into the answer. + * @experimental */ export const appDoctorReport = ( app: AppIdentity, diff --git a/src/cli/ask-before-write.ts b/src/cli/ask-before-write.ts index b8b91e3b3..157cfb1e7 100644 --- a/src/cli/ask-before-write.ts +++ b/src/cli/ask-before-write.ts @@ -11,6 +11,7 @@ import { commandPathKey } from "./permission-keys.js" * already stopped it before it ran (`refuseByCommandPermissions`), and `ask` is left to the command. At `ask` the owner * is asked, `--yes` answers, an agent goes ahead, and with nobody to answer it refuses. Outside the CLI's run, where * the profile's levels are not known, it refuses too. + * @experimental */ export const askBeforeWrite = async (command: Command): Promise => { const key = commandPathKey(commandPathOf(command)) diff --git a/src/cli/base-stages-command.ts b/src/cli/base-stages-command.ts index fa4a6c7a3..1fb8c028a 100644 --- a/src/cli/base-stages-command.ts +++ b/src/cli/base-stages-command.ts @@ -19,6 +19,7 @@ import { queryTerms, termField, withQuery } from "./list-query.js" import { readAll } from "./messenger/stdin.js" import { ANSWER_SHAPE, askModel, parseProposals, recordProposals, suggestJobOf } from "./stage-suggest.js" +/** @experimental */ export interface BaseStagesCommandOptions { /** The run's environment, read for an agent's markers: an agent suggests mappings, the owner confirms and edits. */ env: () => NodeJS.ProcessEnv @@ -115,6 +116,7 @@ const kindArgument = () => new Argument("", "deal or lead: which base set" /** * `stages …`: the owner's base stages of deals and of leads, and the stages of every other pipeline mapped onto them. memo mounts it; a CRM * CLI moves a card to a base stage with `deals move stage:`. + * @experimental */ export const baseStagesCommand = (app: AppIdentity, options: BaseStagesCommandOptions): Command => { const isAgent = (command: Command) => Boolean(environmentOf(command).agent || agentOf(options.env())) diff --git a/src/cli/bot/api-http.ts b/src/cli/bot/api-http.ts index e4e76a18d..356952aeb 100644 --- a/src/cli/bot/api-http.ts +++ b/src/cli/bot/api-http.ts @@ -8,6 +8,7 @@ import { itemOf, renderAnswer } from "../envelope.js" import type { ApiCommandInput } from "./api.js" import { apiJson, graphqlVariables, parseApiJson, sendsBytes } from "./api-input.js" +/** @experimental */ export interface HttpApiRequest { method: string url: URL @@ -18,6 +19,7 @@ export interface HttpApiRequest { redirect?: "follow" | "manual" | "error" } +/** @experimental */ export interface HttpApiExecutorOptions { /** The service's name in messages: "Notion". */ service: string @@ -56,7 +58,10 @@ const segment = (name: string, value: string | undefined): string => { return encodeURIComponent(value) } -/** Why the generated command cannot send the operation's body, or `undefined` when it can: JSON, or an upload's bytes. */ +/** + * Why the generated command cannot send the operation's body, or `undefined` when it can: JSON, or an upload's bytes. + * @experimental + */ export const unsendableBody = (operation: ManifestOperation): string | undefined => { const type = operation.request?.contentType return type === undefined || sendsBytes(operation) @@ -64,7 +69,7 @@ export const unsendableBody = (operation: ManifestOperation): string | undefined : `it sends ${type}, which the generated command cannot send` } -/** One generated HTTP operation and its flags as the request they stand for; nothing is sent. */ +/** One generated HTTP operation and its flags as the request they stand for; nothing is sent. @experimental */ export const httpApiRequest = ( operation: ManifestOperation, input: ApiCommandInput, @@ -275,6 +280,7 @@ export const httpApiSend = (options: HttpApiSendOptions) => { * The `execute` of `generatedApiCommand` for any OpenAPI CLI: fills the path, adds the query, sends the JSON body * with the caller's headers through the caller's fetch, and prints the answer. Nothing here retries: a write is * never sent twice, since the first may have landed (WC-OUT-20). + * @experimental */ export const httpApiExecutor = (options: HttpApiExecutorOptions) => diff --git a/src/cli/bot/api-input.ts b/src/cli/bot/api-input.ts index 1d5e575cf..22be5c7d8 100644 --- a/src/cli/bot/api-input.ts +++ b/src/cli/bot/api-input.ts @@ -14,6 +14,7 @@ export const apiFlagOf = (name: string): string => .replace(/([a-z0-9])([A-Z])/g, "$1-$2") .toLowerCase() +/** @experimental */ export const apiOptionKey = (name: string): string => apiFlagOf(name).replace(/-([a-z0-9])/g, (_, letter: string) => letter.toUpperCase()) @@ -75,7 +76,7 @@ export const sendsBytes = (operation: ManifestOperation): boolean => { return type !== undefined && !JSON_BODY.test(type) && !FORM_BODY.test(type) } -/** The file `--body-file` names, `-` for stdin, as the bytes an upload sends. */ +/** The file `--body-file` names, `-` for stdin, as the bytes an upload sends. @experimental */ export const readApiBytes = ( path: string, read: (path: string | number) => Uint8Array = (from) => new Uint8Array(readFileSync(from)), diff --git a/src/cli/bot/api-rpc.ts b/src/cli/bot/api-rpc.ts index 15ea74c09..61fa5d93e 100644 --- a/src/cli/bot/api-rpc.ts +++ b/src/cli/bot/api-rpc.ts @@ -7,6 +7,7 @@ import { apiJson, parseApiJson } from "./api-input.js" type Definitions = Readonly> type ObjectValue = Record +/** @experimental */ export interface RpcApiBody { text?: string value: ObjectValue @@ -107,6 +108,7 @@ const flagValue = (raw: string, original: SchemaNode, definitions: Definitions): throw new CliError("validation_error", "an API parameter does not match its declared type") } +/** @experimental */ export const prepareRpcApiBody = ( operation: ManifestOperation, input: ApiCommandInput, diff --git a/src/cli/bot/context.ts b/src/cli/bot/context.ts index 5599d32eb..65b4d9343 100644 --- a/src/cli/bot/context.ts +++ b/src/cli/bot/context.ts @@ -18,7 +18,7 @@ import type { BotAdapter, BotChatRef, BotConnectOptions, BotMessenger } from "./ import { botFiles, ChatRegistry } from "./registry.js" import { BotTokenStore } from "./token.js" -/** How the owner types this bot — `max sales bot` — so a refusal names the command that fixes it. */ +/** How the owner types this bot — `max sales bot` — so a refusal names the command that fixes it. @experimental */ export const botWords = (bot: BotMessenger, profile: string): string => `${bot.app.command} ${asFirstWord(profile)}bot` /** What a messenger command refuses before it connects, for a bot: an unknown key, then a denied read. */ @@ -128,6 +128,7 @@ export const botContext = ( } } +/** @experimental */ export type BotContext = ReturnType /** `--offline` reads the local copy; a command that has to ask the messenger refuses it rather than ignoring it. */ diff --git a/src/cli/bot/copy.ts b/src/cli/bot/copy.ts index da82363c2..57cd4ee7e 100644 --- a/src/cli/bot/copy.ts +++ b/src/cli/bot/copy.ts @@ -135,4 +135,5 @@ export const botCopy = (provider: Provider) => { } } +/** @experimental */ export type BotCopy = ReturnType diff --git a/src/cli/bot/messages.ts b/src/cli/bot/messages.ts index 4ea7a0b5a..46a984c9b 100644 --- a/src/cli/bot/messages.ts +++ b/src/cli/bot/messages.ts @@ -21,7 +21,7 @@ import { botExamples } from "./examples.js" import { BOT_MESSAGES_QUERY, botMessageWindow } from "./list-queries.js" import type { BotAdapter, BotMessenger } from "./port.js" -/** The adapter's `method`, or a refusal naming what this messenger's bot cannot do. */ +/** The adapter's `method`, or a refusal naming what this messenger's bot cannot do. @experimental */ export const botCan = ( adapter: BotAdapter, method: K, @@ -35,7 +35,10 @@ export const botCan = ( return found.bind(adapter) as NonNullable } -/** The bot's own id — the key its local copy is kept under — remembered after the first time it is asked. */ +/** + * The bot's own id — the key its local copy is kept under — remembered after the first time it is asked. + * @experimental + */ export const botIdOf = async (context: BotContext, adapter: BotAdapter): Promise => { const known = context.registry.botId() if (known) return known diff --git a/src/cli/bot/port.ts b/src/cli/bot/port.ts index b67292234..b2ccac52b 100644 --- a/src/cli/bot/port.ts +++ b/src/cli/bot/port.ts @@ -84,7 +84,7 @@ export interface BotPeople { senders(): PersonFacts[] } -/** What a bot shows in a chat while it works. */ +/** What a bot shows in a chat while it works. @experimental */ export const BOT_ACTIONS = ["typing", "photo", "video", "voice", "file"] as const export type BotAction = (typeof BOT_ACTIONS)[number] @@ -120,7 +120,7 @@ export interface BotChatMembers { removeMember(chat: BotChatRef, person: Id, options: { block: boolean }): Promise } -/** One command in the menu people see when they type `/`. */ +/** One command in the menu people see when they type `/`. @experimental */ export interface BotMenuEntry { /** Without the `/`. */ name: string @@ -134,7 +134,7 @@ export interface BotMenu { setMenu(entries: BotMenuEntry[]): Promise } -/** Where a pressed button was, as `bot watch` kept it. */ +/** Where a pressed button was, as `bot watch` kept it. @experimental */ export interface BotPress { chatId: Id messageId: Id @@ -164,7 +164,7 @@ export interface BotWebhooks { deleteWebhook(url: string): Promise } -/** What happened in the bot's chats besides messages: a button, people coming and going, a start. */ +/** What happened in the bot's chats besides messages: a button, people coming and going, a start. @experimental */ export type BotNotice = | { event: "callback" @@ -190,7 +190,10 @@ export interface BotUpdateRef { /** One update as `bot watch` prints it; without `update`, a redelivery is printed and kept again. */ export type BotEvent = (MessageEvent | BotNotice) & { update?: BotUpdateRef } -/** One request as it reached `bot watch --public-url`: the body exactly as sent, never parsed and written again. */ +/** + * One request as it reached `bot watch --public-url`: the body exactly as sent, never parsed and written again. + * @experimental + */ export interface BotWebhookRequest { method: string /** Path and query, against the local listener. */ @@ -199,7 +202,7 @@ export interface BotWebhookRequest { body: Uint8Array } -/** What the receiver answers a request that is not a delivery. */ +/** What the receiver answers a request that is not a delivery. @experimental */ export interface BotWebhookAnswer { status: number body?: string @@ -226,6 +229,7 @@ export interface BotSecret { description: string } +/** @experimental */ export interface BotUpdatesPage { events: BotEvent[] /** Where the next call starts; the same as given when nothing came. Opaque to the caller. */ diff --git a/src/cli/bot/registry.ts b/src/cli/bot/registry.ts index 9ebb2aef2..f13896961 100644 --- a/src/cli/bot/registry.ts +++ b/src/cli/bot/registry.ts @@ -9,11 +9,14 @@ export interface SeenChat extends Chat { lastSeenAt: string } -/** Everything this machine keeps about its bots: seen chats, recipients, the send journal. */ +/** Everything this machine keeps about its bots: seen chats, recipients, the send journal. @experimental */ export const botsDirectory = (app: AppIdentity, env: NodeJS.ProcessEnv = process.env): string => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "bots") -/** One bot's files. The names are what max-cli has always used: a moved path would lose a recipient list, and with it the limit. */ +/** + * One bot's files. The names are what max-cli has always used: a moved path would lose a recipient list, and with it the limit. + * @experimental + */ export const botFiles = (app: AppIdentity, profile: string, env: NodeJS.ProcessEnv = process.env) => { const directory = botsDirectory(app, env) return { @@ -106,7 +109,7 @@ export class ChatRegistry { } } -/** Every profile that has ever kept a registry — the bots this machine has used. */ +/** Every profile that has ever kept a registry — the bots this machine has used. @experimental */ export const registryProfiles = (app: AppIdentity, env: NodeJS.ProcessEnv = process.env): string[] => { const directory = botsDirectory(app, env) if (!existsSync(directory)) return [] diff --git a/src/cli/bot/updates.ts b/src/cli/bot/updates.ts index a21bf05ef..4a7da8b48 100644 --- a/src/cli/bot/updates.ts +++ b/src/cli/bot/updates.ts @@ -6,6 +6,7 @@ import type { BotPress } from "./port.js" * Where the bot's next poll starts. State, not cache: a poll with it confirms everything before it * to the messenger for every reader of this bot, so losing it prints a batch twice and never loses * one. `{ "marker": … }`, the shape max-cli has always written. + * @experimental */ export class UpdatesCursor { readonly #path: string @@ -37,7 +38,7 @@ interface KeptPress extends BotPress { const KEPT_PRESSES = 500 const PRESS_LIFETIME_MS = 24 * 60 * 60 * 1000 -/** The buttons `bot watch` saw pressed, so `bot callbacks answer --text` can find the message later. */ +/** The buttons `bot watch` saw pressed, so `bot callbacks answer --text` can find the message later. @experimental */ export class PressLog { readonly #path: string diff --git a/src/cli/call-stats-command.ts b/src/cli/call-stats-command.ts index cca43beae..e836dad67 100644 --- a/src/cli/call-stats-command.ts +++ b/src/cli/call-stats-command.ts @@ -9,8 +9,10 @@ import { outputFor } from "./context.js" import { LOCAL_READ, NO_EFFECTS } from "./effects.js" import { type Body, itemOf, renderAnswer } from "./envelope.js" +/** @experimental */ export type CallStatsRead = (request: Omit) => Promise +/** @experimental */ export interface CallStatsCommandDeps { /** The calls of the profile's own account; opened when the command runs. */ read: () => Promise @@ -39,6 +41,7 @@ const positive = (value: string) => { /** * `stats calls show`, for a host whose meetings are phone calls: it mounts the command, so a host of video meetings * never shows it. Numbers over the stored calls only; nothing is read from the phone system. + * @experimental */ export const addCallStatsCommand = (program: Command, deps: CallStatsCommandDeps): void => { const stats = diff --git a/src/cli/command-contract.ts b/src/cli/command-contract.ts index cc563467c..ac42c6458 100644 --- a/src/cli/command-contract.ts +++ b/src/cli/command-contract.ts @@ -6,7 +6,9 @@ import { keyForCommand } from "../sends/permissions.js" import { answerEntitySchema, answerProjectionSchema } from "./answer-entity.js" import { answerSchema } from "./envelope.js" +/** @experimental */ export type JsonSchema = Record +/** @experimental */ export const SCHEMA_DIALECT = "https://json-schema.org/draft/2020-12/schema" /** @@ -40,6 +42,7 @@ export const findCommand = (root: Command, path: readonly string[]): Command => return at } +/** @experimental */ export const commandContract = (command: Command) => { const path = commandPathOf(command) const ancestors: Command[] = [] diff --git a/src/cli/command-runs.ts b/src/cli/command-runs.ts index 3d178c70b..15303efd2 100644 --- a/src/cli/command-runs.ts +++ b/src/cli/command-runs.ts @@ -27,6 +27,7 @@ export interface SavedRunSettings { recordInput?: RecordInput | undefined } +/** @experimental */ export interface RunSettings { record: boolean keepFailedRuns: boolean @@ -39,6 +40,7 @@ export interface RunSettings { /** * `--record`/`--no-record` first, then the config: every run is kept unless it says `record: false`, which keeps * failures only; `--no-record` keeps nothing (WC-LIFE-15). + * @experimental */ export const runSettings = (flag: boolean | undefined, saved: SavedRunSettings = {}): RunSettings => { const record = flag ?? saved.record ?? true @@ -198,7 +200,7 @@ interface Parse { const parses = new AsyncLocalStorage() -/** The id `runs show` takes for the command under way, so a write can name the run that made it. */ +/** The id `runs show` takes for the command under way, so a write can name the run that made it. @experimental */ export const commandRunId = (): string | undefined => parses.getStore()?.runs.runId() /** diff --git a/src/cli/commands-command.ts b/src/cli/commands-command.ts index cf49c0963..2376bd1c8 100644 --- a/src/cli/commands-command.ts +++ b/src/cli/commands-command.ts @@ -17,6 +17,7 @@ import { hasSharedContract } from "./shared-contracts.js" /** * The major version of the JSON every command prints. The output types live in this package, so the * contract is this package's: raise it with a major version, when a field is removed or renamed. + * @experimental */ export const CONTRACT = 3 diff --git a/src/cli/compact.ts b/src/cli/compact.ts index 4ff83c329..c25b00194 100644 --- a/src/cli/compact.ts +++ b/src/cli/compact.ts @@ -7,7 +7,7 @@ import { answerRow } from "./answer-entity.js" import type { Body } from "./envelope.js" import { STATUS_ROWS } from "./project-status-rows.js" -/** How one column prints. `text` by default. */ +/** How one column prints. `text` by default. @experimental */ export type RowValue = "text" | "time" | "day" | "count" | "files" | "reply" | "forward" export interface RowColumn { @@ -38,6 +38,7 @@ export interface RowShape { oneLine?: boolean } +/** @experimental */ export interface CompactOptions { /** IANA zone for times; the answer's `meta.timezone` wins. */ timezone: string @@ -118,7 +119,7 @@ const EVIDENCE_ROWS: Readonly> = { }, } -/** Rows for cli-core's shared entities. */ +/** Rows for cli-core's shared entities. @experimental */ export const SHARED_ROWS: Readonly> = { message: messageRow, "message.summary": messageRow, @@ -145,7 +146,7 @@ export const SHARED_ROWS: Readonly> = { ...EVIDENCE_ROWS, } -/** Any record: what names it, what it is called, what state it is in, then what it says. */ +/** Any record: what names it, what it is called, what state it is in, then what it says. @experimental */ export const GENERIC_ROW: RowShape = { columns: [ { field: ["key", "ref", "id"] }, @@ -155,12 +156,16 @@ export const GENERIC_ROW: RowShape = { text: ["text", "excerpt"], } +/** @experimental */ export type RowsResolver = (command: Command | undefined) => RowShape | undefined -/** An app's own rows by entity name (or `name.view`). */ +/** An app's own rows by entity name (or `name.view`). @experimental */ export type RowTable = Readonly> -/** The row an entity named in a section is drawn with: the app's, the shared one, else the generic one. */ +/** + * The row an entity named in a section is drawn with: the app's, the shared one, else the generic one. + * @experimental + */ export const rowsOfEntity = (table: RowTable = {}) => (entity: string): RowShape => @@ -172,7 +177,7 @@ const declaredNames = (command: Command | undefined): string[] => { return output.view ? [`${output.entity}.${output.view}`, output.entity] : [output.entity] } -/** An app's own rows by entity name, as `entityFields` takes its fields; a shared name is refused. */ +/** An app's own rows by entity name, as `entityFields` takes its fields; a shared name is refused. @experimental */ export const entityRows = (table: RowTable): RowsResolver => { const shared = Object.keys(table).filter((name) => name in ENTITIES || name in SHARED_ROWS) if (shared.length > 0) throw new Error(`entityRows: ${shared.join(", ")} is cli-core's entity; name yours apart`) @@ -182,7 +187,7 @@ export const entityRows = (table: RowTable): RowsResolver => { } } -/** The row a command's answer is drawn with: its own, its app's, the shared one, else the generic one. */ +/** The row a command's answer is drawn with: its own, its app's, the shared one, else the generic one. @experimental */ export const rowShapeOf = (command: Command | undefined, resolve?: RowsResolver): RowShape => { const own = answerRow(command) ?? resolve?.(command) if (own) return own @@ -477,7 +482,7 @@ const usableZone = (zone: string | undefined): string | undefined => { } } -/** The whole answer as compact text: header, rows, footer. Pure: no store, no clock. */ +/** The whole answer as compact text: header, rows, footer. Pure: no store, no clock. @experimental */ export const compactText = ( body: Body, shape: RowShape, diff --git a/src/cli/config-command.ts b/src/cli/config-command.ts index baed2062b..98ee5e02d 100644 --- a/src/cli/config-command.ts +++ b/src/cli/config-command.ts @@ -339,6 +339,7 @@ const repairCommand = (app: AppIdentity, config: Configuration): Command => /** * A key no command or write is checked against would be saved and do nothing — whether it * comes as `permissions.` or inside a whole `permissions` object. + * @experimental */ export const refuseUnknownKey = ( command: Command, diff --git a/src/cli/config-issues.ts b/src/cli/config-issues.ts index 9efb32e83..f8a5d1873 100644 --- a/src/cli/config-issues.ts +++ b/src/cli/config-issues.ts @@ -335,7 +335,7 @@ export const withoutIssues = (raw: unknown, issues: readonly LocatedIssue[]): un issues.map(({ at }) => at), ).pruned -/** The path `config unset ` names: a permission key keeps its dots; a number is a list item. */ +/** The path `config unset ` names: a permission key keeps its dots; a number is a list item. @experimental */ export const settingPathOf = (setting: string): string[] => setting.startsWith("permissions.") ? ["permissions", setting.slice("permissions.".length)] : setting.split(".") @@ -357,7 +357,10 @@ export const withoutPath = (raw: unknown, at: readonly string[]): { config: unkn return { config: prune(raw, [gone]).pruned, removed: true } } -/** `withoutPath` for a setting as `config unset` takes it: `mail.accounts.0.colour`, `permissions.messages.send`. */ +/** + * `withoutPath` for a setting as `config unset` takes it: `mail.accounts.0.colour`, `permissions.messages.send`. + * @experimental + */ export const withoutSetting = (raw: unknown, setting: string) => withoutPath(raw, settingPathOf(setting)) /** The public shape: where in the file is the loader's own business. */ @@ -427,6 +430,7 @@ const wholeFile = (file: string, what: string): ConfigIssue => ({ kind: "invalid /** * A config file's text, `undefined` when there is no file, or the issue when one is there and cannot be read: a * folder at the path, or a file this user may not read. Neither has a fix `config` could run. + * @experimental */ export const readConfigText = (path: string): { text: string | undefined } | { issue: ConfigIssue } => { try { diff --git a/src/cli/config-keys.ts b/src/cli/config-keys.ts index fca97c456..8d1751ee5 100644 --- a/src/cli/config-keys.ts +++ b/src/cli/config-keys.ts @@ -21,7 +21,10 @@ const problemOf = (issues: [v.BaseIssue, ...v.BaseIssue[]]): s return `${v.getDotPath(issue) ?? "the whole file"} ${reasonOf(issue)}${count}` } -/** Reads and checks a config file; a missing one is the fallback, a broken one an error naming its first problem. */ +/** + * Reads and checks a config file; a missing one is the fallback, a broken one an error naming its first problem. + * @experimental + */ export const loadSnakeCaseConfig = ( path: string, schema: T, diff --git a/src/cli/context.ts b/src/cli/context.ts index c8e84dd0f..1702cd8be 100644 --- a/src/cli/context.ts +++ b/src/cli/context.ts @@ -157,7 +157,10 @@ export const environmentOf = (comma const PAGING = ["page", "limit", "all"] -/** A generated API command's own `--page`, `--limit` or `--all` is the service's parameter, not the CLI's paging. */ +/** + * A generated API command's own `--page`, `--limit` or `--all` is the service's parameter, not the CLI's paging. + * @experimental + */ export const withoutOwnPaging = (command: Command, flags: F): F => { if (metaOf(command).origin !== "generated") return flags const own = PAGING.filter((name) => command.options.some((option) => option.attributeName() === name)) @@ -169,6 +172,7 @@ export const withoutOwnPaging = (command: Command, flags: F): /** * The command's flags as settings read them, an MCP server's `--permission` levels first: they reach a run on its * agent, never in argv. + * @experimental */ export const withAgentLevels = (command: Command, flags: F): F => { const overrides = environmentOf(command).agent?.overrides ?? [] diff --git a/src/cli/contract-evidence.ts b/src/cli/contract-evidence.ts index cfa7a1c94..8eb0a6155 100644 --- a/src/cli/contract-evidence.ts +++ b/src/cli/contract-evidence.ts @@ -16,6 +16,7 @@ export interface ContractEvidenceOptions { errors?: AppErrors } +/** @experimental */ export const contractEvidence = (root: Command, { fields, errors }: ContractEvidenceOptions = {}) => { const schemas: Record = { ...entityDefinitions() } const fieldOnly: string[] = [] diff --git a/src/cli/csv.ts b/src/cli/csv.ts index 3b682fc8a..cd5e6013e 100644 --- a/src/cli/csv.ts +++ b/src/cli/csv.ts @@ -8,6 +8,7 @@ const FORMULA = /^[=+\-@\t\r]/ /** * One cell as RFC 4180 writes it, safe to open in a spreadsheet: text that would start a formula gets a leading `'`, * since every cell may be what someone else typed into the CRM. + * @experimental */ export const csvCell = (value: unknown): string => { if (value === null || value === undefined) return "" @@ -16,11 +17,11 @@ export const csvCell = (value: unknown): string => { return /[",\r\n]/.test(safe) ? `"${safe.replaceAll('"', '""')}"` : safe } -/** A header and its rows as RFC 4180 records, without line ends; the header is guarded like any cell. */ +/** A header and its rows as RFC 4180 records, without line ends; the header is guarded like any cell. @experimental */ export const csvRecords = (header: readonly string[], rows: readonly (readonly unknown[])[]): string[] => [header, ...rows].map((row) => row.map(csvCell).join(",")) -/** The table on stdout and nothing else, every record ending in CRLF. */ +/** The table on stdout and nothing else, every record ending in CRLF. @experimental */ export const writeCsv = ( streams: Pick, header: readonly string[], diff --git a/src/cli/default-config.ts b/src/cli/default-config.ts index dbd8ef98b..96eccf7eb 100644 --- a/src/cli/default-config.ts +++ b/src/cli/default-config.ts @@ -1,6 +1,7 @@ import { existsSync, linkSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs" import { dirname, join } from "node:path" +/** @experimental */ export const DEFAULT_CONFIG = { defaults: { limit: 20, keep_runs_for_days: 30, sends_per_hour: 30, update_check: true, skill_hint: true }, profiles: {}, @@ -10,6 +11,7 @@ export const DEFAULT_CONFIG = { * Publish a complete starter file without replacing a concurrent first run or the owner's settings. `config` is * `DEFAULT_CONFIG` spelled as the reading schema declares it: an app with a schema of its own may not yet say * `keep_runs_for_days`. + * @experimental */ export function ensureDefaultConfig(path: string, config: unknown = DEFAULT_CONFIG): void { if (existsSync(path)) return diff --git a/src/cli/doctor-reports-command.ts b/src/cli/doctor-reports-command.ts index a4f57c074..5b44d34d5 100644 --- a/src/cli/doctor-reports-command.ts +++ b/src/cli/doctor-reports-command.ts @@ -14,6 +14,7 @@ import { buildReport, reportFileName } from "./messenger/report.js" import { ownPackageRoot } from "./messenger/serve-outdated.js" import { lineOf, nextStep, rootOf } from "./steps.js" +/** @experimental */ export interface DoctorReportsSource { app: AppIdentity /** What the file holds and never holds, as `doctor reports show` lists it. */ @@ -92,7 +93,10 @@ export const issueUrlFor = ( return `${app.issues}?title=${encodeURIComponent(title)}&body=${encodeURIComponent(body)}` } -/** `doctor reports show|create`: one file for the author, the same for every CLI; `collect` says what it holds. */ +/** + * `doctor reports show|create`: one file for the author, the same for every CLI; `collect` says what it holds. + * @experimental + */ export const doctorReportsCommand = (source: DoctorReportsSource): Command => { const { app, includes, excludes } = source const reports = annotate(new Command("reports"), { effects: NO_EFFECTS }).description("problem reports") diff --git a/src/cli/effects.ts b/src/cli/effects.ts index b156e109e..395fb09bf 100644 --- a/src/cli/effects.ts +++ b/src/cli/effects.ts @@ -47,6 +47,7 @@ export const changesAuthorityAt = return at !== undefined && changesAuthority(at) } +/** @experimental */ export const changesAuthorityNow = (command: Command): boolean => { if (!AUTHORITY.has(command)) return false const unless = AUTHORITY.get(command) @@ -65,6 +66,7 @@ export const logsInOrOut = (command: T): T => { return command } +/** @experimental */ export const isLogin = (command: Command): boolean => LOGIN.has(command) const KEPT_UNDER_LOCK = new WeakSet() @@ -74,6 +76,7 @@ const KEPT_UNDER_LOCK = new WeakSet() * back: what the store rebuilds from its messages (vectors, a backfill job, the mention index), a new file (a backup, * a chart, a report), or the task bookkeeping a scheduled agent does, which only adds, is undone by its pair * (merge/unmerge, claim/release) or keeps the old value in the task's history; under the lock a close only suggests. + * @experimental */ export const destroysNothing = (command: T): T => { KEPT_UNDER_LOCK.add(command) @@ -85,6 +88,7 @@ export const destroysNothing = (command: T): T => { * appends a proposal the owner decides or moves its caller's own processing mark, and nothing else. A command must * be marked `proposesOnly` **and** end with one of these paths; adding a path widens what a read-only agent can * write, so it needs its own review. + * @experimental */ export const PROPOSE_COMMANDS = [ "messages acknowledge", @@ -95,12 +99,16 @@ export const PROPOSE_COMMANDS = [ const PROPOSES = new WeakSet() -/** Marks a command of the `propose` tier; the lock lets it through only when its path is in `PROPOSE_COMMANDS`. */ +/** + * Marks a command of the `propose` tier; the lock lets it through only when its path is in `PROPOSE_COMMANDS`. + * @experimental + */ export const proposesOnly = (command: T): T => { PROPOSES.add(command) return command } +/** @experimental */ export const isProposal = (command: Command): boolean => { if (!PROPOSES.has(command)) return false const path = pathOf(command).join(" ") @@ -112,17 +120,22 @@ export const isProposal = (command: Command): boolean => { * scheduled mail triage run. Such a command is marked `narrowsUnderLock` **and** has one of these paths, and under the * lock it narrows itself: it only adds what the owner can list and remove, and replaces nothing. Adding a path widens * what a read-only agent decides for later runs, so it needs its own review. + * @experimental */ export const LOCKED_AUTHORITY_COMMANDS = ["rules add"] as const const NARROWS = new WeakSet() -/** Marks an authority change that checks the lock itself; the lock lets it through only when its path is listed. */ +/** + * Marks an authority change that checks the lock itself; the lock lets it through only when its path is listed. + * @experimental + */ export const narrowsUnderLock = (command: T): T => { NARROWS.add(command) return command } +/** @experimental */ export const admittedUnderLock = (command: Command): boolean => { if (!NARROWS.has(command)) return false const path = pathOf(command).join(" ") @@ -176,7 +189,10 @@ export const fetchesOnly = (command: Command): boolean => { ) } -/** `fetchesOnly` by command path under `root`, as an MCP catalogue asks it; an unknown path is not one. */ +/** + * `fetchesOnly` by command path under `root`, as an MCP catalogue asks it; an unknown path is not one. + * @experimental + */ export const fetchesOnlyAt = (root: Command) => (path: readonly string[]): boolean => { @@ -192,6 +208,7 @@ const FILE_OPTION = new WeakMap() * effects stay a write, as WC-CMD-17 asks, but a run without the option only reads. An MCP tool never offers the * option, so it runs through `read`; `_READ_ONLY` refuses only a run that gives it. `option` is the option's * attribute name, `output`. + * @experimental */ export const writesFileOnlyWith = (command: T, option: string): T => { const flag = command.options.find((one) => one.attributeName() === option) @@ -252,11 +269,17 @@ export const isStoreChange = (command: Command): boolean => { export const STORE_CHANGE_REFUSAL = "change the message store" -/** ` --dry-run` where the program has it, so an example of a command that calls a provider calls nothing. */ +/** + * ` --dry-run` where the program has it, so an example of a command that calls a provider calls nothing. + * @experimental + */ export const previewFlag = (program: Command): string => program.options.some((option) => option.long === "--dry-run") ? " --dry-run" : "" -/** What a read-only refusal says the command would do: the store holds more than messages outside a messenger. */ +/** + * What a read-only refusal says the command would do: the store holds more than messages outside a messenger. + * @experimental + */ export const storeChangeRefusal = (app: Pick): string => app.messenger === false ? "change the local store" : STORE_CHANGE_REFUSAL @@ -296,12 +319,14 @@ const OTHER_SERVICE = new WeakSet() * model host. Its effects still say what leaves the machine, but serve's relay has no connection to lend it, so it * always runs here. Its description says `reaches: "other_service"`, so the commands page does not call it a change * in the messenger. + * @experimental */ export const reachesOtherService = (command: T): T => { OTHER_SERVICE.add(command) return annotate(command, { reaches: "other_service" }) } +/** @experimental */ export const isOtherServiceCall = (command: Command): boolean => OTHER_SERVICE.has(command) /** An option only the owner passes: MCP tools leave it out of their input (`mcp: false`). */ @@ -324,7 +349,7 @@ export const judgedEffects = (effects: Effects | undefined): Effects | undefined const judgedStepEffects = (effects: Effects | undefined): Effects | undefined => effects?.remote === "none" ? effects : judgedEffects(effects) -/** `stepTargets`, with each command's effects judged for running unasked. */ +/** `stepTargets`, with each command's effects judged for running unasked. @experimental */ export const judgedTargets = (root: Command): NonNullable => { const targets = stepTargets(root) return (command) => { diff --git a/src/cli/entry.ts b/src/cli/entry.ts index 3510d50b5..508075cdb 100644 --- a/src/cli/entry.ts +++ b/src/cli/entry.ts @@ -160,7 +160,10 @@ export const startCli = async (entry: CliEntry): Promise => { else if (code !== undefined) io.setExitCode(code) } -/** The first-run questions, before the command acts. A dry run writes nothing, and these write the shared config. */ +/** + * The first-run questions, before the command acts. A dry run writes nothing, and these write the shared config. + * @experimental + */ export const firstRunAt = (entry: CliEntry, io: EntryIo, headless: (command: Command) => boolean) => async (command: Command): Promise => { diff --git a/src/cli/envelope.ts b/src/cli/envelope.ts index ded268804..17dc2a7f5 100644 --- a/src/cli/envelope.ts +++ b/src/cli/envelope.ts @@ -113,6 +113,7 @@ const snake = (key: string) => key.replace(/[A-Z]/g, (letter) => `_${letter.toLo /** * `snakeKeys` that keeps everything under the listed keys as written: a note's front matter, an email's headers — the * owner's or a provider's words, not field names. The key itself still goes snake_case; either spelling matches. + * @experimental */ export const snakeKeysKeeping = (verbatim: Iterable): ((value: unknown) => unknown) => { const kept = new Set(verbatim) @@ -158,14 +159,20 @@ const refuse = (value: unknown): never => { throw new Error(`not an answer envelope (keys: ${keys}) — build it with itemOf or listOf`) } -/** The answer with each next step judged by `targets` — for MCP, which prints no command line to check them by. */ +/** + * The answer with each next step judged by `targets` — for MCP, which prints no command line to check them by. + * @experimental + */ export const judgedAnswer = (value: T, targets: NonNullable): T => { if (!isBody(value)) return refuse(value) if (!value.next) return value return { ...value, next: withSafety(value.next, targets) } as T } -/** `meta` from the run the answer belongs to, so `runs show ` finds it. Complete unless it names an issue. */ +/** + * `meta` from the run the answer belongs to, so `runs show ` finds it. Complete unless it names an issue. + * @experimental + */ export const metaNow = (extra: Partial = {}): Meta => { const run = currentRun() return { @@ -176,7 +183,7 @@ export const metaNow = (extra: Partial = {}): Meta => { } } -/** The one place an answer gets its `meta`, for the CLI and MCP alike. */ +/** The one place an answer gets its `meta`, for the CLI and MCP alike. @experimental */ export const sealed = (value: T): T => { if (!isBody(value)) return refuse(value) const { meta, ...rest } = withoutProviderRefs(value) @@ -296,7 +303,10 @@ export const renderAnswer = ( export const renderDocument = ({ renderer }: Pick, document: object): void => renderer.result(document) -/** One thing as a sealed `{ item, meta }` answer, for a command that prints without `renderAnswer`'s steps. */ +/** + * One thing as a sealed `{ item, meta }` answer, for a command that prints without `renderAnswer`'s steps. + * @experimental + */ export const itemAnswer = (item: T) => sealed(itemOf(item)) /** Prints one thing: the envelope in `--json`, one record and the end line in `--jsonl`, the thing itself to a person. */ diff --git a/src/cli/execution.ts b/src/cli/execution.ts index ab3ef543f..45ce14954 100644 --- a/src/cli/execution.ts +++ b/src/cli/execution.ts @@ -204,6 +204,7 @@ export const execution = ( } } +/** @experimental */ export const withAbort = async (signal: AbortSignal | undefined, body: () => Promise): Promise => { if (!signal) return body() if (signal.aborted) throw signal.reason diff --git a/src/cli/findings-input.ts b/src/cli/findings-input.ts index ba8d2b2d3..6cc9ef676 100644 --- a/src/cli/findings-input.ts +++ b/src/cli/findings-input.ts @@ -51,13 +51,21 @@ const parseFindingsJson = (text: string, label: string, validate: (input: T) } return validate(decode(raw) as T) } +/** @experimental */ export const parseMeetingFindingsJson = (text: string): MeetingFindingsInput => parseFindingsJson(text, "meeting findings", validateMeetingFindings) +/** @experimental */ export const parseEvidenceFindingsJson = (text: string): FindingsInput => parseFindingsJson(text, "evidence findings", validateEvidenceFindings) -/** A mail findings batch as `mail findings add --dry-run` reads it: snake_case JSON, for `mailFindings.check`. */ +/** + * A mail findings batch as `mail findings add --dry-run` reads it: snake_case JSON, for `mailFindings.check`. + * @experimental + */ export const readMailFindingsJson = (text: string): MailFindingsInput => parseFindingsJson(text, "mail findings", (input: MailFindingsInput) => input) -/** A mail findings batch as `mail findings add` reads it: snake_case JSON, checked for shape before the store. */ +/** + * A mail findings batch as `mail findings add` reads it: snake_case JSON, checked for shape before the store. + * @experimental + */ export const parseMailFindingsJson = (text: string): MailFindingsInput => parseFindingsJson(text, "mail findings", validateMailFindings) diff --git a/src/cli/first-run.ts b/src/cli/first-run.ts index e98d09614..11a829d08 100644 --- a/src/cli/first-run.ts +++ b/src/cli/first-run.ts @@ -16,13 +16,14 @@ import { writeSetupAnswers, } from "./setup-answers.js" -/** The languages cli-core stems and has a dictionary for; each is one stemmer of its alphabet. */ +/** The languages cli-core stems and has a dictionary for; each is one stemmer of its alphabet. @experimental */ export interface FirstRunIo { ask: (prompt: string) => Promise say: (text: string) => void } +/** @experimental */ export interface FirstRun { command: string env: NodeJS.ProcessEnv @@ -43,6 +44,7 @@ const SKIPPED = new Set(["help", "guide", "completion", "mcp", "serve", "server" /** * Only a person at a terminal is asked. An agent in a real terminal passes every terminal check and would wait on * the question forever; a process locked read-only must write nothing, and every answer writes something. + * @experimental */ export const asksAtStart = (start: { headless: boolean @@ -58,7 +60,10 @@ export const asksAtStart = (start: { start.readOnlyLock === undefined && !SKIPPED.has(start.path[0] ?? "") -/** The system's language, as the first locale variable set names it: `LC_ALL`, `LC_MESSAGES`, `LANG`, `LANGUAGE`. */ +/** + * The system's language, as the first locale variable set names it: `LC_ALL`, `LC_MESSAGES`, `LANG`, `LANGUAGE`. + * @experimental + */ export const systemLanguage = (env: NodeJS.ProcessEnv): string | undefined => { const named = [env.LC_ALL, env.LC_MESSAGES, env.LANG, ...(env.LANGUAGE ?? "").split(":")] .map((value) => value?.trim()) @@ -232,6 +237,7 @@ const answersAt = (path: string): SetupAnswers => { /** * The questions every WireCat tool shares, asked once for all of them: the answers go to the shared config * file, the languages to the store. Only this, at a terminal, writes the permission answer. + * @experimental */ export const askSetupQuestions = async (run: FirstRun): Promise => { const path = sharedConfigPath(storePath(run.env), run.env) @@ -254,6 +260,7 @@ export const askSetupQuestions = async (run: FirstRun): Promise => { * The first-run step a tool runs before each command: asks when `asksAtStart` says so, and lets the command run * whatever happens to the questions. `setup` asks all three again, since a refusal sends the owner there. * A tool that builds its own program gets it from `startCli` as `entry.atStart`. + * @experimental */ export const setupAtStart = async (start: { command: string diff --git a/src/cli/group-lock.ts b/src/cli/group-lock.ts index 69ae79a73..494dedc79 100644 --- a/src/cli/group-lock.ts +++ b/src/cli/group-lock.ts @@ -13,12 +13,14 @@ const keepsToGroup = new WeakSet() /** * Marks a command, and every command under it, as one that keeps to the run's account group: it scopes its reads * and writes with `scopeToGroup`. Under `_GROUP_LOCK` every other command is refused (WC-ACCT-13). + * @experimental */ export const groupAware = (command: T): T => { keepsToGroup.add(command) return command } +/** @experimental */ export const isGroupAware = (command: Command): boolean => { let top: Command | undefined for (let at: Command | null = command; at?.parent; at = at.parent) { @@ -34,6 +36,7 @@ const valuesOf = (value: unknown): string[] => /** * What a bare id names: a referenced thing's kind, a proposed action (`action`, as `actions confirm 17` takes it), or * a proposal id of the review registry (`proposal`: `17070`, `17080/f1`, `link:17`, `fact:512`). + * @experimental */ export type RefKind = SimpleReference | "action" | "proposal" @@ -45,6 +48,7 @@ const declared = new WeakMap>>() * after a kind needs no entry. Under the lock a bare value there is checked as `:`; a command that * declares nothing has any other argument value refused, since what it names is unknown (`1e0`, `+1`, `link:1`). * `{}` says no argument takes an id, so free text passes. + * @experimental */ export const refKinds = (command: T, kinds: Readonly>): T => { declared.set(command, kinds) @@ -61,6 +65,7 @@ const kindAt = (command: Command, name: string, implicit: string): RefKind | und * Every reference typed into the run: each word of each argument and option value that is a reference, and each bare * id in a position whose kind is known, as `:`. `unknown` holds every other argument value of a command * that declares no kinds. + * @experimental */ export const referencesIn = (command: Command): { references: string[]; unknown: string[] } => { const references = new Set() @@ -109,6 +114,7 @@ const pathOf = (command: Command): string => { * Under `_GROUP_LOCK`, refuses a command that does not keep to a group, and a reference whose thing belongs * only to accounts outside the group. A thing no account brought is the owner's and passes in every group, a note * written in memo included; a person passes when one of their identities is in the group. + * @experimental */ export const refuseOutsideGroup = async ( command: Command, diff --git a/src/cli/guide.ts b/src/cli/guide.ts index 0553bf3cf..d8231a904 100644 --- a/src/cli/guide.ts +++ b/src/cli/guide.ts @@ -271,7 +271,7 @@ const scan = (line: string): { words: string[]; live: string[]; open: boolean } const words = (line: string): string[] => scan(line).words -/** Characters in a step that a shell would act on: the person who copies it would run something else. */ +/** Characters in a step that a shell would act on: the person who copies it would run something else. @experimental */ export const shellProblems = (run: string): string[] => { const { live, open } = scan(run) return [ @@ -304,7 +304,10 @@ const isProfileWord = (word: string | undefined): boolean => { } } -/** What is wrong with one step on this program: the path, each option and its value, the arguments. Never runs it. */ +/** + * What is wrong with one step on this program: the path, each option and its value, the arguments. Never runs it. + * @experimental + */ export const checkStep = (program: Command, run: string): string[] => { const [tool, ...rest] = words(run) if (tool !== program.name()) return [`starts with "${tool ?? ""}", not ${program.name()}`] diff --git a/src/cli/help/command-help.ts b/src/cli/help/command-help.ts index 6cb47bfa4..c90820c9e 100644 --- a/src/cli/help/command-help.ts +++ b/src/cli/help/command-help.ts @@ -88,6 +88,7 @@ const SAMPLES: Readonly> = { const MAX_NEXT = 3 +/** @experimental */ export interface NextChoice { /** Command paths shown first, in this order: `messages context`. */ pin?: readonly string[] @@ -97,7 +98,10 @@ export interface NextChoice { const choices = new WeakMap() -/** Overrides the "Next usually" a command's help derives from types. Kept off `annotate`, like its section. */ +/** + * Overrides the "Next usually" a command's help derives from types. Kept off `annotate`, like its section. + * @experimental + */ export const nextUsually = (command: T, choice: NextChoice): T => { choices.set(command, choice) return command @@ -214,6 +218,7 @@ const withProfile = (command: Command, example: string): string => { : example } +/** @experimental */ export interface CommandHelp { /** Empty when the command declares no output entity: its description already says what it does. */ returns: string @@ -223,7 +228,7 @@ export interface CommandHelp { origin: "written" | "generated" } -/** Returns, Next usually and Example for one command, from its definition alone. */ +/** Returns, Next usually and Example for one command, from its definition alone. @experimental */ export const commandHelp = (command: Command): CommandHelp => { const written = metaOf(command).examples ?? [] return { @@ -236,7 +241,7 @@ export const commandHelp = (command: Command): CommandHelp => { const LABEL = 15 -/** The lines `--help` prints after a command's options. */ +/** The lines `--help` prints after a command's options. @experimental */ export const commandHelpText = (command: Command): string => { const { returns, next, examples } = commandHelp(command) const rows = (label: string, values: readonly string[]) => @@ -287,7 +292,10 @@ export const installCommandHelp = (program: Command, { profile = true }: { profi for (const command of leaves(program)) command.addHelpText("after", () => commandHelpText(command)) } -/** Which leaf commands still show a generated example, so the important ones get a written one. Report only. */ +/** + * Which leaf commands still show a generated example, so the important ones get a written one. Report only. + * @experimental + */ export const exampleReport = (program: Command): { written: string[]; generated: string[]; text: string } => { const written: string[] = [] const generated: string[] = [] diff --git a/src/cli/help/first-screen.ts b/src/cli/help/first-screen.ts index ae851248f..a00044a8a 100644 --- a/src/cli/help/first-screen.ts +++ b/src/cli/help/first-screen.ts @@ -73,6 +73,7 @@ const pointers = (program: Command, cli: string, start: string | undefined, prof /** * The screen ` --help` and a bare `` show: what the tool is for, what it does that a client would not, * the other tools, and where the full list, the scenarios and the options are. It never lists every command. + * @experimental */ export const firstScreen = (program: Command, screen: FirstScreen = {}): string => { const cli = program.name() @@ -113,6 +114,7 @@ const optionsScreen = (program: Command): string => { * command's `--help`. `help options` prints the options for every command, `--help-all` the full commander help; * both are hidden, so `commands --json` and MCP do not change. For a tool that builds its own program; * `createProgram` calls it for tg, max and wa. + * @experimental */ export const installHelp = (program: Command, screen: FirstScreen = {}): Command => { let full = false diff --git a/src/cli/help/sections.ts b/src/cli/help/sections.ts index cf6aca18a..ca095f7fc 100644 --- a/src/cli/help/sections.ts +++ b/src/cli/help/sections.ts @@ -1,5 +1,6 @@ import type { Command } from "commander" +/** @experimental */ export const SECTIONS = { read: "Read", write: "Write", diff --git a/src/cli/index.ts b/src/cli/index.ts index dc51d08b5..b3751f361 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -806,15 +806,7 @@ export { upgradeCommand, watchCommand, } from "./shared-command-exports.js" -export { - assertSharedContracts, - customizeSharedCommand, - hasSharedContract, - overrideSharedContract, - type SharedContractOverride, - sharedContractOverrides, - sharedContracts, -} from "./shared-contracts.js" +export { hasSharedContract, overrideSharedContract } from "./shared-contracts.js" export { runnable, withSafety } from "./steps.js" export { type StoreInfo, sharedStoreCommand, storeInfo, storeInfoCommand } from "./store-info.js" export { diff --git a/src/cli/input-policy.ts b/src/cli/input-policy.ts index eb8dcef1e..dfa85a4a6 100644 --- a/src/cli/input-policy.ts +++ b/src/cli/input-policy.ts @@ -1,6 +1,8 @@ import { CliError } from "@wirecat/cli-base" +/** @experimental */ export const MAX_BUFFERED_INPUT = 16 * 1024 * 1024 +/** @experimental */ export const MAX_SECRET_INPUT = 64 * 1024 export interface InputPolicy { @@ -13,6 +15,7 @@ const policies = new WeakMap() export const inputPolicy = (input: NodeJS.ReadableStream): InputPolicy => policies.get(input) ?? {} +/** @experimental */ export const provideInputPolicy = (input: NodeJS.ReadableStream, policy: InputPolicy): (() => void) => { const previous = policies.get(input) policies.set(input, policy) diff --git a/src/cli/json-fields.ts b/src/cli/json-fields.ts index 34764ab16..10f54ac88 100644 --- a/src/cli/json-fields.ts +++ b/src/cli/json-fields.ts @@ -72,6 +72,7 @@ export interface JsonRequest { * `--json=a,b` or `--json a,b` keeps those fields, a bare `--json` all of them. The separate word is taken only when * every name in it is a field of the command's answer, so `--json chats list` and `messages list --json 111` keep * their words. Commander sees a plain `--json` either way. + * @experimental */ export const liftJson = ( argv: readonly string[], diff --git a/src/cli/list-query.ts b/src/cli/list-query.ts index 1745b3867..1e9835e4d 100644 --- a/src/cli/list-query.ts +++ b/src/cli/list-query.ts @@ -25,6 +25,7 @@ import { queryWordsAfterOptions } from "../meetings/cli/index.js" import { type ListBody, type ListInput, listOf } from "./envelope.js" import type { Settings } from "./settings.js" +/** @experimental */ export const LIST_QUERY_GUIDE = "https://github.com/WireCatLabs/cli-core/blob/main/docs/search/query-language.md" /** `[query...]`'s help, which points at the Fields section; an MCP tool has none and says the fields instead. */ @@ -156,11 +157,14 @@ export const pagedList = ( const askable = (registry: QueryRegistry) => registry.backend === "native" ? registry.fields.filter((field) => field.native) : registry.fields -/** An MCP list's `query` argument: the language the CLI list takes after its arguments. */ +/** An MCP list's `query` argument: the language the CLI list takes after its arguments. @experimental */ export const queryArgument = (registry: QueryRegistry) => v.optional(v.pipe(v.string(), v.maxLength(QUERY_LIMITS.bytes), v.description(queryDescription(registry)))) -/** The fields a native list can also leave out, `-field:value`: what `nativeTermLists` keeps under `-field`. */ +/** + * The fields a native list can also leave out, `-field:value`: what `nativeTermLists` keeps under `-field`. + * @experimental + */ export const negatableOf = (registry: QueryRegistry): string[] => askable(registry) .filter((field) => field.negatable) @@ -177,6 +181,7 @@ export const nativeTerms = (ast: QueryAst | undefined, command: string): Map` start; `from` is the first moment taken, for a reader * that takes its start. + * @experimental */ export const timeBounds = ( term: Predicate | undefined, @@ -289,11 +295,11 @@ export const timeBounds = ( } } -/** A text term as the plain words a provider searches by: `name:ana`, `name:"Ana K"`, `name:*ana*`. */ +/** A text term as the plain words a provider searches by: `name:ana`, `name:"Ana K"`, `name:*ana*`. @experimental */ export const searchText = (term: Predicate | undefined): string | undefined => term === undefined ? undefined : term.value.replace(/^\*+|\*+$/g, "") -/** A field the provider filters itself; names follow the search language, as in `search messages`. */ +/** A field the provider filters itself; names follow the search language, as in `search messages`. @experimental */ export const nativeField = (field: Omit): FieldSpec => ({ ...field, native: true }) /** A field the store filters by whole values only, as `queryTerms` reads them. */ @@ -311,5 +317,5 @@ export const termField = ( ...more, }) -/** The Fields section of a list's help, for a list that places its own `[query...]`. */ +/** The Fields section of a list's help, for a list that places its own `[query...]`. @experimental */ export const queryHelp = (registry: QueryRegistry): string => `\n${fieldsHelp(registry, LIST_QUERY_GUIDE)}` diff --git a/src/cli/listings.ts b/src/cli/listings.ts index 3c8960979..621b6c6b1 100644 --- a/src/cli/listings.ts +++ b/src/cli/listings.ts @@ -17,7 +17,7 @@ const SOURCE = termField("source", "kw", 'source:"google-drive:ana@example.com"' relation: "one account, provider:account, or every account of a provider; repeat for several", }) -/** `documents list`: what the store filters, and `text`, which the notes search answers first. */ +/** `documents list`: what the store filters, and `text`, which the notes search answers first. @experimental */ export const DOCUMENTS_LIST_QUERY = { entity: "document_entry", backend: "native", @@ -46,7 +46,7 @@ export const DOCUMENTS_LIST_QUERY = { ], } as const satisfies QueryRegistry -/** `meetings list`: the time window, and filters every row answers. */ +/** `meetings list`: the time window, and filters every row answers. @experimental */ export const MEETINGS_LIST_QUERY = { entity: "meeting_entry", backend: "native", @@ -76,8 +76,12 @@ export const MEETINGS_LIST_QUERY = { ], } as const satisfies QueryRegistry -/** Without `started_at`, the meetings list reads the last 30 days and the next 7: calls are all in the past. */ +/** + * Without `started_at`, the meetings list reads the last 30 days and the next 7: calls are all in the past. + * @experimental + */ export const MEETINGS_RECENT_DAYS = 30 +/** @experimental */ export const MEETINGS_AHEAD_DAYS = 7 const REPEATABLE = ["text", "source", "kind", "tag", "person"] @@ -110,7 +114,7 @@ const storeQueryOf = (terms: Map, fields: readonly string[] return { version: 1, language: "lucene-v1", root: { kind: "boolean", clauses, span } } } -/** `documents list`'s query and page, as `listDocuments` takes them. */ +/** `documents list`'s query and page, as `listDocuments` takes them. @experimental */ export const documentListRequest = ( words: QueryWords, { limit, page, zone = timezoneOf(), now = Date.now() }: { limit: number; page: number; zone?: string; now?: number }, @@ -150,12 +154,16 @@ const windowOf = (node: Predicate, zone: string, now: number) => { } } +/** @experimental */ export interface MeetingWindowMeta { timezone: string window: { since?: string; until?: string } } -/** `meetings list`'s query and page, as `listMeetingEntries` takes them, and the window it read for `meta`. */ +/** + * `meetings list`'s query and page, as `listMeetingEntries` takes them, and the window it read for `meta`. + * @experimental + */ export const meetingListRequest = ( words: QueryWords, { diff --git a/src/cli/local-times.ts b/src/cli/local-times.ts index 37446e052..4411fb747 100644 --- a/src/cli/local-times.ts +++ b/src/cli/local-times.ts @@ -5,7 +5,7 @@ import { type AnswerOutput, type Body, renderAnswer } from "./envelope.js" export const UTC_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/u -/** `YYYY-MM-DD HH:MM` on the wall clock of `zone`, with no offset: the answer names the zone once. */ +/** `YYYY-MM-DD HH:MM` on the wall clock of `zone`, with no offset: the answer names the zone once. @experimental */ export const wallClock = (zone: string) => { const format = new Intl.DateTimeFormat("en-CA", { timeZone: zone, @@ -31,7 +31,7 @@ export const wallClock = (zone: string) => { } } -/** Turns a UTC time into the shown one; any other text comes back as it was. */ +/** Turns a UTC time into the shown one; any other text comes back as it was. @experimental */ export type ShownTime = (value: string) => string const localised = (value: unknown, shown: ShownTime): unknown => { @@ -46,6 +46,7 @@ const localised = (value: unknown, shown: ShownTime): unknown => { * Answers as `renderAnswer` does, and a person reads every UTC time in the zone in use (`zone`, else the computer's), * with one line naming it (WC-TIME-4). A `view` builds its text with the `shown` it is given. JSON, JSONL, compact * rows and agents keep UTC (WC-TIME-2), and `next` is left alone: its args run. + * @experimental */ export const answerLocally = ( command: Command, diff --git a/src/cli/mcp-server-command.ts b/src/cli/mcp-server-command.ts index e07979d89..deac55a2b 100644 --- a/src/cli/mcp-server-command.ts +++ b/src/cli/mcp-server-command.ts @@ -17,10 +17,11 @@ import { } from "../mcp/http/state.js" import { destroysNothing, LOCAL_READ, LOCAL_WRITE } from "./effects.js" +/** @experimental */ export const MCP_HTTP_DEFAULT_PORT = 8765 const LOOKS = 120 -/** What one CLI tells `mcp server` about the server it would run. */ +/** What one CLI tells `mcp server` about the server it would run. @experimental */ export interface McpServerTarget { /** What a person types before `mcp`: `tg personal`, `memo`. */ invocation: string @@ -38,6 +39,7 @@ export interface McpServerTarget { version: string } +/** @experimental */ export interface McpServerOptions { /** How help shows the CLI before `mcp`: `tg personal`. */ example: string @@ -118,6 +120,7 @@ const clientLines = (clients: ReturnType) => * keeps a lock beside its token file (`state.ts`) with its port, address and login code, so status * survives the shell that started it, and `stop` ends only a process that carries this CLI's marker. * None of it is offered over MCP: status holds a live login code. + * @experimental */ export const mcpServerCommand = ({ example, diff --git a/src/cli/meeting-batch.ts b/src/cli/meeting-batch.ts index 8474e8697..30dbd081f 100644 --- a/src/cli/meeting-batch.ts +++ b/src/cli/meeting-batch.ts @@ -134,7 +134,7 @@ const handlers = (reader: MeetingBatchReader, meta: () => Meta, limit: number): ] } -/** `limit` is a search's page without `--limit`: the profile's `defaults.limit`. */ +/** `limit` is a search's page without `--limit`: the profile's `defaults.limit`. @experimental */ export const prepareMeetingBatch = (input: string, reader: MeetingBatchReader, meta: () => Meta, limit: number) => prepareBatch(input, handlers(reader, meta, limit)) @@ -153,6 +153,7 @@ const textResult = (result: BatchResult, format: "text" | "markdown") => { .join("\n") return `${title}\n${hits.map(hitText).join("\n\n")}\nCoverage: ${JSON.stringify({ page: "page" in body ? body.page : undefined, missing: body.missing, meta: body.meta })}\n` } +/** @experimental */ export const formatMeetingBatch = (report: BatchReport, format: "text" | "markdown") => report.items.map((result) => textResult(result, format)).join("\n") diff --git a/src/cli/meeting-evidence-answer.ts b/src/cli/meeting-evidence-answer.ts index 285c49df6..83d094202 100644 --- a/src/cli/meeting-evidence-answer.ts +++ b/src/cli/meeting-evidence-answer.ts @@ -18,10 +18,10 @@ export const mapEvidence = (evidence: MeetingEvidencePacket) => ({ items: evidence.items.map(mapCue), }) -/** `meetings evidence`: the `meeting_evidence` entity. */ +/** `meetings evidence`: the `meeting_evidence` entity. @experimental */ export const meetingEvidenceItem = (evidence: MeetingEvidencePacket) => snakeKeys(mapEvidence(evidence)) -/** `meetings context`: the `meeting_person_context` entity. */ +/** `meetings context`: the `meeting_person_context` entity. @experimental */ export const meetingPersonContextItem = (context: PersonMeetingContext) => snakeKeys({ ...context, diff --git a/src/cli/meeting-meaning-command.ts b/src/cli/meeting-meaning-command.ts index 90922cfac..e54fff58a 100644 --- a/src/cli/meeting-meaning-command.ts +++ b/src/cli/meeting-meaning-command.ts @@ -100,6 +100,7 @@ const withMeaningOptions = (command: Command): Command => .option("--max-text-bytes ", "by meaning: most transcript text to read (default 4 MiB)", count) }) +/** @experimental */ export interface MeetingCombinedSearchDeps { words: () => Promise meaning: () => Promise @@ -111,11 +112,13 @@ export interface MeetingCombinedSearchDeps { examples: string[] } +/** @experimental */ export type MeetingSearchRun = (query: string, options: SearchFlags, command: Command) => Promise /** * `search meetings` by words, and by words and meaning ranked together with `--model`, for any host of stored * meetings. Returns the run, so a host's saved searches replay it. + * @experimental */ export const addMeetingCombinedSearchCommand = ( program: Command, @@ -166,6 +169,7 @@ export const addMeetingCombinedSearchCommand = ( return execute } +/** @experimental */ export interface MeetingEmbeddingCommandDeps { meaning: () => Promise /** The local model used without `--model`: the `models` command's default text model. */ @@ -180,6 +184,7 @@ export interface MeetingEmbeddingCommandDeps { /** * `meetings embed`: previews the vectors a search by meaning needs, and `--yes` splits every transcript and embeds one * batch of the passages without a vector; run it again for the next batch. + * @experimental */ export const addMeetingEmbeddingCommand = (program: Command, deps: MeetingEmbeddingCommandDeps): void => { const meetings = program.commands.find((command) => command.name() === "meetings") diff --git a/src/cli/meeting-passage-text.ts b/src/cli/meeting-passage-text.ts index d0db0a944..0ae226136 100644 --- a/src/cli/meeting-passage-text.ts +++ b/src/cli/meeting-passage-text.ts @@ -7,6 +7,7 @@ import { runMarkOf, withUntrustedMarked } from "./untrusted-marks.js" * The passage as the host prints it from `meetings passage`'s `output`, or as `callMeetingPassageTool` answers it: in a scheduled agent's run, text and Markdown * are formatted again from the marked cues. The meetings module cannot read the run's mark; JSON is marked by * `renderAnswer`. + * @experimental */ export const passageForRun = ( command: Command, diff --git a/src/cli/meeting-preparation-answer.ts b/src/cli/meeting-preparation-answer.ts index 129bff6a8..83c49d351 100644 --- a/src/cli/meeting-preparation-answer.ts +++ b/src/cli/meeting-preparation-answer.ts @@ -21,6 +21,7 @@ const mapMeeting = (meeting: MeetingPreparation["items"][number]["meeting"]) => updatedAt: at(meeting.updatedAt), } } +/** @experimental */ export const meetingPreparationAnswer = (packet: MeetingPreparation) => { const candidate = packet.upcoming.candidate const mapped = snakeKeys({ diff --git a/src/cli/meeting-preparation-read.ts b/src/cli/meeting-preparation-read.ts index 51a9c09df..43d8d09aa 100644 --- a/src/cli/meeting-preparation-read.ts +++ b/src/cli/meeting-preparation-read.ts @@ -20,6 +20,7 @@ const bound = (name: keyof typeof MEETING_PREPARATION_LIMITS) => { const { min, max } = MEETING_PREPARATION_LIMITS[name] return v.optional(v.pipe(v.number(), v.integer(), v.minValue(min), v.maxValue(max))) } +/** @experimental */ export const meetingPreparationInput = v.strictObject({ series_id: v.pipe(v.string(), v.minLength(1), v.maxLength(1000)), communications: v.optional( @@ -38,6 +39,7 @@ export const meetingPreparationInput = v.strictObject({ // A date alone ends a window at the end of that day and starts one at its start. const instant = (value: string | undefined, fallback: number, field: string, now: number, end = false) => value === undefined ? fallback : momentOf(value, field, now, { end }) +/** @experimental */ export const readMeetingPreparation = async ( read: MeetingPreparationReader, input: unknown, diff --git a/src/cli/meeting-project-candidates-read.ts b/src/cli/meeting-project-candidates-read.ts index 142bb424a..9c75897a1 100644 --- a/src/cli/meeting-project-candidates-read.ts +++ b/src/cli/meeting-project-candidates-read.ts @@ -17,6 +17,7 @@ export const meetingProjectCandidatesInput = v.strictObject({ cursor: v.optional(v.pipe(v.string(), v.minLength(1), v.maxLength(200))), }) +/** @experimental */ export const readMeetingProjectCandidates = async ( read: StoredMeetingProjectCandidateReader, input: unknown, diff --git a/src/cli/meeting-results.ts b/src/cli/meeting-results.ts index ead00d73f..fd515b8bf 100644 --- a/src/cli/meeting-results.ts +++ b/src/cli/meeting-results.ts @@ -21,7 +21,10 @@ const publicValue = (value: unknown, key = ""): unknown => { return value } -/** Store IDs stay numeric below the CLI; public receipts use the shared string IDs and validated wire fields. */ +/** + * Store IDs stay numeric below the CLI; public receipts use the shared string IDs and validated wire fields. + * @experimental + */ export const meetingResultItem = (entity: keyof typeof MEETING_RESULT_ENTITIES, value: unknown): unknown => { const parsed = v.safeParse(MEETING_RESULT_ENTITIES[entity] as v.GenericSchema, publicValue(snakeKeys(value))) if (!parsed.success) { diff --git a/src/cli/meeting-series-inventory-read.ts b/src/cli/meeting-series-inventory-read.ts index 53419f9af..8544dd8ee 100644 --- a/src/cli/meeting-series-inventory-read.ts +++ b/src/cli/meeting-series-inventory-read.ts @@ -9,6 +9,7 @@ import { import { momentOf } from "../services/moment.js" import { itemOf, metaNow, sealed, snakeKeys } from "./envelope.js" +/** @experimental */ export type MeetingSeriesInventoryReader = ( request: MeetingSeriesInventoryRequest, ) => Promise @@ -38,6 +39,7 @@ export const boundMeetingSeriesInventoryItem = (item: { limits: { bytes: number "meeting inventory bytes cannot fit the provider page; increase bytes or lower limit", ) } +/** @experimental */ export const readMeetingSeriesInventory = async ( read: MeetingSeriesInventoryReader, input: unknown, diff --git a/src/cli/meeting-tags-command.ts b/src/cli/meeting-tags-command.ts index 1552cf3aa..2b6f742ca 100644 --- a/src/cli/meeting-tags-command.ts +++ b/src/cli/meeting-tags-command.ts @@ -9,6 +9,7 @@ import { LOCAL_READ, LOCAL_WRITE, NO_EFFECTS } from "./effects.js" import { type Body, itemOf, listOf, renderAnswer } from "./envelope.js" import { queryTerms, termField, withQuery } from "./list-query.js" +/** @experimental */ export interface MeetingTagsCommandDeps { /** The tags of the profile's own meetings account; opened when the command runs. */ read: () => Promise @@ -53,6 +54,7 @@ const groupOf = (program: Command): Command => * `tags add|remove|list` for a host whose things to label are its meetings, such as pbx's phone calls. A host of * chats mounts the messenger's `tags` instead. `--matching` takes `search meetings`'s query, so "search, then tag" is * one command, and a rerun after new calls are transcribed marks only those. + * @experimental */ export const addMeetingTagsCommand = (program: Command, deps: MeetingTagsCommandDeps): void => { const tags = groupOf(program) diff --git a/src/cli/messenger/context.ts b/src/cli/messenger/context.ts index 69245cf47..37256a0ca 100644 --- a/src/cli/messenger/context.ts +++ b/src/cli/messenger/context.ts @@ -331,6 +331,7 @@ export interface Messenger extends ServiceMessenger { /** * The messenger's connection — or, in a command serve runs for a client, serve's own, borrowed. Every connect * goes through here, so a relayed command never opens a second connection. + * @experimental */ export const connectFor = ( command: Command, diff --git a/src/cli/messenger/doctor-command.ts b/src/cli/messenger/doctor-command.ts index 78a87086f..f27eb66ca 100644 --- a/src/cli/messenger/doctor-command.ts +++ b/src/cli/messenger/doctor-command.ts @@ -59,6 +59,7 @@ export const doctorCommand = (messenger: Messenger): Command => { return command } +/** @experimental */ export const DOCTOR_DEEP_OPTION = "also read every page of the store and check every search index (about 30 s for 6 GB); without it, only the file header and schema" @@ -69,7 +70,7 @@ const summaryOptions = (command: Command, app: { command: string; version: strin version: app.version, }) -/** The plain-words account of a damaged store, under the answer. */ +/** The plain-words account of a damaged store, under the answer. @experimental */ export const damageNotes = (store: unknown): string[] => { const { damage, damage_mark_cleared: cleared } = (store as diff --git a/src/cli/messenger/lacks.ts b/src/cli/messenger/lacks.ts index 24de1f25c..873f6ff38 100644 --- a/src/cli/messenger/lacks.ts +++ b/src/cli/messenger/lacks.ts @@ -9,6 +9,7 @@ type Need = readonly [method: keyof MessengerAdapter, what: string] * The commands that do one thing only an adapter method can, with the words `capability()` refuses in. * `Messenger.lacks` names the methods a messenger never has, so these refuse before anything connects; * a test holds each entry to the live refusal it stands in for. + * @experimental */ export const COMMAND_NEEDS: Readonly> = { "account update": ["updateProfile", "change the profile"], diff --git a/src/cli/messenger/mcp-command.ts b/src/cli/messenger/mcp-command.ts index e212c756e..4933e902f 100644 --- a/src/cli/messenger/mcp-command.ts +++ b/src/cli/messenger/mcp-command.ts @@ -23,7 +23,7 @@ import { nextStep } from "../steps.js" import { recalledAccount } from "./accounts.js" import { type Messenger, type MessengerContext, messengerContext } from "./context.js" -/** Where the running CLI really lives; a test hands in its own. */ +/** Where the running CLI really lives; a test hands in its own. @experimental */ export interface McpEnvironment extends BaseEnvironment { mcp?: { scriptPath?: string; execPath?: string } system?: ServerSystem @@ -132,7 +132,10 @@ const withProfiles = (command: Command): Command => "serve several profiles from one server instead of one: names, comma-separated, or all for every profile", ) -/** Where `mcp serve --http` keeps the hashes of the tokens it issued — per profile, in the state folder. */ +/** + * Where `mcp serve --http` keeps the hashes of the tokens it issued — per profile, in the state folder. + * @experimental + */ export const httpTokenFile = (app: AppIdentity, profile: string, env: NodeJS.ProcessEnv): string => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "mcp-http", `${profile}.json`) @@ -147,6 +150,7 @@ const withFlags = (command: Command, example: string): Command => * What the `mcp` group needs of the CLI it serves. A messenger serves through its one connection (`messengerHost`); * a CLI that is not a messenger through its own program (`appMcpCommand`). The commands, flags and answers are the * same in both, so every WireCat CLI has one `mcp`. + * @experimental */ export interface McpHost { app: AppIdentity @@ -688,6 +692,7 @@ const VERSION_MANAGER = /[\\/](\.nvm|nvm|\.fnm|fnm|fnm_multishells|\.volta|volta * keyring entry and the store, so a server without them would answer "no session" or search another * store. So is `XDG_RUNTIME_DIR`: the keyring is reached through it, and an MCP client that starts * servers with a trimmed environment leaves it out (measured 2026-09-28). Credentials are never copied. + * @experimental */ export const serverEntry = ( app: AppIdentity, diff --git a/src/cli/messenger/message-items.ts b/src/cli/messenger/message-items.ts index 0925283cb..8ded90d32 100644 --- a/src/cli/messenger/message-items.ts +++ b/src/cli/messenger/message-items.ts @@ -14,9 +14,10 @@ import type { MessengerAdapter } from "../../ports/messenger.js" import type { AccountKey } from "../../store/store.js" import type { Messenger, MessengerContext } from "./context.js" +/** @experimental */ export type MessageItem = v.InferOutput -/** What a read hands over: a message, sometimes found by a search, heard, or the anchor of a window. */ +/** What a read hands over: a message, sometimes found by a search, heard, or the anchor of a window. @experimental */ export type ReadMessage = Message & Partial> & { locator?: string @@ -69,6 +70,7 @@ const mailPerson = ({ name, address, ref }: MailPerson) => ({ name, address, ref /** * A message as every command answers it. The ref is the message's locator: the one a store hit carries, else * built from the account that read it. What only the adapter needs (`providerRef`) stays behind. + * @experimental */ export const messageItem = (message: ReadMessage, reader: AccountKey): MessageItem => { const { provider, account } = message.locator === undefined ? reader : parseLocator(message.locator) diff --git a/src/cli/messenger/report.ts b/src/cli/messenger/report.ts index 00d489da1..d83a3c857 100644 --- a/src/cli/messenger/report.ts +++ b/src/cli/messenger/report.ts @@ -9,6 +9,7 @@ import type { SendEntry } from "../../sends/journal.js" const RECENT_SENDS = 20 +/** @experimental */ export interface Report> { createdAt: string /** What `doctor --json` answers — versions, paths, counts and the messenger's own checks. */ @@ -19,7 +20,7 @@ export interface Report> { sends: SendEntry[] } -/** Optional technical context supplied by a consumer; it is redacted with the rest of the report. */ +/** Optional technical context supplied by a consumer; it is redacted with the rest of the report. @experimental */ export interface ReportContext { createdAt?: never doctor?: never @@ -57,6 +58,7 @@ const EVENT_FIELDS = [ * **Everything a report holds is already free of content** — the doctor, the run log and the send * journal are built that way. Two things are added: every id becomes a label, and the home * directory is hidden, since paths name the person's account on this machine. + * @experimental */ export const buildReport = >({ doctor, @@ -172,6 +174,7 @@ const labelled = (entry: SendEntry, label: (id: string) => string): SendEntry => return copy as unknown as SendEntry } +/** @experimental */ export const reportFileName = (app: string, now: Date): string => `${app}-report-${now .toISOString() diff --git a/src/cli/messenger/search-answers.ts b/src/cli/messenger/search-answers.ts index 474f15f1b..d474b6443 100644 --- a/src/cli/messenger/search-answers.ts +++ b/src/cli/messenger/search-answers.ts @@ -25,8 +25,11 @@ import { historyLimitGaps } from "./history-gaps.js" export const SOURCE_SEARCHED = ["messages", "notes", "events", "meetings"] as const export type SourceSearched = (typeof SOURCE_SEARCHED)[number] +/** @experimental */ export type MessageHitItem = InferOutput<(typeof ENTITIES)["message.hit"]> +/** @experimental */ export type NoteHitItem = InferOutput<(typeof ENTITIES)["note.hit"]> +/** @experimental */ export type HitItem = InferOutput<(typeof ENTITIES)["hit"]> const nonEmpty = (list: T[]): T[] | undefined => (list.length > 0 ? list : undefined) @@ -59,6 +62,7 @@ export const MAIL_HIT_UNTRUSTED = [ "email.reply_addresses.name", ] +/** @experimental */ export const messageHitItem = (hit: FoundMessage, query = ""): MessageHitItem => { const at = parseLocator(hit.locator) const around = hit.thread?.items ?? hit.context @@ -183,6 +187,7 @@ const chatGaps = (rows: ChatCoverage[], since?: string): { next: NextStep[]; mis /** * What the archive lacked for this answer, and the step that would fill it. From a search's coverage, or from the * chats an answer is about (`since` is the start of the window it was asked for). + * @experimental */ export const coverageGaps = ( found: Pick | ChatCoverage[], @@ -295,7 +300,7 @@ export interface Paging { archiveOnly?: boolean } -/** "showing 20 of 144", for the human view under a page of hits; `+` when the total is a lower bound. */ +/** "showing 20 of 144", for the human view under a page of hits; `+` when the total is a lower bound. @experimental */ export const shownOf = (shown: number, offset: number, total: SearchTotal | undefined): string | undefined => total === undefined || shown === 0 ? undefined @@ -333,6 +338,7 @@ export const messagesAnswer = ( */ const DOCUMENT_HIT_UNTRUSTED = ["title", "excerpt"] +/** @experimental */ export const noteHitItem = (hit: FoundNote): NoteHitItem => defined({ ...hit, untrusted: hit.kind === "document" ? DOCUMENT_HIT_UNTRUSTED : undefined }) @@ -361,6 +367,7 @@ const ALL_HIT_UNTRUSTED: Record = { ...BUSINESS_UNTRUSTED, } +/** @experimental */ export const allHitItem = (item: SearchAllItem): HitItem => item.kind === "meeting" ? { @@ -443,7 +450,7 @@ export const notesAnswer = ( meta: metaOf(found.accounts, found.skipped), }) -/** `search all`, CLI and MCP alike. A meeting account whose index is still being built says so. */ +/** `search all`, CLI and MCP alike. A meeting account whose index is still being built says so. @experimental */ export const allAnswer = ( command: string, found: SearchAllFound, diff --git a/src/cli/messenger/searches-command.ts b/src/cli/messenger/searches-command.ts index fa1506614..2331af3a7 100644 --- a/src/cli/messenger/searches-command.ts +++ b/src/cli/messenger/searches-command.ts @@ -25,7 +25,10 @@ const line = ({ id, name, command, params, runs, lastRunAt }: StoredSearch) => lastRunAt?.slice(0, 16).replace("T", " ") ?? "never run", ].join(" ") -/** `searches list` takes a query over the saved search fields, none of them a filter: the list is short and whole. */ +/** + * `searches list` takes a query over the saved search fields, none of them a filter: the list is short and whole. + * @experimental + */ export const SEARCHES_QUERY = unfilteredQuery("saved_search", savedSearch) /** Saved searches and the history of `search messages` and `stats messages show`, in the local store only. */ diff --git a/src/cli/messenger/serve-members.ts b/src/cli/messenger/serve-members.ts index f5f503184..7c9f11d0c 100644 --- a/src/cli/messenger/serve-members.ts +++ b/src/cli/messenger/serve-members.ts @@ -2,10 +2,12 @@ import { failureKey } from "../../errors/failures.js" import type { AccountKey, MessageStore } from "../../store/store.js" import type { ServeNotice } from "./serve-notice.js" -/** After connecting, `serve` waits this long before its first member fetch: catch-up comes first. */ +/** After connecting, `serve` waits this long before its first member fetch: catch-up comes first. @experimental */ export const FIRST_FETCH_MS = 60_000 +/** @experimental */ export const DAY_MS = 86_400_000 +/** @experimental */ export interface MemberFetches { /** Starts the daily round; a second call is ignored. */ start(): void @@ -17,6 +19,7 @@ export interface MemberFetches { /** * `serve`'s daily fetch of every tracked chat's member list, one chat after another, each under the fetch's * own page budget and pause. A chat already fetched today is skipped, so a restart does not fetch it again. + * @experimental */ export const memberFetches = ({ withStore, diff --git a/src/cli/messenger/serve-outdated.ts b/src/cli/messenger/serve-outdated.ts index 1ef928985..cc4eb9ac1 100644 --- a/src/cli/messenger/serve-outdated.ts +++ b/src/cli/messenger/serve-outdated.ts @@ -3,9 +3,13 @@ import { dirname, join } from "node:path" import { fileSchemaOf, SPEAKS, writableBy } from "../../store/compatibility.js" import { openSqlite } from "../../store/store.js" +/** @experimental */ export const OUTDATED_CHECK_MS = 60_000 -/** The folder of the package this process was started from, when its `package.json` still names `running`. */ +/** + * The folder of the package this process was started from, when its `package.json` still names `running`. + * @experimental + */ export const ownPackageRoot = (running: string, script = process.argv[1]): string | undefined => { let dir: string try { @@ -42,6 +46,7 @@ const newer = (one: string, other: string): boolean => { /** * Why this serve should stop so its unit starts the installed build: the store moved past what this build * may write, or a newer version was installed over it. A store that cannot be read now is not a reason. + * @experimental */ export const outdatedReason = async ({ command, @@ -79,7 +84,7 @@ export const outdatedReason = async ({ ) } -/** Runs `check` every `everyMs` and calls `onOutdated` once with its first reason. */ +/** Runs `check` every `everyMs` and calls `onOutdated` once with its first reason. @experimental */ export const watchOutdated = ({ check, onOutdated, diff --git a/src/cli/messenger/serve-stems.ts b/src/cli/messenger/serve-stems.ts index 3af9b3859..7d17a924e 100644 --- a/src/cli/messenger/serve-stems.ts +++ b/src/cli/messenger/serve-stems.ts @@ -2,9 +2,12 @@ import { failureKey } from "../../errors/failures.js" import type { MessageStore } from "../../store/store.js" import type { ServeNotice } from "./serve-notice.js" +/** @experimental */ export const STEMS_EVERY_MS = 30_000 +/** @experimental */ export const STEMS_SLICE_MS = 2_000 +/** @experimental */ export interface StemFills { /** Starts filling; a second call is ignored. */ start(): void @@ -17,6 +20,7 @@ export interface StemFills { * `serve`'s fill of stems still building — after an upgrade changed the default stemmers, a large store * would otherwise wait for a search or `store migrate`. A short slice per interval, so the store stays free * for everything else; it ends when the stems are ready, and never touches stems waiting for a reindex. + * @experimental */ export const stemFills = ({ withStore, diff --git a/src/cli/messenger/store-maintenance-command.ts b/src/cli/messenger/store-maintenance-command.ts index 33b751ae5..5ebf289a5 100644 --- a/src/cli/messenger/store-maintenance-command.ts +++ b/src/cli/messenger/store-maintenance-command.ts @@ -189,6 +189,7 @@ const result = (command: Command, value: unknown, next: NextStep[] = []) => /** * Who mounts the store file's commands: a messenger, or any CLI on the shared store. Without a `provider` nothing is * said about chats. + * @experimental */ export type StoreOwner = { app: AppIdentity } & Partial> diff --git a/src/cli/messenger/stored.ts b/src/cli/messenger/stored.ts index 07ddbd7ae..5e0fd5564 100644 --- a/src/cli/messenger/stored.ts +++ b/src/cli/messenger/stored.ts @@ -18,6 +18,7 @@ import type { AccountKey, DeletionScope, IngestedVia, MessageStore } from "../.. const REKEY_PACING = { lockMs: 50, pauseMs: 25 } +/** @experimental */ export interface Saving { account: AccountKey /** Opened on the first save, not before: a command that reads nothing has no reason to touch the file. */ @@ -63,6 +64,7 @@ export interface Saving { * `resolve` is not saved: a chat found by name has no unread count or last message, and writing it * would erase what `chats list` stored. Nor are `chat` and `contact`: a card's member list is not * known to be whole, and `saveMembers` replaces the list. + * @experimental */ export const stored = ( messenger: MessengerAdapter, diff --git a/src/cli/messenger/tasks-command.ts b/src/cli/messenger/tasks-command.ts index 364821c9d..7ad822e87 100644 --- a/src/cli/messenger/tasks-command.ts +++ b/src/cli/messenger/tasks-command.ts @@ -145,6 +145,7 @@ const pairLine = (pair: TaskPair) => /** * `none` clears a date; anything else is a time ahead. Not `null`: commander stores a parser's `null` as "". With * `end`, a date alone is the end of that day: a task due on the 20th is not overdue all of the 20th. + * @experimental */ export const dateOrNone = (flag: string, { end = false }: { end?: boolean } = {}) => diff --git a/src/cli/model-catalogue-command.ts b/src/cli/model-catalogue-command.ts index c7d2f2569..57edc31ab 100644 --- a/src/cli/model-catalogue-command.ts +++ b/src/cli/model-catalogue-command.ts @@ -23,6 +23,7 @@ import { localOnlyCommand } from "./local-only-command.js" import { pictureReadingCommand } from "./picture-reading-command.js" import { harderConsentsCommand } from "./search-harder-consents-command.js" +/** @experimental */ export const MODEL_CATALOGUE_QUERY = defineQuery({ entity: "model", backend: "native", diff --git a/src/cli/oauth-session.ts b/src/cli/oauth-session.ts index 4c02fc381..b2e558643 100644 --- a/src/cli/oauth-session.ts +++ b/src/cli/oauth-session.ts @@ -21,7 +21,10 @@ import type { ServiceApiManifest } from "./service-api-manifest.js" import type { GlobalFlags, ResolveOptions, Settings } from "./settings.js" import { storageOf } from "./token-session.js" -/** The authorization code flow an OpenAPI spec declares; a GraphQL service (Linear) writes the same object by hand. */ +/** + * The authorization code flow an OpenAPI spec declares; a GraphQL service (Linear) writes the same object by hand. + * @experimental + */ export const oauthFlowOf = (manifest: ServiceApiManifest, scheme?: string): OAuthFlow => { const schemes = Object.entries(manifest.securitySchemes ?? {}).filter( ([name, one]) => (scheme === undefined || name === scheme) && one.flows?.authorizationCode !== undefined, @@ -37,6 +40,7 @@ export const oauthFlowOf = (manifest: ServiceApiManifest, scheme?: string): OAut return flow } +/** @experimental */ export interface OAuthPresetOptions { /** A short word, part of the keyring account: `attio`. */ id: string @@ -53,13 +57,17 @@ export interface OAuthPresetOptions { rotating?: boolean } +/** @experimental */ export interface OAuthPreset { provider: OAuthProvider scopes: readonly string[] rotating: boolean } -/** An installed app's sign-in (authorization code with PKCE) from the flow a spec declares, and the scopes it asks. */ +/** + * An installed app's sign-in (authorization code with PKCE) from the flow a spec declares, and the scopes it asks. + * @experimental + */ export const oauthPreset = (flow: OAuthFlow, options: OAuthPresetOptions): OAuthPreset => { const known = Object.keys(flow.scopes) const unknown = options.scopes.filter((scope) => !known.includes(scope)) @@ -93,13 +101,14 @@ export const oauthPreset = (flow: OAuthFlow, options: OAuthPresetOptions): OAuth return { provider, scopes: [...options.scopes], rotating: options.rotating === true } } -/** What the CLI's entry hands `run()` beside cli-core's own; a test hands a fake service and browser. */ +/** What the CLI's entry hands `run()` beside cli-core's own; a test hands a fake service and browser. @experimental */ export interface OAuthEnvironment extends BaseEnvironment { fetch?: typeof fetch /** Gets the command, so the entry opens nothing under `--json`, `--no-input`, CI or without a terminal. */ openBrowser?: (url: string, command?: Command) => Promise } +/** @experimental */ export interface OAuthSessionOptions { app: AppIdentity resolveSettings: (flags: GlobalFlags, options?: ResolveOptions) => Settings @@ -122,6 +131,7 @@ export interface OAuthSessionOptions { * `session start | status | end | list` for a service signed in in the browser (WC-SECR-22): PKCE on the loopback, * the account checked before the tokens are kept, refreshes under one lock, and a run with moved folders that never * removes the owner's sign-in. + * @experimental */ export const oauthSessionCommand = (options: OAuthSessionOptions): Command => { const { app, providerId, service } = options diff --git a/src/cli/paging.ts b/src/cli/paging.ts index 6c1548129..73635da0e 100644 --- a/src/cli/paging.ts +++ b/src/cli/paging.ts @@ -43,6 +43,7 @@ export const withPaging = (command: Command): Command => * ⚠ **A page number over a live list can repeat or skip a row.** The order is most-recent-first, * so a message arriving between page one and page two pushes somebody across the boundary. Every * CLI that pages this way has this; it is in `--help` rather than engineered away. + * @experimental */ export const window = ({ limit, page, all }: Settings): { limit?: number; offset: number } => all ? { offset: 0 } : { limit, offset: (page - 1) * limit } diff --git a/src/cli/permission-keys.ts b/src/cli/permission-keys.ts index 725cfa5ba..52389c99c 100644 --- a/src/cli/permission-keys.ts +++ b/src/cli/permission-keys.ts @@ -39,7 +39,7 @@ export interface ConditionalKey { when: string } -/** Either way of naming a program's keys: a messenger's per-command mapping, or a declared CLI's own. */ +/** Either way of naming a program's keys: a messenger's per-command mapping, or a declared CLI's own. @experimental */ export type PermissionKeySource = PermissionKeyOf | CommandPermissions const HOUSEKEEPING = new Set([ @@ -91,6 +91,7 @@ const everyCommand = (command: Command): Command[] => [command, ...command.comma /** * The keys `permissions` may name: every command of the program, every write key, and each of their * parents. A key outside it is a typo that would otherwise do nothing. + * @experimental */ export const knownPermissionKeys = ( command: Command, @@ -131,7 +132,7 @@ export const markRenamedPermissionKeys = (command: Command, renamed: ReadonlyMap export const renamedPermissionKeys = (command: Command): Map => new Map(everyCommand(rootOf(command)).flatMap((one) => [...(RENAMED.get(one) ?? [])])) -/** The known keys one level under the unknown key's parent, to name in the refusal. */ +/** The known keys one level under the unknown key's parent, to name in the refusal. @experimental */ export const knownBeside = (key: PermissionKey, known: ReadonlySet): PermissionKey[] => { const parent = key.split(".").slice(0, -1).join(".") const depth = parent === "" ? 1 : parent.split(".").length + 1 @@ -140,12 +141,16 @@ export const knownBeside = (key: PermissionKey, known: ReadonlySet>, known: ReadonlySet, ): PermissionKey[] => Object.keys(levels).filter((key) => key !== CEILING_KEY && !known.has(key)) -/** Every unknown permission key saved in the file, in every section and profile, with the unset that removes it. */ +/** + * Every unknown permission key saved in the file, in every section and profile, with the unset that removes it. + * @experimental + */ export const unknownPermissionIssues = ( command: Command, settings: Pick, @@ -168,6 +173,7 @@ export const unknownPermissionIssues = ( /** * A saved key no command checks would do nothing, so the command refuses to run and names the unset that removes * it. A `--permission` key is checked too: it is no file's, so the flag is the fix. + * @experimental */ export const refuseUnknownPermissionKeys = ( command: Command, diff --git a/src/cli/profile.ts b/src/cli/profile.ts index 4743ebfe3..581b59e9d 100644 --- a/src/cli/profile.ts +++ b/src/cli/profile.ts @@ -41,7 +41,10 @@ export const profileFree = (command: T): T => { return command } -/** Whether the command line puts a profile before this command: not for `PROFILE_FREE` or a `profileFree` one. */ +/** + * Whether the command line puts a profile before this command: not for `PROFILE_FREE` or a `profileFree` one. + * @experimental + */ export const takesProfile = (command: Command): boolean => { let top: Command | undefined for (let at: Command | null = command; at?.parent; at = at.parent) { @@ -81,6 +84,7 @@ export const liftProfile = ( * The group a run reads, from the first word (`liftProfile` lifts it) or `_GROUP`; `all`, the default, is * every account, so no restriction. Under `_GROUP_LOCK` any other group, `all` included, is refused, as the * profile lock refuses another profile (WC-ACCT-5); a lock of `all` locks nothing. + * @experimental */ export const runGroup = (app: AppIdentity, env: NodeJS.ProcessEnv, word?: string): RunGroup | undefined => { const GROUP = envName(app, "GROUP") diff --git a/src/cli/project-evidence.ts b/src/cli/project-evidence.ts index 7adb7fce1..562acecff 100644 --- a/src/cli/project-evidence.ts +++ b/src/cli/project-evidence.ts @@ -7,7 +7,10 @@ import type { LeftOutChat, StoredProjectGathering } from "../services/stored-pro import { coverageGaps, heldPhrase } from "./messenger/search-answers.js" import { heldInWindow } from "./project-status.js" -/** Days back (`90d`) or a start date (`2026-09-01`); either way the run freezes its end, so a resume keeps it. */ +/** + * Days back (`90d`) or a start date (`2026-09-01`); either way the run freezes its end, so a resume keeps it. + * @experimental + */ export const projectWindowOf = (value: string): { days: number } | { after: number } => { const days = /^([1-9]\d{0,2})d$/.exec(value)?.[1] if (days !== undefined && Number(days) <= 730) return { days: Number(days) } @@ -20,6 +23,7 @@ export const projectWindowOf = (value: string): { days: number } | { after: numb ) } +/** @experimental */ export const projectCutoffTime = (value: string): number => { const parsed = v.safeParse(v.pipe(v.string(), v.isoTimestamp()), value) const at = parsed.success ? Date.parse(parsed.output) : Number.NaN @@ -48,6 +52,7 @@ const coverageRows = ({ linkedChats }: StoredProjectGathering): ChatCoverage[] = /** * The zone a typed start date was read in, and the window the run used, in UTC. `complete` is "the answer is whole": * reads finished and every linked chat held in full; the answer's own `complete` stays "reads finished". + * @experimental */ export const projectAnswerParts = ( sinceTime: string, @@ -85,6 +90,7 @@ export const projectAnswerParts = ( /** * The gathering with each linked chat's `syncCommand`: the line that syncs a chat held in part back to the window * start, or null when it needs none or no command here can. JSON readers get what the text says per chat. + * @experimental */ export const withSyncCommands = ( found: StoredProjectGathering, @@ -100,6 +106,7 @@ export const withSyncCommands = ( leftOut: found.leftOut.map((one) => ({ ...one, readCommand: read?.(one, day(found.window.after)) ?? null })), }) +/** @experimental */ export interface ProjectTextHints { /** The command that syncs one linked chat back to `since` (`YYYY-MM-DD`), or null when no command here can. */ sync: (chat: StoredProjectGathering["linkedChats"][number], since: string) => string | null @@ -135,6 +142,7 @@ const FETCH_STATES: Record = { skipped: "not synced, the fetch time ran out first", } +/** @experimental */ export const projectEvidenceText = (found: StoredProjectGathering, hints: ProjectTextHints) => { const lanes = new Map( found.lanes.map((lane) => [ diff --git a/src/cli/project-status-rows.ts b/src/cli/project-status-rows.ts index 2eaa891ea..575f5b22c 100644 --- a/src/cli/project-status-rows.ts +++ b/src/cli/project-status-rows.ts @@ -9,6 +9,7 @@ export const ON_CHAT_ROW: ReadonlySet = new Set(["reply-next", "coverage /** * The compact row of each listed status signal's items, by `status.`; a signal's file and its row are the * two places a new signal touches. They live here because a service may not import the CLI's row type. + * @experimental */ export const STATUS_SIGNAL_ROWS: Readonly> = { "status.questions": { @@ -61,7 +62,7 @@ export const STATUS_SIGNAL_ROWS: Readonly> = { }, } -/** The rest of a `project_status` answer: its chats, open money, chats left out, and failed signals. */ +/** The rest of a `project_status` answer: its chats, open money, chats left out, and failed signals. @experimental */ export const STATUS_ROWS: Readonly> = { ...STATUS_SIGNAL_ROWS, "status.chat": { diff --git a/src/cli/project-status.ts b/src/cli/project-status.ts index 904c81e1d..0e166d8fd 100644 --- a/src/cli/project-status.ts +++ b/src/cli/project-status.ts @@ -16,6 +16,7 @@ import { snakeKeys } from "./envelope.js" import { heldPhrase } from "./messenger/search-answers.js" import { ON_CHAT_ROW, STATUS_SIGNAL_ROWS } from "./project-status-rows.js" +/** @experimental */ export interface ProjectStatusHints { /** The step that syncs a chat held in part back to `since` (`YYYY-MM-DD`); null when no command here can. */ sync: (chat: StatusChatSummary, since: string) => NextStep | null @@ -37,7 +38,10 @@ const SECTIONS = { failed: "status.failed", } -/** The `project_status` answer drawn by `--compact`: a row per chat, then each listed signal with its own row. */ +/** + * The `project_status` answer drawn by `--compact`: a row per chat, then each listed signal with its own row. + * @experimental + */ export const projectStatusRow = (signals: readonly { id: string }[]): RowShape => ({ columns: [], hidden: ["project", "purposes", "signals"], @@ -62,7 +66,10 @@ const statusItem = v.looseObject({ data: v.record(v.string(), v.unknown()), }) -/** Where a project stands: per chat signals, open money, and what was left out. Empty lists are left out. */ +/** + * Where a project stands: per chat signals, open money, and what was left out. Empty lists are left out. + * @experimental + */ export const projectStatusSchema = v.looseObject({ project: v.string(), key: v.nullable(v.string()), @@ -113,6 +120,7 @@ export const projectStatusSchema = v.looseObject({ ), }) +/** @experimental */ export type ProjectStatusItem = v.InferOutput const coverageOf = (found: ProjectStatus, chat: string) => @@ -306,7 +314,7 @@ const chatRow = (found: ProjectStatus, hints: ProjectStatusHints, chat: StatusCh } } -/** The answer of `projects status`: the item, two steps at most, what is missing, and the window. */ +/** The answer of `projects status`: the item, two steps at most, what is missing, and the window. @experimental */ export const projectStatusAnswer = (found: ProjectStatus, hints: ProjectStatusHints) => { const unlisted = unlistedOf(found) const lists = Object.fromEntries( @@ -414,7 +422,7 @@ const moneyLine = (one: StatusItem, titles: Map) => { return ` ${words.padEnd(7)} ${sum}${asks}${where} · ${one.evidence[0]?.ref ?? ""} [${one.basis}]` } -/** The human form: header, money, a line per chat with what is open, then the steps. */ +/** The human form: header, money, a line per chat with what is open, then the steps. @experimental */ export const projectStatusText = (found: ProjectStatus, hints: ProjectStatusHints): string => { const titles = new Map(found.chats.map((chat) => [chat.ref, chat.title])) const { next } = projectStatusAnswer(found, hints) diff --git a/src/cli/result-fields.ts b/src/cli/result-fields.ts index be8e77c2e..2e72d0915 100644 --- a/src/cli/result-fields.ts +++ b/src/cli/result-fields.ts @@ -13,6 +13,7 @@ const named = (work: () => T): T => { } } +/** @experimental */ export const fieldsOf = (value: string): string[] => named(() => coreFieldsOf(value)) const projectCommands = (commands: readonly CommandInfo[], fields: readonly string[]): unknown[] => @@ -25,6 +26,7 @@ const projectCommands = (commands: readonly CommandInfo[], fields: readonly stri commands: projectCommands(command.commands, fields), })) +/** @experimental */ export const projectFields = (value: unknown, fields: readonly string[]): unknown => named(() => { if ( diff --git a/src/cli/schedule/harnesses.ts b/src/cli/schedule/harnesses.ts index 93244d61a..ac8eb4a51 100644 --- a/src/cli/schedule/harnesses.ts +++ b/src/cli/schedule/harnesses.ts @@ -292,11 +292,12 @@ const AGENT_HARNESSES = { }, } as const satisfies Record +/** @experimental */ export type Harness = keyof typeof AGENT_HARNESSES /** The variables a harness reads its limits from; a run rebuilds them, so a saved one is never taken from the file. */ export const HARNESS_VARIABLES = ["GEMINI_CLI_SYSTEM_SETTINGS_PATH", "OPENCODE_CONFIG_CONTENT"] as const -/** Every agent a schedule may start, as `schedule agent ` and a digest's agent take it. */ +/** Every agent a schedule may start, as `schedule agent ` and a digest's agent take it. @experimental */ export const HARNESSES = Object.keys(AGENT_HARNESSES) as readonly Harness[] export const AGENT_MODELS = Object.fromEntries(HARNESSES.map((id) => [id, AGENT_HARNESSES[id].model])) as Record< Harness, @@ -306,9 +307,10 @@ export const AGENT_MODELS = Object.fromEntries(HARNESSES.map((id) => [id, AGENT_ export const harnessOf = (id: Harness): HarnessKind => AGENT_HARNESSES[id] export const COSTED = HARNESSES.filter((id) => harnessOf(id).reportsCost).join(", ") +/** @experimental */ export const isHarness = (id: string): id is Harness => (HARNESSES as readonly string[]).includes(id) -/** An agent's name, programs and what holds it, as `schedule agents list` answers them. */ +/** An agent's name, programs and what holds it, as `schedule agents list` answers them. @experimental */ export const harnessInfo = (harness: Harness) => { const { name, programs, reportsCost, restricted, restrictedReason, allowedWithAck } = harnessOf(harness) return { @@ -322,7 +324,7 @@ export const harnessInfo = (harness: Harness) => { } } -/** Whether the harness reports what a run cost; the cost caps hold only for one that does. */ +/** Whether the harness reports what a run cost; the cost caps hold only for one that does. @experimental */ export const reportsCost = (harness: Harness): boolean => harnessOf(harness).reportsCost /** The harness's program on PATH, by the first of its names found. */ @@ -331,7 +333,10 @@ export const programOf = (harness: Harness, env: NodeJS.ProcessEnv, platform: No .programs.map((name) => findProgram(name, env, platform)) .find(Boolean) -/** Which harness an agent schedule's argv starts, by its program's name; null for one no harness here knows. */ +/** + * Which harness an agent schedule's argv starts, by its program's name; null for one no harness here knows. + * @experimental + */ export const harnessOfArgv = (argv: readonly string[]): Harness | null => { const name = basename(argv[0] ?? "") .replace(/\.(exe|cmd)$/i, "") @@ -351,7 +356,7 @@ export const harnessRefusal = (harness: Harness, accepted: boolean): string | un return `${kind.name} cannot run on a schedule: ${kind.restrictedReason}` } -/** Each harness, with its program when it is on PATH: what `schedule agents list` answers. */ +/** Each harness, with its program when it is on PATH: what `schedule agents list` answers. @experimental */ export const harnessesOn = (env: NodeJS.ProcessEnv, platform: NodeJS.Platform) => HARNESSES.map((id) => { const path = programOf(id, env, platform) ?? null diff --git a/src/cli/schedule/schedule-command.ts b/src/cli/schedule/schedule-command.ts index 0b6eeb795..135c31c3a 100644 --- a/src/cli/schedule/schedule-command.ts +++ b/src/cli/schedule/schedule-command.ts @@ -85,7 +85,7 @@ interface WhenOptions { const CLOCK = /^([01]\d|2[0-3]):[0-5]\d$/ -/** One `--at`: `HH:MM` every day, or weekdays and a time, `mon 09:00` or `mon,fri 09:00`. */ +/** One `--at`: `HH:MM` every day, or weekdays and a time, `mon 09:00` or `mon,fri 09:00`. @experimental */ export const slotsOfAt = (at: string): Slot[] => { const [, words, clock = ""] = /^\s*(?:([a-z,]+)\s+)?(\S+)\s*$/i.exec(at) ?? [] if (!CLOCK.test(clock)) @@ -343,6 +343,7 @@ const reportTemplatesOf = /** * One past day's run of the agent schedule in `file`, as `backfillSchedule` makes it, with the owner's language and * templates as `schedule run` renders them; a stop of the command stops the agent. + * @experimental */ export const backfillScheduleRun = ( command: Command, @@ -366,7 +367,10 @@ export const backfillScheduleRun = ( ) } -/** Where a schedule is written and for whom: the CLI, the machine, the run's variables and its profile. */ +/** + * Where a schedule is written and for whom: the CLI, the machine, the run's variables and its profile. + * @experimental + */ export interface ScheduleSite { app: AppIdentity system: ServerSystem @@ -378,7 +382,7 @@ export interface ScheduleSite { limits?: ScheduleLimits } -/** The tool's state folder, which holds its schedules. */ +/** The tool's state folder, which holds its schedules. @experimental */ export const scheduleState = ({ app, env }: Pick) => resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state @@ -403,7 +407,7 @@ const scheduleEnvironment = ({ app, env, profile }: ScheduleSite): Record { const { app, system, env, agentRuns = [], limits = {} } = site const { harness, prompt, when } = spec @@ -475,6 +482,7 @@ export const agentSchedule = (site: ScheduleSite, spec: AgentScheduleSpec): Sche /** * Writes the schedule's file and puts it on its timer, or takes it off when it is paused. A name another profile's * schedule holds is refused. + * @experimental */ export const writeSchedule = async ( site: ScheduleSite, @@ -524,6 +532,7 @@ const ownRoutes = (schedule: Schedule, routes: readonly string[] | undefined) => /** * Takes a schedule off its timer and keeps its file, or puts it back. It keeps the profile it was made for, as pausing * names no new one. + * @experimental */ export const pauseSchedule = async (site: ScheduleSite, name: string, paused: boolean) => { const file = scheduleFile(scheduleState(site), scheduleName(name)) @@ -534,7 +543,7 @@ export const pauseSchedule = async (site: ScheduleSite, name: string, paused: bo return { schedule: kept, ...(await writeSchedule({ ...site, profile: owner }, kept)) } } -/** Takes the schedule off its timer and removes its file; its past runs stay. */ +/** Takes the schedule off its timer and removes its file; its past runs stay. @experimental */ export const removeSchedule = async (site: ScheduleSite, name: string): Promise => { const file = scheduleFile(scheduleState(site), scheduleName(name)) if (!existsSync(file)) throw new CliError("not_found", `no schedule ${name}`) @@ -545,6 +554,7 @@ export const removeSchedule = async (site: ScheduleSite, name: string): Promise< /** * Runs the schedule in `file` now, as `schedule run` does: its report rendered with the owner's language and templates * and sent along `routes` (its own when absent, none when empty). A stop of the command stops the agent. + * @experimental */ export const runScheduleNow = async ( command: Command, diff --git a/src/cli/search-left-out.ts b/src/cli/search-left-out.ts index 1ee97130c..4ae53904d 100644 --- a/src/cli/search-left-out.ts +++ b/src/cli/search-left-out.ts @@ -21,8 +21,10 @@ const LIST_KEYS = { tracker: "issues.list", } as const satisfies Record +/** @experimental */ export type SearchedKind = keyof typeof LIST_KEYS +/** @experimental */ export interface LeftOut { kind: K key: PermissionKey @@ -33,6 +35,7 @@ export interface LeftOut { /** * The kinds whose list `permissions` deny, for a CLI with levels of its own, such as memo's: `by` names who denies in * `why` (`memo's permissions`). + * @experimental */ export const deniedKindsOf = ( permissions: Readonly>, @@ -49,6 +52,7 @@ export const deniedKindsOf = ( * The kinds whose list the profile denies, so `search all` leaves them out rather than show their titles and excerpts * under another key. Levels as the run judged the command: the profile's, `--permission`, and an MCP * server's own stricter ones. + * @experimental */ export const deniedKinds = ( command: Command, diff --git a/src/cli/service-api-manifest.ts b/src/cli/service-api-manifest.ts index e507595d3..d4c706e89 100644 --- a/src/cli/service-api-manifest.ts +++ b/src/cli/service-api-manifest.ts @@ -58,6 +58,7 @@ export const manifestBaseUrl = ( /** * The site an owner types, as a server's free variable takes it: a host with a port or a path if any, from * `blog.example.com` or `https://blog.example.com/`. Only https: an `http://` address is refused, not rewritten. + * @experimental */ export const siteValue = (raw: string): string => { const text = raw @@ -152,6 +153,7 @@ const authOf = (manifest: ServiceApiManifest, operation: ManifestOperation): Sig * standard sign-in header, or a key in the query, never follows a redirect, even to the same host: another host would * get the key. The URL then holds the key, so a fetch wrapper must not log it. Without `token`, for a CLI that never * signs in, nothing is added. + * @experimental */ export const signRequest = async ( manifest: ServiceApiManifest, @@ -171,6 +173,7 @@ export const signRequest = async ( /** * A URL on the server's origin and under its path: a site at `host/blog` shares its host with `host/other`, which * must never get its sign-in. + * @experimental */ export const underBase = (url: URL, baseUrl: string): boolean => { const base = new URL(baseUrl) @@ -214,7 +217,10 @@ export const withValue = ( return { ...input, fields, body: apiJson({ ...(body as Record), [parameter.name]: value }) } } -/** One page's items, and how to ask for the next: new flags, the next page's whole URL, or `undefined` at the end. */ +/** + * One page's items, and how to ask for the next: new flags, the next page's whole URL, or `undefined` at the end. + * @experimental + */ export interface PageStep { items: readonly unknown[] next?: { input: ApiCommandInput } | { url: string } @@ -224,6 +230,7 @@ export interface PageStep { * Reads one answer by the manifest's pagination: where its items are and what the next request is. `headers` are the * response's, where a page style's `pagesHeader` gives the number of pages: the page that reaches it is the last, as * WordPress refuses a page past the end. + * @experimental */ export const nextPage = ( pagination: Pagination, diff --git a/src/cli/service-api.ts b/src/cli/service-api.ts index acdd072e2..662b5ae6e 100644 --- a/src/cli/service-api.ts +++ b/src/cli/service-api.ts @@ -198,7 +198,10 @@ const applies = (permission: OperationPermission, body: unknown, input: ApiComma ) } -/** The keys one call checks beside `api.`: the manifest's that apply, and the CLI's from the body. */ +/** + * The keys one call checks beside `api.`: the manifest's that apply, and the CLI's from the body. + * @experimental + */ export const serviceApiKeys = ( input: ServiceApiPermissionsInput, operation: ManifestOperation, diff --git a/src/cli/settings.ts b/src/cli/settings.ts index d6fbfdd2b..e8c4145df 100644 --- a/src/cli/settings.ts +++ b/src/cli/settings.ts @@ -65,9 +65,11 @@ export const plain = (issue: v.BaseIssue): string => `${rule}, not ${issue.received}` const wholeNumber = plain("has to be a whole number, 1 or more") +/** @experimental */ export const count = v.pipe(v.number(wholeNumber), v.integer(wholeNumber), v.minValue(1, wholeNumber)) const zeroOrMore = plain("has to be a whole number, 0 or more") const countOrZero = v.pipe(v.number(zeroOrMore), v.integer(zeroOrMore), v.minValue(0, zeroOrMore)) +/** @experimental */ export const flag = v.boolean(plain("has to be true or false")) const historyDaysMessage = plain(`has to be a whole number of days, 1 to ${HISTORY_MAX_DAYS}`) const historyDays = v.pipe( @@ -308,6 +310,7 @@ interface KindSection { profiles?: Record } +/** @experimental */ export interface Config { defaults?: Scope profiles: Record @@ -333,7 +336,7 @@ export interface GlobalFlags { timeout?: string } -/** `first word`, `flag`, `TG_PROFILE`, `config file`, `config defaults`, `default`… */ +/** `first word`, `flag`, `TG_PROFILE`, `config file`, `config defaults`, `default`… @experimental */ export type Source = string export interface Settings extends AISettings { @@ -461,7 +464,10 @@ export const NONE_NAMED = "none named" /** A name for a command that speaks for no account; never chosen for one that does. */ const NO_PROFILE = "default" -/** The profile a run is for: none when nothing named one, even though `Settings.profile` holds a placeholder. */ +/** + * The profile a run is for: none when nothing named one, even though `Settings.profile` holds a placeholder. + * @experimental + */ export const namedProfile = (settings: Pick & Partial>) => settings.sources?.profile === NONE_NAMED ? undefined : settings.profile @@ -491,7 +497,7 @@ export class NoProfileHere extends CliError { } } -/** The first candidate that is set, and which layer it came from. */ +/** The first candidate that is set, and which layer it came from. @experimental */ export const first = (candidates: [Source, T | undefined][], fallback: T): { value: T; from: Source } => { for (const [from, value] of candidates) if (value !== undefined) return { value, from } return { value: fallback, from: "default" } diff --git a/src/cli/setup-answers.ts b/src/cli/setup-answers.ts index 1415cc809..89978e9e6 100644 --- a/src/cli/setup-answers.ts +++ b/src/cli/setup-answers.ts @@ -5,11 +5,13 @@ import { readSharedSection, sharedConfigPath, writeSharedSection } from "../stor /** One switch for every tool, the same on the command line and over MCP; "allow" leaves each profile as configured. */ export const PERMISSION_ANSWERS = ["readonly", "allow"] as const +/** @experimental */ export type PermissionAnswer = (typeof PERMISSION_ANSWERS)[number] /** * The first-run answers every WireCat CLI shares. Languages live in the store (`search_stemmers`), so only the * fact that they were asked is kept here. + * @experimental */ export interface SetupAnswers { languages?: true @@ -21,6 +23,7 @@ export type Question = (typeof QUESTIONS)[number] const SECTION = "setup" +/** @experimental */ export const readSetupAnswers = (path: string): SetupAnswers => { const section = readSharedSection(path, SECTION) if (section === undefined) return {} diff --git a/src/cli/shared-command-exports.ts b/src/cli/shared-command-exports.ts index d67a92426..bcee442d1 100644 --- a/src/cli/shared-command-exports.ts +++ b/src/cli/shared-command-exports.ts @@ -84,30 +84,39 @@ import { upgradeCommand as upgradeCommandDefinition } from "./upgrade-command.js const sharedCommand: typeof protectedCommand = (factory) => honoursDryRun(protectedCommand(factory)) +/** @experimental */ export const addStoreMaintenanceCommands = sharedCommand(addStoreMaintenanceCommandsDefinition) export const appDoctorCommand = sharedCommand(appDoctorCommandDefinition) export const appCompleteCommand = sharedCommand(appCompleteCommandDefinition) export const appMcpCommand = sharedCommand(appMcpCommandDefinition) +/** @experimental */ export const botAdminsCommand = sharedCommand(botAdminsCommandDefinition) +/** @experimental */ export const botMembersCommand = sharedCommand(botMembersCommandDefinition) export const generatedApiCommand = sharedCommand(generatedApiCommandDefinition) export const serviceApiCommand = sharedCommand(serviceApiCommandDefinition) export const botCommand = sharedCommand(botCommandDefinition) +/** @experimental */ export const botMcpCommand = sharedCommand(botMcpCommandDefinition) +/** @experimental */ export const botMessagesCommand = sharedCommand(botMessagesCommandDefinition) export const commandsCommand = sharedCommand(commandsCommandDefinition) export const configCommand = sharedCommand(configCommandDefinition) export const setupCommand = sharedCommand(setupCommandDefinition) export const guideCommand = sharedCommand(guideCommandDefinition) +/** @experimental */ export const addMeetingBatchCommand = sharedCommand(addMeetingBatchCommandDefinition) export const addMeetingPreparationCommand = sharedCommand(addMeetingPreparationCommandDefinition) +/** @experimental */ export const addMeetingProjectCandidatesCommand = sharedCommand(addMeetingProjectCandidatesCommandDefinition) +/** @experimental */ export const addMeetingSeriesInventoryCommand = sharedCommand(addMeetingSeriesInventoryCommandDefinition) export const accountCommand = sharedCommand(accountCommandDefinition) export const messengerSessionCommands = sharedCommand(messengerSessionCommandsDefinition) export const storeCommand = sharedCommand(storeCommandDefinition) export const attachmentsCommand = sharedCommand(attachmentsCommandDefinition) export const chatsCommand = sharedCommand(chatsCommandDefinition) +/** @experimental */ export const markReadCommand = sharedCommand(markReadCommandDefinition) export const completeCommand = sharedCommand(completeCommandDefinition) export const contactsCommand = sharedCommand(contactsCommandDefinition) @@ -121,18 +130,27 @@ export const inboxCommand = sharedCommand(inboxCommandDefinition) export const mcpCommand = sharedCommand(mcpCommandDefinition) export const mentionsCommand = sharedCommand(mentionsCommandDefinition) export const messagesCommand = sharedCommand(messagesCommandDefinition) +/** @experimental */ export const sendCommand = sharedCommand(sendCommandDefinition) +/** @experimental */ export const deleteCommand = sharedCommand(deleteCommandDefinition) +/** @experimental */ export const editCommand = sharedCommand(editCommandDefinition) +/** @experimental */ export const forwardCommand = sharedCommand(forwardCommandDefinition) +/** @experimental */ export const pinCommand = sharedCommand(pinCommandDefinition) +/** @experimental */ export const starCommands = sharedCommand(starCommandsDefinition) +/** @experimental */ export const unpinCommand = sharedCommand(unpinCommandDefinition) export const metadataCommand = sharedCommand(metadataCommandDefinition) export const modelsCommand = sharedCommand(modelsCommandDefinition) export const pollsCommand = sharedCommand(pollsCommandDefinition) export const reactionsCommand = sharedCommand(reactionsCommandDefinition) +/** @experimental */ export const callsCommand = sharedCommand(callsCommandDefinition) +/** @experimental */ export const stickersCommand = sharedCommand(stickersCommandDefinition) export const repliesCommand = sharedCommand(repliesCommandDefinition) export const reviewCommand = sharedCommand(reviewCommandDefinition) @@ -145,7 +163,9 @@ export const serverCommand = sharedCommand(serverCommandDefinition) export const statsCommand = sharedCommand(statsCommandDefinition) export const tagsCommand = sharedCommand(tagsCommandDefinition) export const tasksCommand = sharedCommand(tasksCommandDefinition) +/** @experimental */ export const tasksStatsCommand = sharedCommand(tasksStatsCommandDefinition) +/** @experimental */ export const topicsCommand = sharedCommand(topicsCommandDefinition) export const projectsCommand = sharedCommand(projectsCommandDefinition) export const watchCommand = sharedCommand(watchCommandDefinition) @@ -156,4 +176,5 @@ export const upgradeCommand = sharedCommand(upgradeCommandDefinition) import { modelCatalogueCommand as modelCatalogueDefinition } from "./model-catalogue-command.js" import { templatesCommand as templatesDefinition } from "./templates-command.js" export const modelCatalogueCommand = sharedCommand(modelCatalogueDefinition) +/** @experimental */ export const templatesCommand = sharedCommand(templatesDefinition) diff --git a/src/cli/steps.ts b/src/cli/steps.ts index eed5569a5..2b200a264 100644 --- a/src/cli/steps.ts +++ b/src/cli/steps.ts @@ -296,6 +296,7 @@ type Targets = NonNullable * The steps this CLI can run, at most two: a step naming a command it lacks is dropped, never printed. Whether a * step may run unasked is judged here, where the command tree is known: only when its command writes nothing * remotely. + * @experimental */ export const runnable = (root: Command, steps: readonly NextStep[] | undefined): NextStep[] => withSafety( @@ -327,7 +328,10 @@ export const failureSteps = ( return runnable(root, [...(error.next ?? []), ...own]) } -/** Each command step judged by its command's effects: safe to run unasked only when it writes nothing remotely. */ +/** + * Each command step judged by its command's effects: safe to run unasked only when it writes nothing remotely. + * @experimental + */ export const withSafety = (steps: readonly NextStep[], targets: Targets): NextStep[] => steps.map((step) => { if (step.kind === "user_action") return step diff --git a/src/cli/store-info.ts b/src/cli/store-info.ts index 0e3d26f07..d6d456a67 100644 --- a/src/cli/store-info.ts +++ b/src/cli/store-info.ts @@ -21,6 +21,7 @@ import { LOCAL_READ } from "./effects.js" import { itemOf, renderAnswer, snakeKeys } from "./envelope.js" import { storeRecoverCommand } from "./store-recover.js" +/** @experimental */ export type StoreInfo = v.InferOutput /** Before version 6 the column does not exist, and a file behind this build is not migrated here. */ @@ -79,6 +80,7 @@ export const storeInfo = async (env: NodeJS.ProcessEnv): Promise => { } } +/** @experimental */ export const storeInfoCommand = (): Command => annotate(new Command("info"), { output: { entity: "store_info" }, effects: LOCAL_READ }) .summary("the shared store's format, size and contents, and whether this tool can read it") diff --git a/src/cli/store-recover.ts b/src/cli/store-recover.ts index 7e36e5286..6f0809549 100644 --- a/src/cli/store-recover.ts +++ b/src/cli/store-recover.ts @@ -36,6 +36,7 @@ const COUNTED = [ "mentions", ] +/** @experimental */ export interface RecoveryCheck { path: string exists: boolean @@ -63,6 +64,7 @@ const stopTimers = (timers: string[]) => `systemctl --user stop ${timers.join(" /** * `store recover`: what is wrong with the store and what to run, reading every page. Changes nothing in the store; it * records the check beside it, and one that passes lifts the damage mark. + * @experimental */ export const storeRecoveryCheck = async ( env: NodeJS.ProcessEnv, @@ -123,6 +125,7 @@ export const storeRecoveryCheck = async ( } } +/** @experimental */ export type RecoveryRun = Omit & { /** `sqlite3` reported these while copying; most are rows that broke a constraint and were skipped. */ copyErrors: number @@ -131,7 +134,10 @@ export type RecoveryRun = Omit & { next: string[] } -/** `store recover run`: refuses while a WireCat timer is scheduled, so none writes to the file being replaced. */ +/** + * `store recover run`: refuses while a WireCat timer is scheduled, so none writes to the file being replaced. + * @experimental + */ export const storeRecoveryRun = async ( env: NodeJS.ProcessEnv, { @@ -196,7 +202,7 @@ const refetchNotes = ({ since, chats, mail }: RecoveryRun["refetch"]): string[] ] } -/** The lines a person reads under the answer; the JSON carries the same in its fields. */ +/** The lines a person reads under the answer; the JSON carries the same in its fields. @experimental */ export const recoveryNotes = (answer: RecoveryCheck | RecoveryRun): string[] => { if ("keptAt" in answer) { const lost = answer.lost.map( @@ -240,7 +246,7 @@ export const recoveryNotes = (answer: RecoveryCheck | RecoveryRun): string[] => ] } -/** `store recover` and `store recover run`, for a CLI whose commands run on cli-core's context. */ +/** `store recover` and `store recover run`, for a CLI whose commands run on cli-core's context. @experimental */ export const storeRecoverCommand = ({ command, version }: { command: string; version?: string }): Command => { const recover = annotate(new Command("recover"), { effects: LOCAL_READ, examples: [`${command} store recover`] }) .summary("what is damaged in the store and how to recover it") diff --git a/src/cli/store-settings.ts b/src/cli/store-settings.ts index 5400998a1..f9cf6c81f 100644 --- a/src/cli/store-settings.ts +++ b/src/cli/store-settings.ts @@ -59,7 +59,7 @@ const AGENT_CLOSE = "task_agent_close" const AGENT_CLOSE_MIN = "task_agent_close_min" const FIRST_PASS = "task_first_pass_per_chat" -/** Settings of the store file, not of a profile: the store is one file for every profile, tg and MAX. */ +/** Settings of the store file, not of a profile: the store is one file for every profile, tg and MAX. @experimental */ export const STORE_SETTINGS = [ ...Object.keys(SCRIPTS), OWNER_LANGUAGES, @@ -116,6 +116,7 @@ export const isOwnerOnlyStoreSetting = (setting: string): boolean => { ) } +/** @experimental */ export const isStoreSetting = (setting: string): boolean => setting in SCRIPTS || setting === OWNER_LANGUAGES || @@ -128,6 +129,7 @@ export const isStoreSetting = (setting: string): boolean => setting.startsWith(GROUP_PREFIX) || parseCrmSetting(setting) !== undefined +/** @experimental */ export const changeStoreSetting = async ( app: AppIdentity, env: NodeJS.ProcessEnv, @@ -423,7 +425,10 @@ const categoryRows = (saved: readonly TaskCategory[] | undefined, file: string) })) } -/** For `config show`: reads the file as it is — never creates, migrates or unseals it to say the defaults apply. */ +/** + * For `config show`: reads the file as it is — never creates, migrates or unseals it to say the defaults apply. + * @experimental + */ export const storeSettings = async (env: NodeJS.ProcessEnv) => { const path = storePath(env) let saved: Stemmers | null | undefined diff --git a/src/cli/templates-command.ts b/src/cli/templates-command.ts index 088934cf0..86a5b9fd8 100644 --- a/src/cli/templates-command.ts +++ b/src/cli/templates-command.ts @@ -34,6 +34,7 @@ import { type Body, itemOf, listOf } from "./envelope.js" import { type QueryWords, queryTerms, withQuery } from "./list-query.js" import { ownerLanguageOf, scheduleState } from "./schedule/schedule-command.js" +/** @experimental */ export interface TemplatesOptions { env: () => NodeJS.ProcessEnv output: (answer: Body, command: Command) => void diff --git a/src/context/evidence.ts b/src/context/evidence.ts index 227ef021a..c9024e917 100644 --- a/src/context/evidence.ts +++ b/src/context/evidence.ts @@ -9,6 +9,7 @@ export interface ContextSource { provider: string account: string } +/** @experimental */ export interface ContextEvidenceRequest { source: ContextSource /** Required unless `chat` is given; a chat read takes no query. */ @@ -24,6 +25,7 @@ export interface ContextEvidenceRequest { cursor?: { at: number; id: number; scope: string } signal?: AbortSignal } +/** @experimental */ export interface ContextEvidenceItem { ref: string provider: string @@ -49,6 +51,7 @@ export interface ContextEvidenceSender { /** The identity is the owner's: linked to the owner person, or the account's own. */ owner: boolean } +/** @experimental */ export interface ContextEvidencePage { source: ContextSource items: ContextEvidenceItem[] @@ -66,6 +69,7 @@ export interface ContextEvidencePage { consistency: "snapshot-per-page" } } +/** @experimental */ export interface ContextEvidenceReader { read(request: ContextEvidenceRequest): Promise } diff --git a/src/domain/addresses.ts b/src/domain/addresses.ts index 682befe3f..162301a6a 100644 --- a/src/domain/addresses.ts +++ b/src/domain/addresses.ts @@ -4,7 +4,7 @@ export const EMAIL_ADDRESS = /^[^\s@]+@[^\s@]+\.[^\s@]+$/u /** Whether a lower-cased, trimmed value is an email address. */ export const isEmailAddress = (value: string): boolean => EMAIL_ADDRESS.test(value) -/** Local parts that name a mailbox, not a person; the no-reply family names no one at all. */ +/** Local parts that name a mailbox, not a person; the no-reply family names no one at all. @experimental */ export const ROLE_ADDRESS_WORDS = { noReply: ["noreply", "no-reply", "donotreply", "do-not-reply", "mailer-daemon", "bounce", "bounces"], shared: [ @@ -72,7 +72,10 @@ const SEPARATORS = /[.\-_]/u const partsOf = (address: string): string[] => localPart(address).split(SEPARATORS) const NO_REPLY_PARTS = ROLE_ADDRESS_WORDS.noReply.map((word) => `.${word.split(SEPARATORS).join(".")}.`) -/** Whether the address is a no-reply one, which belongs to no person: `noreply-12345@`, `service.no-reply@`. */ +/** + * Whether the address is a no-reply one, which belongs to no person: `noreply-12345@`, `service.no-reply@`. + * @experimental + */ export const isNoReplyAddress = (address: string): boolean => { const word = localWord(address) const parts = `.${partsOf(address).join(".")}.` @@ -83,6 +86,7 @@ export const isNoReplyAddress = (address: string): boolean => { /** * Whether the whole local part, `+tag` and `.`/`-`/`_` aside, is a role word (`info@`, `Hello+news@`, `no_reply@`), * or the address is a no-reply one. + * @experimental */ export const isRoleAddress = (address: string): boolean => ROLE.has(localWord(address)) || isNoReplyAddress(address) @@ -95,5 +99,5 @@ const PERSON_LIKE = new Set(["hr"]) /** Whether the address is a role address that one person often reads alone, such as `hr@`. */ export const isPersonLikeRoleAddress = (address: string): boolean => PERSON_LIKE.has(localWord(address)) -/** Whether a program sends from the address: `notify@`, `alerts@`, `bank-notifications@`. */ +/** Whether a program sends from the address: `notify@`, `alerts@`, `bank-notifications@`. @experimental */ export const isNotificationAddress = (address: string): boolean => partsOf(address).some((part) => NOTIFY.has(part)) diff --git a/src/domain/business.ts b/src/domain/business.ts index 230f4b15e..c8c223c71 100644 --- a/src/domain/business.ts +++ b/src/domain/business.ts @@ -2,35 +2,51 @@ import { CliError } from "@wirecat/cli-base" import { dayMonth, type FinanceReview, type MoneyDirection, notes } from "./finance.js" import { moneyLabel } from "./money.js" +/** @experimental */ export const CATALOG_KINDS = ["product", "service"] as const -/** What the `business` lane of `search all` reads; transactions are too many to fold per query. */ +/** What the `business` lane of `search all` reads; transactions are too many to fold per query. @experimental */ export const BUSINESS_KINDS = ["invoice", "payment", "order", "contract", "subscription", "product", "wallet"] as const +/** @experimental */ export type BusinessKind = (typeof BUSINESS_KINDS)[number] +/** @experimental */ export const CONTRACT_KINDS = ["sale", "purchase", "service", "lease", "employment", "nda", "license", "other"] as const +/** @experimental */ export const CONTRACT_STATUSES = ["draft", "active", "ended", "terminated"] as const +/** @experimental */ export const PERIOD_UNITS = ["day", "week", "month", "year"] as const +/** @experimental */ export const SUBSCRIPTION_STATUSES = ["trial", "active", "paused", "cancelled", "ended"] as const +/** @experimental */ export const WALLET_KINDS = ["bank", "card", "cash", "wallet", "other"] as const -/** Only a booked transaction counts in a balance; a pending one is shown beside it. */ +/** Only a booked transaction counts in a balance; a pending one is shown beside it. @experimental */ export const TRANSACTION_STATUSES = ["pending", "booked"] as const -/** `purchase`: the owner buys, as every order before store version 57; `sale`: the owner sells. */ +/** `purchase`: the owner buys, as every order before store version 57; `sale`: the owner sells. @experimental */ export const ORDER_DIRECTIONS = ["purchase", "sale"] as const +/** @experimental */ export type CatalogKind = (typeof CATALOG_KINDS)[number] +/** @experimental */ export type ContractKind = (typeof CONTRACT_KINDS)[number] +/** @experimental */ export type ContractStatus = (typeof CONTRACT_STATUSES)[number] +/** @experimental */ export type PeriodUnit = (typeof PERIOD_UNITS)[number] +/** @experimental */ export type SubscriptionStatus = (typeof SUBSCRIPTION_STATUSES)[number] +/** @experimental */ export type WalletKind = (typeof WALLET_KINDS)[number] +/** @experimental */ export type TransactionStatus = (typeof TRANSACTION_STATUSES)[number] +/** @experimental */ export type OrderDirection = (typeof ORDER_DIRECTIONS)[number] +/** @experimental */ export interface Interval { count: number unit: PeriodUnit } -/** `1-month`, `2-week` or a bare `year`, as `--every` takes it. */ +/** `1-month`, `2-week` or a bare `year`, as `--every` takes it. @experimental */ export const intervalOf = (text: unknown, reason = "subscription.interval"): Interval => { const match = typeof text === "string" ? /^(?:([1-9]\d{0,2})-)?(day|week|month|year)$/.exec(text.trim()) : null if (!match) @@ -38,6 +54,7 @@ export const intervalOf = (text: unknown, reason = "subscription.interval"): Int return { count: match[1] === undefined ? 1 : Number(match[1]), unit: match[2] as PeriodUnit } } +/** @experimental */ export const intervalText = ({ count, unit }: Interval): string => `${count}-${unit}` const priced = (units: number | null, currency: string | null) => diff --git a/src/domain/counters.ts b/src/domain/counters.ts index 50b156e5e..4f7065899 100644 --- a/src/domain/counters.ts +++ b/src/domain/counters.ts @@ -1,7 +1,9 @@ import { CliError } from "@wirecat/cli-base" import type { Message, Reactions } from "./models.js" +/** @experimental */ export const COUNTER_FIELDS = ["views", "reactions", "comments"] as const +/** @experimental */ export type CounterField = (typeof COUNTER_FIELDS)[number] export interface CounterObservation { value: number @@ -9,6 +11,7 @@ export interface CounterObservation { source: "remote_fetch" | "remote_update" reactions?: Reactions } +/** @experimental */ export type CounterObservations = Partial> export interface CounterState { counter: CounterField @@ -20,6 +23,7 @@ export interface CounterState { } export const validCounter = (value: unknown): value is number => typeof value === "number" && Number.isFinite(value) && value >= 0 +/** @experimental */ export const counterValue = ( message: Pick, field: CounterField, diff --git a/src/domain/crm.ts b/src/domain/crm.ts index 3ad862d58..ba5262948 100644 --- a/src/domain/crm.ts +++ b/src/domain/crm.ts @@ -1,6 +1,9 @@ import type { DealKind, DealRole, DealStatus, StageOutcome } from "./deals.js" -/** What a CRM holds that the store copies: its deals and leads, and the contacts and companies on them. */ +/** + * What a CRM holds that the store copies: its deals and leads, and the contacts and companies on them. + * @experimental + */ export const CRM_KINDS = ["organization", "person", "deal", "lead"] as const export type CrmKind = (typeof CRM_KINDS)[number] @@ -154,7 +157,7 @@ export interface CrmUser { active?: boolean } -/** A department of the own company: a user reports to its head, a head to the head of the parent. */ +/** A department of the own company: a user reports to its head, a head to the head of the parent. @experimental */ export interface CrmDepartment { externalId: string name: string @@ -189,7 +192,10 @@ export interface CrmRecords { organization: CrmOrganization } -/** What a CRM activity is: a call, an e-mail, a meeting, a to-do, a task of the CRM's task tracker, or a comment. */ +/** + * What a CRM activity is: a call, an e-mail, a meeting, a to-do, a task of the CRM's task tracker, or a comment. + * @experimental + */ export const CRM_ACTIVITY_KINDS = ["call", "email", "meeting", "todo", "task", "comment", "other"] as const export type CrmActivityKind = (typeof CRM_ACTIVITY_KINDS)[number] @@ -215,7 +221,10 @@ export interface CrmActivity { on: { kind: CrmKind; externalId: string }[] } -/** The account's scope settings: `also` are the users whose deals `mine` copies, in place of the sign-in's own. */ +/** + * The account's scope settings: `also` are the users whose deals `mine` copies, in place of the sign-in's own. + * @experimental + */ export type CrmScopeSetting = { mode: "all" } | { mode: "mine"; also: readonly string[]; explicit: boolean } /** @@ -224,18 +233,20 @@ export type CrmScopeSetting = { mode: "all" } | { mode: "mine"; also: readonly s * contacts are what the source lists; under `mine`, a contact no kept deal, lead or company names, and not assigned * to a user in scope, is removed after a sync that narrowed the copy or listed it again. Ids are normalised * (`normalCrmUserId`). + * @experimental */ export type CrmScope = { mode: "all" } | { mode: "mine"; self: string; also: readonly string[] } -/** A CRM's user id as `unassigned` takes it: digits, as every CRM core syncs numbers its users. */ +/** A CRM's user id as `unassigned` takes it: digits, as every CRM core syncs numbers its users. @experimental */ export const isCrmUserId = (id: string): boolean => /^\d{1,20}$/.test(id) -/** One spelling per user id, so `015`, ` 15` and `15` are one user wherever they come from. */ +/** One spelling per user id, so `015`, ` 15` and `15` are one user wherever they come from. @experimental */ export const normalCrmUserId = (id: string): string => { const text = id.trim() return /^\d+$/.test(text) ? text.replace(/^0+(?=\d)/, "") : text } +/** @experimental */ export const isItemKind = (kind: CrmKind): kind is DealKind => kind === "deal" || kind === "lead" /** diff --git a/src/domain/deals.ts b/src/domain/deals.ts index 69d72862f..5ddfd89fa 100644 --- a/src/domain/deals.ts +++ b/src/domain/deals.ts @@ -1,20 +1,23 @@ import { moneyLabel } from "./money.js" -/** A pipeline holds deals or leads, never both; a deal and a lead are rows of their own tables. */ +/** A pipeline holds deals or leads, never both; a deal and a lead are rows of their own tables. @experimental */ export const DEAL_KINDS = ["deal", "lead"] as const -/** Whether a deal or a lead ended, kept apart from the stage it stands in. */ +/** Whether a deal or a lead ended, kept apart from the stage it stands in. @experimental */ export const DEAL_STATUSES = ["open", "won", "lost"] as const -/** What reaching a stage means, as a CRM marks it: still open, or won or lost. */ +/** What reaching a stage means, as a CRM marks it: still open, or won or lost. @experimental */ export const STAGE_OUTCOMES = DEAL_STATUSES /** * The part a person plays on a deal: the owner's side runs it (`owner`, the CRM's "responsible"), the client's side * talks, decides or sways the decision. + * @experimental */ export const DEAL_ROLES = ["owner", "contact", "decision-maker", "influencer"] as const export type DealKind = (typeof DEAL_KINDS)[number] +/** @experimental */ export type DealStatus = (typeof DEAL_STATUSES)[number] export type StageOutcome = DealStatus +/** @experimental */ export type DealRole = (typeof DEAL_ROLES)[number] export interface DealTitleFields { diff --git a/src/domain/display-names.ts b/src/domain/display-names.ts index d23fbc9d5..bce03aee7 100644 --- a/src/domain/display-names.ts +++ b/src/domain/display-names.ts @@ -1,6 +1,6 @@ import { foldName } from "../resolve.js" -/** What a person can be shown as when their name has nothing to read. */ +/** What a person can be shown as when their name has nothing to read. @experimental */ export interface NameFallbacks { /** A name one of the person's accounts carries: a real name beats a handle. */ name?: string | null @@ -42,6 +42,7 @@ const given = (value: string | null | undefined): string | undefined => { * A name as it is shown: no wrapping quotes, no repeated or edge spaces. One with no letter or digit (`!`, `!$`), or a * placeholder such as `null` or «Без имени», gives way to an account's name, then the username, the phone, the email; * the stored name stays as it came. + * @experimental */ export const displayName = (name: string | null | undefined, fallbacks: NameFallbacks = {}): string | null => { const unwrapped = typeof name === "string" ? unquoted(name) : "" @@ -90,6 +91,7 @@ export const noFallbacks = (): Required => ({ name: null, usernam /** * The name two people share when case, quotes, punctuation and word order are ignored: `"Ivanov Ivan"` and * `ivan IVANOV` give one key. `null` for a name with no letter or digit, which matches nobody. + * @experimental */ export const nameKey = (name: string | null | undefined): string | null => { if (typeof name !== "string") return null diff --git a/src/domain/finance.ts b/src/domain/finance.ts index 2956bec5a..e27c01fce 100644 --- a/src/domain/finance.ts +++ b/src/domain/finance.ts @@ -1,15 +1,21 @@ import { moneyLabel } from "./money.js" +/** @experimental */ export const INVOICE_DIRECTIONS = ["receivable", "payable"] as const +/** @experimental */ export const INVOICE_STATUSES = ["draft", "issued", "partly_paid", "paid", "void"] as const -/** `in` is money to the owner, `out` money from the owner. */ +/** `in` is money to the owner, `out` money from the owner. @experimental */ export const MONEY_DIRECTIONS = ["in", "out"] as const -/** The owner's entry is confirmed at once; an agent's or an import's waits as proposed. */ +/** The owner's entry is confirmed at once; an agent's or an import's waits as proposed. @experimental */ export const FINANCE_REVIEWS = ["proposed", "confirmed", "rejected"] as const +/** @experimental */ export type InvoiceDirection = (typeof INVOICE_DIRECTIONS)[number] +/** @experimental */ export type InvoiceStatus = (typeof INVOICE_STATUSES)[number] +/** @experimental */ export type MoneyDirection = (typeof MONEY_DIRECTIONS)[number] +/** @experimental */ export type FinanceReview = (typeof FINANCE_REVIEWS)[number] /** An invoice's status from what confirmed payments settle; `draft` and `void` are the owner's and stay. */ diff --git a/src/domain/formatting.ts b/src/domain/formatting.ts index cf2438dab..f1e0f9179 100644 --- a/src/domain/formatting.ts +++ b/src/domain/formatting.ts @@ -28,6 +28,7 @@ export interface MarkdownFormatting { formatMarkdown(text: string): Promise } +/** @experimental */ export interface HtmlFormatting { formatHtml(text: string): Promise } diff --git a/src/domain/knowledge.ts b/src/domain/knowledge.ts index 448eb134c..8d5cdc41c 100644 --- a/src/domain/knowledge.ts +++ b/src/domain/knowledge.ts @@ -1,12 +1,17 @@ import { TASK_KINDS } from "../tasks/index.js" export { FACT_TYPES } from "../meetings/index.js" +/** @experimental */ export const FACT_STATUSES = ["proposed", "accepted", "superseded", "reversed", "rejected"] as const +/** @experimental */ export const MEMORY_KINDS = ["summary", "digest", "preference"] as const +/** @experimental */ export const MEMORY_STATUSES = ["proposed", "confirmed", "stale", "superseded"] as const +/** @experimental */ export const MEMORY_SCOPES = ["personal", "work"] as const -/** What the store writes itself; the task package finds only `TASK_KINDS`, in messages. */ +/** What the store writes itself; the task package finds only `TASK_KINDS`, in messages. @experimental */ export const WORK_TASK_TYPES = ["bug", "feature", "chore"] as const +/** @experimental */ export const TASK_TYPES = [...WORK_TASK_TYPES, ...TASK_KINDS] as const diff --git a/src/domain/links.ts b/src/domain/links.ts index 4d5c93a9b..0a8fa13c1 100644 --- a/src/domain/links.ts +++ b/src/domain/links.ts @@ -3,6 +3,7 @@ import { parseReference } from "./references.js" /** * What a WireCat link opens. A link only opens a screen in WireCat Desktop: no kind performs an action, a proposal * link shows the proposal and the owner presses Confirm or Reject there. + * @experimental */ export type DeepLinkTarget = | { type: "message"; provider: string; account: string; chat: string; message: string } @@ -24,15 +25,19 @@ export type DeepLinkTarget = */ | { type: "meeting"; provider: string; account: string; meeting: string } +/** @experimental */ export type LinkForm = "web" | "app" +/** @experimental */ export interface LinkConfig { /** The bounce page: the path goes after its `#`, so the host never sees it. */ base: string enabled: boolean } +/** @experimental */ export const LINK_VERSION = "v1" +/** @experimental */ export const DEFAULT_LINK_CONFIG: LinkConfig = { base: "https://wirecat.dev/o", enabled: true } const APP_PREFIX = "wirecat://open" const MAX_PATH = 512 @@ -113,12 +118,13 @@ const targetOfPath = (path: string): DeepLinkTarget | null => { } } -/** `/v1/msg/max/1001/-2002/3003`, the part both forms share. */ +/** `/v1/msg/max/1001/-2002/3003`, the part both forms share. @experimental */ export const formatLink = (target: DeepLinkTarget): string => `/${LINK_VERSION}/${pathOf(target)}` /** * The target of a link in either form (`https://…#/v1/…`, `wirecat://open/v1/…`) or of its bare path (`/v1/…`), or * `null` for anything else: another version, an unknown kind, a part too many or empty, a path over 512 characters. + * @experimental */ export const parseLink = (text: string): DeepLinkTarget | null => { const link = text.trim() @@ -141,6 +147,7 @@ const ENTITY_KINDS = new Set(["person", "project"]) /** * The refs in the order an item's one link is chosen from: a person or a project names who or what an item is about, * not where it happened, so it opens only when nothing else does. + * @experimental */ export const refsForLink = (refs: readonly string[]): string[] => [ ...refs.filter((ref) => !ENTITY_KINDS.has(ref.slice(0, ref.indexOf(":")))), @@ -152,6 +159,7 @@ export const refsForLink = (refs: readonly string[]): string[] => [ * `person:`, `project:`) is read by its own grammar; the kinds that are no reference are written as their path with a * colon after the kind: `proposal:fact%3A512`, `tasks:overdue`, `tasks:new/2026-11-07T08%3A00%3A00Z`, * `digest:2026-11-08`, `sync:telegram/1001`. + * @experimental */ export const linkTargetOf = (ref: string): DeepLinkTarget | null => { const text = ref.trim() @@ -167,7 +175,10 @@ export const linkTargetOf = (ref: string): DeepLinkTarget | null => { } } -/** The `links` section of the shared config, with the default for what is missing or not a usable value. */ +/** + * The `links` section of the shared config, with the default for what is missing or not a usable value. + * @experimental + */ export const linkConfigOf = (section: unknown): LinkConfig => { const value = section && typeof section === "object" ? (section as Record) : {} const base = @@ -181,6 +192,7 @@ export const linkConfigOf = (section: unknown): LinkConfig => { * The one way to build a WireCat link: the web form for messages and mail (an https page that hands it to the app), * the app form for a desktop terminal. `null` when links are off (`links.enabled: false`, or `WIRECAT_LINKS=off` for * one run) or the ref names nothing a link opens; the caller then leaves the link out. + * @experimental */ export const linkFor = ( ref: DeepLinkTarget | string, diff --git a/src/domain/locator.ts b/src/domain/locator.ts index 0d5471f94..be5f24490 100644 --- a/src/domain/locator.ts +++ b/src/domain/locator.ts @@ -5,6 +5,7 @@ import type { Id, Provider } from "./models.js" * Where one message lives, whichever messenger it came from. A message id alone means nothing: * Telegram numbers messages per chat in channels and per account in private chats, so only all four * parts name exactly one message across every provider and account in a shared store. + * @experimental */ export interface MessageLocator { provider: Provider @@ -15,12 +16,14 @@ export interface MessageLocator { const SCHEME = "msg:" -/** `msg:telegram/12345/-1001234567890/42` — each part percent-encoded, so no id can add a part. */ +/** `msg:telegram/12345/-1001234567890/42` — each part percent-encoded, so no id can add a part. @experimental */ export const formatLocator = ({ provider, account, chat, message }: MessageLocator): string => SCHEME + [provider, account, chat, message].map(encodeURIComponent).join("/") +/** @experimental */ export const isLocator = (reference: string): boolean => reference.trim().startsWith(SCHEME) +/** @experimental */ export const parseLocator = (reference: string): MessageLocator => { const trimmed = reference.trim() const parts = trimmed.startsWith(SCHEME) ? trimmed.slice(SCHEME.length).split("/") : [] diff --git a/src/domain/markdown.ts b/src/domain/markdown.ts index f1686bf48..fca6b9718 100644 --- a/src/domain/markdown.ts +++ b/src/domain/markdown.ts @@ -22,6 +22,7 @@ const WORD = /[\p{L}\p{N}]/u * ⚠ `_` and `*` open and close only at a word's edge, so `file_name_here` and `2*3*4` stay as they * are — the case where turning Markdown on would otherwise change a message nobody meant to format. * A backslash keeps the next character literal. + * @experimental */ export const parseMarkdown = (input: string): { text: string; markup: Markup[] } => { let text = "" diff --git a/src/domain/models.ts b/src/domain/models.ts index 431df58fb..e435ed4ac 100644 --- a/src/domain/models.ts +++ b/src/domain/models.ts @@ -13,7 +13,7 @@ import type { CounterObservation, CounterObservations } from "./counters.js" /** Every id is a string, never a number: provider ids are 64-bit, and an id is not arithmetic. */ export type Id = string -/** `telegram`, `max`… Open, because a new adapter must not need a change here. */ +/** `telegram`, `max`… Open, because a new adapter must not need a change here. @experimental */ export type Provider = string /** Whatever one provider knows that the shared model has no field for. */ @@ -22,7 +22,10 @@ export type ProviderMetadata = Record /** `saved` is the account's notes-to-self chat. */ export type ChatKind = "dialog" | "group" | "channel" | "saved" | "unknown" -/** Where the owner stands in a chat. Kept apart from whether its messages are searchable: a chat left keeps them. */ +/** + * Where the owner stands in a chat. Kept apart from whether its messages are searchable: a chat left keeps them. + * @experimental + */ export type MembershipState = "joined" | "left" | "public" | "imported" | "archived" | "external" export interface Chat { @@ -115,6 +118,7 @@ export interface GroupChange { removePhoto?: true } +/** @experimental */ export const GROUP_SETTINGS = [ "allCanPin", "onlyAdminsAdd", @@ -144,9 +148,13 @@ export interface Folder { pinnedChatIds?: Id[] } +/** @experimental */ export const FOLDER_KINDS = ["contacts", "non-contacts", "groups", "channels", "bots"] as const +/** @experimental */ export type FolderKind = (typeof FOLDER_KINDS)[number] +/** @experimental */ export const FOLDER_SKIPS = ["muted", "read", "archived"] as const +/** @experimental */ export type FolderSkip = (typeof FOLDER_SKIPS)[number] /** A folder's rules beside its chats; `include` and `skip` replace what it had, the chat lists add to it. */ @@ -165,7 +173,7 @@ export interface FolderChange extends FolderRules { remove?: Id[] } -/** What an admin may do, in max-cli's words; a messenger maps them onto its own. */ +/** What an admin may do, in max-cli's words; a messenger maps them onto its own. @experimental */ export const ADMIN_RIGHTS = ["read", "members", "admins", "info", "pin", "link", "post", "edit", "delete"] as const export type AdminRight = (typeof ADMIN_RIGHTS)[number] @@ -266,7 +274,7 @@ export interface Button { data?: string } -/** Where one attachment's bytes can be fetched. */ +/** Where one attachment's bytes can be fetched. @experimental */ export interface AttachmentLink { kind: string url: string @@ -275,7 +283,7 @@ export interface AttachmentLink { unsafe?: boolean } -/** What a chat has pinned after `messages pin` or `unpin`; `null` is nothing. */ +/** What a chat has pinned after `messages pin` or `unpin`; `null` is nothing. @experimental */ export interface Pin { chatId: Id pinned: Id | null @@ -325,7 +333,10 @@ export interface PollVote { votedAt: string } -/** A chat marked read up to `messageId`, inclusive. `unread` is what the provider says is left, or `null`. */ +/** + * A chat marked read up to `messageId`, inclusive. `unread` is what the provider says is left, or `null`. + * @experimental + */ export interface ReadMark { chatId: Id messageId: Id @@ -427,7 +438,7 @@ export interface Message { delivery?: Delivery } -/** MAX reports the owner's own messages with no sender id, so `outgoing` counts as well as the id. */ +/** MAX reports the owner's own messages with no sender id, so `outgoing` counts as well as the id. @experimental */ export const senderIsMe = (message: Pick, account: string): boolean => message.outgoing === true || (message.senderId !== null && String(message.senderId) === account) @@ -644,7 +655,10 @@ export interface Contact { /** Somebody in a chat, as much of them as a chat card shows. */ export type Member = Pick -/** A contact of the messenger's address book: the phone is there when the messenger shows it to the owner. */ +/** + * A contact of the messenger's address book: the phone is there when the messenger shows it to the owner. + * @experimental + */ export type AddressBookEntry = Member & { phone?: string | null } /** A topic of a forum group; its messages carry this id as `threadId`. */ @@ -661,7 +675,7 @@ export interface Topic { createdAt: string | null } -/** Who the account may post as in one chat. `self` is the account itself, always offered. */ +/** Who the account may post as in one chat. `self` is the account itself, always offered. @experimental */ export interface SenderIdentity { id: Id title: string @@ -714,7 +728,7 @@ export interface LinkTarget { } /** Somewhere this account is logged in — a device, a browser, this tool. */ -/** One call in the account's call history. */ +/** One call in the account's call history. @experimental */ export interface CallRecord { id: Id /** The dialog or group the call belongs to. */ @@ -737,6 +751,7 @@ export type Audience = "everyone" | "contacts" | "nobody" /** * An audience as `account privacy show` may report it: also the owner's contacts but some of them, which `set` * cannot choose. Kept apart from `Audience` so that a table keyed on it does not have to name it. + * @experimental */ export type ShownAudience = Audience | "contacts_except" @@ -762,10 +777,10 @@ export interface PrivacySettings { lastSeen?: ShownAudience } -/** Every setting `account privacy set` knows. */ +/** Every setting `account privacy set` knows. @experimental */ export type PrivacyKey = keyof PrivacySettings -/** A set of stickers the account has added. */ +/** A set of stickers the account has added. @experimental */ export interface StickerSet { id: Id title: string @@ -774,6 +789,7 @@ export interface StickerSet { link: string | null } +/** @experimental */ export interface Sticker { id: Id setId: Id | null @@ -783,8 +799,9 @@ export interface Sticker { url: string | null } -/** Kinds of attachment `chats media` filters by. */ +/** Kinds of attachment `chats media` filters by. @experimental */ export const MEDIA_KINDS = ["photo", "video", "file", "audio", "link"] as const +/** @experimental */ export type MediaKind = (typeof MEDIA_KINDS)[number] export interface AccountSession { @@ -834,6 +851,7 @@ export interface PersonCard extends Contact { /** * When they were last seen: a time, or the bucket their privacy leaves — `hidden` only when the * messenger says nothing at all. Telegram answers `recently`, `week` or `month` instead of a time. + * @experimental */ export type Seen = "online" | "recently" | "week" | "month" | "hidden" | (string & {}) @@ -934,6 +952,7 @@ export interface Account { phone?: string | null } +/** @experimental */ export interface Profile { id: Id name: string | null @@ -944,7 +963,7 @@ export interface Profile { /** One message of a window around another, which carries `anchor: true`. */ export type WindowedMessage = Message & { anchor?: true } -/** A number the messenger reports for its period, beside the same number for the period before. */ +/** A number the messenger reports for its period, beside the same number for the period before. @experimental */ export interface OfficialValue { current: number previous: number @@ -953,6 +972,7 @@ export interface OfficialValue { /** * One of the messenger's own graphs, colours and zoom dropped. `x.type` is read from the points: * `date` for UTC day starts (`YYYY-MM-DD`), `time` for other moments (ISO 8601), `number` as given. + * @experimental */ export interface OfficialGraph { kind: string @@ -962,11 +982,12 @@ export interface OfficialGraph { percentage?: boolean } -/** A graph the messenger could not give; the other graphs still answer. */ +/** A graph the messenger could not give; the other graphs still answer. @experimental */ export interface OfficialGraphError { error: string } +/** @experimental */ export interface OfficialPerson { person: Id name: string | null @@ -979,6 +1000,7 @@ interface OfficialStatsBase { period: { since: string; until: string } } +/** @experimental */ export interface OfficialGroupStats extends OfficialStatsBase { kind: "group" totals: Record<"members" | "messages" | "viewers" | "posters", OfficialValue> @@ -990,6 +1012,7 @@ export interface OfficialGroupStats extends OfficialStatsBase { graphs: Record } +/** @experimental */ export interface OfficialChannelStats extends OfficialStatsBase { kind: "channel" totals: Record< diff --git a/src/domain/money.ts b/src/domain/money.ts index 1bc03112d..2bbc07f6e 100644 --- a/src/domain/money.ts +++ b/src/domain/money.ts @@ -3,6 +3,7 @@ import { CliError } from "@wirecat/cli-base" /** * Minor-unit digits per ISO 4217 for the currencies the store keeps money in. A currency outside the list is refused * rather than guessed: a wrong scale would store every amount 100 times off. + * @experimental */ export const CURRENCY_SCALES: Readonly> = { AED: 2, @@ -41,7 +42,10 @@ export const CURRENCY_SCALES: Readonly> = { VND: 0, } -/** An exact amount as callers read and write it: a decimal string with the currency's scale, never a float. */ +/** + * An exact amount as callers read and write it: a decimal string with the currency's scale, never a float. + * @experimental + */ export interface Money { amount: string currency: string @@ -60,6 +64,7 @@ export const parseDecimal = (text: string, scale: number): bigint | undefined => return BigInt(`${match[1]}${(match[2] ?? "").padEnd(scale, "0")}`) } +/** @experimental */ export const formatDecimal = (units: bigint | number, scale: number): string => { const value = BigInt(units) if (value < 0n) return `-${formatDecimal(-value, scale)}` @@ -74,6 +79,7 @@ export const groupDigits = (decimal: string): string => { return fraction === undefined ? grouped : `${grouped}.${fraction}` } +/** @experimental */ export const currencyOf = (text: unknown): string => { const code = typeof text === "string" ? text.trim().toUpperCase() : "" if (CURRENCY_SCALES[code] === undefined) @@ -87,7 +93,10 @@ export const currencyOf = (text: unknown): string => { export const scaleOf = (currency: string): number => CURRENCY_SCALES[currencyOf(currency)] as number -/** Minor units of `currency` for a decimal string such as "50000.00"; refuses more decimals than the currency has. */ +/** + * Minor units of `currency` for a decimal string such as "50000.00"; refuses more decimals than the currency has. + * @experimental + */ export const minorUnits = (amount: unknown, currency: string, what = "an amount"): number => { const scale = scaleOf(currency) const units = typeof amount === "string" ? parseDecimal(amount, scale) : undefined @@ -100,19 +109,20 @@ export const minorUnits = (amount: unknown, currency: string, what = "an amount" return Number(units) } -/** Minor units for a decimal that may be negative, such as an opening balance of "-1200.50". */ +/** Minor units for a decimal that may be negative, such as an opening balance of "-1200.50". @experimental */ export const signedMinorUnits = (amount: unknown, currency: string, what = "an amount"): number => { if (typeof amount !== "string" || !amount.trim().startsWith("-")) return minorUnits(amount, currency, what) const units = minorUnits(amount.trim().slice(1), currency, what) return units === 0 ? 0 : -units } +/** @experimental */ export const moneyOf = (units: number, currency: string): Money => ({ amount: formatDecimal(units, scaleOf(currency)), currency, }) -/** "50 000.00 RUB". */ +/** "50 000.00 RUB". @experimental */ export const moneyLabel = (units: number, currency: string): string => `${groupDigits(formatDecimal(units, scaleOf(currency)))} ${currency}` diff --git a/src/domain/orders.ts b/src/domain/orders.ts index 2c452ff3c..5b1466a04 100644 --- a/src/domain/orders.ts +++ b/src/domain/orders.ts @@ -2,11 +2,14 @@ import type { OrderDirection } from "./business.js" import type { FinanceReview } from "./finance.js" import { moneyLabel } from "./money.js" +/** @experimental */ export const ORDER_STATUSES = ["placed", "shipped", "delivered", "cancelled", "returned"] as const -/** Why it was ordered: for the owner himself, for his business, for a client, or anything else. */ +/** Why it was ordered: for the owner himself, for his business, for a client, or anything else. @experimental */ export const ORDER_PURPOSES = ["personal", "business", "client", "other"] as const +/** @experimental */ export type OrderStatus = (typeof ORDER_STATUSES)[number] +/** @experimental */ export type OrderPurpose = (typeof ORDER_PURPOSES)[number] export interface OrderTitleFields { diff --git a/src/domain/person-kinds.ts b/src/domain/person-kinds.ts index 8d863a0ac..659990ae3 100644 --- a/src/domain/person-kinds.ts +++ b/src/domain/person-kinds.ts @@ -1,11 +1,13 @@ /** * What a person in the store is, for a list that shows the useful ones and keeps the noise apart. `test` is what a * test run left, which `all` leaves out too. + * @experimental */ export const PERSON_KINDS = ["person", "organization", "automated", "stranger", "unsorted", "test"] as const +/** @experimental */ export type PersonKind = (typeof PERSON_KINDS)[number] -/** What decided a kind, besides the ties that make someone a `person`. */ +/** What decided a kind, besides the ties that make someone a `person`. @experimental */ export type KindSignal = | "test-data" | "bot" diff --git a/src/domain/phones.ts b/src/domain/phones.ts index 0fbd3dbfc..fc4c4b2d4 100644 --- a/src/domain/phones.ts +++ b/src/domain/phones.ts @@ -1,8 +1,10 @@ import { CliError } from "@wirecat/cli-base" import { PHONE_PLANS } from "./phone-plans.generated.js" +/** @experimental */ export type PhoneCountry = (typeof PHONE_PLANS)[number]["country"] +/** @experimental */ export const PHONE_COUNTRIES = PHONE_PLANS.map((plan) => plan.country) /** Without the setting a number with no `+` is read as Russian, as before the setting existed. */ diff --git a/src/domain/polls.ts b/src/domain/polls.ts index 427130e5f..599e00114 100644 --- a/src/domain/polls.ts +++ b/src/domain/polls.ts @@ -3,6 +3,7 @@ import type { Id, Poll, PollVote } from "./models.js" /** * A poll with its counts taken from each voter's newest vote, for a messenger that sends votes one by one and counts * nothing (WhatsApp). `self`'s vote, when there is one, also sets `chosen`. A vote taken back counts toward nothing. + * @experimental */ export const countedPoll = (poll: Poll, votes: readonly PollVote[], self: Id | null): Poll => { const cast = votes.filter((vote) => vote.answers.length > 0) diff --git a/src/domain/providers.ts b/src/domain/providers.ts index 6b0edb4a3..6fc922abb 100644 --- a/src/domain/providers.ts +++ b/src/domain/providers.ts @@ -33,10 +33,10 @@ export interface ProviderEntry { } const MESSENGER_OPENS = { chat: "messages list", message: "messages show", contact: "contacts show" } as const -/** What a CRM CLI's entry gives as `opens`: the read commands `addCrmCommands` mounts. */ +/** What a CRM CLI's entry gives as `opens`: the read commands `addCrmCommands` mounts. @experimental */ export const CRM_OPENS = { deal: "deals show", lead: "leads show", pipeline: "pipelines show" } as const -/** The seed: what cli-core knows before any CLI has written its entry into the store. */ +/** The seed: what cli-core knows before any CLI has written its entry into the store. @experimental */ export const PROVIDERS: readonly ProviderEntry[] = [ { name: "telegram", kind: "messages", aliases: ["tg"], command: "tg", opens: MESSENGER_OPENS }, { name: "telegram-bot", kind: "messages", aliases: ["tg-bot"] }, @@ -93,6 +93,7 @@ export const providerLabel = (provider: Provider): string => LABELS[provider] ?? * A notes folder is an `accounts` row of one of these providers; people call every one `notes`. `obsidian` is a vault, * `local` a plain folder (store version 32). `folder` is what they were before, and what Drive's stand-in folders and * profile keys saved before that still say. + * @experimental */ export const FOLDER_PROVIDERS = ["local", "obsidian", "folder"] as const export const isFolderProvider = (provider: string): boolean => @@ -122,8 +123,10 @@ export const documentAccountProvidersSql = (): string => /** * What the owner adds by hand (`saveAddedSource`): one account, `owner`. Neither a folder nor a documents account, so no * folder can be bound to it and no sync deletes a source whose file is gone. + * @experimental */ export const ADDED_PROVIDER = "added" +/** @experimental */ export const ADDED_ACCOUNT = "owner" /** Documents `d` outside the added sources: a folder file joined to one would delete it when the file goes. */ export const notAdded = `d.account_id NOT IN (SELECT id FROM accounts WHERE provider = '${ADDED_PROVIDER}')` @@ -133,7 +136,7 @@ export const filesAccountSql = (column = "provider"): string => /** Notes written in memo have no account row; this is their account. */ export const INTERNAL_NOTES = "internal" -/** The reason a search gives for an account whose provider no entry names. */ +/** The reason a search gives for an account whose provider no entry names. @experimental */ export const UNKNOWN_PROVIDER = "unknown provider — run its CLI once" const WORD = /^[a-z0-9][a-z0-9_-]*$/ @@ -232,12 +235,16 @@ const joined = (known: readonly ProviderEntry[], entry: ProviderEntry): Provider let registry: readonly ProviderEntry[] = PROVIDERS -/** The built-ins and the entries the store or the CLI running gave; what `kindOf` and `providerNamed` read. */ +/** + * The built-ins and the entries the store or the CLI running gave; what `kindOf` and `providerNamed` read. + * @experimental + */ export const providers = (): readonly ProviderEntry[] => registry /** * Replaces the entries beyond the built-ins. Opening the store calls it with the stored entries; a test or a CLI * with no store may call it too. Two entries that disagree on a kind, or one word naming two providers, throw. + * @experimental */ export const useProviders = (entries: readonly ProviderEntry[]): void => { registry = entries.map(providerEntryOf).reduce(joined, PROVIDERS) @@ -266,6 +273,7 @@ export const addProvider = (entry: ProviderEntry): void => { registry = joined(registry, providerEntryOf(entry)) } +/** @experimental */ export const isKind = (word: string): word is Kind => (KINDS as readonly string[]).includes(word.toLowerCase()) /** The registry's provider a name or alias stands for. */ @@ -274,13 +282,17 @@ export const providerNamed = (word: string): ProviderEntry | undefined => { return registry.find((entry) => wordsOf(entry).includes(wanted)) } -/** The kind of a provider the registry knows; `undefined` for one no entry names, which a search skips. */ +/** + * The kind of a provider the registry knows; `undefined` for one no entry names, which a search skips. + * @experimental + */ export const kindIn = (provider: Provider): Kind | undefined => isFolderProvider(provider) ? "notes" : registry.find(({ name }) => name === provider)?.kind /** * Every kind a provider's accounts hold, its `kind` first; empty for one no entry names. An import-only provider's * accounts hold documents too: a records import writes them beside its calls and SMS. + * @experimental */ export const kindsIn = (provider: Provider): readonly Kind[] => { if (isFolderProvider(provider)) return ["notes"] @@ -321,12 +333,15 @@ export const isImportedProvider = (provider: Provider): boolean => export const alsoListedByKey = (provider: Provider): boolean => isDocumentAccountProvider(provider) && kindsIn(provider).some((kind) => kind !== "documents") -/** Whether a provider's accounts hold `kind`: what a search lane picks its accounts by. */ +/** Whether a provider's accounts hold `kind`: what a search lane picks its accounts by. @experimental */ export const holdsKind = (provider: Provider, kind: Kind): boolean => kindsIn(provider).includes(kind) /** `holdsKind`, with a provider no entry names counted as a messenger, as `kindOf` counts it. */ export const holdsKindOf = (provider: Provider, kind: Kind): boolean => kindIn(provider) === undefined ? kind === "messages" : holdsKind(provider, kind) -/** A provider the registry does not list counts as a messenger here; a search asks `kindIn` and skips it. */ +/** + * A provider the registry does not list counts as a messenger here; a search asks `kindIn` and skips it. + * @experimental + */ export const kindOf = (provider: Provider): Kind => kindIn(provider) ?? "messages" diff --git a/src/domain/rankings-graph.ts b/src/domain/rankings-graph.ts index 9128a8e82..2fdaef45f 100644 --- a/src/domain/rankings-graph.ts +++ b/src/domain/rankings-graph.ts @@ -1,10 +1,12 @@ import { CliError } from "@wirecat/cli-base" import { rankingQuestion } from "./rankings-options.js" +/** @experimental */ export interface RankingGraphLink { chatId: string messageId: string } +/** @experimental */ export interface RankingGraphEvidence { version: 1 reply?: RankingGraphLink | null diff --git a/src/domain/rankings-options.ts b/src/domain/rankings-options.ts index 66545960f..1b4cbb865 100644 --- a/src/domain/rankings-options.ts +++ b/src/domain/rankings-options.ts @@ -13,13 +13,16 @@ export const AUTHOR_MEASURES = [ ] as const export type RankingTarget = "messages" | "contacts" export type MessageKind = "all" | "posts" | "comments" +/** @experimental */ export type RankingMeasure = (typeof MESSAGE_MEASURES)[number] | (typeof AUTHOR_MEASURES)[number] export type RankingComponent = | Exclude | "replies-from-others" | "reactions-per-message" | "replies-from-others-per-message" +/** @experimental */ export type ScorePreset = "helpful" | "active" | "engaging" +/** @experimental */ export type RankingWeights = Partial> export interface RankingInput { measure?: string @@ -28,6 +31,7 @@ export interface RankingInput { minMessages?: number messageKind?: string } +/** @experimental */ export interface RankingOptions { target: RankingTarget measure: RankingMeasure | "score" @@ -59,6 +63,7 @@ function invalid(message: string): never { throw new CliError("validation_error", message, { reason: "ranking.invalid" }) } +/** @experimental */ export const rankingOptions = (target: RankingTarget, input: RankingInput): RankingOptions => { const measures: readonly string[] = target === "messages" ? MESSAGE_MEASURES : AUTHOR_MEASURES const { measure, score, weights: given, minMessages } = input diff --git a/src/domain/record-types.ts b/src/domain/record-types.ts index faec37507..4e3048bc5 100644 --- a/src/domain/record-types.ts +++ b/src/domain/record-types.ts @@ -532,7 +532,10 @@ export const RECORD_TYPES = { export type RecordType = keyof typeof RECORD_TYPES -/** Every registered type is an envelope type: `custom:` covers whatever a source has beyond them. */ +/** + * Every registered type is an envelope type: `custom:` covers whatever a source has beyond them. + * @experimental + */ export type RecordEntityType = RecordType export const isRecordType = (type: string): type is RecordType => Object.hasOwn(RECORD_TYPES, type) @@ -548,6 +551,7 @@ export const isBusinessType = (type: string): type is BusinessType => export const isIdentityType = (type: unknown): type is IdentityType => typeof type === "string" && isRecordType(type) && RECORD_TYPES[type].review === "identity" +/** @experimental */ export const RECORD_ENTITY_TYPES = Object.keys(RECORD_TYPES) as RecordType[] type Tables = { [K in keyof T]: T[K] extends { table: infer N } ? N : never } diff --git a/src/domain/records-table.ts b/src/domain/records-table.ts index 142dde8f7..b01647b02 100644 --- a/src/domain/records-table.ts +++ b/src/domain/records-table.ts @@ -11,13 +11,18 @@ import { type RecordsEnvelope, } from "./records.js" -/** The types a table can carry: an SMS and a call come from a phone's own export, never from a hand-made sheet. */ +/** + * The types a table can carry: an SMS and a call come from a phone's own export, never from a hand-made sheet. + * @experimental + */ export const TABLE_RECORD_TYPES = Object.keys(RECORD_TYPES).filter( (type) => (RECORD_TYPES[type as keyof typeof RECORD_TYPES] as RecordTypeSpec).sheet !== false, ) as readonly string[] +/** @experimental */ export type ColumnShape = "text" | "decimal" | "day" | "instant" | "currency" | "integer" | "boolean" | "list" +/** @experimental */ export interface TableColumn { /** `external_id`, a field (`total`), a role (`counterparty`) or an item of a list (`lines.amount`). */ name: string @@ -32,18 +37,23 @@ export interface TableColumn { many?: boolean } -/** Where a pointer into the envelope came from in the sheet: its line from 1 (the header is 1), and the column. */ +/** + * Where a pointer into the envelope came from in the sheet: its line from 1 (the header is 1), and the column. + * @experimental + */ export interface TablePlace { line: number column?: string } +/** @experimental */ export interface TableEnvelope { envelope: RecordsEnvelope /** The sheet's place of a receipt's or an error's pointer, by its longest known prefix. */ placeOf(pointer: string): TablePlace | undefined } +/** @experimental */ export class TableError extends Error { constructor(readonly errors: (IngestError & { place?: TablePlace })[]) { super(errors.map((e) => e.message).join("; ")) @@ -104,7 +114,10 @@ const roleColumn = (name: string, role: RecordRoleSpec): TableColumn => ({ ...(role.many ? { many: true } : {}), }) -/** A type's columns: the external id, its flat fields, one per role, then one per key of each list of items. */ +/** + * A type's columns: the external id, its flat fields, one per role, then one per key of each list of items. + * @experimental + */ export const recordColumns = (type: string): TableColumn[] => { const spec = specOf(type) if (!spec || spec.sheet === false) return [] @@ -163,6 +176,7 @@ const exampleRef = (column: TableColumn) => ({ /** * A file to fill for a type. CSV is the header row alone, with a byte-order mark so Excel reads it as UTF-8; JSON is * an envelope of one example record that names every field and role. + * @experimental */ export const recordTemplate = ( type: string, @@ -315,6 +329,7 @@ const relationsOf = (column: TableColumn, raw: string): RecordRelation[] | Inges /** * Reads a sheet of one type as an envelope. A row whose `external_id` an earlier row had continues that record: its * item columns (`lines.amount`) add one item to the list, as an invoice exported a line a row does. + * @experimental */ export const envelopeOfCsv = ( text: string, diff --git a/src/domain/records.ts b/src/domain/records.ts index e1f237e45..60714ea8e 100644 --- a/src/domain/records.ts +++ b/src/domain/records.ts @@ -21,10 +21,14 @@ import { export { RECORD_ENTITY_TYPES, type RecordEntityType } from "./record-types.js" +/** @experimental */ export const RECORDS_SCHEMA_VERSION = 1 +/** @experimental */ export const RECORD_OPERATIONS = ["upsert", "delete"] as const +/** @experimental */ export type RecordOperation = (typeof RECORD_OPERATIONS)[number] +/** @experimental */ export interface RecordRelation { /** What the target is to this record: `counterparty`, `payer`, `settles`, or a source's own word. */ role: string @@ -41,6 +45,7 @@ export interface RecordRelation { /** How an envelope's lines read `product`: `text` keeps an invoice line's product as data, as v1 did. */ export const LINE_OPTIONS = ["text", "products"] as const +/** @experimental */ export interface EnvelopeOptions { lines?: (typeof LINE_OPTIONS)[number] /** @@ -50,6 +55,7 @@ export interface EnvelopeOptions { phone_region?: string } +/** @experimental */ export interface EnvelopeRecord { /** The caller's name for this line, unique in the envelope; the receipt cites it. */ key: string @@ -62,12 +68,14 @@ export interface EnvelopeRecord { relations?: RecordRelation[] } +/** @experimental */ export interface EnvelopeSource { provider: string account: string batch_id: string } +/** @experimental */ export interface RecordsEnvelope { schema_version: 1 source: EnvelopeSource @@ -75,7 +83,10 @@ export interface RecordsEnvelope { records: EnvelopeRecord[] } -/** A refusal: `pointer` is an RFC 6901 JSON pointer into the envelope, `code` a stable word callers may branch on. */ +/** + * A refusal: `pointer` is an RFC 6901 JSON pointer into the envelope, `code` a stable word callers may branch on. + * @experimental + */ export interface IngestError { pointer: string code: string @@ -94,7 +105,10 @@ const REF = "^[a-z]+:[^\\s]{1,500}$" const fieldsDef = (type: RecordType) => `fields-${type}` -/** The v1 envelope as JSON Schema (Draft 2020-12); `schemas/records-envelope.v1.schema.json` is this, written out. */ +/** + * The v1 envelope as JSON Schema (Draft 2020-12); `schemas/records-envelope.v1.schema.json` is this, written out. + * @experimental + */ export const RECORDS_ENVELOPE_SCHEMA = { $schema: "https://json-schema.org/draft/2020-12/schema", title: "WireCat records envelope, version 1", @@ -449,6 +463,7 @@ export const jsonLine = (line: string): unknown => { /** * A JSONL import as the envelope it stands for: the first line holds `schema_version`, `source` and `options`, each * further non-empty line one record. + * @experimental */ export const envelopeOfJsonl = (text: string): unknown => { const lines = withoutBom(text).split(/\r?\n/) @@ -466,6 +481,7 @@ export const envelopeOfJsonl = (text: string): unknown => { /** * A file's text as the envelope it stands for: one JSON envelope, or JSONL, told apart by the first non-empty line; * a JSON object holding `records` is a whole envelope. + * @experimental */ export const envelopeOfText = (text: string): unknown => { const clean = withoutBom(text) diff --git a/src/domain/ref-summaries.ts b/src/domain/ref-summaries.ts index 08088febb..ce0c1e981 100644 --- a/src/domain/ref-summaries.ts +++ b/src/domain/ref-summaries.ts @@ -4,11 +4,15 @@ import type { AccountKey } from "../store/types.js" import { providerNamed } from "./providers.js" import type { RefKindName } from "./references.js" +/** @experimental */ export type RefState = "available" | "deleted" | "unavailable" -/** A message or chat of the `email` provider is mail, so it reads as `email` and `email_thread`. */ +/** A message or chat of the `email` provider is mail, so it reads as `email` and `email_thread`. @experimental */ export type RefSummaryKind = RefKindName | "email" | "email_thread" | "unknown" -/** What a reference names, read from the store in one batch so a page of refs costs one query per kind. */ +/** + * What a reference names, read from the store in one batch so a page of refs costs one query per kind. + * @experimental + */ export interface RefSummary { /** Canonical spelling; the map key is the text the caller passed. */ ref: string @@ -29,6 +33,7 @@ export interface RefSummary { excerpt?: string | null } +/** @experimental */ export interface RefsStore { /** One query per kind present. Never throws for a bad ref: it comes back `unknown`, `unavailable`. */ summaries(refs: readonly string[], options?: { excerpt?: boolean }): Promise> @@ -44,12 +49,16 @@ export interface RefsStore { ends(ref: string): Promise<{ provider: string; account: string }[][] | undefined> } -/** The caller's answer to "which profile opens this": one signed in, or the choices and why there is not one. */ +/** + * The caller's answer to "which profile opens this": one signed in, or the choices and why there is not one. + * @experimental + */ export type ProfilesFor = ( provider: string, account: string | null, ) => { profile: string } | { why: string; profiles: string[] } +/** @experimental */ export interface RefOpen { /** Ready to run; contains `` when `profiles` is not exactly one. `null` when no CLI opens it. */ argv: string[] | null @@ -57,16 +66,21 @@ export interface RefOpen { why: string | null } +/** @experimental */ export const PROFILE_PLACEHOLDER = "" const unregistered = (provider: string) => `no CLI has registered ${provider} in this store yet; run its CLI once` +/** @experimental */ export const profilesOn = (profiles: Profiles, app: string, key: AccountKey): string[] => Object.entries(profiles[app] ?? {}) .filter(([, saved]) => saved.provider === key.provider && saved.account === key.account) .map(([name]) => name) -/** From the store's record, so it answers for any CLI that registered its provider, not only the messengers. */ +/** + * From the store's record, so it answers for any CLI that registered its provider, not only the messengers. + * @experimental + */ export const storedProfilesFor = (profiles: Profiles): ProfilesFor => (provider, account) => { @@ -87,6 +101,7 @@ export const storedProfilesFor = /** * Which CLI changes a CRM copy on its server, and as which profile; `profile` is `null` unless exactly one fits. * `account` is the row's: the write refuses a row of any other account than its profile's live one. + * @experimental */ export interface WritesWith { tool: string | null @@ -101,6 +116,7 @@ const keyText = (key: AccountKey) => `${key.provider}:${key.account}` /** * `null` for the owner's own row: memo itself writes it. `allowed` is the caller's profile or group lock: a profile it * forbids is never named, and the one profile it leaves is the answer. + * @experimental */ export const writesWithOf = ( account: AccountKey | null, @@ -140,6 +156,7 @@ const openKind = (kind: RefSummaryKind): RefKindName | undefined => /** * The command that opens a ref. A registered provider opens its own kinds; anything else opens with the caller's * `local` words (memo's `notes show`). The profile is never picked: with none or several, `argv` keeps ``. + * @experimental */ export const openOf = ( summary: RefSummary, @@ -197,7 +214,7 @@ const WORDS: Record = { unknown: "Unknown", } -/** `Chat «Сайт + автоматизация» (MAX)`: the one label every review row, status line and `show` prints. */ +/** `Chat «Сайт + автоматизация» (MAX)`: the one label every review row, status line and `show` prints. @experimental */ export const refLabel = (summary: RefSummary): string => { const named = summary.title === null ? summary.ref : `«${oneLine(summary.title)}»` const notes = [summary.in === null ? null : oneLine(summary.in), summary.state === "available" ? null : summary.state] diff --git a/src/domain/references.ts b/src/domain/references.ts index 427ab27f0..620fd8219 100644 --- a/src/domain/references.ts +++ b/src/domain/references.ts @@ -48,6 +48,7 @@ export type SimpleReference = (typeof SIMPLE_REFERENCES)[number] export type RefKindName = Exclude +/** @experimental */ export interface RefKindSpec { /** The word before the first colon: `chat`, `msg`, `document`. */ prefix: string @@ -107,7 +108,7 @@ const simple = (prefix: SimpleReference) => format: (reference) => `${reference.type}:${reference.id}`, }) -/** Every kind of reference. A new kind is one row here; nothing else switches on the prefix. */ +/** Every kind of reference. A new kind is one row here; nothing else switches on the prefix. @experimental */ export const REF_KINDS: readonly RefKindSpec[] = [ kind>({ prefix: "msg", @@ -222,12 +223,13 @@ export const parseReference = (text: string): Reference => { return spec.parse(rest, reference) } -/** The stored spelling of a reference, so two spellings of one thing compare equal. */ +/** The stored spelling of a reference, so two spellings of one thing compare equal. @experimental */ export const canonicalReference = (text: string): string => formatReference(parseReference(text)) /** * Strict: the whole text is one reference of a known kind, with no space. A title such as "Note: plan" is not, so an * argument that takes either a reference or a title can tell them apart. The shape is checked only by parsing it. + * @experimental */ export const looksLikeReference = (text: string): boolean => { const match = /^([a-z]+):\S+$/.exec(text.trim()) diff --git a/src/domain/relation-role-labels.ts b/src/domain/relation-role-labels.ts index 16f99835f..fdddd2964 100644 --- a/src/domain/relation-role-labels.ts +++ b/src/domain/relation-role-labels.ts @@ -1,5 +1,6 @@ import type { ROLE_LISTS, RoleList } from "./relations.js" +/** @experimental */ export interface RoleLabels { en: string ru: string @@ -8,7 +9,10 @@ export interface RoleLabels { const label = (en: string, ru: string, es: string): RoleLabels => ({ en, ru, es }) -/** Keyed by list: a deal's `owner` is the one responsible for it, an organization's is the one who owns it. */ +/** + * Keyed by list: a deal's `owner` is the one responsible for it, an organization's is the one who owns it. + * @experimental + */ export const ROLE_LABELS: { [L in RoleList]: Record<(typeof ROLE_LISTS)[L][number], RoleLabels> } = { organization: { employee: label("Employee", "Сотрудник", "Empleado"), diff --git a/src/domain/relations.ts b/src/domain/relations.ts index 7a24df2e9..566f163d4 100644 --- a/src/domain/relations.ts +++ b/src/domain/relations.ts @@ -1,7 +1,10 @@ import { CliError } from "@wirecat/cli-base" import { DEAL_ROLES } from "./deals.js" -/** What a person is to an organization; who reports to whom is `reports-to`, and a job title is never a role. */ +/** + * What a person is to an organization; who reports to whom is `reports-to`, and a job title is never a role. + * @experimental + */ export const ORGANIZATION_ROLES = [ "employee", "contractor", @@ -11,18 +14,24 @@ export const ORGANIZATION_ROLES = [ "adviser", "contact", ] as const +/** @experimental */ export const PROJECT_ROLES = ["owner", "manager", "contributor", "client-contact", "approver"] as const -/** A contract party's part; a party the list cannot name has none, never a catch-all `other`. */ +/** A contract party's part; a party the list cannot name has none, never a catch-all `other`. @experimental */ export const CONTRACT_ROLES = ["customer", "supplier", "signatory", "guarantor"] as const /** * What a person or an organization is to another on `related-to`, offered so the same tie reads the same way. Unlike * the other lists it is not enforced: roles written before it, and words a source reports, stay. Buying and partnering * are the kinds `customer-of` and `partner-of`, so they are not roles here. + * @experimental */ export const RELATED_ROLES = ["colleague", "adviser", "investor", "mentor", "family", "friend"] as const -/** How much the owner deals with a person on a project himself, not how active the person is; absent is unknown. */ +/** + * How much the owner deals with a person on a project himself, not how active the person is; absent is unknown. + * @experimental + */ export const ENGAGEMENT_LEVELS = ["none", "low", "medium", "high"] as const +/** @experimental */ export type Engagement = (typeof ENGAGEMENT_LEVELS)[number] export const isEngagement = (value: unknown): value is Engagement => @@ -44,9 +53,10 @@ export const checkEngagement = (kind: string, from: string, to: string, level: s /** Who the owner deals with most comes first: high, medium, unknown, low, none. */ const ENGAGEMENT_ORDER: Record = { high: 0, medium: 1, unknown: 2, low: 3, none: 4 } +/** @experimental */ export const engagementRank = (level: Engagement | null | undefined): number => ENGAGEMENT_ORDER[level ?? "unknown"] -/** A stable sort by `engagementRank`; links without a level keep their order among themselves. */ +/** A stable sort by `engagementRank`; links without a level keep their order among themselves. @experimental */ export const byEngagement = (items: readonly T[]): T[] => items .map((item, index) => ({ item, index })) @@ -69,6 +79,7 @@ interface RelationSpec { /** * Every relationship `knowledge.relate` makes, its ends, its roles and how it reads backwards. An organization may * still be a member: owner data from before this list holds such links. + * @experimental */ export const RELATIONS = { "member-of": { @@ -86,7 +97,9 @@ export const RELATIONS = { }, } as const satisfies Record +/** @experimental */ export type RelationKind = keyof typeof RELATIONS +/** @experimental */ export const RELATION_KINDS = Object.keys(RELATIONS) as RelationKind[] const specOf = (kind: string): RelationSpec | undefined => @@ -123,6 +136,7 @@ const isParty = (type: string) => type === "person" || type === "organization" /** * The roles a relationship takes, or `undefined` for free text. A member's list is the organization's or the * project's only when the member is a person: a chat's or a sub-project's role was never one of them. + * @experimental */ export const rolesOf = (kind: string, from: string, to: string): readonly string[] | undefined => { const spec = specOf(kind) @@ -130,7 +144,7 @@ export const rolesOf = (kind: string, from: string, to: string): readonly string return spec?.roles?.from?.[from as End] ?? spec?.roles?.to?.[to as End] } -/** The role lists the owner may add to; each is a list the registry gives some relationship's ends. */ +/** The role lists the owner may add to; each is a list the registry gives some relationship's ends. @experimental */ export const ROLE_LISTS = { organization: ORGANIZATION_ROLES, project: PROJECT_ROLES, @@ -138,6 +152,7 @@ export const ROLE_LISTS = { contract: CONTRACT_ROLES, related: RELATED_ROLES, } as const +/** @experimental */ export type RoleList = keyof typeof ROLE_LISTS /** Which list a relationship's role comes from, or `undefined` where a role is free text. */ @@ -168,15 +183,20 @@ export const checkRole = ( export const isSymmetric = (kind: string): boolean => specOf(kind)?.symmetric === true -/** The label of a relationship read from its `to` end: `manages` for `reports-to`; the kind itself when symmetric. */ +/** + * The label of a relationship read from its `to` end: `manages` for `reports-to`; the kind itself when symmetric. + * @experimental + */ export const inverseOf = (kind: string): string | null => specOf(kind)?.symmetric ? kind : ((specOf(kind)?.inverse as string | undefined) ?? null) /** * What an answer says about a relationship, derived, never stored: the owner's, a source's that nobody confirmed, an * agent's suggestion waiting for review, or one that no longer holds. + * @experimental */ export const STANDINGS = ["confirmed", "reported", "proposed", "ended"] as const +/** @experimental */ export type Standing = (typeof STANDINGS)[number] /** A link's columns `standing` reads; a column an older store lacks is `null`. */ @@ -213,7 +233,10 @@ export interface RelationshipColumns { derived?: string } -/** The owner's confirmation outlives a source that stopped reporting it; only its own end date ends it. */ +/** + * The owner's confirmation outlives a source that stopped reporting it; only its own end date ends it. + * @experimental + */ export const standingOf = (link: StandingFields, now: number): Standing => { if (link.endsAt != null && link.endsAt <= now) return "ended" if (link.confirmed) return "confirmed" @@ -221,9 +244,10 @@ export const standingOf = (link: StandingFields, now: number): Standing => { return link.accountId != null ? "reported" : "proposed" } -/** A relationship a context or a traversal counts: the owner's, or a source's that still holds. */ +/** A relationship a context or a traversal counts: the owner's, or a source's that still holds. @experimental */ export const isUsable = (standing: Standing): boolean => standing === "confirmed" || standing === "reported" +/** @experimental */ export const usableLink = (link: StandingFields, now: number): boolean => isUsable(standingOf(link, now)) // links_relationship_key's WHERE, word for word: without it SQLite cannot use that partial index, picks diff --git a/src/domain/tag-consolidation.ts b/src/domain/tag-consolidation.ts index f6a9eb882..d2c105771 100644 --- a/src/domain/tag-consolidation.ts +++ b/src/domain/tag-consolidation.ts @@ -1,3 +1,4 @@ +/** @experimental */ export interface TagConsolidationOptions { sourceId: string survivorId: string @@ -8,6 +9,7 @@ export interface TagConsolidationOptions { signal?: AbortSignal } +/** @experimental */ export interface TagConsolidationPreview { source: { id: string; name: string } survivor: { id: string; name: string } @@ -54,17 +56,20 @@ export interface TagConsolidationPreview { } } +/** @experimental */ export interface TagConsolidationStore { previewTagConsolidation(options: TagConsolidationOptions): Promise applyTagConsolidation(options: TagConsolidationApplyOptions): Promise } +/** @experimental */ export interface TagConsolidationApplyOptions extends Omit { by: "owner" expectedPreviewFingerprint: string idempotencyKey: string } +/** @experimental */ export interface TagConsolidationReceipt { id: string sourceId: string diff --git a/src/domain/tag-redirects.ts b/src/domain/tag-redirects.ts index d55b3221d..1e226e4eb 100644 --- a/src/domain/tag-redirects.ts +++ b/src/domain/tag-redirects.ts @@ -1,11 +1,13 @@ import { CliError } from "@wirecat/cli-base" +/** @experimental */ export interface TagRedirectSnapshot { complete: true tags: readonly { id: string; kind: "tag" }[] redirects: readonly { sourceId: string; survivorId: string }[] } +/** @experimental */ export interface TagRedirectResolution { requestedId: string canonicalId: string @@ -15,6 +17,7 @@ export interface TagRedirectResolution { memberIds: string[] } +/** @experimental */ export interface TagRedirectIndex { resolve(id: string): TagRedirectResolution } @@ -38,7 +41,7 @@ const tagId = (value: unknown, field: string): string => { return value } -/** Validates the whole captured graph before exposing any resolution; it enables no store writes. */ +/** Validates the whole captured graph before exposing any resolution; it enables no store writes. @experimental */ export const createTagRedirectIndex = (snapshot: TagRedirectSnapshot): TagRedirectIndex => { const input = record(snapshot, ["complete", "tags", "redirects"], "snapshot") if (input.complete !== true) invalid("snapshot.complete must be true; partial tag graphs cannot resolve labels") diff --git a/src/domain/tags.ts b/src/domain/tags.ts index 0f0cdd694..d3929658c 100644 --- a/src/domain/tags.ts +++ b/src/domain/tags.ts @@ -1,6 +1,8 @@ import { CliError, singleLine } from "@wirecat/cli-base" +/** @experimental */ export const TAG_TYPES = ["chat", "contact", "message", "task"] as const +/** @experimental */ export type TagType = (typeof TAG_TYPES)[number] const TAG = /^[a-z0-9-]{1,32}$/ diff --git a/src/domain/vcard.ts b/src/domain/vcard.ts index 70b251aeb..d7faf94b7 100644 --- a/src/domain/vcard.ts +++ b/src/domain/vcard.ts @@ -3,6 +3,7 @@ import { e164Of, type PhoneCountry } from "./phones.js" import { WORD_BODY } from "./record-types.js" import type { EnvelopeRecord, RecordRelation, RecordsEnvelope } from "./records.js" +/** @experimental */ export interface VcardOptions { provider: string account: string @@ -11,6 +12,7 @@ export interface VcardOptions { region?: PhoneCountry } +/** @experimental */ export interface VcardIssue { /** The card's place in the file, from 0. */ card: number @@ -26,7 +28,7 @@ interface Property { const MAX_ID = 512 const AS_WORD = new RegExp(`^${WORD_BODY}$`) -/** Whether a file is a vCard address book rather than a JSON or JSONL envelope. */ +/** Whether a file is a vCard address book rather than a JSON or JSONL envelope. @experimental */ export const isVcard = (text: string): boolean => /^?\s*BEGIN:VCARD\b/i.test(text) const isQuotedPrintable = (line: string) => { @@ -195,6 +197,7 @@ const cardsOf = (text: string): { cards: Property[][]; issues: VcardIssue[] } => * A vCard file (2.1, 3.0 or 4.0) as a records envelope: one person per card, matched later by its numbers and * addresses, and one organization per `ORG` name the person is a member of. Nothing is guessed: a national number * is read only in `region`, and a card says nothing about a person it does not hold. + * @experimental */ export const envelopeOfVcard = ( text: string, diff --git a/src/entities/business-context.ts b/src/entities/business-context.ts index 686e38a0c..2bd128332 100644 --- a/src/entities/business-context.ts +++ b/src/entities/business-context.ts @@ -137,7 +137,7 @@ export const personBusiness = v.strictObject({ categories, }) -/** Any canonical person's context: every account in scope read, their business, and what was not read. */ +/** Any canonical person's context: every account in scope read, their business, and what was not read. @experimental */ export const personContext: v.GenericSchema = v.strictObject({ ...crossAccountContext.entries, person: linkedPerson, @@ -146,7 +146,10 @@ export const personContext: v.GenericSchema = v.strictObject({ coverage, }) -/** One organization: people, customers, suppliers, partners, projects, open deals, money and how much is said. */ +/** + * One organization: people, customers, suppliers, partners, projects, open deals, money and how much is said. + * @experimental + */ export const organizationContext: v.GenericSchema = v.strictObject({ organization: v.strictObject({ ...organization.entries, own: v.boolean() }), categories, @@ -181,7 +184,10 @@ export const organizationContext: v.GenericSchema = v.strictObject({ const { untrusted: _, ...dealRow } = deal.entries -/** One deal or lead: the row, its stages, client, people, project, money and what its people said in its time. */ +/** + * One deal or lead: the row, its stages, client, people, project, money and what its people said in its time. + * @experimental + */ export const dealContext: v.GenericSchema = v.strictObject({ deal: v.strictObject(dealRow), stages: section(v.strictObject({ from: nullableText, to: text, pipeline: reference, at: time, exact: v.boolean() })), @@ -200,7 +206,7 @@ export const dealContext: v.GenericSchema = v.strictObject({ coverage, }) -/** A deal context's compact form, for a model's context. */ +/** A deal context's compact form, for a model's context. @experimental */ export const dealBrief: v.GenericSchema = v.strictObject({ ref: reference, kind: v.picklist(DEAL_KINDS), diff --git a/src/entities/knowledge-lists.ts b/src/entities/knowledge-lists.ts index 9e691e3ee..06c67e984 100644 --- a/src/entities/knowledge-lists.ts +++ b/src/entities/knowledge-lists.ts @@ -1,6 +1,7 @@ import * as v from "valibot" import { id, reference, text, time } from "./fields.js" +/** @experimental */ export const organization = v.strictObject({ id, ref: reference, @@ -9,6 +10,7 @@ export const organization = v.strictObject({ scope: v.picklist(["personal", "work"]), created_at: time, }) +/** @experimental */ export const project = v.strictObject({ id, ref: reference, @@ -20,6 +22,7 @@ export const project = v.strictObject({ scope: v.picklist(["personal", "work"]), created_at: time, }) +/** @experimental */ export const reminder = v.strictObject({ id, task: text, diff --git a/src/entities/list-results.ts b/src/entities/list-results.ts index 42f04c8c7..195b5fe64 100644 --- a/src/entities/list-results.ts +++ b/src/entities/list-results.ts @@ -115,6 +115,7 @@ export const scheduleHarness = v.strictObject({ path: v.nullable(text), }) +/** @experimental */ export const botTemplate = v.strictObject({ name: v.nullable(text), status: v.nullable(text), diff --git a/src/entities/listings.ts b/src/entities/listings.ts index 4e46270e9..8282992f6 100644 --- a/src/entities/listings.ts +++ b/src/entities/listings.ts @@ -15,7 +15,10 @@ const source = v.strictObject({ const person = v.strictObject({ ref: reference, name: v.nullable(text), kind: text }) -/** One document of any account: a Drive file, a notes folder's file, an added source, an import's document. */ +/** + * One document of any account: a Drive file, a notes folder's file, an added source, an import's document. + * @experimental + */ export const documentEntry = v.strictObject({ ref: reference, id, @@ -42,7 +45,7 @@ export const documentEntry = v.strictObject({ const linked = v.strictObject({ ref: reference, title: v.nullable(text), at: v.nullable(time), role: v.nullable(text) }) -/** One document with a part of its text, its tags, the people it names and the meetings it belongs to. */ +/** One document with a part of its text, its tags, the people it names and the meetings it belongs to. @experimental */ export const documentEntryDetails = v.strictObject({ ...documentEntry.entries, text: v.nullable(text), @@ -61,7 +64,7 @@ export const documentEntryDetails = v.strictObject({ events: v.array(linked), }) -/** One account holding documents, with its folders and how many documents each holds. */ +/** One account holding documents, with its folders and how many documents each holds. @experimental */ export const documentSource = v.strictObject({ ...source.entries, name: v.nullable(text), @@ -84,7 +87,10 @@ const participant = v.strictObject({ response: v.nullable(v.picklist(PARTICIPANT_RESPONSES)), }) -/** One real meeting, call or calendar event: a calendar's event and its Zoom or Meet record are one row. */ +/** + * One real meeting, call or calendar event: a calendar's event and its Zoom or Meet record are one row. + * @experimental + */ export const meetingEntry = v.strictObject({ /** `event:` when a calendar or a meeting service's record made an event of it, else `meeting:/`. */ ref: reference, @@ -132,7 +138,7 @@ export const meetingEntry = v.strictObject({ untrusted, }) -/** One meeting row with its transcript lines, summaries, findings batches and the calendar's text. */ +/** One meeting row with its transcript lines, summaries, findings batches and the calendar's text. @experimental */ export const meetingEntryDetails = v.strictObject({ ...meetingEntry.entries, description: v.nullable(text), @@ -180,6 +186,7 @@ export const meetingEntryDetails = v.strictObject({ /** * The listings' answers by entity name. Not in `ENTITIES`: that registry's inferred type is at the compiler's size * limit, so a CLI registers these as its own (memo's `entityFields`). + * @experimental */ export const LISTING_ENTITIES = { document_entry: documentEntry, diff --git a/src/entities/note.ts b/src/entities/note.ts index 806e8ec2e..ab3d22e8b 100644 --- a/src/entities/note.ts +++ b/src/entities/note.ts @@ -7,6 +7,7 @@ const link = { anchor: v.nullable(text), } +/** @experimental */ export const note = v.strictObject({ ref: reference, kind: v.optional(v.picklist(["note", "document"])), diff --git a/src/entities/store-records.ts b/src/entities/store-records.ts index e3e1d233f..01ee648c3 100644 --- a/src/entities/store-records.ts +++ b/src/entities/store-records.ts @@ -83,6 +83,7 @@ const problem = v.objectWithRest( { code: text, message: text, retryable: v.optional(v.boolean()), retry_after_ms: v.optional(v.number()) }, v.unknown(), ) +/** @experimental */ const progress = v.strictObject({ job: id, profile: text, diff --git a/src/errors/failures.ts b/src/errors/failures.ts index 2615cac90..bebfae22c 100644 --- a/src/errors/failures.ts +++ b/src/errors/failures.ts @@ -6,13 +6,14 @@ import { CliError, errorCodes } from "@wirecat/cli-base" * measured 2026-09-27: an ambiguous chat name from `pickChat` reached tg-cli's `run` as an unknown * failure, exit 1, and lost its list of candidates. A name and a code from the closed list * identify one in every install layout. + * @experimental */ export const isCliFailure = (value: unknown): value is CliError => value instanceof Error && value.name === "CliError" && (errorCodes as readonly string[]).includes((value as { code?: unknown }).code as string) -/** Commander's own errors, by the same rule: its `code` always starts with `commander.`. */ +/** Commander's own errors, by the same rule: its `code` always starts with `commander.`. @experimental */ export const isCommanderFailure = (value: unknown): value is Error & { code: string; exitCode: number } => { const { code, exitCode } = (value ?? {}) as { code?: unknown; exitCode?: unknown } return ( @@ -72,6 +73,7 @@ const wrapping = (error: CliError, original: unknown): CliError => { * `next` is the command line that says what to do, such as `tg store recover`, only where that command exists. * Only for the CLI's own store: a file the owner named goes through `damagedFile`. Any other failure is returned as * it came. + * @experimental */ export const storeDamaged = (error: unknown, next?: string): unknown => damageIn(error) diff --git a/src/errors/reasons.ts b/src/errors/reasons.ts index e7f6f5965..9bbce80b0 100644 --- a/src/errors/reasons.ts +++ b/src/errors/reasons.ts @@ -900,6 +900,7 @@ export const REASONS: ErrorReason[] = defineReasons([ /** * Detail keys an error from this package may carry, until each is registered on its own reason. Not `cause`: * that can hold a provider's or SQLite's raw text. + * @experimental */ export const DETAILS = [ "account", diff --git a/src/http/link-fetch.ts b/src/http/link-fetch.ts index 15de1b52c..b8753d7f8 100644 --- a/src/http/link-fetch.ts +++ b/src/http/link-fetch.ts @@ -8,6 +8,7 @@ const CREDENTIALS = ["authorization", "cookie", "proxy-authorization"] * another host (Yandex Disk's `downloader.disk.yandex.ru`, Notion's file store) and carries its own grant, so it goes * only to the hosts listed, over https, and never with the sign-in: a request carrying one is refused before it leaves. * `signIn` names a service's own sign-in headers (an API key's `X-Api-Key`) to refuse beside the standard ones. + * @experimental */ export const linkFetch = (options: HostFetchOptions & { signIn?: readonly string[] }): FetchLike => { const { signIn = [], ...rest } = options diff --git a/src/http/public-url.ts b/src/http/public-url.ts index 847e0fc33..ce1db81d7 100644 --- a/src/http/public-url.ts +++ b/src/http/public-url.ts @@ -5,6 +5,7 @@ const EXAMPLE = "--public-url https://.ts.net" /** * The tunnel's address a public listener is reached at, checked one way for every command that opens * one. `missing` says what needs it; `reaches` who calls through it, for the https refusal. + * @experimental */ export const publicUrlOf = ( given: string | undefined, @@ -44,7 +45,7 @@ export const publicUrlOf = ( return url } -/** A local port from `--port`, or the command's own default. */ +/** A local port from `--port`, or the command's own default. @experimental */ export const portOf = (given: string | undefined, fallback: number): number => { if (given === undefined) return fallback const port = Number(given) @@ -53,6 +54,9 @@ export const portOf = (given: string | undefined, fallback: number): number => { return port } -/** The connector address under a public address: `https://.ts.net/mcp`, or `…/tg/mcp` under a path. */ +/** + * The connector address under a public address: `https://.ts.net/mcp`, or `…/tg/mcp` under a path. + * @experimental + */ export const mcpUrlOf = (publicUrl: URL): URL => new URL(`${publicUrl.pathname.replace(/\/+$/, "")}/mcp`, publicUrl.origin) diff --git a/src/kit/contract.ts b/src/kit/contract.ts index b699c7389..b3a406faf 100644 --- a/src/kit/contract.ts +++ b/src/kit/contract.ts @@ -36,7 +36,7 @@ const serverReads = (adapter: MessengerAdapter): Reading | undefined => const NO_SERVER_READS = { skipped: "the adapter has no server reads (chats, history, around, contact)" } -/** Every method of the optional groups, which `capability` hands over or refuses. */ +/** Every method of the optional groups, which `capability` hands over or refuses. @experimental */ export const OPTIONAL_METHODS = [ "fetchCounters", ...SERVER_READS, diff --git a/src/kit/fake.ts b/src/kit/fake.ts index d0404df99..0c5a60f80 100644 --- a/src/kit/fake.ts +++ b/src/kit/fake.ts @@ -46,7 +46,7 @@ import { isId, pickChat, pickPerson } from "../resolve.js" import { uploadSize } from "../sends/upload.js" import { contractSeed, type Seed } from "./seed.js" -/** Every group of the port, over memory. */ +/** Every group of the port, over memory. @experimental */ export type FakeAdapter = MessengerCore & ServerReads & ChatReading & @@ -114,6 +114,7 @@ const withRules = (folder: Folder, { emoji, include, skip, exclude, pin }: Folde if (pin?.length) folder.pinnedChatIds = [...new Set([...(folder.pinnedChatIds ?? []), ...pin])] } +/** @experimental */ export const fakeAdapter = ( seed: Seed = contractSeed(), options: { feed?: boolean; listen?: boolean; listenHistory?: boolean; storedChats?: boolean } = {}, diff --git a/src/kit/search-recipes.ts b/src/kit/search-recipes.ts index 37e78ee30..61c244e6a 100644 --- a/src/kit/search-recipes.ts +++ b/src/kit/search-recipes.ts @@ -2,6 +2,7 @@ import { readFileSync } from "node:fs" import type { Chat, Message } from "../domain/models.js" import type { AccountKey, MessageStore } from "../store/store.js" +/** @experimental */ export interface SearchRecipes { chats: Pick[] messages: Pick[] @@ -15,6 +16,7 @@ export interface SearchRecipes { recipes: { title: string; query: string; ids: string[] }[] negative: { query: string; code: string; reason: string }[] } +/** @experimental */ export const searchRecipes: SearchRecipes = JSON.parse( readFileSync(new URL("../../docs/search/recipes.json", import.meta.url), "utf8"), ) diff --git a/src/kit/seed.ts b/src/kit/seed.ts index 472187453..3cadf3292 100644 --- a/src/kit/seed.ts +++ b/src/kit/seed.ts @@ -26,13 +26,14 @@ export type IdKind = "chat" | "message" | "person" /** An id for the `n`th thing of a kind; `time` is when a message was sent, for a messenger whose ids carry it. */ export type IdMaker = (kind: IdKind, n: number, time: Date) => Id +/** @experimental */ export const BUSY_PAGE = 3 const BUSY_MESSAGES = 10 -/** Ids that are not numbers, so no code may take them for one. */ +/** Ids that are not numbers, so no code may take them for one. @experimental */ export const wordIds: IdMaker = (kind, n) => `${kind}-${n}` -/** Whole numbers within 2^53, for a messenger whose store pages by id. */ +/** Whole numbers within 2^53, for a messenger whose store pages by id. @experimental */ export const digitIds: IdMaker = (kind, n) => String({ person: 100, chat: 200, message: 1000 }[kind] + n) const START = Date.parse("2026-09-01T09:00:00.000Z") diff --git a/src/mail/findings.ts b/src/mail/findings.ts index 77b050bdf..2d631c266 100644 --- a/src/mail/findings.ts +++ b/src/mail/findings.ts @@ -266,7 +266,7 @@ const VALUES: Partial> order_update: { status: ORDER_STATUSES }, } -/** One line per kind, `kind: needed fields; optional ones`, for `mail findings add --help`. */ +/** One line per kind, `kind: needed fields; optional ones`, for `mail findings add --help`. @experimental */ export const mailFindingFieldsHelp = (): string => MAIL_FINDING_KINDS.map((kind) => { const { needs, may } = MAIL_FINDING_FIELDS[kind] diff --git a/src/mcp/agent.ts b/src/mcp/agent.ts index 2e66524aa..a4ed8954a 100644 --- a/src/mcp/agent.ts +++ b/src/mcp/agent.ts @@ -34,6 +34,7 @@ export interface AgentProgram { commands: readonly CommandInfo[] } +/** @experimental */ export interface AgentContext { profile: string readOnly?: boolean @@ -58,6 +59,7 @@ export interface AgentContext { caller?: RunCaller } +/** @experimental */ export type AgentAnswer = { result: unknown } | { error: ErrorObject } export interface AgentTool { @@ -340,6 +342,7 @@ const argvOf = ( * apply, to the check before the run and to the command's own guard. With `connection`, the command borrows the * server's open connection and never opens one of its own. Which commands are offered is the catalogue's * decision (`toolsFromCommands`); this runs what it is handed, except a command that never returns. + * @experimental */ export const runCommandForAgent = async ( program: AgentProgram, diff --git a/src/mcp/all-profiles.ts b/src/mcp/all-profiles.ts index d318da848..1726441a2 100644 --- a/src/mcp/all-profiles.ts +++ b/src/mcp/all-profiles.ts @@ -12,13 +12,14 @@ const PROTOCOL = "2025-06-18" const START_MS = 30_000 export const CHILD_IDLE_MS = 10 * 60 * 1000 -/** How to start the one-profile server for a profile: `