@wirecat/files-cli 0.1.0 → 0.2.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/CHANGELOG.md +29 -0
- package/README.md +2 -2
- package/contracts/wirecat.json +42 -0
- package/dist/bin/files.js +2 -2
- package/dist/bundle/{chunk-GNDPV4HK.js → chunk-3GCXH3WT.js} +1 -1
- package/dist/bundle/files.js +2 -2
- package/dist/bundle/{program-EN7Z757N.js → program-OBKXQ4VY.js} +498 -310
- package/dist/config.js +10 -1
- package/dist/doctor.js +33 -0
- package/dist/entities.js +1 -0
- package/dist/import/readers.js +10 -3
- package/dist/notes/bound.js +7 -5
- package/dist/notes/files.js +6 -0
- package/dist/notes/folders.js +6 -4
- package/dist/notes/import.js +67 -12
- package/dist/notes/links.js +3 -1
- package/dist/people/command.js +92 -0
- package/dist/program.js +4 -1
- package/dist/sources/read.js +2 -1
- package/dist/sync.js +35 -9
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/skills/files-cli/SKILL.md +1 -1
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
__name,
|
|
9
9
|
__require,
|
|
10
10
|
__toESM
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-3GCXH3WT.js";
|
|
12
12
|
|
|
13
13
|
// node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/identity.js
|
|
14
14
|
var require_identity = __commonJS({
|
|
@@ -4083,10 +4083,10 @@ var require_resolve_block_map = __commonJS({
|
|
|
4083
4083
|
let offset = bm.offset;
|
|
4084
4084
|
let commentEnd = null;
|
|
4085
4085
|
for (const collItem of bm.items) {
|
|
4086
|
-
const { start, key, sep:
|
|
4086
|
+
const { start, key, sep: sep7, value } = collItem;
|
|
4087
4087
|
const keyProps = resolveProps.resolveProps(start, {
|
|
4088
4088
|
indicator: "explicit-key-ind",
|
|
4089
|
-
next: key ??
|
|
4089
|
+
next: key ?? sep7?.[0],
|
|
4090
4090
|
offset,
|
|
4091
4091
|
onError,
|
|
4092
4092
|
parentIndent: bm.indent,
|
|
@@ -4100,7 +4100,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
4100
4100
|
else if ("indent" in key && key.indent !== bm.indent)
|
|
4101
4101
|
onError(offset, "BAD_INDENT", startColMsg);
|
|
4102
4102
|
}
|
|
4103
|
-
if (!keyProps.anchor && !keyProps.tag && !
|
|
4103
|
+
if (!keyProps.anchor && !keyProps.tag && !sep7) {
|
|
4104
4104
|
commentEnd = keyProps.end;
|
|
4105
4105
|
if (keyProps.comment) {
|
|
4106
4106
|
if (map.comment)
|
|
@@ -4124,7 +4124,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
4124
4124
|
ctx.atKey = false;
|
|
4125
4125
|
if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
|
|
4126
4126
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
4127
|
-
const valueProps = resolveProps.resolveProps(
|
|
4127
|
+
const valueProps = resolveProps.resolveProps(sep7 ?? [], {
|
|
4128
4128
|
indicator: "map-value-ind",
|
|
4129
4129
|
next: value,
|
|
4130
4130
|
offset: keyNode.range[2],
|
|
@@ -4140,7 +4140,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
4140
4140
|
if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
|
|
4141
4141
|
onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
|
|
4142
4142
|
}
|
|
4143
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset,
|
|
4143
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep7, null, valueProps, onError);
|
|
4144
4144
|
if (ctx.schema.compat)
|
|
4145
4145
|
utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
|
|
4146
4146
|
offset = valueNode.range[2];
|
|
@@ -4233,7 +4233,7 @@ var require_resolve_end = __commonJS({
|
|
|
4233
4233
|
let comment = "";
|
|
4234
4234
|
if (end) {
|
|
4235
4235
|
let hasSpace = false;
|
|
4236
|
-
let
|
|
4236
|
+
let sep7 = "";
|
|
4237
4237
|
for (const token of end) {
|
|
4238
4238
|
const { source, type } = token;
|
|
4239
4239
|
switch (type) {
|
|
@@ -4247,13 +4247,13 @@ var require_resolve_end = __commonJS({
|
|
|
4247
4247
|
if (!comment)
|
|
4248
4248
|
comment = cb;
|
|
4249
4249
|
else
|
|
4250
|
-
comment +=
|
|
4251
|
-
|
|
4250
|
+
comment += sep7 + cb;
|
|
4251
|
+
sep7 = "";
|
|
4252
4252
|
break;
|
|
4253
4253
|
}
|
|
4254
4254
|
case "newline":
|
|
4255
4255
|
if (comment)
|
|
4256
|
-
|
|
4256
|
+
sep7 += source;
|
|
4257
4257
|
hasSpace = true;
|
|
4258
4258
|
break;
|
|
4259
4259
|
default:
|
|
@@ -4297,18 +4297,18 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4297
4297
|
let offset = fc.offset + fc.start.source.length;
|
|
4298
4298
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
4299
4299
|
const collItem = fc.items[i];
|
|
4300
|
-
const { start, key, sep:
|
|
4300
|
+
const { start, key, sep: sep7, value } = collItem;
|
|
4301
4301
|
const props = resolveProps.resolveProps(start, {
|
|
4302
4302
|
flow: fcName,
|
|
4303
4303
|
indicator: "explicit-key-ind",
|
|
4304
|
-
next: key ??
|
|
4304
|
+
next: key ?? sep7?.[0],
|
|
4305
4305
|
offset,
|
|
4306
4306
|
onError,
|
|
4307
4307
|
parentIndent: fc.indent,
|
|
4308
4308
|
startOnNewline: false
|
|
4309
4309
|
});
|
|
4310
4310
|
if (!props.found) {
|
|
4311
|
-
if (!props.anchor && !props.tag && !
|
|
4311
|
+
if (!props.anchor && !props.tag && !sep7 && !value) {
|
|
4312
4312
|
if (i === 0 && props.comma)
|
|
4313
4313
|
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
|
|
4314
4314
|
else if (i < fc.items.length - 1)
|
|
@@ -4362,8 +4362,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4362
4362
|
}
|
|
4363
4363
|
}
|
|
4364
4364
|
}
|
|
4365
|
-
if (!isMap && !
|
|
4366
|
-
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end,
|
|
4365
|
+
if (!isMap && !sep7 && !props.found) {
|
|
4366
|
+
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep7, null, props, onError);
|
|
4367
4367
|
coll.items.push(valueNode);
|
|
4368
4368
|
offset = valueNode.range[2];
|
|
4369
4369
|
if (isBlock(value))
|
|
@@ -4375,7 +4375,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4375
4375
|
if (isBlock(key))
|
|
4376
4376
|
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
4377
4377
|
ctx.atKey = false;
|
|
4378
|
-
const valueProps = resolveProps.resolveProps(
|
|
4378
|
+
const valueProps = resolveProps.resolveProps(sep7 ?? [], {
|
|
4379
4379
|
flow: fcName,
|
|
4380
4380
|
indicator: "map-value-ind",
|
|
4381
4381
|
next: value,
|
|
@@ -4386,8 +4386,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4386
4386
|
});
|
|
4387
4387
|
if (valueProps.found) {
|
|
4388
4388
|
if (!isMap && !props.found && ctx.options.strict) {
|
|
4389
|
-
if (
|
|
4390
|
-
for (const st of
|
|
4389
|
+
if (sep7)
|
|
4390
|
+
for (const st of sep7) {
|
|
4391
4391
|
if (st === valueProps.found)
|
|
4392
4392
|
break;
|
|
4393
4393
|
if (st.type === "newline") {
|
|
@@ -4404,7 +4404,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4404
4404
|
else
|
|
4405
4405
|
onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
|
|
4406
4406
|
}
|
|
4407
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end,
|
|
4407
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep7, null, valueProps, onError) : null;
|
|
4408
4408
|
if (valueNode) {
|
|
4409
4409
|
if (isBlock(value))
|
|
4410
4410
|
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
@@ -4587,7 +4587,7 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
4587
4587
|
chompStart = i + 1;
|
|
4588
4588
|
}
|
|
4589
4589
|
let value = "";
|
|
4590
|
-
let
|
|
4590
|
+
let sep7 = "";
|
|
4591
4591
|
let prevMoreIndented = false;
|
|
4592
4592
|
for (let i = 0; i < contentStart; ++i)
|
|
4593
4593
|
value += lines[i][0].slice(trimIndent) + "\n";
|
|
@@ -4604,24 +4604,24 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
4604
4604
|
indent = "";
|
|
4605
4605
|
}
|
|
4606
4606
|
if (type === Scalar.Scalar.BLOCK_LITERAL) {
|
|
4607
|
-
value +=
|
|
4608
|
-
|
|
4607
|
+
value += sep7 + indent.slice(trimIndent) + content;
|
|
4608
|
+
sep7 = "\n";
|
|
4609
4609
|
} else if (indent.length > trimIndent || content[0] === " ") {
|
|
4610
|
-
if (
|
|
4611
|
-
|
|
4612
|
-
else if (!prevMoreIndented &&
|
|
4613
|
-
|
|
4614
|
-
value +=
|
|
4615
|
-
|
|
4610
|
+
if (sep7 === " ")
|
|
4611
|
+
sep7 = "\n";
|
|
4612
|
+
else if (!prevMoreIndented && sep7 === "\n")
|
|
4613
|
+
sep7 = "\n\n";
|
|
4614
|
+
value += sep7 + indent.slice(trimIndent) + content;
|
|
4615
|
+
sep7 = "\n";
|
|
4616
4616
|
prevMoreIndented = true;
|
|
4617
4617
|
} else if (content === "") {
|
|
4618
|
-
if (
|
|
4618
|
+
if (sep7 === "\n")
|
|
4619
4619
|
value += "\n";
|
|
4620
4620
|
else
|
|
4621
|
-
|
|
4621
|
+
sep7 = "\n";
|
|
4622
4622
|
} else {
|
|
4623
|
-
value +=
|
|
4624
|
-
|
|
4623
|
+
value += sep7 + content;
|
|
4624
|
+
sep7 = " ";
|
|
4625
4625
|
prevMoreIndented = false;
|
|
4626
4626
|
}
|
|
4627
4627
|
}
|
|
@@ -4810,25 +4810,25 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
4810
4810
|
trimBoth = /^[ \t]+|[ \t]+$/g;
|
|
4811
4811
|
}
|
|
4812
4812
|
let res = match[1].replace(trimEnd, "");
|
|
4813
|
-
let
|
|
4813
|
+
let sep7 = " ";
|
|
4814
4814
|
let pos = line2.lastIndex;
|
|
4815
4815
|
while (match = line2.exec(source)) {
|
|
4816
4816
|
const lm = match[1].replace(trimBoth, "");
|
|
4817
4817
|
if (lm === "") {
|
|
4818
|
-
if (
|
|
4819
|
-
res +=
|
|
4818
|
+
if (sep7 === "\n")
|
|
4819
|
+
res += sep7;
|
|
4820
4820
|
else
|
|
4821
|
-
|
|
4821
|
+
sep7 = "\n";
|
|
4822
4822
|
} else {
|
|
4823
|
-
res +=
|
|
4824
|
-
|
|
4823
|
+
res += sep7 + lm;
|
|
4824
|
+
sep7 = " ";
|
|
4825
4825
|
}
|
|
4826
4826
|
pos = line2.lastIndex;
|
|
4827
4827
|
}
|
|
4828
4828
|
const last = /[ \t]*(.*)/sy;
|
|
4829
4829
|
last.lastIndex = pos;
|
|
4830
4830
|
match = last.exec(source);
|
|
4831
|
-
return res +
|
|
4831
|
+
return res + sep7 + (match?.[1] ?? "");
|
|
4832
4832
|
}
|
|
4833
4833
|
__name(unfoldLines, "unfoldLines");
|
|
4834
4834
|
function doubleQuotedValue(source, onError) {
|
|
@@ -5662,14 +5662,14 @@ var require_cst_stringify = __commonJS({
|
|
|
5662
5662
|
}
|
|
5663
5663
|
}
|
|
5664
5664
|
__name(stringifyToken, "stringifyToken");
|
|
5665
|
-
function stringifyItem({ start, key, sep:
|
|
5665
|
+
function stringifyItem({ start, key, sep: sep7, value }) {
|
|
5666
5666
|
let res = "";
|
|
5667
5667
|
for (const st of start)
|
|
5668
5668
|
res += st.source;
|
|
5669
5669
|
if (key)
|
|
5670
5670
|
res += stringifyToken(key);
|
|
5671
|
-
if (
|
|
5672
|
-
for (const st of
|
|
5671
|
+
if (sep7)
|
|
5672
|
+
for (const st of sep7)
|
|
5673
5673
|
res += st.source;
|
|
5674
5674
|
if (value)
|
|
5675
5675
|
res += stringifyToken(value);
|
|
@@ -6858,18 +6858,18 @@ var require_parser = __commonJS({
|
|
|
6858
6858
|
if (this.type === "map-value-ind") {
|
|
6859
6859
|
const prev = getPrevProps(this.peek(2));
|
|
6860
6860
|
const start = getFirstKeyStartProps(prev);
|
|
6861
|
-
let
|
|
6861
|
+
let sep7;
|
|
6862
6862
|
if (scalar.end) {
|
|
6863
|
-
|
|
6864
|
-
|
|
6863
|
+
sep7 = scalar.end;
|
|
6864
|
+
sep7.push(this.sourceToken);
|
|
6865
6865
|
delete scalar.end;
|
|
6866
6866
|
} else
|
|
6867
|
-
|
|
6867
|
+
sep7 = [this.sourceToken];
|
|
6868
6868
|
const map = {
|
|
6869
6869
|
type: "block-map",
|
|
6870
6870
|
offset: scalar.offset,
|
|
6871
6871
|
indent: scalar.indent,
|
|
6872
|
-
items: [{ start, key: scalar, sep:
|
|
6872
|
+
items: [{ start, key: scalar, sep: sep7 }]
|
|
6873
6873
|
};
|
|
6874
6874
|
this.onKeyLine = true;
|
|
6875
6875
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -7022,15 +7022,15 @@ var require_parser = __commonJS({
|
|
|
7022
7022
|
} else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
|
|
7023
7023
|
const start2 = getFirstKeyStartProps(it.start);
|
|
7024
7024
|
const key = it.key;
|
|
7025
|
-
const
|
|
7026
|
-
|
|
7025
|
+
const sep7 = it.sep;
|
|
7026
|
+
sep7.push(this.sourceToken);
|
|
7027
7027
|
delete it.key;
|
|
7028
7028
|
delete it.sep;
|
|
7029
7029
|
this.stack.push({
|
|
7030
7030
|
type: "block-map",
|
|
7031
7031
|
offset: this.offset,
|
|
7032
7032
|
indent: this.indent,
|
|
7033
|
-
items: [{ start: start2, key, sep:
|
|
7033
|
+
items: [{ start: start2, key, sep: sep7 }]
|
|
7034
7034
|
});
|
|
7035
7035
|
} else if (start.length > 0) {
|
|
7036
7036
|
it.sep = it.sep.concat(start, this.sourceToken);
|
|
@@ -7224,13 +7224,13 @@ var require_parser = __commonJS({
|
|
|
7224
7224
|
const prev = getPrevProps(parent);
|
|
7225
7225
|
const start = getFirstKeyStartProps(prev);
|
|
7226
7226
|
fixFlowSeqItems(fc);
|
|
7227
|
-
const
|
|
7228
|
-
|
|
7227
|
+
const sep7 = fc.end.splice(1, fc.end.length);
|
|
7228
|
+
sep7.push(this.sourceToken);
|
|
7229
7229
|
const map = {
|
|
7230
7230
|
type: "block-map",
|
|
7231
7231
|
offset: fc.offset,
|
|
7232
7232
|
indent: fc.indent,
|
|
7233
|
-
items: [{ start, key: fc, sep:
|
|
7233
|
+
items: [{ start, key: fc, sep: sep7 }]
|
|
7234
7234
|
};
|
|
7235
7235
|
this.onKeyLine = true;
|
|
7236
7236
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -7514,7 +7514,7 @@ var require_dist = __commonJS({
|
|
|
7514
7514
|
});
|
|
7515
7515
|
|
|
7516
7516
|
// dist/program.js
|
|
7517
|
-
import { join as
|
|
7517
|
+
import { join as join14 } from "node:path";
|
|
7518
7518
|
import { processStreams, resolvePaths as resolvePaths6 } from "@wirecat/cli-base";
|
|
7519
7519
|
import { appDoctorCommand, appMcpCommand, appUpdate, commandsCommand, configCommand, createProgram as createSharedProgram, outputFor as outputFor2, run as runShared, runsCommand, skillCommand, upgradeCommand } from "@wirecat/cli-core";
|
|
7520
7520
|
import { Command } from "commander";
|
|
@@ -7528,7 +7528,8 @@ var STORE_CLIENT = { command: APP.command, version: APP.version };
|
|
|
7528
7528
|
|
|
7529
7529
|
// dist/config.js
|
|
7530
7530
|
import { CliError, configFilePath, resolvePaths, saveConfigFile } from "@wirecat/cli-base";
|
|
7531
|
-
import { commandPermissions, DEFAULT_DECISION_POLICY, issueMessage, onThisComputer, readConfigFile, settingsFor } from "@wirecat/cli-core";
|
|
7531
|
+
import { baseContext, commandPermissions, DEFAULT_DECISION_POLICY, fromFile, issueMessage, onThisComputer, readConfigFile, settingsFor } from "@wirecat/cli-core";
|
|
7532
|
+
import { DOCUMENT_SCAN_SETTINGS } from "@wirecat/cli-core/documents";
|
|
7532
7533
|
|
|
7533
7534
|
// node_modules/.pnpm/valibot@1.5.0_typescript@7.0.2/node_modules/valibot/dist/index.mjs
|
|
7534
7535
|
var store$4;
|
|
@@ -8147,11 +8148,16 @@ var NOTE_EXTENSIONS = [
|
|
|
8147
8148
|
".ods",
|
|
8148
8149
|
".pptx",
|
|
8149
8150
|
".epub",
|
|
8151
|
+
".odp",
|
|
8150
8152
|
".doc",
|
|
8153
|
+
".rtf",
|
|
8154
|
+
// cli-core has no reader for it: listed so the sync names it as not read instead of passing it over.
|
|
8151
8155
|
".xls",
|
|
8152
8156
|
".html",
|
|
8153
8157
|
".htm"
|
|
8154
8158
|
];
|
|
8159
|
+
var PICTURE_EXTENSIONS = [".jpg", ".jpeg", ".png", ".webp"];
|
|
8160
|
+
var isPicturePath = /* @__PURE__ */ __name((path) => PICTURE_EXTENSIONS.some((extension) => path.toLowerCase().endsWith(extension)), "isPicturePath");
|
|
8155
8161
|
var MEMO_ID = /^---\r?\n(?:[^\n]*\n)*?memo-id:[ \t]*["']?([^"'\s]+)/;
|
|
8156
8162
|
var HEAD = 1024;
|
|
8157
8163
|
var readMemoId = /* @__PURE__ */ __name((path) => {
|
|
@@ -8379,8 +8385,14 @@ var OwnSchema = object({ notes: optional(NotesSchema), sources: optional(Sources
|
|
|
8379
8385
|
var permissions = commandPermissions();
|
|
8380
8386
|
var configuration = settingsFor(IDENTITY, {
|
|
8381
8387
|
permissions,
|
|
8382
|
-
defaults: { notes: optional(NotesSchema), sources: optional(SourcesSchema) }
|
|
8388
|
+
defaults: { notes: optional(NotesSchema), sources: optional(SourcesSchema) },
|
|
8389
|
+
profile: DOCUMENT_SCAN_SETTINGS.profile,
|
|
8390
|
+
settings: DOCUMENT_SCAN_SETTINGS.settings
|
|
8383
8391
|
});
|
|
8392
|
+
var readScans = /* @__PURE__ */ __name((command) => {
|
|
8393
|
+
const { settings } = baseContext(command, (flags, options) => configuration.resolveSettings(flags, { ...options, needsProfile: false }));
|
|
8394
|
+
return fromFile(settings, "read_scans", "local").value;
|
|
8395
|
+
}, "readScans");
|
|
8384
8396
|
var configPath = /* @__PURE__ */ __name((env = process.env) => configFilePath(resolvePaths({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }).config), "configPath");
|
|
8385
8397
|
var rawConfig = /* @__PURE__ */ __name((env) => {
|
|
8386
8398
|
const read = readConfigFile(configPath(env));
|
|
@@ -8458,6 +8470,107 @@ var answers = /* @__PURE__ */ __name((program, _streams, env) => {
|
|
|
8458
8470
|
};
|
|
8459
8471
|
}, "answers");
|
|
8460
8472
|
|
|
8473
|
+
// dist/doctor.js
|
|
8474
|
+
import { existsSync } from "node:fs";
|
|
8475
|
+
|
|
8476
|
+
// dist/notes/folders.js
|
|
8477
|
+
import { realpathSync, statSync } from "node:fs";
|
|
8478
|
+
import { basename, dirname, join as join2, resolve, sep as sep2 } from "node:path";
|
|
8479
|
+
import { CliError as CliError2 } from "@wirecat/cli-base";
|
|
8480
|
+
var entryOf = /* @__PURE__ */ __name((entry) => typeof entry === "string" ? { id: null, path: resolve(entry), format: "obsidian" } : { id: entry.id, path: resolve(entry.path), format: entry.format ?? "obsidian" }, "entryOf");
|
|
8481
|
+
var noteFolders = /* @__PURE__ */ __name((notes) => (notes?.folders ?? []).map(entryOf), "noteFolders");
|
|
8482
|
+
var written = /* @__PURE__ */ __name((folder) => ({
|
|
8483
|
+
id: folder.id,
|
|
8484
|
+
path: folder.path,
|
|
8485
|
+
...folder.format === "obsidian" ? {} : { format: folder.format }
|
|
8486
|
+
}), "written");
|
|
8487
|
+
var withFolders = /* @__PURE__ */ __name((config, folders) => ({
|
|
8488
|
+
...config,
|
|
8489
|
+
notes: {
|
|
8490
|
+
...config.notes,
|
|
8491
|
+
folders: folders.map((folder) => folder.id === null ? folder.path : written(folder))
|
|
8492
|
+
}
|
|
8493
|
+
}), "withFolders");
|
|
8494
|
+
var bindFolder = /* @__PURE__ */ __name((config, folder) => {
|
|
8495
|
+
const at = resolve(folder.path);
|
|
8496
|
+
const folders = noteFolders(config.notes);
|
|
8497
|
+
const index = folders.findIndex((other) => other.path === at);
|
|
8498
|
+
const bound = { ...folder, path: at };
|
|
8499
|
+
const kept = folders.map((other, position) => position === index ? bound : other).filter((other, position) => position === index || other.id !== folder.id && other.path !== at);
|
|
8500
|
+
return withFolders(config, index < 0 ? [...kept, bound] : kept);
|
|
8501
|
+
}, "bindFolder");
|
|
8502
|
+
var attachFolder = /* @__PURE__ */ __name((config, id, path, format) => {
|
|
8503
|
+
const at = resolve(path);
|
|
8504
|
+
const folders = noteFolders(config.notes);
|
|
8505
|
+
const taken = folders.find((folder2) => folder2.path === at && folder2.id !== null && folder2.id !== id);
|
|
8506
|
+
if (taken)
|
|
8507
|
+
throw new CliError2("validation_error", `${at} is already folder ${taken.id} \u2014 attach that id elsewhere first, or remove it from the config`);
|
|
8508
|
+
const previous = folders.find((folder2) => folder2.id === id);
|
|
8509
|
+
const folder = { id, path: at, format: format ?? previous?.format ?? "obsidian" };
|
|
8510
|
+
const kept = folders.filter((other) => other.id !== id && other.path !== at);
|
|
8511
|
+
return { config: withFolders(config, [...kept, folder]), folder };
|
|
8512
|
+
}, "attachFolder");
|
|
8513
|
+
var unbindFolder = /* @__PURE__ */ __name((config, path) => withFolders(config, noteFolders(config.notes).filter((folder) => folder.path !== resolve(path))), "unbindFolder");
|
|
8514
|
+
var real = /* @__PURE__ */ __name((path) => {
|
|
8515
|
+
const at = resolve(path);
|
|
8516
|
+
try {
|
|
8517
|
+
return realpathSync(at);
|
|
8518
|
+
} catch {
|
|
8519
|
+
const parent = dirname(at);
|
|
8520
|
+
return parent === at ? at : join2(real(parent), basename(at));
|
|
8521
|
+
}
|
|
8522
|
+
}, "real");
|
|
8523
|
+
var detectFormat = /* @__PURE__ */ __name((path) => {
|
|
8524
|
+
for (let at = real(path); ; at = dirname(at)) {
|
|
8525
|
+
try {
|
|
8526
|
+
if (statSync(join2(at, ".obsidian")).isDirectory())
|
|
8527
|
+
return "obsidian";
|
|
8528
|
+
} catch {
|
|
8529
|
+
}
|
|
8530
|
+
if (dirname(at) === at)
|
|
8531
|
+
return "markdown";
|
|
8532
|
+
}
|
|
8533
|
+
}, "detectFormat");
|
|
8534
|
+
var comparable = /* @__PURE__ */ __name((path) => process.platform === "darwin" || process.platform === "win32" ? real(path).toLowerCase() : real(path), "comparable");
|
|
8535
|
+
var inside = /* @__PURE__ */ __name((child, parent) => child.startsWith(parent.endsWith(sep2) ? parent : `${parent}${sep2}`), "inside");
|
|
8536
|
+
var overlapping = /* @__PURE__ */ __name((folders, path) => {
|
|
8537
|
+
const at = comparable(path);
|
|
8538
|
+
return folders.filter((folder) => {
|
|
8539
|
+
const other = comparable(folder.path);
|
|
8540
|
+
return other !== at && (inside(at, other) || inside(other, at));
|
|
8541
|
+
});
|
|
8542
|
+
}, "overlapping");
|
|
8543
|
+
|
|
8544
|
+
// dist/doctor.js
|
|
8545
|
+
var notesFolderCheck = /* @__PURE__ */ __name((env) => {
|
|
8546
|
+
const configured = noteFolders(loadConfig(env).notes);
|
|
8547
|
+
const problems = [];
|
|
8548
|
+
for (const [index, folder] of configured.entries())
|
|
8549
|
+
for (const other of overlapping(configured.slice(index + 1), folder.path))
|
|
8550
|
+
problems.push({
|
|
8551
|
+
what: `the notes folders ${folder.path} and ${other.path} overlap, so the files they share are read twice`,
|
|
8552
|
+
fix: `files folders remove "${other.path}" (or the other one)`
|
|
8553
|
+
});
|
|
8554
|
+
const folders = configured.map(({ path, id }) => ({ path, exists: existsSync(path), bound: id !== null }));
|
|
8555
|
+
for (const folder of folders) {
|
|
8556
|
+
if (!folder.exists)
|
|
8557
|
+
problems.push({
|
|
8558
|
+
what: `the notes folder ${folder.path} is missing`,
|
|
8559
|
+
fix: "connect its disk; if it moved, files folders update <id> <new path>"
|
|
8560
|
+
});
|
|
8561
|
+
else if (!folder.bound)
|
|
8562
|
+
problems.push({
|
|
8563
|
+
what: `the notes folder ${folder.path} has no folder id`,
|
|
8564
|
+
fix: `files folders add "${folder.path}"`
|
|
8565
|
+
});
|
|
8566
|
+
}
|
|
8567
|
+
return {
|
|
8568
|
+
fields: { notes_folders: folders, problems },
|
|
8569
|
+
notes: problems.map(({ what, fix }) => `${what} \u2014 ${fix}`),
|
|
8570
|
+
failing: problems.length > 0
|
|
8571
|
+
};
|
|
8572
|
+
}, "notesFolderCheck");
|
|
8573
|
+
|
|
8461
8574
|
// dist/entities.js
|
|
8462
8575
|
import { metaOf } from "@wirecat/cli-base/commands";
|
|
8463
8576
|
import { answerEntity, answerFields } from "@wirecat/cli-core";
|
|
@@ -8494,6 +8607,7 @@ var OWN_FIELDS = {
|
|
|
8494
8607
|
"cut"
|
|
8495
8608
|
],
|
|
8496
8609
|
notes_folder: ["id", "name", "path", "format", "kept_by"],
|
|
8610
|
+
person_note_links: ["person", "name", "files"],
|
|
8497
8611
|
source_detail: [
|
|
8498
8612
|
"ref",
|
|
8499
8613
|
"title",
|
|
@@ -8557,7 +8671,7 @@ var declareOwnAnswers = /* @__PURE__ */ __name((command) => {
|
|
|
8557
8671
|
}, "declareOwnAnswers");
|
|
8558
8672
|
|
|
8559
8673
|
// dist/import/command.js
|
|
8560
|
-
import { CliError as
|
|
8674
|
+
import { CliError as CliError8 } from "@wirecat/cli-base";
|
|
8561
8675
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
8562
8676
|
import { environmentOf as environmentOf2, ingestLines as ingestLines2, LOCAL_WRITE, providerNamed } from "@wirecat/cli-core";
|
|
8563
8677
|
|
|
@@ -8565,7 +8679,7 @@ import { environmentOf as environmentOf2, ingestLines as ingestLines2, LOCAL_WRI
|
|
|
8565
8679
|
import { openSync as openSync2 } from "node:fs";
|
|
8566
8680
|
import { createInterface } from "node:readline";
|
|
8567
8681
|
import { ReadStream } from "node:tty";
|
|
8568
|
-
import { CliError as
|
|
8682
|
+
import { CliError as CliError3 } from "@wirecat/cli-base";
|
|
8569
8683
|
import { environmentOf } from "@wirecat/cli-core";
|
|
8570
8684
|
|
|
8571
8685
|
// dist/terminal.js
|
|
@@ -8595,7 +8709,7 @@ var fromTerminal = /* @__PURE__ */ __name(async (question) => {
|
|
|
8595
8709
|
const reader2 = createInterface({ input, output: process.stderr, terminal: true });
|
|
8596
8710
|
try {
|
|
8597
8711
|
return await new Promise((resolve6, reject) => {
|
|
8598
|
-
const cancel = /* @__PURE__ */ __name(() => reject(new
|
|
8712
|
+
const cancel = /* @__PURE__ */ __name(() => reject(new CliError3("cancelled", "cancelled \u2014 nothing was done")), "cancel");
|
|
8599
8713
|
reader2.once("SIGINT", cancel);
|
|
8600
8714
|
reader2.once("close", cancel);
|
|
8601
8715
|
reader2.question(question, resolve6);
|
|
@@ -8615,15 +8729,15 @@ var ownerSays = /* @__PURE__ */ __name(async (command, question) => {
|
|
|
8615
8729
|
const machine = command.optsWithGlobals().json !== void 0;
|
|
8616
8730
|
const answer = terminalOf(command).present && !machine ? await (terminalOf(command).answer ?? environmentOf(command).answer ?? fromTerminal)(`${question} [y/N] `) : null;
|
|
8617
8731
|
if (answer === null)
|
|
8618
|
-
throw new
|
|
8732
|
+
throw new CliError3("confirmation_required", "--as-owner asks at a terminal, and nobody is at one to answer; the owner runs it there, without --json", { reason: "decision.owner-unconfirmed" });
|
|
8619
8733
|
if (!/^\s*y(es)?\s*$/i.test(answer))
|
|
8620
|
-
throw new
|
|
8734
|
+
throw new CliError3("cancelled", "not done \u2014 the answer was no");
|
|
8621
8735
|
}, "ownerSays");
|
|
8622
8736
|
var isMcpRun = /* @__PURE__ */ __name((command, _env) => environmentOf(command).agent !== void 0, "isMcpRun");
|
|
8623
8737
|
var whoRuns = /* @__PURE__ */ __name(async (command, env, { asOwner = false, question }) => {
|
|
8624
8738
|
if (isMcpRun(command, env)) {
|
|
8625
8739
|
if (asOwner)
|
|
8626
|
-
throw new
|
|
8740
|
+
throw new CliError3("permission_error", "an agent cannot act as the owner; the owner runs this command");
|
|
8627
8741
|
return { bot: agentIn(env) ?? "files-mcp" };
|
|
8628
8742
|
}
|
|
8629
8743
|
if (command.opts().fromApp)
|
|
@@ -8642,7 +8756,7 @@ var reasonOption = /* @__PURE__ */ __name((command) => command.option("--reason
|
|
|
8642
8756
|
|
|
8643
8757
|
// dist/records/input.js
|
|
8644
8758
|
import { open } from "node:fs/promises";
|
|
8645
|
-
import { CliError as
|
|
8759
|
+
import { CliError as CliError4 } from "@wirecat/cli-base";
|
|
8646
8760
|
import { envelopeOfText, ingest, ingestLines, ingestVcard, isVcard, jsonlLines } from "@wirecat/cli-core";
|
|
8647
8761
|
var PHONE = "phone";
|
|
8648
8762
|
var BOM = /^\uFEFF/;
|
|
@@ -8659,12 +8773,12 @@ var linesOf = /* @__PURE__ */ __name(async (file, stdin) => {
|
|
|
8659
8773
|
return jsonlLines(handle.createReadStream({ encoding: "utf8" }));
|
|
8660
8774
|
} catch (error) {
|
|
8661
8775
|
if (errnoOf(error) === "ENOENT")
|
|
8662
|
-
throw new
|
|
8776
|
+
throw new CliError4("not_found", `no records file ${file}: give a file that exists, or - for stdin`, {
|
|
8663
8777
|
reason: "records.file-missing",
|
|
8664
8778
|
path: file
|
|
8665
8779
|
});
|
|
8666
8780
|
const why = errnoOf(error) === "EISDIR" ? "it is a folder" : errnoOf(error) === "EACCES" ? "no permission" : "unreadable";
|
|
8667
|
-
throw new
|
|
8781
|
+
throw new CliError4("validation_error", `the records file ${file} cannot be read: ${why}`, {
|
|
8668
8782
|
reason: "records.file-unreadable",
|
|
8669
8783
|
path: file,
|
|
8670
8784
|
why
|
|
@@ -8688,7 +8802,7 @@ var deviceOf = /* @__PURE__ */ __name((given) => {
|
|
|
8688
8802
|
if (at < 0)
|
|
8689
8803
|
return given;
|
|
8690
8804
|
if (given.slice(0, at) !== PHONE)
|
|
8691
|
-
throw new
|
|
8805
|
+
throw new CliError4("validation_error", "a vCard file holds a phone's contacts: --account phone:<device>", {
|
|
8692
8806
|
param: "--account"
|
|
8693
8807
|
});
|
|
8694
8808
|
return given.slice(at + 1);
|
|
@@ -8761,19 +8875,19 @@ var receiptText = /* @__PURE__ */ __name((receipt) => [
|
|
|
8761
8875
|
].join("\n"), "receiptText");
|
|
8762
8876
|
|
|
8763
8877
|
// dist/records/source.js
|
|
8764
|
-
import { CliError as
|
|
8878
|
+
import { CliError as CliError5 } from "@wirecat/cli-base";
|
|
8765
8879
|
var sourceOf = /* @__PURE__ */ __name((account) => {
|
|
8766
8880
|
const [provider = "", ...rest] = (account ?? "").trim().split(":");
|
|
8767
8881
|
const name = rest.join(":");
|
|
8768
8882
|
if (!provider || !name)
|
|
8769
|
-
throw new
|
|
8883
|
+
throw new CliError5("validation_error", "name the source as --account <provider>:<account>, such as sheet:rentals", {
|
|
8770
8884
|
param: "--account"
|
|
8771
8885
|
});
|
|
8772
8886
|
return { provider, account: name };
|
|
8773
8887
|
}, "sourceOf");
|
|
8774
8888
|
|
|
8775
8889
|
// dist/import/audio.js
|
|
8776
|
-
import { CliError as
|
|
8890
|
+
import { CliError as CliError6, isCliError } from "@wirecat/cli-base";
|
|
8777
8891
|
import { DEFAULT_ORDER, decodeAudio, installedBytes, isInstalled, megabytes, modelsDirectory, recognizeLocalPieces, runFfmpeg, speechModel } from "@wirecat/cli-core";
|
|
8778
8892
|
|
|
8779
8893
|
// dist/import/external-id.js
|
|
@@ -8781,8 +8895,8 @@ import { createHash } from "node:crypto";
|
|
|
8781
8895
|
var MOST = 180;
|
|
8782
8896
|
var HASHED_HEAD = 160;
|
|
8783
8897
|
var PLAIN = /[A-Za-z0-9._-]/;
|
|
8784
|
-
var idOfPath = /* @__PURE__ */ __name((
|
|
8785
|
-
const normalized =
|
|
8898
|
+
var idOfPath = /* @__PURE__ */ __name((relative6) => {
|
|
8899
|
+
const normalized = relative6.split(/[\\/]/).join("/").normalize("NFC");
|
|
8786
8900
|
let id = "";
|
|
8787
8901
|
for (const char of normalized) {
|
|
8788
8902
|
if (PLAIN.test(char))
|
|
@@ -8801,7 +8915,7 @@ var idOfPath = /* @__PURE__ */ __name((relative5) => {
|
|
|
8801
8915
|
import { createHash as createHash2 } from "node:crypto";
|
|
8802
8916
|
import { constants } from "node:fs";
|
|
8803
8917
|
import { lstat, open as open2, readdir, realpath } from "node:fs/promises";
|
|
8804
|
-
import { basename, extname, join as
|
|
8918
|
+
import { basename as basename2, extname, join as join3, relative as relative2, sep as sep3 } from "node:path";
|
|
8805
8919
|
import { pathToFileURL } from "node:url";
|
|
8806
8920
|
import { attachmentMaxBytes, readWhole, sizeText } from "@wirecat/cli-core/documents";
|
|
8807
8921
|
var MOST_FILES = 1e4;
|
|
@@ -8834,7 +8948,7 @@ var unreadable = /* @__PURE__ */ __name((error) => {
|
|
|
8834
8948
|
return "it disappeared while the import ran";
|
|
8835
8949
|
return `could not be read${error instanceof Error ? `: ${error.message}` : ""}`;
|
|
8836
8950
|
}, "unreadable");
|
|
8837
|
-
var isInside = /* @__PURE__ */ __name((root, path) => path === root || path.startsWith(root +
|
|
8951
|
+
var isInside = /* @__PURE__ */ __name((root, path) => path === root || path.startsWith(root + sep3), "isInside");
|
|
8838
8952
|
var walk = /* @__PURE__ */ __name(async (root) => {
|
|
8839
8953
|
const real2 = await realpath(root);
|
|
8840
8954
|
const files = [];
|
|
@@ -8843,7 +8957,7 @@ var walk = /* @__PURE__ */ __name(async (root) => {
|
|
|
8843
8957
|
if (!stat.isDirectory()) {
|
|
8844
8958
|
if (!stat.isFile())
|
|
8845
8959
|
return { files, skipped: [{ path: root, reason: "not a file or a folder" }], base: real2 };
|
|
8846
|
-
const name =
|
|
8960
|
+
const name = basename2(real2);
|
|
8847
8961
|
return {
|
|
8848
8962
|
files: [{ path: real2, relative: name, extension: extname(name).toLowerCase(), stat }],
|
|
8849
8963
|
skipped,
|
|
@@ -8859,15 +8973,15 @@ var walk = /* @__PURE__ */ __name(async (root) => {
|
|
|
8859
8973
|
try {
|
|
8860
8974
|
entries = await readdir(folder, { withFileTypes: true });
|
|
8861
8975
|
} catch (error) {
|
|
8862
|
-
skipped.push({ path: relative2(real2, folder).split(
|
|
8976
|
+
skipped.push({ path: relative2(real2, folder).split(sep3).join("/") || ".", reason: unreadable(error) });
|
|
8863
8977
|
return;
|
|
8864
8978
|
}
|
|
8865
8979
|
entries.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
8866
8980
|
for (const entry of entries) {
|
|
8867
8981
|
if (entry.name.startsWith("."))
|
|
8868
8982
|
continue;
|
|
8869
|
-
const path =
|
|
8870
|
-
const shown = relative2(real2, path).split(
|
|
8983
|
+
const path = join3(folder, entry.name);
|
|
8984
|
+
const shown = relative2(real2, path).split(sep3).join("/");
|
|
8871
8985
|
if (entry.isSymbolicLink()) {
|
|
8872
8986
|
skipped.push({ path: shown, reason: refusedLink });
|
|
8873
8987
|
continue;
|
|
@@ -8925,7 +9039,7 @@ var headingOf = /* @__PURE__ */ __name((text2) => {
|
|
|
8925
9039
|
}
|
|
8926
9040
|
return void 0;
|
|
8927
9041
|
}, "headingOf");
|
|
8928
|
-
var titleOfName = /* @__PURE__ */ __name((name) => (
|
|
9042
|
+
var titleOfName = /* @__PURE__ */ __name((name) => (basename2(name).replace(/\.[^.]+$/, "") || basename2(name)).slice(0, 200), "titleOfName");
|
|
8929
9043
|
var sha256Of = /* @__PURE__ */ __name((bytes) => createHash2("sha256").update(bytes).digest("hex"), "sha256Of");
|
|
8930
9044
|
var bytesOf = /* @__PURE__ */ __name((value) => Buffer.byteLength(JSON.stringify(value)), "bytesOf");
|
|
8931
9045
|
var documentFields = /* @__PURE__ */ __name((file, { title, text: text2, metadata }) => {
|
|
@@ -8988,7 +9102,7 @@ var hearLocally = /* @__PURE__ */ __name(async (bytes, env) => {
|
|
|
8988
9102
|
const model = speechModel(MODEL);
|
|
8989
9103
|
const directory2 = modelsDirectory(env);
|
|
8990
9104
|
if (!isInstalled(model, directory2))
|
|
8991
|
-
throw new
|
|
9105
|
+
throw new CliError6("not_found", `the speech model ${MODEL} is not on this computer; a WireCat CLI that transcribes downloads it once, such as \`tg models download ${MODEL}\` (${megabytes(installedBytes(model))})`, { reason: "model.not-downloaded", model: MODEL });
|
|
8992
9106
|
const pcm = await decodeAudio(bytes, runFfmpeg);
|
|
8993
9107
|
const pieces = await recognizeLocalPieces(MODEL, pcm, { env, directory: directory2 });
|
|
8994
9108
|
return { pieces, model: MODEL, seconds: pcm.samples.length / pcm.rate };
|
|
@@ -9062,9 +9176,9 @@ var hearAll = /* @__PURE__ */ __name(async (store, files, { provider, account, t
|
|
|
9062
9176
|
import { isCliError as isCliError3 } from "@wirecat/cli-base";
|
|
9063
9177
|
|
|
9064
9178
|
// dist/sources/read.js
|
|
9065
|
-
import { statSync } from "node:fs";
|
|
9066
|
-
import { basename as
|
|
9067
|
-
import { CliError as
|
|
9179
|
+
import { statSync as statSync2 } from "node:fs";
|
|
9180
|
+
import { basename as basename3, extname as extname2 } from "node:path";
|
|
9181
|
+
import { CliError as CliError7, isCliError as isCliError2 } from "@wirecat/cli-base";
|
|
9068
9182
|
import { attachmentMaxBytes as attachmentMaxBytes2, extractText, fetchPage, importEngine, ocrImage, readWhole as readWhole2, sizeText as sizeText2 } from "@wirecat/cli-core/documents";
|
|
9069
9183
|
|
|
9070
9184
|
// dist/sources/transcript.js
|
|
@@ -9135,6 +9249,7 @@ var MIMES = {
|
|
|
9135
9249
|
".xls": "application/vnd.ms-excel",
|
|
9136
9250
|
".odt": "application/vnd.oasis.opendocument.text",
|
|
9137
9251
|
".ods": "application/vnd.oasis.opendocument.spreadsheet",
|
|
9252
|
+
".odp": "application/vnd.oasis.opendocument.presentation",
|
|
9138
9253
|
".epub": "application/epub+zip",
|
|
9139
9254
|
".rtf": "application/rtf",
|
|
9140
9255
|
".vtt": "text/vtt",
|
|
@@ -9163,28 +9278,28 @@ var withNextStep = /* @__PURE__ */ __name((error) => {
|
|
|
9163
9278
|
return error;
|
|
9164
9279
|
const reason = error.details.reason;
|
|
9165
9280
|
const step = typeof reason === "string" ? NEXT[reason] : void 0;
|
|
9166
|
-
return step === void 0 ? error : new
|
|
9281
|
+
return step === void 0 ? error : new CliError7(error.code, `${error.message} \u2014 ${step}`, error.details);
|
|
9167
9282
|
}, "withNextStep");
|
|
9168
9283
|
var refusal = /* @__PURE__ */ __name((extraction, name) => {
|
|
9169
9284
|
switch (extraction.status) {
|
|
9170
9285
|
case "unsupported":
|
|
9171
|
-
return new
|
|
9286
|
+
return new CliError7("validation_error", `no reader takes ${name}`, { reason: "source.unsupported" });
|
|
9172
9287
|
case "unreadable":
|
|
9173
|
-
return new
|
|
9288
|
+
return new CliError7("validation_error", `the ${extraction.extractor} reader could not read ${name}`, {
|
|
9174
9289
|
reason: "source.unreadable"
|
|
9175
9290
|
});
|
|
9176
9291
|
case "engine-missing":
|
|
9177
|
-
return new
|
|
9292
|
+
return new CliError7("configuration_error", `reading ${name} needs ${extraction.engine}, which is not installed`, {
|
|
9178
9293
|
reason: "source.engine-missing"
|
|
9179
9294
|
});
|
|
9180
9295
|
case "too-large":
|
|
9181
|
-
return new
|
|
9296
|
+
return new CliError7("validation_error", `${name} is larger than its reader reads`, { reason: "source.too-large" });
|
|
9182
9297
|
}
|
|
9183
9298
|
}, "refusal");
|
|
9184
|
-
var tooLarge = /* @__PURE__ */ __name((what) => new
|
|
9299
|
+
var tooLarge = /* @__PURE__ */ __name((what) => new CliError7("validation_error", `${what} is larger than ${sizeText2(attachmentMaxBytes2())}; configure MESSAGING_ATTACHMENT_MAX_MIB`, {
|
|
9185
9300
|
reason: "source.too-large"
|
|
9186
9301
|
}), "tooLarge");
|
|
9187
|
-
var noText = /* @__PURE__ */ __name((what) => new
|
|
9302
|
+
var noText = /* @__PURE__ */ __name((what) => new CliError7("validation_error", `${what} holds no text to keep`, { reason: "source.no-text" }), "noText");
|
|
9188
9303
|
var bounded = /* @__PURE__ */ __name((text2, maxChars) => {
|
|
9189
9304
|
const normalized = text2.replace(/\r\n?/g, "\n");
|
|
9190
9305
|
return { text: normalized.slice(0, maxChars), cut: normalized.length > maxChars };
|
|
@@ -9231,12 +9346,12 @@ var readText = /* @__PURE__ */ __name(async (stdin, { maxChars }) => {
|
|
|
9231
9346
|
};
|
|
9232
9347
|
}, "readText");
|
|
9233
9348
|
var readFile = /* @__PURE__ */ __name(async (path, { maxChars, load = importEngine, image }) => {
|
|
9234
|
-
const stat =
|
|
9235
|
-
const name =
|
|
9349
|
+
const stat = statSync2(path, { throwIfNoEntry: false });
|
|
9350
|
+
const name = basename3(path);
|
|
9236
9351
|
if (!stat)
|
|
9237
|
-
throw new
|
|
9352
|
+
throw new CliError7("not_found", `no file ${path}`, { path });
|
|
9238
9353
|
if (!stat.isFile())
|
|
9239
|
-
throw new
|
|
9354
|
+
throw new CliError7("validation_error", `${path} is not a file`, { path });
|
|
9240
9355
|
if (stat.size > attachmentMaxBytes2())
|
|
9241
9356
|
throw tooLarge(name);
|
|
9242
9357
|
const read = await readWhole2(path);
|
|
@@ -9362,7 +9477,10 @@ var previewOf = /* @__PURE__ */ __name((read) => {
|
|
|
9362
9477
|
|
|
9363
9478
|
// dist/import/readers.js
|
|
9364
9479
|
var RECORDS_FILES = /* @__PURE__ */ new Set([".json", ".jsonl"]);
|
|
9365
|
-
var DOCUMENT_EXTENSIONS =
|
|
9480
|
+
var DOCUMENT_EXTENSIONS = Object.fromEntries(NOTE_EXTENSIONS.filter((extension) => !TEXT_EXTENSIONS[extension] && extension !== ".xls").map((extension) => [
|
|
9481
|
+
extension,
|
|
9482
|
+
extension.slice(1)
|
|
9483
|
+
]));
|
|
9366
9484
|
var TRANSCRIPT_EXTENSIONS = { ".vtt": "vtt", ".srt": "srt" };
|
|
9367
9485
|
var readDocument = /* @__PURE__ */ __name(async (file) => {
|
|
9368
9486
|
try {
|
|
@@ -9442,22 +9560,22 @@ var importAccounts = /* @__PURE__ */ __name(async (store) => {
|
|
|
9442
9560
|
}, "importAccounts");
|
|
9443
9561
|
var noAccount = /* @__PURE__ */ __name(async (env) => {
|
|
9444
9562
|
const choices2 = await withStore(env, importAccounts);
|
|
9445
|
-
throw new
|
|
9563
|
+
throw new CliError8("validation_error", `name the account to import into: --account <provider>:<account>. ${choices2.length ? `Accounts that hold imports: ${choices2.join(", ")}.` : "No account holds imports yet."} A new one is made on first use: import:<name> for documents and notes, phone:<exchange> for call transcripts`, { param: "--account", choices: choices2 });
|
|
9446
9564
|
}, "noAccount");
|
|
9447
9565
|
var folderImport = /* @__PURE__ */ __name(async (store, { path, provider, account, dryRun, by, onIssue, transcribe, hear, env }) => {
|
|
9448
9566
|
if (providerNamed(provider)?.imported !== true)
|
|
9449
|
-
throw new
|
|
9567
|
+
throw new CliError8("validation_error", `files are imported only into an account of an import-only provider, which no sync owns: ${provider} is not one. Use import:<name> for documents and notes, or phone:<exchange> for call transcripts`, { param: "--account", reason: "record.provider-not-imported" });
|
|
9450
9568
|
let found;
|
|
9451
9569
|
try {
|
|
9452
9570
|
found = await walk(path);
|
|
9453
9571
|
} catch (error) {
|
|
9454
9572
|
if (error instanceof TooMany)
|
|
9455
|
-
throw new
|
|
9573
|
+
throw new CliError8("validation_error", `${path} holds more than ${MOST_FILES} files: import them by folder`, {
|
|
9456
9574
|
reason: "import.too-many-files",
|
|
9457
9575
|
path
|
|
9458
9576
|
});
|
|
9459
9577
|
if (errnoOf2(error) === "ENOENT")
|
|
9460
|
-
throw new
|
|
9578
|
+
throw new CliError8("not_found", `no file or folder ${path}`, { path });
|
|
9461
9579
|
throw error;
|
|
9462
9580
|
}
|
|
9463
9581
|
const heard = await hearAll(store, found.files, {
|
|
@@ -9515,7 +9633,7 @@ var importCommand = /* @__PURE__ */ __name((program, streams, env, { hear = hear
|
|
|
9515
9633
|
const { print } = answers(program, streams, env);
|
|
9516
9634
|
byOption(annotate(program.command("import"), { effects: LOCAL_WRITE, output: { entity: "import_receipt" } }).summary("bring a folder of documents or a records file into files' search").description("bring a folder of text, Markdown, PDF and Word files, .vtt or .srt transcripts and, with --transcribe, recordings, one such file, or a records file (JSON or JSONL) into the store, under the account you name. Each file is a document keyed by its path in the folder: the same folder twice changes nothing, an edited file updates its document, and a file gone from the folder is kept. Links are not followed and nothing leaves this computer; the text is kept as data, never run")).argument("<path>", "a folder, a .txt, .md, .pdf, .docx, .vtt, .srt or audio file, or a records file (.json, .jsonl; - for stdin)").option("--account <account>", "the source the files belong to: import:<name> (import:handbook), or phone:<exchange> for call transcripts; never chosen for you").option("--transcribe", "hear recordings (.wav, .mp3, .m4a, .ogg, .opus, .flac) with the local speech model; a recording heard before and unchanged is not heard again. Without it recordings are skipped").option("--dry-run", "read every file and plan the import; write nothing. Holds the store's write lock meanwhile").action(async (path, given, command) => {
|
|
9517
9635
|
if (isMcpRun(command, env))
|
|
9518
|
-
throw new
|
|
9636
|
+
throw new CliError8("permission_error", "an agent over MCP hands records over with records import, not a path");
|
|
9519
9637
|
if (!given.account?.trim())
|
|
9520
9638
|
await noAccount(env);
|
|
9521
9639
|
const { provider, account } = sourceOf(given.account);
|
|
@@ -9558,8 +9676,8 @@ var importCommand = /* @__PURE__ */ __name((program, streams, env, { hear = hear
|
|
|
9558
9676
|
}, "importCommand");
|
|
9559
9677
|
|
|
9560
9678
|
// dist/migrate.js
|
|
9561
|
-
import { copyFileSync, existsSync, mkdirSync, readdirSync as readdirSync2, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
9562
|
-
import { join as
|
|
9679
|
+
import { copyFileSync, existsSync as existsSync2, mkdirSync, readdirSync as readdirSync2, readFileSync, realpathSync as realpathSync2, writeFileSync } from "node:fs";
|
|
9680
|
+
import { join as join4 } from "node:path";
|
|
9563
9681
|
import { Credentials, configFilePath as configFilePath2, pathsAreOverridden, resolvePaths as resolvePaths3, saveConfigFile as saveConfigFile2 } from "@wirecat/cli-base";
|
|
9564
9682
|
import { installerOf } from "@wirecat/cli-base/update";
|
|
9565
9683
|
|
|
@@ -9585,7 +9703,7 @@ var readJson = /* @__PURE__ */ __name((path) => {
|
|
|
9585
9703
|
}
|
|
9586
9704
|
}, "readJson");
|
|
9587
9705
|
var isRecord = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "isRecord");
|
|
9588
|
-
var homeOf = /* @__PURE__ */ __name((env) => MEMO_HOMES.map((home) => resolvePaths3({ ...home, env })).find(({ config, state }) =>
|
|
9706
|
+
var homeOf = /* @__PURE__ */ __name((env) => MEMO_HOMES.map((home) => resolvePaths3({ ...home, env })).find(({ config, state }) => existsSync2(configFilePath2(config)) || existsSync2(join4(state, "folders"))), "homeOf");
|
|
9589
9707
|
var renamedMarks = /* @__PURE__ */ __name((state) => {
|
|
9590
9708
|
if (!isRecord(state) || !isRecord(state.files))
|
|
9591
9709
|
return state;
|
|
@@ -9612,19 +9730,19 @@ var copyConfig = /* @__PURE__ */ __name((from, env) => {
|
|
|
9612
9730
|
return copied.map((key) => `defaults.${key}`);
|
|
9613
9731
|
}, "copyConfig");
|
|
9614
9732
|
var copyFolderStates = /* @__PURE__ */ __name((from, to) => {
|
|
9615
|
-
const source =
|
|
9616
|
-
if (!
|
|
9733
|
+
const source = join4(from, "folders");
|
|
9734
|
+
if (!existsSync2(source))
|
|
9617
9735
|
return 0;
|
|
9618
|
-
const target =
|
|
9736
|
+
const target = join4(to, "folders");
|
|
9619
9737
|
mkdirSync(target, { recursive: true });
|
|
9620
9738
|
let copied = 0;
|
|
9621
9739
|
for (const name of readdirSync2(source)) {
|
|
9622
|
-
if (!name.endsWith(".json") ||
|
|
9740
|
+
if (!name.endsWith(".json") || existsSync2(join4(target, name)))
|
|
9623
9741
|
continue;
|
|
9624
|
-
const state = readJson(
|
|
9742
|
+
const state = readJson(join4(source, name));
|
|
9625
9743
|
if (state === void 0)
|
|
9626
9744
|
continue;
|
|
9627
|
-
writeFileSync(
|
|
9745
|
+
writeFileSync(join4(target, name), JSON.stringify(renamedMarks(state)));
|
|
9628
9746
|
copied++;
|
|
9629
9747
|
}
|
|
9630
9748
|
return copied;
|
|
@@ -9635,10 +9753,10 @@ var copyMaps = /* @__PURE__ */ __name((from, to) => {
|
|
|
9635
9753
|
[from.config, "people-notes.json", to.config],
|
|
9636
9754
|
[from.state, "people-notes-imported.json", to.state]
|
|
9637
9755
|
]) {
|
|
9638
|
-
if (!
|
|
9756
|
+
if (!existsSync2(join4(dir, name)) || existsSync2(join4(into, name)))
|
|
9639
9757
|
continue;
|
|
9640
9758
|
mkdirSync(into, { recursive: true });
|
|
9641
|
-
copyFileSync(
|
|
9759
|
+
copyFileSync(join4(dir, name), join4(into, name));
|
|
9642
9760
|
copied.push(name);
|
|
9643
9761
|
}
|
|
9644
9762
|
return copied;
|
|
@@ -9682,13 +9800,13 @@ var keysIfAnswered = /* @__PURE__ */ __name((env, keyring) => {
|
|
|
9682
9800
|
}
|
|
9683
9801
|
}, "keysIfAnswered");
|
|
9684
9802
|
var writeMarker = /* @__PURE__ */ __name((path, done, keysPending) => {
|
|
9685
|
-
mkdirSync(
|
|
9803
|
+
mkdirSync(join4(path, ".."), { recursive: true });
|
|
9686
9804
|
writeFileSync(path, JSON.stringify({ ...done, keys_pending: keysPending, at: (/* @__PURE__ */ new Date()).toISOString() }));
|
|
9687
9805
|
}, "writeMarker");
|
|
9688
9806
|
var migrateFromMemo = /* @__PURE__ */ __name((env, keyring) => {
|
|
9689
9807
|
const own = filesPaths(env);
|
|
9690
|
-
const marker =
|
|
9691
|
-
if (
|
|
9808
|
+
const marker = join4(own.state, MARKER);
|
|
9809
|
+
if (existsSync2(marker)) {
|
|
9692
9810
|
const saved = readJson(marker);
|
|
9693
9811
|
if (!isRecord(saved) || saved.keys_pending !== true)
|
|
9694
9812
|
return void 0;
|
|
@@ -9715,7 +9833,7 @@ var isInstalledCopy = /* @__PURE__ */ __name((script) => {
|
|
|
9715
9833
|
if (!script)
|
|
9716
9834
|
return false;
|
|
9717
9835
|
try {
|
|
9718
|
-
const installer = installerOf(
|
|
9836
|
+
const installer = installerOf(realpathSync2(script));
|
|
9719
9837
|
return installer !== "checkout" && installer !== "unknown";
|
|
9720
9838
|
} catch {
|
|
9721
9839
|
return false;
|
|
@@ -9740,81 +9858,13 @@ var positive = /* @__PURE__ */ __name((value) => {
|
|
|
9740
9858
|
var collect = /* @__PURE__ */ __name((value, previous = []) => [...previous, value], "collect");
|
|
9741
9859
|
|
|
9742
9860
|
// dist/people/notes-map.js
|
|
9743
|
-
import { existsSync as
|
|
9861
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
9744
9862
|
import { join as join6 } from "node:path";
|
|
9745
9863
|
import { loadConfigFile } from "@wirecat/cli-base";
|
|
9746
9864
|
|
|
9747
9865
|
// dist/notes/bound.js
|
|
9748
|
-
import { resolve as resolve2 } from "node:path";
|
|
9866
|
+
import { isAbsolute, relative as relative3, resolve as resolve2, sep as sep4 } from "node:path";
|
|
9749
9867
|
import { CliError as CliError9 } from "@wirecat/cli-base";
|
|
9750
|
-
|
|
9751
|
-
// dist/notes/folders.js
|
|
9752
|
-
import { realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
|
|
9753
|
-
import { dirname, join as join4, resolve, sep as sep3 } from "node:path";
|
|
9754
|
-
import { CliError as CliError8 } from "@wirecat/cli-base";
|
|
9755
|
-
var entryOf = /* @__PURE__ */ __name((entry) => typeof entry === "string" ? { id: null, path: resolve(entry), format: "obsidian" } : { id: entry.id, path: resolve(entry.path), format: entry.format ?? "obsidian" }, "entryOf");
|
|
9756
|
-
var noteFolders = /* @__PURE__ */ __name((notes) => (notes?.folders ?? []).map(entryOf), "noteFolders");
|
|
9757
|
-
var written = /* @__PURE__ */ __name((folder) => ({
|
|
9758
|
-
id: folder.id,
|
|
9759
|
-
path: folder.path,
|
|
9760
|
-
...folder.format === "obsidian" ? {} : { format: folder.format }
|
|
9761
|
-
}), "written");
|
|
9762
|
-
var withFolders = /* @__PURE__ */ __name((config, folders) => ({
|
|
9763
|
-
...config,
|
|
9764
|
-
notes: {
|
|
9765
|
-
...config.notes,
|
|
9766
|
-
folders: folders.map((folder) => folder.id === null ? folder.path : written(folder))
|
|
9767
|
-
}
|
|
9768
|
-
}), "withFolders");
|
|
9769
|
-
var bindFolder = /* @__PURE__ */ __name((config, folder) => {
|
|
9770
|
-
const at = resolve(folder.path);
|
|
9771
|
-
const folders = noteFolders(config.notes);
|
|
9772
|
-
const index = folders.findIndex((other) => other.path === at);
|
|
9773
|
-
const bound = { ...folder, path: at };
|
|
9774
|
-
const kept = folders.map((other, position) => position === index ? bound : other).filter((other, position) => position === index || other.id !== folder.id && other.path !== at);
|
|
9775
|
-
return withFolders(config, index < 0 ? [...kept, bound] : kept);
|
|
9776
|
-
}, "bindFolder");
|
|
9777
|
-
var attachFolder = /* @__PURE__ */ __name((config, id, path, format) => {
|
|
9778
|
-
const at = resolve(path);
|
|
9779
|
-
const folders = noteFolders(config.notes);
|
|
9780
|
-
const taken = folders.find((folder2) => folder2.path === at && folder2.id !== null && folder2.id !== id);
|
|
9781
|
-
if (taken)
|
|
9782
|
-
throw new CliError8("validation_error", `${at} is already folder ${taken.id} \u2014 attach that id elsewhere first, or remove it from the config`);
|
|
9783
|
-
const previous = folders.find((folder2) => folder2.id === id);
|
|
9784
|
-
const folder = { id, path: at, format: format ?? previous?.format ?? "obsidian" };
|
|
9785
|
-
const kept = folders.filter((other) => other.id !== id && other.path !== at);
|
|
9786
|
-
return { config: withFolders(config, [...kept, folder]), folder };
|
|
9787
|
-
}, "attachFolder");
|
|
9788
|
-
var unbindFolder = /* @__PURE__ */ __name((config, path) => withFolders(config, noteFolders(config.notes).filter((folder) => folder.path !== resolve(path))), "unbindFolder");
|
|
9789
|
-
var real = /* @__PURE__ */ __name((path) => {
|
|
9790
|
-
try {
|
|
9791
|
-
return realpathSync2(path);
|
|
9792
|
-
} catch {
|
|
9793
|
-
return resolve(path);
|
|
9794
|
-
}
|
|
9795
|
-
}, "real");
|
|
9796
|
-
var detectFormat = /* @__PURE__ */ __name((path) => {
|
|
9797
|
-
for (let at = real(path); ; at = dirname(at)) {
|
|
9798
|
-
try {
|
|
9799
|
-
if (statSync2(join4(at, ".obsidian")).isDirectory())
|
|
9800
|
-
return "obsidian";
|
|
9801
|
-
} catch {
|
|
9802
|
-
}
|
|
9803
|
-
if (dirname(at) === at)
|
|
9804
|
-
return "markdown";
|
|
9805
|
-
}
|
|
9806
|
-
}, "detectFormat");
|
|
9807
|
-
var comparable = /* @__PURE__ */ __name((path) => process.platform === "darwin" || process.platform === "win32" ? real(path).toLowerCase() : real(path), "comparable");
|
|
9808
|
-
var inside = /* @__PURE__ */ __name((child, parent) => child.startsWith(parent.endsWith(sep3) ? parent : `${parent}${sep3}`), "inside");
|
|
9809
|
-
var overlapping = /* @__PURE__ */ __name((folders, path) => {
|
|
9810
|
-
const at = comparable(path);
|
|
9811
|
-
return folders.filter((folder) => {
|
|
9812
|
-
const other = comparable(folder.path);
|
|
9813
|
-
return other !== at && (inside(at, other) || inside(other, at));
|
|
9814
|
-
});
|
|
9815
|
-
}, "overlapping");
|
|
9816
|
-
|
|
9817
|
-
// dist/notes/bound.js
|
|
9818
9868
|
var UNBOUND = "folder.unbound";
|
|
9819
9869
|
var unboundReason = /* @__PURE__ */ __name((path) => `${path} has no folder id \u2014 files folders add ${path}, or files folders update <id> ${path} if another computer made one`, "unboundReason");
|
|
9820
9870
|
var unbound = /* @__PURE__ */ __name((path) => new CliError9("configuration_error", unboundReason(path), { reason: UNBOUND, path }), "unbound");
|
|
@@ -9837,19 +9887,21 @@ var boundFolders = /* @__PURE__ */ __name(async (store, env, { only, strict = tr
|
|
|
9837
9887
|
}, "boundFolders");
|
|
9838
9888
|
var folderOfFile = /* @__PURE__ */ __name((folders, file) => {
|
|
9839
9889
|
const at = resolve2(file);
|
|
9840
|
-
const folder
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
-
|
|
9890
|
+
for (const folder of folders) {
|
|
9891
|
+
const path = relative3(folder.path, at);
|
|
9892
|
+
if (path && path !== ".." && !path.startsWith(`..${sep4}`) && !isAbsolute(path))
|
|
9893
|
+
return { folder, path: path.split(sep4).join("/") };
|
|
9894
|
+
}
|
|
9895
|
+
throw new CliError9("not_found", `${at} is in no configured folder of notes`, { reason: "folder.not-found" });
|
|
9844
9896
|
}, "folderOfFile");
|
|
9845
9897
|
|
|
9846
9898
|
// dist/notes/import.js
|
|
9847
9899
|
import { createHash as createHash3 } from "node:crypto";
|
|
9848
|
-
import { existsSync as
|
|
9849
|
-
import { basename as
|
|
9850
|
-
import { CliError as CliError10 } from "@wirecat/cli-base";
|
|
9900
|
+
import { existsSync as existsSync3, statSync as statSync3 } from "node:fs";
|
|
9901
|
+
import { basename as basename4, extname as extname3, relative as relative4, sep as sep5 } from "node:path";
|
|
9902
|
+
import { CliError as CliError10, isCliError as isCliError4 } from "@wirecat/cli-base";
|
|
9851
9903
|
import { normalizeTag } from "@wirecat/cli-core";
|
|
9852
|
-
import { attachmentMaxBytes as attachmentMaxBytes3, extractText as extractText2, importEngine as importEngine2, readWhole as readWhole3 } from "@wirecat/cli-core/documents";
|
|
9904
|
+
import { attachmentMaxBytes as attachmentMaxBytes3, extractText as extractText2, importEngine as importEngine2, readWhole as readWhole3, scanRetry } from "@wirecat/cli-core/documents";
|
|
9853
9905
|
|
|
9854
9906
|
// dist/notes/dates.js
|
|
9855
9907
|
var BARE_DAY = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
@@ -9868,7 +9920,8 @@ var noteFileTime = /* @__PURE__ */ __name((frontMatter, mtimeMs) => new Date(fro
|
|
|
9868
9920
|
// dist/notes/links.js
|
|
9869
9921
|
import { posix as posix2 } from "node:path";
|
|
9870
9922
|
var fold = /* @__PURE__ */ __name((value) => value.normalize("NFC").toLocaleLowerCase("en"), "fold");
|
|
9871
|
-
var
|
|
9923
|
+
var STEM = new RegExp(`\\.(${[...NOTE_EXTENSIONS, ...PICTURE_EXTENSIONS].map((ext) => ext.slice(1)).join("|")})$`, "i");
|
|
9924
|
+
var stem = /* @__PURE__ */ __name((path) => path.replace(STEM, ""), "stem");
|
|
9872
9925
|
var aliasesOf = /* @__PURE__ */ __name((frontMatter) => {
|
|
9873
9926
|
const value = frontMatter?.aliases ?? frontMatter?.alias;
|
|
9874
9927
|
if (typeof value === "string")
|
|
@@ -9882,9 +9935,9 @@ var documentOf = /* @__PURE__ */ __name((note) => ({
|
|
|
9882
9935
|
}), "documentOf");
|
|
9883
9936
|
var notesNamed = /* @__PURE__ */ __name((source, target, documents) => {
|
|
9884
9937
|
const normalized = stem(posix2.normalize(target.replace(/\\/g, "/").replace(/^\//, "")));
|
|
9885
|
-
const
|
|
9938
|
+
const relative6 = stem(posix2.normalize(posix2.join(posix2.dirname(source), normalized)));
|
|
9886
9939
|
const explicit = target.startsWith("./") || target.startsWith("../") || target.startsWith("/") || normalized.includes("/");
|
|
9887
|
-
const preferred = target.startsWith("./") || target.startsWith("../") ?
|
|
9940
|
+
const preferred = target.startsWith("./") || target.startsWith("../") ? relative6 : normalized;
|
|
9888
9941
|
if (target === "")
|
|
9889
9942
|
return documents.filter((doc) => doc.path === source);
|
|
9890
9943
|
if (explicit)
|
|
@@ -9952,7 +10005,7 @@ var PAGE = 500;
|
|
|
9952
10005
|
var TEXT_NOTE2 = /\.(md|markdown|txt)$/i;
|
|
9953
10006
|
var MEMO = "files:";
|
|
9954
10007
|
var missingFolder = /* @__PURE__ */ __name((path) => `the notes folder ${path} is missing \u2014 connect its disk; if it moved, files folders update <id> <new path>`, "missingFolder");
|
|
9955
|
-
var inside2 = /* @__PURE__ */ __name((folder, path) =>
|
|
10008
|
+
var inside2 = /* @__PURE__ */ __name((folder, path) => relative4(folder, path).split(sep5).join("/"), "inside");
|
|
9956
10009
|
var folderNotes = /* @__PURE__ */ __name(async (store, folderId) => {
|
|
9957
10010
|
const notes = [];
|
|
9958
10011
|
for (let offset = 0; ; offset += PAGE) {
|
|
@@ -9971,9 +10024,9 @@ var storable = /* @__PURE__ */ __name((tags) => [
|
|
|
9971
10024
|
}
|
|
9972
10025
|
}))
|
|
9973
10026
|
].sort(), "storable");
|
|
9974
|
-
var importNotes = /* @__PURE__ */ __name(async (store, folder, { ignore = [], skip = [], env = process.env, loadEngine = importEngine2, onFile = /* @__PURE__ */ __name(() => {
|
|
10027
|
+
var importNotes = /* @__PURE__ */ __name(async (store, folder, { ignore = [], skip = [], env = process.env, loadEngine = importEngine2, scans, onFile = /* @__PURE__ */ __name(() => {
|
|
9975
10028
|
}, "onFile") } = {}) => {
|
|
9976
|
-
if (!
|
|
10029
|
+
if (!existsSync3(folder.path))
|
|
9977
10030
|
throw new CliError10("not_found", missingFolder(folder.path), {
|
|
9978
10031
|
reason: "notes.folder-missing",
|
|
9979
10032
|
path: folder.path
|
|
@@ -9991,13 +10044,18 @@ var importNotes = /* @__PURE__ */ __name(async (store, folder, { ignore = [], sk
|
|
|
9991
10044
|
const unreadable2 = [];
|
|
9992
10045
|
const read = [];
|
|
9993
10046
|
const mtimes = /* @__PURE__ */ new Map();
|
|
9994
|
-
const notReadAs = /* @__PURE__ */ __name((path, status, engine) => {
|
|
9995
|
-
const entry = { status, ...engine === void 0 ? {} : { engine } };
|
|
10047
|
+
const notReadAs = /* @__PURE__ */ __name((path, status, engine, reason) => {
|
|
10048
|
+
const entry = { status, ...engine === void 0 ? {} : { engine }, ...reason === void 0 ? {} : { reason } };
|
|
9996
10049
|
notRead.push({ path, ...entry });
|
|
9997
10050
|
notReadNow[path] = entry;
|
|
9998
10051
|
unreadable2.push(path);
|
|
9999
10052
|
}, "notReadAs");
|
|
10000
|
-
const
|
|
10053
|
+
const reads = scans?.extractor !== void 0;
|
|
10054
|
+
const refused = reads ? await refusal2(scans, { name: "probe.pdf", mime: "application/pdf" }) : void 0;
|
|
10055
|
+
const ocr = { read: 0, picturesWaiting: 0 };
|
|
10056
|
+
const scanned = /* @__PURE__ */ __name((id) => isPicturePath(id) || extname3(id).toLowerCase() === ".pdf", "scanned");
|
|
10057
|
+
const retried = /* @__PURE__ */ __name((id, entry) => reads && entry?.status === "needs-agent" && scanned(id) && (entry.reason === void 0 || entry.reason !== refused && scanRetry(scans, entry.reason)), "retried");
|
|
10058
|
+
const files = noteFiles(folder.path, ignore, [...NOTE_EXTENSIONS, ...PICTURE_EXTENSIONS], { skipExported: false });
|
|
10001
10059
|
onFile(0, files.length);
|
|
10002
10060
|
for (const [index, path] of files.entries()) {
|
|
10003
10061
|
if (index > 0)
|
|
@@ -10005,7 +10063,13 @@ var importNotes = /* @__PURE__ */ __name(async (store, folder, { ignore = [], sk
|
|
|
10005
10063
|
const id = inside2(folder.path, path);
|
|
10006
10064
|
const previous = before?.files[id];
|
|
10007
10065
|
const wasNotRead = before?.notRead?.[id];
|
|
10008
|
-
|
|
10066
|
+
const waiting = !reads && isPicturePath(id);
|
|
10067
|
+
if (waiting && !stored.has(id)) {
|
|
10068
|
+
if (scans)
|
|
10069
|
+
ocr.picturesWaiting++;
|
|
10070
|
+
continue;
|
|
10071
|
+
}
|
|
10072
|
+
if (skipped(id) || waiting) {
|
|
10009
10073
|
held.add(id);
|
|
10010
10074
|
if (previous !== void 0)
|
|
10011
10075
|
after.files[id] = previous;
|
|
@@ -10017,11 +10081,11 @@ var importNotes = /* @__PURE__ */ __name(async (store, folder, { ignore = [], sk
|
|
|
10017
10081
|
mtimes.set(id, stat.mtimeMs);
|
|
10018
10082
|
const stamp = `${stat.mtimeMs}:${stat.size}:`;
|
|
10019
10083
|
const exported = previous?.startsWith(`${MEMO}${stamp}`);
|
|
10020
|
-
const settled = stored.has(id) || wasNotRead !== void 0 && wasNotRead.status !== "engine-missing" && wasNotRead.status !== "too-large";
|
|
10084
|
+
const settled = stored.has(id) || wasNotRead !== void 0 && wasNotRead.status !== "engine-missing" && wasNotRead.status !== "too-large" && !retried(id, wasNotRead);
|
|
10021
10085
|
if (exported || previous?.startsWith(stamp) && settled && !reparse(id)) {
|
|
10022
10086
|
after.files[id] = previous;
|
|
10023
10087
|
if (wasNotRead)
|
|
10024
|
-
notReadAs(id, wasNotRead.status, wasNotRead.engine);
|
|
10088
|
+
notReadAs(id, wasNotRead.status, wasNotRead.engine, wasNotRead.reason);
|
|
10025
10089
|
continue;
|
|
10026
10090
|
}
|
|
10027
10091
|
if (stat.size > attachmentMaxBytes3()) {
|
|
@@ -10036,7 +10100,7 @@ var importNotes = /* @__PURE__ */ __name(async (store, folder, { ignore = [], sk
|
|
|
10036
10100
|
const bytes = await readWhole3(path);
|
|
10037
10101
|
const hash = createHash3("sha256").update(bytes).digest("hex");
|
|
10038
10102
|
after.files[id] = `${stamp}${hash}`;
|
|
10039
|
-
read.push({ id, path, bytes, hash });
|
|
10103
|
+
read.push({ id, path, bytes: isPicturePath(id) ? null : bytes, hash });
|
|
10040
10104
|
}
|
|
10041
10105
|
const listed = /* @__PURE__ */ new Set([
|
|
10042
10106
|
...Object.keys(after.files).filter((id) => !after.files[id]?.startsWith(MEMO)),
|
|
@@ -10058,7 +10122,20 @@ var importNotes = /* @__PURE__ */ __name(async (store, folder, { ignore = [], sk
|
|
|
10058
10122
|
onFile(files.length - read.length + index, files.length);
|
|
10059
10123
|
if (stored.get(id)?.contentHash === hash && !reparse(id))
|
|
10060
10124
|
continue;
|
|
10061
|
-
|
|
10125
|
+
let extraction = bytes === null ? { status: "needs-agent" } : await extractText2(bytes, { kind: "file", name: basename4(path), mime: null, path }, loadEngine);
|
|
10126
|
+
if (extraction.status === "needs-agent" && scans && scanned(id)) {
|
|
10127
|
+
const mime = MIMES[extname3(id).toLowerCase()] ?? "application/octet-stream";
|
|
10128
|
+
try {
|
|
10129
|
+
const text3 = await scans.read(async () => bytes ?? await readWhole3(path), { name: basename4(path), mime });
|
|
10130
|
+
extraction = { status: "extracted", text: text3, extractor: scans.extractor ?? "ocr" };
|
|
10131
|
+
ocr.read++;
|
|
10132
|
+
} catch (error) {
|
|
10133
|
+
if (!isCliError4(error) || error.code !== "validation_error")
|
|
10134
|
+
throw error;
|
|
10135
|
+
notReadAs(id, "needs-agent", void 0, error.message);
|
|
10136
|
+
continue;
|
|
10137
|
+
}
|
|
10138
|
+
}
|
|
10062
10139
|
if (extraction.status !== "extracted") {
|
|
10063
10140
|
notReadAs(id, extraction.status, "engine" in extraction ? extraction.engine : void 0);
|
|
10064
10141
|
continue;
|
|
@@ -10070,7 +10147,7 @@ var importNotes = /* @__PURE__ */ __name(async (store, folder, { ignore = [], sk
|
|
|
10070
10147
|
const saved = await store.notes.saveFileNote({
|
|
10071
10148
|
folderId: folder.id,
|
|
10072
10149
|
path: id,
|
|
10073
|
-
title: note?.title ??
|
|
10150
|
+
title: note?.title ?? basename4(id).replace(/\.[^.]+$/, ""),
|
|
10074
10151
|
text: text2.slice(0, MAX_TEXT),
|
|
10075
10152
|
...note && Object.keys(note.frontMatter).length ? { frontMatter: note.frontMatter } : {},
|
|
10076
10153
|
contentHash: hash
|
|
@@ -10134,6 +10211,7 @@ var importNotes = /* @__PURE__ */ __name(async (store, folder, { ignore = [], sk
|
|
|
10134
10211
|
await store.notes.replaceFileTags(stored.get(id).id, storable(note.tags));
|
|
10135
10212
|
const heldBack = [...held].some((id) => reparse(id) && stored.has(id));
|
|
10136
10213
|
saveFolderState(env, folder.id, { ...after, format: heldBack ? before?.format : folder.format });
|
|
10214
|
+
const scansNotRead = notRead.filter(({ reason }) => reason !== void 0).length;
|
|
10137
10215
|
return {
|
|
10138
10216
|
folder: folder.path,
|
|
10139
10217
|
folderId: folder.id,
|
|
@@ -10143,16 +10221,25 @@ var importNotes = /* @__PURE__ */ __name(async (store, folder, { ignore = [], sk
|
|
|
10143
10221
|
deleted,
|
|
10144
10222
|
...notRead.length ? { notRead } : {},
|
|
10145
10223
|
...truncated.length ? { truncated } : {},
|
|
10146
|
-
...deletionsSkipped === void 0 ? {} : { deletionsSkipped }
|
|
10224
|
+
...deletionsSkipped === void 0 ? {} : { deletionsSkipped },
|
|
10225
|
+
...ocr.read + scansNotRead + ocr.picturesWaiting > 0 ? {
|
|
10226
|
+
ocr: {
|
|
10227
|
+
read: ocr.read,
|
|
10228
|
+
notRead: scansNotRead,
|
|
10229
|
+
...ocr.picturesWaiting ? { picturesWaiting: ocr.picturesWaiting } : {},
|
|
10230
|
+
...!reads && scans ? { unavailable: await refusal2(scans, { name: "probe.png", mime: "image/png" }) } : {}
|
|
10231
|
+
}
|
|
10232
|
+
} : {}
|
|
10147
10233
|
};
|
|
10148
10234
|
}, "importNotes");
|
|
10235
|
+
var refusal2 = /* @__PURE__ */ __name((scans, file) => scans.read(async () => new Uint8Array(), file).then(() => "", (error) => error instanceof Error ? error.message : String(error)), "refusal");
|
|
10149
10236
|
|
|
10150
10237
|
// dist/people/notes-map.js
|
|
10151
10238
|
var NotesMapSchema = record(string(), string());
|
|
10152
10239
|
var mapPath = /* @__PURE__ */ __name((env) => join6(filesPaths(env).config, "people-notes.json"), "mapPath");
|
|
10153
10240
|
var donePath = /* @__PURE__ */ __name((env) => join6(filesPaths(env).state, "people-notes-imported.json"), "donePath");
|
|
10154
10241
|
var importNotesMap = /* @__PURE__ */ __name(async (store, env, folders) => {
|
|
10155
|
-
if (!
|
|
10242
|
+
if (!existsSync4(mapPath(env)))
|
|
10156
10243
|
return 0;
|
|
10157
10244
|
const map = loadConfigFile(mapPath(env), NotesMapSchema, () => ({}));
|
|
10158
10245
|
let done = [];
|
|
@@ -10363,7 +10450,7 @@ import { CliError as CliError16 } from "@wirecat/cli-base";
|
|
|
10363
10450
|
|
|
10364
10451
|
// dist/notes/export.js
|
|
10365
10452
|
import { createHash as createHash4 } from "node:crypto";
|
|
10366
|
-
import { existsSync as
|
|
10453
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync4, readdirSync as readdirSync3, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync4 } from "node:fs";
|
|
10367
10454
|
import { join as join7 } from "node:path";
|
|
10368
10455
|
var HASH_LINE = /^memo-hash: .*\r?\n/m;
|
|
10369
10456
|
var PLACEHOLDER = "f".repeat(64);
|
|
@@ -10405,7 +10492,7 @@ var exportNotes = /* @__PURE__ */ __name(({ dir, dialect, notes }) => {
|
|
|
10405
10492
|
frontMatter["memo-hash"] = PLACEHOLDER;
|
|
10406
10493
|
const content = withHash(dialect.render({ ...note, frontMatter }));
|
|
10407
10494
|
const known = existing.get(id);
|
|
10408
|
-
const name = known ?? fileName(note.title, id, (candidate) => claimed.has(candidate) ||
|
|
10495
|
+
const name = known ?? fileName(note.title, id, (candidate) => claimed.has(candidate) || existsSync5(join7(dir, candidate)));
|
|
10409
10496
|
claimed.add(name);
|
|
10410
10497
|
const path = join7(dir, name);
|
|
10411
10498
|
if (known !== void 0) {
|
|
@@ -10670,7 +10757,7 @@ var notesCommand = notesCommandDefinition;
|
|
|
10670
10757
|
|
|
10671
10758
|
// dist/notes/folders-command.js
|
|
10672
10759
|
import { statSync as statSync4 } from "node:fs";
|
|
10673
|
-
import { basename as
|
|
10760
|
+
import { basename as basename5, resolve as resolve4 } from "node:path";
|
|
10674
10761
|
import { CliError as CliError19 } from "@wirecat/cli-base";
|
|
10675
10762
|
import { annotate as annotate3 } from "@wirecat/cli-base/commands";
|
|
10676
10763
|
import { grantsAuthority, LOCAL_READ as LOCAL_READ2, LOCAL_WRITE as LOCAL_WRITE3, notLocalPaths, queryTerms as queryTerms2, withQuery as withQuery2 } from "@wirecat/cli-core";
|
|
@@ -10740,7 +10827,7 @@ var foldersCommand = /* @__PURE__ */ __name((program, streams, env) => {
|
|
|
10740
10827
|
throw new CliError19("validation_error", `${at} is inside or around ${clash.path}, which files already reads \u2014 one file would be two notes; remove one of them first (files folders remove "${clash.path}")`, { reason: "folder.overlap", path: at, other: clash.path });
|
|
10741
10828
|
const saved = current?.id === null ? void 0 : current?.format;
|
|
10742
10829
|
const format = options.format ?? saved ?? detectFormat(at);
|
|
10743
|
-
const made = await store.notes.addFolder({ name:
|
|
10830
|
+
const made = await store.notes.addFolder({ name: basename5(at) || at, format });
|
|
10744
10831
|
const folder = { id: made.id, path: at, format };
|
|
10745
10832
|
updateConfig((config) => bindFolder(config, folder), env);
|
|
10746
10833
|
const from = options.format ? "option" : saved ? "saved" : "detected";
|
|
@@ -10821,9 +10908,91 @@ var foldersCommand = /* @__PURE__ */ __name((program, streams, env) => {
|
|
|
10821
10908
|
});
|
|
10822
10909
|
}, "foldersCommand");
|
|
10823
10910
|
|
|
10824
|
-
// dist/
|
|
10911
|
+
// dist/people/command.js
|
|
10912
|
+
import { join as join9 } from "node:path";
|
|
10913
|
+
import { CliError as CliError20 } from "@wirecat/cli-base";
|
|
10825
10914
|
import { annotate as annotate4 } from "@wirecat/cli-base/commands";
|
|
10826
|
-
import { LOCAL_READ as LOCAL_READ3,
|
|
10915
|
+
import { LOCAL_READ as LOCAL_READ3, LOCAL_WRITE as LOCAL_WRITE4 } from "@wirecat/cli-core";
|
|
10916
|
+
var noteLinksCommand = /* @__PURE__ */ __name((program, streams, env) => {
|
|
10917
|
+
const notes = program.commands.find((command) => command.name() === "notes") ?? program.command("notes");
|
|
10918
|
+
const links = notes.command("links").description("imported note files linked to the person behind an identity");
|
|
10919
|
+
const { print } = answers(program, streams, env);
|
|
10920
|
+
for (const operation of ["show", "add", "clear"]) {
|
|
10921
|
+
const command = annotate4(links.command(operation), {
|
|
10922
|
+
effects: operation === "show" ? LOCAL_READ3 : LOCAL_WRITE4,
|
|
10923
|
+
output: { entity: "person_note_links" },
|
|
10924
|
+
examples: [
|
|
10925
|
+
{
|
|
10926
|
+
show: "files notes links show telegram:'Kai Sample'",
|
|
10927
|
+
add: "files notes links add telegram:'Kai Sample' /path/to/vault/People/Kai.md",
|
|
10928
|
+
clear: "files notes links clear telegram:'Kai Sample'"
|
|
10929
|
+
}[operation]
|
|
10930
|
+
]
|
|
10931
|
+
}).description({
|
|
10932
|
+
show: "show the note files about a person",
|
|
10933
|
+
add: "link an imported note file to a person",
|
|
10934
|
+
clear: "remove the owner's note-file links for a person"
|
|
10935
|
+
}[operation]).argument("<identity>", "<messenger>:<name or id> of an identity of the person").option("--json", "print the standard JSON answer");
|
|
10936
|
+
if (operation === "add")
|
|
10937
|
+
command.argument("<path>", "the imported note file in a configured folder");
|
|
10938
|
+
if (operation !== "show")
|
|
10939
|
+
byOption(command);
|
|
10940
|
+
command.action(async (identity, ...rest) => {
|
|
10941
|
+
const options = command.opts();
|
|
10942
|
+
const path = operation === "add" ? String(rest[0]) : void 0;
|
|
10943
|
+
let by = "owner";
|
|
10944
|
+
if (operation !== "show") {
|
|
10945
|
+
const who = await whoRuns(command, env, {
|
|
10946
|
+
asOwner: options.asOwner,
|
|
10947
|
+
question: `change ${identity}'s note files as you, the owner?`
|
|
10948
|
+
});
|
|
10949
|
+
if (who !== "owner")
|
|
10950
|
+
by = { bot: who.bot, reason: `files notes links ${operation}` };
|
|
10951
|
+
}
|
|
10952
|
+
const result = await withStore(env, async (store) => {
|
|
10953
|
+
const folders = await boundFolders(store, env, { strict: false });
|
|
10954
|
+
await importNotesMap(store, env, folders);
|
|
10955
|
+
const person = await store.people.personOf(await identityOf(store, identity));
|
|
10956
|
+
if (person === void 0)
|
|
10957
|
+
throw new CliError20("not_found", `the store has no person for "${identity}"`, { reason: "person.not-found" });
|
|
10958
|
+
const to = `person:${person.uid}`;
|
|
10959
|
+
const files = /* @__PURE__ */ __name(async () => {
|
|
10960
|
+
const found = [];
|
|
10961
|
+
for (const link of await store.notes.links({ to })) {
|
|
10962
|
+
if (link.kind !== "about" || link.origin !== "owner")
|
|
10963
|
+
continue;
|
|
10964
|
+
const note = await store.notes.resolveNote(link.from);
|
|
10965
|
+
if (note?.source === "file" && note.deletedAt === null)
|
|
10966
|
+
found.push({ link, note });
|
|
10967
|
+
}
|
|
10968
|
+
return found;
|
|
10969
|
+
}, "files");
|
|
10970
|
+
if (operation === "clear")
|
|
10971
|
+
for (const { link } of await files())
|
|
10972
|
+
await store.notes.removeLink(link.id, by);
|
|
10973
|
+
else if (path !== void 0) {
|
|
10974
|
+
const { folder, path: inside3 } = folderOfFile(folders, path);
|
|
10975
|
+
const note = (await folderNotes(store, folder.id)).find((candidate) => candidate.path === inside3);
|
|
10976
|
+
if (!note)
|
|
10977
|
+
throw new CliError20("not_found", `${path} is not imported yet \u2014 files sync`, {
|
|
10978
|
+
reason: "note.not-imported"
|
|
10979
|
+
});
|
|
10980
|
+
await store.notes.addLink({ from: note.ref, to, kind: "about", origin: "owner", by });
|
|
10981
|
+
}
|
|
10982
|
+
const paths = (await files()).map(({ note }) => {
|
|
10983
|
+
const folder = folders.find((candidate) => candidate.id === note.folderId);
|
|
10984
|
+
return folder ? join9(folder.path, note.path) : note.ref;
|
|
10985
|
+
});
|
|
10986
|
+
return { person: to, name: person.name ?? person.uid, files: paths };
|
|
10987
|
+
});
|
|
10988
|
+
print(options.json, itemAnswer(result), `${result.name}: ${result.files.join(", ") || "no note"}`);
|
|
10989
|
+
});
|
|
10990
|
+
}
|
|
10991
|
+
}, "noteLinksCommand");
|
|
10992
|
+
|
|
10993
|
+
// dist/search.js
|
|
10994
|
+
import { annotate as annotate5 } from "@wirecat/cli-base/commands";
|
|
10995
|
+
import { LOCAL_READ as LOCAL_READ4, noteHitItem, searchNotesOf } from "@wirecat/cli-core";
|
|
10827
10996
|
import { InvalidArgumentError as InvalidArgumentError4 } from "commander";
|
|
10828
10997
|
|
|
10829
10998
|
// dist/notes/search.js
|
|
@@ -10856,7 +11025,7 @@ var notesAnswer = /* @__PURE__ */ __name((found, limit, page, args = {}) => list
|
|
|
10856
11025
|
var searchCommand = /* @__PURE__ */ __name((program, streams, env) => {
|
|
10857
11026
|
const { print } = answers(program, streams, env);
|
|
10858
11027
|
const group = program.command("search").description("search the notes in the local store");
|
|
10859
|
-
|
|
11028
|
+
annotate5(group.command("notes"), { effects: LOCAL_READ4, output: { entity: "note", view: "hit" } }).description("native notes by words and, with the local model, meaning").argument("<query...>", "words, phrases, Boolean operators and field queries").addHelpText("after", "\nsource:internal keeps the notes you wrote with notes add, source:file the notes from a folder \u2014 'budget source:internal'.\n--source notes:<folder id> is different: it chooses which notes accounts are read.\nFields in the query or in --filter (tag:, date:) hold for every hit, found by words or by meaning; a query of\nfields alone lists the matching notes, newest first \u2014 'budget tag:work', 'date:today'.\n--json: each note's reference is ref (note: or document:).").option("--limit <n>", "most results, at most 100", (value) => {
|
|
10860
11029
|
const limit = positive(value);
|
|
10861
11030
|
if (limit > 100)
|
|
10862
11031
|
throw new InvalidArgumentError4("at most 100");
|
|
@@ -10885,17 +11054,17 @@ var searchCommand = /* @__PURE__ */ __name((program, streams, env) => {
|
|
|
10885
11054
|
}, "searchCommand");
|
|
10886
11055
|
|
|
10887
11056
|
// dist/sources/command.js
|
|
10888
|
-
import { existsSync as
|
|
10889
|
-
import { CliError as
|
|
10890
|
-
import { annotate as
|
|
10891
|
-
import { addedSourceKeyOf, environmentOf as environmentOf4, FETCH as FETCH2, LOCAL_READ as
|
|
11057
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
11058
|
+
import { CliError as CliError29 } from "@wirecat/cli-base";
|
|
11059
|
+
import { annotate as annotate7 } from "@wirecat/cli-base/commands";
|
|
11060
|
+
import { addedSourceKeyOf, environmentOf as environmentOf4, FETCH as FETCH2, LOCAL_READ as LOCAL_READ6, LOCAL_WRITE as LOCAL_WRITE6, REMOTE_READ } from "@wirecat/cli-core";
|
|
10892
11061
|
import { agentPictureReader, aiImageReader, MAX_TEXT_CHARS } from "@wirecat/cli-core/documents";
|
|
10893
11062
|
import { InvalidArgumentError as InvalidArgumentError5 } from "commander";
|
|
10894
11063
|
|
|
10895
11064
|
// dist/notes/embed.js
|
|
10896
|
-
import { existsSync as
|
|
10897
|
-
import { join as
|
|
10898
|
-
import { isCliError as
|
|
11065
|
+
import { existsSync as existsSync6, readdirSync as readdirSync4 } from "node:fs";
|
|
11066
|
+
import { join as join10 } from "node:path";
|
|
11067
|
+
import { isCliError as isCliError5 } from "@wirecat/cli-base";
|
|
10899
11068
|
import { chosenTextModel, embedNotes as embedNoteChunksOf, sharedModelsDirectory, textModels } from "@wirecat/cli-core";
|
|
10900
11069
|
var EMBED_PER_RUN = 600;
|
|
10901
11070
|
var MEASURED_WITH = "e5-small";
|
|
@@ -10907,19 +11076,19 @@ var embedPerRun = /* @__PURE__ */ __name((env = process.env) => {
|
|
|
10907
11076
|
return Math.max(8, Math.min(EMBED_PER_RUN, Math.round(EMBED_PER_RUN * ratio)));
|
|
10908
11077
|
}, "embedPerRun");
|
|
10909
11078
|
var missingModel = /* @__PURE__ */ __name((error, env) => {
|
|
10910
|
-
const named2 =
|
|
11079
|
+
const named2 = isCliError5(error) ? error.details.model : void 0;
|
|
10911
11080
|
const id = typeof named2 === "string" ? named2 : chosenTextModel(env).id;
|
|
10912
11081
|
return `the ${id} model is not downloaded \u2014 wcat models download ${id}`;
|
|
10913
11082
|
}, "missingModel");
|
|
10914
11083
|
var searchModelPresent = /* @__PURE__ */ __name((env) => {
|
|
10915
11084
|
try {
|
|
10916
|
-
const path =
|
|
10917
|
-
return
|
|
11085
|
+
const path = join10(sharedModelsDirectory("text", env), chosenTextModel(env).id);
|
|
11086
|
+
return existsSync6(path) && readdirSync4(path).length > 0;
|
|
10918
11087
|
} catch {
|
|
10919
11088
|
return false;
|
|
10920
11089
|
}
|
|
10921
11090
|
}, "searchModelPresent");
|
|
10922
|
-
var isMissingModel = /* @__PURE__ */ __name((error) =>
|
|
11091
|
+
var isMissingModel = /* @__PURE__ */ __name((error) => isCliError5(error) && error.details.reason === "model.not-downloaded", "isMissingModel");
|
|
10923
11092
|
var reportOf = /* @__PURE__ */ __name((run2) => {
|
|
10924
11093
|
if (run2 === void 0)
|
|
10925
11094
|
return void 0;
|
|
@@ -10967,7 +11136,7 @@ var embedNoteChunks = /* @__PURE__ */ __name(async (store, { embed = true, env,
|
|
|
10967
11136
|
} catch (error) {
|
|
10968
11137
|
if (!isMissingModel(error))
|
|
10969
11138
|
throw error;
|
|
10970
|
-
const enrichment =
|
|
11139
|
+
const enrichment = isCliError5(error) ? reportOf(error.details.enrichment) : void 0;
|
|
10971
11140
|
return {
|
|
10972
11141
|
chunks: 0,
|
|
10973
11142
|
left: true,
|
|
@@ -10979,14 +11148,14 @@ var embedNoteChunks = /* @__PURE__ */ __name(async (store, { embed = true, env,
|
|
|
10979
11148
|
|
|
10980
11149
|
// dist/sources/copy.js
|
|
10981
11150
|
import { randomUUID } from "node:crypto";
|
|
10982
|
-
import { existsSync as
|
|
10983
|
-
import { isAbsolute, join as
|
|
11151
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync5, renameSync as renameSync3, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "node:fs";
|
|
11152
|
+
import { isAbsolute as isAbsolute2, join as join11, relative as relative5, resolve as resolve5, sep as sep6 } from "node:path";
|
|
10984
11153
|
import { resolvePaths as resolvePaths4 } from "@wirecat/cli-base";
|
|
10985
|
-
var copiesDir = /* @__PURE__ */ __name((env) =>
|
|
10986
|
-
var copyPath = /* @__PURE__ */ __name((env, hash) =>
|
|
11154
|
+
var copiesDir = /* @__PURE__ */ __name((env) => join11(resolvePaths4({ appName: APP.appName, prefix: APP.envPrefix, env }).state, "sources"), "copiesDir");
|
|
11155
|
+
var copyPath = /* @__PURE__ */ __name((env, hash) => join11(copiesDir(env), hash), "copyPath");
|
|
10987
11156
|
var keepCopy = /* @__PURE__ */ __name((env, hash, bytes) => {
|
|
10988
11157
|
const path = copyPath(env, hash);
|
|
10989
|
-
if (
|
|
11158
|
+
if (existsSync7(path))
|
|
10990
11159
|
return { path, wrote: false };
|
|
10991
11160
|
mkdirSync5(copiesDir(env), { recursive: true, mode: 448 });
|
|
10992
11161
|
const partial = `${path}.${randomUUID()}.part`;
|
|
@@ -10995,8 +11164,8 @@ var keepCopy = /* @__PURE__ */ __name((env, hash, bytes) => {
|
|
|
10995
11164
|
return { path, wrote: true };
|
|
10996
11165
|
}, "keepCopy");
|
|
10997
11166
|
var dropCopy = /* @__PURE__ */ __name((env, path) => {
|
|
10998
|
-
const inside3 =
|
|
10999
|
-
if (!inside3 ||
|
|
11167
|
+
const inside3 = relative5(resolve5(copiesDir(env)), resolve5(path));
|
|
11168
|
+
if (!inside3 || isAbsolute2(inside3) || inside3.startsWith("..") || inside3.includes(sep6) || !existsSync7(path))
|
|
11000
11169
|
return false;
|
|
11001
11170
|
rmSync2(path);
|
|
11002
11171
|
return true;
|
|
@@ -11072,15 +11241,15 @@ ${note.text}`);
|
|
|
11072
11241
|
}, "namedIn");
|
|
11073
11242
|
|
|
11074
11243
|
// dist/sources/suggest-command.js
|
|
11075
|
-
import { CliError as
|
|
11076
|
-
import { annotate as
|
|
11244
|
+
import { CliError as CliError28 } from "@wirecat/cli-base";
|
|
11245
|
+
import { annotate as annotate6 } from "@wirecat/cli-base/commands";
|
|
11077
11246
|
import { HOST_PATTERN, hostFetch } from "@wirecat/cli-base/http";
|
|
11078
11247
|
import { defineQuery } from "@wirecat/cli-base/query";
|
|
11079
|
-
import { environmentOf as environmentOf3, FETCH, LOCAL_READ as
|
|
11248
|
+
import { environmentOf as environmentOf3, FETCH, LOCAL_READ as LOCAL_READ5, LOCAL_WRITE as LOCAL_WRITE5, listQuery, nativeTerms, termField as termField2, typedQuery, withQuery as withQuery3 } from "@wirecat/cli-core";
|
|
11080
11249
|
import { aiSettingPath as aiSettingPath2, readAiSetting as readAiSetting2 } from "@wirecat/cli-core/documents";
|
|
11081
11250
|
|
|
11082
11251
|
// dist/sources/readers/ai-model.js
|
|
11083
|
-
import { CliError as
|
|
11252
|
+
import { CliError as CliError21, isCliError as isCliError6 } from "@wirecat/cli-base";
|
|
11084
11253
|
import { aiLeavesComputer, aiSettingPath, aiTextReader, readAiSetting } from "@wirecat/cli-core/documents";
|
|
11085
11254
|
var SET = "wcat models ai set";
|
|
11086
11255
|
var chosen = /* @__PURE__ */ __name((context2) => aiTextReader({
|
|
@@ -11133,21 +11302,21 @@ var aiModel = {
|
|
|
11133
11302
|
read: /* @__PURE__ */ __name(async (context2, { system, prompt }) => {
|
|
11134
11303
|
const found = reader(context2);
|
|
11135
11304
|
if ("refused" in found)
|
|
11136
|
-
throw found.refused === "ai.not-set" ? new
|
|
11305
|
+
throw found.refused === "ai.not-set" ? new CliError21("configuration_error", problemOf(found.refused), { reason: "reader.ai-not-set" }) : new CliError21("authentication_error", problemOf(found.refused), { reason: "reader.no-key" });
|
|
11137
11306
|
try {
|
|
11138
11307
|
return await found.complete({ purpose: "sources", system, prompt, maxTokens: 4096 });
|
|
11139
11308
|
} catch (error) {
|
|
11140
|
-
if (
|
|
11141
|
-
throw new
|
|
11309
|
+
if (isCliError6(error) && error.code === "rate_limited")
|
|
11310
|
+
throw new CliError21("rate_limited", `${found.by} says the limit is reached; try later`, {
|
|
11142
11311
|
reason: "reader.limit"
|
|
11143
11312
|
});
|
|
11144
|
-
throw new
|
|
11313
|
+
throw new CliError21("invalid_response", `${found.by} failed: wcat models ai check names the cause (key, model, credit or address)`, { reason: "reader.failed" });
|
|
11145
11314
|
}
|
|
11146
11315
|
}, "read")
|
|
11147
11316
|
};
|
|
11148
11317
|
|
|
11149
11318
|
// dist/sources/readers/api.js
|
|
11150
|
-
import { CliError as
|
|
11319
|
+
import { CliError as CliError22, isCliError as isCliError7 } from "@wirecat/cli-base";
|
|
11151
11320
|
import { modelGateway } from "@wirecat/cli-core";
|
|
11152
11321
|
|
|
11153
11322
|
// dist/sources/readers/keys.js
|
|
@@ -11195,7 +11364,7 @@ var apiReader = /* @__PURE__ */ __name((provider, title) => ({
|
|
|
11195
11364
|
read: /* @__PURE__ */ __name(async (context2, { system, prompt, model }) => {
|
|
11196
11365
|
const key = providerKeys(context2).read(provider);
|
|
11197
11366
|
if (key === void 0)
|
|
11198
|
-
throw new
|
|
11367
|
+
throw new CliError22("authentication_error", `no ${title} key: wcat models ai set ${provider} --secret-stdin`, {
|
|
11199
11368
|
reason: "reader.no-key"
|
|
11200
11369
|
});
|
|
11201
11370
|
const gateway = modelGateway({
|
|
@@ -11209,9 +11378,9 @@ var apiReader = /* @__PURE__ */ __name((provider, title) => ({
|
|
|
11209
11378
|
try {
|
|
11210
11379
|
return (await gateway.complete({ purpose: "sources", system, prompt, maxTokens: 4096 })).text;
|
|
11211
11380
|
} catch (error) {
|
|
11212
|
-
if (
|
|
11213
|
-
throw new
|
|
11214
|
-
throw new
|
|
11381
|
+
if (isCliError7(error) && error.code === "rate_limited")
|
|
11382
|
+
throw new CliError22("rate_limited", `${title} says the limit is reached; try later`, { reason: "reader.limit" });
|
|
11383
|
+
throw new CliError22("invalid_response", `${title} failed: check the key (wcat models ai set ${provider} --secret-stdin), the model and the account's credit`, { reason: "reader.failed" });
|
|
11215
11384
|
}
|
|
11216
11385
|
}, "read")
|
|
11217
11386
|
}), "apiReader");
|
|
@@ -11221,12 +11390,12 @@ var anthropicReader = apiReader("anthropic", "Anthropic");
|
|
|
11221
11390
|
// dist/sources/readers/claude-code.js
|
|
11222
11391
|
import { mkdtempSync, rmSync as rmSync3 } from "node:fs";
|
|
11223
11392
|
import { tmpdir } from "node:os";
|
|
11224
|
-
import { join as
|
|
11225
|
-
import { CliError as
|
|
11393
|
+
import { join as join12 } from "node:path";
|
|
11394
|
+
import { CliError as CliError24 } from "@wirecat/cli-base";
|
|
11226
11395
|
|
|
11227
11396
|
// dist/sources/readers/process.js
|
|
11228
11397
|
import { spawn } from "node:child_process";
|
|
11229
|
-
import { CliError as
|
|
11398
|
+
import { CliError as CliError23 } from "@wirecat/cli-base";
|
|
11230
11399
|
var TIMEOUT_MS = 6e5;
|
|
11231
11400
|
var MAX_OUTPUT = 4 * 1024 * 1024;
|
|
11232
11401
|
var WITHHELD = ["ANTHROPIC_API_KEY", "OPENAI_API_KEY", "CLAUDECODE", "AI_AGENT"];
|
|
@@ -11251,14 +11420,14 @@ var runProgram = /* @__PURE__ */ __name((program, args, { env, cwd, stdin, signa
|
|
|
11251
11420
|
if (error.code === "ENOENT")
|
|
11252
11421
|
resolve6(void 0);
|
|
11253
11422
|
else if (error.name === "AbortError")
|
|
11254
|
-
reject(new
|
|
11423
|
+
reject(new CliError23("cancelled", `${program} was stopped`));
|
|
11255
11424
|
else
|
|
11256
11425
|
reject(error);
|
|
11257
11426
|
});
|
|
11258
11427
|
child.on("close", (code, killed) => {
|
|
11259
11428
|
clearTimeout(timer);
|
|
11260
11429
|
if (killed === "SIGTERM" && code === null)
|
|
11261
|
-
return reject(new
|
|
11430
|
+
return reject(new CliError23("timeout", `${program} gave no answer in time, or too long an answer`, {
|
|
11262
11431
|
reason: "reader.timeout"
|
|
11263
11432
|
}));
|
|
11264
11433
|
resolve6({ code, stdout: Buffer.concat(out).toString("utf8"), stderr: Buffer.concat(err).toString("utf8") });
|
|
@@ -11302,7 +11471,7 @@ var claudeCode = {
|
|
|
11302
11471
|
};
|
|
11303
11472
|
}, "probe"),
|
|
11304
11473
|
read: /* @__PURE__ */ __name(async ({ env, signal }, { system, prompt, model }) => {
|
|
11305
|
-
const folder = mkdtempSync(
|
|
11474
|
+
const folder = mkdtempSync(join12(tmpdir(), "files-reader-"));
|
|
11306
11475
|
try {
|
|
11307
11476
|
const ran = await runProgram("claude", [
|
|
11308
11477
|
"--print",
|
|
@@ -11322,9 +11491,9 @@ var claudeCode = {
|
|
|
11322
11491
|
...model ? ["--model", model] : []
|
|
11323
11492
|
], { env, cwd: folder, stdin: prompt, ...signal ? { signal } : {} });
|
|
11324
11493
|
if (!ran)
|
|
11325
|
-
throw new
|
|
11494
|
+
throw new CliError24("configuration_error", "Claude Code is not installed", { reason: "reader.unavailable" });
|
|
11326
11495
|
if (ran.code !== 0)
|
|
11327
|
-
throw new
|
|
11496
|
+
throw new CliError24("invalid_response", `Claude Code failed: ${firstLine2(ran.stderr || ran.stdout)}`, {
|
|
11328
11497
|
reason: "reader.failed"
|
|
11329
11498
|
});
|
|
11330
11499
|
return ran.stdout;
|
|
@@ -11337,8 +11506,8 @@ var claudeCode = {
|
|
|
11337
11506
|
// dist/sources/readers/codex.js
|
|
11338
11507
|
import { mkdtempSync as mkdtempSync2, readFileSync as readFileSync6, rmSync as rmSync4 } from "node:fs";
|
|
11339
11508
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
11340
|
-
import { join as
|
|
11341
|
-
import { CliError as
|
|
11509
|
+
import { join as join13 } from "node:path";
|
|
11510
|
+
import { CliError as CliError25 } from "@wirecat/cli-base";
|
|
11342
11511
|
var codex = {
|
|
11343
11512
|
id: "codex",
|
|
11344
11513
|
title: "Codex CLI",
|
|
@@ -11361,8 +11530,8 @@ var codex = {
|
|
|
11361
11530
|
};
|
|
11362
11531
|
}, "probe"),
|
|
11363
11532
|
read: /* @__PURE__ */ __name(async ({ env, signal }, { system, prompt, model }) => {
|
|
11364
|
-
const folder = mkdtempSync2(
|
|
11365
|
-
const answer =
|
|
11533
|
+
const folder = mkdtempSync2(join13(tmpdir2(), "files-reader-"));
|
|
11534
|
+
const answer = join13(folder, "answer.txt");
|
|
11366
11535
|
try {
|
|
11367
11536
|
const ran = await runProgram(
|
|
11368
11537
|
"codex",
|
|
@@ -11389,9 +11558,9 @@ var codex = {
|
|
|
11389
11558
|
${prompt}`, ...signal ? { signal } : {} }
|
|
11390
11559
|
);
|
|
11391
11560
|
if (!ran)
|
|
11392
|
-
throw new
|
|
11561
|
+
throw new CliError25("configuration_error", "Codex CLI is not installed", { reason: "reader.unavailable" });
|
|
11393
11562
|
if (ran.code !== 0)
|
|
11394
|
-
throw new
|
|
11563
|
+
throw new CliError25("invalid_response", `Codex CLI failed: ${firstLine2(ran.stderr || ran.stdout)}`, {
|
|
11395
11564
|
reason: "reader.failed"
|
|
11396
11565
|
});
|
|
11397
11566
|
try {
|
|
@@ -11406,7 +11575,7 @@ ${prompt}`, ...signal ? { signal } : {} }
|
|
|
11406
11575
|
};
|
|
11407
11576
|
|
|
11408
11577
|
// dist/sources/readers/ollama.js
|
|
11409
|
-
import { CliError as
|
|
11578
|
+
import { CliError as CliError26 } from "@wirecat/cli-base";
|
|
11410
11579
|
import { onThisComputer as onThisComputer2 } from "@wirecat/cli-core";
|
|
11411
11580
|
var OLLAMA = "http://127.0.0.1:11434";
|
|
11412
11581
|
var ollamaAddressAllowed = /* @__PURE__ */ __name((value) => {
|
|
@@ -11424,12 +11593,12 @@ var addressOf = /* @__PURE__ */ __name((env) => {
|
|
|
11424
11593
|
if (given === void 0)
|
|
11425
11594
|
return OLLAMA;
|
|
11426
11595
|
if (!ollamaAddressAllowed(given))
|
|
11427
|
-
throw new
|
|
11596
|
+
throw new CliError26("configuration_error", `sources.base_url ${given} is not on this computer`, {
|
|
11428
11597
|
reason: "reader.address-refused"
|
|
11429
11598
|
});
|
|
11430
11599
|
return given.replace(/\/+$/, "");
|
|
11431
11600
|
}, "addressOf");
|
|
11432
|
-
var notRunning = /* @__PURE__ */ __name(() => new
|
|
11601
|
+
var notRunning = /* @__PURE__ */ __name(() => new CliError26("provider_unavailable", "Ollama is not running on this computer: start it with ollama serve", {
|
|
11433
11602
|
reason: "reader.not-running"
|
|
11434
11603
|
}), "notRunning");
|
|
11435
11604
|
var ollama = {
|
|
@@ -11475,12 +11644,12 @@ var ollama = {
|
|
|
11475
11644
|
throw notRunning();
|
|
11476
11645
|
}
|
|
11477
11646
|
if (response.status === 404)
|
|
11478
|
-
throw new
|
|
11647
|
+
throw new CliError26("not_found", `Ollama has no model ${model}: ollama pull ${model}`, {
|
|
11479
11648
|
reason: "reader.model-missing"
|
|
11480
11649
|
});
|
|
11481
11650
|
const body = await response.json().catch(() => ({}));
|
|
11482
11651
|
if (!response.ok || typeof body.response !== "string")
|
|
11483
|
-
throw new
|
|
11652
|
+
throw new CliError26("invalid_response", `Ollama answered ${response.status}`, { reason: "reader.failed" });
|
|
11484
11653
|
return body.response;
|
|
11485
11654
|
}, "read")
|
|
11486
11655
|
};
|
|
@@ -11495,7 +11664,7 @@ var readerOf2 = /* @__PURE__ */ __name((id) => READERS.find((reader2) => reader2
|
|
|
11495
11664
|
|
|
11496
11665
|
// dist/sources/suggest.js
|
|
11497
11666
|
import { createHash as createHash5, randomUUID as randomUUID2 } from "node:crypto";
|
|
11498
|
-
import { CliError as
|
|
11667
|
+
import { CliError as CliError27 } from "@wirecat/cli-base";
|
|
11499
11668
|
import { FACT_TYPES, QUOTE_LIMIT, quoteKept } from "@wirecat/cli-core";
|
|
11500
11669
|
var PROMPT_VERSION = "facts-1";
|
|
11501
11670
|
var READER_BOT = "files-reader";
|
|
@@ -11527,7 +11696,7 @@ var objectIn = /* @__PURE__ */ __name((answer) => {
|
|
|
11527
11696
|
var factsIn = /* @__PURE__ */ __name((answer, text2) => {
|
|
11528
11697
|
const body = objectIn(answer);
|
|
11529
11698
|
if (!body || !Array.isArray(body.facts))
|
|
11530
|
-
throw new
|
|
11699
|
+
throw new CliError27("invalid_response", "the reader's answer was not the JSON files asked for; nothing was staged", {
|
|
11531
11700
|
reason: "reader.unusable-answer"
|
|
11532
11701
|
});
|
|
11533
11702
|
const facts = [];
|
|
@@ -11653,25 +11822,25 @@ var readerHosts = /* @__PURE__ */ __name((env) => {
|
|
|
11653
11822
|
var READ_TIMEOUT_MS = 15 * 6e4;
|
|
11654
11823
|
var isAgentServer = /* @__PURE__ */ __name((command, _env) => environmentOf3(command).agent !== void 0, "isAgentServer");
|
|
11655
11824
|
var unknownReader = /* @__PURE__ */ __name((id) => {
|
|
11656
|
-
throw new
|
|
11825
|
+
throw new CliError28("validation_error", `${id} is not a reader files knows; it reads with ${READER_IDS.join(", ")}`, {
|
|
11657
11826
|
reason: "reader.unknown",
|
|
11658
11827
|
reader: id,
|
|
11659
11828
|
readers: READER_IDS
|
|
11660
11829
|
});
|
|
11661
11830
|
}, "unknownReader");
|
|
11662
|
-
var fixedModel = /* @__PURE__ */ __name((reader2) => new
|
|
11831
|
+
var fixedModel = /* @__PURE__ */ __name((reader2) => new CliError28("validation_error", `${reader2.title} reads with the model wcat models ai set chose; --model is not taken`, {
|
|
11663
11832
|
reason: "input.invalid",
|
|
11664
11833
|
param: "model"
|
|
11665
11834
|
}), "fixedModel");
|
|
11666
11835
|
var chosen2 = /* @__PURE__ */ __name((env, who, given) => {
|
|
11667
11836
|
if (who !== "owner" && (given.reader !== void 0 || given.model !== void 0))
|
|
11668
|
-
throw new
|
|
11837
|
+
throw new CliError28("permission_error", "only the owner picks the reader; an agent uses the one the owner chose", {
|
|
11669
11838
|
reason: "reader.owner-picks"
|
|
11670
11839
|
});
|
|
11671
11840
|
const config = loadConfig(env).sources;
|
|
11672
11841
|
const id = given.reader ?? config?.reader;
|
|
11673
11842
|
if (id === void 0)
|
|
11674
|
-
throw new
|
|
11843
|
+
throw new CliError28("configuration_error", `no reader is chosen for sources; the owner picks one of ${READER_IDS.join(", ")} with files sources readers set <reader>, or names it with --provider`, { reason: "reader.none-chosen", readers: READER_IDS });
|
|
11675
11844
|
const reader2 = readerOf2(id) ?? unknownReader(id);
|
|
11676
11845
|
if (reader2.modelOf) {
|
|
11677
11846
|
if (given.model !== void 0)
|
|
@@ -11680,14 +11849,14 @@ var chosen2 = /* @__PURE__ */ __name((env, who, given) => {
|
|
|
11680
11849
|
}
|
|
11681
11850
|
const model = given.model ?? (given.reader === void 0 || given.reader === config?.reader ? config?.model : void 0);
|
|
11682
11851
|
if (reader2.needsModel && !model)
|
|
11683
|
-
throw new
|
|
11852
|
+
throw new CliError28("configuration_error", `${reader2.title} reads only with a model the owner names: files sources readers set ${reader2.id} --model <model>`, { reason: "reader.model-missing" });
|
|
11684
11853
|
return { reader: reader2, model: model ?? null };
|
|
11685
11854
|
}, "chosen");
|
|
11686
11855
|
var documentRef = /* @__PURE__ */ __name(async (store, reference) => {
|
|
11687
11856
|
await refuseBareNumber(store, reference, ["document", "note"]);
|
|
11688
11857
|
const ref = reference.trim();
|
|
11689
11858
|
if (!/^(document|note):[1-9]\d*$/.test(ref))
|
|
11690
|
-
throw new
|
|
11859
|
+
throw new CliError28("validation_error", `${reference} is not a source; give its document:<id>`, {
|
|
11691
11860
|
reason: "input.invalid"
|
|
11692
11861
|
});
|
|
11693
11862
|
return ref;
|
|
@@ -11703,22 +11872,22 @@ var readerCommands = /* @__PURE__ */ __name((program, sources, streams, env, dep
|
|
|
11703
11872
|
}),
|
|
11704
11873
|
...deps.keyring ? { keyring: deps.keyring } : {}
|
|
11705
11874
|
}), "context");
|
|
11706
|
-
byOption(
|
|
11875
|
+
byOption(annotate6(sources.command("suggest"), { effects: FETCH, output: { entity: "source_suggestion" } }).summary("have the chosen reader propose facts from a source, for you to confirm").description("send a source's text to the reader you chose and stage the facts it finds, each with a quote checked against the text, as one batch only you confirm")).argument("<ref>", "document:<id> of the source, as sources add answered").option("--provider <provider>", `read with this reader once: ${READER_IDS.join(", ")}; only you name one`).option("--model <model>", "the reader's model this once; only you may name one").option("--subject <ref>", "who or what every fact is about: person:, organization:, project: or task:").option("--rescan", "read it again although this reader already read this text").action(async (reference, options, command) => {
|
|
11707
11876
|
if (isAgentServer(command, env))
|
|
11708
|
-
throw new
|
|
11877
|
+
throw new CliError28("permission_error", "over MCP an agent cannot send a source's text to a reader");
|
|
11709
11878
|
const who = await whoRuns(command, env, { asOwner: options.asOwner, question: "read this source as you?" });
|
|
11710
11879
|
const { reader: reader2, model } = chosen2(env, who, { reader: options.provider, model: options.model });
|
|
11711
11880
|
const item = await withStore(env, async (store) => {
|
|
11712
11881
|
const ref = await documentRef(store, reference);
|
|
11713
11882
|
const subject = options.subject === void 0 ? null : (await subjectOf(store, options.subject)).ref;
|
|
11714
11883
|
if (subject !== null && !SUBJECT.test(subject))
|
|
11715
|
-
throw new
|
|
11884
|
+
throw new CliError28("validation_error", "a suggested fact is about a person:, organization:, project: or task:", {
|
|
11716
11885
|
reason: "input.invalid",
|
|
11717
11886
|
param: "subject"
|
|
11718
11887
|
});
|
|
11719
11888
|
const record2 = await store.evidenceFindings.citable(ref);
|
|
11720
11889
|
if (!record2)
|
|
11721
|
-
throw new
|
|
11890
|
+
throw new CliError28("not_found", `${ref} is not stored`, { reason: "input.invalid" });
|
|
11722
11891
|
const done = await suggestFacts(store, context2(), {
|
|
11723
11892
|
record: record2,
|
|
11724
11893
|
reader: reader2,
|
|
@@ -11755,8 +11924,8 @@ var readerCommands = /* @__PURE__ */ __name((program, sources, streams, env, dep
|
|
|
11755
11924
|
].join("\n"));
|
|
11756
11925
|
});
|
|
11757
11926
|
const readers = sources.command("readers").summary("the readers that can propose facts from a source, and which one you chose").description("the readers that can propose facts from a source: installed, signed in, and which one you chose");
|
|
11758
|
-
withQuery3(
|
|
11759
|
-
effects:
|
|
11927
|
+
withQuery3(annotate6(readers.command("list", { isDefault: true }), {
|
|
11928
|
+
effects: LOCAL_READ5,
|
|
11760
11929
|
output: { entity: "source_reader" }
|
|
11761
11930
|
}), READERS_QUERY).summary("each reader: installed, signed in, and your pick").description("each reader: installed, signed in, its model, whether the text leaves this computer, and your pick").action(async (words, options) => {
|
|
11762
11931
|
const terms = nativeTerms(listQuery(typedQuery(words), READERS_QUERY, "sources readers list"), "sources readers list");
|
|
@@ -11785,27 +11954,27 @@ var readerCommands = /* @__PURE__ */ __name((program, sources, streams, env, dep
|
|
|
11785
11954
|
const items = all.filter((item) => (flag("available") === void 0 || String(item.available) === flag("available")) && (flag("chosen") === void 0 || String(item.chosen) === flag("chosen")));
|
|
11786
11955
|
print(options.json, listAnswer("sources readers list", { items, limit: Math.max(1, items.length), has_more: false }), items.map((item) => `${item.chosen ? "*" : " "} ${item.id.padEnd(12)} ${item.problem ?? "ready"}${item.model ? ` model ${item.model}` : ""}${item.leavesComputer ? "" : " stays on this computer"}`).join("\n"));
|
|
11787
11956
|
});
|
|
11788
|
-
byOption(
|
|
11957
|
+
byOption(annotate6(readers.command("set"), { effects: LOCAL_WRITE5, output: { entity: "source_reader_choice" } }).summary("choose the reader that reads your sources").description("choose the reader sources suggest sends a source's text to, and its model; only you choose")).argument("<reader>", READER_IDS.join(", ")).option("--model <model>", "its model; Ollama and the API readers need one, Claude Code and Codex use their own").option("--base-url <url>", `Ollama only: its address on this computer, when not ${OLLAMA}`).action(async (id, options, command) => {
|
|
11789
11958
|
if (isAgentServer(command, env))
|
|
11790
|
-
throw new
|
|
11959
|
+
throw new CliError28("permission_error", "only the owner picks the reader", { reason: "reader.owner-picks" });
|
|
11791
11960
|
const who = await whoRuns(command, env, { asOwner: options.asOwner, question: `read sources with ${id}?` });
|
|
11792
11961
|
if (who !== "owner")
|
|
11793
|
-
throw new
|
|
11962
|
+
throw new CliError28("permission_error", "only the owner picks the reader that reads a source", {
|
|
11794
11963
|
reason: "reader.owner-picks"
|
|
11795
11964
|
});
|
|
11796
11965
|
const reader2 = readerOf2(id) ?? unknownReader(id);
|
|
11797
11966
|
if (reader2.modelOf && options.model !== void 0)
|
|
11798
11967
|
throw fixedModel(reader2);
|
|
11799
11968
|
if (reader2.needsModel && !options.model?.trim())
|
|
11800
|
-
throw new
|
|
11969
|
+
throw new CliError28("validation_error", `${reader2.title} needs --model <model>`, {
|
|
11801
11970
|
reason: "reader.model-missing",
|
|
11802
11971
|
param: "model"
|
|
11803
11972
|
});
|
|
11804
11973
|
const baseUrl = options.baseUrl?.trim().replace(/\/+$/, "") || void 0;
|
|
11805
11974
|
if (baseUrl !== void 0 && reader2.id !== ollama.id)
|
|
11806
|
-
throw new
|
|
11975
|
+
throw new CliError28("validation_error", "--base-url is for the ollama reader", { param: "base-url" });
|
|
11807
11976
|
if (baseUrl !== void 0 && !ollamaAddressAllowed(baseUrl))
|
|
11808
|
-
throw new
|
|
11977
|
+
throw new CliError28("validation_error", "Ollama is read only on this computer: give http://127.0.0.1:<port>", {
|
|
11809
11978
|
reason: "reader.address-refused",
|
|
11810
11979
|
param: "base-url"
|
|
11811
11980
|
});
|
|
@@ -11847,7 +12016,7 @@ var documentRef2 = /* @__PURE__ */ __name(async (store, reference) => {
|
|
|
11847
12016
|
await refuseBareNumber(store, reference, ["document"]);
|
|
11848
12017
|
const ref = reference.trim();
|
|
11849
12018
|
if (!/^document:[1-9]\d*$/.test(ref))
|
|
11850
|
-
throw new
|
|
12019
|
+
throw new CliError29("validation_error", `${reference} is not a source; give its document:<id>`, {
|
|
11851
12020
|
reason: "input.invalid"
|
|
11852
12021
|
});
|
|
11853
12022
|
return ref;
|
|
@@ -11885,12 +12054,12 @@ var imageLine = /* @__PURE__ */ __name((image) => image.read_by ? `read by ${ima
|
|
|
11885
12054
|
var sourcesCommand = /* @__PURE__ */ __name((program, streams, env, { fetch, readers = {} } = {}) => {
|
|
11886
12055
|
const { print, run: run2 } = answers(program, streams, env);
|
|
11887
12056
|
const sources = program.command("sources").summary("files, web pages and text you add by hand").description("sources you add by hand: pasted text, a file or a web page, kept as searchable documents");
|
|
11888
|
-
byOption(reasonOption(
|
|
12057
|
+
byOption(reasonOption(annotate7(sources.command("add"), { effects: FETCH2, output: { entity: "added_source" } }).summary("keep a file, a web page or pasted text as a document").description("keep a file, a web page or pasted text as a document of its own; only its text is kept unless --keep-copy"))).argument("<source>", "a file's path, an http(s) address, or - to read the text from stdin").option("--title <title>", "a title; otherwise the page's or file's own, or the text's first line").option("--subject <ref>", SUBJECT_HELP, collect).option("--keep-copy", "also keep a copy of the file in files' data folder, so it opens after the file is gone").option("--max-chars <n>", `most characters of text to keep, up to ${MAX_TEXT_CHARS} (default ${SOURCE_TEXT_CHARS})`, between(1, MAX_TEXT_CHARS, "--max-chars")).action(async (given, options, command) => {
|
|
11889
12058
|
const kind = argumentKind(given);
|
|
11890
12059
|
if (isAgentServer2(command, env) && kind !== "text")
|
|
11891
|
-
throw new
|
|
12060
|
+
throw new CliError29("permission_error", "over MCP a source is added as text only, never from a path or a link");
|
|
11892
12061
|
if (options.keepCopy && kind !== "path")
|
|
11893
|
-
throw new
|
|
12062
|
+
throw new CliError29("validation_error", "--keep-copy keeps a file; a link or pasted text keeps its text only", {
|
|
11894
12063
|
reason: "input.invalid",
|
|
11895
12064
|
param: "keep_copy"
|
|
11896
12065
|
});
|
|
@@ -11978,13 +12147,13 @@ var sourcesCommand = /* @__PURE__ */ __name((program, streams, env, { fetch, rea
|
|
|
11978
12147
|
...item.subjects.length ? [` about: ${item.subjects.join(", ")}`] : []
|
|
11979
12148
|
].join("\n"));
|
|
11980
12149
|
});
|
|
11981
|
-
|
|
12150
|
+
annotate7(sources.command("preview"), { effects: REMOTE_READ, output: { entity: "source_preview" } }).summary("read a web page as sources add would, and keep nothing").description("read a web page as sources add would, with the same refusals, and say what would be kept; nothing is saved").argument("<url>", "an http(s) address").action(async (given, options, command) => {
|
|
11982
12151
|
if (isAgentServer2(command, env))
|
|
11983
|
-
throw new
|
|
12152
|
+
throw new CliError29("permission_error", "an agent over MCP cannot make files fetch an address", {
|
|
11984
12153
|
reason: "source.agent-fetch"
|
|
11985
12154
|
});
|
|
11986
12155
|
if (argumentKind(given) !== "url")
|
|
11987
|
-
throw new
|
|
12156
|
+
throw new CliError29("validation_error", "give an http(s) address; a file is previewed by the app that picked it", {
|
|
11988
12157
|
reason: "input.invalid"
|
|
11989
12158
|
});
|
|
11990
12159
|
const read = await readPage(given, { maxChars: SOURCE_TEXT_CHARS, ...fetch ? { fetch } : {} }).catch((error) => {
|
|
@@ -11998,7 +12167,7 @@ var sourcesCommand = /* @__PURE__ */ __name((program, streams, env, { fetch, rea
|
|
|
11998
12167
|
...item.excerpt ? [` \u201C${item.excerpt}\u201D`] : []
|
|
11999
12168
|
].join("\n"));
|
|
12000
12169
|
});
|
|
12001
|
-
|
|
12170
|
+
annotate7(sources.command("show"), { effects: LOCAL_READ6, output: { entity: "source_detail" } }).summary("one source: its text, what is kept, and what cites it").description("one source: its text, what is kept, what it is about, and the facts, memories and batches citing it").argument("<ref>", "document:<id>, as sources add answered").option("--bytes <bytes>", `most UTF-8 bytes of its text, up to ${MAX_TEXT_BYTES} (default ${TEXT_BYTES})`, between(1, MAX_TEXT_BYTES, "--bytes")).action((reference, options) => run2(options.json, async (store) => {
|
|
12002
12171
|
const ref = await documentRef2(store, reference);
|
|
12003
12172
|
const source = await store.notes.addedSource(ref);
|
|
12004
12173
|
const note = source?.note ?? await store.notes.note(ref);
|
|
@@ -12014,7 +12183,7 @@ var sourcesCommand = /* @__PURE__ */ __name((program, streams, env, { fetch, rea
|
|
|
12014
12183
|
mime: source?.mime ?? null,
|
|
12015
12184
|
bytes: source?.size ?? null,
|
|
12016
12185
|
// The row says a copy was kept; only the file itself says it still is.
|
|
12017
|
-
kept: source === void 0 ? null : source.copy !== null &&
|
|
12186
|
+
kept: source === void 0 ? null : source.copy !== null && existsSync8(source.copy) ? "copy" : "text",
|
|
12018
12187
|
chars: note.text.length,
|
|
12019
12188
|
text: text2,
|
|
12020
12189
|
textTruncated: truncated,
|
|
@@ -12025,7 +12194,7 @@ var sourcesCommand = /* @__PURE__ */ __name((program, streams, env, { fetch, rea
|
|
|
12025
12194
|
batches: await batchesCiting(store, ref)
|
|
12026
12195
|
});
|
|
12027
12196
|
}));
|
|
12028
|
-
|
|
12197
|
+
annotate7(sources.command("mentions"), { effects: LOCAL_READ6, output: { entity: "source_mention" } }).summary("known people and organizations named in a source").description("people and organizations files knows whose names appear in a source's text; nothing leaves").argument("<ref>", "document:<id>").action((reference, options) => run2(options.json, async (store) => {
|
|
12029
12198
|
const ref = await documentRef2(store, reference);
|
|
12030
12199
|
const found = await namedIn(store, await store.notes.note(ref));
|
|
12031
12200
|
return listAnswer("sources mentions", {
|
|
@@ -12042,7 +12211,7 @@ var sourcesCommand = /* @__PURE__ */ __name((program, streams, env, { fetch, rea
|
|
|
12042
12211
|
}
|
|
12043
12212
|
});
|
|
12044
12213
|
}));
|
|
12045
|
-
byOption(
|
|
12214
|
+
byOption(annotate7(sources.command("remove"), { effects: LOCAL_WRITE6, output: { entity: "source_removal" } }).summary("remove a source you added, and its kept copy").description("remove a source you added, and its copy if one was kept; the next source check reviews what cites it")).argument("<ref>", "document:<id> of a source you added").action(async (reference, options, command) => {
|
|
12046
12215
|
const who = await whoRuns(command, env, { asOwner: options.asOwner, question: "remove this source as you?" });
|
|
12047
12216
|
const by = who === "owner" ? "owner" : { bot: who.bot, reason: "files sources remove" };
|
|
12048
12217
|
await run2(options.json, async (store) => {
|
|
@@ -12062,23 +12231,23 @@ var sourcesCommand = /* @__PURE__ */ __name((program, streams, env, { fetch, rea
|
|
|
12062
12231
|
|
|
12063
12232
|
// dist/sync.js
|
|
12064
12233
|
import { errorCodes } from "@wirecat/cli-base";
|
|
12065
|
-
import { annotate as
|
|
12234
|
+
import { annotate as annotate8 } from "@wirecat/cli-base/commands";
|
|
12066
12235
|
import { environmentOf as environmentOf5, FETCH as FETCH3, markStoreDamaged, notLocalPaths as notLocalPaths2, openStore as openStore2, setExitCode, storePath } from "@wirecat/cli-core";
|
|
12067
|
-
import { attachmentMaxBytes as attachmentMaxBytes4, sizeText as sizeText3 } from "@wirecat/cli-core/documents";
|
|
12236
|
+
import { attachmentMaxBytes as attachmentMaxBytes4, scanReader, sizeText as sizeText3 } from "@wirecat/cli-core/documents";
|
|
12068
12237
|
import { Option } from "commander";
|
|
12069
12238
|
|
|
12070
12239
|
// dist/failure.js
|
|
12071
|
-
import { CliError as
|
|
12240
|
+
import { CliError as CliError30, errorObjectOf } from "@wirecat/cli-base";
|
|
12072
12241
|
import { failureContext, storeDamaged } from "@wirecat/cli-core";
|
|
12073
12242
|
import { CommanderError } from "commander";
|
|
12074
12243
|
var context = failureContext(APP.errors ?? { reasons: [] });
|
|
12075
12244
|
var recognisable = /* @__PURE__ */ __name((error) => {
|
|
12076
12245
|
if (error instanceof CommanderError)
|
|
12077
|
-
return new
|
|
12246
|
+
return new CliError30("validation_error", error.message.replace(/^error: /, ""), { reason: "input.invalid" });
|
|
12078
12247
|
if (error instanceof ValiError) {
|
|
12079
12248
|
const [issue] = error.issues;
|
|
12080
12249
|
const param = issue?.path?.map((item) => String(item.key)).join(".");
|
|
12081
|
-
return new
|
|
12250
|
+
return new CliError30("validation_error", issue?.message ?? "the input is not valid", {
|
|
12082
12251
|
reason: "input.invalid",
|
|
12083
12252
|
...param ? { param } : {}
|
|
12084
12253
|
});
|
|
@@ -12110,14 +12279,18 @@ var NOT_READ = {
|
|
|
12110
12279
|
"needs-agent": "no text in it, such as a scanned PDF",
|
|
12111
12280
|
unreadable: "the file is damaged or locked"
|
|
12112
12281
|
};
|
|
12113
|
-
var notReadReason = /* @__PURE__ */ __name((status, engine) => status === "engine-missing" ? `needs the ${engine ?? "missing"} reader` : status === "too-large" ? `larger than ${sizeText3(attachmentMaxBytes4())}; configure MESSAGING_ATTACHMENT_MAX_MIB` : NOT_READ[status] ?? status, "notReadReason");
|
|
12282
|
+
var notReadReason = /* @__PURE__ */ __name((status, engine, reason) => reason !== void 0 ? reason : status === "engine-missing" ? `needs the ${engine ?? "missing"} reader` : status === "too-large" ? `larger than ${sizeText3(attachmentMaxBytes4())}; configure MESSAGING_ATTACHMENT_MAX_MIB` : NOT_READ[status] ?? status, "notReadReason");
|
|
12114
12283
|
var enrichmentLine = /* @__PURE__ */ __name((run2) => `enrichment: ${run2.enriched} of ${run2.sent} records sent${run2.provider ? ` to ${run2.provider} ${run2.model}` : ""}` + (run2.costUsd === null ? "" : `, $${run2.costUsd}`) + (run2.left > 0 ? `, ${run2.left} left` : "") + (run2.status === "done" ? "" : ` \u2014 ${run2.status}: ${run2.reason ?? "no reason given"}`), "enrichmentLine");
|
|
12115
12284
|
var text = /* @__PURE__ */ __name((run2) => [
|
|
12116
12285
|
...run2.notes.flatMap((n) => [
|
|
12117
12286
|
`notes ${n.folder}: ${n.notes} notes, ${n.changed} changed, ${n.renamed} moved, ${n.deleted} gone` + (n.notRead ? `, ${n.notRead.length} not read` : "") + (n.deletionsSkipped === void 0 ? "" : ` \u2014 deletions skipped: ${n.deletionsSkipped}`),
|
|
12118
|
-
...(n.notRead ?? []).slice(0, NOT_READ_SHOWN).map(({ path, status, engine }) => ` not read: ${path} \u2014 ${notReadReason(status, engine)}`),
|
|
12119
|
-
...(n.notRead?.length ?? 0) > NOT_READ_SHOWN ? [` and ${(n.notRead?.length ?? 0) - NOT_READ_SHOWN} more not read \u2014 --json lists them all`] : []
|
|
12287
|
+
...(n.notRead ?? []).slice(0, NOT_READ_SHOWN).map(({ path, status, engine, reason }) => ` not read: ${path} \u2014 ${reason !== void 0 && reason === n.ocr?.unavailable ? "waits for OCR, below" : notReadReason(status, engine, reason)}`),
|
|
12288
|
+
...(n.notRead?.length ?? 0) > NOT_READ_SHOWN ? [` and ${(n.notRead?.length ?? 0) - NOT_READ_SHOWN} more not read \u2014 --json lists them all`] : [],
|
|
12289
|
+
...n.ocr === void 0 ? [] : [
|
|
12290
|
+
` OCR${run2.scans?.engine ? ` (${run2.scans.engine})` : ""}: ${n.ocr.read} read, ${n.ocr.notRead} not read` + (n.ocr.picturesWaiting ? `, ${n.ocr.picturesWaiting} pictures waiting` : "") + (n.ocr.unavailable ? ` \u2014 ${n.ocr.unavailable}` : "")
|
|
12291
|
+
]
|
|
12120
12292
|
]),
|
|
12293
|
+
...run2.scans?.warning ? [`warning: ${run2.scans.warning}`] : [],
|
|
12121
12294
|
...run2.notesEmbedded === void 0 ? [] : [
|
|
12122
12295
|
`notes by meaning: ${run2.notesEmbedded.chunks} chunks embedded` + (run2.notesEmbedded.notEmbedded !== void 0 ? ` \u2014 ${run2.notesEmbedded.notEmbedded}` : run2.notesEmbedded.left ? " \u2014 more next run" : "")
|
|
12123
12296
|
],
|
|
@@ -12133,7 +12306,7 @@ var failureReason = /* @__PURE__ */ __name((error, failure, debug) => {
|
|
|
12133
12306
|
}, "failureReason");
|
|
12134
12307
|
var syncCommand = /* @__PURE__ */ __name((program, streams, env, keyring) => {
|
|
12135
12308
|
const { print } = answers(program, streams, env);
|
|
12136
|
-
notLocalPaths2(
|
|
12309
|
+
notLocalPaths2(annotate8(program.command("sync"), { effects: FETCH3 }), "folder", "ignore").summary("bring the notes folders up to date in the store and searchable by meaning").description("bring every configured notes folder up to date in the store, only what changed, and embed the new chunks for search by meaning. Every configured folder unless narrowed; --timeout keeps the progress made so far").addOption(new Option("--folder <folder>", "only this configured folder, by its id or path; repeat for more").argParser(collect)).addOption(new Option("--ignore <path>", "leave this file or folder alone this run, a path or a glob; repeat for more").argParser(collect)).option("--no-embed", "skip embedding notes for search by meaning this run").action(async (options, command) => {
|
|
12137
12310
|
const stop = environmentOf5(command).signal;
|
|
12138
12311
|
const halt = /* @__PURE__ */ __name(() => {
|
|
12139
12312
|
if (stop?.aborted)
|
|
@@ -12175,10 +12348,24 @@ var syncCommand = /* @__PURE__ */ __name((program, streams, env, keyring) => {
|
|
|
12175
12348
|
const ignore = config.notes?.ignore ?? [];
|
|
12176
12349
|
const skip = options.ignore ?? [];
|
|
12177
12350
|
const json = command.optsWithGlobals().json !== void 0;
|
|
12351
|
+
const choice = readScans(command);
|
|
12352
|
+
const scans = folders.length > 0 ? await scanReader(choice, {
|
|
12353
|
+
app: APP,
|
|
12354
|
+
env,
|
|
12355
|
+
command: APP.command,
|
|
12356
|
+
...keyring ? { keyring } : {},
|
|
12357
|
+
...stop ? { signal: stop } : {}
|
|
12358
|
+
}) : void 0;
|
|
12359
|
+
if (scans)
|
|
12360
|
+
run2.scans = {
|
|
12361
|
+
readScans: choice,
|
|
12362
|
+
engine: scans.extractor ?? null,
|
|
12363
|
+
...scans.warning ? { warning: scans.warning } : {}
|
|
12364
|
+
};
|
|
12178
12365
|
for (const folder of folders)
|
|
12179
12366
|
await attempt(`notes ${folder.path}`, async () => {
|
|
12180
12367
|
const onFile = progressLine(streams.diagnostic, json, { step: "notes", unit: "files", label: folder.id });
|
|
12181
|
-
run2.notes.push(await importNotes(store, folder, { ignore, skip, env, onFile }));
|
|
12368
|
+
run2.notes.push(await importNotes(store, folder, { ignore, skip, env, onFile, ...scans ? { scans } : {} }));
|
|
12182
12369
|
});
|
|
12183
12370
|
if (folders.length > 0)
|
|
12184
12371
|
await attempt("notes by meaning", async () => {
|
|
@@ -12212,7 +12399,7 @@ var update = appUpdate({
|
|
|
12212
12399
|
command: IDENTITY.command,
|
|
12213
12400
|
version: IDENTITY.version,
|
|
12214
12401
|
entry: new URL("../program.js", import.meta.url).href,
|
|
12215
|
-
statePath: /* @__PURE__ */ __name((env) =>
|
|
12402
|
+
statePath: /* @__PURE__ */ __name((env) => join14(resolvePaths6({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }).state, "update-check.json"), "statePath"),
|
|
12216
12403
|
// biome-ignore lint/plugin/no-own-settings: the update check runs before any command exists to give baseContext
|
|
12217
12404
|
enabled: /* @__PURE__ */ __name((env) => configuration.resolveSettings({}, { env, needsProfile: false }).updateCheck, "enabled"),
|
|
12218
12405
|
offVariables: [`${IDENTITY.envPrefix}_NO_UPDATE_CHECK`]
|
|
@@ -12229,6 +12416,7 @@ var fileCommands = /* @__PURE__ */ __name((options) => {
|
|
|
12229
12416
|
const keyring = options.keyring;
|
|
12230
12417
|
const root = new Command(IDENTITY.command);
|
|
12231
12418
|
notesCommand(root, streams, env);
|
|
12419
|
+
noteLinksCommand(root, streams, env);
|
|
12232
12420
|
foldersCommand(root, streams, env);
|
|
12233
12421
|
sourcesCommand(root, streams, env, {
|
|
12234
12422
|
...options.fetchPage ? { fetch: options.fetchPage } : {},
|
|
@@ -12263,7 +12451,7 @@ var definition = /* @__PURE__ */ __name((options = {}) => ({
|
|
|
12263
12451
|
commands: /* @__PURE__ */ __name(() => [
|
|
12264
12452
|
...fileCommands(options),
|
|
12265
12453
|
commandsCommand(IDENTITY),
|
|
12266
|
-
appDoctorCommand(IDENTITY, configuration, { packageName: PACKAGE }),
|
|
12454
|
+
appDoctorCommand(IDENTITY, configuration, { packageName: PACKAGE, local: notesFolderCheck }),
|
|
12267
12455
|
skillCommand(IDENTITY, SKILL),
|
|
12268
12456
|
mcpCommand(),
|
|
12269
12457
|
upgradeCommand(IDENTITY, PACKAGE, (command) => ({
|