strom-research 1.24.0 → 1.25.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 +20 -0
- package/CHANGELOG.de.md +23 -0
- package/CHANGELOG.md +21 -0
- package/assets/archives.json +35 -0
- package/assets/lang/cs.json +41 -0
- package/assets/lang/de.json +41 -0
- package/assets/terms/streets.json +3 -2
- package/dist/cli/help.js +2 -2
- package/dist/cli/main.js +3 -0
- package/dist/cli/menu-links.js +22 -0
- package/dist/cli/menu.js +11 -1
- package/dist/cli/ui.js +39 -0
- package/dist/commands/checks.js +94 -10
- package/dist/commands/fixchecks.js +25 -2
- package/dist/commands/fixes.js +100 -26
- package/dist/commands/guide.js +6 -1
- package/dist/commands/links.js +8 -0
- package/dist/commands/setup.js +4 -0
- package/dist/commands/start.js +1 -1
- package/dist/core/changelog.js +17 -1
- package/dist/core/json.js +10 -4
- package/dist/core/links.js +14 -2
- package/dist/core/live.js +20 -6
- package/dist/core/phone-finds.js +3 -3
- package/dist/core/phone-watch.js +6 -0
- package/dist/core/phrases.js +2 -0
- package/dist/core/streetfix.js +54 -12
- package/dist/core/streets.js +107 -4
- package/dist/core/timetravel.js +210 -0
- package/dist/core/tree.js +1 -1
- package/dist/core/uninstall.js +78 -3
- package/dist/core/widget.js +135 -40
- package/package.json +4 -1
package/dist/commands/checks.js
CHANGED
|
@@ -11,13 +11,16 @@ import { unprovenPeople } from "../core/review.js";
|
|
|
11
11
|
import { AFTER_REPAIR_HINT, NOT_DOWNLOADED, OTHER_KEY, REPAIR_IN_TERMINAL_HINT, SEALED_PATHS, lastSealed, notDownloaded, notDownloadedError, otherKeyError, verifyFast, verifyFull } from "../core/integrity.js";
|
|
12
12
|
import { otherKeys } from "../core/seal.js";
|
|
13
13
|
import { adoptSeal, keysToUnite } from "../cli/seal.js";
|
|
14
|
-
import { NeedsConsentError, StromError } from "../core/errors.js";
|
|
14
|
+
import { NeedsConsentError, StromError, UsageError } from "../core/errors.js";
|
|
15
15
|
import * as git from "../core/git.js";
|
|
16
16
|
import { ui } from "../cli/ui.js";
|
|
17
17
|
import { history } from "../core/live.js";
|
|
18
18
|
import { humanWhen } from "../cli/human.js";
|
|
19
19
|
import { isAgent } from "../core/which.js";
|
|
20
20
|
import { writeProblems } from "../core/writable.js";
|
|
21
|
+
import { applyReturn, planReturn, resolveTarget } from "../core/timetravel.js";
|
|
22
|
+
import { liveWorkers, runsAtWork } from "../core/workers.js";
|
|
23
|
+
import { receivedPending } from "../core/sync.js";
|
|
21
24
|
/**
|
|
22
25
|
* A finding a person may meet with nothing gone wrong, said in their language (found on Windows: "counter P is behind
|
|
23
26
|
* existing IDs" in a Czech research, after a write a held file stopped); the rest stay strom's own words.
|
|
@@ -275,14 +278,95 @@ register({
|
|
|
275
278
|
// show a person (the agents' files, the tree made) left out of the lines, never out of --json (found 2026-10-04:
|
|
276
279
|
// "strom sync undo: 5 changes" in a German research)
|
|
277
280
|
const lang = tree.lang;
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
281
|
+
const rows = historyRows(tree, ctx.limit).map((r) => [r.change, r.when, r.text]);
|
|
282
|
+
// the way back to one of them, for a person reading it (the command is theirs alone)
|
|
283
|
+
return { text: rows.length ? lines(table(rows), "", ui(lang, "ui.history.back.hint")) : ui(lang, "ui.history.none"), data: { commits } };
|
|
284
|
+
},
|
|
285
|
+
}, {
|
|
286
|
+
path: ["history", "back"],
|
|
287
|
+
summary: "Return the research to its state after an earlier change (a new change: nothing deleted; the person's own)",
|
|
288
|
+
group: "history",
|
|
289
|
+
tree: true,
|
|
290
|
+
writes: true,
|
|
291
|
+
description: "The people, families, sources, places and the rest of the tree's evidence as they were right after the change named\n" +
|
|
292
|
+
"(its hash from strom history, or a day YYYY-MM-DD: the state at its end), the person's decisions on the tree's\n" +
|
|
293
|
+
"quality with them. Written as one new change: records added later are retracted, never deleted, and the whole\n" +
|
|
294
|
+
"history stays — a return is taken back the same way (the command it prints). What stays as it is: the tasks,\n" +
|
|
295
|
+
"sessions, directions and lessons, the settings, the history of the places, the images in the shared folder.\n" +
|
|
296
|
+
"--preview says what would return (read only, anyone may). The return itself is the person's own decision, at their\n" +
|
|
297
|
+
"own terminal — an agent tells the user the command, never runs it; never while somebody works on the research.",
|
|
298
|
+
args: [{ name: "change", description: "the change from strom history (e.g. 1a2b3c4d), or a day YYYY-MM-DD", required: true }],
|
|
299
|
+
options: [{ name: "preview", type: "boolean", description: "only say what would return; nothing written" }],
|
|
300
|
+
examples: ["strom history back 1a2b3c4d --preview", "strom history back 2026-01-15"],
|
|
301
|
+
async run(ctx, { args, opts }) {
|
|
302
|
+
const tree = ctx.tree();
|
|
303
|
+
const lang = tree.lang;
|
|
304
|
+
const target = resolveTarget(tree, args[0]);
|
|
305
|
+
const change = target.hash.slice(0, 8);
|
|
306
|
+
const when = humanWhen(target.at, lang);
|
|
307
|
+
const head = git.runGit(tree.root, ["rev-parse", "HEAD"]).stdout.trim();
|
|
308
|
+
if (target.hash === head)
|
|
309
|
+
return { text: ui(lang, "ui.back.now", { when, change }), data: { change: target.hash, at: target.at, same: true, returned: false } };
|
|
310
|
+
const plan = planReturn(tree, target);
|
|
311
|
+
const set = `strom history back ${change}`;
|
|
312
|
+
const said = backPreview(tree, plan, lang);
|
|
313
|
+
const inbox = receivedPending(tree.root).length;
|
|
314
|
+
const data = { change: target.hash, at: target.at, counts: plan.counts, facts: plan.facts, quality: plan.quality, same: plan.same, ...(inbox ? { inbox } : {}) };
|
|
315
|
+
if (plan.same)
|
|
316
|
+
return { text: lines(said, ui(lang, "ui.back.nothing")), data: { ...data, returned: false } };
|
|
317
|
+
if (opts.preview)
|
|
318
|
+
return { text: lines(said, "", ui(lang, "ui.back.person", { command: set })), data: { ...data, returned: false, run: set } };
|
|
319
|
+
// nobody's work is cut short: what an agent writes now would be returned over
|
|
320
|
+
if (liveWorkers(tree.root).length > 0 || runsAtWork(tree.root).length > 0)
|
|
321
|
+
throw new UsageError("somebody is at work on this research: a return only once they finished", { hint: "strom session finish, then " + set, code: "back.busy", params: { command: set } });
|
|
322
|
+
if (ctx.yes)
|
|
323
|
+
throw new UsageError("--yes never returns the research: a person chooses at their terminal", { hint: set });
|
|
324
|
+
ctx.requireHuman(`Return the research to its state after the change of ${target.at} (${change})?`, set, "history.back", ui(lang, "ui.back.person", { command: set }), { window: false });
|
|
325
|
+
ctx.io.stdout(said + "\n");
|
|
326
|
+
if (!(await ctx.confirm(ui(lang, "ui.back.ask"), false)))
|
|
327
|
+
return { text: ui(lang, "ui.cancelled"), data: { ...data, returned: false } };
|
|
328
|
+
tree.withTreeLock(() => applyReturn(tree, plan));
|
|
329
|
+
const undo = `strom history back ${plan.head.slice(0, 8)}`;
|
|
330
|
+
return { text: ui(lang, "ui.back.done", { when, undo }), data: { ...data, returned: true, undo } };
|
|
287
331
|
},
|
|
288
332
|
});
|
|
333
|
+
/**
|
|
334
|
+
* The changes of the history as a person reads them (the newest first): its short hash, its day and what it was, in the
|
|
335
|
+
* research's language — a change with nothing to show a person (only its English subject) left out.
|
|
336
|
+
*/
|
|
337
|
+
export function historyRows(tree, limit) {
|
|
338
|
+
const lang = tree.lang;
|
|
339
|
+
const said = new Map(history(tree.root, tree, [`-n${Math.max(1, limit)}`]).map((e) => [e.head, e.text]));
|
|
340
|
+
return git.log(tree.root, limit).flatMap((c, i) => {
|
|
341
|
+
const text = (said.get(c.hash) ?? []).filter((t) => t !== c.subject);
|
|
342
|
+
if (!text.length)
|
|
343
|
+
return [];
|
|
344
|
+
return [{ change: c.hash.slice(0, 8), now: i === 0, at: c.at, when: humanWhen(c.at, lang), text: text.length > 1 ? `${text[0]} ${ui(lang, "ui.recent.morechanges", { n: text.length - 1 })}` : text[0] }];
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
/** What a return changes, as a person reads it: the change returned to, then a line for each kind of record. */
|
|
348
|
+
function backPreview(tree, plan, lang) {
|
|
349
|
+
const waiting = receivedPending(tree.root).length;
|
|
350
|
+
const what = history(tree.root, tree, ["-n1", plan.target.hash])[0]?.text.find((t) => t !== plan.target.subject);
|
|
351
|
+
const groups = [
|
|
352
|
+
["ui.back.g.people", ["person"]],
|
|
353
|
+
["ui.back.g.families", ["family"]],
|
|
354
|
+
["ui.back.g.sources", ["source", "recordset", "repository", "media"]],
|
|
355
|
+
["ui.back.g.other", ["place", "search", "conflict", "hypothesis", "input"]],
|
|
356
|
+
];
|
|
357
|
+
const rows = groups.flatMap(([key, types]) => {
|
|
358
|
+
const back = types.reduce((n, t) => n + (plan.counts[t]?.back ?? 0), 0);
|
|
359
|
+
const out = types.reduce((n, t) => n + (plan.counts[t]?.out ?? 0), 0);
|
|
360
|
+
if (!back && !out)
|
|
361
|
+
return [];
|
|
362
|
+
const parts = [back ? ui(lang, "ui.back.asthen", { n: back }) : "", out ? ui(lang, "ui.back.out", { n: out }) : ""].filter(Boolean).join(", ");
|
|
363
|
+
return [` ${ui(lang, key)}: ${parts}`];
|
|
364
|
+
});
|
|
365
|
+
if (plan.facts)
|
|
366
|
+
rows.push(` ${ui(lang, "ui.back.facts", { n: plan.facts })}`);
|
|
367
|
+
if (plan.quality)
|
|
368
|
+
rows.push(` ${ui(lang, "ui.back.quality", { n: plan.quality })}`);
|
|
369
|
+
return lines(ui(lang, "ui.back.title", { when: humanWhen(plan.target.at, lang), change: plan.target.hash.slice(0, 8) }), what ? ` ${what}` : undefined, ...(plan.same ? [] : ["", ...rows, "", ui(lang, actsAsArchive(tree) ? "ui.back.kept.archive" : "ui.back.kept")]),
|
|
370
|
+
// trees the app sent that wait in the inbox (sync.review on): the return leaves them, decided after it they come on top
|
|
371
|
+
...(plan.same || !waiting ? [] : [ui(lang, "ui.back.inbox", { n: waiting })]));
|
|
372
|
+
}
|
|
@@ -734,7 +734,7 @@ export const STREET_PLACES = {
|
|
|
734
734
|
unit: "fact",
|
|
735
735
|
detect: (tree) => {
|
|
736
736
|
const f = streetPlaceFixes(tree);
|
|
737
|
-
return { items: [], exact: 0, estimated: 0, unjudged: 0, readings: 0, rewrites: f.fixes, unsplit: f.left.length, left: f.left };
|
|
737
|
+
return { items: [], exact: 0, estimated: 0, unjudged: 0, readings: 0, rewrites: f.fixes, unsplit: f.left.length, left: f.left, ...(f.towns.length ? { towns: f.towns } : {}) };
|
|
738
738
|
},
|
|
739
739
|
applied: (tree) => streetPlacesDone(tree).length,
|
|
740
740
|
};
|
|
@@ -746,7 +746,11 @@ export function checksHere(tree) {
|
|
|
746
746
|
}
|
|
747
747
|
/** How many a check found to set right: what it would rewrite, or the places to read again. */
|
|
748
748
|
export function foundCount(f) {
|
|
749
|
-
return f.rewrites ? f.rewrites.length : f.items.length;
|
|
749
|
+
return f.rewrites ? f.rewrites.length + townCount(f) : f.items.length;
|
|
750
|
+
}
|
|
751
|
+
/** The facts of the municipalities waiting for a person's answer whether their bare numbers are houses (street-places). */
|
|
752
|
+
export function townCount(f) {
|
|
753
|
+
return (f.towns ?? []).reduce((n, t) => n + t.fixes.length, 0);
|
|
750
754
|
}
|
|
751
755
|
export function fixCheck(id) {
|
|
752
756
|
return FIX_CHECKS.find((c) => c.id === id);
|
|
@@ -1117,6 +1121,11 @@ export function fixTargets(f) {
|
|
|
1117
1121
|
ids.add(id);
|
|
1118
1122
|
for (const l of f.left ?? [])
|
|
1119
1123
|
ids.add(l.owner);
|
|
1124
|
+
for (const t of f.towns ?? [])
|
|
1125
|
+
for (const r of t.fixes)
|
|
1126
|
+
for (const id of [r.owner, r.record])
|
|
1127
|
+
if (id)
|
|
1128
|
+
ids.add(id);
|
|
1120
1129
|
for (const i of f.items) {
|
|
1121
1130
|
for (const s of i.sources)
|
|
1122
1131
|
ids.add(s);
|
|
@@ -1134,6 +1143,18 @@ export function fixTargets(f) {
|
|
|
1134
1143
|
}
|
|
1135
1144
|
return Object.keys(out).length ? out : undefined;
|
|
1136
1145
|
}
|
|
1146
|
+
/** How many municipalities /fixes names, and how many places of each. */
|
|
1147
|
+
export const APP_FIX_TOWNS = 200;
|
|
1148
|
+
export const APP_FIX_TOWN_PLACES = 20;
|
|
1149
|
+
/** The municipalities waiting for the person's answer, as the app is told them (the most facts first). */
|
|
1150
|
+
export function appFixTowns(f) {
|
|
1151
|
+
if (!f.towns?.length)
|
|
1152
|
+
return undefined;
|
|
1153
|
+
return [...f.towns]
|
|
1154
|
+
.sort((a, b) => b.fixes.length - a.fixes.length || a.key.localeCompare(b.key))
|
|
1155
|
+
.slice(0, APP_FIX_TOWNS)
|
|
1156
|
+
.map((t) => ({ town: t.town, key: t.key, count: t.fixes.length, places: t.places.slice(0, APP_FIX_TOWN_PLACES) }));
|
|
1157
|
+
}
|
|
1137
1158
|
/**
|
|
1138
1159
|
* strom's fixes of this research for the app: each check, what it found, its state and what it would take — free, as
|
|
1139
1160
|
* strom fixes says it (no agent, no network, nothing written: what waits is not kept, the readings' cost only estimated
|
|
@@ -1161,6 +1182,7 @@ export function fixesForApp(tree, settings, env, o) {
|
|
|
1161
1182
|
const applied = check.applied?.(tree) ?? 0;
|
|
1162
1183
|
const found = foundCount(s.found);
|
|
1163
1184
|
const targets = fixTargets(s.found);
|
|
1185
|
+
const towns = appFixTowns(s.found);
|
|
1164
1186
|
const cost = check.remedy === "rewrite"
|
|
1165
1187
|
? "free"
|
|
1166
1188
|
: found
|
|
@@ -1183,6 +1205,7 @@ export function fixesForApp(tree, settings, env, o) {
|
|
|
1183
1205
|
...(cost ? { cost } : {}),
|
|
1184
1206
|
since: check.since,
|
|
1185
1207
|
paid: check.paid,
|
|
1208
|
+
...(towns ? { towns } : {}),
|
|
1186
1209
|
},
|
|
1187
1210
|
];
|
|
1188
1211
|
});
|
package/dist/commands/fixes.js
CHANGED
|
@@ -14,11 +14,12 @@ import { isArchive } from "../core/mode.js";
|
|
|
14
14
|
import { refuseInArchive } from "../core/state.js";
|
|
15
15
|
import { create } from "../core/records.js";
|
|
16
16
|
import { phrase } from "../core/phrases.js";
|
|
17
|
-
import { compareDocuments, compareReadings, checksHere, decide, decisionChange, decisionKeyOf, foundCount, estimateFix, fixCheck, fixEnv, fixStates, FIX_CHECKS, loadDocResult, byReading, defaultStage, readBefore, readersOf, readsOf, fixModelText as modelText, fixTextValues as textValues, stagesOf, } from "./fixchecks.js";
|
|
17
|
+
import { compareDocuments, compareReadings, checksHere, decide, decisionChange, decisionKeyOf, foundCount, estimateFix, fixCheck, fixEnv, fixStates, FIX_CHECKS, loadDocResult, byReading, defaultStage, readBefore, readersOf, readsOf, fixModelText as modelText, fixTextValues as textValues, stagesOf, townCount, } from "./fixchecks.js";
|
|
18
18
|
import { VERSION } from "../core/tree.js";
|
|
19
19
|
import { applyNameRewrites, nameRewritesDone, undoNameRewrites } from "../core/participants.js";
|
|
20
20
|
import { applyAppShapes, appShapesDone, undoAppShapes } from "../core/appshapefix.js";
|
|
21
|
-
import { applyStreetPlaces, streetPlacesDone, undoStreetPlaces } from "../core/streetfix.js";
|
|
21
|
+
import { applyStreetPlaces, forgetTownAnswers, streetPlacesDone, undoStreetPlaces } from "../core/streetfix.js";
|
|
22
|
+
import { townAnswers } from "../core/streets.js";
|
|
22
23
|
import { calibrationLabel } from "../core/viewsizes.js";
|
|
23
24
|
import { calibrationKey, loadAliases, resolveKey, splitKey, UNKNOWN_KEY } from "../core/modelkey.js";
|
|
24
25
|
import { agentsHere } from "../core/apps.js";
|
|
@@ -188,7 +189,7 @@ const REWRITERS = {
|
|
|
188
189
|
const r = item;
|
|
189
190
|
return t("ui.fixes.street-places.kept", { event: r.event, place: r.place, house: r.house, street: r.street });
|
|
190
191
|
},
|
|
191
|
-
apply: (tree, items, config) => applyStreetPlaces(tree, items, VERSION, config),
|
|
192
|
+
apply: (tree, items, config, towns) => applyStreetPlaces(tree, items, VERSION, config, towns),
|
|
192
193
|
done: (tree) => streetPlacesDone(tree).length,
|
|
193
194
|
undo: (tree, config) => undoStreetPlaces(tree, config),
|
|
194
195
|
ask: "Set the streets and house numbers out of the places of facts into their houses?",
|
|
@@ -203,22 +204,33 @@ const rewriterOf = (id) => {
|
|
|
203
204
|
throw new Error(`no rewriter for ${id}`);
|
|
204
205
|
return r;
|
|
205
206
|
};
|
|
207
|
+
/** The places of a municipality with numbers alone after its name, as written: the first few, how many in all. */
|
|
208
|
+
const townPlaces = (town) => (town.places.length > 3 ? `${town.places.slice(0, 3).join(", ")} … (${town.places.length})` : town.places.join(", "));
|
|
206
209
|
/** A check that rewrites by rules: what it is, what it found, examples, what setting it right does and does not. */
|
|
207
210
|
function rewriteDetail(t, s) {
|
|
208
211
|
const f = s.found;
|
|
209
212
|
const rewrites = f.rewrites ?? [];
|
|
213
|
+
const towns = f.towns ?? [];
|
|
210
214
|
const id = s.check.id;
|
|
211
215
|
return [
|
|
212
216
|
`${id} · ${t(`ui.fixes.${id}.name`)} — ${stateText(t, s)}`,
|
|
213
217
|
t(`ui.fixes.${id}.what`, { since: s.check.since }),
|
|
214
|
-
rewrites.length || f.unsplit
|
|
218
|
+
rewrites.length || f.unsplit
|
|
219
|
+
? t(`ui.fixes.${id}.found`, { found: rewrites.length + (f.unsplit ?? 0), split: rewrites.length, unsplit: f.unsplit ?? 0 })
|
|
220
|
+
: towns.length
|
|
221
|
+
? undefined
|
|
222
|
+
: t("ui.fixes.found.none"),
|
|
215
223
|
...rewrites.slice(0, EXAMPLES).map((r) => rewriterOf(id).example(t, r)),
|
|
216
224
|
rewrites.length > EXAMPLES ? t(`ui.fixes.${id}.more`, { n: rewrites.length - EXAMPLES, id }) : undefined,
|
|
217
225
|
// what it leaves as it is, each with why
|
|
218
226
|
...(f.left ?? []).slice(0, EXAMPLES).map((r) => rewriterOf(id).left?.(t, r) ?? ""),
|
|
219
227
|
(f.left?.length ?? 0) > EXAMPLES ? t(`ui.fixes.${id}.more`, { n: f.left.length - EXAMPLES, id }) : undefined,
|
|
220
|
-
|
|
221
|
-
|
|
228
|
+
// numbers alone after a municipality: each municipality, set right only on a person's word for all of it
|
|
229
|
+
towns.length ? t("ui.fixes.street-places.bare") : undefined,
|
|
230
|
+
...towns.slice(0, EXAMPLES).map((x) => t("ui.fixes.street-places.town", { town: x.town, n: x.fixes.length, places: townPlaces(x) })),
|
|
231
|
+
towns.length > EXAMPLES ? t(`ui.fixes.${id}.more`, { n: towns.length - EXAMPLES, id }) : undefined,
|
|
232
|
+
rewrites.length || towns.length ? t(`ui.fixes.${id}.does`, { id }) : undefined,
|
|
233
|
+
rewrites.length || towns.length ? t(`ui.fixes.${id}.not`, { id }) : undefined,
|
|
222
234
|
].filter((l) => l !== undefined);
|
|
223
235
|
}
|
|
224
236
|
/** What it is, what it found, what setting it right does and does not, and what it would take. */
|
|
@@ -253,9 +265,25 @@ function stateData(ctx, tree, s, all = false) {
|
|
|
253
265
|
remedy: s.check.remedy,
|
|
254
266
|
state: s.state,
|
|
255
267
|
...(s.decision ? { decision: s.decision } : {}),
|
|
256
|
-
found: {
|
|
268
|
+
found: {
|
|
269
|
+
count: rewrites.length + (s.found.unsplit ?? 0) + townCount(s.found),
|
|
270
|
+
split: rewrites.length,
|
|
271
|
+
unsplit: s.found.unsplit ?? 0,
|
|
272
|
+
...(s.found.towns ? { bare: townCount(s.found) } : {}),
|
|
273
|
+
},
|
|
257
274
|
items: all ? rewrites : rewrites.slice(0, EXAMPLES),
|
|
258
275
|
...(s.found.left ? { left: all ? s.found.left : s.found.left.slice(0, EXAMPLES) } : {}),
|
|
276
|
+
// municipalities with numbers alone after the name: set right only on a person's answer for each (strom fixes run)
|
|
277
|
+
...(s.found.towns
|
|
278
|
+
? {
|
|
279
|
+
towns: s.found.towns.map((x) => ({
|
|
280
|
+
town: x.town,
|
|
281
|
+
count: x.fixes.length,
|
|
282
|
+
places: all ? x.places : x.places.slice(0, EXAMPLES),
|
|
283
|
+
items: all ? x.fixes : x.fixes.slice(0, EXAMPLES),
|
|
284
|
+
})),
|
|
285
|
+
}
|
|
286
|
+
: {}),
|
|
259
287
|
};
|
|
260
288
|
}
|
|
261
289
|
const items = all ? s.found.items : s.found.items.slice(0, EXAMPLES);
|
|
@@ -293,32 +321,67 @@ async function runRewrite(ctx, tree, t, s) {
|
|
|
293
321
|
for (const l of detail(ctx, tree, t, s))
|
|
294
322
|
out(l);
|
|
295
323
|
const rewrites = s.found.rewrites ?? [];
|
|
296
|
-
|
|
324
|
+
const towns = s.found.towns ?? [];
|
|
325
|
+
if (!rewrites.length && !towns.length)
|
|
297
326
|
return { changed: 0, records: 0 };
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
|
|
327
|
+
const take = [];
|
|
328
|
+
if (rewrites.length) {
|
|
329
|
+
const choices = [{ label: t(`ui.fixes.${id}.all`, { n: rewrites.length }) }, { label: t("ui.fixes.decline") }];
|
|
330
|
+
const pick = await ctx.choose(t(`ui.fixes.${id}.ask`), choices, choices.length, { back: t("ui.fixes.later") });
|
|
331
|
+
if (pick === undefined) {
|
|
332
|
+
out(t("ui.fixes.later.said", { id }));
|
|
333
|
+
return { changed: 0, records: 0 };
|
|
334
|
+
}
|
|
335
|
+
if (pick === 1) {
|
|
336
|
+
tree.withTreeLock(() => {
|
|
337
|
+
decide(tree, s.key, "declined");
|
|
338
|
+
tree.commit(`Fix ${s.key}: left as it is`);
|
|
339
|
+
});
|
|
340
|
+
out(t("ui.fixes.declined", { id }));
|
|
341
|
+
return { decided: "declined", changed: 0, records: 0 };
|
|
342
|
+
}
|
|
343
|
+
take.push(...rewrites);
|
|
344
|
+
}
|
|
345
|
+
// numbers alone after a municipality ("Lhota 16"): the person's word for each municipality, its facts shown first
|
|
346
|
+
// (Enter: later, nothing kept)
|
|
347
|
+
const answers = {};
|
|
348
|
+
const kept = [];
|
|
349
|
+
for (const town of towns) {
|
|
350
|
+
out("");
|
|
351
|
+
out(t("ui.fixes.street-places.town", { town: town.town, n: town.fixes.length, places: townPlaces(town) }));
|
|
352
|
+
for (const r of town.fixes.slice(0, EXAMPLES))
|
|
353
|
+
out(rewriterOf(id).example(t, r));
|
|
354
|
+
if (town.fixes.length > EXAMPLES)
|
|
355
|
+
out(t(`ui.fixes.${id}.more`, { n: town.fixes.length - EXAMPLES, id }));
|
|
356
|
+
const choices = [{ label: t("ui.fixes.street-places.town.yes", { town: town.town, n: town.fixes.length }) }, { label: t("ui.fixes.street-places.town.no", { town: town.town }) }];
|
|
357
|
+
const a = await ctx.choose(t("ui.fixes.street-places.town.ask", { town: town.town }), choices, choices.length, { back: t("ui.fixes.later") });
|
|
358
|
+
if (a === undefined)
|
|
359
|
+
continue;
|
|
360
|
+
answers[town.key] = { town: town.town, houses: a === 0 };
|
|
361
|
+
if (a === 0)
|
|
362
|
+
take.push(...town.fixes);
|
|
363
|
+
else
|
|
364
|
+
kept.push(town.town);
|
|
365
|
+
}
|
|
366
|
+
if (!take.length && !Object.keys(answers).length) {
|
|
301
367
|
out(t("ui.fixes.later.said", { id }));
|
|
302
368
|
return { changed: 0, records: 0 };
|
|
303
369
|
}
|
|
304
|
-
if (pick === 1) {
|
|
305
|
-
tree.withTreeLock(() => {
|
|
306
|
-
decide(tree, s.key, "declined");
|
|
307
|
-
tree.commit(`Fix ${s.key}: left as it is`);
|
|
308
|
-
});
|
|
309
|
-
out(t("ui.fixes.declined", { id }));
|
|
310
|
-
return { decided: "declined", changed: 0, records: 0 };
|
|
311
|
-
}
|
|
312
370
|
const r = tree.withTreeLock(() => {
|
|
313
|
-
// what it sets right and the decision: one operation, one commit
|
|
371
|
+
// what it sets right, the answers and the decision: one operation, one commit
|
|
314
372
|
const w = rewriterOf(id);
|
|
315
|
-
const done = w.apply(tree,
|
|
373
|
+
const done = w.apply(tree, take, take.length ? decisionChange(s.key, "fixed") : undefined, answers);
|
|
316
374
|
if (done.changed)
|
|
317
375
|
tree.commit(w.fixed(s.key, done.changed, done.records));
|
|
376
|
+
else
|
|
377
|
+
tree.commit(`Fix ${s.key}: numbers after a municipality answered (${Object.keys(answers).length})`);
|
|
318
378
|
return done;
|
|
319
379
|
});
|
|
320
|
-
|
|
321
|
-
|
|
380
|
+
if (take.length)
|
|
381
|
+
out(t(`ui.fixes.${id}.done`, { n: r.changed, records: r.records, id }));
|
|
382
|
+
if (kept.length)
|
|
383
|
+
out(t("ui.fixes.street-places.town.kept", { towns: kept.join(", "), id }));
|
|
384
|
+
return { ...(take.length ? { decided: "fixed" } : {}), changed: r.changed, records: r.records };
|
|
322
385
|
}
|
|
323
386
|
/** The person's own decision: in their terminal alone (an agent, a run nobody watches: exit 4, with the command). */
|
|
324
387
|
function personOnly(ctx, t, question, set, says = "ui.fixes.person") {
|
|
@@ -625,7 +688,13 @@ register({
|
|
|
625
688
|
"thing is left and listed with why (--json: left). A street is told by its word (ulice, nám., Straße, ул.), a house\n" +
|
|
626
689
|
"number's marker (č. p., Nr.), a part after the municipality of words and a house number (Lhota, Dlouhá 12 — never\n" +
|
|
627
690
|
"the municipality's own name with a number), or as a street the research's own houses name at that municipality.\n" +
|
|
628
|
-
"
|
|
691
|
+
"A number alone after the name (Lhota 16) is no street by the rules — it may be a house or a part of the\n" +
|
|
692
|
+
"municipality (Praha 5): each municipality the research writes is offered on its own, with its facts (--json: towns),\n" +
|
|
693
|
+
"and the person says at their terminal whether its numbers are houses — yes sets them right with the rest (a new\n" +
|
|
694
|
+
"number there refused from then on), no is not asked again (strom fixes reopen street-places asks again); never\n" +
|
|
695
|
+
"offered where the number names a part: a municipality numbered by its parts (assets/terms/streets.json), a place\n" +
|
|
696
|
+
"record of the name with its number, a street there (Lhota 2, Dlouhá 12). The answers are kept with the research.\n" +
|
|
697
|
+
"One operation, one commit; strom fixes undo street-places puts it back, the answers with it.\n" +
|
|
629
698
|
SET_RIGHT_HELP,
|
|
630
699
|
examples: ["strom fixes", "strom fixes show blind-reduced", "strom fixes show new-model", "strom fixes show participant-names", "strom fixes show app-shapes", "strom fixes show street-places", "strom fixes --json"],
|
|
631
700
|
run: (ctx) => {
|
|
@@ -768,9 +837,14 @@ register({
|
|
|
768
837
|
const t = (key, values = {}) => ui(tree.lang, key, values);
|
|
769
838
|
const s = stateOfCheck(ctx, tree, args[0]);
|
|
770
839
|
personOnly(ctx, t, `Ask ${s.check.id} again?`, `strom fixes reopen ${s.check.id}`, "ui.fixes.person.decide");
|
|
771
|
-
|
|
840
|
+
// street-places: the answers on numbers after a municipality asked again too
|
|
841
|
+
const answered = s.check.id === "street-places" && Object.keys(townAnswers(tree.root)).length > 0;
|
|
842
|
+
if (s.decision || answered)
|
|
772
843
|
tree.withTreeLock(() => {
|
|
773
|
-
|
|
844
|
+
if (answered)
|
|
845
|
+
forgetTownAnswers(tree, s.decision ? decisionChange(s.key, undefined) : undefined);
|
|
846
|
+
else
|
|
847
|
+
decide(tree, s.key, undefined);
|
|
774
848
|
tree.commit(`Fix ${s.key}: asked again`);
|
|
775
849
|
});
|
|
776
850
|
return { text: t("ui.fixes.reopened", { id: s.check.id }), data: { id: s.check.id, decision: null } };
|
package/dist/commands/guide.js
CHANGED
|
@@ -164,7 +164,12 @@ write is a suggestion: link (godparent:P…) only when the record says so. Old n
|
|
|
164
164
|
(strom fixes undo participant-names) is the user's decision alone, in their terminal — never an agent's.
|
|
165
165
|
A place is the municipality, never a street or a house number: --place "Lhota" --house "Dlouhá 12" (refused:
|
|
166
166
|
place.street, the hint says what to write). Old facts with a street in the place (street-place): strom fixes show
|
|
167
|
-
street-places; setting them right or back is the user's decision alone, in their terminal.
|
|
167
|
+
street-places; setting them right or back is the user's decision alone, in their terminal. A number alone
|
|
168
|
+
after the name ("Lhota 16") is written as the record gives it: whether a municipality's numbers are houses only the
|
|
169
|
+
user says (strom fixes run street-places), never an agent.
|
|
170
|
+
Back in time: strom history lists the changes; strom history back <change> --preview says what a return to the
|
|
171
|
+
state after one would bring back (read only). The return itself is the user's decision alone, in their terminal:
|
|
172
|
+
tell them the command, never run it. It is a new change (nothing deleted), taken back the same way.
|
|
168
173
|
Many facts from one record in one call — lines of commands, "#name" labels
|
|
169
174
|
what a line creates, "@name" uses it later:
|
|
170
175
|
strom batch 'person add "Anna /Svobodová/" --sex F #anna' 'family add --partner P0001 --partner @anna --married 1910 --cite S0001'
|
package/dist/commands/links.js
CHANGED
|
@@ -279,6 +279,11 @@ async function inTerminal(ctx, link) {
|
|
|
279
279
|
const { fixesDo } = await import("../cli/menu-links.js");
|
|
280
280
|
return end(await fixesDo(ctx, run, treeLang, root, link.id, link.do));
|
|
281
281
|
}
|
|
282
|
+
case "back": {
|
|
283
|
+
// back in time: the change named (or one picked here) — strom history back shows what returns, the person decides
|
|
284
|
+
const { backDo } = await import("../cli/menu-links.js");
|
|
285
|
+
return end((await backDo(ctx, run, treeLang, root, link.change)) === 0);
|
|
286
|
+
}
|
|
282
287
|
}
|
|
283
288
|
const named = "person" in link ? link.person : undefined;
|
|
284
289
|
const person = named ? personOf(root, ctx, named) : undefined;
|
|
@@ -426,6 +431,9 @@ register({
|
|
|
426
431
|
"browser, by hand), answered in the terminal as in the menu's What waits; the answer is never in the link.\n" +
|
|
427
432
|
"strom-research://fixes?tree=<id>[&id=street-places][&do=undo] — strom's fixes of the research (strom fixes), one of them\n" +
|
|
428
433
|
" shown, or what it set right to be put back: set right or put back only on the person's word in the terminal.\n" +
|
|
434
|
+
"strom-research://back?tree=<id>[&change=<hash>] — the research back in time (strom history back): the change named by\n" +
|
|
435
|
+
" its hash (the bridge's /log head, or its first 8), else the earlier changes to pick from — what returns shown, the\n" +
|
|
436
|
+
" return only on the person's word in the terminal.\n" +
|
|
429
437
|
"strom-research://update|sessions|setup?tree=<id> — strom update, the agent's sessions and their cost, strom setup.\n" +
|
|
430
438
|
"strom-research://new?app=<the app's mark> — a tree of the app becomes a new research: named, made, the app hands the\n" +
|
|
431
439
|
"tree to its bridge (?adopt=, GET/POST /adopt), taken in as leads, sent back to the app. Family trees here already:\n" +
|
package/dist/commands/setup.js
CHANGED
|
@@ -68,6 +68,7 @@ import { ensureHooksDir } from "../core/hooks.js";
|
|
|
68
68
|
import { claudeInChrome, CLAUDE_IN_CHROME_URL, downloadsDir } from "../core/browser.js";
|
|
69
69
|
import { browserConnectors, fenceKeepsNetOff, listConnectors } from "../core/connector.js";
|
|
70
70
|
import { appReadLimits } from "../core/live-read.js";
|
|
71
|
+
import { markWidget } from "../core/widget.js";
|
|
71
72
|
export const SHARED_DIRS = ["media", "catalog", "tools", "cache", "inbox"];
|
|
72
73
|
export function ensureShared(dir) {
|
|
73
74
|
for (const d of SHARED_DIRS)
|
|
@@ -94,6 +95,8 @@ register({
|
|
|
94
95
|
const s = ctx.settings;
|
|
95
96
|
if (ctx.interactive && !isAgent(ctx.env)) {
|
|
96
97
|
const r = await setupWizard(ctx, { research: Boolean(opts.research) });
|
|
98
|
+
// the widget on the desktop (macOS, Windows) learns this strom writes its files
|
|
99
|
+
markWidget(ctx.env);
|
|
97
100
|
// run in an archive (the Strom app's link to the research's settings too): research offered beside it
|
|
98
101
|
let root;
|
|
99
102
|
try {
|
|
@@ -184,6 +187,7 @@ register({
|
|
|
184
187
|
cfg.trees = trees;
|
|
185
188
|
s.save();
|
|
186
189
|
fs.mkdirSync(home, { recursive: true });
|
|
190
|
+
markWidget(ctx.env);
|
|
187
191
|
const sharedDir = s.shared().value;
|
|
188
192
|
const treesDir = s.trees().value;
|
|
189
193
|
fs.mkdirSync(treesDir, { recursive: true });
|
package/dist/commands/start.js
CHANGED
|
@@ -497,7 +497,7 @@ register({
|
|
|
497
497
|
},
|
|
498
498
|
}, {
|
|
499
499
|
path: ["uninstall"],
|
|
500
|
-
summary: "Take strom off this computer: what the agents were taught, the shortcut, its own git, its PATH lines and the program — the research and the settings stay",
|
|
500
|
+
summary: "Take strom off this computer: what the agents were taught, the shortcut, its own git, its PATH lines, the widget's files and the program — the research and the settings stay",
|
|
501
501
|
group: "setup",
|
|
502
502
|
description: "The user's decision: a person at their terminal is asked there (--yes: no question); asked by an agent, strom asks\n" +
|
|
503
503
|
"in a window of the system. Installed through npm, the program itself goes with npm uninstall -g strom-research.",
|
package/dist/core/changelog.js
CHANGED
|
@@ -11,7 +11,7 @@ import { conflictTitle, displayName, lifespan } from "./people.js";
|
|
|
11
11
|
import { ownerName, cardFact } from "./overview.js";
|
|
12
12
|
import { phrase } from "./phrases.js";
|
|
13
13
|
import { clock } from "./net.js";
|
|
14
|
-
import { eventName, humanDate, humanPlace, humanTask } from "../cli/human.js";
|
|
14
|
+
import { eventName, humanDate, humanPlace, humanTask, humanWhen } from "../cli/human.js";
|
|
15
15
|
import { UI, ui } from "../cli/ui.js";
|
|
16
16
|
import { actsAsArchive } from "./state.js";
|
|
17
17
|
/** Operations nobody needs to read: what another line says already, or bookkeeping. */
|
|
@@ -464,6 +464,22 @@ export function changeLines(tree, ops, subject, lang, was, tasks) {
|
|
|
464
464
|
say(phrase(lang, o.op === "streetplace.fix" ? "log.streetplace.fix" : "log.streetplace.unfix", { n }));
|
|
465
465
|
continue;
|
|
466
466
|
}
|
|
467
|
+
// the research returned to its state after an earlier change (strom history back): one line, the day of then
|
|
468
|
+
if (o.op === "tree.return") {
|
|
469
|
+
// the sources it brought back as they were — never one it took out (the app would open a retracted record)
|
|
470
|
+
const taken = (id) => !!get(id)?.retracted;
|
|
471
|
+
cites = sourcesOf(tree, { ...o, targets: o.targets.filter((id) => !taken(id) || get(id)?.mergedInto) }).filter((id) => !taken(id));
|
|
472
|
+
const at = /^Return to the state of (\S+) \(/u.exec(o.summary)?.[1];
|
|
473
|
+
say(at ? phrase(lang, "log.tree.return", { when: humanWhen(at, lang) }) : changed(o));
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
// the person's answers whether the numbers after a municipality's name are houses (quality/street-places.json)
|
|
477
|
+
if (o.op === "streetplace.towns") {
|
|
478
|
+
const n = /: (\d+) answer/u.exec(o.summary)?.[1];
|
|
479
|
+
if (n)
|
|
480
|
+
say(phrase(lang, "log.streetplace.towns", { n }));
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
467
483
|
// a finding the person marked no error (quality/dismissed.json): its people by name, never the English summary
|
|
468
484
|
if (o.op === "quality.dismiss" || o.op === "quality.undo") {
|
|
469
485
|
const m = /^[^:]*: (\S+) ((?:P\d+ ?)+?)(?: \((.*)\))?$/su.exec(o.summary);
|
package/dist/core/json.js
CHANGED
|
@@ -42,7 +42,7 @@ export function stringifyCanonical(value) {
|
|
|
42
42
|
export const RENAME_PATIENCE = 1500;
|
|
43
43
|
const RENAME_FIRST_WAIT = 25;
|
|
44
44
|
/** What another program holding the target (an antivirus, the search indexer, a backup) makes a rename fail with. */
|
|
45
|
-
const HELD = new Set(["EPERM", "EBUSY", "EACCES"]);
|
|
45
|
+
export const HELD = new Set(["EPERM", "EBUSY", "EACCES"]);
|
|
46
46
|
/**
|
|
47
47
|
* fn, again for a while on Windows when a file it uses is held: an antivirus, the indexer or a sync tool that has the
|
|
48
48
|
* file open for a moment makes a rename, a read or a removal fail with EPERM, EBUSY or EACCES. The waits grow (25, 50,
|
|
@@ -88,14 +88,20 @@ export function readFileRetrying(file, platform = process.platform) {
|
|
|
88
88
|
export function removeRetrying(file, platform = process.platform) {
|
|
89
89
|
retryingHeld(file, platform, () => fs.rmSync(file, { force: true }));
|
|
90
90
|
}
|
|
91
|
-
/**
|
|
92
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Write via a temp file in the same directory and rename: never a half file. `patient: false`: the rename tried once,
|
|
93
|
+
* never waited for a file another program holds (the widget's files: the bridge's tick is never held up by a reader).
|
|
94
|
+
*/
|
|
95
|
+
export function writeFileAtomic(file, content, opts = {}) {
|
|
93
96
|
const dir = path.dirname(file);
|
|
94
97
|
fs.mkdirSync(dir, { recursive: true });
|
|
95
98
|
const tmp = path.join(dir, `.${path.basename(file)}.${process.pid}.${crypto.randomBytes(4).toString("hex")}.tmp`);
|
|
96
99
|
fs.writeFileSync(tmp, content, "utf8");
|
|
97
100
|
try {
|
|
98
|
-
|
|
101
|
+
if (opts.patient === false)
|
|
102
|
+
fs.renameSync(tmp, file);
|
|
103
|
+
else
|
|
104
|
+
renameRetrying(tmp, file);
|
|
99
105
|
}
|
|
100
106
|
catch (err) {
|
|
101
107
|
fs.rmSync(tmp, { force: true });
|
package/dist/core/links.js
CHANGED
|
@@ -50,11 +50,12 @@ function handlerName(env) {
|
|
|
50
50
|
* here (strom seal adopt: checked, then the person's yes in the terminal — never by itself); an experiment turned on (the
|
|
51
51
|
* person's question in the terminal) or off for the research (at once); the history of a place and its surroundings
|
|
52
52
|
* looked for (the estimate and the person's question in the terminal); strom's fixes of the research, one of them, or one
|
|
53
|
-
* put back (shown, then set right or put back only on the person's word in the terminal)
|
|
53
|
+
* put back (shown, then set right or put back only on the person's word in the terminal); the research back in time (the
|
|
54
|
+
* earlier changes to pick from, or the one the app names by its hash: the preview, then the person's yes in the terminal).
|
|
54
55
|
*/
|
|
55
56
|
/** A story: approved (or, beside an approved one, its new version approved in its place), or that new version not wanted. */
|
|
56
57
|
export const LINK_STORY_DOS = ["final", "keep"];
|
|
57
|
-
export const LINK_ACTIONS = ["send", "excerpt", "app", "open", "chat", "task", "review", "research", "new", "update", "sessions", "conflict", "story", "sync-undo", "setup", "live", "direction", "finish", "sync", "media", "archive", "seal", "experiment", "history", "fixes"];
|
|
58
|
+
export const LINK_ACTIONS = ["send", "excerpt", "app", "open", "chat", "task", "review", "research", "new", "update", "sessions", "conflict", "story", "sync-undo", "setup", "live", "direction", "finish", "sync", "media", "archive", "seal", "experiment", "history", "fixes", "back"];
|
|
58
59
|
/** A person's review: the person, with the family, with the ancestors (strom review --scope). */
|
|
59
60
|
export const LINK_SCOPES = ["person", "family", "line"];
|
|
60
61
|
/** A new direction from a person (strom research new --direction). */
|
|
@@ -100,6 +101,8 @@ const INPUT = /^I\d{1,9}$/;
|
|
|
100
101
|
const RECEIVED = /^R\d{17}-[0-9a-f]{4}$/;
|
|
101
102
|
const RESEARCH = /^G\d{1,9}$/;
|
|
102
103
|
const SESSION = /^N\d{1,9}$/;
|
|
104
|
+
/** A change of the research's history by its commit hash (the app's /log head, or its first 8 as strom history shows it). */
|
|
105
|
+
const CHANGE = /^[0-9a-f]{7,40}$/;
|
|
103
106
|
/** An archive's host, as a connector names it (www.example.org): letters, digits, hyphens and dots only. */
|
|
104
107
|
const HOST = /^(?=.{1,253}$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/;
|
|
105
108
|
/** The name the app gives the tree's file of a move (its strom-prenos-<8 of its mark>.json). */
|
|
@@ -301,6 +304,15 @@ export function parseLink(text, scheme = LINK_SCHEME) {
|
|
|
301
304
|
const fix = oneOf(q, "id", LINK_FIX_IDS);
|
|
302
305
|
return { action, tree: id, id: fix, ...(q.has("do") ? { do: oneOf(q, "do", LINK_FIX_DOS) } : {}) };
|
|
303
306
|
}
|
|
307
|
+
case "back": {
|
|
308
|
+
// back in time: the change by its hash only (never a day or a text); none: the earlier changes to pick from
|
|
309
|
+
if (!q.has("change"))
|
|
310
|
+
return { action, tree: id };
|
|
311
|
+
const change = (q.get("change") ?? "").toLowerCase();
|
|
312
|
+
if (!CHANGE.test(change))
|
|
313
|
+
throw new LinkError("no change named");
|
|
314
|
+
return { action, tree: id, change };
|
|
315
|
+
}
|
|
304
316
|
}
|
|
305
317
|
throw new LinkError(`unknown action "${action.slice(0, 32)}"`);
|
|
306
318
|
}
|