@wirecat/drive-cli 0.68.0 → 0.70.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/contracts/wirecat.json +14 -13
- package/dist/age.d.ts +0 -36
- package/dist/age.d.ts.map +1 -1
- package/dist/age.js +0 -22
- package/dist/age.js.map +1 -1
- package/dist/bin/drive.js +2 -2
- package/dist/bundle/{all-profiles-BU6XUFUP.js → all-profiles-FW3GK3QO.js} +24 -34
- package/dist/bundle/{anthropic-ZP5B7S2Z.js → anthropic-QVKJT3II.js} +8 -8
- package/dist/bundle/{app-server-EB4DH6T7.js → app-server-QU73RD5R.js} +68 -76
- package/dist/bundle/{bun-PWMM6L45.js → bun-5XCD5CBB.js} +2 -2
- package/dist/bundle/{bun-sqlite-6VPR2SVC.js → bun-sqlite-TIGSVNSV.js} +9 -9
- package/dist/bundle/{chunk-7BXVI7XF.js → chunk-2SBC4DVV.js} +4 -4
- package/dist/bundle/{chunk-UFPRP7MG.js → chunk-3AHBZP33.js} +10 -15
- package/dist/bundle/{chunk-QRSPFCRY.js → chunk-3CHW7JGR.js} +17 -17
- package/dist/bundle/chunk-3TCMANIM.js +387 -0
- package/dist/bundle/{chunk-EOC7RHJ2.js → chunk-3UWRAIWA.js} +5 -7
- package/dist/bundle/{chunk-5G2BY4B6.js → chunk-3UZ4OH22.js} +32 -31
- package/dist/bundle/{chunk-UIKVP23D.js → chunk-4WK26MPY.js} +1 -1
- package/dist/bundle/{chunk-WUFZGPXX.js → chunk-54BQWRJL.js} +7 -7
- package/dist/bundle/{chunk-EA2OB75T.js → chunk-54NDYVZA.js} +1 -1
- package/dist/bundle/{chunk-QKY24RWV.js → chunk-5JTB4URG.js} +12 -12
- package/dist/bundle/{chunk-M4OP5ASJ.js → chunk-66PL7P4C.js} +1 -1
- package/dist/bundle/{chunk-JMZQBRRZ.js → chunk-6BMTW5A6.js} +9 -9
- package/dist/bundle/{chunk-CVAJMRRD.js → chunk-6DPOWBKA.js} +6 -6
- package/dist/bundle/{chunk-YUGTJBV3.js → chunk-7C5KENNU.js} +3 -3
- package/dist/bundle/chunk-7DJNURKV.js +823 -0
- package/dist/bundle/{chunk-5TK2YQCO.js → chunk-7IBENBCK.js} +2 -2
- package/dist/bundle/chunk-7QSRODXM.js +259 -0
- package/dist/bundle/{chunk-HCZYJMBP.js → chunk-ABZ2NYDT.js} +1 -1
- package/dist/bundle/chunk-AV5UKJZM.js +729 -0
- package/dist/bundle/{chunk-IVOG6T6P.js → chunk-BBFXQPKD.js} +3 -3
- package/dist/bundle/{chunk-BXHFJTU5.js → chunk-BBRMDMIR.js} +3 -3
- package/dist/bundle/{chunk-DYLYH7VE.js → chunk-BD2K2ONK.js} +4 -4
- package/dist/bundle/{chunk-AIEMFRBU.js → chunk-BFKFKDPC.js} +1 -1
- package/dist/bundle/{chunk-JZ3MT7IE.js → chunk-BXPC5TFG.js} +2 -2
- package/dist/bundle/chunk-DHX27E5M.js +31 -0
- package/dist/bundle/{chunk-6QR7NKMG.js → chunk-DR57KDAY.js} +109 -5
- package/dist/bundle/{chunk-2VYEGKQ3.js → chunk-DVI72ZQG.js} +1 -1
- package/dist/bundle/{chunk-WGX4DZPW.js → chunk-DVVUJ254.js} +2 -2
- package/dist/bundle/{chunk-PJ3FKBXG.js → chunk-EDO5LZVF.js} +1 -1
- package/dist/bundle/{chunk-QTRYJZL7.js → chunk-EG62WVR2.js} +6 -6
- package/dist/bundle/{chunk-WCNTDETD.js → chunk-F5KJWRF5.js} +98 -6
- package/dist/bundle/{chunk-D4MVEOU2.js → chunk-FADAOLGB.js} +4 -4
- package/dist/bundle/{chunk-FAMXUI2X.js → chunk-FCSHWUMW.js} +5 -5
- package/dist/bundle/{chunk-O7T3WGCV.js → chunk-FN3RXBO7.js} +6 -6
- package/dist/bundle/{chunk-5W65QTYS.js → chunk-FONIFRYI.js} +4 -4
- package/dist/bundle/{chunk-UUQJVKPB.js → chunk-FVTKFIQH.js} +2340 -1436
- package/dist/bundle/{chunk-7A77GYCE.js → chunk-FYPW7NMH.js} +4 -4
- package/dist/bundle/{chunk-FIVFP53N.js → chunk-GA3URWIF.js} +1 -1
- package/dist/bundle/{chunk-GTLXBAJV.js → chunk-GAHIHE4K.js} +3035 -2482
- package/dist/bundle/{chunk-CMWFYZ45.js → chunk-GJZSVSV3.js} +2 -2
- package/dist/bundle/{chunk-QWGEOQHA.js → chunk-GK3BJMGK.js} +1 -1
- package/dist/bundle/{chunk-TI2OANJZ.js → chunk-GPDPEHYX.js} +1 -1
- package/dist/bundle/{chunk-KPKIHJIT.js → chunk-GV5DGHSA.js} +4 -4
- package/dist/bundle/{chunk-JRFKCYMW.js → chunk-HHAZ6DCY.js} +23 -6
- package/dist/bundle/{chunk-ZVQDOKDY.js → chunk-HK225DAG.js} +1 -1
- package/dist/bundle/{chunk-MW46BLWH.js → chunk-HRATXUFH.js} +22 -20
- package/dist/bundle/{chunk-Z5BMYI2V.js → chunk-HWUPU6WX.js} +8 -8
- package/dist/bundle/{chunk-6WAC2LOS.js → chunk-HYXXMSVD.js} +8614 -8597
- package/dist/bundle/{chunk-YYIWPH53.js → chunk-I7YSHUPW.js} +13 -13
- package/dist/bundle/{chunk-MWCPKUU4.js → chunk-IFTX7AQU.js} +5 -5
- package/dist/bundle/{chunk-SOS4U2RF.js → chunk-IGNIUDI3.js} +71 -49
- package/dist/bundle/{chunk-7JKECODO.js → chunk-ILAQIBEO.js} +1 -11
- package/dist/bundle/{chunk-CK2SQ2CE.js → chunk-KSJAFMU5.js} +78 -31
- package/dist/bundle/{chunk-ZSVMZH5O.js → chunk-LINBDWJK.js} +2 -2
- package/dist/bundle/{chunk-43NEDPXB.js → chunk-LMJBQFW6.js} +6 -6
- package/dist/bundle/{chunk-IJCUAKR5.js → chunk-ML3R2UHV.js} +4 -4
- package/dist/bundle/{chunk-PGPHEC2X.js → chunk-MXNQZAJQ.js} +2 -2
- package/dist/bundle/{chunk-RT5NT62B.js → chunk-NP7LJATI.js} +16 -70
- package/dist/bundle/chunk-OY7TNUEC.js +16 -0
- package/dist/bundle/{chunk-74NCZKRW.js → chunk-P77FL6RY.js} +18 -18
- package/dist/bundle/chunk-P7PLKNPX.js +3611 -0
- package/dist/bundle/{chunk-QVJMFZFW.js → chunk-PAPY6Q6H.js} +1 -1
- package/dist/bundle/{chunk-Q6BD6RUH.js → chunk-PN4JYURZ.js} +102 -57
- package/dist/bundle/{chunk-MOKEB656.js → chunk-PR7XD2DI.js} +2 -2
- package/dist/bundle/{chunk-UPCEHSIZ.js → chunk-Q5C6YKAY.js} +21 -16
- package/dist/bundle/{chunk-EXWZCI5G.js → chunk-QBAOIMVB.js} +1 -1
- package/dist/bundle/{chunk-ULNN3LCY.js → chunk-RCTOWLCD.js} +44 -37
- package/dist/bundle/{chunk-7TNQZKRD.js → chunk-REM5WHHQ.js} +77 -76
- package/dist/bundle/{chunk-Y2QVNVHK.js → chunk-RHSBXOQM.js} +1 -1
- package/dist/bundle/{chunk-UYBLNGZ2.js → chunk-RLNZ7NX5.js} +2 -2
- package/dist/bundle/chunk-RQNRYF6D.js +170 -0
- package/dist/bundle/{chunk-PV3AWPHR.js → chunk-SONPLYV7.js} +5 -5
- package/dist/bundle/{chunk-CRIEW4FP.js → chunk-T5D4OGDC.js} +2 -2
- package/dist/bundle/{chunk-MLSXHTUB.js → chunk-TGS5VPJD.js} +1228 -455
- package/dist/bundle/chunk-TNKQDS5A.js +335 -0
- package/dist/bundle/{chunk-DU23ET2O.js → chunk-VVN6GHAZ.js} +60 -81
- package/dist/bundle/{chunk-PWIEOATY.js → chunk-WJK6KTCS.js} +325 -14
- package/dist/bundle/{chunk-U52QE4QV.js → chunk-WWE5GO6G.js} +3 -3
- package/dist/bundle/{chunk-6HFZZ2PW.js → chunk-XOL346TJ.js} +2 -2
- package/dist/bundle/{chunk-ZAIE3G5I.js → chunk-XZBA6FVH.js} +3 -3
- package/dist/bundle/chunk-YCL3SK4T.js +1978 -0
- package/dist/bundle/{chunk-DIZBJLPM.js → chunk-YRUR3E3E.js} +68 -78
- package/dist/bundle/{chunk-EEE4H2PA.js → chunk-YZPE72GE.js} +12 -12
- package/dist/bundle/{chunk-F7KAMSXA.js → chunk-ZCXWV4XO.js} +4 -4
- package/dist/bundle/{chunk-NV75QPML.js → chunk-ZHZYGY5R.js} +4 -4
- package/dist/bundle/{cli-L7P36YUH.js → cli-K4D4DIGQ.js} +137 -88
- package/dist/bundle/command-contract-V3F452QI.js +43 -0
- package/dist/bundle/{command-server-entry-H3VGPOLJ.js → command-server-entry-WREK3QBB.js} +33 -31
- package/dist/bundle/decode-SEETPKBH.js +299 -0
- package/dist/bundle/{dispatch-WBEOHZDV.js → dispatch-SQCEURVK.js} +9 -9
- package/dist/bundle/drive.js +11 -11
- package/dist/bundle/{echarts-SDZA2SWG.js → echarts-WZ5RKFCX.js} +2 -2
- package/dist/bundle/{embed-WUKOASQG.js → embed-B2UCRZZR.js} +9 -9
- package/dist/bundle/{embedder-UBRAXRDZ.js → embedder-4R6Z7G7L.js} +12 -12
- package/dist/bundle/entry-ORZYRJ5N.js +25 -0
- package/dist/bundle/{failure-X6PSLVSO.js → failure-CYNXH3RQ.js} +4 -4
- package/dist/bundle/first-run-KAKA6KBY.js +31 -0
- package/dist/bundle/first-screen-R645UHRH.js +41 -0
- package/dist/bundle/google-BSO3YB7N.js +45 -0
- package/dist/bundle/{google-api-SQQ4BSNR.js → google-api-SAND2F7L.js} +70 -63
- package/dist/bundle/grants-PLNFYARD.js +118 -0
- package/dist/bundle/{identity-SRL6RSU2.js → identity-JVVGS4U6.js} +6 -6
- package/dist/bundle/{instructions-7T6JJIFS.js → instructions-JSMTSB22.js} +1 -1
- package/dist/bundle/{login-N243GGEE.js → login-6WG3YBDU.js} +78 -71
- package/dist/bundle/{mcp-TDKGDB4V.js → mcp-VFIOZDVY.js} +2 -2
- package/dist/bundle/meeting-combined-SUKMFK3F.js +27 -0
- package/dist/bundle/meeting-model-S4YGKIFI.js +29 -0
- package/dist/bundle/meeting-semantic-5U7JQCFF.js +25 -0
- package/dist/bundle/{node-BZDMUFTW.js → node-VJMVHOWD.js} +2 -2
- package/dist/bundle/{node-sqlite-SZQCCMV2.js → node-sqlite-DCNT3HVE.js} +10 -10
- package/dist/bundle/oauth-KCMNQ3ZP.js +22 -0
- package/dist/bundle/{open-RVTPKDA3.js → open-NFOEHVW7.js} +8 -8
- package/dist/bundle/{openai-6NN63BMH.js → openai-D47WY7EC.js} +32 -30
- package/dist/bundle/{process-756VBE7E.js → process-Q2FRU5VA.js} +1 -1
- package/dist/bundle/{program-B4QBJYB5.js → program-T2AJJQEM.js} +1327 -1329
- package/dist/bundle/{prompt-HGP2DSRW.js → prompt-YJSDABXN.js} +8 -8
- package/dist/bundle/{reasons-KSYP5VDJ.js → reasons-WEHPCSJX.js} +5 -5
- package/dist/bundle/{recognize-26SHB7HI.js → recognize-6OBEIEB3.js} +7 -7
- package/dist/bundle/{remote-Z4PWHZ5N.js → remote-3SL2QJ7T.js} +13 -13
- package/dist/bundle/{rerank-QHJZJK3Q.js → rerank-L6F5SLIB.js} +10 -10
- package/dist/bundle/{serve-MYJW5IEM.js → serve-GYSWIWH4.js} +12 -12
- package/dist/bundle/server-BI46BSRE.js +80 -0
- package/dist/bundle/{server-XFW3V7CR.js → server-GWWP3RIT.js} +62 -53
- package/dist/bundle/{services-IQG2RVTO.js → services-BDQBRXT5.js} +91 -51
- package/dist/bundle/{sqlite-runtime-X4GB5PBV.js → sqlite-runtime-ZSZGAUYB.js} +9 -9
- package/dist/bundle/{start-C6EXYXAL.js → start-BJ275RUK.js} +7 -7
- package/dist/bundle/{state-ATQK2X3W.js → state-HLNGFI2T.js} +9 -9
- package/dist/bundle/{store-QUBUPK6F.js → store-I43KZNJW.js} +35 -26
- package/dist/bundle/{store-MEHEUOJH.js → store-OSRTGYGI.js} +23 -19
- package/dist/bundle/store-maintenance-command-FO7LEVSL.js +72 -0
- package/dist/bundle/tokens-DB7O7QNB.js +118 -0
- package/dist/catalog.d.ts +0 -28
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +0 -82
- package/dist/catalog.js.map +1 -1
- package/dist/commands/catalog.d.ts +3 -8
- package/dist/commands/catalog.d.ts.map +1 -1
- package/dist/commands/catalog.js +36 -109
- package/dist/commands/catalog.js.map +1 -1
- package/dist/commands/context.d.ts +3 -0
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +20 -0
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/documents.d.ts.map +1 -1
- package/dist/commands/documents.js +30 -72
- package/dist/commands/documents.js.map +1 -1
- package/dist/commands/folders.d.ts +1 -1
- package/dist/commands/folders.d.ts.map +1 -1
- package/dist/commands/folders.js +45 -48
- package/dist/commands/folders.js.map +1 -1
- package/dist/commands/knowledge.d.ts +4 -21
- package/dist/commands/knowledge.d.ts.map +1 -1
- package/dist/commands/knowledge.js +3 -241
- package/dist/commands/knowledge.js.map +1 -1
- package/dist/commands/mirrors.d.ts +2 -2
- package/dist/commands/mirrors.d.ts.map +1 -1
- package/dist/commands/mirrors.js +46 -202
- package/dist/commands/mirrors.js.map +1 -1
- package/dist/commands/search.d.ts +1 -3
- package/dist/commands/search.d.ts.map +1 -1
- package/dist/commands/search.js +20 -42
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +36 -53
- package/dist/commands/sync.js.map +1 -1
- package/dist/contract-overrides.d.ts +0 -2
- package/dist/contract-overrides.d.ts.map +1 -1
- package/dist/contract-overrides.js +0 -317
- package/dist/contract-overrides.js.map +1 -1
- package/dist/knowledge.d.ts +1 -1
- package/dist/knowledge.d.ts.map +1 -1
- package/dist/knowledge.js +4 -3
- package/dist/knowledge.js.map +1 -1
- package/dist/list-queries.d.ts +0 -31
- package/dist/list-queries.d.ts.map +1 -1
- package/dist/list-queries.js +0 -36
- package/dist/list-queries.js.map +1 -1
- package/dist/policy.d.ts +1 -1
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +3 -3
- package/dist/policy.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +2 -3
- package/dist/program.js.map +1 -1
- package/dist/provider-json.d.ts.map +1 -1
- package/dist/provider-json.js +5 -5
- package/dist/provider-json.js.map +1 -1
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +0 -10
- package/dist/reasons.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/dist/bundle/chunk-2UHQVRH2.js +0 -1235
- package/dist/bundle/chunk-AXYG2DDY.js +0 -4721
- package/dist/bundle/chunk-J5LXL435.js +0 -1316
- package/dist/bundle/chunk-R5FTCNLJ.js +0 -76
- package/dist/bundle/command-contract-EYFGMKIG.js +0 -41
- package/dist/bundle/decode-JEU6JWCV.js +0 -165
- package/dist/bundle/entry-C4NUQFTF.js +0 -25
- package/dist/bundle/first-run-PKHBS7B4.js +0 -30
- package/dist/bundle/first-screen-QOVOM4BF.js +0 -39
- package/dist/bundle/google-XXHSMTVK.js +0 -45
- package/dist/bundle/grants-2U4JVT6O.js +0 -111
- package/dist/bundle/oauth-CMAFXX6A.js +0 -22
- package/dist/bundle/server-HBZPIHDX.js +0 -74
- package/dist/bundle/store-maintenance-command-33ULVDWY.js +0 -65
- package/dist/bundle/tokens-A2GP4F34.js +0 -111
- package/dist/knowledge-query.d.ts +0 -77
- package/dist/knowledge-query.d.ts.map +0 -1
- package/dist/knowledge-query.js +0 -104
- package/dist/knowledge-query.js.map +0 -1
- package/dist/bundle/{chunk-XWBPP2HX.js → chunk-ZI3YTXSF.js} +0 -0
- package/dist/bundle/{mdast-util-from-markdown-CE73EWJ2.js → mdast-util-from-markdown-FXEPSNER.js} +3 -3
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { writeFileSync } from "node:fs";
|
|
2
1
|
import { CliError } from "@wirecat/cli-base";
|
|
3
2
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
4
|
-
import { FETCH, itemOf
|
|
5
|
-
import {
|
|
6
|
-
import { ageOf, staleCopy } from "../age.js";
|
|
3
|
+
import { FETCH, itemOf } from "@wirecat/cli-core/cli";
|
|
4
|
+
import { addLocalDocumentCommands } from "@wirecat/cli-core/documents/cli";
|
|
7
5
|
import { activeProfile, fileId, textLimit } from "../config.js";
|
|
8
6
|
import { addDocument, profilesToAdd } from "../documents-add.js";
|
|
9
7
|
import { metadataJson } from "../model.js";
|
|
10
8
|
import { examples } from "../registry.js";
|
|
11
9
|
import { readSnapshot, readState } from "../state.js";
|
|
12
|
-
import {
|
|
10
|
+
import { DRIVE_WORDS } from "./context.js";
|
|
13
11
|
// A `search` hit's ref; checkpoints are rewritten when the store changes, so it names one document here.
|
|
14
12
|
const DOCUMENT_REF = /^document:[1-9]\d*$/;
|
|
15
13
|
export const isDocumentRef = (input) => DOCUMENT_REF.test(input);
|
|
@@ -55,73 +53,33 @@ export const addProfilesOf = (env, command, word) => profilesToAdd(env, {
|
|
|
55
53
|
export const installDocumentCommands = (program, context) => {
|
|
56
54
|
const { env, selected, output, withIndex, source, profileWord } = context;
|
|
57
55
|
const imported = importedDocument(context);
|
|
58
|
-
const documents =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
: { id, name: note.title, reference: note.ref, tabs: 0, ...age };
|
|
86
|
-
}),
|
|
87
|
-
limit,
|
|
88
|
-
has_more: found.hasMore,
|
|
89
|
-
page,
|
|
90
|
-
args: { query: query || undefined },
|
|
91
|
-
}));
|
|
92
|
-
});
|
|
93
|
-
examples(annotate(documents.command("show"), { effects: LOCAL_READ, partial: true })
|
|
94
|
-
.argument("<document>", documentArgument)
|
|
95
|
-
.description("show an imported document's text, tabs and metadata"), ["drive personal documents show DOC_ID", "drive personal documents show document:42 --offline"]).action((input) => {
|
|
96
|
-
const { snapshot } = imported(input);
|
|
97
|
-
const state = readState(env, selected(), activeProfile(env, selected()).principal);
|
|
98
|
-
output(itemOf({
|
|
99
|
-
metadata: metadataJson(snapshot.metadata),
|
|
100
|
-
...ageOf(state),
|
|
101
|
-
text: snapshot.text,
|
|
102
|
-
tabs: snapshot.tabs,
|
|
103
|
-
...(snapshot.notRead ? { not_read: snapshot.notRead } : {}),
|
|
104
|
-
}, staleCopy(state)));
|
|
105
|
-
});
|
|
106
|
-
examples(annotate(documents.command("export"), { effects: LOCAL_WRITE, partial: true })
|
|
107
|
-
.argument("<document>", documentArgument)
|
|
108
|
-
.description("write an imported document to a new Markdown file"), ["drive personal documents export DOC_ID --output notes.md"])
|
|
109
|
-
.requiredOption("--output <file>", "path of the Markdown file to write; an existing file is refused")
|
|
110
|
-
.action((input, args) => {
|
|
111
|
-
const { id, snapshot } = imported(input);
|
|
112
|
-
try {
|
|
113
|
-
writeFileSync(args.output, snapshot.markdown, { flag: "wx", mode: 0o600 });
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
if (error.code === "EEXIST")
|
|
117
|
-
throw new CliError("validation_error", "the output file already exists; choose another --output", {
|
|
118
|
-
reason: "export.exists",
|
|
119
|
-
param: "--output",
|
|
120
|
-
});
|
|
121
|
-
throw error;
|
|
122
|
-
}
|
|
123
|
-
const state = readState(env, selected(), activeProfile(env, selected()).principal);
|
|
124
|
-
output(itemOf({ id, path: args.output, format: "markdown", ...ageOf(state) }, staleCopy(state)));
|
|
56
|
+
const documents = addLocalDocumentCommands(program, {
|
|
57
|
+
words: DRIVE_WORDS,
|
|
58
|
+
output,
|
|
59
|
+
list: async (query, page) => {
|
|
60
|
+
const profile = activeProfile(env, selected());
|
|
61
|
+
const found = await withIndex(async (index) => {
|
|
62
|
+
if (!index.knowledge)
|
|
63
|
+
throw new CliError("configuration_error", "index has no shared knowledge adapter");
|
|
64
|
+
return index.knowledge.documents(profile.principal, query, page);
|
|
65
|
+
});
|
|
66
|
+
const state = readState(env, selected(), profile.principal);
|
|
67
|
+
return {
|
|
68
|
+
items: found.items.map((note) => {
|
|
69
|
+
const id = (note.path ?? "").replace(/\.md$/, "");
|
|
70
|
+
const doc = state.documents[id];
|
|
71
|
+
return doc
|
|
72
|
+
? { ...metadataJson(doc.metadata), reference: doc.reference, tabs: doc.tabs }
|
|
73
|
+
: { id, name: note.title, reference: note.ref, tabs: 0 };
|
|
74
|
+
}),
|
|
75
|
+
hasMore: found.hasMore,
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
document: (input) => {
|
|
79
|
+
const { id, snapshot } = imported(input);
|
|
80
|
+
return { id, metadata: metadataJson(snapshot.metadata), snapshot };
|
|
81
|
+
},
|
|
82
|
+
lastSync: () => readState(env, selected(), activeProfile(env, selected()).principal).lastSync,
|
|
125
83
|
});
|
|
126
84
|
examples(annotate(documents.command("add"), { mcp: false, effects: FETCH })
|
|
127
85
|
.argument("<url>", "Google Drive or Docs URL, or file id")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../src/commands/documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../src/commands/documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAA;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,MAA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commander";
|
|
2
2
|
import { type Call } from "../browse.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type CommandContext } from "./context.js";
|
|
4
4
|
export declare const installFolderCommands: (program: Command, context: CommandContext, call: Call) => void;
|
|
5
5
|
//# sourceMappingURL=folders.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folders.d.ts","sourceRoot":"","sources":["../../src/commands/folders.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"folders.d.ts","sourceRoot":"","sources":["../../src/commands/folders.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAyC,KAAK,IAAI,EAAkB,MAAM,cAAc,CAAA;AAI/F,OAAO,EAAE,KAAK,cAAc,EAAe,MAAM,cAAc,CAAA;AAE/D,eAAO,MAAM,qBAAqB,YAAa,OAAO,WAAW,cAAc,QAAQ,IAAI,SAqD1F,CAAA"}
|
package/dist/commands/folders.js
CHANGED
|
@@ -1,59 +1,56 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
3
|
-
import { answerEntity
|
|
3
|
+
import { answerEntity } from "@wirecat/cli-core/cli";
|
|
4
|
+
import { addDocumentFolderCommands } from "@wirecat/cli-core/documents/cli";
|
|
4
5
|
import { BROWSE_HELP, browseFolders, browseRow, SHARED_WITH_ME } from "../browse.js";
|
|
5
6
|
import { activeProfile, fileId, readConfig, selectedFolders, writeConfig } from "../config.js";
|
|
6
|
-
import { bindQuery, FOLDERS_QUERY, folderRow, termsOf } from "../list-queries.js";
|
|
7
7
|
import { FOLDER } from "../model.js";
|
|
8
|
-
import { allOf } from "../output.js";
|
|
9
8
|
import { examples, GOOGLE_READ } from "../registry.js";
|
|
9
|
+
import { DRIVE_WORDS } from "./context.js";
|
|
10
10
|
export const installFolderCommands = (program, context, call) => {
|
|
11
11
|
const { env, selected, output, source } = context;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
profile
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
config.profiles[name] = profile;
|
|
55
|
-
writeConfig(env, config);
|
|
56
|
-
output(itemOf({ id, removed: true }));
|
|
12
|
+
addDocumentFolderCommands(program, {
|
|
13
|
+
words: DRIVE_WORDS,
|
|
14
|
+
output,
|
|
15
|
+
add: async (input) => {
|
|
16
|
+
const id = fileId(input);
|
|
17
|
+
const config = readConfig(env);
|
|
18
|
+
const name = selected();
|
|
19
|
+
const profile = activeProfile(env, name);
|
|
20
|
+
const metadata = await (await source()).metadata(id);
|
|
21
|
+
if (metadata.mime !== FOLDER || metadata.trashed)
|
|
22
|
+
throw new CliError("validation_error", "source is not an accessible Google folder");
|
|
23
|
+
if (!profile.roots.includes(metadata.id))
|
|
24
|
+
profile.roots.push(metadata.id);
|
|
25
|
+
config.profiles[name] = profile;
|
|
26
|
+
writeConfig(env, config);
|
|
27
|
+
return { id: metadata.id, name: metadata.name };
|
|
28
|
+
},
|
|
29
|
+
list: (filter) => selectedFolders(env, selected(), filter),
|
|
30
|
+
browse: (folders) => {
|
|
31
|
+
examples(answerEntity(annotate(folders.command("browse"), { effects: GOOGLE_READ }).description("list Google Drive folders one level at a time, to choose one for folders add"), "drive_remote_folder", browseRow), [
|
|
32
|
+
"drive personal folders browse",
|
|
33
|
+
"drive personal folders browse --parent FOLDER_ID --json",
|
|
34
|
+
`drive personal folders browse --parent ${SHARED_WITH_ME}`,
|
|
35
|
+
])
|
|
36
|
+
.option("--parent <id>", `folder id or URL to list inside, or ${SHARED_WITH_ME}; the top level without it`)
|
|
37
|
+
.addHelpText("after", BROWSE_HELP)
|
|
38
|
+
.action(async (args) => {
|
|
39
|
+
const parent = args.parent === undefined || args.parent === SHARED_WITH_ME ? args.parent : fileId(args.parent);
|
|
40
|
+
const roots = activeProfile(env, selected()).roots;
|
|
41
|
+
output(await browseFolders(call, parent, roots));
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
remove: (input) => {
|
|
45
|
+
const id = fileId(input);
|
|
46
|
+
const config = readConfig(env);
|
|
47
|
+
const name = selected();
|
|
48
|
+
const profile = activeProfile(env, name);
|
|
49
|
+
profile.roots = profile.roots.filter((root) => root !== id);
|
|
50
|
+
config.profiles[name] = profile;
|
|
51
|
+
writeConfig(env, config);
|
|
52
|
+
return id;
|
|
53
|
+
},
|
|
57
54
|
});
|
|
58
55
|
};
|
|
59
56
|
//# sourceMappingURL=folders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folders.js","sourceRoot":"","sources":["../../src/commands/folders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"folders.js","sourceRoot":"","sources":["../../src/commands/folders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,E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C;QACD,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAChB,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;YACxB,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAA;YAC9B,MAAM,IAAI,GAAG,QAAQ,EAAE,CAAA;YACvB,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;YACxC,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAA;YAC3D,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAA;YAC/B,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;YACxB,OAAO,EAAE,CAAA;QACX,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import
|
|
3
|
-
import { type Command } from "commander";
|
|
4
|
-
import type { Complete } from "../extraction.js";
|
|
1
|
+
import { type DocumentKnowledgeCommands } from "@wirecat/cli-core/documents/cli";
|
|
2
|
+
import type { Command } from "commander";
|
|
5
3
|
import type { DocumentKnowledge } from "../knowledge.js";
|
|
6
|
-
|
|
7
|
-
export interface KnowledgeCommands {
|
|
8
|
-
document(input: string): {
|
|
9
|
-
id: string;
|
|
10
|
-
ref: string;
|
|
11
|
-
hash: string;
|
|
12
|
-
snapshot: DocumentContent;
|
|
13
|
-
};
|
|
4
|
+
export interface KnowledgeCommands extends Omit<DocumentKnowledgeCommands, "words" | "run"> {
|
|
14
5
|
run<T>(input: string, fn: (knowledge: DocumentKnowledge, principal: string, ref: string) => Promise<T>): Promise<T>;
|
|
15
|
-
output(body: Body): void;
|
|
16
|
-
positive(input: string): number;
|
|
17
|
-
complete(): Complete;
|
|
18
|
-
/** Who writes or decides in this run: the owner at a terminal, an agent over MCP. */
|
|
19
|
-
author(): Author;
|
|
20
|
-
decider(): Decider;
|
|
21
6
|
}
|
|
22
|
-
declare const
|
|
23
|
-
export declare const installKnowledgeCommands: (...args: Parameters<typeof installKnowledgeCommandsDefinition>) => void;
|
|
24
|
-
export {};
|
|
7
|
+
export declare const installKnowledgeCommands: (program: Command, helpers: KnowledgeCommands) => void;
|
|
25
8
|
//# sourceMappingURL=knowledge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge.d.ts","sourceRoot":"","sources":["../../src/commands/knowledge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"knowledge.d.ts","sourceRoot":"","sources":["../../src/commands/knowledge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,yBAAyB,EAAE,MAAM,iCAAiC,CAAA;AAC9G,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAGxD,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,yBAAyB,EAAE,OAAO,GAAG,KAAK,CAAC;IACzF,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;CACpH;AAED,eAAO,MAAM,wBAAwB,YAAa,OAAO,WAAW,iBAAiB,SACV,CAAA"}
|
|
@@ -1,242 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { extractDocumentMemories } from "@wirecat/cli-core/documents";
|
|
5
|
-
import { FACT_TYPES, MEMORY_KINDS } from "@wirecat/cli-core/store";
|
|
6
|
-
import { Option } from "commander";
|
|
7
|
-
import { reviewedOverrides, SHELL_OVERRIDES } from "../contract-overrides.js";
|
|
8
|
-
import { FACT_QUERY, factItem, MEMORY_QUERY, MEMORY_SEARCH_QUERY, memoryItem, memorySearch, } from "../knowledge-query.js";
|
|
9
|
-
import { bindQuery, IDENTITIES_QUERY, identityRow, LINKS_QUERY, linkRow, NOTES_QUERY, TAGS_QUERY, tagRow, termsOf, } from "../list-queries.js";
|
|
10
|
-
import { allOf } from "../output.js";
|
|
11
|
-
import { DRIVE_APP } from "../policy.js";
|
|
12
|
-
import { examples } from "../registry.js";
|
|
13
|
-
const installKnowledgeCommandsDefinition = (program, helpers) => {
|
|
14
|
-
const { run, output, positive, author, decider } = helpers;
|
|
15
|
-
const documentArgument = "Google file or folder id or URL in the local catalog, or a document:<n> ref";
|
|
16
|
-
const scopes = ["personal", "work"];
|
|
17
|
-
const documents = program.commands.find((command) => command.name() === "documents");
|
|
18
|
-
examples(annotate(documents.command("context"), { effects: LOCAL_READ })
|
|
19
|
-
.argument("<document>", documentArgument)
|
|
20
|
-
.description("show a document with its tags, relationships, notes, memories and editors"), ["drive personal documents context DOC_ID"]).action(async (doc) => output(itemOf(await run(doc, (k, p, ref) => k.context(p, ref)))));
|
|
21
|
-
const tags = annotate(program.command("tags"), { effects: LOCAL_READ }).description("label imported documents; labels survive a sync");
|
|
22
|
-
for (const action of ["list", "add", "remove"]) {
|
|
23
|
-
const command = examples(annotate(tags.command(action), { effects: action === "list" ? LOCAL_READ : LOCAL_WRITE })
|
|
24
|
-
.description(action === "list" ? "list a document's tags" : action === "add" ? "tag a document" : "untag a document")
|
|
25
|
-
.argument("<document>", documentArgument), [`drive personal tags ${action} DOC_ID${action === "list" ? "" : " budget q3"}`]);
|
|
26
|
-
if (action === "list") {
|
|
27
|
-
bindQuery(command, TAGS_QUERY, tagRow).action(async (doc, words) => {
|
|
28
|
-
const filter = termsOf(words, TAGS_QUERY, "tags list");
|
|
29
|
-
output(allOf((await run(doc, (k, p, ref) => k.tags(p, ref, "list", [], filter))).map((tag) => ({ tag }))));
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
else
|
|
33
|
-
command
|
|
34
|
-
.argument("<tags...>", "one or more tags")
|
|
35
|
-
.action(async (doc, values) => output(itemOf({ tags: await run(doc, (k, p, ref) => k.tags(p, ref, action, values)) })));
|
|
36
|
-
}
|
|
37
|
-
const relationships = annotate(program.command("relationships"), { effects: LOCAL_READ }).description("connect a document to people, projects, notes and other references");
|
|
38
|
-
bindQuery(examples(annotate(relationships.command("list"), { effects: LOCAL_READ }).description("list a document's relationships"), ["drive personal relationships list DOC_ID"]).argument("<document>", documentArgument), LINKS_QUERY, linkRow).action(async (doc, words) => {
|
|
39
|
-
const { confirmed, ...filter } = termsOf(words, LINKS_QUERY, "relationships list");
|
|
40
|
-
output(allOf(await run(doc, (k, p, ref) => k.links(p, ref, { ...filter, ...(confirmed === undefined ? {} : { confirmed: confirmed === "true" }) }))));
|
|
41
|
-
});
|
|
42
|
-
examples(annotate(relationships.command("add"), { effects: LOCAL_WRITE }).description("connect a document to another reference"), [
|
|
43
|
-
"drive personal relationships add DOC_ID project:PROJECT_ID --kind about",
|
|
44
|
-
"drive personal relationships add DOC_ID person:PERSON_UID --kind assigned-to --role reviewer",
|
|
45
|
-
])
|
|
46
|
-
.argument("<document>", documentArgument)
|
|
47
|
-
.argument("<reference>", "what it connects to, such as person:<uid>, project:<id> or note:<id>")
|
|
48
|
-
.addOption(new Option("--kind <kind>", "how the two relate")
|
|
49
|
-
.choices(["links-to", "about", "evidence", "created-from", "related-to", "assigned-to"])
|
|
50
|
-
.default("related-to"))
|
|
51
|
-
.option("--role <role>", "the part the reference plays, in a word or two")
|
|
52
|
-
.option("--reason <text>", "why the two are connected")
|
|
53
|
-
.action(async (doc, to, { reason, ...args }) => output(itemOf(await run(doc, (k, p, ref) => k.addLink(p, ref, { to, ...args, by: decider(), ...(reason ? { evidence: reason } : {}) })))));
|
|
54
|
-
examples(annotate(relationships.command("remove"), { effects: LOCAL_WRITE }).description("remove one of a document's relationships"), ["drive personal relationships remove DOC_ID LINK_ID"])
|
|
55
|
-
.argument("<document>", documentArgument)
|
|
56
|
-
.argument("<relationship-id>", "id, as relationships list prints it")
|
|
57
|
-
.action(async (doc, id) => output(itemOf(await run(doc, (k, p, ref) => k.removeLink(p, ref, id, decider())))));
|
|
58
|
-
const notes = annotate(program.command("notes"), { effects: LOCAL_READ }).description("write notes about an imported document");
|
|
59
|
-
const noteArgument = "note:<id> reference, as notes list prints it";
|
|
60
|
-
examples(annotate(notes.command("add"), {
|
|
61
|
-
effects: LOCAL_WRITE,
|
|
62
|
-
output: { entity: "note" },
|
|
63
|
-
literal_after_dashes: true,
|
|
64
|
-
}).description("write a note about a document"), [`drive personal notes add DOC_ID "Check the numbers" --title Review`])
|
|
65
|
-
.argument("<document>", documentArgument)
|
|
66
|
-
.argument("<text>", "the note's text")
|
|
67
|
-
.option("--title <title>", "a title for the note")
|
|
68
|
-
.action(async (doc, text, args) => output(itemOf(await run(doc, (k, p, ref) => k.addNote(p, ref, text, args.title)))));
|
|
69
|
-
withQuery(examples(annotate(notes.command("list"), { effects: LOCAL_READ }).description("list a document's notes"), [
|
|
70
|
-
"drive personal notes list DOC_ID",
|
|
71
|
-
"drive personal notes list DOC_ID text:review --limit 10",
|
|
72
|
-
]).argument("<document>", documentArgument), NOTES_QUERY)
|
|
73
|
-
.option("--limit <n>", "how many notes to return", positive, 50)
|
|
74
|
-
.option("--page <n>", "which page to return", positive, 1)
|
|
75
|
-
.action(async (doc, words, { page, limit }) => {
|
|
76
|
-
const query = termsOf(words, NOTES_QUERY, "notes list").text;
|
|
77
|
-
const found = await run(doc, (k, p, ref) => k.notes(p, ref, { ...(query ? { search: query } : {}), limit, offset: (page - 1) * limit }));
|
|
78
|
-
output(listOf("notes list", {
|
|
79
|
-
items: found.items,
|
|
80
|
-
limit,
|
|
81
|
-
has_more: found.hasMore,
|
|
82
|
-
page,
|
|
83
|
-
args: { document: doc, query: words.join(" ") },
|
|
84
|
-
}));
|
|
85
|
-
});
|
|
86
|
-
examples(annotate(notes.command("show"), { effects: LOCAL_READ, output: { entity: "note" } }).description("show one note"), ["drive personal notes show DOC_ID note:NOTE_ID"])
|
|
87
|
-
.argument("<document>", documentArgument)
|
|
88
|
-
.argument("<note>", noteArgument)
|
|
89
|
-
.action(async (doc, noteRef) => output(itemOf(await run(doc, (k, p, ref) => k.note(p, ref, noteRef)))));
|
|
90
|
-
examples(annotate(notes.command("edit"), {
|
|
91
|
-
effects: LOCAL_WRITE,
|
|
92
|
-
output: { entity: "note" },
|
|
93
|
-
literal_after_dashes: true,
|
|
94
|
-
}).description("replace a note's text"), [`drive personal notes edit DOC_ID note:NOTE_ID "Numbers checked" --revision 2`])
|
|
95
|
-
.argument("<document>", documentArgument)
|
|
96
|
-
.argument("<note>", noteArgument)
|
|
97
|
-
.argument("<text>", "the note's new text")
|
|
98
|
-
.requiredOption("--revision <n>", "revision from notes show; a newer note is not overwritten", positive)
|
|
99
|
-
.action(async (doc, noteRef, text, args) => output(itemOf(await run(doc, (k, p, ref) => k.editNote(p, ref, noteRef, text, args.revision)))));
|
|
100
|
-
examples(annotate(notes.command("remove"), { effects: LOCAL_WRITE }).description("delete one note"), [
|
|
101
|
-
"drive personal notes remove DOC_ID note:NOTE_ID",
|
|
102
|
-
])
|
|
103
|
-
.argument("<document>", documentArgument)
|
|
104
|
-
.argument("<note>", noteArgument)
|
|
105
|
-
.action(async (doc, noteRef) => output(itemOf(await run(doc, (k, p, ref) => k.removeNote(p, ref, noteRef)))));
|
|
106
|
-
const memories = annotate(program.command("memories"), { effects: LOCAL_READ }).description("keep what was learned from a document, with evidence; an agent's stay proposed");
|
|
107
|
-
const memoryArgument = "memory:<id> reference, as memories list prints it";
|
|
108
|
-
const scope = (description) => new Option("--scope <scope>", description).choices(scopes);
|
|
109
|
-
examples(annotate(memories.command("add"), { effects: LOCAL_WRITE }).description("record a memory about a document"), [`drive personal memories add DOC_ID "The team prefers async reviews" --scope work --kind preference`])
|
|
110
|
-
.argument("<document>", documentArgument)
|
|
111
|
-
.argument("<text>", "what to remember")
|
|
112
|
-
.addOption(scope("whose memory it is: personal or work").makeOptionMandatory())
|
|
113
|
-
.addOption(new Option("--kind <kind>", "what kind of memory it is").choices(MEMORY_KINDS).default("summary"))
|
|
114
|
-
.option("--supersedes <ref>", "a memory:<id> about the same document that this one replaces")
|
|
115
|
-
.action(async (doc, body, args) => output(itemOf(memoryItem(await run(doc, (k, p, ref) => k.addMemory(p, ref, { body, ...args, status: "proposed", author: author() }))))));
|
|
116
|
-
withQuery(examples(annotate(memories.command("list"), { effects: LOCAL_READ }).description("list a document's memories"), [
|
|
117
|
-
"drive personal memories list DOC_ID scope:work",
|
|
118
|
-
"drive personal memories list DOC_ID kind:preference status:confirmed",
|
|
119
|
-
]).argument("<document>", documentArgument), MEMORY_QUERY)
|
|
120
|
-
.option("--limit <n>", "how many memories to return", positive, 50)
|
|
121
|
-
.action(async (doc, words, { limit }) => {
|
|
122
|
-
const terms = queryTerms(words, MEMORY_QUERY, "memories list");
|
|
123
|
-
const filters = {
|
|
124
|
-
...(terms.has("kind") ? { kind: terms.get("kind") } : {}),
|
|
125
|
-
...(terms.has("status") ? { status: terms.get("status") } : {}),
|
|
126
|
-
...(terms.has("scope") ? { scope: terms.get("scope") } : {}),
|
|
127
|
-
};
|
|
128
|
-
output(allOf((await run(doc, (k, p, ref) => k.memories(p, ref, { ...filters, limit }))).items.map(memoryItem)));
|
|
129
|
-
});
|
|
130
|
-
const memoryActions = {
|
|
131
|
-
show: "show one memory",
|
|
132
|
-
confirm: "confirm a proposed memory as true",
|
|
133
|
-
stale: "mark a memory as out of date",
|
|
134
|
-
};
|
|
135
|
-
for (const [action, description] of Object.entries(memoryActions))
|
|
136
|
-
examples(annotate(memories.command(action), { effects: action === "show" ? LOCAL_READ : LOCAL_WRITE }).description(description), [`drive personal memories ${action} DOC_ID memory:MEMORY_ID`])
|
|
137
|
-
.argument("<document>", documentArgument)
|
|
138
|
-
.argument("<memory>", memoryArgument)
|
|
139
|
-
.action(async (doc, memoryRef) => output(itemOf(memoryItem(await run(doc, (k, p, ref) => action === "show" ? k.memory(p, ref, memoryRef) : k.memory(p, ref, memoryRef, action, decider()))))));
|
|
140
|
-
const search = examples(annotate(memories.command("search"), { effects: LOCAL_READ }).description("search a document's memories by words"), [
|
|
141
|
-
"drive personal memories search DOC_ID reviews scope:work",
|
|
142
|
-
`drive personal memories search DOC_ID "async reviews"`,
|
|
143
|
-
])
|
|
144
|
-
.argument("<document>", documentArgument)
|
|
145
|
-
.argument("<query...>", "words to look for, and scope:personal or scope:work — the fields are below")
|
|
146
|
-
.allowUnknownOption()
|
|
147
|
-
.addHelpText("after", queryHelp(MEMORY_SEARCH_QUERY))
|
|
148
|
-
.action(async (doc, words) => {
|
|
149
|
-
const { text, scope } = memorySearch(words);
|
|
150
|
-
const found = await run(doc, (k, p, ref) => k.searchMemories(p, ref, text, scope));
|
|
151
|
-
output({
|
|
152
|
-
...allOf(found.items.map(memoryItem)),
|
|
153
|
-
...(found.hasMore ? { meta: { truncated: true } } : {}),
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
annotate(search, { query: defineQuery(MEMORY_SEARCH_QUERY), output: { entity: "memory" } });
|
|
157
|
-
examples(annotate(memories.command("extract"), { effects: REMOTE_WRITE })
|
|
158
|
-
.argument("<document>", documentArgument)
|
|
159
|
-
.description("send a document's text to the model and show the memories it proposes"), [
|
|
160
|
-
"drive personal memories extract DOC_ID --scope work",
|
|
161
|
-
"drive personal memories extract DOC_ID --scope work --yes",
|
|
162
|
-
])
|
|
163
|
-
.addOption(scope("whose memories they become: personal or work").makeOptionMandatory())
|
|
164
|
-
.option("--tab <id>", "send only this tab of the document")
|
|
165
|
-
.option("--yes", "save the proposals, each with its quote and the document's version")
|
|
166
|
-
.action(async function (doc) {
|
|
167
|
-
// The root --yes takes the flag wherever it is typed; this one only lists it for help and MCP.
|
|
168
|
-
const args = this.optsWithGlobals();
|
|
169
|
-
await run(doc, async () => undefined);
|
|
170
|
-
const result = await extractDocumentMemories({
|
|
171
|
-
read: () => helpers.document(doc),
|
|
172
|
-
complete: helpers.complete(),
|
|
173
|
-
scope: args.scope,
|
|
174
|
-
author: "drive-memory",
|
|
175
|
-
tab: args.tab,
|
|
176
|
-
save: args.yes,
|
|
177
|
-
withWrite: (write) => run(doc, write),
|
|
178
|
-
});
|
|
179
|
-
output(itemOf({ ...result, saved: result.saved.map((item) => ("type" in item ? factItem(item) : memoryItem(item))) }));
|
|
180
|
-
});
|
|
181
|
-
const facts = annotate(program.command("facts"), { effects: LOCAL_READ }).description("what happened, as a document shows it; an agent's stay proposed until confirmed");
|
|
182
|
-
const factArgument = "fact:<id> reference, as facts list prints it";
|
|
183
|
-
examples(annotate(facts.command("add"), { effects: LOCAL_WRITE }).description("record a fact a document shows"), [
|
|
184
|
-
`drive personal facts add DOC_ID "Budget approved" --type decision --scope work`,
|
|
185
|
-
])
|
|
186
|
-
.argument("<document>", documentArgument)
|
|
187
|
-
.argument("<statement>", "the fact, in one sentence")
|
|
188
|
-
.addOption(new Option("--type <type>", "what kind of fact it is").choices(FACT_TYPES).default("fact"))
|
|
189
|
-
.addOption(scope("whose fact it is: personal or work"))
|
|
190
|
-
.option("--supersedes <ref>", "a decision only: the decision this one replaces")
|
|
191
|
-
.option("--occurred-time <time>", "when it happened, as the evidence shows, ISO 8601; a time without a zone is read in this computer's zone, a date alone as its midnight")
|
|
192
|
-
.action(async (doc, statement, { occurredTime, ...args }) => output(itemOf(factItem(await run(doc, (k, p, ref) => k.addFact(p, ref, {
|
|
193
|
-
statement,
|
|
194
|
-
...args,
|
|
195
|
-
by: author(),
|
|
196
|
-
...(occurredTime === undefined ? {} : { occurredAt: occurredTime }),
|
|
197
|
-
}))))));
|
|
198
|
-
withQuery(examples(annotate(facts.command("list"), { effects: LOCAL_READ }).description("list a document's facts"), [
|
|
199
|
-
"drive personal facts list DOC_ID status:proposed",
|
|
200
|
-
"drive personal facts list DOC_ID kind:decision",
|
|
201
|
-
]).argument("<document>", documentArgument), FACT_QUERY)
|
|
202
|
-
.option("--limit <n>", "how many facts to return", positive, 50)
|
|
203
|
-
.action(async (doc, words, { limit }) => {
|
|
204
|
-
const terms = queryTerms(words, FACT_QUERY, "facts list");
|
|
205
|
-
const filters = {
|
|
206
|
-
...(terms.has("kind") ? { type: terms.get("kind") } : {}),
|
|
207
|
-
...(terms.has("status") ? { status: terms.get("status") } : {}),
|
|
208
|
-
};
|
|
209
|
-
output(allOf((await run(doc, (k, p, ref) => k.facts(p, ref, { ...filters, limit }))).items.map(factItem)));
|
|
210
|
-
});
|
|
211
|
-
const factActions = {
|
|
212
|
-
show: "show one fact",
|
|
213
|
-
confirm: "confirm a proposed fact; a decision it supersedes stops holding",
|
|
214
|
-
reverse: "an accepted decision no longer holds, and nothing replaced it",
|
|
215
|
-
};
|
|
216
|
-
for (const [action, description] of Object.entries(factActions))
|
|
217
|
-
examples(annotate(facts.command(action), { effects: action === "show" ? LOCAL_READ : LOCAL_WRITE }).description(description), [`drive personal facts ${action} DOC_ID fact:FACT_ID`])
|
|
218
|
-
.argument("<document>", documentArgument)
|
|
219
|
-
.argument("<fact>", factArgument)
|
|
220
|
-
.action(async (doc, factRef) => output(itemOf(factItem(await run(doc, (k, p, ref) => action === "show" ? k.fact(p, ref, factRef) : k.fact(p, ref, factRef, action, decider()))))));
|
|
221
|
-
const identities = annotate(program.command("identities"), { effects: LOCAL_READ }).description("the Google accounts seen on a document, and the people they belong to");
|
|
222
|
-
bindQuery(examples(annotate(identities.command("list"), { effects: LOCAL_READ }).description("list the owners and last editor Google shows for a document"), ["drive personal identities list DOC_ID"]).argument("<document>", documentArgument), IDENTITIES_QUERY, identityRow).action(async (doc, words) => {
|
|
223
|
-
const filter = termsOf(words, IDENTITIES_QUERY, "identities list");
|
|
224
|
-
output(itemOf(await run(doc, (k, p, ref) => k.people(p, ref, filter))));
|
|
225
|
-
});
|
|
226
|
-
examples(annotate(identities.command("link"), { effects: LOCAL_WRITE }).description("record that a Google account belongs to a known person"), ["drive personal identities link DOC_ID GOOGLE_ID person:PERSON_UID"])
|
|
227
|
-
.argument("<document>", documentArgument)
|
|
228
|
-
.argument("<google-id>", "Google account id, as identities list prints it")
|
|
229
|
-
.argument("<person>", "person:<uid> reference of someone already known")
|
|
230
|
-
.action(async (doc, googleId, personRef) => output(itemOf(await run(doc, (k, p, ref) => k.linkPerson(p, ref, googleId, personRef)))));
|
|
231
|
-
};
|
|
232
|
-
export const installKnowledgeCommands = (...args) => {
|
|
233
|
-
const reference = sharedCommandTemplate(DRIVE_APP, "notes");
|
|
234
|
-
customizeSharedCommand(reference, "Drive notes annotate one explicitly selected imported document; document-bound arguments and receipts replace the generic note scope.", () => {
|
|
235
|
-
installKnowledgeCommandsDefinition(...args);
|
|
236
|
-
const command = args[0].commands.find((command) => command.name() === "notes");
|
|
237
|
-
if (!command)
|
|
238
|
-
throw new Error("notes builder did not install its command");
|
|
239
|
-
return command;
|
|
240
|
-
}, reviewedOverrides(reference, SHELL_OVERRIDES.notes));
|
|
241
|
-
};
|
|
1
|
+
import { addDocumentKnowledgeCommands } from "@wirecat/cli-core/documents/cli";
|
|
2
|
+
import { DRIVE_WORDS } from "./context.js";
|
|
3
|
+
export const installKnowledgeCommands = (program, helpers) => addDocumentKnowledgeCommands(program, { ...helpers, words: DRIVE_WORDS });
|
|
242
4
|
//# sourceMappingURL=knowledge.js.map
|