strom-research 1.32.0 → 1.33.0-beta.2
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.cs.md +24 -0
- package/CHANGELOG.de.md +28 -0
- package/CHANGELOG.md +24 -0
- package/CHANGELOG.pl.md +27 -0
- package/assets/archives.json +2 -2
- package/assets/lang/cs.json +1 -1
- package/assets/lang/de.json +1 -1
- package/assets/lang/pl.json +1 -1
- package/assets/method/core.md +4 -1
- package/assets/method/enrich.md +3 -1
- package/assets/method/locate.md +2 -1
- package/assets/method/waiting.md +7 -5
- package/dist/agents/files.js +3 -2
- package/dist/brief/brief.js +41 -15
- package/dist/brief/sheet.js +16 -6
- package/dist/cli/execute.js +40 -9
- package/dist/cli/registry.js +3 -3
- package/dist/commands/analysis.js +68 -12
- package/dist/commands/archives.js +14 -4
- package/dist/commands/connectors.js +14 -3
- package/dist/commands/grep.js +6 -4
- package/dist/commands/history.js +58 -9
- package/dist/commands/media.js +383 -57
- package/dist/commands/query.js +1 -1
- package/dist/commands/sources.js +1 -1
- package/dist/commands/tasks.js +11 -2
- package/dist/core/browser.js +112 -13
- package/dist/core/browserhelp.js +6 -1
- package/dist/core/byhand.js +18 -1
- package/dist/core/grep.js +36 -3
- package/dist/core/indexfirst.js +57 -21
- package/dist/core/live.js +21 -1
- package/dist/core/phrases.js +1 -1
- package/dist/core/sync.js +69 -3
- package/dist/core/tree.js +1 -1
- package/package.json +4 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { actsAsArchive } from "../core/state.js";
|
|
3
3
|
import { register } from "../cli/registry.js";
|
|
4
4
|
import { ui } from "../cli/ui.js";
|
|
5
|
-
import { counted, lines, moreLine, paginate, table, truncate } from "../cli/format.js";
|
|
5
|
+
import { counted, lines, moreLine, paginate, shellArg, table, truncate } from "../cli/format.js";
|
|
6
6
|
import { UsageError } from "../core/errors.js";
|
|
7
7
|
import { LESSON_DETAIL_MAX, LESSON_MAX, LESSON_SCOPES, RECORD_TYPES, SEARCH_METHODS, SEARCH_RESULTS, VARIANT_LINK_KINDS, } from "../core/model.js";
|
|
8
8
|
import { create, csvOpt, listOpt, normId, requireRecord, update } from "../core/records.js";
|
|
@@ -258,28 +258,51 @@ function searchLine(s) {
|
|
|
258
258
|
}
|
|
259
259
|
/** What a found search needs before it: the source it found (N0181, N0187: the search written first). */
|
|
260
260
|
const FOUND_FIRST = "the source first, then the search: strom source add \"…\" … — in one batch the source add line first, ending #s, then search add … --found @s";
|
|
261
|
+
/** The options of strom search add, in the order the hint retypes them. */
|
|
262
|
+
const SEARCH_ADD_OPTS = ["recordset", "years", "surname", "place", "pages", "method", "result", "task", "by", "note"];
|
|
263
|
+
/**
|
|
264
|
+
* A found search typed without the source it found (1114 C10: four times in one session): the order, and this very
|
|
265
|
+
* command again with --found — the next thing to run, once the source is recorded.
|
|
266
|
+
*/
|
|
267
|
+
function foundFirst(question, opts) {
|
|
268
|
+
const said = SEARCH_ADD_OPTS.flatMap((o) => listOpt(opts[o]).flatMap((v) => [`--${o}`, shellArg(v)]));
|
|
269
|
+
return new UsageError("result found needs --found <S…>: the source it found is recorded first", {
|
|
270
|
+
code: "search.found.first",
|
|
271
|
+
hint: lines('1. strom source add "…" --kind … --recordset … --locator … (its answer names the source: S…)', `2. strom search add ${[shellArg(question), ...said, "--found", "<S…>"].join(" ")}`, "in one batch: the source add line first, ending #s, then search add … --found @s"),
|
|
272
|
+
});
|
|
273
|
+
}
|
|
261
274
|
register({
|
|
262
275
|
path: ["search", "add"],
|
|
263
276
|
summary: "Record a search — ALSO when nothing was found (negative results are results)",
|
|
264
277
|
group: "analysis",
|
|
265
|
-
sheet: "found:
|
|
278
|
+
sheet: "found: in this order — strom source add … → strom search add … --result found --found <S…> (in a batch source add … #s, then --found @s)",
|
|
266
279
|
tree: true,
|
|
267
280
|
writes: true,
|
|
281
|
+
description: "Every search is recorded, the one that found nothing too. A search that found something cites what it found, so\n" +
|
|
282
|
+
"the source comes first, in this order:\n" +
|
|
283
|
+
' 1. strom source add "…" --kind … --recordset … --locator … (its answer names the source: S…)\n' +
|
|
284
|
+
" 2. strom search add \"…\" … --result found --found <S…>\n" +
|
|
285
|
+
"In one batch: the source add line first, ending #s, then search add … --found @s. A source found later is added\n" +
|
|
286
|
+
"with strom search edit <Q…> --found <S…>.",
|
|
268
287
|
args: [{ name: "question", description: 'what was looked for: "Baptisms Novák 1903–1907"', required: true }],
|
|
269
288
|
options: [
|
|
270
289
|
{ name: "recordset", type: "string", multiple: true, value: "<B…>", description: "where (repeatable)", aliases: ["where"] },
|
|
271
290
|
{ name: "years", type: "string", value: "<from-to>", description: "years covered" },
|
|
272
|
-
{ name: "surname", type: "string", multiple: true, value: "<name>", description: "surnames looked for (repeatable)", aliases: ["surnames"] },
|
|
291
|
+
{ name: "surname", type: "string", multiple: true, value: "<name>", description: "surnames looked for (repeatable)", aliases: ["surnames"], mistaken: ["about"] },
|
|
273
292
|
{ name: "place", type: "string", multiple: true, value: "<name>", description: "places covered (repeatable)" },
|
|
274
293
|
{ name: "pages", type: "string", value: "<range>", description: "images/pages covered, e.g. 95-100" },
|
|
275
294
|
{ name: "method", type: "string", value: "<m>", description: SEARCH_METHODS.join(", ") },
|
|
276
295
|
{ name: "result", type: "string", value: "<r>", description: SEARCH_RESULTS.join(", ") },
|
|
277
296
|
{ name: "found", type: "string", multiple: true, value: "<S…>", description: "sources found (repeatable; required with --result found)" },
|
|
278
|
-
{ name: "task", type: "string", value: "<T…>", description: "task this search served (default: the task of the open session)" },
|
|
279
|
-
{ name: "by", type: "string", value: "<who>", description: "main (default), reader, user" },
|
|
297
|
+
{ name: "task", type: "string", value: "<T…>", description: "task this search served (default: the task of the open session) — the people it is about are the task's", mistaken: ["about"] },
|
|
298
|
+
{ name: "by", type: "string", value: "<who>", description: "main (default; agent is the same), reader, user" },
|
|
280
299
|
{ name: "note", type: "string", value: "<text>", description: "what was illegible, what is left" },
|
|
281
300
|
],
|
|
282
|
-
examples: [
|
|
301
|
+
examples: [
|
|
302
|
+
'strom search add "Křty Novák 1903-1907" --recordset B0001 --years 1903-1907 --surname Novák --method page-by-page --result negative --task T0001',
|
|
303
|
+
'strom source add "Křest Jana Lhotáka 1905" --kind baptism --recordset B0001 --locator "fol. 12"',
|
|
304
|
+
'strom search add "Křty Lhoták 1903-1907" --recordset B0001 --years 1903-1907 --method page-by-page --result found --found S0001',
|
|
305
|
+
],
|
|
283
306
|
run(ctx, { args, opts }) {
|
|
284
307
|
const tree = ctx.tree();
|
|
285
308
|
const recordsets = csvOpt(opts.recordset).map((b) => requireRecord(tree, b, "recordset").id);
|
|
@@ -288,7 +311,7 @@ register({
|
|
|
288
311
|
const findings = csvOpt(opts.found).map((s) => requireRecord(tree, s, "source").id);
|
|
289
312
|
const result = oneOf(opts.result, SEARCH_RESULTS, "result");
|
|
290
313
|
if (result === "found" && findings.length === 0)
|
|
291
|
-
throw
|
|
314
|
+
throw foundFirst(args[0].trim(), opts);
|
|
292
315
|
// A search made in a session served that session's task, unless it says otherwise.
|
|
293
316
|
const session = currentSession(tree, ctx.env, ctx.refs);
|
|
294
317
|
const task = opts.task ? requireRecord(tree, String(opts.task), "task").id : session?.task;
|
|
@@ -308,7 +331,8 @@ register({
|
|
|
308
331
|
result,
|
|
309
332
|
findings,
|
|
310
333
|
task,
|
|
311
|
-
|
|
334
|
+
// "agent": the agent of the session, the main one (what agents type for it)
|
|
335
|
+
by: opts.by === undefined || (typeof opts.by === "string" && foldText(opts.by) === "agent") ? "main" : oneOf(opts.by, ["main", "reader", "user"], "by"),
|
|
312
336
|
note: opts.note,
|
|
313
337
|
}, (id) => `+${id} search [${result}] "${truncate(args[0], 50)}"`, [...recordsets, ...findings]);
|
|
314
338
|
return { text: lines(written(tree), ...said), data: { search: s } };
|
|
@@ -348,7 +372,8 @@ register({
|
|
|
348
372
|
writes: true,
|
|
349
373
|
description: "Only the options given change; lists (--recordset, --surname, --place, --found) replace the old ones; --note adds a note.\n" +
|
|
350
374
|
"A search is evidence — a negative one above all: changing where it looked, how, or what came out needs --reason;\n" +
|
|
351
|
-
"filling in what was not recorded doesn't."
|
|
375
|
+
"filling in what was not recorded doesn't. A source attached by mistake: --drop-found <S…> takes it off, --no-found\n" +
|
|
376
|
+
"takes off every one; a search found with no source left says what it is now (--result negative|partial|inconclusive).",
|
|
352
377
|
args: [{ name: "search", description: "search ID (Q0001)", required: true }],
|
|
353
378
|
options: [
|
|
354
379
|
{ name: "question", type: "string", value: "<text>", description: "what was looked for" },
|
|
@@ -361,15 +386,37 @@ register({
|
|
|
361
386
|
{ name: "method", type: "string", value: "<m>", description: SEARCH_METHODS.join(", ") },
|
|
362
387
|
{ name: "result", type: "string", value: "<r>", description: SEARCH_RESULTS.join(", ") },
|
|
363
388
|
{ name: "found", type: "string", multiple: true, value: "<S…>", description: "sources found (repeatable; replaces)" },
|
|
389
|
+
{ name: "drop-found", type: "string", multiple: true, value: "<S…>", description: "take off a source attached by mistake (repeatable; with --reason)" },
|
|
390
|
+
{ name: "no-found", type: "boolean", description: "take off every source found (with --reason)" },
|
|
364
391
|
{ name: "task", type: "string", value: "<T…>", description: "task this search served" },
|
|
365
392
|
{ name: "note", type: "string", value: "<text>", description: "add a note" },
|
|
366
393
|
],
|
|
367
|
-
examples: [
|
|
394
|
+
examples: [
|
|
395
|
+
'strom search edit Q0001 --recordset B0002 --reason "the index belongs to the other volume"',
|
|
396
|
+
'strom search edit Q0001 --pages 95-100 --note "images 101-104 unreadable"',
|
|
397
|
+
'strom search edit Q0003 --drop-found S0002 --reason "attached to the wrong search"',
|
|
398
|
+
],
|
|
368
399
|
run(ctx, { args, opts }) {
|
|
369
400
|
const tree = ctx.tree();
|
|
370
|
-
const
|
|
401
|
+
const was = requireRecord(tree, args[0], "search");
|
|
402
|
+
const id = was.id;
|
|
371
403
|
if (opts["no-recordset"] && csvOpt(opts.recordset).length)
|
|
372
404
|
throw new UsageError("--recordset or --no-recordset, not both");
|
|
405
|
+
// the sources found: replaced (--found), one taken off (--drop-found) or every one (--no-found) — 1114 C9: --found ""
|
|
406
|
+
// read as nothing to change
|
|
407
|
+
const given = { found: opts.found !== undefined, drop: csvOpt(opts["drop-found"]).length > 0, none: !!opts["no-found"] };
|
|
408
|
+
if ([given.found, given.drop, given.none].filter(Boolean).length > 1)
|
|
409
|
+
throw new UsageError("--found, --drop-found or --no-found, one of them", { code: "search.found.which" });
|
|
410
|
+
if (given.found && !csvOpt(opts.found).length)
|
|
411
|
+
throw new UsageError("--found names no source", {
|
|
412
|
+
code: "search.found.empty",
|
|
413
|
+
hint: `a source attached by mistake: strom search edit ${id} --drop-found <S…> --reason "…" (every one: --no-found)`,
|
|
414
|
+
});
|
|
415
|
+
const dropped = csvOpt(opts["drop-found"]).map((s) => normId(s, "source"));
|
|
416
|
+
for (const s of dropped)
|
|
417
|
+
if (!was.findings.includes(s))
|
|
418
|
+
throw new UsageError(`${id} has no source found ${s}`, { code: "search.found.not", hint: was.findings.length ? `its sources found: ${was.findings.join(" ")}` : `strom search show ${id}` });
|
|
419
|
+
const findings = given.found ? csvOpt(opts.found).map((s) => requireRecord(tree, s, "source").id) : given.drop ? was.findings.filter((s) => !dropped.includes(s)) : given.none ? [] : undefined;
|
|
373
420
|
const said = [];
|
|
374
421
|
const years = yearsOption(opts.years, said);
|
|
375
422
|
const scope = {
|
|
@@ -384,7 +431,7 @@ register({
|
|
|
384
431
|
...(opts["no-recordset"] ? { recordsets: [] } : {}),
|
|
385
432
|
...(opts.method !== undefined ? { method: oneOf(opts.method, SEARCH_METHODS, "method") } : {}),
|
|
386
433
|
...(opts.result !== undefined ? { result: oneOf(opts.result, SEARCH_RESULTS, "result") } : {}),
|
|
387
|
-
...(
|
|
434
|
+
...(findings ? { findings } : {}),
|
|
388
435
|
...(opts.task ? { task: requireRecord(tree, String(opts.task), "task").id } : {}),
|
|
389
436
|
};
|
|
390
437
|
const note = typeof opts.note === "string" && opts.note.trim() ? makeNotes(tree, opts.note) : undefined;
|
|
@@ -393,6 +440,15 @@ register({
|
|
|
393
440
|
throw new UsageError("nothing to change", { hint: `strom help search edit` });
|
|
394
441
|
const reason = typeof opts.reason === "string" && opts.reason.trim() ? opts.reason.trim() : undefined;
|
|
395
442
|
const s = update(tree, id, "search", (cur) => {
|
|
443
|
+
// found with nothing left: what it is now is said in the same command (a found search cites what it found)
|
|
444
|
+
if ((given.drop || given.none) && (change.result ?? cur.result) === "found" && !change.findings.length) {
|
|
445
|
+
const taken = given.none ? "--no-found" : dropped.map((s) => `--drop-found ${s}`).join(" ");
|
|
446
|
+
throw new UsageError(`${id} would be found with no source left: say what it is now`, {
|
|
447
|
+
code: "search.found.none",
|
|
448
|
+
params: { search: id },
|
|
449
|
+
hint: `strom search edit ${id} ${taken} --result negative|partial|inconclusive --reason "…" — or --found <S…>: the source it did find`,
|
|
450
|
+
});
|
|
451
|
+
}
|
|
396
452
|
// What was recorded as searched is evidence: overwriting it needs a reason, filling it in doesn't.
|
|
397
453
|
const was = { recordsets: cur.recordsets, method: cur.method, result: cur.result, findings: cur.findings, ...cur.scope };
|
|
398
454
|
const now = { ...change, ...scope };
|
|
@@ -355,7 +355,7 @@ async function askPerson(ctx, c, missing, way) {
|
|
|
355
355
|
* permission stays as given, the direct way is never taken. Its ways for the agent, in words and in --json (details):
|
|
356
356
|
* the person's permission "through the browser" where the agent's browser could help (one strom keeps), else by hand.
|
|
357
357
|
*/
|
|
358
|
-
export function browserOnlyRefusal(ctx, c, a, images, pages = false) {
|
|
358
|
+
export function browserOnlyRefusal(ctx, c, a, images, pages = false, catalogue = false) {
|
|
359
359
|
const agent = detectAgent(ctx.env);
|
|
360
360
|
// what the agent's own browser may do there (none for an agent whose browser strom does not keep)
|
|
361
361
|
const root = ctx.hasTree() ? ctx.tree().root : undefined;
|
|
@@ -365,8 +365,17 @@ export function browserOnlyRefusal(ctx, c, a, images, pages = false) {
|
|
|
365
365
|
const allow = `strom allow archive ${a.host} --way browser`;
|
|
366
366
|
const manual = byHand(ctx, images);
|
|
367
367
|
const kept = a.permission === "slow" ? ` — the person's permission "slowly" from before is kept as given, and takes no direct request there` : "";
|
|
368
|
-
|
|
369
|
-
|
|
368
|
+
// finding a book (--find, --list): never through strom there — its catalogue on the archive's own site, page by page
|
|
369
|
+
// through the agent's browser strom keeps (the person allowed it "through the browser"), else the person's
|
|
370
|
+
const site = `https://${a.host}/`;
|
|
371
|
+
const find = !catalogue
|
|
372
|
+
? ""
|
|
373
|
+
: agent && browserHelps(a) && a.permission === "browser" && browserKept(agent, root, ctx.env)
|
|
374
|
+
? `find the book on the archive's own site through your browser instead (${site} — its catalogue page by page, at a person's pace), then record it: strom recordset add "<title>" --url <the book's page there> --places <place> --years <from-to> --kinds <kinds>; its images then one at a time: strom media save. `
|
|
375
|
+
: `the book is found on the archive's own site (${site}) by a person: strom task wait ${taskHere(ctx) ?? "T…"} --check ${site} --on "<which book: the place, the years, the kind — impersonal, in the research language>". `;
|
|
376
|
+
return new UsageError(`${a.title ?? a.host} lets automated tools in only through a person's browser (${browserWhy(a)}) — no direct request through ${c.name}, a probe or your web tools${catalogue ? ", finding its books neither" : ""}${kept}`, {
|
|
377
|
+
hint: find +
|
|
378
|
+
`go on with another way to the same records (another archive, the parish, an index, a catalogue), or the user saves what the research needs by hand: ${manual}` +
|
|
370
379
|
`${pages ? "" : " — only a connector whose pages come from the person's browser (browser.pages) goes there, with the person's permission"}` +
|
|
371
380
|
`${advice ? `; ${advice}` : browser && a.permission !== "browser" ? `; its images through the agent's browser, one at a time, only with the person's permission "through the browser" (${allow} — the person's)` : ""}`,
|
|
372
381
|
code: "archive.browser",
|
|
@@ -379,6 +388,7 @@ export function browserOnlyRefusal(ctx, c, a, images, pages = false) {
|
|
|
379
388
|
...(a.permission ? { permission: a.permission } : {}),
|
|
380
389
|
...(browser && a.permission !== "browser" ? { browser: allow } : {}),
|
|
381
390
|
manual,
|
|
391
|
+
...(find ? { find: find.trim() } : {}),
|
|
382
392
|
},
|
|
383
393
|
});
|
|
384
394
|
}
|
|
@@ -421,7 +431,7 @@ export async function gateArchive(ctx, c, o) {
|
|
|
421
431
|
// only a person's browser goes there: nothing straight through strom — a connector without the browser's pages has no way
|
|
422
432
|
const browserOnly = levels.find((a) => a.browserOnly && (!pages || !allows(a, activity, route).ok && allows(a, activity, route).why === "browser"));
|
|
423
433
|
if (browserOnly)
|
|
424
|
-
throw browserOnlyRefusal(ctx, c, browserOnly, o.images, pages);
|
|
434
|
+
throw browserOnlyRefusal(ctx, c, browserOnly, o.images, pages, activity === "catalogue");
|
|
425
435
|
if (o.closedOnly)
|
|
426
436
|
return { levels, human: new Map() };
|
|
427
437
|
const missing = levels.filter((a) => {
|
|
@@ -1322,6 +1322,9 @@ register({
|
|
|
1322
1322
|
"downloads folder, and --take, which takes them over from there, checked and registered.\n" +
|
|
1323
1323
|
"A connector whose portal answers a real browser only (browser.pages: a bot check) has every page read\n" +
|
|
1324
1324
|
"there too: each run plans the page it needs next, --take gives it to the connector and goes on.\n" +
|
|
1325
|
+
"An archive only a person's browser goes to (strom's list, its robots.txt) takes no other connector's request,\n" +
|
|
1326
|
+
"--find and --list neither: its books are found on its own site (your browser strom keeps, with the person's\n" +
|
|
1327
|
+
"permission \"through the browser\", else the person), its images saved one at a time with strom media save.\n" +
|
|
1325
1328
|
"--background (with --recordset, in a session) fetches by a strom of its own while you work on — the images\n" +
|
|
1326
1329
|
"this session reads (never for a later one): strom read of the book reads them as they come. It belongs to\n" +
|
|
1327
1330
|
"your session and the task it is for (--task T…; without it the one task this session worked on that names\n" +
|
|
@@ -2995,10 +2998,18 @@ async function takeOver(ctx, c, result) {
|
|
|
2995
2998
|
const pagePlans = all.filter((p) => p.pages?.length);
|
|
2996
2999
|
const pagesHere = got.some((g) => g.page) || pagePlans.some((p) => p.pages.some((pg) => findDownload(dir, pg.file).file));
|
|
2997
3000
|
const imagesHere = all.some((p) => p.items.some((i) => findDownload(dir, i.file).file));
|
|
3001
|
+
// the script's line names images and no page: it was a script of images — what it saved (or not) is said of them,
|
|
3002
|
+
// never "no page taken over" of a page plan lying there
|
|
3003
|
+
const imagesSaid = got.some((g) => !g.page) && !got.some((g) => g.page);
|
|
3004
|
+
// a page plan whose script is over (it refuses to run past its time) and whose page never came holds nothing back
|
|
3005
|
+
const now = Date.now();
|
|
3006
|
+
const livePages = pagePlans.filter((p) => now <= p.until + PLAN_TTL_MS || p.pages.some((pg) => findDownload(dir, pg.file).file));
|
|
3007
|
+
const imagePlans = all.some((p) => p.items.length);
|
|
3008
|
+
const toPages = pagePlans.length > 0 && !imagesSaid && (pagesHere || (!imagesHere && (livePages.length > 0 || !imagePlans)));
|
|
2998
3009
|
// a plan made before (another strom, the terms since known): taken over only as the archive's terms let it now (D12)
|
|
2999
3010
|
if (all.length && !tree.dryRun)
|
|
3000
|
-
await gateArchive(ctx, c, { activity:
|
|
3001
|
-
if (
|
|
3011
|
+
await gateArchive(ctx, c, { activity: toPages ? "catalogue" : "images", route: "browser", ask: false });
|
|
3012
|
+
if (toPages && !tree.dryRun)
|
|
3002
3013
|
return takePages(ctx, c, pagePlans, result);
|
|
3003
3014
|
const plans = all.filter((p) => p.items.length);
|
|
3004
3015
|
if (!plans.length)
|
|
@@ -3096,7 +3107,7 @@ async function takeOver(ctx, c, result) {
|
|
|
3096
3107
|
text: lines(taken.length
|
|
3097
3108
|
? `${counted(taken.length, "image")} taken over from ${ctx.display(dir)}${added.length ? `: registered ${added.map((a) => a.id).join(" ")}` : ""}${inboxed.length ? ` into the inbox: ${[...new Set(inboxed)].join(", ")}/ — register them: strom media add --inbox ${shellArg(inboxed[0])} --recordset B…` : ""}`
|
|
3098
3109
|
: `nothing taken over from ${ctx.display(dir)}`, again.length ? ` already registered: ${again.join(" ")}` : undefined, woken.length ? ` back in the queue (they waited for these images): ${woken.join(" ")}` : undefined, ...notes.map((n) => ` ⚠ ${n}`), lost.length
|
|
3099
|
-
? ` images ${nums(lost)}: the browser fetched them but saved nothing here — Chrome lets a site download one file until the user allows automatic downloads for it (at the right end of the address bar), or it asks where to save each file (Settings → Downloads). Then plan them again: strom fetch ${c.name} ${lost[0].plan.book} --images ${nums(lost)}${lost[0].plan.recordset ? ` --recordset ${lost[0].plan.recordset}` : ""}`
|
|
3110
|
+
? ` images ${nums(lost)}: the browser fetched them but saved nothing here — Chrome lets a site download one file until the user allows automatic downloads for it (at the right end of the address bar), or it asks where to save each file (Settings → Downloads) — in the browser profile your browser tool works in (a permission given in another profile does not count). Tell the user exactly that: it is the person's to allow, never change the browser's settings yourself, and running the take again brings nothing. Then plan them again: strom fetch ${c.name} ${lost[0].plan.book} --images ${nums(lost)}${lost[0].plan.recordset ? ` --recordset ${lost[0].plan.recordset}` : ""}`
|
|
3100
3111
|
: undefined, notYet.length ? ` still waiting for images ${nums(notYet)}${notYet.some((m) => m.unfinished) ? " (a download is still running)" : ""} — run the script of their plan, or they went elsewhere: strom config set browser.downloads <folder>` : undefined),
|
|
3101
3112
|
data: { taken: taken.map((t) => ({ n: t.item.n, file: t.file })), added, again, woken, inbox: [...new Set(inboxed)], missing: missing.map((m) => m.item.n), notes },
|
|
3102
3113
|
...(!taken.length && missing.length ? { exitCode: 1 } : {}),
|
package/dist/commands/grep.js
CHANGED
|
@@ -102,7 +102,9 @@ register({
|
|
|
102
102
|
code: "grep.outside",
|
|
103
103
|
params: { where: outside },
|
|
104
104
|
});
|
|
105
|
-
const { targets, error, code, params } = grepTargets(tree.root, wanted);
|
|
105
|
+
const { targets, error, code, params, prefixed } = grepTargets(tree.root, wanted);
|
|
106
|
+
// a path no file has, the start of the names of files beside it: those files, said
|
|
107
|
+
const starts = (prefixed ?? []).map((p) => `--in ${p.where}: no such file — the files beginning so: ${p.names.join(", ")}`);
|
|
106
108
|
if (error)
|
|
107
109
|
throw new UsageError(error, { ...(code ? { code, params } : {}), hint: `strom grep ${patterns.map(shellArg).join(" ")} --in ${GREP_FOLDERS.join("|")}|all` });
|
|
108
110
|
let match;
|
|
@@ -126,7 +128,7 @@ register({
|
|
|
126
128
|
const tooBig = found.tooBig.length ? `left out, over 64 MB: ${found.tooBig.join(", ")}` : undefined;
|
|
127
129
|
if (!found.hits.length)
|
|
128
130
|
return {
|
|
129
|
-
text: lines(`not found in ${counted(found.searched, "text file")} of ${where}`, tooBig, cut, "→ the records: strom find <text>"),
|
|
131
|
+
text: lines(...starts, `not found in ${counted(found.searched, "text file")} of ${where}`, tooBig, cut, "→ the records: strom find <text>"),
|
|
130
132
|
data: { total: 0, searched: found.searched, hits: [], ...(found.tooBig.length ? { tooBig: found.tooBig } : {}) },
|
|
131
133
|
};
|
|
132
134
|
const total = `${found.hits.length}${found.capped ? "+" : ""}`;
|
|
@@ -137,13 +139,13 @@ register({
|
|
|
137
139
|
const files = [...found.counts].map(([file, n]) => ({ file, lines: n }));
|
|
138
140
|
const page = paginate(files, ctx.limit, ctx.page);
|
|
139
141
|
return {
|
|
140
|
-
text: lines(head + ":", ...page.items.map((f) => `${f.file}: ${f.lines}`), moreLine(page, again) || undefined, tooBig),
|
|
142
|
+
text: lines(...starts, head + ":", ...page.items.map((f) => `${f.file}: ${f.lines}`), moreLine(page, again) || undefined, tooBig),
|
|
141
143
|
data: { total: found.hits.length, capped: found.capped, searched: found.searched, files: page.items, ...(found.tooBig.length ? { tooBig: found.tooBig } : {}) },
|
|
142
144
|
};
|
|
143
145
|
}
|
|
144
146
|
const page = paginate(found.hits, ctx.limit, ctx.page);
|
|
145
147
|
return {
|
|
146
|
-
text: lines(head + ":", ...grepLines(page.items), moreLine(page, again) || undefined, tooBig, cut),
|
|
148
|
+
text: lines(...starts, head + ":", ...grepLines(page.items), moreLine(page, again) || undefined, tooBig, cut),
|
|
147
149
|
data: { total: found.hits.length, capped: found.capped, searched: found.searched, files: found.counts.size, hits: page.items, ...(found.tooBig.length ? { tooBig: found.tooBig } : {}) },
|
|
148
150
|
};
|
|
149
151
|
},
|
package/dist/commands/history.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// ancestors lived through (the experiment experiments.history, core/pastevents.ts). Behind its gate (hidden): runs
|
|
4
4
|
// when named, shown nowhere until the Strom app shows the events. `strom history` alone stays what changed recently.
|
|
5
5
|
import { register } from "../cli/registry.js";
|
|
6
|
-
import { lines, table } from "../cli/format.js";
|
|
6
|
+
import { lines, shellArg, table } from "../cli/format.js";
|
|
7
7
|
import { ui } from "../cli/ui.js";
|
|
8
8
|
import { StromError, UsageError } from "../core/errors.js";
|
|
9
9
|
import { listOpt, normId } from "../core/records.js";
|
|
@@ -23,7 +23,7 @@ import { isAgent } from "../core/which.js";
|
|
|
23
23
|
// strom history list
|
|
24
24
|
import { moreLine, paginate } from "../cli/format.js";
|
|
25
25
|
import { displayName } from "../core/people.js";
|
|
26
|
-
import { historyOn, readLocal } from "../core/pastevents.js";
|
|
26
|
+
import { eventExists, historyOn, readLocal } from "../core/pastevents.js";
|
|
27
27
|
import { placeRecord } from "../core/placehistory.js";
|
|
28
28
|
import { foldText } from "../core/text.js";
|
|
29
29
|
import { addOtherNames, recordIndex, unlocatePlace } from "../core/placeid.js";
|
|
@@ -260,7 +260,10 @@ register({
|
|
|
260
260
|
}
|
|
261
261
|
const links = listOpt(opts.region).map(regionLink);
|
|
262
262
|
if (!links.length)
|
|
263
|
-
throw new UsageError("--region <id>[:<from>-<to>] (or --unlocated)", {
|
|
263
|
+
throw new UsageError("--region <id>[:<from>-<to>] (or --unlocated)", {
|
|
264
|
+
code: "history.map",
|
|
265
|
+
hint: `strom history map ${shellArg(args[0])} --region <id>[:<from>-<to>] (once for each region it belonged to; the regions: strom history status) — or --unlocated --why "…"`,
|
|
266
|
+
});
|
|
264
267
|
const sh = shared(ctx);
|
|
265
268
|
const missing = [...new Set(links.map((l) => l.id))].filter((id) => !readCatalog(sh, id));
|
|
266
269
|
const name = texts(opts, "name");
|
|
@@ -885,15 +888,18 @@ register({
|
|
|
885
888
|
{ name: "region", type: "string", value: "<id>", description: "everything of this region (no event)" },
|
|
886
889
|
],
|
|
887
890
|
examples: [`strom history ${verb} cz-bohemia-0003 --place "Lhota"`, `strom history ${verb} cz-bohemia-0003 --tree`, `strom history ${verb} --region cz-bohemia`],
|
|
891
|
+
// what it is given is checked before the person is asked (1114 A3: strom history show <event> to read one event put
|
|
892
|
+
// the person's question first): a question whose yes is refused after it is never asked
|
|
893
|
+
refusesFirst(ctx, { args, opts }) {
|
|
894
|
+
hideAsked(ctx, verb, args, opts);
|
|
895
|
+
},
|
|
888
896
|
run(ctx, { args, opts }) {
|
|
889
897
|
const tree = ctx.tree();
|
|
890
898
|
const place = str(opts.place);
|
|
891
899
|
const who = str(opts.person);
|
|
892
900
|
const region = str(opts.region)?.trim();
|
|
893
901
|
const event = args[0]?.trim() || undefined;
|
|
894
|
-
|
|
895
|
-
if (region !== undefined ? event !== undefined || wheres > 0 : event === undefined || wheres !== 1)
|
|
896
|
-
throw new UsageError("an event with --place, --person or --tree (one of them) — or --region alone", { code: "history.body" });
|
|
902
|
+
hideAsked(ctx, verb, args, opts);
|
|
897
903
|
let person;
|
|
898
904
|
if (who !== undefined) {
|
|
899
905
|
try {
|
|
@@ -1012,6 +1018,36 @@ register({
|
|
|
1012
1018
|
return { text, data: { place, map: shown } };
|
|
1013
1019
|
},
|
|
1014
1020
|
});
|
|
1021
|
+
/**
|
|
1022
|
+
* What strom history hide|show is given, checked before anything (the person's question too): an event and where it is
|
|
1023
|
+
* hidden (one of --place, --person, --tree), or a region alone; an event that is there, a person that is. An event
|
|
1024
|
+
* alone is what an agent types to read it: said how it is read (strom history list --event).
|
|
1025
|
+
*/
|
|
1026
|
+
function hideAsked(ctx, verb, args, opts) {
|
|
1027
|
+
const event = args[0]?.trim() || undefined;
|
|
1028
|
+
const region = str(opts.region)?.trim();
|
|
1029
|
+
const who = str(opts.person);
|
|
1030
|
+
const wheres = [str(opts.place) !== undefined, who !== undefined, !!opts.tree].filter(Boolean).length;
|
|
1031
|
+
const read = event ? `one event read: strom history list --event ${event} (--json)` : "the events, each with its ID: strom history list";
|
|
1032
|
+
if (region !== undefined ? event !== undefined || wheres > 0 : event === undefined || wheres !== 1)
|
|
1033
|
+
throw new UsageError(`strom history ${verb}: an event with --place, --person or --tree (one of them) — or --region alone`, {
|
|
1034
|
+
code: "history.body",
|
|
1035
|
+
hint: `${read} — hiding and showing again is the person's: strom history ${verb} <event> --place <place>|--person <P…>|--tree`,
|
|
1036
|
+
});
|
|
1037
|
+
if (event === undefined)
|
|
1038
|
+
return;
|
|
1039
|
+
const tree = ctx.tree();
|
|
1040
|
+
if (!eventExists(tree, ctx.settings.shared()?.value, event))
|
|
1041
|
+
throw new UsageError(`there is no event ${event}`, { code: "history.event", params: { event }, hint: "strom history list: the events, each with its ID" });
|
|
1042
|
+
if (who !== undefined) {
|
|
1043
|
+
try {
|
|
1044
|
+
resolvePerson(tree, who);
|
|
1045
|
+
}
|
|
1046
|
+
catch {
|
|
1047
|
+
throw new UsageError(`there is no person ${who}`, { code: "history.person", params: { person: who } });
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1015
1051
|
// ── strom history list: the events the research shows, readable in the terminal ──
|
|
1016
1052
|
const KIND_TEXT = {
|
|
1017
1053
|
war: "ui.history.kind.war",
|
|
@@ -1095,12 +1131,14 @@ register({
|
|
|
1095
1131
|
description: "The events the Strom app shows (a region's by the years each place belonged to it, a place's own, the local ones read in\n" +
|
|
1096
1132
|
"the research's sources), grouped by region and place, by year. Hidden by the person (at a place, a person, the whole tree,\n" +
|
|
1097
1133
|
"everything of a region) and deleted ones marked. Read only; in an archive too, with the history off too (what was found\n" +
|
|
1098
|
-
"stays). --place: the events at one place (its record L…, or the place as the facts write it); --region: one region's
|
|
1134
|
+
"stays). --place: the events at one place (its record L…, or the place as the facts write it); --region: one region's;\n" +
|
|
1135
|
+
"--event: one event (its ID).",
|
|
1099
1136
|
options: [
|
|
1137
|
+
{ name: "event", type: "string", value: "<id>", description: "only this event, by its ID (cz-bohemia-0003, L0001)" },
|
|
1100
1138
|
{ name: "place", type: "string", value: "<L…|place>", description: "only the events at this place: its record (L…), or the place as the facts write it" },
|
|
1101
1139
|
{ name: "region", type: "string", value: "<id>", description: "only this region's events (strom history status lists the regions)" },
|
|
1102
1140
|
],
|
|
1103
|
-
examples: ["strom history list", "strom history list --place L0003", "strom history list --region cz-bohemia --json"],
|
|
1141
|
+
examples: ["strom history list", "strom history list --place L0003", "strom history list --region cz-bohemia --json", "strom history list --event cz-bohemia-0003 --json"],
|
|
1104
1142
|
run(ctx, { opts }) {
|
|
1105
1143
|
const tree = ctx.tree();
|
|
1106
1144
|
const lang = tree.lang;
|
|
@@ -1142,6 +1180,17 @@ register({
|
|
|
1142
1180
|
throw new UsageError(`no region ${region} at the places of the tree`, { code: "history.region.unknown", params: { region }, hint: "strom history status lists the regions of the tree" });
|
|
1143
1181
|
events = events.filter((e) => e.scope === "region" && e.region?.id === region);
|
|
1144
1182
|
}
|
|
1183
|
+
// --event: that one event (1114 A3: what an agent typed strom history show for)
|
|
1184
|
+
const one = str(opts.event)?.trim();
|
|
1185
|
+
if (one !== undefined) {
|
|
1186
|
+
events = events.filter((e) => e.id.toLowerCase() === one.toLowerCase());
|
|
1187
|
+
if (!events.length)
|
|
1188
|
+
throw new UsageError(`no event ${one} among the events the research shows${givenPlace || region !== undefined ? " there" : ""}`, {
|
|
1189
|
+
code: "history.event",
|
|
1190
|
+
params: { event: one },
|
|
1191
|
+
hint: "strom history list: the events, each with its ID",
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1145
1194
|
const sorted = [...events].sort((a, b) => {
|
|
1146
1195
|
const [ga, gb] = [groupOf(a), groupOf(b)];
|
|
1147
1196
|
return ga.order - gb.order || ga.name.localeCompare(gb.name) || ga.key.localeCompare(gb.key) || a.from - b.from || a.to - b.to || a.id.localeCompare(b.id);
|
|
@@ -1175,7 +1224,7 @@ register({
|
|
|
1175
1224
|
rows.push([` ${yearsOf(e)}`, ui(lang, KIND_TEXT[e.kind] ?? "ui.history.kind.other"), [`${e.text}${source ? ` — ${source}` : ""}`, e.id, ...marks.map((m) => `[${m}]`)].join(" · ")]);
|
|
1176
1225
|
}
|
|
1177
1226
|
flush();
|
|
1178
|
-
const command = `strom history list${givenPlace ? ` --place ${/\s/u.test(givenPlace) ? `"${givenPlace}"` : givenPlace}` : ""}${region ? ` --region ${region}` : ""}`;
|
|
1227
|
+
const command = `strom history list${givenPlace ? ` --place ${/\s/u.test(givenPlace) ? `"${givenPlace}"` : givenPlace}` : ""}${region ? ` --region ${region}` : ""}${one ? ` --event ${one}` : ""}`;
|
|
1179
1228
|
return {
|
|
1180
1229
|
text: lines(on ? undefined : ui(lang, "ui.history.list.off"), sorted.length ? lines(...out, moreLine(page, command, lang) || undefined) : ui(lang, "ui.history.list.none")),
|
|
1181
1230
|
data: {
|