@wirecat/wirecat 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +204 -0
- package/README.md +400 -2
- package/THIRD_PARTY_NOTICES +2 -0
- package/contracts/wirecat.json +4612 -0
- package/dist/actions/actions.js +269 -0
- package/dist/actions/command.js +102 -0
- package/dist/agents/command.js +17 -0
- package/dist/agents/log.js +23 -0
- package/dist/answer.js +100 -0
- package/dist/answers/command.js +128 -0
- package/dist/app.js +15 -0
- package/dist/author.js +109 -0
- package/dist/bin/wcat-wirecat.js +40 -0
- package/dist/bots/command.js +175 -0
- package/dist/bundle/auto-YETGUQ2J.js +43 -0
- package/dist/bundle/chunk-3ME37WWB.js +31 -0
- package/dist/bundle/chunk-4WI3FO7T.js +395 -0
- package/dist/bundle/chunk-7O7XM37N.js +2 -0
- package/dist/bundle/chunk-DWQQRBQV.js +51 -0
- package/dist/bundle/chunk-FOWR5KJS.js +72 -0
- package/dist/bundle/chunk-GGRL6DTE.js +120 -0
- package/dist/bundle/chunk-KNFSW562.js +312 -0
- package/dist/bundle/chunk-KPJVVFQF.js +416 -0
- package/dist/bundle/chunk-WMPDRWVF.js +222 -0
- package/dist/bundle/chunk-X5OK73GU.js +807 -0
- package/dist/bundle/chunk-ZC4PRE6C.js +38 -0
- package/dist/bundle/entry-S4DSYEAY.js +64 -0
- package/dist/bundle/failure-FALOD7QW.js +19 -0
- package/dist/bundle/from-memo-XVOLSUOM.js +314 -0
- package/dist/bundle/program-XSZSINBU.js +14994 -0
- package/dist/bundle/server-GQ4NZUDL.js +303 -0
- package/dist/bundle/update-2EH5KHTV.js +22 -0
- package/dist/bundle/wcat-wirecat.js +83 -0
- package/dist/config-command.js +39 -0
- package/dist/config-issues.js +15 -0
- package/dist/config.js +187 -0
- package/dist/context/command.js +162 -0
- package/dist/context/context.js +197 -0
- package/dist/contract-overrides/commands.js +81 -0
- package/dist/contract-overrides/mcp.js +241 -0
- package/dist/contract-overrides/meetings.js +344 -0
- package/dist/contract-overrides/search.js +508 -0
- package/dist/contract-overrides/skill.js +85 -0
- package/dist/contract-overrides.js +7 -0
- package/dist/digest/backfill.js +175 -0
- package/dist/digest/brief.js +189 -0
- package/dist/digest/catch-up-record.js +30 -0
- package/dist/digest/catch-up.js +86 -0
- package/dist/digest/command.js +110 -0
- package/dist/digest/digest-commands.js +327 -0
- package/dist/digest/digest.js +560 -0
- package/dist/digest/digests.js +213 -0
- package/dist/digest/history.js +202 -0
- package/dist/digest/input.js +30 -0
- package/dist/digest/known.js +28 -0
- package/dist/digest/sources.js +155 -0
- package/dist/digest/sync-health.js +158 -0
- package/dist/digest/task-proposals.js +67 -0
- package/dist/digest/tasks.js +145 -0
- package/dist/digest/text.js +49 -0
- package/dist/discovery/command.js +107 -0
- package/dist/doctor/command.js +167 -0
- package/dist/documents/command.js +107 -0
- package/dist/domain-lists/command.js +13 -0
- package/dist/events/command.js +35 -0
- package/dist/events/events.js +196 -0
- package/dist/examples.js +609 -0
- package/dist/facts/command.js +100 -0
- package/dist/facts/fact.js +54 -0
- package/dist/facts/facts.js +15 -0
- package/dist/failure.js +58 -0
- package/dist/finance/command.js +121 -0
- package/dist/finance/contracts-command.js +109 -0
- package/dist/finance/deal-text.js +34 -0
- package/dist/finance/deals-command.js +346 -0
- package/dist/finance/finance.js +129 -0
- package/dist/finance/lines-command.js +70 -0
- package/dist/finance/orders-command.js +94 -0
- package/dist/finance/products-command.js +98 -0
- package/dist/finance/subscriptions-command.js +152 -0
- package/dist/finance/transactions-command.js +136 -0
- package/dist/finance/wallets-command.js +105 -0
- package/dist/finance/written.js +36 -0
- package/dist/findings/command.js +102 -0
- package/dist/findings-input.js +23 -0
- package/dist/identity.js +20 -0
- package/dist/install/postinstall.js +47 -0
- package/dist/json-fields.js +48 -0
- package/dist/knowledge/business-text.js +19 -0
- package/dist/knowledge/command.js +435 -0
- package/dist/knowledge/document-context.js +33 -0
- package/dist/knowledge/key-documents.js +120 -0
- package/dist/knowledge/list-queries.js +20 -0
- package/dist/knowledge/meeting-projects-command.js +61 -0
- package/dist/knowledge/messenger-sync.js +253 -0
- package/dist/knowledge/money-text.js +16 -0
- package/dist/knowledge/notes-about.js +81 -0
- package/dist/knowledge/organization-delete-command.js +44 -0
- package/dist/knowledge/organization-text.js +27 -0
- package/dist/knowledge/project-actions-command.js +130 -0
- package/dist/knowledge/project-actions.js +104 -0
- package/dist/knowledge/project-activity-command.js +70 -0
- package/dist/knowledge/project-context.js +101 -0
- package/dist/knowledge/project-findings.js +41 -0
- package/dist/knowledge/project-gather-command.js +100 -0
- package/dist/knowledge/project-status-command.js +129 -0
- package/dist/knowledge/project-transfer-command.js +58 -0
- package/dist/knowledge/project-transfer.js +107 -0
- package/dist/knowledge/relationships-scan.js +116 -0
- package/dist/knowledge/relationships.js +115 -0
- package/dist/knowledge/roles-command.js +67 -0
- package/dist/mail/command.js +20 -0
- package/dist/mail/findings-command.js +143 -0
- package/dist/mail/findings-duplicates.js +159 -0
- package/dist/mail/messages-command.js +77 -0
- package/dist/mail/review-command.js +59 -0
- package/dist/mail/subscriptions-command.js +84 -0
- package/dist/mcp/catalogue.js +159 -0
- package/dist/mcp/command.js +125 -0
- package/dist/mcp/granted.js +18 -0
- package/dist/mcp/permissions.js +61 -0
- package/dist/mcp/server.js +128 -0
- package/dist/meetings/command.js +31 -0
- package/dist/meetings/list-command.js +59 -0
- package/dist/meetings/preparation-command.js +42 -0
- package/dist/meetings/preparation-text.js +44 -0
- package/dist/meetings/preparation.js +50 -0
- package/dist/meetings/read.js +32 -0
- package/dist/memories/command.js +105 -0
- package/dist/memories/memories.js +17 -0
- package/dist/memories/memory.js +89 -0
- package/dist/memories/sources.js +111 -0
- package/dist/mentions/command.js +91 -0
- package/dist/migrate/check.js +48 -0
- package/dist/migrate/from-memo.js +345 -0
- package/dist/migrate/skill.js +35 -0
- package/dist/models/command.js +19 -0
- package/dist/options.js +35 -0
- package/dist/output.js +17 -0
- package/dist/page.js +14 -0
- package/dist/people/command.js +144 -0
- package/dist/people/delete-command.js +53 -0
- package/dist/people/doubts-command.js +81 -0
- package/dist/people/identities-command.js +188 -0
- package/dist/people/identity.js +42 -0
- package/dist/people/owner.js +14 -0
- package/dist/people/proposal-rows.js +70 -0
- package/dist/people/proposals-command.js +248 -0
- package/dist/people/review-context.js +108 -0
- package/dist/people/subject.js +19 -0
- package/dist/program.js +875 -0
- package/dist/read-only.js +51 -0
- package/dist/reasons.js +368 -0
- package/dist/records/import.js +135 -0
- package/dist/records/input.js +210 -0
- package/dist/records/mapping.js +80 -0
- package/dist/records/record-commands.js +125 -0
- package/dist/records/sources.js +73 -0
- package/dist/refs.js +28 -0
- package/dist/review/command.js +171 -0
- package/dist/review/kinds.js +44 -0
- package/dist/review/review.js +299 -0
- package/dist/review/status.js +93 -0
- package/dist/rows.js +219 -0
- package/dist/run/auto.js +237 -0
- package/dist/run/entry.js +62 -0
- package/dist/run/files.js +51 -0
- package/dist/run/import.js +253 -0
- package/dist/run/lock.js +20 -0
- package/dist/save-help.js +3 -0
- package/dist/schedule/command.js +58 -0
- package/dist/schedule/mail-triage-input.js +152 -0
- package/dist/schedule/task-triage-input.js +152 -0
- package/dist/search/answers.js +176 -0
- package/dist/search/command.js +257 -0
- package/dist/search/denied.js +9 -0
- package/dist/search/embed.js +126 -0
- package/dist/search/hits.js +4 -0
- package/dist/search/lane-gates.js +76 -0
- package/dist/search/notes-text.js +18 -0
- package/dist/search/people.js +88 -0
- package/dist/search/search.js +306 -0
- package/dist/show/command.js +179 -0
- package/dist/store/crm-viewer.js +102 -0
- package/dist/store/group.js +112 -0
- package/dist/store/groups-command.js +136 -0
- package/dist/store/guard.js +94 -0
- package/dist/store/held.js +21 -0
- package/dist/store/info-command.js +37 -0
- package/dist/store/scope.js +53 -0
- package/dist/store/source-list.js +222 -0
- package/dist/store/source-target.js +28 -0
- package/dist/tags/command.js +176 -0
- package/dist/tasks/command.js +174 -0
- package/dist/tasks/context.js +74 -0
- package/dist/tasks/list.js +199 -0
- package/dist/tasks/proposal-duplicates.js +70 -0
- package/dist/tasks/relations-command.js +28 -0
- package/dist/tasks/shared.js +105 -0
- package/dist/tasks/tasks.js +197 -0
- package/dist/templates/command.js +18 -0
- package/dist/terminal.js +23 -0
- package/dist/update.js +35 -0
- package/dist/version.js +2 -0
- package/dist/vocabulary/command.js +103 -0
- package/dist/vocabulary/inspect.js +23 -0
- package/dist/vocabulary/inspection.js +18 -0
- package/dist/vocabulary/list.js +18 -0
- package/dist/vocabulary/project.js +19 -0
- package/dist/wcat.js +3 -0
- package/install/postinstall.mjs +9 -0
- package/package.json +89 -4
- package/scenarios/decision-trail.md +21 -0
- package/scenarios/person-brief.md +35 -0
- package/scenarios/prepare-meeting.md +17 -0
- package/scenarios/project-state.md +26 -0
- package/scenarios/set-up.md +18 -0
- package/scenarios/start-the-day.md +19 -0
- package/skills/mail-triage/SKILL.md +208 -0
- package/skills/morning-digest/SKILL.md +147 -0
- package/skills/task-triage/SKILL.md +79 -0
- package/skills/wcat/SKILL.md +65 -0
- package/skills/wcat/topics/mail.md +32 -0
- package/skills/wcat/topics/mcp.md +22 -0
- package/skills/wcat/topics/meetings.md +37 -0
- package/skills/wcat/topics/money.md +52 -0
- package/skills/wcat/topics/projects.md +54 -0
- package/skills/wcat/topics/proposals.md +113 -0
- package/skills/wcat/topics/search.md +85 -0
- package/skills/wcat/topics/vocabulary.md +8 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const preparationText = (item) => {
|
|
2
|
+
const lines = [
|
|
3
|
+
`${item.series?.title ?? item.upcoming.meeting_id} — stored meeting preparation`,
|
|
4
|
+
"Next meeting: unverified; no provider calendar was read.",
|
|
5
|
+
`History: ${item.history_window.after} to ${item.history_window.before} (exclusive)`,
|
|
6
|
+
`Archive completeness: ${item.coverage.archive_completeness}`,
|
|
7
|
+
];
|
|
8
|
+
for (const entry of [...item.meetings, ...item.related.items]) {
|
|
9
|
+
lines.push("", `${entry.ref} ${entry.meeting.started_at ?? "undated"} ${entry.meeting.title ?? "untitled"}`);
|
|
10
|
+
for (const cue of entry.evidence.items)
|
|
11
|
+
lines.push(` ${cue.ref} ${cue.speaker_name ?? "unknown speaker"}: ${cue.text}`);
|
|
12
|
+
if (entry.evidence.coverage.has_more)
|
|
13
|
+
lines.push(" More transcript evidence available; use --json for references.");
|
|
14
|
+
}
|
|
15
|
+
if (!item.meetings.length)
|
|
16
|
+
lines.push("No stored occurrences found in this series and history window.");
|
|
17
|
+
for (const fact of item.knowledge?.items ?? [])
|
|
18
|
+
lines.push(`Fact ${fact.ref}: ${fact.statement}`);
|
|
19
|
+
for (const note of item.notes?.items ?? [])
|
|
20
|
+
lines.push(`Note ${note.ref}: ${note.text}`);
|
|
21
|
+
if (item.project_evidence)
|
|
22
|
+
lines.push(`Project word evidence: ${item.project_evidence.project}; use --json to inspect candidates.`);
|
|
23
|
+
if (item.communications) {
|
|
24
|
+
lines.push("", `Communications: literal words “${item.communications.coverage.query}”`);
|
|
25
|
+
for (const source of item.communications.coverage.sources) {
|
|
26
|
+
lines.push(` ${source.selection_id}: ${source.state}; index ${source.index}; completeness ${source.completeness}`);
|
|
27
|
+
if (source.has_more)
|
|
28
|
+
lines.push(" More matches available; use --json for the source cursor.");
|
|
29
|
+
if (source.restart_required)
|
|
30
|
+
lines.push(" Some matches were omitted; restart with a larger output budget.");
|
|
31
|
+
}
|
|
32
|
+
for (const excerpt of item.communications.items)
|
|
33
|
+
lines.push(`${excerpt.ref} ${excerpt.at}: ${excerpt.text}`);
|
|
34
|
+
}
|
|
35
|
+
else
|
|
36
|
+
lines.push("Communications: not queried; select --context-source and --context-query to include them.");
|
|
37
|
+
if (item.coverage.history_has_more)
|
|
38
|
+
lines.push("More series history available; raise --meetings.");
|
|
39
|
+
if (item.coverage.output_limited)
|
|
40
|
+
lines.push("Output limited; raise --bytes to include more evidence.");
|
|
41
|
+
lines.push("Use --json for linked people, projects, facts, notes, tasks and full coverage.");
|
|
42
|
+
return lines.join("\n");
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=preparation-text.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { createMeetingPreparationService, createUpcomingMeetingReader, entriesOfList, } from "@wirecat/cli-core";
|
|
3
|
+
import { accountName, oneAccountOf } from "../store/source-list.js";
|
|
4
|
+
const communicationSource = async (store, env, id) => {
|
|
5
|
+
const dot = id.indexOf(".");
|
|
6
|
+
if (dot < 1 || dot === id.length - 1)
|
|
7
|
+
throw new CliError("validation_error", "context source needs app.profile or email.mailbox, such as tg.personal", {
|
|
8
|
+
param: "communications.sources",
|
|
9
|
+
});
|
|
10
|
+
const key = await oneAccountOf(store, env, `${id.slice(0, dot)}:${id.slice(dot + 1)}`, "--context-source");
|
|
11
|
+
const held = await store.accounts.storedAccount(key);
|
|
12
|
+
const listed = entriesOfList(accountName(key), {
|
|
13
|
+
held: [held],
|
|
14
|
+
profiles: {},
|
|
15
|
+
groups: {},
|
|
16
|
+
running: { provider: "email", command: "wcat" },
|
|
17
|
+
})[0]?.accounts[0];
|
|
18
|
+
const kind = listed?.kind === "messages" ? "message" : listed?.kind === "mail" ? "mail" : undefined;
|
|
19
|
+
if (kind === undefined)
|
|
20
|
+
throw new CliError("validation_error", `${id}: select one stored messenger profile or mailbox`, {
|
|
21
|
+
param: "communications.sources",
|
|
22
|
+
});
|
|
23
|
+
return { id, source: { ...key, accountId: held.id, kind } };
|
|
24
|
+
};
|
|
25
|
+
export const prepareStoredMeeting = async (store, env, source, seriesId, request) => {
|
|
26
|
+
const key = await oneAccountOf(store, env, source);
|
|
27
|
+
const held = await store.accounts.storedAccount(key);
|
|
28
|
+
const selections = request.communications
|
|
29
|
+
? await Promise.all(request.communications.sources.map(({ id }) => communicationSource(store, env, id)))
|
|
30
|
+
: undefined;
|
|
31
|
+
if (selections && !store.contextEvidence)
|
|
32
|
+
throw new CliError("configuration_error", "Stored communications are unavailable in this store");
|
|
33
|
+
const service = createMeetingPreparationService(key, held.id, {
|
|
34
|
+
meetings: store.meetings,
|
|
35
|
+
upcoming: createUpcomingMeetingReader(key, {
|
|
36
|
+
read: async (meetingId) => ({
|
|
37
|
+
meetingId,
|
|
38
|
+
kind: "unknown",
|
|
39
|
+
timezone: null,
|
|
40
|
+
occurrences: [],
|
|
41
|
+
complete: false,
|
|
42
|
+
missing: ["schedule-details", "occurrence-details"],
|
|
43
|
+
}),
|
|
44
|
+
}),
|
|
45
|
+
projectDiscovery: { vocabulary: store.knowledge, search: store.meetings },
|
|
46
|
+
...(selections && store.contextEvidence ? { communications: { selections, reader: store.contextEvidence } } : {}),
|
|
47
|
+
});
|
|
48
|
+
return service.prepare(seriesId, request);
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=preparation.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { meetingHitsList, meetingSearchMeta, readMeetingPassage, searchMeetingHits, } from "@wirecat/cli-core";
|
|
2
|
+
import { accountName, oneAccountOf } from "../store/source-list.js";
|
|
3
|
+
const account = async (store, env, source) => {
|
|
4
|
+
const key = await oneAccountOf(store, env, source);
|
|
5
|
+
return { key, held: await store.accounts.storedAccount(key) };
|
|
6
|
+
};
|
|
7
|
+
export const searchStoredMeetings = async (store, env, source, query, request, args, flags) => {
|
|
8
|
+
const { key, held } = await account(store, env, source);
|
|
9
|
+
const found = await searchMeetingHits(store, query, { ...request, accountId: held.id });
|
|
10
|
+
const limit = request.limit;
|
|
11
|
+
const body = meetingHitsList(found, limit, "search meetings", {
|
|
12
|
+
...args,
|
|
13
|
+
limit,
|
|
14
|
+
source: accountName(key),
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
...body,
|
|
18
|
+
missing: [
|
|
19
|
+
...(body.missing ?? []),
|
|
20
|
+
{
|
|
21
|
+
field: "archive_completeness",
|
|
22
|
+
why: "Only stored, currently indexed meeting revisions were searched; archive and index completeness are unknown.",
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
meta: { accounts: [accountName(key)], ...meetingSearchMeta(flags) },
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export const readStoredMeetingPassage = async (store, env, source, reference, request) => {
|
|
29
|
+
const { held } = await account(store, env, source);
|
|
30
|
+
return readMeetingPassage(store.meetings, held.id, reference, request);
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=read.js.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { annotate } from "@wirecat/cli-base/commands";
|
|
2
|
+
import { LOCAL_READ, LOCAL_WRITE, MEMORY_KINDS, MEMORY_SCOPES, withQuery, } from "@wirecat/cli-core";
|
|
3
|
+
import { answers, itemAnswer } from "../answer.js";
|
|
4
|
+
import { byOption, deciderOf, reasonOption, whoRuns } from "../author.js";
|
|
5
|
+
import { oneOf, positive } from "../options.js";
|
|
6
|
+
import { decideOne } from "../review/review.js";
|
|
7
|
+
import { sourcesIn, stripped } from "../store/guard.js";
|
|
8
|
+
import { canonicalProject } from "../vocabulary/project.js";
|
|
9
|
+
import { addMemory } from "./memories.js";
|
|
10
|
+
import { listMemories, MEMORY_QUERY, memoryItem, searchMemories } from "./memory.js";
|
|
11
|
+
import { challengeCommand, explainQuote, quotedEvidence, quoteOption, sourceCheckCommand } from "./sources.js";
|
|
12
|
+
export const memoriesCommand = (program, streams, env) => {
|
|
13
|
+
const { run } = answers(program, streams, env);
|
|
14
|
+
const memories = program
|
|
15
|
+
.command("memories")
|
|
16
|
+
.description("what agents and you concluded, with evidence; you confirm an agent's");
|
|
17
|
+
quoteOption(byOption(annotate(memories.command("add"), {
|
|
18
|
+
effects: LOCAL_WRITE,
|
|
19
|
+
output: { entity: "memory" },
|
|
20
|
+
literal_after_dashes: true,
|
|
21
|
+
}).description("write a memory; an agent's waits as proposed until you confirm it")))
|
|
22
|
+
.argument("<text...>", "what is true, in a sentence or two")
|
|
23
|
+
.requiredOption("--kind <kind>", MEMORY_KINDS.join(", "), oneOf(MEMORY_KINDS))
|
|
24
|
+
.requiredOption("--scope <scope>", MEMORY_SCOPES.join(" or "), oneOf(MEMORY_SCOPES))
|
|
25
|
+
.requiredOption("--evidence <ref...>", "what shows it: msg:, note:, meeting:, person: or another reference")
|
|
26
|
+
.option("--subject <ref>", "what it is about, as a reference")
|
|
27
|
+
.option("--project <project>", "the project it belongs to: its key or project:<id>")
|
|
28
|
+
.option("--supersedes <ref>", "the memory this one corrects, superseded once this one is confirmed; an agent's waits until you confirm it")
|
|
29
|
+
.option("--json", "print JSON; --json=id,title keeps only those fields")
|
|
30
|
+
.action((words, options, command) => {
|
|
31
|
+
const evidence = quotedEvidence(options.evidence, options.quote);
|
|
32
|
+
const by = whoRuns(command, env, { asOwner: options.asOwner, question: "record this memory as yours?" });
|
|
33
|
+
return run(options.json, async (store) => itemAnswer(memoryItem(await addMemory(store, {
|
|
34
|
+
text: words.join(" "),
|
|
35
|
+
kind: options.kind,
|
|
36
|
+
scope: options.scope,
|
|
37
|
+
evidence,
|
|
38
|
+
...(options.subject === undefined ? {} : { subject: options.subject }),
|
|
39
|
+
...(options.project === undefined ? {} : { project: options.project }),
|
|
40
|
+
...(options.supersedes === undefined ? {} : { supersedes: options.supersedes }),
|
|
41
|
+
}, await by).catch(explainQuote))));
|
|
42
|
+
});
|
|
43
|
+
withQuery(annotate(memories.command("list"), { effects: LOCAL_READ }).description("memories, newest first"), MEMORY_QUERY)
|
|
44
|
+
.option("--limit <n>", "most memories on a page, up to 500", positive, 100)
|
|
45
|
+
.option("--page <n>", "which page, from 1", positive, 1)
|
|
46
|
+
.option("--json", "print JSON; --json=id,title keeps only those fields")
|
|
47
|
+
.action((words, { json, limit, page }) => run(json, async (store) => stripped(store, env, await listMemories(store, words, limit, page))));
|
|
48
|
+
annotate(memories.command("show"), { effects: LOCAL_READ, output: { entity: "memory" } })
|
|
49
|
+
.description("one memory with its evidence")
|
|
50
|
+
.argument("<ref>", "memory:<id>")
|
|
51
|
+
.option("--sources", "read each piece of evidence back: who, when, a short excerpt, and whether it is gone")
|
|
52
|
+
.option("--json", "print JSON; --json=id,title keeps only those fields")
|
|
53
|
+
.action((ref, options) => run(options.json, async (store) => itemAnswer(await stripped(store, env, {
|
|
54
|
+
...memoryItem(await store.memories.get(ref)),
|
|
55
|
+
...(options.sources ? await sourcesIn(store, env, await store.memories.sources(ref)) : {}),
|
|
56
|
+
}))));
|
|
57
|
+
annotate(memories.command("update"), { effects: LOCAL_WRITE, output: { entity: "memory" } })
|
|
58
|
+
.description("move a memory to another project, or to none")
|
|
59
|
+
.argument("<ref>", "memory:<id>")
|
|
60
|
+
.requiredOption("--project <project>", "the project's key or project:<id>; none takes it out of its project")
|
|
61
|
+
.option("--json", "print JSON; --json=id,title keeps only those fields")
|
|
62
|
+
.action((ref, options) => run(options.json, async (store) => itemAnswer(memoryItem(await store.memories.update(ref, {
|
|
63
|
+
project: options.project === "none" ? null : await canonicalProject(store, options.project),
|
|
64
|
+
})))));
|
|
65
|
+
const decide = (name, description, act) => reasonOption(byOption(annotate(memories.command(name), {
|
|
66
|
+
effects: LOCAL_WRITE,
|
|
67
|
+
...(name === "remove" ? {} : { output: { entity: "memory" } }),
|
|
68
|
+
}))
|
|
69
|
+
.description(description)
|
|
70
|
+
.argument("<ref>", "memory:<id>")
|
|
71
|
+
.option("--json", "print JSON; --json=id,title keeps only those fields")).action(async (ref, options, command) => {
|
|
72
|
+
await run(options.json, async (store) => {
|
|
73
|
+
// An unknown ref is not_found for anyone, before asking who decides.
|
|
74
|
+
await store.memories.get(ref);
|
|
75
|
+
const by = await deciderOf(command, env, { ...options, question: `${name} ${ref} as you, the owner?` });
|
|
76
|
+
const done = await act(store, ref, by);
|
|
77
|
+
return itemAnswer(name === "remove" ? done : memoryItem(done));
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
// A proposed memory is decided through the review registry; a confirmed one is checked again or marked stale.
|
|
81
|
+
const decided = async (store, ref, by, confirm) => {
|
|
82
|
+
if ((await store.memories.get(ref)).status !== "proposed")
|
|
83
|
+
return confirm ? store.memories.confirm(ref, by) : store.memories.markStale(ref, by);
|
|
84
|
+
await decideOne(store, env, ref, { confirm, by });
|
|
85
|
+
return store.memories.get(ref);
|
|
86
|
+
};
|
|
87
|
+
decide("confirm", "stand behind a memory: its evidence was checked now", (store, ref, by) => decided(store, ref, by, true));
|
|
88
|
+
decide("invalidate", "mark a memory whose evidence no longer holds", (store, ref, by) => decided(store, ref, by, false));
|
|
89
|
+
decide("remove", "forget a memory: erase its text, its links to sources and its search entry", (store, ref, by) => store.memories.remove(ref, by)).addHelpText("after", `\n${FORGET_HELP}`);
|
|
90
|
+
sourceCheckCommand(memories, streams, env);
|
|
91
|
+
challengeCommand(memories, "memory", streams, env);
|
|
92
|
+
};
|
|
93
|
+
/** What Forget leaves behind, said where the owner decides (NEED-169). */
|
|
94
|
+
export const FORGET_HELP = "The messages, notes and meetings it cites stay. A store backup made before keeps it, until that backup is " +
|
|
95
|
+
"deleted. To keep a record of the mistake, use invalidate, or add the right one with --supersedes instead.";
|
|
96
|
+
export const searchMemoriesCommand = (search, streams, env) => {
|
|
97
|
+
const { run } = answers(search, streams, env);
|
|
98
|
+
annotate(search.command("memories"), { effects: LOCAL_READ, output: { entity: "memory" } })
|
|
99
|
+
.description("memories holding every word, best first")
|
|
100
|
+
.argument("<query...>", "the words to find; scope:personal or scope:work narrows them")
|
|
101
|
+
.option("--limit <n>", "most memories, up to 500", positive, 20)
|
|
102
|
+
.option("--json", "print JSON; --json=id,title keeps only those fields")
|
|
103
|
+
.action((words, options) => run(options.json, (store) => searchMemories(store, words, options.limit)));
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { canonicalProject } from "../vocabulary/project.js";
|
|
2
|
+
/**
|
|
3
|
+
* The owner stands behind what they write; an agent's memory waits as `proposed` until the owner confirms it. An
|
|
4
|
+
* agent's correction waits too: the memory it corrects stays as it is until the owner confirms the correction.
|
|
5
|
+
*/
|
|
6
|
+
export const addMemory = async (store, memory, by) => store.memories.add({
|
|
7
|
+
kind: memory.kind,
|
|
8
|
+
body: memory.text,
|
|
9
|
+
scope: memory.scope,
|
|
10
|
+
evidence: memory.evidence,
|
|
11
|
+
author: by,
|
|
12
|
+
status: by === "owner" ? "confirmed" : "proposed",
|
|
13
|
+
...(memory.subject === undefined ? {} : { subject: memory.subject }),
|
|
14
|
+
...(memory.project === undefined ? {} : { project: await canonicalProject(store, memory.project) }),
|
|
15
|
+
...(memory.supersedes === undefined ? {} : { supersedes: memory.supersedes }),
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=memories.js.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { parseLucene, queryError } from "@wirecat/cli-base/query";
|
|
2
|
+
import { LIST_QUERY_GUIDE, MEMORY_KINDS, MEMORY_SCOPES, MEMORY_STATUSES, plainQuery, queryTerms, termField, typedQuery, } from "@wirecat/cli-core";
|
|
3
|
+
import { pageOf } from "../page.js";
|
|
4
|
+
import { canonicalProject } from "../vocabulary/project.js";
|
|
5
|
+
export const MEMORY_QUERY = {
|
|
6
|
+
entity: "memory",
|
|
7
|
+
backend: "native",
|
|
8
|
+
fields: [
|
|
9
|
+
termField("kind", "enum", "kind:preference", { values: MEMORY_KINDS }),
|
|
10
|
+
termField("status", "enum", "status:proposed", { values: MEMORY_STATUSES }),
|
|
11
|
+
termField("scope", "enum", "scope:work", { values: MEMORY_SCOPES }),
|
|
12
|
+
termField("subject", "ref", 'subject:"person:42"'),
|
|
13
|
+
termField("project", "kw", "project:SYH"),
|
|
14
|
+
],
|
|
15
|
+
};
|
|
16
|
+
/** A memory under cli-core's `memory` entity names. */
|
|
17
|
+
export const memoryItem = ({ body, ...memory }) => ({
|
|
18
|
+
ref: memory.ref,
|
|
19
|
+
id: memory.id,
|
|
20
|
+
kind: memory.kind,
|
|
21
|
+
text: body,
|
|
22
|
+
subject: memory.subject,
|
|
23
|
+
subjectName: memory.subjectName,
|
|
24
|
+
subjectIsOwner: memory.subjectIsOwner,
|
|
25
|
+
project: memory.project,
|
|
26
|
+
projectName: memory.projectName,
|
|
27
|
+
author: memory.author,
|
|
28
|
+
model: memory.model,
|
|
29
|
+
confidence: memory.confidence,
|
|
30
|
+
status: memory.status,
|
|
31
|
+
scope: memory.scope,
|
|
32
|
+
supersedes: memory.supersedes,
|
|
33
|
+
evidence: memory.evidence,
|
|
34
|
+
lastVerifiedAt: memory.lastVerifiedAt,
|
|
35
|
+
sourceReview: memory.sourceReview,
|
|
36
|
+
createdAt: memory.createdAt,
|
|
37
|
+
updatedAt: memory.updatedAt,
|
|
38
|
+
});
|
|
39
|
+
/** Memories the store filters by the query's terms; CLI and MCP list through it. */
|
|
40
|
+
export const listMemories = async (store, query, limit, page) => {
|
|
41
|
+
const terms = queryTerms(query, MEMORY_QUERY, "memories list");
|
|
42
|
+
const project = terms.get("project");
|
|
43
|
+
const filters = {
|
|
44
|
+
...(terms.has("kind") ? { kind: terms.get("kind") } : {}),
|
|
45
|
+
...(terms.has("status") ? { status: terms.get("status") } : {}),
|
|
46
|
+
...(terms.has("scope") ? { scope: terms.get("scope") } : {}),
|
|
47
|
+
...(terms.has("subject") ? { subject: terms.get("subject") } : {}),
|
|
48
|
+
...(project === undefined ? {} : { project: await canonicalProject(store, project) }),
|
|
49
|
+
};
|
|
50
|
+
return pageOf("memories list", limit, (most, offset) => store.memories.list({ ...filters, limit: most, offset }), {
|
|
51
|
+
page,
|
|
52
|
+
args: { query: typedQuery(query) },
|
|
53
|
+
shape: (rows) => rows.map(memoryItem),
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
const SEARCH = { command: "search memories", guide: LIST_QUERY_GUIDE };
|
|
57
|
+
const MEMORY_FIELDS = new Set(["text", ...MEMORY_QUERY.fields.map(({ name }) => name)]);
|
|
58
|
+
/**
|
|
59
|
+
* The store matches every word and narrows by scope in SQL, so the query is words and at most one `scope:`, all
|
|
60
|
+
* joined by AND; anything the store cannot ask is refused rather than filtered afterwards.
|
|
61
|
+
*/
|
|
62
|
+
export const searchMemories = (store, query, limit) => {
|
|
63
|
+
const { root } = parseLucene(plainQuery(typedQuery(query), MEMORY_FIELDS), { ...SEARCH, defaultField: "text" });
|
|
64
|
+
const clauses = [];
|
|
65
|
+
if (root.kind === "predicate")
|
|
66
|
+
clauses.push(root);
|
|
67
|
+
else
|
|
68
|
+
for (const { occur, node } of root.clauses) {
|
|
69
|
+
if (occur !== "must" || node.kind !== "predicate")
|
|
70
|
+
queryError("query.unsupported-operator", node.span, "join words and scope: with AND only", SEARCH);
|
|
71
|
+
clauses.push(node);
|
|
72
|
+
}
|
|
73
|
+
const words = [];
|
|
74
|
+
let scope;
|
|
75
|
+
for (const term of clauses) {
|
|
76
|
+
if (term.field === "text" && (term.operator === "term" || term.operator === "phrase"))
|
|
77
|
+
words.push(term.value);
|
|
78
|
+
else if (term.field === "scope" && term.operator === "term" && scope === undefined) {
|
|
79
|
+
const value = term.value.toLowerCase();
|
|
80
|
+
if (!MEMORY_SCOPES.includes(value))
|
|
81
|
+
queryError("query.invalid-value", term.span, `scope is ${MEMORY_SCOPES.join(" or ")}`, SEARCH);
|
|
82
|
+
scope = value;
|
|
83
|
+
}
|
|
84
|
+
else
|
|
85
|
+
queryError("query.unsupported-field", term.span, "words, and scope:personal or scope:work once", SEARCH);
|
|
86
|
+
}
|
|
87
|
+
return pageOf("search memories", limit, (most) => store.memories.search(words.join(" "), { limit: most, ...(scope === undefined ? {} : { scope }) }), { fallback: 20, cap: 200, shape: (rows) => rows.map(memoryItem) });
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { CliError, isCliError } from "@wirecat/cli-base";
|
|
2
|
+
import { annotate } from "@wirecat/cli-base/commands";
|
|
3
|
+
import { answerEntity, LOCAL_WRITE } from "@wirecat/cli-core";
|
|
4
|
+
import * as v from "valibot";
|
|
5
|
+
import { answers, itemAnswer, withStore } from "../answer.js";
|
|
6
|
+
import { byOption, whoRuns } from "../author.js";
|
|
7
|
+
import { sinceOf } from "../digest/command.js";
|
|
8
|
+
import { positive } from "../options.js";
|
|
9
|
+
import { REVIEW_SOURCES, reviewItemOf } from "../review/review.js";
|
|
10
|
+
export const QUOTE_HELP = "the words an --evidence reference says that this rests on, as <ref>=<words>, one per reference. A later check " +
|
|
11
|
+
"raises nothing while the source still says them";
|
|
12
|
+
export const quoteOption = (command) => command.option("--quote <ref=words...>", QUOTE_HELP);
|
|
13
|
+
/**
|
|
14
|
+
* Pairs each `--quote` with its `--evidence` reference. The reference is matched as a prefix, longest first, because a
|
|
15
|
+
* reference or a quote may itself hold `=`.
|
|
16
|
+
*/
|
|
17
|
+
export const quotedEvidence = (evidence, quotes = []) => {
|
|
18
|
+
const longestFirst = [...evidence].sort((a, b) => b.length - a.length);
|
|
19
|
+
const quoteOf = new Map();
|
|
20
|
+
for (const given of quotes) {
|
|
21
|
+
const ref = longestFirst.find((one) => given.startsWith(`${one}=`));
|
|
22
|
+
const words = ref === undefined ? "" : given.slice(ref.length + 1).trim();
|
|
23
|
+
if (ref === undefined || !words)
|
|
24
|
+
throw new CliError("validation_error", `--quote ${given.slice(0, 60)} names none of the --evidence references; write it as <ref>=<the words>`, { reason: "evidence.quote-unmatched", param: "quote" });
|
|
25
|
+
if (quoteOf.has(ref))
|
|
26
|
+
throw new CliError("validation_error", `${ref} has two --quote values; give one quote per reference`, {
|
|
27
|
+
reason: "evidence.quote-unmatched",
|
|
28
|
+
param: "quote",
|
|
29
|
+
});
|
|
30
|
+
quoteOf.set(ref, words);
|
|
31
|
+
}
|
|
32
|
+
return evidence.map((ref) => {
|
|
33
|
+
const quote = quoteOf.get(ref);
|
|
34
|
+
return quote === undefined ? ref : { ref, quote };
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
/** The store's refusal names the reference; the reader also needs what to do about it. */
|
|
38
|
+
export const explainQuote = (error) => {
|
|
39
|
+
if (isCliError(error) && error.details.reason === "evidence.quote-not-found")
|
|
40
|
+
throw new CliError("validation_error", `${error.message}: quote the words exactly as the source has them (wcat show <ref> reads it), or leave --quote out`, { reason: "evidence.quote-not-found", param: "quote" });
|
|
41
|
+
throw error;
|
|
42
|
+
};
|
|
43
|
+
export const SOURCE_CHECK = v.strictObject({
|
|
44
|
+
checked: v.number(),
|
|
45
|
+
baselined: v.number(),
|
|
46
|
+
raised: v.number(),
|
|
47
|
+
refreshed: v.number(),
|
|
48
|
+
closed: v.number(),
|
|
49
|
+
changed_refs: v.array(v.string()),
|
|
50
|
+
});
|
|
51
|
+
export const sourceCheckText = (check) => [
|
|
52
|
+
`${check.checked} sources checked: ${check.raised} raised for review, ${check.refreshed} changed but still say ` +
|
|
53
|
+
`the quoted words, ${check.baselined} signed for the first time, ${check.closed} reviews closed`,
|
|
54
|
+
...(check.raised > 0 ? [`next: ${REVIEW_SOURCES}`] : []),
|
|
55
|
+
...(check.changedRefs.length > 0
|
|
56
|
+
? [`${check.changedRefs.length} changed sources no findings batch reads yet: ${check.changedRefs.join(" ")}`]
|
|
57
|
+
: []),
|
|
58
|
+
].join("\n");
|
|
59
|
+
/** `memories check`: anyone may run it, since it only signs links and opens reviews for the owner. */
|
|
60
|
+
export const sourceCheckCommand = (memories, streams, env) => {
|
|
61
|
+
const { print } = answers(memories, streams, env);
|
|
62
|
+
answerEntity(annotate(memories.command("check"), { effects: LOCAL_WRITE }), "source_check", SOURCE_CHECK)
|
|
63
|
+
.summary("look again at what memories and facts cite; raise a review where it changed")
|
|
64
|
+
.description("compare what memories and facts cite with the sources now, least recently checked first: a changed source " +
|
|
65
|
+
"that still says the quoted words is signed again; one that changed, went or was replaced raises a " +
|
|
66
|
+
"memory_source_review for you to decide. Status never changes here. changed_refs lists changed sources no " +
|
|
67
|
+
"findings batch reads yet, for an agent to read again with projects actions add; a run names a change " +
|
|
68
|
+
"once, so --since-time also lists those an earlier run, such as wcat sync's, already found. wcat sync runs it too")
|
|
69
|
+
.option("--limit <n>", "most evidence links this run, up to 10000", positive, 500)
|
|
70
|
+
.option("--since-time <time>", "changed_refs also lists sources earlier runs found changed since then: 12h, 7d or a date (2026-11-01)")
|
|
71
|
+
.option("--json", "print JSON; --json=id,title keeps only those fields")
|
|
72
|
+
.action(async (options) => {
|
|
73
|
+
const since = options.sinceTime === undefined ? undefined : sinceOf(options.sinceTime);
|
|
74
|
+
const check = await withStore(env, async (store) => {
|
|
75
|
+
const found = await store.knowledge.checkSources({ limit: options.limit });
|
|
76
|
+
if (since === undefined)
|
|
77
|
+
return found;
|
|
78
|
+
const earlier = await store.knowledge.changedSources({ since, limit: options.limit });
|
|
79
|
+
return { ...found, changedRefs: [...new Set([...found.changedRefs, ...earlier.map(({ ref }) => ref)])] };
|
|
80
|
+
});
|
|
81
|
+
print(options.json, itemAnswer(check), sourceCheckText(check));
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const TARGET = { memory: "memory:<id>", fact: "fact:<id>" };
|
|
85
|
+
/** `memories challenge` and `facts challenge`: a contradiction opens the owner's review and decides nothing. */
|
|
86
|
+
export const challengeCommand = (parent, type, streams, env) => {
|
|
87
|
+
const { run } = answers(parent, streams, env);
|
|
88
|
+
byOption(annotate(parent.command("challenge"), { effects: LOCAL_WRITE }))
|
|
89
|
+
.summary(`say a ${type} no longer holds, citing what contradicts it; you decide`)
|
|
90
|
+
.description(`say a ${type} is contradicted, citing what shows it: this opens its memory_source_review, or adds to the ` +
|
|
91
|
+
"open one, and changes nothing else. Only you decide it (wcat review show <id>). An agent may run it")
|
|
92
|
+
.argument("<ref>", TARGET[type])
|
|
93
|
+
.requiredOption("--evidence <ref...>", "what contradicts it: msg:, note:, meeting:, fact: or another reference")
|
|
94
|
+
.requiredOption("--reason <text>", "why it no longer holds, in a sentence")
|
|
95
|
+
.option("--suggest <text>", `what the ${type} should say instead, for you to take or leave`)
|
|
96
|
+
.option("--json", "print JSON; --json=id,title keeps only those fields")
|
|
97
|
+
.action(async (ref, options, command) => {
|
|
98
|
+
const by = await whoRuns(command, env, { asOwner: options.asOwner, question: `challenge ${ref} as you?` });
|
|
99
|
+
await run(options.json, async (store) => {
|
|
100
|
+
await (type === "memory" ? store.memories.get(ref) : store.facts.get(ref));
|
|
101
|
+
const proposal = await store.knowledge.challenge(ref, {
|
|
102
|
+
evidence: options.evidence,
|
|
103
|
+
reason: options.reason,
|
|
104
|
+
by,
|
|
105
|
+
...(options.suggest === undefined ? {} : { suggestion: options.suggest }),
|
|
106
|
+
});
|
|
107
|
+
return itemAnswer(await reviewItemOf(store, proposal.id));
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=sources.js.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { annotate } from "@wirecat/cli-base/commands";
|
|
3
|
+
import { parseLucene, validateQuery } from "@wirecat/cli-base/query";
|
|
4
|
+
import { LOCAL_READ, LOCAL_WRITE, MENTION_QUERY, queryHelp } from "@wirecat/cli-core";
|
|
5
|
+
import { answers, itemAnswer, listAnswer, withStore } from "../answer.js";
|
|
6
|
+
import { byOption, whoRuns } from "../author.js";
|
|
7
|
+
import { positive } from "../options.js";
|
|
8
|
+
import { withOwner } from "../people/owner.js";
|
|
9
|
+
import { SOURCE_HELP, sourceListOf } from "../store/source-list.js";
|
|
10
|
+
const mailOf = async (store, env, source) => source === undefined ? [] : (await sourceListOf(store, env, source)).mail;
|
|
11
|
+
const line = ({ id, kind, value, status, source }) => `${id} ${source.at ?? "-"} ${kind} ${value} ${status} ${source.type}:${source.id}` +
|
|
12
|
+
(source.title ? ` ${source.title}` : "") +
|
|
13
|
+
(source.from ? ` from ${source.from}` : "");
|
|
14
|
+
const withSource = (command, what) => command.option("--source <accounts>", what).option("--json", "print JSON; --json=id,title keeps only those fields");
|
|
15
|
+
const SCOPE = "the mailboxes a mail mention may be in: email:<account>, email or group:<name>";
|
|
16
|
+
const idArgument = (command) => command.argument("<id>", "the mention's id, from wcat mentions list", positive);
|
|
17
|
+
export const mentionsCommand = (program, streams, env) => {
|
|
18
|
+
const { print, run } = answers(program, streams, env);
|
|
19
|
+
const decider = async (command, options) => {
|
|
20
|
+
const who = await whoRuns(command, env, { asOwner: options.asOwner, question: "decide this mention as you?" });
|
|
21
|
+
return { by: who === "owner" ? "owner" : who.bot };
|
|
22
|
+
};
|
|
23
|
+
const mentions = program
|
|
24
|
+
.command("mentions")
|
|
25
|
+
.description("phones, e-mail, links, names and addresses in documents, notes and mail");
|
|
26
|
+
annotate(mentions.command("list"), { effects: LOCAL_READ, query: MENTION_QUERY })
|
|
27
|
+
.description("the mentions in the texts --source names matching the query, newest text first")
|
|
28
|
+
.argument("[query...]", "fields below; a bare word is a value")
|
|
29
|
+
.requiredOption("--source <accounts>", SOURCE_HELP)
|
|
30
|
+
.option("--limit <n>", "most mentions", positive, 100)
|
|
31
|
+
.option("--json", "print JSON; --json=id,title keeps only those fields")
|
|
32
|
+
.addHelpText("after", queryHelp(MENTION_QUERY))
|
|
33
|
+
.action(async (words, options) => {
|
|
34
|
+
const text = words.join(" ").trim();
|
|
35
|
+
const query = text
|
|
36
|
+
? validateQuery(parseLucene(text, { ...MENTION_QUERY, defaultField: "value" }), MENTION_QUERY)
|
|
37
|
+
: undefined;
|
|
38
|
+
const { found, read } = await withStore(env, async (store) => {
|
|
39
|
+
const list = await sourceListOf(store, env, options.source);
|
|
40
|
+
const kinds = [
|
|
41
|
+
...(list.mail.length > 0 ? ["email"] : []),
|
|
42
|
+
...(list.notes ? ["note"] : []),
|
|
43
|
+
...(list.documents ? ["document"] : []),
|
|
44
|
+
];
|
|
45
|
+
const window = { limit: options.limit, offset: 0 };
|
|
46
|
+
const pages = await Promise.all(kinds.map((kind) => store.sourceMentions.list(kind, query, window, kind === "email" ? list.mail : [])));
|
|
47
|
+
const read = [
|
|
48
|
+
...list.mail.map(({ provider, account }) => `${provider}:${account}`),
|
|
49
|
+
...(list.notes ? ["notes:internal"] : []),
|
|
50
|
+
...(list.documents ? ["documents"] : []),
|
|
51
|
+
];
|
|
52
|
+
return { found: pages, read };
|
|
53
|
+
});
|
|
54
|
+
const all = found
|
|
55
|
+
.flatMap((page) => page.items)
|
|
56
|
+
.sort((a, b) => (b.source.at ?? "").localeCompare(a.source.at ?? ""));
|
|
57
|
+
const items = all.slice(0, options.limit);
|
|
58
|
+
print(options.json, listAnswer("mentions list", {
|
|
59
|
+
items,
|
|
60
|
+
limit: options.limit,
|
|
61
|
+
has_more: all.length > options.limit || found.some((page) => page.hasMore),
|
|
62
|
+
args: { query: text, source: options.source },
|
|
63
|
+
meta: { accounts: read },
|
|
64
|
+
}), [...items.map(line), `read: ${read.join(", ") || "nothing"}`].join("\n"));
|
|
65
|
+
});
|
|
66
|
+
idArgument(withSource(annotate(mentions.command("show"), { effects: LOCAL_READ })
|
|
67
|
+
.summary("one mention, the text around it, and who it may be")
|
|
68
|
+
.description("one mention, the text around it, how many other places hold its value, and who it may be"), SCOPE)).action(async (id, options) => {
|
|
69
|
+
const found = await withStore(env, async (store) => store.sourceMentions.show(id, await mailOf(store, env, options.source)));
|
|
70
|
+
if (!found)
|
|
71
|
+
throw new CliError("not_found", `no mention ${id} in a document, a note or the mail named; a mail one needs --source email:<account>`);
|
|
72
|
+
print(options.json, itemAnswer(found), `${line(found)}\n…${found.before}[${found.written}]${found.after}…\n` +
|
|
73
|
+
`same ${found.kind} in ${found.sameValue} other place${found.sameValue === 1 ? "" : "s"}` +
|
|
74
|
+
(found.candidates.length > 0 ? `\nmay be ${found.candidates.join(", ")}` : ""));
|
|
75
|
+
});
|
|
76
|
+
byOption(idArgument(withSource(annotate(mentions.command("confirm"), { effects: LOCAL_WRITE })
|
|
77
|
+
.summary("say what a mention is, everywhere its value is written")
|
|
78
|
+
.description("say what a mention is: a phone's owner everywhere it is written, the stored document, who a name means"), SCOPE)))
|
|
79
|
+
.argument("[person]", "person:<uid> or organization:<id> that owns the phone or address, or a name means")
|
|
80
|
+
.action(async (id, person, options, command) => {
|
|
81
|
+
const by = await decider(command, options);
|
|
82
|
+
await run(options.json, async (store) => itemAnswer(await store.sourceMentions.confirm(id, person === undefined ? person : await withOwner(store, person), by, await mailOf(store, env, options.source))));
|
|
83
|
+
});
|
|
84
|
+
byOption(idArgument(withSource(annotate(mentions.command("reject"), { effects: LOCAL_WRITE })
|
|
85
|
+
.summary("dismiss a mention's value everywhere, and on later imports")
|
|
86
|
+
.description("not a real mention: dismiss its value everywhere and on later imports; a name only where it is"), SCOPE))).action(async (id, options, command) => {
|
|
87
|
+
const by = await decider(command, options);
|
|
88
|
+
await run(options.json, async (store) => itemAnswer(await store.sourceMentions.reject(id, by, await mailOf(store, env, options.source))));
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
2
|
+
import { userInfo } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
/** Where npm, pnpm and bun all put the package; a checkout, its build and CI run from anywhere else. */
|
|
5
|
+
const INSTALLED = "/node_modules/@wirecat/wirecat/";
|
|
6
|
+
/**
|
|
7
|
+
* Whether this start may still have memo's files to move, from Node built-ins only: the bin asks on every start, so
|
|
8
|
+
* the migration code loads only before the marker says it is done. `migrateFromMemo` decides the rest.
|
|
9
|
+
* Only an installed wcat moves anything: `cli-dev lint` and the smoke run a checkout's bin with the developer's own
|
|
10
|
+
* home, and once moved the owner's memo folders and timers on 2026-11-28.
|
|
11
|
+
*/
|
|
12
|
+
export const mayMigrate = (env, platform = process.platform, script = "") => {
|
|
13
|
+
if (!script)
|
|
14
|
+
return false;
|
|
15
|
+
let real;
|
|
16
|
+
try {
|
|
17
|
+
// npm and pnpm start the program through a link in their bin folder.
|
|
18
|
+
real = realpathSync(script);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
real = script;
|
|
22
|
+
}
|
|
23
|
+
if (!real.replaceAll("\\", "/").includes(INSTALLED))
|
|
24
|
+
return false;
|
|
25
|
+
const kinds = ["CONFIG", "STATE", "CACHE"];
|
|
26
|
+
if (kinds.some((kind) => env[`WCAT_${kind}_DIR`] || env[`MEMO_${kind}_DIR`]))
|
|
27
|
+
return false;
|
|
28
|
+
let home;
|
|
29
|
+
try {
|
|
30
|
+
home = userInfo().homedir;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (platform !== "win32" && env.HOME && env.HOME !== home)
|
|
36
|
+
return false;
|
|
37
|
+
const state = platform === "win32"
|
|
38
|
+
? join(env.LOCALAPPDATA || join(env.USERPROFILE || home, "AppData", "Local"), "wcat", "Data")
|
|
39
|
+
: join(env.XDG_DATA_HOME || join(env.HOME || home, ".local", "share"), "wcat");
|
|
40
|
+
try {
|
|
41
|
+
return (JSON.parse(readFileSync(join(state, "migrated-from-memo.json"), "utf8")).keyring !==
|
|
42
|
+
"done");
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=check.js.map
|