memgineering 0.27.0 → 0.28.1
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 +137 -1
- package/README.md +11 -0
- package/assets/MEMGINEERING.md +4 -4
- package/assets/memgineering-setup/SKILL.md +77 -7
- package/dist/index.js +1223 -502
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -4108,16 +4108,12 @@ function findBlock(lines2) {
|
|
|
4108
4108
|
if (start === -1) return null;
|
|
4109
4109
|
if (inlineValueOf(lines2[start] ?? "") !== null) return { start, end: start + 1 };
|
|
4110
4110
|
let end = start + 1;
|
|
4111
|
-
|
|
4112
|
-
const line = lines2[
|
|
4113
|
-
if (line.trim() === "")
|
|
4114
|
-
end += 1;
|
|
4115
|
-
continue;
|
|
4116
|
-
}
|
|
4111
|
+
for (let i = start + 1; i < lines2.length; i += 1) {
|
|
4112
|
+
const line = lines2[i] ?? "";
|
|
4113
|
+
if (line.trim() === "" || line.startsWith("#")) continue;
|
|
4117
4114
|
if (!/^\s/.test(line)) break;
|
|
4118
|
-
end
|
|
4115
|
+
end = i + 1;
|
|
4119
4116
|
}
|
|
4120
|
-
while (end > start + 1 && (lines2[end - 1] ?? "").trim() === "") end -= 1;
|
|
4121
4117
|
return { start, end };
|
|
4122
4118
|
}
|
|
4123
4119
|
function blockBodyOf(lines2, span) {
|
|
@@ -4392,8 +4388,28 @@ function readNamespace(noteContent) {
|
|
|
4392
4388
|
return {};
|
|
4393
4389
|
}
|
|
4394
4390
|
}
|
|
4391
|
+
function hasUnreadableFrontmatter(mapped) {
|
|
4392
|
+
return mapped.issues.some((issue) => issue.startsWith(UNREADABLE_FRONTMATTER));
|
|
4393
|
+
}
|
|
4395
4394
|
function verifyPatch(patched, proposal, before) {
|
|
4396
4395
|
const mapped = mapNoteToMemory({ path: proposal.target.path, content: patched, revision: null });
|
|
4396
|
+
if (before !== void 0) {
|
|
4397
|
+
const was = mapNoteToMemory({ path: proposal.target.path, content: before, revision: null });
|
|
4398
|
+
if (!hasUnreadableFrontmatter(was)) {
|
|
4399
|
+
if (hasUnreadableFrontmatter(mapped)) {
|
|
4400
|
+
throw new PatchError(
|
|
4401
|
+
"the patched note has frontmatter that no longer parses, so the note would lose what it declared",
|
|
4402
|
+
"This is a defect in the patcher, not in your note \u2014 it would have dropped the note\u2019s id, binding and never-store words. Nothing was written."
|
|
4403
|
+
);
|
|
4404
|
+
}
|
|
4405
|
+
if (mapped.memory.id !== was.memory.id) {
|
|
4406
|
+
throw new PatchError(
|
|
4407
|
+
`the patched note no longer reads with its own id (${was.memory.id})`,
|
|
4408
|
+
"This is a defect in the patcher, not in your note \u2014 a note that loses its id is a different memory to everything that points at it. Nothing was written."
|
|
4409
|
+
);
|
|
4410
|
+
}
|
|
4411
|
+
}
|
|
4412
|
+
}
|
|
4397
4413
|
if (isLifecycleAction(proposal.action)) {
|
|
4398
4414
|
const want = STATUS_FOR_ACTION[proposal.action];
|
|
4399
4415
|
if (mapped.memory.status !== want) {
|
|
@@ -4629,7 +4645,7 @@ function reversePatch(content, patch) {
|
|
|
4629
4645
|
}
|
|
4630
4646
|
return null;
|
|
4631
4647
|
}
|
|
4632
|
-
var NAMESPACE2, FENCE_RE, LOOKS_FENCED_RE, PatchError, BLOCK_KEY_RE, ANY_INDENTED_KEY_RE;
|
|
4648
|
+
var NAMESPACE2, FENCE_RE, LOOKS_FENCED_RE, PatchError, BLOCK_KEY_RE, ANY_INDENTED_KEY_RE, UNREADABLE_FRONTMATTER;
|
|
4633
4649
|
var init_patch = __esm({
|
|
4634
4650
|
"../../packages/memory-engine/src/proposal/patch.ts"() {
|
|
4635
4651
|
"use strict";
|
|
@@ -4650,6 +4666,7 @@ var init_patch = __esm({
|
|
|
4650
4666
|
};
|
|
4651
4667
|
BLOCK_KEY_RE = /^([^\s#][^:]*?)\s*:/;
|
|
4652
4668
|
ANY_INDENTED_KEY_RE = /^(\s*)([^\s#][^:]*?)\s*:/;
|
|
4669
|
+
UNREADABLE_FRONTMATTER = "frontmatter is not valid YAML";
|
|
4653
4670
|
}
|
|
4654
4671
|
});
|
|
4655
4672
|
|
|
@@ -6865,10 +6882,10 @@ var init_cloud_pointer = __esm({
|
|
|
6865
6882
|
});
|
|
6866
6883
|
|
|
6867
6884
|
// src/commands/link.ts
|
|
6868
|
-
import { readFile as
|
|
6869
|
-
import { join as
|
|
6870
|
-
import { Command as
|
|
6871
|
-
import
|
|
6885
|
+
import { readFile as readFile20 } from "fs/promises";
|
|
6886
|
+
import { join as join20 } from "path";
|
|
6887
|
+
import { Command as Command14 } from "commander";
|
|
6888
|
+
import prompts3 from "prompts";
|
|
6872
6889
|
function sameBasename(all, entry) {
|
|
6873
6890
|
const base2 = (entry.split("/").pop() ?? entry).normalize("NFC").toLowerCase();
|
|
6874
6891
|
return all.filter((p) => (p.split("/").pop() ?? "").normalize("NFC").toLowerCase() === base2);
|
|
@@ -6890,7 +6907,7 @@ function spreadAcrossFolders(rows, max) {
|
|
|
6890
6907
|
return picked;
|
|
6891
6908
|
}
|
|
6892
6909
|
function linkCommand() {
|
|
6893
|
-
return new
|
|
6910
|
+
return new Command14("link").description("read a notes folder as a brain \u2014 audits its rules first").argument("<path>", "path to the notes folder").option("--yes", "skip the confirmation").option("--dry-run", "show exactly what would be stored, then stop").option(
|
|
6894
6911
|
"--observations <dir>",
|
|
6895
6912
|
"where `remember` writes, relative to the folder",
|
|
6896
6913
|
DEFAULT_OBSERVATIONS_DIR
|
|
@@ -7070,7 +7087,7 @@ async function recordLink(adapter, observationsDir) {
|
|
|
7070
7087
|
}
|
|
7071
7088
|
async function refuseSilentRules(path, denied, excluded, unsupported) {
|
|
7072
7089
|
const denyEntries = (await LocalFileReadAdapter.readDenyFile(path, ".memgdeny")).entries;
|
|
7073
|
-
const rawDenyLines = await
|
|
7090
|
+
const rawDenyLines = await readFile20(join20(path, ".memgdeny"), "utf8").then(
|
|
7074
7091
|
(t) => t.split("\n").map((l) => l.trim()).filter((l) => l !== "" && !l.startsWith("#"))
|
|
7075
7092
|
).catch(() => []);
|
|
7076
7093
|
const asWritten = (folded) => rawDenyLines.find(
|
|
@@ -7216,7 +7233,7 @@ Brain: ${root}`));
|
|
|
7216
7233
|
"\n This tool writes into your notes without asking each time \u2014 new\n observations, and changes to the memory block of a note. Every one is\n recorded and reversible: memgineering log \xB7 memgineering undo"
|
|
7217
7234
|
)
|
|
7218
7235
|
);
|
|
7219
|
-
const { ok } = await
|
|
7236
|
+
const { ok } = await prompts3({
|
|
7220
7237
|
type: "confirm",
|
|
7221
7238
|
name: "ok",
|
|
7222
7239
|
message: "Build the index for this folder?",
|
|
@@ -7297,9 +7314,9 @@ var init_open_browser = __esm({
|
|
|
7297
7314
|
});
|
|
7298
7315
|
|
|
7299
7316
|
// src/commands/login.ts
|
|
7300
|
-
import { Command as
|
|
7317
|
+
import { Command as Command22 } from "commander";
|
|
7301
7318
|
function loginCommand() {
|
|
7302
|
-
return new
|
|
7319
|
+
return new Command22("login").description("sign in to a hosted brain").option(
|
|
7303
7320
|
"--emit-only",
|
|
7304
7321
|
"start the sign-in, open the browser, and return immediately \u2014 THE path an agent should use on a user\u2019s behalf; the next command claims the token automatically. Prefer this over the plain form, whose wait for a human click will outlast an agent\u2019s command timeout"
|
|
7305
7322
|
).option("--no-browser", "do not try to open a browser \u2014 just print the link").option("--print-url", "print the approval link even when a browser opened").addHelpText(
|
|
@@ -7499,9 +7516,9 @@ var push_exports = {};
|
|
|
7499
7516
|
__export(push_exports, {
|
|
7500
7517
|
pushCommand: () => pushCommand
|
|
7501
7518
|
});
|
|
7502
|
-
import { Command as
|
|
7519
|
+
import { Command as Command37 } from "commander";
|
|
7503
7520
|
function pushCommand() {
|
|
7504
|
-
return new
|
|
7521
|
+
return new Command37("push").description("upload the brain on this machine to your hosted one").option("--vault <path>", "which local brain to upload").option("--brain <name>", "the hosted brain to upload into (created if it does not exist)").option("--dry-run", "list what would be uploaded and send nothing").action(async (opts) => {
|
|
7505
7522
|
const { brain: local } = await resolveBrain(opts.vault);
|
|
7506
7523
|
const adapter = await openBrainOrExplain(local.root);
|
|
7507
7524
|
const scan = await adapter.scan();
|
|
@@ -7753,8 +7770,8 @@ var init_guard_shell = __esm({
|
|
|
7753
7770
|
});
|
|
7754
7771
|
|
|
7755
7772
|
// src/lib/hook-refresh.ts
|
|
7756
|
-
import { chmod, lstat as lstat5, readFile as
|
|
7757
|
-
import { join as
|
|
7773
|
+
import { chmod, lstat as lstat5, readFile as readFile26 } from "fs/promises";
|
|
7774
|
+
import { join as join26 } from "path";
|
|
7758
7775
|
function moveShippedCommands(parsed, moves) {
|
|
7759
7776
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
7760
7777
|
const settings = parsed;
|
|
@@ -7785,10 +7802,10 @@ function moveShippedCommands(parsed, moves) {
|
|
|
7785
7802
|
return { next: changed === 0 ? settings : { ...settings, hooks: nextHooks }, changed };
|
|
7786
7803
|
}
|
|
7787
7804
|
function withHookFileLock(fn, waitMs = 0) {
|
|
7788
|
-
return withPathLock(
|
|
7805
|
+
return withPathLock(join26(brandHome(), "hook-files.lock"), fn, waitMs);
|
|
7789
7806
|
}
|
|
7790
7807
|
async function readSettings(path) {
|
|
7791
|
-
const raw = await
|
|
7808
|
+
const raw = await readFile26(path, "utf8").catch(() => null);
|
|
7792
7809
|
if (raw === null) return void 0;
|
|
7793
7810
|
try {
|
|
7794
7811
|
return JSON.parse(raw);
|
|
@@ -8024,7 +8041,7 @@ var init_setup_brain = __esm({
|
|
|
8024
8041
|
});
|
|
8025
8042
|
|
|
8026
8043
|
// src/commands/setup-signin.ts
|
|
8027
|
-
import
|
|
8044
|
+
import prompts5 from "prompts";
|
|
8028
8045
|
async function runSignInStep(opts) {
|
|
8029
8046
|
const summary = await signInSummary();
|
|
8030
8047
|
if (summary.signedIn) return { status: "signed-in", displayName: summary.displayName };
|
|
@@ -8051,7 +8068,7 @@ async function runSignInStep(opts) {
|
|
|
8051
8068
|
}
|
|
8052
8069
|
if (opts.interactive) {
|
|
8053
8070
|
printHuman(c.bold("\nmemgineering \u2014 setup\n"));
|
|
8054
|
-
const { wants } = await
|
|
8071
|
+
const { wants } = await prompts5({
|
|
8055
8072
|
type: "toggle",
|
|
8056
8073
|
name: "wants",
|
|
8057
8074
|
message: "Sign in to a memgineering account first?",
|
|
@@ -8181,37 +8198,37 @@ var init_setup_signin = __esm({
|
|
|
8181
8198
|
});
|
|
8182
8199
|
|
|
8183
8200
|
// src/lib/next-step.ts
|
|
8184
|
-
import { mkdir as
|
|
8185
|
-
import { join as
|
|
8201
|
+
import { mkdir as mkdir17, readFile as readFile27, writeFile as writeFile14 } from "fs/promises";
|
|
8202
|
+
import { join as join27 } from "path";
|
|
8186
8203
|
function isSetUp(cfg) {
|
|
8187
8204
|
return Object.keys(cfg.system.installed).length > 0;
|
|
8188
8205
|
}
|
|
8189
8206
|
function connectedMarker(at) {
|
|
8190
|
-
return
|
|
8207
|
+
return join27(brandHome(), `setup-connected-shown-${at.replace(/[^0-9A-Za-z]/g, "")}`);
|
|
8191
8208
|
}
|
|
8192
8209
|
async function connectedNoticeShown(at) {
|
|
8193
|
-
return
|
|
8210
|
+
return readFile27(connectedMarker(at), "utf8").then(
|
|
8194
8211
|
() => true,
|
|
8195
8212
|
() => false
|
|
8196
8213
|
);
|
|
8197
8214
|
}
|
|
8198
8215
|
async function markConnectedNoticeShown(at) {
|
|
8199
8216
|
try {
|
|
8200
|
-
await
|
|
8217
|
+
await mkdir17(brandHome(), { recursive: true });
|
|
8201
8218
|
await writeFile14(connectedMarker(at), `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
8202
8219
|
`);
|
|
8203
8220
|
} catch {
|
|
8204
8221
|
}
|
|
8205
8222
|
}
|
|
8206
8223
|
async function claimFullSetupNotice() {
|
|
8207
|
-
const marker =
|
|
8224
|
+
const marker = join27(brandHome(), "setup-notice-shown");
|
|
8208
8225
|
try {
|
|
8209
|
-
await
|
|
8226
|
+
await readFile27(marker, "utf8");
|
|
8210
8227
|
return false;
|
|
8211
8228
|
} catch {
|
|
8212
8229
|
}
|
|
8213
8230
|
try {
|
|
8214
|
-
await
|
|
8231
|
+
await mkdir17(brandHome(), { recursive: true });
|
|
8215
8232
|
await writeFile14(marker, `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
8216
8233
|
`);
|
|
8217
8234
|
} catch {
|
|
@@ -8378,7 +8395,7 @@ Synced instead? \`memgineering login\`, then \`memgineering create <name>\`.`;
|
|
|
8378
8395
|
// src/lib/provenance.ts
|
|
8379
8396
|
import { execFile, spawn as spawn2 } from "child_process";
|
|
8380
8397
|
import { realpath as realpath3 } from "fs/promises";
|
|
8381
|
-
import { dirname as dirname9, join as
|
|
8398
|
+
import { dirname as dirname9, join as join28, resolve as resolve14 } from "path";
|
|
8382
8399
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
8383
8400
|
import { promisify } from "util";
|
|
8384
8401
|
async function detectProvenance(selfPath, opts = {}) {
|
|
@@ -8516,7 +8533,7 @@ var init_provenance = __esm({
|
|
|
8516
8533
|
kind: "npm",
|
|
8517
8534
|
bin: "npm",
|
|
8518
8535
|
prefixArgs: ["prefix", "-g"],
|
|
8519
|
-
moduleRoot: (prefix) => process.platform === "win32" ?
|
|
8536
|
+
moduleRoot: (prefix) => process.platform === "win32" ? join28(prefix, "node_modules") : join28(prefix, "lib", "node_modules"),
|
|
8520
8537
|
install: "npm i -g memgineering@latest"
|
|
8521
8538
|
},
|
|
8522
8539
|
{
|
|
@@ -8553,9 +8570,9 @@ __export(setup_cloud_exports, {
|
|
|
8553
8570
|
});
|
|
8554
8571
|
import { spawn as spawn3 } from "child_process";
|
|
8555
8572
|
import { realpathSync as realpathSync2 } from "fs";
|
|
8556
|
-
import { readdir as readdir9, stat as
|
|
8573
|
+
import { readdir as readdir9, stat as stat9 } from "fs/promises";
|
|
8557
8574
|
import { homedir as homedir5 } from "os";
|
|
8558
|
-
import { basename as basename4, dirname as dirname10, join as
|
|
8575
|
+
import { basename as basename4, dirname as dirname10, join as join29, resolve as resolve15, sep as sep4 } from "path";
|
|
8559
8576
|
async function report2(setupToken, state, detail, code) {
|
|
8560
8577
|
try {
|
|
8561
8578
|
await apiRequest({
|
|
@@ -8573,7 +8590,7 @@ async function report2(setupToken, state, detail, code) {
|
|
|
8573
8590
|
}
|
|
8574
8591
|
async function folderCandidates() {
|
|
8575
8592
|
const home = homedir5();
|
|
8576
|
-
const roots = ["Documents", "notes", "Notes", "Obsidian", "vault"].map((d) =>
|
|
8593
|
+
const roots = ["Documents", "notes", "Notes", "Obsidian", "vault"].map((d) => join29(home, d));
|
|
8577
8594
|
const found = [];
|
|
8578
8595
|
const countNotes = async (dir) => {
|
|
8579
8596
|
let count = 0;
|
|
@@ -8582,7 +8599,7 @@ async function folderCandidates() {
|
|
|
8582
8599
|
if (entry.name.startsWith(".")) continue;
|
|
8583
8600
|
if (entry.isFile() && /\.(md|markdown)$/i.test(entry.name)) count += 1;
|
|
8584
8601
|
else if (entry.isDirectory()) {
|
|
8585
|
-
const inner = await readdir9(
|
|
8602
|
+
const inner = await readdir9(join29(dir, entry.name)).catch(() => []);
|
|
8586
8603
|
count += inner.filter((n) => /\.(md|markdown)$/i.test(n)).length;
|
|
8587
8604
|
}
|
|
8588
8605
|
if (count > 999) break;
|
|
@@ -8590,7 +8607,7 @@ async function folderCandidates() {
|
|
|
8590
8607
|
return count;
|
|
8591
8608
|
};
|
|
8592
8609
|
for (const root of roots) {
|
|
8593
|
-
const info = await
|
|
8610
|
+
const info = await stat9(root).catch(() => null);
|
|
8594
8611
|
if (!info?.isDirectory()) continue;
|
|
8595
8612
|
const notes = await countNotes(root);
|
|
8596
8613
|
if (notes > 0) found.push({ path: root, note_count: notes });
|
|
@@ -8935,8 +8952,8 @@ function insideFolder(target, folder) {
|
|
|
8935
8952
|
return landed === root || landed.startsWith(root + sep4);
|
|
8936
8953
|
}
|
|
8937
8954
|
async function askBeforeUpload(q) {
|
|
8938
|
-
const { default:
|
|
8939
|
-
const { yes } = await
|
|
8955
|
+
const { default: prompts7 } = await import("prompts");
|
|
8956
|
+
const { yes } = await prompts7({
|
|
8940
8957
|
type: "confirm",
|
|
8941
8958
|
name: "yes",
|
|
8942
8959
|
message: `Upload the notes in ${q.path} to the brain on ${q.email ?? "this account"}?`,
|
|
@@ -8974,14 +8991,14 @@ var init_setup_cloud = __esm({
|
|
|
8974
8991
|
|
|
8975
8992
|
// src/commands/setup.ts
|
|
8976
8993
|
import { createHash as createHash9 } from "crypto";
|
|
8977
|
-
import { access as access2, mkdir as
|
|
8978
|
-
import { dirname as dirname11, join as
|
|
8994
|
+
import { access as access2, mkdir as mkdir18, readFile as readFile28 } from "fs/promises";
|
|
8995
|
+
import { dirname as dirname11, join as join30 } from "path";
|
|
8979
8996
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
8980
|
-
import { Command as
|
|
8981
|
-
import
|
|
8997
|
+
import { Command as Command39 } from "commander";
|
|
8998
|
+
import prompts6 from "prompts";
|
|
8982
8999
|
import { homedir as homedir6 } from "os";
|
|
8983
9000
|
function setupCommand() {
|
|
8984
|
-
return new
|
|
9001
|
+
return new Command39("setup").description("install into your agents, and point at a brain (--dry-run to only report)").option("--agent", "non-interactive: take every answer from flags").option("--human", "interactive: choose from a list").option("--web", "open a screen in the browser and answer it there").option("--print-url", "with --web: print the URL instead of opening a browser").option(
|
|
8985
9002
|
"--wait",
|
|
8986
9003
|
"with --web: block until the screen is finished, even with nobody watching the terminal"
|
|
8987
9004
|
).option(
|
|
@@ -9002,9 +9019,11 @@ function setupCommand() {
|
|
|
9002
9019
|
"",
|
|
9003
9020
|
"Chat apps with no shell need no setup. They read and write the brain on your",
|
|
9004
9021
|
`account (not a folder on this machine) at ${HOSTED_CONNECTOR_URL}:`,
|
|
9005
|
-
" ChatGPT: Settings \u2192 Developer mode \u2192 add an MCP server with that URL, sign in.",
|
|
9006
9022
|
" Claude.ai, Claude Desktop, Cowork: Customize \u2192 Connectors \u2192 Add custom",
|
|
9007
|
-
" connector with that URL, sign in."
|
|
9023
|
+
" connector with that URL, sign in.",
|
|
9024
|
+
" ChatGPT: Settings \u2192 Developer mode \u2192 add an MCP server with that URL, sign in",
|
|
9025
|
+
" (paused for now: the connect screen refuses ChatGPT while its notice is",
|
|
9026
|
+
" verified; use Claude or Gemini meanwhile)."
|
|
9008
9027
|
].join("\n")
|
|
9009
9028
|
).action(async (opts) => {
|
|
9010
9029
|
const detected = await detectTools();
|
|
@@ -9277,7 +9296,7 @@ function setupCommand() {
|
|
|
9277
9296
|
}
|
|
9278
9297
|
});
|
|
9279
9298
|
if (mode.kind === "human" && brains.length === 0 && !opts.dryRun && isInteractive()) {
|
|
9280
|
-
const { path } = await
|
|
9299
|
+
const { path } = await prompts6({
|
|
9281
9300
|
type: "text",
|
|
9282
9301
|
name: "path",
|
|
9283
9302
|
message: "Path to your notes folder (blank to skip)"
|
|
@@ -9342,7 +9361,7 @@ async function applySetup(choice, dryRun) {
|
|
|
9342
9361
|
}
|
|
9343
9362
|
async function write2() {
|
|
9344
9363
|
for (const tool of choice.tools) {
|
|
9345
|
-
const hubPath =
|
|
9364
|
+
const hubPath = join30(agentHome(), tool.hubFile);
|
|
9346
9365
|
const written = await injectBlock(
|
|
9347
9366
|
hubPath,
|
|
9348
9367
|
hub + tailFor(tool, choice.hook),
|
|
@@ -9357,8 +9376,8 @@ async function applySetup(choice, dryRun) {
|
|
|
9357
9376
|
});
|
|
9358
9377
|
if (!dryRun && written.after !== null) mark(hubPath, written.after);
|
|
9359
9378
|
for (const skill of BRAND.subSkills) {
|
|
9360
|
-
const content = await loadAsset(
|
|
9361
|
-
const path =
|
|
9379
|
+
const content = await loadAsset(join30(skill, "SKILL.md"));
|
|
9380
|
+
const path = join30(agentHome(), tool.skillsDir, skill, "SKILL.md");
|
|
9362
9381
|
const out = await writeIfDifferent(path, content, dryRun);
|
|
9363
9382
|
results.push({
|
|
9364
9383
|
tool: tool.label,
|
|
@@ -9448,7 +9467,7 @@ async function hooksArmed(tools) {
|
|
|
9448
9467
|
const capable = tools.filter((t) => t.hooks && t.hooksFile);
|
|
9449
9468
|
if (capable.length === 0) return void 0;
|
|
9450
9469
|
for (const tool of capable) {
|
|
9451
|
-
const raw = await
|
|
9470
|
+
const raw = await readFile28(join30(agentHome(), ...(tool.hooksFile ?? "").split("/")), "utf8").catch(
|
|
9452
9471
|
() => ""
|
|
9453
9472
|
);
|
|
9454
9473
|
if (hooksFor([tool]).some((spec) => raw.includes(spec.signature))) return "on";
|
|
@@ -9468,7 +9487,7 @@ async function resolveMode(opts) {
|
|
|
9468
9487
|
return { kind: "human", chosen: true };
|
|
9469
9488
|
}
|
|
9470
9489
|
if (!isInteractive() || isJsonMode()) return { kind: "agent", chosen: false };
|
|
9471
|
-
const { mode } = await
|
|
9490
|
+
const { mode } = await prompts6({
|
|
9472
9491
|
type: "select",
|
|
9473
9492
|
name: "mode",
|
|
9474
9493
|
message: "How would you like to set this up?",
|
|
@@ -9488,7 +9507,7 @@ async function detectTools() {
|
|
|
9488
9507
|
const home = agentHome();
|
|
9489
9508
|
const found = [];
|
|
9490
9509
|
for (const tool of TOOLS) {
|
|
9491
|
-
if (await exists2(
|
|
9510
|
+
if (await exists2(join30(home, tool.dir))) found.push(tool);
|
|
9492
9511
|
}
|
|
9493
9512
|
return found;
|
|
9494
9513
|
}
|
|
@@ -9535,7 +9554,7 @@ async function askHuman(detected, opts) {
|
|
|
9535
9554
|
printHuman(c.bold("\nmemgineering \u2014 setup\n"));
|
|
9536
9555
|
printHuman(c.gray(" Found: ") + detected.map((t) => t.label).join(", "));
|
|
9537
9556
|
printHuman("");
|
|
9538
|
-
const answers = await
|
|
9557
|
+
const answers = await prompts6([
|
|
9539
9558
|
{
|
|
9540
9559
|
type: "multiselect",
|
|
9541
9560
|
name: "tools",
|
|
@@ -9588,10 +9607,10 @@ async function injectBlock(filePath, content, dryRun, weWroteThis) {
|
|
|
9588
9607
|
const block = `${BRAND.hubMarkerStart}
|
|
9589
9608
|
${content.trimEnd()}
|
|
9590
9609
|
${BRAND.hubMarkerEnd}`;
|
|
9591
|
-
const existing = await
|
|
9610
|
+
const existing = await readFile28(filePath, "utf8").catch(() => null);
|
|
9592
9611
|
if (existing === null) {
|
|
9593
9612
|
if (!dryRun) {
|
|
9594
|
-
await
|
|
9613
|
+
await mkdir18(dirname11(filePath), { recursive: true });
|
|
9595
9614
|
await writeThenRename(filePath, `${block}
|
|
9596
9615
|
`);
|
|
9597
9616
|
}
|
|
@@ -9631,11 +9650,11 @@ function looksLikeOurGuide(text) {
|
|
|
9631
9650
|
return text.includes("memgineering recall") && text.includes("memgineering remember");
|
|
9632
9651
|
}
|
|
9633
9652
|
async function writeIfDifferent(filePath, content, dryRun) {
|
|
9634
|
-
const existing = await
|
|
9653
|
+
const existing = await readFile28(filePath, "utf8").catch(() => null);
|
|
9635
9654
|
const after = fingerprint(content);
|
|
9636
9655
|
if (existing === content) return { outcome: "unchanged", before: existing, after };
|
|
9637
9656
|
if (!dryRun) {
|
|
9638
|
-
await
|
|
9657
|
+
await mkdir18(dirname11(filePath), { recursive: true });
|
|
9639
9658
|
await writeThenRename(filePath, content);
|
|
9640
9659
|
}
|
|
9641
9660
|
return { outcome: existing === null ? "injected" : "updated", before: existing, after };
|
|
@@ -9652,7 +9671,7 @@ async function refreshOwnHookCommands() {
|
|
|
9652
9671
|
const changed = [];
|
|
9653
9672
|
const skipped = [];
|
|
9654
9673
|
for (const tool of TOOLS.filter((t) => t.hooks && t.hooksFile && DEFAULT_HOOK_TOOLS.includes(t.id))) {
|
|
9655
|
-
const path =
|
|
9674
|
+
const path = join30(agentHome(), ...(tool.hooksFile ?? "").split("/"));
|
|
9656
9675
|
const outcome = await refreshHookFile(path, moves);
|
|
9657
9676
|
if (outcome === "changed") changed.push(path);
|
|
9658
9677
|
else if (outcome === "symlink" || outcome === "refused") skipped.push({ path, why: outcome });
|
|
@@ -9679,8 +9698,8 @@ function hooksFor(tools) {
|
|
|
9679
9698
|
);
|
|
9680
9699
|
}
|
|
9681
9700
|
async function installHook(spec, tool, dryRun) {
|
|
9682
|
-
const settingsPath =
|
|
9683
|
-
const raw = await
|
|
9701
|
+
const settingsPath = join30(agentHome(), ...(tool.hooksFile ?? "").split("/"));
|
|
9702
|
+
const raw = await readFile28(settingsPath, "utf8").catch(() => null);
|
|
9684
9703
|
let settings = {};
|
|
9685
9704
|
if (raw !== null) {
|
|
9686
9705
|
try {
|
|
@@ -9722,15 +9741,15 @@ async function installHook(spec, tool, dryRun) {
|
|
|
9722
9741
|
}
|
|
9723
9742
|
const next = { ...settings, hooks: { ...hooks, [spec.event]: existingGroups } };
|
|
9724
9743
|
if (!dryRun) {
|
|
9725
|
-
await
|
|
9744
|
+
await mkdir18(dirname11(settingsPath), { recursive: true });
|
|
9726
9745
|
await writeThenRename(settingsPath, `${JSON.stringify(next, null, 2)}
|
|
9727
9746
|
`);
|
|
9728
9747
|
}
|
|
9729
9748
|
return raw === null ? "injected" : "updated";
|
|
9730
9749
|
}
|
|
9731
9750
|
async function removeHook(spec, tool, dryRun) {
|
|
9732
|
-
const settingsPath =
|
|
9733
|
-
const raw = await
|
|
9751
|
+
const settingsPath = join30(agentHome(), ...(tool.hooksFile ?? "").split("/"));
|
|
9752
|
+
const raw = await readFile28(settingsPath, "utf8").catch(() => null);
|
|
9734
9753
|
if (raw === null) return "unchanged";
|
|
9735
9754
|
let parsed;
|
|
9736
9755
|
try {
|
|
@@ -9754,7 +9773,7 @@ async function removeHook(spec, tool, dryRun) {
|
|
|
9754
9773
|
return "removed";
|
|
9755
9774
|
}
|
|
9756
9775
|
async function loadAsset(relPath) {
|
|
9757
|
-
const raw = await
|
|
9776
|
+
const raw = await readFile28(join30(await assetRoot(), relPath), "utf8");
|
|
9758
9777
|
if (relPath === BRAND.hubFileName && raw.startsWith("---")) {
|
|
9759
9778
|
const end = raw.indexOf("\n---", 4);
|
|
9760
9779
|
if (end !== -1) return raw.slice(end + 4).trimStart();
|
|
@@ -9763,12 +9782,12 @@ async function loadAsset(relPath) {
|
|
|
9763
9782
|
}
|
|
9764
9783
|
async function assetRoot() {
|
|
9765
9784
|
const here = dirname11(fileURLToPath3(import.meta.url));
|
|
9766
|
-
const bundled =
|
|
9767
|
-
if (await exists2(
|
|
9785
|
+
const bundled = join30(here, "..", "assets");
|
|
9786
|
+
if (await exists2(join30(bundled, BRAND.hubFileName))) return bundled;
|
|
9768
9787
|
let dir = here;
|
|
9769
9788
|
for (; ; ) {
|
|
9770
|
-
const candidate =
|
|
9771
|
-
if (await exists2(
|
|
9789
|
+
const candidate = join30(dir, "packages", "skills");
|
|
9790
|
+
if (await exists2(join30(candidate, BRAND.hubFileName))) return candidate;
|
|
9772
9791
|
const parent = dirname11(dir);
|
|
9773
9792
|
if (parent === dir) break;
|
|
9774
9793
|
dir = parent;
|
|
@@ -9963,7 +9982,7 @@ For a guide: put ${BRAND.hubMarkerStart} and ${BRAND.hubMarkerEnd} back around t
|
|
|
9963
9982
|
import net from "net";
|
|
9964
9983
|
|
|
9965
9984
|
// src/program.ts
|
|
9966
|
-
import { Command as
|
|
9985
|
+
import { Command as Command47 } from "commander";
|
|
9967
9986
|
|
|
9968
9987
|
// src/help.ts
|
|
9969
9988
|
init_ui();
|
|
@@ -10031,6 +10050,7 @@ var COMMAND_GROUPS = [
|
|
|
10031
10050
|
"create",
|
|
10032
10051
|
"rename",
|
|
10033
10052
|
"delete-brain",
|
|
10053
|
+
"delete-account",
|
|
10034
10054
|
"push",
|
|
10035
10055
|
"pull"
|
|
10036
10056
|
]
|
|
@@ -11525,6 +11545,11 @@ var YankResponseSchema = z19.object({
|
|
|
11525
11545
|
yank_reason: z19.string().max(280).nullable(),
|
|
11526
11546
|
effective_current_version: SemverSchema
|
|
11527
11547
|
});
|
|
11548
|
+
var RestorePackageResponseSchema = z19.object({
|
|
11549
|
+
full_slug: FullSlugSchema,
|
|
11550
|
+
status: z19.literal("restored"),
|
|
11551
|
+
restored_at: IsoDateTimeSchema
|
|
11552
|
+
});
|
|
11528
11553
|
var ResolveVersionQuerySchema = z19.object({
|
|
11529
11554
|
range: SemverRangeSchema
|
|
11530
11555
|
});
|
|
@@ -11569,7 +11594,15 @@ var UserProfileResponseSchema = PublicUserSchema.extend({
|
|
|
11569
11594
|
* responses omit both. Optional so pre-P1 clients ignore them.
|
|
11570
11595
|
*/
|
|
11571
11596
|
viewer_is_following: z19.boolean().optional(),
|
|
11572
|
-
viewer_is_self: z19.boolean().optional()
|
|
11597
|
+
viewer_is_self: z19.boolean().optional(),
|
|
11598
|
+
/**
|
|
11599
|
+
* Whether other people can see this profile (migration 0031). A profile
|
|
11600
|
+
* becomes public with its owner's first public publish, comment or star,
|
|
11601
|
+
* and stays public. Anyone else asking for a non-public profile gets the
|
|
11602
|
+
* unknown-user `404`, so `false` only ever reaches the owner. Absent from
|
|
11603
|
+
* servers that predate it; treat absent as public.
|
|
11604
|
+
*/
|
|
11605
|
+
is_public: z19.boolean().optional()
|
|
11573
11606
|
});
|
|
11574
11607
|
var UserPackagesQuerySchema = z19.object({
|
|
11575
11608
|
sort: SortModeSchema.default("stars"),
|
|
@@ -11597,6 +11630,81 @@ var ListFollowersResponseSchema = z19.object({
|
|
|
11597
11630
|
results: PublicUserSchema.array(),
|
|
11598
11631
|
next_cursor: z19.string().nullable()
|
|
11599
11632
|
});
|
|
11633
|
+
var MeResponseSchema = SelfUserSchema.extend({
|
|
11634
|
+
/**
|
|
11635
|
+
* Whether the caller's registry profile is visible to other people
|
|
11636
|
+
* (migration 0031): false until their first public publish, comment or
|
|
11637
|
+
* star. Absent from servers that predate it; treat absent as public.
|
|
11638
|
+
*/
|
|
11639
|
+
profile_public: z19.boolean().optional()
|
|
11640
|
+
});
|
|
11641
|
+
var DeleteMeRequestSchema = z19.object({
|
|
11642
|
+
confirm_username: z19.string().min(1).max(32)
|
|
11643
|
+
});
|
|
11644
|
+
var AccountExportUserSchema = z19.object({
|
|
11645
|
+
id: z19.string(),
|
|
11646
|
+
username: z19.string(),
|
|
11647
|
+
display_name: z19.string().nullable(),
|
|
11648
|
+
email: z19.string().nullable(),
|
|
11649
|
+
bio: z19.string().nullable(),
|
|
11650
|
+
avatar_url: z19.string().nullable(),
|
|
11651
|
+
primary_provider: z19.string(),
|
|
11652
|
+
role: z19.string(),
|
|
11653
|
+
created_at: z19.string(),
|
|
11654
|
+
updated_at: z19.string(),
|
|
11655
|
+
last_active_at: z19.string().nullable()
|
|
11656
|
+
});
|
|
11657
|
+
var AccountExportSchema = z19.object({
|
|
11658
|
+
schema_version: z19.literal(1),
|
|
11659
|
+
exported_at: z19.string(),
|
|
11660
|
+
user: AccountExportUserSchema,
|
|
11661
|
+
packages: z19.array(
|
|
11662
|
+
z19.object({
|
|
11663
|
+
id: z19.string(),
|
|
11664
|
+
slug: z19.string(),
|
|
11665
|
+
full_slug: z19.string(),
|
|
11666
|
+
type: z19.string(),
|
|
11667
|
+
tier: z19.string(),
|
|
11668
|
+
title: z19.string(),
|
|
11669
|
+
description: z19.string(),
|
|
11670
|
+
content: z19.string(),
|
|
11671
|
+
current_version: z19.string(),
|
|
11672
|
+
visibility: z19.string(),
|
|
11673
|
+
created_at: z19.string(),
|
|
11674
|
+
updated_at: z19.string(),
|
|
11675
|
+
deleted_at: z19.string().nullable()
|
|
11676
|
+
})
|
|
11677
|
+
),
|
|
11678
|
+
package_versions: z19.array(
|
|
11679
|
+
z19.object({
|
|
11680
|
+
id: z19.string(),
|
|
11681
|
+
package_id: z19.string(),
|
|
11682
|
+
version: z19.string(),
|
|
11683
|
+
content: z19.string(),
|
|
11684
|
+
review_status: z19.string(),
|
|
11685
|
+
published_at: z19.string(),
|
|
11686
|
+
yanked_at: z19.string().nullable()
|
|
11687
|
+
})
|
|
11688
|
+
),
|
|
11689
|
+
comments: z19.array(
|
|
11690
|
+
z19.object({
|
|
11691
|
+
id: z19.string(),
|
|
11692
|
+
package_id: z19.string(),
|
|
11693
|
+
body: z19.string(),
|
|
11694
|
+
kind: z19.string(),
|
|
11695
|
+
title: z19.string().nullable(),
|
|
11696
|
+
status: z19.string().nullable(),
|
|
11697
|
+
parent_id: z19.string().nullable(),
|
|
11698
|
+
created_at: z19.string(),
|
|
11699
|
+
edited_at: z19.string().nullable(),
|
|
11700
|
+
deleted_at: z19.string().nullable()
|
|
11701
|
+
})
|
|
11702
|
+
),
|
|
11703
|
+
stars: z19.array(z19.object({ package_id: z19.string(), created_at: z19.string() })),
|
|
11704
|
+
follows: z19.array(
|
|
11705
|
+
z19.object({ follower_id: z19.string(), following_id: z19.string(), created_at: z19.string() })
|
|
11706
|
+
)
|
|
11707
|
+
});
|
|
11600
11708
|
|
|
11601
11709
|
// ../../packages/contracts/src/context.ts
|
|
11602
11710
|
import { z as z20 } from "zod";
|
|
@@ -12078,6 +12186,23 @@ var KordisClient = class {
|
|
|
12078
12186
|
me() {
|
|
12079
12187
|
return this.request("/api/me");
|
|
12080
12188
|
}
|
|
12189
|
+
/**
|
|
12190
|
+
* The account's own data — the one registry answer that carries its `email`.
|
|
12191
|
+
* A GET, so it is retried once on a failed fetch like every other GET.
|
|
12192
|
+
*/
|
|
12193
|
+
exportMe() {
|
|
12194
|
+
return this.request("/api/me/export");
|
|
12195
|
+
}
|
|
12196
|
+
/**
|
|
12197
|
+
* Delete the signed-in registry account. Irreversible: the server compares
|
|
12198
|
+
* `confirm_username` with the current username and answers 204. The account
|
|
12199
|
+
* is renamed `deleted-<id>`; its published packages and versions stay at their
|
|
12200
|
+
* existing addresses, which still contain the old username. Never retried
|
|
12201
|
+
* (a DELETE), like every write here.
|
|
12202
|
+
*/
|
|
12203
|
+
deleteMe(body) {
|
|
12204
|
+
return this.request("/api/me", { method: "DELETE", body });
|
|
12205
|
+
}
|
|
12081
12206
|
listMyPackages(opts = {}) {
|
|
12082
12207
|
return this.request("/api/me/packages", {
|
|
12083
12208
|
query: {
|
|
@@ -12109,6 +12234,18 @@ var KordisClient = class {
|
|
|
12109
12234
|
deletePackage(username, slug) {
|
|
12110
12235
|
return this.request(`/api/packages/${seg(username)}/${seg(slug)}`, { method: "DELETE" });
|
|
12111
12236
|
}
|
|
12237
|
+
/**
|
|
12238
|
+
* Undo a delete. Author only, within 30 days of the deletion and before the
|
|
12239
|
+
* package's content is deleted; refusals are `conflict` (not deleted, too
|
|
12240
|
+
* late, content already deleted), `not_authorized` and `not_found`, each
|
|
12241
|
+
* with a hint.
|
|
12242
|
+
*/
|
|
12243
|
+
restorePackage(username, slug) {
|
|
12244
|
+
return this.request(
|
|
12245
|
+
`/api/packages/${seg(username)}/${seg(slug)}/restore`,
|
|
12246
|
+
{ method: "POST" }
|
|
12247
|
+
);
|
|
12248
|
+
}
|
|
12112
12249
|
getContent(username, slug, opts = {}) {
|
|
12113
12250
|
return this.request(
|
|
12114
12251
|
`/api/packages/${seg(username)}/${seg(slug)}/content`,
|
|
@@ -16890,70 +17027,699 @@ function nextStep3(renamed) {
|
|
|
16890
17027
|
return `Other machines that point at this brain keep showing the old name until their next command against it; nothing on them breaks \u2014 the pointer holds the id. \`--brain "${oneLine(renamed.renamed_from, WIDTH.title)}"\` no longer matches anywhere; use the new name or the id.`;
|
|
16891
17028
|
}
|
|
16892
17029
|
|
|
16893
|
-
// src/commands/delete-
|
|
17030
|
+
// src/commands/delete-account.ts
|
|
17031
|
+
import { Command as Command12 } from "commander";
|
|
17032
|
+
import prompts from "prompts";
|
|
16894
17033
|
init_errors();
|
|
16895
17034
|
init_api_client();
|
|
16896
|
-
|
|
17035
|
+
|
|
17036
|
+
// src/lib/account-deletion-marker.ts
|
|
17037
|
+
init_atomic();
|
|
17038
|
+
init_brand();
|
|
17039
|
+
import { mkdir as mkdir12, readFile as readFile18, stat as stat5, unlink as unlink5 } from "fs/promises";
|
|
17040
|
+
import { join as join19 } from "path";
|
|
17041
|
+
import { z as z25 } from "zod";
|
|
17042
|
+
var SideSchema = z25.object({
|
|
17043
|
+
api_url: z25.string().min(1),
|
|
17044
|
+
/** When the delete request was sent — set before it goes, so a lost answer is visible. */
|
|
17045
|
+
requested_at: z25.string().min(1).nullable().default(null),
|
|
17046
|
+
/** When the server confirmed it. Null while that side is still to do. */
|
|
17047
|
+
deleted_at: z25.string().min(1).nullable().default(null)
|
|
17048
|
+
});
|
|
17049
|
+
var MarkerSchema = z25.object({
|
|
17050
|
+
version: z25.literal(1),
|
|
17051
|
+
started_at: z25.string().min(1),
|
|
17052
|
+
/** How the two accounts were matched before anything was deleted. */
|
|
17053
|
+
matched_by: z25.enum(["email", "federation"]),
|
|
17054
|
+
brain: SideSchema.extend({ account_id: z25.string().min(1) }),
|
|
17055
|
+
registry: SideSchema.extend({
|
|
17056
|
+
user_id: z25.string().min(1),
|
|
17057
|
+
username: z25.string().min(1)
|
|
17058
|
+
})
|
|
17059
|
+
});
|
|
17060
|
+
function accountDeletionMarkerPath() {
|
|
17061
|
+
return join19(brandHome(), "delete-account.json");
|
|
17062
|
+
}
|
|
17063
|
+
async function readAccountDeletionMarker() {
|
|
17064
|
+
try {
|
|
17065
|
+
const parsed = MarkerSchema.safeParse(
|
|
17066
|
+
JSON.parse(await readFile18(accountDeletionMarkerPath(), "utf8"))
|
|
17067
|
+
);
|
|
17068
|
+
return parsed.success ? parsed.data : null;
|
|
17069
|
+
} catch {
|
|
17070
|
+
return null;
|
|
17071
|
+
}
|
|
17072
|
+
}
|
|
17073
|
+
async function accountDeletionMarkerExists() {
|
|
17074
|
+
return stat5(accountDeletionMarkerPath()).then(
|
|
17075
|
+
() => true,
|
|
17076
|
+
() => false
|
|
17077
|
+
);
|
|
17078
|
+
}
|
|
17079
|
+
async function saveAccountDeletionMarker(marker) {
|
|
17080
|
+
await mkdir12(brandHome(), { recursive: true });
|
|
17081
|
+
await writeThenRename(accountDeletionMarkerPath(), `${JSON.stringify(marker, null, 2)}
|
|
17082
|
+
`);
|
|
17083
|
+
}
|
|
17084
|
+
async function clearAccountDeletionMarker() {
|
|
17085
|
+
await unlink5(accountDeletionMarkerPath()).catch(() => void 0);
|
|
17086
|
+
}
|
|
17087
|
+
|
|
17088
|
+
// src/commands/delete-account.ts
|
|
16897
17089
|
init_config();
|
|
17090
|
+
init_credentials();
|
|
17091
|
+
init_pending_login();
|
|
17092
|
+
|
|
17093
|
+
// src/lib/registry-session.ts
|
|
17094
|
+
init_errors();
|
|
17095
|
+
init_credentials();
|
|
17096
|
+
init_version();
|
|
17097
|
+
function registryApiUrl(stored) {
|
|
17098
|
+
const override = process.env["KORDIS_API_URL"];
|
|
17099
|
+
return override !== void 0 && override !== "" ? override : stored;
|
|
17100
|
+
}
|
|
17101
|
+
async function requireRegistryCredentials() {
|
|
17102
|
+
const credentials = await readCredentials();
|
|
17103
|
+
const registry = credentials?.registry;
|
|
17104
|
+
if (!registry) {
|
|
17105
|
+
throw memgError(
|
|
17106
|
+
"not_linked",
|
|
17107
|
+
"this machine holds no registry identity",
|
|
17108
|
+
credentials === null ? "Nothing was sent. Sign in with `memgineering login` \u2014 it links the registry identity at the same time, so one sign-in covers both." : "Nothing was sent. This machine is signed in to a brain, and the registry half of that sign-in is missing \u2014 which is what a credential file written before federation looks like. Run `memgineering login` again; it links the registry identity too."
|
|
17109
|
+
);
|
|
17110
|
+
}
|
|
17111
|
+
return registry;
|
|
17112
|
+
}
|
|
17113
|
+
var RACE_WAIT_MS = 2e3;
|
|
17114
|
+
var RACE_POLL_MS = 50;
|
|
17115
|
+
function lostRace(err) {
|
|
17116
|
+
return err instanceof KordisApiError && err.status === 401 && isRefreshRace({ error: { code: err.code, flags: err.flags } });
|
|
17117
|
+
}
|
|
17118
|
+
async function newerRegistry(sent) {
|
|
17119
|
+
const deadline = Date.now() + RACE_WAIT_MS;
|
|
17120
|
+
for (; ; ) {
|
|
17121
|
+
const registry = (await readCredentials())?.registry;
|
|
17122
|
+
if (registry !== void 0 && registry.refresh_token !== sent) return registry;
|
|
17123
|
+
if (Date.now() >= deadline) return null;
|
|
17124
|
+
await new Promise((resolve17) => setTimeout(resolve17, RACE_POLL_MS));
|
|
17125
|
+
}
|
|
17126
|
+
}
|
|
17127
|
+
async function refreshRegistrySession(stored, opts = {}) {
|
|
17128
|
+
const attempt = async (registry) => {
|
|
17129
|
+
const baseUrl = (opts.apiUrlOf ?? ((r) => registryApiUrl(r.api_url)))(registry);
|
|
17130
|
+
const anonymous = new KordisClient({
|
|
17131
|
+
baseUrl,
|
|
17132
|
+
userAgent: `memgineering/${VERSION}`,
|
|
17133
|
+
...opts.fetchImpl ? { fetch: opts.fetchImpl } : {},
|
|
17134
|
+
...opts.requestTimeoutMs === void 0 ? {} : { requestTimeoutMs: opts.requestTimeoutMs }
|
|
17135
|
+
});
|
|
17136
|
+
return { registry, baseUrl, tokens: await anonymous.refreshSession(registry.refresh_token) };
|
|
17137
|
+
};
|
|
17138
|
+
try {
|
|
17139
|
+
return await attempt(stored);
|
|
17140
|
+
} catch (err) {
|
|
17141
|
+
if (!lostRace(err)) throw err;
|
|
17142
|
+
const newer = await newerRegistry(stored.refresh_token);
|
|
17143
|
+
if (newer === null) throw err;
|
|
17144
|
+
return attempt(newer);
|
|
17145
|
+
}
|
|
17146
|
+
}
|
|
17147
|
+
function refusal(err) {
|
|
17148
|
+
if (lostRace(err)) {
|
|
17149
|
+
return memgError(
|
|
17150
|
+
"not_authenticated",
|
|
17151
|
+
err.message,
|
|
17152
|
+
"This machine's registry sign-in was refreshed by another request at the same moment, so this command could not use it. Run this command again."
|
|
17153
|
+
);
|
|
17154
|
+
}
|
|
17155
|
+
const busyOrUnreachable = err instanceof KordisNetworkError || err instanceof KordisApiError && (err.status === 429 || err.status >= 500);
|
|
17156
|
+
return (busyOrUnreachable ? adaptRegistryError(err) : null) ?? memgError(
|
|
17157
|
+
"not_linked",
|
|
17158
|
+
`the registry refused this machine's stored sign-in: ${err instanceof Error ? err.message : String(err)}`,
|
|
17159
|
+
"Nothing was sent. The link between this brain and your registry account has expired or been revoked. `memgineering login` re-links both."
|
|
17160
|
+
);
|
|
17161
|
+
}
|
|
17162
|
+
async function openRegistrySession(fetchImpl) {
|
|
17163
|
+
const stored = await requireRegistryCredentials();
|
|
17164
|
+
let refreshed;
|
|
17165
|
+
try {
|
|
17166
|
+
refreshed = await refreshRegistrySession(stored, fetchImpl ? { fetchImpl } : {});
|
|
17167
|
+
} catch (err) {
|
|
17168
|
+
throw refusal(err);
|
|
17169
|
+
}
|
|
17170
|
+
const { registry, baseUrl, tokens } = refreshed;
|
|
17171
|
+
const credentialsRotated = await persistRotatedRefresh(
|
|
17172
|
+
registry,
|
|
17173
|
+
tokens.refresh_token,
|
|
17174
|
+
tokens.session_id
|
|
17175
|
+
);
|
|
17176
|
+
const client = new KordisClient({
|
|
17177
|
+
baseUrl,
|
|
17178
|
+
userAgent: `memgineering/${VERSION}`,
|
|
17179
|
+
getAccessToken: () => tokens.access_token,
|
|
17180
|
+
...fetchImpl ? { fetch: fetchImpl } : {}
|
|
17181
|
+
});
|
|
17182
|
+
return { client, username: registry.username, apiUrl: baseUrl, credentialsRotated };
|
|
17183
|
+
}
|
|
17184
|
+
async function persistRotatedRefresh(sent, refreshToken, sessionId) {
|
|
17185
|
+
if (refreshToken === sent.refresh_token && sessionId === sent.session_id) return false;
|
|
17186
|
+
try {
|
|
17187
|
+
return await saveRotatedRegistry(sent.refresh_token, {
|
|
17188
|
+
refresh_token: refreshToken,
|
|
17189
|
+
session_id: sessionId
|
|
17190
|
+
});
|
|
17191
|
+
} catch {
|
|
17192
|
+
return false;
|
|
17193
|
+
}
|
|
17194
|
+
}
|
|
17195
|
+
|
|
17196
|
+
// src/commands/delete-account.ts
|
|
16898
17197
|
init_ui();
|
|
16899
|
-
|
|
16900
|
-
|
|
16901
|
-
function
|
|
16902
|
-
return new Command12("delete-
|
|
17198
|
+
var DELETE_ACCOUNT_PHRASE = "delete my account";
|
|
17199
|
+
var SUPPORT_ADDRESS = "support@memgineering.com";
|
|
17200
|
+
function deleteAccountCommand() {
|
|
17201
|
+
return new Command12("delete-account").description("delete your hosted brain account and your registry account, for good").option(
|
|
17202
|
+
"--confirm <phrase>",
|
|
17203
|
+
`the sentence "${DELETE_ACCOUNT_PHRASE}", typed exactly, authorising the deletion`
|
|
17204
|
+
).addHelpText(
|
|
16903
17205
|
"after",
|
|
16904
|
-
|
|
16905
|
-
|
|
16906
|
-
|
|
17206
|
+
`
|
|
17207
|
+
Irreversible, and server-side, in this order: the hosted brain account (every
|
|
17208
|
+
brain on it, every note, every token), then the registry account made by the
|
|
17209
|
+
same Google sign-in (profile, stars, follows, comment text, sign-ins; the account
|
|
17210
|
+
is renamed deleted-\u2026, and published packages stay at their existing addresses).
|
|
17211
|
+
Then this machine is signed out.
|
|
17212
|
+
Folders on this disk are never touched. Run this ONLY when the person has
|
|
17213
|
+
explicitly asked for their account to be deleted, and pass --confirm "${DELETE_ACCOUNT_PHRASE}".
|
|
17214
|
+
If a run stops halfway, run it again: it finishes the side that is left.
|
|
17215
|
+
\`memgineering delete-brain\` deletes one brain and keeps the account;
|
|
17216
|
+
\`memgineering logout\` only signs this machine out.`
|
|
17217
|
+
).action(async (opts) => {
|
|
17218
|
+
const confirmFlag = opts.confirm;
|
|
17219
|
+
if (confirmFlag !== void 0 && confirmFlag.startsWith("--")) {
|
|
16907
17220
|
throw memgError(
|
|
16908
17221
|
"invalid_input",
|
|
16909
|
-
|
|
16910
|
-
|
|
17222
|
+
`\`--confirm\` was given the flag \`${oneLine(confirmFlag, WIDTH.title)}\` as its sentence`,
|
|
17223
|
+
`Nothing was deleted. \`--confirm\` takes the sentence "${DELETE_ACCOUNT_PHRASE}", and the flag written after it was read as that sentence. Put the sentence, in quotes, immediately after \`--confirm\`.`
|
|
16911
17224
|
);
|
|
16912
17225
|
}
|
|
16913
|
-
const
|
|
16914
|
-
|
|
17226
|
+
const server = apiUrl();
|
|
17227
|
+
const stored = await readCredentials();
|
|
17228
|
+
const saved = await readAccountDeletionMarker();
|
|
17229
|
+
const marker = saved !== null && (stored === null || stored.account_id === saved.brain.account_id) ? saved : null;
|
|
17230
|
+
const brainDone = marker?.brain.deleted_at != null;
|
|
17231
|
+
const registryDone = marker?.registry.deleted_at != null;
|
|
17232
|
+
if (!brainDone) requireBrainSignIn(stored, server);
|
|
17233
|
+
if (!registryDone && stored?.registry === void 0) {
|
|
17234
|
+
throw noRegistrySignIn(marker);
|
|
17235
|
+
}
|
|
17236
|
+
if (confirmFlag !== void 0 && confirmFlag !== DELETE_ACCOUNT_PHRASE) {
|
|
16915
17237
|
throw memgError(
|
|
16916
17238
|
"invalid_input",
|
|
16917
|
-
|
|
16918
|
-
|
|
17239
|
+
"the confirmation is not the sentence this needs",
|
|
17240
|
+
`Nothing was deleted. The sentence is "${DELETE_ACCOUNT_PHRASE}" \u2014 exactly that, lower case, no punctuation. It deletes the hosted brain account with every brain and note on it, and the registry account; none of it comes back. Pass --confirm "${DELETE_ACCOUNT_PHRASE}" only if the person explicitly asked for their account to be deleted.`
|
|
16919
17241
|
);
|
|
16920
17242
|
}
|
|
16921
|
-
|
|
16922
|
-
|
|
16923
|
-
|
|
16924
|
-
|
|
16925
|
-
|
|
16926
|
-
|
|
16927
|
-
if (authorised === void 0) {
|
|
16928
|
-
printHuman(c.yellow("Cancelled \u2014 nothing was deleted."));
|
|
16929
|
-
return;
|
|
17243
|
+
if (confirmFlag === void 0 && !isInteractive()) {
|
|
17244
|
+
throw memgError(
|
|
17245
|
+
"invalid_input",
|
|
17246
|
+
"cannot ask for confirmation here \u2014 this is not an interactive terminal",
|
|
17247
|
+
`Nothing was deleted. Two ways forward: run this in a terminal the person can see and let them type "${DELETE_ACCOUNT_PHRASE}"; or, once they have explicitly asked for their account to be deleted, pass --confirm "${DELETE_ACCOUNT_PHRASE}". Deciding for them is the one thing this gate exists to prevent.`
|
|
17248
|
+
);
|
|
16930
17249
|
}
|
|
16931
|
-
const
|
|
16932
|
-
const
|
|
16933
|
-
const
|
|
16934
|
-
|
|
16935
|
-
|
|
16936
|
-
|
|
16937
|
-
|
|
16938
|
-
|
|
16939
|
-
|
|
16940
|
-
...cfg.brain.default === void 0 ? {} : { default: cfg.brain.default }
|
|
16941
|
-
}
|
|
16942
|
-
});
|
|
17250
|
+
const brain = brainDone ? null : await brainAccount(stored, marker);
|
|
17251
|
+
const registry = registryDone ? null : await registryAccount(stored?.registry, marker);
|
|
17252
|
+
const match = matchAccounts({ stored, marker, brain, registry });
|
|
17253
|
+
if (confirmFlag === void 0) {
|
|
17254
|
+
const typed = await retypeThePhrase({ brain, registry, marker, match });
|
|
17255
|
+
if (typed !== DELETE_ACCOUNT_PHRASE) {
|
|
17256
|
+
printHuman(c.yellow("Cancelled \u2014 nothing was deleted."));
|
|
17257
|
+
return;
|
|
17258
|
+
}
|
|
16943
17259
|
}
|
|
16944
|
-
const
|
|
17260
|
+
const record = marker ?? {
|
|
17261
|
+
version: 1,
|
|
17262
|
+
started_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
17263
|
+
matched_by: match.by === "earlier-run" ? match.matched_by : match.by,
|
|
17264
|
+
brain: {
|
|
17265
|
+
api_url: stored.api_url,
|
|
17266
|
+
account_id: brain.id,
|
|
17267
|
+
requested_at: null,
|
|
17268
|
+
deleted_at: null
|
|
17269
|
+
},
|
|
17270
|
+
registry: {
|
|
17271
|
+
api_url: registry.apiUrl,
|
|
17272
|
+
user_id: registry.id,
|
|
17273
|
+
username: registry.username,
|
|
17274
|
+
requested_at: null,
|
|
17275
|
+
deleted_at: null
|
|
17276
|
+
}
|
|
17277
|
+
};
|
|
17278
|
+
try {
|
|
17279
|
+
await saveAccountDeletionMarker(record);
|
|
17280
|
+
} catch (err) {
|
|
17281
|
+
throw memgError(
|
|
17282
|
+
"filesystem_error",
|
|
17283
|
+
`could not write ${accountDeletionMarkerPath()}`,
|
|
17284
|
+
`Nothing was deleted. This command records its progress there so a run that stops halfway can be finished, and it will not start without it. Free the disk or fix the permissions of that folder, then run this again. Underlying cause: ${err instanceof Error ? err.message : String(err)}`
|
|
17285
|
+
);
|
|
17286
|
+
}
|
|
17287
|
+
if (brain !== null) {
|
|
17288
|
+
record.brain.requested_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
17289
|
+
await saveBestEffort(record);
|
|
17290
|
+
await deleteBrainAccount(stored, registry);
|
|
17291
|
+
record.brain.deleted_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
17292
|
+
await saveBestEffort(record);
|
|
17293
|
+
}
|
|
17294
|
+
if (registry !== null) {
|
|
17295
|
+
record.registry.requested_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
17296
|
+
await saveBestEffort(record);
|
|
17297
|
+
await deleteRegistryAccount(registry);
|
|
17298
|
+
record.registry.deleted_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
17299
|
+
await saveBestEffort(record);
|
|
17300
|
+
}
|
|
17301
|
+
const pointerCleared = await signOutHere(record.brain.api_url);
|
|
17302
|
+
await clearAccountDeletionMarker();
|
|
17303
|
+
const hint = "Both accounts are gone and this machine is signed out. Signing in again with the same Google account creates a new, empty account. Folders on this disk were not touched.";
|
|
16945
17304
|
printDual({
|
|
16946
17305
|
json: {
|
|
16947
|
-
deleted:
|
|
16948
|
-
|
|
16949
|
-
|
|
16950
|
-
|
|
17306
|
+
deleted: true,
|
|
17307
|
+
brain: {
|
|
17308
|
+
status: brain === null ? "deleted-earlier" : "deleted",
|
|
17309
|
+
account_id: record.brain.account_id,
|
|
17310
|
+
api_url: record.brain.api_url
|
|
17311
|
+
},
|
|
17312
|
+
registry: {
|
|
17313
|
+
status: registry === null ? "deleted-earlier" : "deleted",
|
|
17314
|
+
user_id: record.registry.user_id,
|
|
17315
|
+
username: record.registry.username,
|
|
17316
|
+
api_url: record.registry.api_url
|
|
17317
|
+
},
|
|
17318
|
+
matched: match,
|
|
17319
|
+
credentials_cleared: true,
|
|
16951
17320
|
pointer_cleared: pointerCleared,
|
|
17321
|
+
local_folders: "untouched",
|
|
16952
17322
|
hint
|
|
16953
17323
|
},
|
|
16954
17324
|
human: () => {
|
|
17325
|
+
printHuman(c.green("\u2713 Account deleted."));
|
|
16955
17326
|
printHuman(
|
|
16956
|
-
c.
|
|
17327
|
+
c.gray(
|
|
17328
|
+
brain === null ? " brain the hosted account was deleted by an earlier run" : " brain the hosted account, every brain and note on it, and every token \u2014 gone"
|
|
17329
|
+
)
|
|
17330
|
+
);
|
|
17331
|
+
printHuman(
|
|
17332
|
+
c.gray(
|
|
17333
|
+
` registry ${oneLine(record.registry.username, WIDTH.title)} \u2014 ` + (registry === null ? "deleted by an earlier run" : "profile, stars, follows, comment text and sign-ins removed; renamed deleted-\u2026; published packages stay at their existing addresses")
|
|
17334
|
+
)
|
|
17335
|
+
);
|
|
17336
|
+
printHuman(c.gray(` matched ${matchLine(match)}`));
|
|
17337
|
+
printHuman(c.gray(" here signed out; this machine\u2019s credentials are removed"));
|
|
17338
|
+
if (pointerCleared) {
|
|
17339
|
+
printHuman(c.gray(" and it no longer points at a hosted brain"));
|
|
17340
|
+
}
|
|
17341
|
+
printHuman(c.gray(`
|
|
17342
|
+
${hint}`));
|
|
17343
|
+
}
|
|
17344
|
+
});
|
|
17345
|
+
});
|
|
17346
|
+
}
|
|
17347
|
+
function requireBrainSignIn(stored, server) {
|
|
17348
|
+
if (stored !== null && stored.api_url === server) return;
|
|
17349
|
+
if (stored !== null) {
|
|
17350
|
+
throw memgError(
|
|
17351
|
+
"not_signed_in",
|
|
17352
|
+
`this machine is signed in to ${oneLine(stored.api_url, WIDTH.path)}, not ${oneLine(server, WIDTH.path)}`,
|
|
17353
|
+
"Nothing was deleted. The account to delete is on the server this machine signed in to. If MEMGINEERING_API_URL points somewhere else, unset it and run this again."
|
|
17354
|
+
);
|
|
17355
|
+
}
|
|
17356
|
+
throw memgError(
|
|
17357
|
+
"not_signed_in",
|
|
17358
|
+
"this machine is not signed in to a memgineering account",
|
|
17359
|
+
`Nothing was deleted, and there may be nothing to delete. A brain kept in a folder on this machine has no account \u2014 it is the person\u2019s own files, and this command never touches them; deleting the folder deletes it (\`memgineering unlink <folder>\` first makes this tool forget it). To delete a hosted account, sign in to it first \u2014 \`memgineering login --emit-only\`, show the person the code it prints, and run this again once they approve. Without a sign-in, mail ${SUPPORT_ADDRESS} from the Google address of the account.`
|
|
17360
|
+
);
|
|
17361
|
+
}
|
|
17362
|
+
function noRegistrySignIn(marker) {
|
|
17363
|
+
if (marker !== null) {
|
|
17364
|
+
return memgError(
|
|
17365
|
+
"not_linked",
|
|
17366
|
+
"the brain account is already deleted, and this machine holds no registry sign-in to finish with",
|
|
17367
|
+
`The hosted brain account was deleted by an earlier run of this command and cannot be undone. The registry account \`${oneLine(marker.registry.username, WIDTH.title)}\` still needs deleting, and that needs this machine's registry sign-in, which is gone. Mail ${SUPPORT_ADDRESS} from the Google address of the account, naming \`${oneLine(marker.registry.username, WIDTH.title)}\`, and it is deleted by hand.`
|
|
17368
|
+
);
|
|
17369
|
+
}
|
|
17370
|
+
return memgError(
|
|
17371
|
+
"not_linked",
|
|
17372
|
+
"this machine is signed in to a brain account but holds no registry sign-in",
|
|
17373
|
+
`Nothing was deleted. This command deletes the brain account and the registry account together, and will not delete one alone. The registry half of the sign-in is missing \u2014 which is what a sign-in made before the two were linked looks like. Run \`memgineering logout\` and then \`memgineering login\` (it links the registry account too), then run this again. Or mail ${SUPPORT_ADDRESS} from the Google address of the account.`
|
|
17374
|
+
);
|
|
17375
|
+
}
|
|
17376
|
+
async function brainAccount(stored, marker) {
|
|
17377
|
+
let body;
|
|
17378
|
+
try {
|
|
17379
|
+
body = (await apiRequest({
|
|
17380
|
+
method: "GET",
|
|
17381
|
+
path: "/v1/me",
|
|
17382
|
+
token: stored.token,
|
|
17383
|
+
baseUrl: stored.api_url
|
|
17384
|
+
})).body;
|
|
17385
|
+
} catch (err) {
|
|
17386
|
+
if (!(err instanceof MemgError)) throw err;
|
|
17387
|
+
if (err.code === "not_authenticated" && marker?.brain.requested_at) {
|
|
17388
|
+
throw memgError(
|
|
17389
|
+
"not_authenticated",
|
|
17390
|
+
"this machine\u2019s brain sign-in no longer works, after an earlier run asked for the account to be deleted",
|
|
17391
|
+
`Nothing more was deleted. An earlier run of this command asked the brain server to delete this account at ${marker.brain.requested_at} and did not hear the answer. A sign-in that stops working is what a deleted account looks like, and also what a revoked sign-in looks like, so this command will not guess and delete the registry account on that basis. Mail ${SUPPORT_ADDRESS} from the Google address of the account, naming registry account \`${oneLine(marker.registry.username, WIDTH.title)}\`, and both are finished by hand.`
|
|
17392
|
+
);
|
|
17393
|
+
}
|
|
17394
|
+
if (err.code === "not_authenticated") {
|
|
17395
|
+
const name = stored.registry === void 0 ? "" : ` \`${oneLine(stored.registry.username, WIDTH.title)}\``;
|
|
17396
|
+
const file = await accountDeletionMarkerExists() ? ` A progress file from an earlier run is on disk (${accountDeletionMarkerPath()}) but could not be used for this account.` : "";
|
|
17397
|
+
throw memgError(
|
|
17398
|
+
"not_authenticated",
|
|
17399
|
+
"the brain server no longer accepts this machine\u2019s sign-in",
|
|
17400
|
+
`This run deleted nothing. Either the sign-in was revoked or has expired \u2014 then \`memgineering login --emit-only\`, show the person the code it prints, and run this again once they approve \u2014 or this account was already deleted by an earlier run of this command whose progress file is gone.${file} If that may be so, the registry account${name} may still exist: mail ${SUPPORT_ADDRESS} from the Google address of the account${name === "" ? "" : `, naming${name}`}.`
|
|
17401
|
+
);
|
|
17402
|
+
}
|
|
17403
|
+
if (err.code === "server_unreachable") {
|
|
17404
|
+
throw memgError(
|
|
17405
|
+
"server_unreachable",
|
|
17406
|
+
err.message,
|
|
17407
|
+
`This run deleted nothing \u2014 neither the brain account nor the registry account. The brain server could not be reached: check the connection, or MEMGINEERING_API_URL if the brain server is somewhere else, then run this again.`
|
|
17408
|
+
);
|
|
17409
|
+
}
|
|
17410
|
+
throw new MemgError({
|
|
17411
|
+
code: err.code,
|
|
17412
|
+
message: err.message,
|
|
17413
|
+
hint: `This run deleted nothing \u2014 neither the brain account nor the registry account. ${err.hint}`
|
|
17414
|
+
});
|
|
17415
|
+
}
|
|
17416
|
+
const account = body?.account;
|
|
17417
|
+
if (!account || typeof account.id !== "string") {
|
|
17418
|
+
throw memgError(
|
|
17419
|
+
"server_refused",
|
|
17420
|
+
`${stored.api_url} answered /v1/me without an account`,
|
|
17421
|
+
"Nothing was deleted. This is not an answer a memgineering brain server gives. If MEMGINEERING_API_URL points at something else, unset it and run this again."
|
|
17422
|
+
);
|
|
17423
|
+
}
|
|
17424
|
+
if (account.id !== stored.account_id) {
|
|
17425
|
+
throw mismatch(
|
|
17426
|
+
`this machine's credentials name brain account ${oneLine(stored.account_id, WIDTH.handle)}, and its token belongs to ${oneLine(account.id, WIDTH.handle)}`
|
|
17427
|
+
);
|
|
17428
|
+
}
|
|
17429
|
+
return {
|
|
17430
|
+
id: account.id,
|
|
17431
|
+
email: typeof account.email === "string" && account.email !== "" ? account.email : null,
|
|
17432
|
+
display_name: typeof account.display_name === "string" ? account.display_name : null
|
|
17433
|
+
};
|
|
17434
|
+
}
|
|
17435
|
+
async function registryAccount(snapshot, marker) {
|
|
17436
|
+
let session;
|
|
17437
|
+
try {
|
|
17438
|
+
session = await openRegistrySession();
|
|
17439
|
+
} catch (err) {
|
|
17440
|
+
if (err instanceof MemgError && err.code === "not_linked") {
|
|
17441
|
+
throw memgError(
|
|
17442
|
+
"not_linked",
|
|
17443
|
+
err.message,
|
|
17444
|
+
marker !== null && marker.brain.deleted_at !== null ? `The hosted brain account was deleted by an earlier run and cannot be undone. The registry account \`${oneLine(marker.registry.username, WIDTH.title)}\` still needs deleting, and this machine's registry sign-in no longer works \u2014 if an earlier run's registry request reached the server, the account may already be gone, which ends sign-ins the same way. Mail ${SUPPORT_ADDRESS} from the Google address of the account, naming \`${oneLine(marker.registry.username, WIDTH.title)}\`, and it is finished by hand.` : `Nothing was deleted. The registry sign-in on this machine has expired or been revoked. Run \`memgineering logout\` and then \`memgineering login\` (it links the registry account again), then run this again. Or mail ${SUPPORT_ADDRESS} from the Google address of the account.`
|
|
17445
|
+
);
|
|
17446
|
+
}
|
|
17447
|
+
throw withNothingDeleted(err, marker);
|
|
17448
|
+
}
|
|
17449
|
+
let exported;
|
|
17450
|
+
try {
|
|
17451
|
+
exported = await session.client.exportMe();
|
|
17452
|
+
} catch (err) {
|
|
17453
|
+
throw withNothingDeleted(err, marker);
|
|
17454
|
+
}
|
|
17455
|
+
const user = exported?.user;
|
|
17456
|
+
if (!user || typeof user.id !== "string" || typeof user.username !== "string") {
|
|
17457
|
+
throw memgError(
|
|
17458
|
+
"server_refused",
|
|
17459
|
+
`${session.apiUrl} answered /api/me/export without an account`,
|
|
17460
|
+
"Nothing was deleted. This is not an answer the registry gives. If KORDIS_API_URL points at something else, unset it and run this again."
|
|
17461
|
+
);
|
|
17462
|
+
}
|
|
17463
|
+
if (snapshot.user_id !== user.id) {
|
|
17464
|
+
throw mismatch(
|
|
17465
|
+
`this run began with a registry sign-in for registry account ${oneLine(snapshot.user_id, WIDTH.handle)}, and the registry answered for ${oneLine(user.id, WIDTH.handle)}`
|
|
17466
|
+
);
|
|
17467
|
+
}
|
|
17468
|
+
return {
|
|
17469
|
+
client: session.client,
|
|
17470
|
+
apiUrl: session.apiUrl,
|
|
17471
|
+
id: user.id,
|
|
17472
|
+
username: user.username,
|
|
17473
|
+
email: typeof user.email === "string" && user.email !== "" ? user.email : null,
|
|
17474
|
+
linkedAt: snapshot.linked_at
|
|
17475
|
+
};
|
|
17476
|
+
}
|
|
17477
|
+
function withNothingDeleted(err, marker) {
|
|
17478
|
+
const adapted = err instanceof MemgError ? err : adaptRegistryError(err);
|
|
17479
|
+
if (adapted === null) return err;
|
|
17480
|
+
const prefix = marker !== null && marker.brain.deleted_at !== null ? "Nothing more was deleted: the brain account is already gone, and the registry account is not deleted yet \u2014 run this again once the registry answers." : "Nothing was deleted \u2014 neither the brain account nor the registry account.";
|
|
17481
|
+
return new MemgError({
|
|
17482
|
+
code: adapted.code,
|
|
17483
|
+
message: adapted.message,
|
|
17484
|
+
hint: `${prefix} ${adapted.hint}`
|
|
17485
|
+
});
|
|
17486
|
+
}
|
|
17487
|
+
function matchAccounts(args) {
|
|
17488
|
+
const { marker, brain, registry } = args;
|
|
17489
|
+
if (marker !== null) {
|
|
17490
|
+
if (registry !== null && registry.id !== marker.registry.user_id) {
|
|
17491
|
+
throw mismatch(
|
|
17492
|
+
`an earlier run matched registry account \`${oneLine(marker.registry.username, WIDTH.title)}\`, and this machine's registry sign-in is now for \`${oneLine(registry.username, WIDTH.title)}\``
|
|
17493
|
+
);
|
|
17494
|
+
}
|
|
17495
|
+
return { by: "earlier-run", matched_by: marker.matched_by };
|
|
17496
|
+
}
|
|
17497
|
+
const b = brain;
|
|
17498
|
+
const r = registry;
|
|
17499
|
+
if (b.email !== null && r.email !== null) {
|
|
17500
|
+
if (normaliseEmail(b.email) !== normaliseEmail(r.email)) {
|
|
17501
|
+
throw mismatch(
|
|
17502
|
+
`the brain account's email is ${oneLine(b.email, WIDTH.title)} and the registry account's is ${oneLine(r.email, WIDTH.title)}`
|
|
17503
|
+
);
|
|
17504
|
+
}
|
|
17505
|
+
return { by: "email", email: b.email };
|
|
17506
|
+
}
|
|
17507
|
+
return { by: "federation", linked_at: r.linkedAt };
|
|
17508
|
+
}
|
|
17509
|
+
function normaliseEmail(email) {
|
|
17510
|
+
return email.trim().toLowerCase();
|
|
17511
|
+
}
|
|
17512
|
+
function mismatch(detail) {
|
|
17513
|
+
return memgError(
|
|
17514
|
+
"account_mismatch",
|
|
17515
|
+
`the brain account and the registry account do not look like the same person: ${detail}`,
|
|
17516
|
+
`Nothing was deleted. This command deletes both accounts together and only when they are one person's. Run \`memgineering logout\` and then \`memgineering login\` with the Google account whose accounts should be deleted, then run this again. If they really are one person's, mail ${SUPPORT_ADDRESS} from that Google address.`
|
|
17517
|
+
);
|
|
17518
|
+
}
|
|
17519
|
+
function matchLine(match) {
|
|
17520
|
+
switch (match.by) {
|
|
17521
|
+
case "email":
|
|
17522
|
+
return `same person \u2014 both accounts carry ${oneLine(match.email, WIDTH.title)}`;
|
|
17523
|
+
case "federation":
|
|
17524
|
+
return `same person \u2014 one of the two accounts has no email on record, so the match is this machine's registry sign-in, which the brain sign-in issued for the same Google account (linked ${oneLine(match.linked_at, WIDTH.title)})`;
|
|
17525
|
+
case "earlier-run":
|
|
17526
|
+
return `same person \u2014 matched by ${match.matched_by} before an earlier run deleted anything`;
|
|
17527
|
+
}
|
|
17528
|
+
}
|
|
17529
|
+
async function retypeThePhrase(args) {
|
|
17530
|
+
const { brain, registry, marker, match } = args;
|
|
17531
|
+
printHuman(c.bold("\nDelete your account?"));
|
|
17532
|
+
if (brain !== null) {
|
|
17533
|
+
const who = brain.email ?? brain.display_name ?? brain.id;
|
|
17534
|
+
printHuman(
|
|
17535
|
+
c.gray(
|
|
17536
|
+
` brain ${oneLine(who, WIDTH.title)} \u2014 every brain on it, every note, every token`
|
|
17537
|
+
)
|
|
17538
|
+
);
|
|
17539
|
+
} else {
|
|
17540
|
+
printHuman(c.gray(" brain already deleted by an earlier run"));
|
|
17541
|
+
}
|
|
17542
|
+
const username = registry?.username ?? marker?.registry.username ?? "";
|
|
17543
|
+
printHuman(
|
|
17544
|
+
c.gray(
|
|
17545
|
+
registry !== null ? ` registry ${oneLine(username, WIDTH.title)} \u2014 profile, stars, follows, comment text, sign-ins` : ` registry ${oneLine(username, WIDTH.title)} \u2014 already deleted by an earlier run`
|
|
17546
|
+
)
|
|
17547
|
+
);
|
|
17548
|
+
printHuman(c.gray(` matched ${matchLine(match)}`));
|
|
17549
|
+
printHuman(
|
|
17550
|
+
c.yellow(
|
|
17551
|
+
"\n None of this comes back. The registry account is renamed deleted-\u2026; published\n packages stay at their existing addresses. Folders on this disk are not\n touched. Signing in again later makes a new, empty account."
|
|
17552
|
+
)
|
|
17553
|
+
);
|
|
17554
|
+
const { typed } = await prompts({
|
|
17555
|
+
type: "text",
|
|
17556
|
+
name: "typed",
|
|
17557
|
+
message: `Type "${DELETE_ACCOUNT_PHRASE}" to delete both accounts`
|
|
17558
|
+
});
|
|
17559
|
+
return typed;
|
|
17560
|
+
}
|
|
17561
|
+
async function deleteBrainAccount(stored, registry) {
|
|
17562
|
+
try {
|
|
17563
|
+
await apiRequest({
|
|
17564
|
+
method: "DELETE",
|
|
17565
|
+
path: "/v1/account",
|
|
17566
|
+
token: stored.token,
|
|
17567
|
+
baseUrl: stored.api_url,
|
|
17568
|
+
body: { confirm: DELETE_ACCOUNT_PHRASE }
|
|
17569
|
+
});
|
|
17570
|
+
return;
|
|
17571
|
+
} catch (err) {
|
|
17572
|
+
if (!(err instanceof MemgError)) throw err;
|
|
17573
|
+
if (err.code === "server_unreachable" && await brainTokenIsDead(stored)) {
|
|
17574
|
+
return;
|
|
17575
|
+
}
|
|
17576
|
+
const registryLine = registry === null ? "" : ` The registry account \`${oneLine(registry.username, WIDTH.title)}\` was not touched.`;
|
|
17577
|
+
if (err.code === "server_unreachable") {
|
|
17578
|
+
throw new MemgError({
|
|
17579
|
+
code: err.code,
|
|
17580
|
+
message: err.message,
|
|
17581
|
+
hint: `The brain server did not confirm the deletion, and the request may have reached it.${registryLine} Check the connection, then run this command again: it asks the server first. If it then says this machine's brain sign-in no longer works, the brain account was deleted \u2014 it will not delete the registry account on that basis; it says how to finish by mail.`
|
|
17582
|
+
});
|
|
17583
|
+
}
|
|
17584
|
+
throw new MemgError({
|
|
17585
|
+
code: err.code,
|
|
17586
|
+
message: err.message,
|
|
17587
|
+
hint: `The brain account was not confirmed deleted.${registryLine} ${err.hint} Then run this again.`
|
|
17588
|
+
});
|
|
17589
|
+
}
|
|
17590
|
+
}
|
|
17591
|
+
async function brainTokenIsDead(stored) {
|
|
17592
|
+
try {
|
|
17593
|
+
await apiRequest({
|
|
17594
|
+
method: "GET",
|
|
17595
|
+
path: "/v1/me",
|
|
17596
|
+
token: stored.token,
|
|
17597
|
+
baseUrl: stored.api_url
|
|
17598
|
+
});
|
|
17599
|
+
return false;
|
|
17600
|
+
} catch (err) {
|
|
17601
|
+
return err instanceof MemgError && err.code === "not_authenticated";
|
|
17602
|
+
}
|
|
17603
|
+
}
|
|
17604
|
+
async function deleteRegistryAccount(registry) {
|
|
17605
|
+
try {
|
|
17606
|
+
await registry.client.deleteMe({ confirm_username: registry.username });
|
|
17607
|
+
return;
|
|
17608
|
+
} catch (err) {
|
|
17609
|
+
if (err instanceof KordisNetworkError && await registrySessionIsDead(registry)) {
|
|
17610
|
+
return;
|
|
17611
|
+
}
|
|
17612
|
+
const adapted = adaptRegistryError(err) ?? memgError(
|
|
17613
|
+
"server_refused",
|
|
17614
|
+
err instanceof Error ? err.message : String(err),
|
|
17615
|
+
"The registry refused the request without saying why."
|
|
17616
|
+
);
|
|
17617
|
+
const name = oneLine(registry.username, WIDTH.title);
|
|
17618
|
+
const unconfirmed = err instanceof KordisNetworkError;
|
|
17619
|
+
const said = err instanceof KordisApiError && err.hint !== void 0 && err.hint !== "" ? ` The registry said: ${err.hint}` : "";
|
|
17620
|
+
throw memgError(
|
|
17621
|
+
"account_partly_deleted",
|
|
17622
|
+
unconfirmed ? `the hosted brain account is deleted; the registry did not confirm deleting \`${name}\` \u2014 ${adapted.code}: ${oneLine(adapted.message, WIDTH.text)}` : `the hosted brain account is deleted; the registry account \`${name}\` is not \u2014 ${adapted.code}: ${oneLine(adapted.message, WIDTH.text)}`,
|
|
17623
|
+
`The brain half is done and cannot be undone. ${unconfirmed ? `The registry did not answer, so it is not known whether \`${name}\` was deleted.` : `The registry account \`${name}\` still exists.`}${said}
|
|
17624
|
+
Run \`memgineering delete-account --confirm "${DELETE_ACCOUNT_PHRASE}"\` again: it skips the brain and deletes only the registry account${unconfirmed ? " if it is still there; if this machine's registry sign-in then no longer works, the account is gone or the sign-in was revoked, and it says how to finish by mail" : ""}. If it keeps failing, mail ${SUPPORT_ADDRESS} from the Google address of the account, naming \`${name}\`.`
|
|
17625
|
+
);
|
|
17626
|
+
}
|
|
17627
|
+
}
|
|
17628
|
+
async function registrySessionIsDead(registry) {
|
|
17629
|
+
try {
|
|
17630
|
+
await registry.client.exportMe();
|
|
17631
|
+
return false;
|
|
17632
|
+
} catch (err) {
|
|
17633
|
+
return err instanceof KordisApiError && err.status === 401;
|
|
17634
|
+
}
|
|
17635
|
+
}
|
|
17636
|
+
async function signOutHere(brainApiUrl) {
|
|
17637
|
+
await clearPendingLogin();
|
|
17638
|
+
await clearSetupFollowUps();
|
|
17639
|
+
await clearCredentials();
|
|
17640
|
+
const cfg = await loadConfig();
|
|
17641
|
+
const pointer = cfg.brain.cloud;
|
|
17642
|
+
if (pointer === void 0 || pointer.api_url !== brainApiUrl) return false;
|
|
17643
|
+
await saveConfig({
|
|
17644
|
+
...cfg,
|
|
17645
|
+
brain: {
|
|
17646
|
+
brains: cfg.brain.brains,
|
|
17647
|
+
...cfg.brain.default === void 0 ? {} : { default: cfg.brain.default }
|
|
17648
|
+
}
|
|
17649
|
+
});
|
|
17650
|
+
return true;
|
|
17651
|
+
}
|
|
17652
|
+
async function saveBestEffort(marker) {
|
|
17653
|
+
try {
|
|
17654
|
+
await saveAccountDeletionMarker(marker);
|
|
17655
|
+
} catch {
|
|
17656
|
+
}
|
|
17657
|
+
}
|
|
17658
|
+
|
|
17659
|
+
// src/commands/delete-brain.ts
|
|
17660
|
+
init_errors();
|
|
17661
|
+
init_api_client();
|
|
17662
|
+
init_cloud_brain();
|
|
17663
|
+
init_config();
|
|
17664
|
+
init_ui();
|
|
17665
|
+
import { Command as Command13 } from "commander";
|
|
17666
|
+
import prompts2 from "prompts";
|
|
17667
|
+
function deleteBrainCommand() {
|
|
17668
|
+
return new Command13("delete-brain").description("delete a hosted brain and everything in it, for good").argument("<name-or-id>", "which hosted brain to delete, by its name or id").option("--confirm <exact-name>", "the brain\u2019s name, typed exactly, authorising the deletion").addHelpText(
|
|
17669
|
+
"after",
|
|
17670
|
+
"\nIrreversible, and server-side: the brain, every note in it, its ledger and its\nmeasurements. `memgineering unlink --brain` is the other thing \u2014 it only stops\nthis machine reading a brain and deletes nothing. Run this ONLY when the person\nhas explicitly asked for this brain to be deleted, and pass --confirm with the\nexact name. A wrongly-named brain is a rename, not a delete."
|
|
17671
|
+
).action(async (named, opts) => {
|
|
17672
|
+
if (named.startsWith("--")) {
|
|
17673
|
+
throw memgError(
|
|
17674
|
+
"invalid_input",
|
|
17675
|
+
`\`delete-brain\` was given the flag \`${oneLine(named, 32)}\` as a brain name`,
|
|
17676
|
+
'Nothing was deleted. The first argument is WHICH BRAIN to delete, and the flag written there was read as its name. Put the name or id first \u2014 `memgineering delete-brain <name-or-id> --confirm "<name>"`. If a brain really is called that, pass its id instead; `memgineering brains` lists them.'
|
|
17677
|
+
);
|
|
17678
|
+
}
|
|
17679
|
+
const confirmFlag = opts.confirm;
|
|
17680
|
+
if (confirmFlag !== void 0 && confirmFlag.startsWith("--")) {
|
|
17681
|
+
throw memgError(
|
|
17682
|
+
"invalid_input",
|
|
17683
|
+
`\`--confirm\` was given the flag \`${oneLine(confirmFlag, WIDTH.title)}\` as a name`,
|
|
17684
|
+
"Nothing was deleted. `--confirm` takes the brain\u2019s own name, typed exactly, and the flag written after it was read as that name. Put the name immediately after `--confirm`, then pass the other flag separately."
|
|
17685
|
+
);
|
|
17686
|
+
}
|
|
17687
|
+
const server = apiUrl();
|
|
17688
|
+
const token = await tokenFor2(server);
|
|
17689
|
+
const brains = await listCloudBrains(token, server);
|
|
17690
|
+
const target = findCloudBrain(brains, named);
|
|
17691
|
+
if (!target) throw noSuchBrain2(named, brains);
|
|
17692
|
+
const authorised = await authorise(target, confirmFlag);
|
|
17693
|
+
if (authorised === void 0) {
|
|
17694
|
+
printHuman(c.yellow("Cancelled \u2014 nothing was deleted."));
|
|
17695
|
+
return;
|
|
17696
|
+
}
|
|
17697
|
+
const deleted = await deleteCloudBrain({ token, server, id: target.id, authorised });
|
|
17698
|
+
const cfg = await loadConfig();
|
|
17699
|
+
const pointer = cfg.brain.cloud;
|
|
17700
|
+
const pointerCleared = pointer !== void 0 && pointer.id === deleted.deleted && pointer.api_url === server;
|
|
17701
|
+
if (pointerCleared) {
|
|
17702
|
+
await saveConfig({
|
|
17703
|
+
...cfg,
|
|
17704
|
+
brain: {
|
|
17705
|
+
brains: cfg.brain.brains,
|
|
17706
|
+
...cfg.brain.default === void 0 ? {} : { default: cfg.brain.default }
|
|
17707
|
+
}
|
|
17708
|
+
});
|
|
17709
|
+
}
|
|
17710
|
+
const hint = deleted.hint ?? "The brain, its notes and its ledger are gone. `memgineering brains` lists what is left.";
|
|
17711
|
+
printDual({
|
|
17712
|
+
json: {
|
|
17713
|
+
deleted: { id: deleted.deleted, name: deleted.name },
|
|
17714
|
+
/** Null when the server said nothing — which is not the same as zero. */
|
|
17715
|
+
notes_deleted: deleted.notes_deleted ?? null,
|
|
17716
|
+
/** Whether this machine had been reading it, and has now stopped. */
|
|
17717
|
+
pointer_cleared: pointerCleared,
|
|
17718
|
+
hint
|
|
17719
|
+
},
|
|
17720
|
+
human: () => {
|
|
17721
|
+
printHuman(
|
|
17722
|
+
c.green(`\u2713 deleted \u201C${oneLine(deleted.name, WIDTH.title)}\u201D`) + c.gray(` (${oneLine(deleted.deleted, WIDTH.handle)})`)
|
|
16957
17723
|
);
|
|
16958
17724
|
printHuman(
|
|
16959
17725
|
c.gray(
|
|
@@ -17036,7 +17802,7 @@ Delete \u201C${oneLine(target.name, WIDTH.title)}\u201D?`));
|
|
|
17036
17802
|
"\n `memgineering unlink --brain` is the other thing: it stops this machine\n reading a brain and deletes nothing. A wrongly-named brain is a rename."
|
|
17037
17803
|
)
|
|
17038
17804
|
);
|
|
17039
|
-
const { typed } = await
|
|
17805
|
+
const { typed } = await prompts2({
|
|
17040
17806
|
type: "text",
|
|
17041
17807
|
name: "typed",
|
|
17042
17808
|
message: "Type the brain\u2019s name exactly to delete it"
|
|
@@ -17070,21 +17836,21 @@ async function deleteCloudBrain(args) {
|
|
|
17070
17836
|
|
|
17071
17837
|
// src/commands/curation.ts
|
|
17072
17838
|
init_src();
|
|
17073
|
-
import { stat as
|
|
17839
|
+
import { stat as stat6 } from "fs/promises";
|
|
17074
17840
|
import { resolve as resolve8 } from "path";
|
|
17075
|
-
import { Command as
|
|
17841
|
+
import { Command as Command15 } from "commander";
|
|
17076
17842
|
|
|
17077
17843
|
// ../../packages/storage-adapter/src/local-file/ignore-file.ts
|
|
17078
17844
|
init_atomic();
|
|
17079
17845
|
init_exclude();
|
|
17080
17846
|
init_walk();
|
|
17081
17847
|
import { createHash as createHash6 } from "crypto";
|
|
17082
|
-
import { readFile as
|
|
17848
|
+
import { readFile as readFile19 } from "fs/promises";
|
|
17083
17849
|
var FILE = ".memgignore";
|
|
17084
17850
|
var hashOf = (content) => createHash6("sha256").update(Buffer.from(content, "utf8")).digest("hex");
|
|
17085
17851
|
async function readIgnoreFileState(root) {
|
|
17086
17852
|
try {
|
|
17087
|
-
const content = await
|
|
17853
|
+
const content = await readFile19(resolveInside(root, FILE), "utf8");
|
|
17088
17854
|
return { content, exists: true, hash: hashOf(content) };
|
|
17089
17855
|
} catch (err) {
|
|
17090
17856
|
if (err?.code === "ENOENT") {
|
|
@@ -17174,7 +17940,7 @@ init_vault();
|
|
|
17174
17940
|
init_ui();
|
|
17175
17941
|
init_link();
|
|
17176
17942
|
function lifecycleCommand(action) {
|
|
17177
|
-
return new
|
|
17943
|
+
return new Command15(action).description(
|
|
17178
17944
|
action === "retire" ? "mark a memory as no longer current \u2014 the note itself is not changed" : "mark a retired memory as current again"
|
|
17179
17945
|
).argument("<ref>", "handle, id, path, or exact title").option("--reason <text>", "why \u2014 kept in the ledger").option("--vault <path>", "which brain the memory is in").option("--local", "use the brain on this machine, even when signed in to a hosted one").action(async (ref, opts) => {
|
|
17180
17946
|
const where = await resolveTarget({
|
|
@@ -17261,7 +18027,7 @@ async function lifecycleLocal(vault, action, ref, reason) {
|
|
|
17261
18027
|
return { entry, record };
|
|
17262
18028
|
}
|
|
17263
18029
|
function ignoreCommand(mode) {
|
|
17264
|
-
return new
|
|
18030
|
+
return new Command15(mode).description(
|
|
17265
18031
|
mode === "exclude" ? "stop reading a note entirely \u2014 the note itself is not changed" : "read a note again after excluding it"
|
|
17266
18032
|
).argument("<path>", "path inside the brain, e.g. decisions/launch-date.md").option("--reason <text>", "why \u2014 kept in the ledger").option("--vault <path>", "which brain the note is in").option("--local", "use the brain on this machine, even when signed in to a hosted one").action(async (path, opts) => {
|
|
17267
18033
|
const rationale = sanitizeRationale(opts.reason);
|
|
@@ -17386,7 +18152,7 @@ async function mustMatchAFile(root, adapter, path) {
|
|
|
17386
18152
|
const wanted = path.normalize("NFC").replace(/^\/+/, "");
|
|
17387
18153
|
const absolute = resolve8(root, wanted);
|
|
17388
18154
|
if (isInside(absolute, root)) {
|
|
17389
|
-
const found = await
|
|
18155
|
+
const found = await stat6(absolute).catch(() => null);
|
|
17390
18156
|
if (found?.isFile()) return wanted;
|
|
17391
18157
|
}
|
|
17392
18158
|
const hits = sameBasename(await adapter.list(""), path);
|
|
@@ -17403,14 +18169,14 @@ var unexcludeCommand = () => ignoreCommand("unexclude");
|
|
|
17403
18169
|
|
|
17404
18170
|
// src/commands/scope-validity.ts
|
|
17405
18171
|
init_src();
|
|
17406
|
-
import { Command as
|
|
18172
|
+
import { Command as Command16 } from "commander";
|
|
17407
18173
|
init_errors();
|
|
17408
18174
|
init_index_build();
|
|
17409
18175
|
init_cloud_brain();
|
|
17410
18176
|
init_vault();
|
|
17411
18177
|
init_ui();
|
|
17412
18178
|
function rescopeCommand() {
|
|
17413
|
-
return new
|
|
18179
|
+
return new Command16("rescope").description("change which project a memory binds in \u2014 nothing it says changes").argument("<ref>", "handle, id, path, or exact title").option("--scope <name>", "the project it binds in from now on").option("--global", "it binds everywhere \u2014 say this rather than leaving the scope off").option("--reason <text>", "why \u2014 kept in the ledger").option("--vault <path>", "which brain the memory is in").option("--local", "use the brain on this machine, even when signed in to a hosted one").action(
|
|
17414
18180
|
async (ref, opts) => {
|
|
17415
18181
|
const scope = scopeAskedFor(opts);
|
|
17416
18182
|
const where = await resolveTarget({
|
|
@@ -17446,7 +18212,7 @@ Undo: \`${undoHint(record.op_id, opts)}\``));
|
|
|
17446
18212
|
);
|
|
17447
18213
|
}
|
|
17448
18214
|
function expireCommand() {
|
|
17449
|
-
return new
|
|
18215
|
+
return new Command16("expire").description("give a memory an end date \u2014 it is NOT retired, and recall still returns it").argument("<ref>", "handle, id, path, or exact title").requiredOption("--until <date>", "the day it stops being current, e.g. 2026-10-31").option("--reason <text>", "why \u2014 kept in the ledger").option("--vault <path>", "which brain the memory is in").option("--local", "use the brain on this machine, even when signed in to a hosted one").action(
|
|
17450
18216
|
async (ref, opts) => {
|
|
17451
18217
|
const where = await resolveTarget({
|
|
17452
18218
|
...opts.local === void 0 ? {} : { local: opts.local },
|
|
@@ -17665,13 +18431,13 @@ Undo: \`memgineering undo ${result.op_id}\``));
|
|
|
17665
18431
|
|
|
17666
18432
|
// src/commands/evidence.ts
|
|
17667
18433
|
init_src();
|
|
17668
|
-
import { Command as
|
|
18434
|
+
import { Command as Command17 } from "commander";
|
|
17669
18435
|
init_index_build();
|
|
17670
18436
|
init_cloud_brain();
|
|
17671
18437
|
init_vault();
|
|
17672
18438
|
init_ui();
|
|
17673
18439
|
function evidenceCommand() {
|
|
17674
|
-
return new
|
|
18440
|
+
return new Command17("evidence").description("how much a memory has been used, and why it last changed").argument("<ref>", "handle, id, path, or exact title").option("--vault <path>", "which brain to read").option("--local", "read the brain on this machine, even when signed in to a hosted one").option(
|
|
17675
18441
|
"--brain <name>",
|
|
17676
18442
|
"read from one existing hosted brain by name or id, without changing the pointer"
|
|
17677
18443
|
).action(async (ref, opts) => {
|
|
@@ -17960,9 +18726,9 @@ function ago(iso, now) {
|
|
|
17960
18726
|
init_brand();
|
|
17961
18727
|
init_config();
|
|
17962
18728
|
import { createHash as createHash7 } from "crypto";
|
|
17963
|
-
import { mkdir as
|
|
17964
|
-
import { dirname as dirname6, isAbsolute as isAbsolute3, join as
|
|
17965
|
-
import { Command as
|
|
18729
|
+
import { mkdir as mkdir13, readdir as readdir8, stat as stat7, unlink as unlink6, writeFile as writeFile10 } from "fs/promises";
|
|
18730
|
+
import { dirname as dirname6, isAbsolute as isAbsolute3, join as join21, resolve as resolve9 } from "path";
|
|
18731
|
+
import { Command as Command18 } from "commander";
|
|
17966
18732
|
|
|
17967
18733
|
// src/lib/rules.ts
|
|
17968
18734
|
init_src();
|
|
@@ -18034,7 +18800,7 @@ init_deadline();
|
|
|
18034
18800
|
init_cloud_brain();
|
|
18035
18801
|
init_vault();
|
|
18036
18802
|
function guardCommand() {
|
|
18037
|
-
return new
|
|
18803
|
+
return new Command18("guard").description("hook entry \u2014 show the user\u2019s rules before the first edit of a session").option("--context-dir <path>", "where the work is happening, when stdin does not say").option("--at <event>", "pre-tool-use | stop", "pre-tool-use").action(async (opts) => {
|
|
18038
18804
|
try {
|
|
18039
18805
|
const out = await withDeadline(HOOK_DEADLINE_MS, async () => {
|
|
18040
18806
|
const payload = await readPayload();
|
|
@@ -18181,7 +18947,7 @@ async function readPayload() {
|
|
|
18181
18947
|
return null;
|
|
18182
18948
|
}
|
|
18183
18949
|
}
|
|
18184
|
-
var guardDir = () =>
|
|
18950
|
+
var guardDir = () => join21(brandHome(), "guard");
|
|
18185
18951
|
var WRITE_TOOLS = /* @__PURE__ */ new Set([
|
|
18186
18952
|
"Write",
|
|
18187
18953
|
"Edit",
|
|
@@ -18202,7 +18968,7 @@ async function misdeliveryNotice(toolName, filePath, sessionId) {
|
|
|
18202
18968
|
return 'This file is this harness\u2019s own memory \u2014 no other tool the user works with will ever read it. Durable facts about the user belong in their brain, which every tool shares: memgineering remember "<the fact>" --reason "<why>" (add --rule if they stated a standing rule). Write it there instead, or in addition.';
|
|
18203
18969
|
}
|
|
18204
18970
|
function markerFor(sessionId, brain) {
|
|
18205
|
-
return
|
|
18971
|
+
return join21(
|
|
18206
18972
|
guardDir(),
|
|
18207
18973
|
`${createHash7("sha256").update(`${sessionId}\0${brain}`).digest("hex").slice(0, 32)}`
|
|
18208
18974
|
);
|
|
@@ -18210,7 +18976,7 @@ function markerFor(sessionId, brain) {
|
|
|
18210
18976
|
async function claimSession(sessionId, brain) {
|
|
18211
18977
|
const marker = markerFor(sessionId, brain);
|
|
18212
18978
|
try {
|
|
18213
|
-
await
|
|
18979
|
+
await mkdir13(guardDir(), { recursive: true, mode: 448 });
|
|
18214
18980
|
await writeFile10(marker, "", { flag: "wx", mode: 384 });
|
|
18215
18981
|
} catch {
|
|
18216
18982
|
return false;
|
|
@@ -18219,10 +18985,10 @@ async function claimSession(sessionId, brain) {
|
|
|
18219
18985
|
return true;
|
|
18220
18986
|
}
|
|
18221
18987
|
async function releaseSession(sessionId, brain) {
|
|
18222
|
-
await
|
|
18988
|
+
await unlink6(markerFor(sessionId, brain)).catch(() => void 0);
|
|
18223
18989
|
}
|
|
18224
18990
|
async function claimExists(sessionId, brain) {
|
|
18225
|
-
return
|
|
18991
|
+
return stat7(markerFor(sessionId, brain)).then(() => true).catch(() => false);
|
|
18226
18992
|
}
|
|
18227
18993
|
var MARKER_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
18228
18994
|
async function pruneOldMarkers() {
|
|
@@ -18230,10 +18996,10 @@ async function pruneOldMarkers() {
|
|
|
18230
18996
|
const dir = guardDir();
|
|
18231
18997
|
const now = Date.now();
|
|
18232
18998
|
for (const name of await readdir8(dir)) {
|
|
18233
|
-
const path =
|
|
18999
|
+
const path = join21(dir, name);
|
|
18234
19000
|
if (!isAbsolute3(path)) continue;
|
|
18235
|
-
const info = await
|
|
18236
|
-
if (info && now - info.mtimeMs > MARKER_TTL_MS) await
|
|
19001
|
+
const info = await stat7(path).catch(() => null);
|
|
19002
|
+
if (info && now - info.mtimeMs > MARKER_TTL_MS) await unlink6(path).catch(() => void 0);
|
|
18237
19003
|
}
|
|
18238
19004
|
await pruneFast(now);
|
|
18239
19005
|
} catch {
|
|
@@ -18277,15 +19043,15 @@ init_link();
|
|
|
18277
19043
|
// src/commands/log.ts
|
|
18278
19044
|
init_src();
|
|
18279
19045
|
init_walk();
|
|
18280
|
-
import { lstat as lstat4, readFile as
|
|
18281
|
-
import { Command as
|
|
19046
|
+
import { lstat as lstat4, readFile as readFile21 } from "fs/promises";
|
|
19047
|
+
import { Command as Command20 } from "commander";
|
|
18282
19048
|
init_errors();
|
|
18283
19049
|
init_cloud_brain();
|
|
18284
19050
|
|
|
18285
19051
|
// src/commands/retract.ts
|
|
18286
19052
|
init_errors();
|
|
18287
19053
|
init_cloud_brain();
|
|
18288
|
-
import { Command as
|
|
19054
|
+
import { Command as Command19 } from "commander";
|
|
18289
19055
|
init_vault();
|
|
18290
19056
|
init_ui();
|
|
18291
19057
|
var CONTENT_VERBS = /* @__PURE__ */ new Set([
|
|
@@ -18356,7 +19122,7 @@ function parseInstant(flag2, raw) {
|
|
|
18356
19122
|
return { ms, iso: new Date(ms).toISOString() };
|
|
18357
19123
|
}
|
|
18358
19124
|
function retractCommand() {
|
|
18359
|
-
return new
|
|
19125
|
+
return new Command19("retract").description(
|
|
18360
19126
|
"retire every memory one writer or one stretch of time wrote \u2014 shows the set first; --yes applies it"
|
|
18361
19127
|
).option("--actor <actor>", 'writes recorded under this actor, e.g. "mcp:ChatGPT" or "agent"').option(
|
|
18362
19128
|
"--token <id>",
|
|
@@ -18571,7 +19337,7 @@ ${failed.length} could not be retired:`);
|
|
|
18571
19337
|
init_vault();
|
|
18572
19338
|
init_ui();
|
|
18573
19339
|
function logCommand() {
|
|
18574
|
-
return new
|
|
19340
|
+
return new Command20("log").description("what changed in this brain, and what can still be undone").option("--limit <n>", "how many operations", (v) => parseInt(v, 10), 20).option("--verbose", "include hashes and reverse patches").option("--vault <path>", "which brain to read").option("--local", "read the brain on this machine, even when signed in to a hosted one").option(
|
|
18575
19341
|
"--brain <name>",
|
|
18576
19342
|
"read one existing hosted brain by name or id, without changing the pointer"
|
|
18577
19343
|
).option("--actor <actor>", 'only operations recorded under this actor, e.g. "mcp:ChatGPT" or "agent"').option("--token <id>", "only operations made with this token (id or 5+ char prefix) \u2014 hosted brains").option("--since <when>", "only operations at or after this date / ISO instant").option("--until <when>", "only operations before this date / ISO instant").action(async (opts) => {
|
|
@@ -18843,16 +19609,16 @@ async function readOrNull(root, path) {
|
|
|
18843
19609
|
if (absolute === null) return null;
|
|
18844
19610
|
const info = await lstat4(absolute).catch(() => null);
|
|
18845
19611
|
if (!info || !info.isFile()) return null;
|
|
18846
|
-
return
|
|
19612
|
+
return readFile21(absolute, "utf8").catch(() => null);
|
|
18847
19613
|
}
|
|
18848
19614
|
|
|
18849
19615
|
// src/commands/project.ts
|
|
18850
19616
|
init_errors();
|
|
18851
19617
|
import { resolve as resolve10 } from "path";
|
|
18852
|
-
import { Command as
|
|
19618
|
+
import { Command as Command21 } from "commander";
|
|
18853
19619
|
init_ui();
|
|
18854
19620
|
function projectCommand() {
|
|
18855
|
-
return new
|
|
19621
|
+
return new Command21("project").description("show or set what the work in this folder is called").argument("[name]", "what to call it \u2014 omit to show what this folder answers to").option("--here <dir>", "act on this directory instead of the current one").option("--unset", "forget the name set here and go back to what the repository says").addHelpText(
|
|
18856
19622
|
"after",
|
|
18857
19623
|
[
|
|
18858
19624
|
"",
|
|
@@ -18979,115 +19745,10 @@ init_api_client();
|
|
|
18979
19745
|
init_credentials();
|
|
18980
19746
|
init_config();
|
|
18981
19747
|
init_pending_login();
|
|
18982
|
-
import { Command as
|
|
18983
|
-
|
|
18984
|
-
// src/lib/registry-session.ts
|
|
18985
|
-
init_errors();
|
|
18986
|
-
init_credentials();
|
|
18987
|
-
init_version();
|
|
18988
|
-
function registryApiUrl(stored) {
|
|
18989
|
-
const override = process.env["KORDIS_API_URL"];
|
|
18990
|
-
return override !== void 0 && override !== "" ? override : stored;
|
|
18991
|
-
}
|
|
18992
|
-
async function requireRegistryCredentials() {
|
|
18993
|
-
const credentials = await readCredentials();
|
|
18994
|
-
const registry = credentials?.registry;
|
|
18995
|
-
if (!registry) {
|
|
18996
|
-
throw memgError(
|
|
18997
|
-
"not_linked",
|
|
18998
|
-
"this machine holds no registry identity",
|
|
18999
|
-
credentials === null ? "Nothing was sent. Sign in with `memgineering login` \u2014 it links the registry identity at the same time, so one sign-in covers both." : "Nothing was sent. This machine is signed in to a brain, and the registry half of that sign-in is missing \u2014 which is what a credential file written before federation looks like. Run `memgineering login` again; it links the registry identity too."
|
|
19000
|
-
);
|
|
19001
|
-
}
|
|
19002
|
-
return registry;
|
|
19003
|
-
}
|
|
19004
|
-
var RACE_WAIT_MS = 2e3;
|
|
19005
|
-
var RACE_POLL_MS = 50;
|
|
19006
|
-
function lostRace(err) {
|
|
19007
|
-
return err instanceof KordisApiError && err.status === 401 && isRefreshRace({ error: { code: err.code, flags: err.flags } });
|
|
19008
|
-
}
|
|
19009
|
-
async function newerRegistry(sent) {
|
|
19010
|
-
const deadline = Date.now() + RACE_WAIT_MS;
|
|
19011
|
-
for (; ; ) {
|
|
19012
|
-
const registry = (await readCredentials())?.registry;
|
|
19013
|
-
if (registry !== void 0 && registry.refresh_token !== sent) return registry;
|
|
19014
|
-
if (Date.now() >= deadline) return null;
|
|
19015
|
-
await new Promise((resolve17) => setTimeout(resolve17, RACE_POLL_MS));
|
|
19016
|
-
}
|
|
19017
|
-
}
|
|
19018
|
-
async function refreshRegistrySession(stored, opts = {}) {
|
|
19019
|
-
const attempt = async (registry) => {
|
|
19020
|
-
const baseUrl = (opts.apiUrlOf ?? ((r) => registryApiUrl(r.api_url)))(registry);
|
|
19021
|
-
const anonymous = new KordisClient({
|
|
19022
|
-
baseUrl,
|
|
19023
|
-
userAgent: `memgineering/${VERSION}`,
|
|
19024
|
-
...opts.fetchImpl ? { fetch: opts.fetchImpl } : {},
|
|
19025
|
-
...opts.requestTimeoutMs === void 0 ? {} : { requestTimeoutMs: opts.requestTimeoutMs }
|
|
19026
|
-
});
|
|
19027
|
-
return { registry, baseUrl, tokens: await anonymous.refreshSession(registry.refresh_token) };
|
|
19028
|
-
};
|
|
19029
|
-
try {
|
|
19030
|
-
return await attempt(stored);
|
|
19031
|
-
} catch (err) {
|
|
19032
|
-
if (!lostRace(err)) throw err;
|
|
19033
|
-
const newer = await newerRegistry(stored.refresh_token);
|
|
19034
|
-
if (newer === null) throw err;
|
|
19035
|
-
return attempt(newer);
|
|
19036
|
-
}
|
|
19037
|
-
}
|
|
19038
|
-
function refusal(err) {
|
|
19039
|
-
if (lostRace(err)) {
|
|
19040
|
-
return memgError(
|
|
19041
|
-
"not_authenticated",
|
|
19042
|
-
err.message,
|
|
19043
|
-
"This machine's registry sign-in was refreshed by another request at the same moment, so this command could not use it. Run this command again."
|
|
19044
|
-
);
|
|
19045
|
-
}
|
|
19046
|
-
const busyOrUnreachable = err instanceof KordisNetworkError || err instanceof KordisApiError && (err.status === 429 || err.status >= 500);
|
|
19047
|
-
return (busyOrUnreachable ? adaptRegistryError(err) : null) ?? memgError(
|
|
19048
|
-
"not_linked",
|
|
19049
|
-
`the registry refused this machine's stored sign-in: ${err instanceof Error ? err.message : String(err)}`,
|
|
19050
|
-
"Nothing was sent. The link between this brain and your registry account has expired or been revoked. `memgineering login` re-links both."
|
|
19051
|
-
);
|
|
19052
|
-
}
|
|
19053
|
-
async function openRegistrySession(fetchImpl) {
|
|
19054
|
-
const stored = await requireRegistryCredentials();
|
|
19055
|
-
let refreshed;
|
|
19056
|
-
try {
|
|
19057
|
-
refreshed = await refreshRegistrySession(stored, fetchImpl ? { fetchImpl } : {});
|
|
19058
|
-
} catch (err) {
|
|
19059
|
-
throw refusal(err);
|
|
19060
|
-
}
|
|
19061
|
-
const { registry, baseUrl, tokens } = refreshed;
|
|
19062
|
-
const credentialsRotated = await persistRotatedRefresh(
|
|
19063
|
-
registry,
|
|
19064
|
-
tokens.refresh_token,
|
|
19065
|
-
tokens.session_id
|
|
19066
|
-
);
|
|
19067
|
-
const client = new KordisClient({
|
|
19068
|
-
baseUrl,
|
|
19069
|
-
userAgent: `memgineering/${VERSION}`,
|
|
19070
|
-
getAccessToken: () => tokens.access_token,
|
|
19071
|
-
...fetchImpl ? { fetch: fetchImpl } : {}
|
|
19072
|
-
});
|
|
19073
|
-
return { client, username: registry.username, apiUrl: baseUrl, credentialsRotated };
|
|
19074
|
-
}
|
|
19075
|
-
async function persistRotatedRefresh(sent, refreshToken, sessionId) {
|
|
19076
|
-
if (refreshToken === sent.refresh_token && sessionId === sent.session_id) return false;
|
|
19077
|
-
try {
|
|
19078
|
-
return await saveRotatedRegistry(sent.refresh_token, {
|
|
19079
|
-
refresh_token: refreshToken,
|
|
19080
|
-
session_id: sessionId
|
|
19081
|
-
});
|
|
19082
|
-
} catch {
|
|
19083
|
-
return false;
|
|
19084
|
-
}
|
|
19085
|
-
}
|
|
19086
|
-
|
|
19087
|
-
// src/commands/logout.ts
|
|
19748
|
+
import { Command as Command23 } from "commander";
|
|
19088
19749
|
init_ui();
|
|
19089
19750
|
function logoutCommand() {
|
|
19090
|
-
return new
|
|
19751
|
+
return new Command23("logout").description("sign out of your account \u2014 the pointer and your notes stay").option("--all", "revoke every token on the account, not just this machine\u2019s").option(
|
|
19091
19752
|
"--local",
|
|
19092
19753
|
"forget the token here without telling the server \u2014 only for a server you cannot reach"
|
|
19093
19754
|
).action(async (opts) => {
|
|
@@ -19096,9 +19757,18 @@ function logoutCommand() {
|
|
|
19096
19757
|
await clearPendingLogin();
|
|
19097
19758
|
await clearSetupFollowUps();
|
|
19098
19759
|
if (!credentials) {
|
|
19760
|
+
const hint = opts.all ? NOT_SIGNED_IN_ALL_HINT : void 0;
|
|
19099
19761
|
printDual({
|
|
19100
|
-
json: {
|
|
19101
|
-
|
|
19762
|
+
json: {
|
|
19763
|
+
signed_out: true,
|
|
19764
|
+
was_signed_in: false,
|
|
19765
|
+
api_url: base2,
|
|
19766
|
+
...hint ? { hint } : {}
|
|
19767
|
+
},
|
|
19768
|
+
human: () => {
|
|
19769
|
+
printHuman("Not signed in \u2014 nothing to do.");
|
|
19770
|
+
if (hint) printHuman(c.gray(` ${hint}`));
|
|
19771
|
+
}
|
|
19102
19772
|
});
|
|
19103
19773
|
return;
|
|
19104
19774
|
}
|
|
@@ -19118,6 +19788,8 @@ function logoutCommand() {
|
|
|
19118
19788
|
return;
|
|
19119
19789
|
}
|
|
19120
19790
|
let revoked = null;
|
|
19791
|
+
let registrySessions = null;
|
|
19792
|
+
let revokedBefore = null;
|
|
19121
19793
|
try {
|
|
19122
19794
|
if (opts.all) {
|
|
19123
19795
|
const res = await apiRequest({
|
|
@@ -19127,6 +19799,8 @@ function logoutCommand() {
|
|
|
19127
19799
|
baseUrl: credentials.api_url
|
|
19128
19800
|
});
|
|
19129
19801
|
revoked = res.body?.revoked ?? null;
|
|
19802
|
+
registrySessions = readRegistrySessions(res.body?.registry_sessions);
|
|
19803
|
+
revokedBefore = typeof res.body?.revoked_before === "string" ? res.body.revoked_before : null;
|
|
19130
19804
|
} else {
|
|
19131
19805
|
const me = await apiRequest({
|
|
19132
19806
|
method: "GET",
|
|
@@ -19156,7 +19830,7 @@ function logoutCommand() {
|
|
|
19156
19830
|
}
|
|
19157
19831
|
}
|
|
19158
19832
|
const registry = (await readCredentials())?.registry ?? credentials.registry;
|
|
19159
|
-
const registryRevoked = await revokeRegistrySession(registry);
|
|
19833
|
+
const registryRevoked = registrySessions?.status === "revoked" ? true : await revokeRegistrySession(registry);
|
|
19160
19834
|
await clearCredentials();
|
|
19161
19835
|
printDual({
|
|
19162
19836
|
json: {
|
|
@@ -19165,7 +19839,9 @@ function logoutCommand() {
|
|
|
19165
19839
|
revoked_on_server: true,
|
|
19166
19840
|
revoked,
|
|
19167
19841
|
all: opts.all === true,
|
|
19168
|
-
api_url: credentials.api_url
|
|
19842
|
+
api_url: credentials.api_url,
|
|
19843
|
+
...registrySessions ? { registry_sessions: registrySessions } : {},
|
|
19844
|
+
...revokedBefore ? { revoked_before: revokedBefore } : {}
|
|
19169
19845
|
},
|
|
19170
19846
|
human: () => {
|
|
19171
19847
|
printHuman(opts.all ? "Signed out everywhere." : "Signed out.");
|
|
@@ -19174,6 +19850,8 @@ function logoutCommand() {
|
|
|
19174
19850
|
opts.all ? " Every token on the account is dead. `memgineering login` starts a new one." : " This machine\u2019s token is revoked. Other machines are unaffected."
|
|
19175
19851
|
)
|
|
19176
19852
|
);
|
|
19853
|
+
const registryLine = registrySessions ? registrySessionsLine(registrySessions) : null;
|
|
19854
|
+
if (registryLine !== null) printHuman(registryLine);
|
|
19177
19855
|
printHuman(
|
|
19178
19856
|
c.gray(
|
|
19179
19857
|
" Your notes are untouched: signing out takes a token, not a brain.\n This machine still remembers which brain it was reading, so `memgineering\n login` picks up where you left off. `memgineering unlink --brain` forgets it."
|
|
@@ -19183,6 +19861,34 @@ function logoutCommand() {
|
|
|
19183
19861
|
});
|
|
19184
19862
|
});
|
|
19185
19863
|
}
|
|
19864
|
+
var NOT_SIGNED_IN_ALL_HINT = 'Nothing is signed in on this machine, so nothing could be ended from here. To disconnect everything, press "disconnect everything" on the website, or run `memgineering login` and then `memgineering logout --all`.';
|
|
19865
|
+
function readRegistrySessions(raw) {
|
|
19866
|
+
if (typeof raw !== "object" || raw === null) return null;
|
|
19867
|
+
const r = raw;
|
|
19868
|
+
if (r["status"] === "revoked" && typeof r["count"] === "number") {
|
|
19869
|
+
return { status: "revoked", count: r["count"] };
|
|
19870
|
+
}
|
|
19871
|
+
if (r["status"] === "not_linked") return { status: "not_linked" };
|
|
19872
|
+
if (r["status"] === "unreachable" && typeof r["hint"] === "string") {
|
|
19873
|
+
return { status: "unreachable", hint: r["hint"] };
|
|
19874
|
+
}
|
|
19875
|
+
return null;
|
|
19876
|
+
}
|
|
19877
|
+
function registrySessionsLine(r) {
|
|
19878
|
+
switch (r.status) {
|
|
19879
|
+
case "revoked":
|
|
19880
|
+
if (r.count === 0) return null;
|
|
19881
|
+
return c.gray(
|
|
19882
|
+
` Registry sign-ins ended too: ${r.count}. Anything approved before now cannot sign back in.`
|
|
19883
|
+
);
|
|
19884
|
+
case "not_linked":
|
|
19885
|
+
return c.gray(
|
|
19886
|
+
" No registry account is linked to this Google account; nothing to end there."
|
|
19887
|
+
);
|
|
19888
|
+
case "unreachable":
|
|
19889
|
+
return c.yellow(` Registry sign-ins could not be ended: ${oneLineWhole(r.hint)}`);
|
|
19890
|
+
}
|
|
19891
|
+
}
|
|
19186
19892
|
async function revokeRegistrySession(reg) {
|
|
19187
19893
|
if (!reg) return false;
|
|
19188
19894
|
try {
|
|
@@ -19206,12 +19912,12 @@ async function revokeRegistrySession(reg) {
|
|
|
19206
19912
|
|
|
19207
19913
|
// src/commands/onboard.ts
|
|
19208
19914
|
init_src();
|
|
19209
|
-
import { Command as
|
|
19915
|
+
import { Command as Command24 } from "commander";
|
|
19210
19916
|
init_cloud_brain();
|
|
19211
19917
|
init_vault();
|
|
19212
19918
|
init_ui();
|
|
19213
19919
|
function onboardCommand() {
|
|
19214
|
-
return new
|
|
19920
|
+
return new Command24("onboard").description("what to ask so the brain knows who it belongs to").option("--vault <path>", "which brain").option("--local", "use the brain on this machine, even when signed in to a hosted one").option(
|
|
19215
19921
|
"--brain <name>",
|
|
19216
19922
|
"read one existing hosted brain by name or id, without changing the pointer"
|
|
19217
19923
|
).action(async (opts) => {
|
|
@@ -19357,11 +20063,11 @@ init_api_client();
|
|
|
19357
20063
|
init_config();
|
|
19358
20064
|
init_cloud_brain();
|
|
19359
20065
|
init_ui();
|
|
19360
|
-
import { mkdir as
|
|
19361
|
-
import { dirname as dirname7, isAbsolute as isAbsolute4, join as
|
|
19362
|
-
import { Command as
|
|
20066
|
+
import { mkdir as mkdir14, readFile as readFile22, writeFile as writeFile11 } from "fs/promises";
|
|
20067
|
+
import { dirname as dirname7, isAbsolute as isAbsolute4, join as join22, resolve as resolve11, sep as sep2 } from "path";
|
|
20068
|
+
import { Command as Command25 } from "commander";
|
|
19363
20069
|
function pullCommand() {
|
|
19364
|
-
return new
|
|
20070
|
+
return new Command25("pull").description("download your hosted brain to a folder on this machine").argument("[destination]", "folder to write into (created if missing)").option("--brain <name>", "which hosted brain to download").option("--dry-run", "say what would be written and write nothing").action(async (destination, opts) => {
|
|
19365
20071
|
const { brain: source, others } = await resolveSource(opts.brain);
|
|
19366
20072
|
const target = resolve11(destination ?? `./${oneLine(source.name, WIDTH.title)}`);
|
|
19367
20073
|
const first = await cloudListNotes(source, { limit: 1 });
|
|
@@ -19426,7 +20132,7 @@ function pullCommand() {
|
|
|
19426
20132
|
already.push(note.path);
|
|
19427
20133
|
continue;
|
|
19428
20134
|
}
|
|
19429
|
-
await
|
|
20135
|
+
await mkdir14(dirname7(file), { recursive: true });
|
|
19430
20136
|
await writeFile11(file, note.content ?? "", "utf8");
|
|
19431
20137
|
written.push(note.path);
|
|
19432
20138
|
if (note.excluded === true) excluded.push(note.path);
|
|
@@ -19541,7 +20247,7 @@ function safeJoin(root, relative3) {
|
|
|
19541
20247
|
"Nothing was written for it. This should not happen \u2014 please report it."
|
|
19542
20248
|
);
|
|
19543
20249
|
}
|
|
19544
|
-
const full = resolve11(
|
|
20250
|
+
const full = resolve11(join22(root, relative3));
|
|
19545
20251
|
if (full !== root && !full.startsWith(root + sep2)) {
|
|
19546
20252
|
throw memgError(
|
|
19547
20253
|
"server_refused",
|
|
@@ -19553,7 +20259,7 @@ function safeJoin(root, relative3) {
|
|
|
19553
20259
|
}
|
|
19554
20260
|
async function exists(file) {
|
|
19555
20261
|
try {
|
|
19556
|
-
await
|
|
20262
|
+
await readFile22(file);
|
|
19557
20263
|
return true;
|
|
19558
20264
|
} catch {
|
|
19559
20265
|
return false;
|
|
@@ -19561,8 +20267,8 @@ async function exists(file) {
|
|
|
19561
20267
|
}
|
|
19562
20268
|
|
|
19563
20269
|
// src/commands/publish.ts
|
|
19564
|
-
import { Command as
|
|
19565
|
-
import { z as
|
|
20270
|
+
import { Command as Command27 } from "commander";
|
|
20271
|
+
import { z as z33 } from "zod";
|
|
19566
20272
|
init_src();
|
|
19567
20273
|
init_errors();
|
|
19568
20274
|
|
|
@@ -19709,9 +20415,9 @@ import semver from "semver";
|
|
|
19709
20415
|
init_parser();
|
|
19710
20416
|
|
|
19711
20417
|
// ../../packages/harness-schema/src/deps.ts
|
|
19712
|
-
import { z as
|
|
20418
|
+
import { z as z26 } from "zod";
|
|
19713
20419
|
var StringDepRe = /^([a-z0-9](-?[a-z0-9])*\/[a-z0-9](-?[a-z0-9])*)(?:@(.+))?$/;
|
|
19714
|
-
var ObjectDepSchema =
|
|
20420
|
+
var ObjectDepSchema = z26.object({
|
|
19715
20421
|
full_slug: FullSlugSchema,
|
|
19716
20422
|
version_range: SemverRangeSchema.default("*")
|
|
19717
20423
|
});
|
|
@@ -19746,33 +20452,33 @@ function normaliseDep(entry, idx) {
|
|
|
19746
20452
|
init_parser();
|
|
19747
20453
|
|
|
19748
20454
|
// ../../packages/harness-schema/src/types/skill.ts
|
|
19749
|
-
import { z as
|
|
20455
|
+
import { z as z27 } from "zod";
|
|
19750
20456
|
var SKILL_DESCRIPTION_SPEC_MAX = 1024;
|
|
19751
20457
|
var SKILL_DESCRIPTION_HARD_MAX = 2048;
|
|
19752
20458
|
var SKILL_COMPATIBILITY_MAX = 500;
|
|
19753
|
-
var MetadataValueSchema =
|
|
19754
|
-
var SkillSpecFrontmatterSchema =
|
|
19755
|
-
name:
|
|
19756
|
-
description:
|
|
20459
|
+
var MetadataValueSchema = z27.union([z27.string(), z27.number(), z27.boolean()]).transform((v) => String(v));
|
|
20460
|
+
var SkillSpecFrontmatterSchema = z27.object({
|
|
20461
|
+
name: z27.string().min(1).max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/, "name must be lowercase-with-hyphens (Agent Skills spec)"),
|
|
20462
|
+
description: z27.string().min(1).max(SKILL_DESCRIPTION_HARD_MAX),
|
|
19757
20463
|
// The spec puts no length limit on license (it is an SPDX identifier or a
|
|
19758
20464
|
// short phrase); the old 64-char cap here was Kordis-invented.
|
|
19759
|
-
license:
|
|
19760
|
-
compatibility:
|
|
20465
|
+
license: z27.string().optional(),
|
|
20466
|
+
compatibility: z27.string().max(SKILL_COMPATIBILITY_MAX).optional(),
|
|
19761
20467
|
// Spec form is a space-separated STRING. The array form is what Kordis
|
|
19762
20468
|
// accepted before the spec settled — still parsed, flagged
|
|
19763
20469
|
// `legacy_frontmatter`, and re-emitted unchanged by the translators.
|
|
19764
|
-
"allowed-tools":
|
|
19765
|
-
metadata:
|
|
20470
|
+
"allowed-tools": z27.union([z27.string(), z27.array(z27.string())]).optional(),
|
|
20471
|
+
metadata: z27.record(z27.string(), MetadataValueSchema).optional()
|
|
19766
20472
|
}).strict();
|
|
19767
|
-
var LegacySkillExtrasSchema =
|
|
20473
|
+
var LegacySkillExtrasSchema = z27.object({
|
|
19768
20474
|
version: SemverSchema.optional(),
|
|
19769
|
-
homepage:
|
|
19770
|
-
model:
|
|
20475
|
+
homepage: z27.string().url().optional(),
|
|
20476
|
+
model: z27.string().optional(),
|
|
19771
20477
|
// model override hint
|
|
19772
|
-
"disable-model-invocation":
|
|
19773
|
-
title:
|
|
19774
|
-
tags:
|
|
19775
|
-
tools:
|
|
20478
|
+
"disable-model-invocation": z27.boolean().optional(),
|
|
20479
|
+
title: z27.string().min(1).max(200).optional(),
|
|
20480
|
+
tags: z27.array(TagSchema).max(16).optional(),
|
|
20481
|
+
tools: z27.array(ToolSlugSchema).optional()
|
|
19776
20482
|
});
|
|
19777
20483
|
var LEGACY_SKILL_EXTRA_KEYS = [
|
|
19778
20484
|
"version",
|
|
@@ -19787,10 +20493,10 @@ var LEGACY_KEY_SET = new Set(LEGACY_SKILL_EXTRA_KEYS);
|
|
|
19787
20493
|
var NONSTANDARD_HINT = 'These are not Agent Skills fields. Move them to `metadata` (string values: `metadata: {version: "1.2.3", tags: "a, b", tools: "claude-code, codex"}`). Accepted with a warning for now; a future release will make this an error and will say so in its changelog.';
|
|
19788
20494
|
var METADATA_READBACK = [
|
|
19789
20495
|
{ field: "version", schema: SemverSchema, list: false },
|
|
19790
|
-
{ field: "homepage", schema:
|
|
19791
|
-
{ field: "model", schema:
|
|
19792
|
-
{ field: "tags", schema:
|
|
19793
|
-
{ field: "tools", schema:
|
|
20496
|
+
{ field: "homepage", schema: z27.string().url(), list: false },
|
|
20497
|
+
{ field: "model", schema: z27.string().min(1), list: false },
|
|
20498
|
+
{ field: "tags", schema: z27.array(TagSchema).max(16), list: true },
|
|
20499
|
+
{ field: "tools", schema: z27.array(ToolSlugSchema), list: true }
|
|
19794
20500
|
];
|
|
19795
20501
|
function splitList(raw) {
|
|
19796
20502
|
return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
@@ -19885,30 +20591,30 @@ function parseSkillFrontmatter(raw) {
|
|
|
19885
20591
|
}
|
|
19886
20592
|
|
|
19887
20593
|
// ../../packages/harness-schema/src/types/mcp-server.ts
|
|
19888
|
-
import { z as
|
|
19889
|
-
var McpTransportSchema =
|
|
19890
|
-
|
|
19891
|
-
type:
|
|
19892
|
-
command:
|
|
19893
|
-
args:
|
|
19894
|
-
env:
|
|
20594
|
+
import { z as z28 } from "zod";
|
|
20595
|
+
var McpTransportSchema = z28.union([
|
|
20596
|
+
z28.object({
|
|
20597
|
+
type: z28.literal("stdio"),
|
|
20598
|
+
command: z28.string().min(1),
|
|
20599
|
+
args: z28.array(z28.string()).optional().default([]),
|
|
20600
|
+
env: z28.record(z28.string()).optional().default({})
|
|
19895
20601
|
}),
|
|
19896
|
-
|
|
19897
|
-
type:
|
|
19898
|
-
url:
|
|
19899
|
-
headers:
|
|
20602
|
+
z28.object({
|
|
20603
|
+
type: z28.enum(["http", "sse"]),
|
|
20604
|
+
url: z28.string().url(),
|
|
20605
|
+
headers: z28.record(z28.string()).optional().default({})
|
|
19900
20606
|
})
|
|
19901
20607
|
]);
|
|
19902
|
-
var McpCapabilitiesSchema =
|
|
19903
|
-
tools:
|
|
19904
|
-
resources:
|
|
19905
|
-
prompts:
|
|
20608
|
+
var McpCapabilitiesSchema = z28.object({
|
|
20609
|
+
tools: z28.array(z28.string()).optional().default([]),
|
|
20610
|
+
resources: z28.array(z28.string()).optional().default([]),
|
|
20611
|
+
prompts: z28.array(z28.string()).optional().default([])
|
|
19906
20612
|
});
|
|
19907
|
-
var McpServerFrontmatterSchema =
|
|
19908
|
-
name:
|
|
19909
|
-
description:
|
|
20613
|
+
var McpServerFrontmatterSchema = z28.object({
|
|
20614
|
+
name: z28.string().min(1).max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/),
|
|
20615
|
+
description: z28.string().min(1).max(2048),
|
|
19910
20616
|
version: SemverSchema,
|
|
19911
|
-
mcp_spec_version:
|
|
20617
|
+
mcp_spec_version: z28.string().default("2026-03"),
|
|
19912
20618
|
transport: McpTransportSchema,
|
|
19913
20619
|
capabilities: McpCapabilitiesSchema.optional().default({
|
|
19914
20620
|
tools: [],
|
|
@@ -19916,34 +20622,34 @@ var McpServerFrontmatterSchema = z27.object({
|
|
|
19916
20622
|
prompts: []
|
|
19917
20623
|
}),
|
|
19918
20624
|
/** Human-readable setup / auth instructions. Surfaced in `kordis info`. */
|
|
19919
|
-
auth_notes:
|
|
20625
|
+
auth_notes: z28.string().optional(),
|
|
19920
20626
|
/** Required env vars with description + whether they must be secret. */
|
|
19921
|
-
env_schema:
|
|
19922
|
-
|
|
19923
|
-
description:
|
|
19924
|
-
required:
|
|
19925
|
-
secret:
|
|
20627
|
+
env_schema: z28.record(
|
|
20628
|
+
z28.object({
|
|
20629
|
+
description: z28.string(),
|
|
20630
|
+
required: z28.boolean().default(true),
|
|
20631
|
+
secret: z28.boolean().default(false)
|
|
19926
20632
|
})
|
|
19927
20633
|
).optional(),
|
|
19928
|
-
homepage:
|
|
19929
|
-
repository:
|
|
19930
|
-
license:
|
|
19931
|
-
title:
|
|
20634
|
+
homepage: z28.string().url().optional(),
|
|
20635
|
+
repository: z28.string().url().optional(),
|
|
20636
|
+
license: z28.string().max(64).optional(),
|
|
20637
|
+
title: z28.string().min(1).max(200).optional()
|
|
19932
20638
|
}).strict();
|
|
19933
20639
|
|
|
19934
20640
|
// ../../packages/harness-schema/src/types/project-rules.ts
|
|
19935
|
-
import { z as
|
|
19936
|
-
var ProjectRulesFrontmatterSchema =
|
|
19937
|
-
title:
|
|
19938
|
-
description:
|
|
20641
|
+
import { z as z29 } from "zod";
|
|
20642
|
+
var ProjectRulesFrontmatterSchema = z29.object({
|
|
20643
|
+
title: z29.string().min(1).max(200),
|
|
20644
|
+
description: z29.string().min(1).max(2048),
|
|
19939
20645
|
version: SemverSchema.optional(),
|
|
19940
|
-
scope:
|
|
19941
|
-
target_path:
|
|
19942
|
-
globs:
|
|
19943
|
-
target_tools:
|
|
20646
|
+
scope: z29.enum(["root", "nested", "globs"]).default("root"),
|
|
20647
|
+
target_path: z29.string().optional(),
|
|
20648
|
+
globs: z29.array(z29.string()).optional(),
|
|
20649
|
+
target_tools: z29.array(ToolSlugSchema).optional().default([]),
|
|
19944
20650
|
/** When true, installation is idempotent via `<!-- kordis:... -->` markers. */
|
|
19945
|
-
mergeable:
|
|
19946
|
-
license:
|
|
20651
|
+
mergeable: z29.boolean().default(true),
|
|
20652
|
+
license: z29.string().max(64).optional()
|
|
19947
20653
|
}).strict().refine((v) => v.scope !== "nested" || !!v.target_path, {
|
|
19948
20654
|
message: 'scope="nested" requires target_path'
|
|
19949
20655
|
}).refine((v) => v.scope !== "globs" || v.globs && v.globs.length > 0, {
|
|
@@ -19951,32 +20657,32 @@ var ProjectRulesFrontmatterSchema = z28.object({
|
|
|
19951
20657
|
});
|
|
19952
20658
|
|
|
19953
20659
|
// ../../packages/harness-schema/src/types/custom-agent.ts
|
|
19954
|
-
import { z as
|
|
19955
|
-
var CustomAgentFrontmatterSchema =
|
|
19956
|
-
name:
|
|
19957
|
-
description:
|
|
19958
|
-
title:
|
|
20660
|
+
import { z as z30 } from "zod";
|
|
20661
|
+
var CustomAgentFrontmatterSchema = z30.object({
|
|
20662
|
+
name: z30.string().min(1).max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/),
|
|
20663
|
+
description: z30.string().min(1).max(2048),
|
|
20664
|
+
title: z30.string().min(1).max(200).optional(),
|
|
19959
20665
|
version: SemverSchema.optional(),
|
|
19960
20666
|
/** System prompt that defines the agent's persona + rules. Required. */
|
|
19961
|
-
system_prompt:
|
|
20667
|
+
system_prompt: z30.string().min(1).max(5e4),
|
|
19962
20668
|
/** Optional model override — string passed verbatim to the host. */
|
|
19963
|
-
model:
|
|
20669
|
+
model: z30.string().optional(),
|
|
19964
20670
|
/** Tools this agent can call. Host-specific names (no uniform namespace). */
|
|
19965
|
-
allowed_tools:
|
|
19966
|
-
disallowed_tools:
|
|
20671
|
+
allowed_tools: z30.array(z30.string()).optional().default([]),
|
|
20672
|
+
disallowed_tools: z30.array(z30.string()).optional().default([]),
|
|
19967
20673
|
/** Fork/context behaviour hint (Claude: `context: fork` etc.). */
|
|
19968
|
-
context:
|
|
20674
|
+
context: z30.enum(["inherit", "fork", "isolated"]).optional(),
|
|
19969
20675
|
/** Known-good tool runtimes. Empty = untested everywhere. */
|
|
19970
|
-
tool_compat:
|
|
20676
|
+
tool_compat: z30.array(ToolSlugSchema).optional().default([]),
|
|
19971
20677
|
/** Pre-load skills when this agent activates. */
|
|
19972
|
-
preload_skills:
|
|
19973
|
-
license:
|
|
19974
|
-
homepage:
|
|
20678
|
+
preload_skills: z30.array(z30.string()).optional().default([]),
|
|
20679
|
+
license: z30.string().max(64).optional(),
|
|
20680
|
+
homepage: z30.string().url().optional()
|
|
19975
20681
|
}).strict();
|
|
19976
20682
|
|
|
19977
20683
|
// ../../packages/harness-schema/src/types/hook.ts
|
|
19978
|
-
import { z as
|
|
19979
|
-
var HookEventSchema =
|
|
20684
|
+
import { z as z31 } from "zod";
|
|
20685
|
+
var HookEventSchema = z31.enum([
|
|
19980
20686
|
"PreToolUse",
|
|
19981
20687
|
"PostToolUse",
|
|
19982
20688
|
"UserPromptSubmit",
|
|
@@ -19988,78 +20694,78 @@ var HookEventSchema = z30.enum([
|
|
|
19988
20694
|
"SubagentStop",
|
|
19989
20695
|
"Background"
|
|
19990
20696
|
]);
|
|
19991
|
-
var HookActionSchema =
|
|
19992
|
-
|
|
19993
|
-
type:
|
|
19994
|
-
command:
|
|
19995
|
-
timeout_ms:
|
|
19996
|
-
blocking:
|
|
20697
|
+
var HookActionSchema = z31.union([
|
|
20698
|
+
z31.object({
|
|
20699
|
+
type: z31.literal("command"),
|
|
20700
|
+
command: z31.string().min(1),
|
|
20701
|
+
timeout_ms: z31.number().int().positive().max(6e5).optional(),
|
|
20702
|
+
blocking: z31.boolean().default(false)
|
|
19997
20703
|
}),
|
|
19998
|
-
|
|
19999
|
-
type:
|
|
20000
|
-
url:
|
|
20001
|
-
method:
|
|
20002
|
-
headers:
|
|
20003
|
-
timeout_ms:
|
|
20004
|
-
blocking:
|
|
20704
|
+
z31.object({
|
|
20705
|
+
type: z31.literal("http"),
|
|
20706
|
+
url: z31.string().url(),
|
|
20707
|
+
method: z31.enum(["GET", "POST", "PUT", "PATCH"]).default("POST"),
|
|
20708
|
+
headers: z31.record(z31.string()).optional().default({}),
|
|
20709
|
+
timeout_ms: z31.number().int().positive().max(6e5).optional(),
|
|
20710
|
+
blocking: z31.boolean().default(false)
|
|
20005
20711
|
})
|
|
20006
20712
|
]);
|
|
20007
|
-
var HookBindingSchema =
|
|
20713
|
+
var HookBindingSchema = z31.object({
|
|
20008
20714
|
event: HookEventSchema,
|
|
20009
|
-
matcher:
|
|
20715
|
+
matcher: z31.string().optional(),
|
|
20010
20716
|
action: HookActionSchema
|
|
20011
20717
|
});
|
|
20012
|
-
var HookFrontmatterSchema =
|
|
20013
|
-
name:
|
|
20014
|
-
description:
|
|
20015
|
-
title:
|
|
20718
|
+
var HookFrontmatterSchema = z31.object({
|
|
20719
|
+
name: z31.string().min(1).max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/),
|
|
20720
|
+
description: z31.string().min(1).max(2048),
|
|
20721
|
+
title: z31.string().min(1).max(200).optional(),
|
|
20016
20722
|
version: SemverSchema.optional(),
|
|
20017
20723
|
/** One or more hook bindings. */
|
|
20018
|
-
hooks:
|
|
20724
|
+
hooks: z31.array(HookBindingSchema).min(1),
|
|
20019
20725
|
/** Declared to surface in search filters — always "claude-code" for now. */
|
|
20020
|
-
tool_compat:
|
|
20021
|
-
license:
|
|
20726
|
+
tool_compat: z31.array(z31.enum(["claude-code"])).default(["claude-code"]),
|
|
20727
|
+
license: z31.string().max(64).optional()
|
|
20022
20728
|
}).strict();
|
|
20023
20729
|
|
|
20024
20730
|
// ../../packages/harness-schema/src/types/judgment-pattern.ts
|
|
20025
|
-
import { z as
|
|
20026
|
-
var FailureModeSchema =
|
|
20027
|
-
symptom:
|
|
20028
|
-
correction:
|
|
20731
|
+
import { z as z32 } from "zod";
|
|
20732
|
+
var FailureModeSchema = z32.object({
|
|
20733
|
+
symptom: z32.string().min(1).max(600).describe("the observable sign the judgment was ignored"),
|
|
20734
|
+
correction: z32.string().min(1).max(1200).describe("what to do once the symptom shows")
|
|
20029
20735
|
}).strict();
|
|
20030
|
-
var AdaptHintsSchema =
|
|
20736
|
+
var AdaptHintsSchema = z32.object({
|
|
20031
20737
|
/**
|
|
20032
20738
|
* Parts that transplant verbatim into ANY harness — the invariant core.
|
|
20033
20739
|
* Required, min 1: a judgment-pattern with no universal part has nothing
|
|
20034
20740
|
* to transplant, which makes it a skill/project-rules in disguise, not a
|
|
20035
20741
|
* judgment worth the dedicated type.
|
|
20036
20742
|
*/
|
|
20037
|
-
universal:
|
|
20743
|
+
universal: z32.array(z32.string().min(1).max(400)).min(1, "adapt_hints.universal must list at least one transplantable, harness-agnostic part").max(20),
|
|
20038
20744
|
/** Parts the adapting agent must re-express in the host's stack/conventions. */
|
|
20039
|
-
context_specific:
|
|
20745
|
+
context_specific: z32.array(z32.string().min(1).max(400)).max(20).optional()
|
|
20040
20746
|
}).strict();
|
|
20041
|
-
var JudgmentPatternFrontmatterSchema =
|
|
20042
|
-
name:
|
|
20747
|
+
var JudgmentPatternFrontmatterSchema = z32.object({
|
|
20748
|
+
name: z32.string().min(1).max(64).regex(
|
|
20043
20749
|
/^[a-z0-9]+(-[a-z0-9]+)*$/,
|
|
20044
20750
|
'name must be lowercase-with-hyphens, e.g. "additive-only-migrations"'
|
|
20045
20751
|
),
|
|
20046
|
-
description:
|
|
20752
|
+
description: z32.string().min(1).max(2048),
|
|
20047
20753
|
version: SemverSchema.optional(),
|
|
20048
|
-
title:
|
|
20754
|
+
title: z32.string().min(1).max(200).optional(),
|
|
20049
20755
|
/** The recurring situation / trap this judgment addresses. */
|
|
20050
|
-
problem:
|
|
20756
|
+
problem: z32.string().min(1).max(4e3),
|
|
20051
20757
|
/**
|
|
20052
20758
|
* The judgment itself — free-form Markdown. The agent is the interpreter,
|
|
20053
20759
|
* so this stays unstructured prose (decision tree, heuristics, rationale).
|
|
20054
20760
|
* This is the part that gets transplanted.
|
|
20055
20761
|
*/
|
|
20056
|
-
decision_logic:
|
|
20762
|
+
decision_logic: z32.string().min(1).max(2e4),
|
|
20057
20763
|
/** Triggers — when this judgment should fire. At least one. */
|
|
20058
|
-
when_to_apply:
|
|
20764
|
+
when_to_apply: z32.array(z32.string().min(1).max(400)).min(1).max(12),
|
|
20059
20765
|
/** Counter-triggers — when applying it would be wrong. */
|
|
20060
|
-
when_not_to_apply:
|
|
20766
|
+
when_not_to_apply: z32.array(z32.string().min(1).max(400)).max(12).optional(),
|
|
20061
20767
|
/** How it fails in practice, and how to recover — the hard-won part. */
|
|
20062
|
-
failure_modes:
|
|
20768
|
+
failure_modes: z32.array(FailureModeSchema).max(12).optional(),
|
|
20063
20769
|
/**
|
|
20064
20770
|
* Transplant steering — the field unique to judgment-pattern. Required:
|
|
20065
20771
|
* `adapt_hints.universal` (min 1) is what makes this a judgment-pattern
|
|
@@ -20067,13 +20773,13 @@ var JudgmentPatternFrontmatterSchema = z31.object({
|
|
|
20067
20773
|
*/
|
|
20068
20774
|
adapt_hints: AdaptHintsSchema,
|
|
20069
20775
|
/** Where this judgment came from (project, incident, paper). Provenance. */
|
|
20070
|
-
origin:
|
|
20776
|
+
origin: z32.string().min(1).max(600).optional(),
|
|
20071
20777
|
/** Proof it works (anti-spam lever for AI review). */
|
|
20072
|
-
evidence:
|
|
20778
|
+
evidence: z32.string().min(1).max(2e3).optional(),
|
|
20073
20779
|
// Kordis-forwarded cross-type fields (kept minimal, like skill).
|
|
20074
|
-
tags:
|
|
20075
|
-
tools:
|
|
20076
|
-
license:
|
|
20780
|
+
tags: z32.array(TagSchema).max(16).optional(),
|
|
20781
|
+
tools: z32.array(ToolSlugSchema).optional(),
|
|
20782
|
+
license: z32.string().max(64).optional()
|
|
20077
20783
|
}).strict();
|
|
20078
20784
|
|
|
20079
20785
|
// ../../packages/harness-schema/src/validator.ts
|
|
@@ -20392,7 +21098,7 @@ function isSameBrainNote(publishedOrigin, memoryId) {
|
|
|
20392
21098
|
}
|
|
20393
21099
|
|
|
20394
21100
|
// src/commands/registry/read.ts
|
|
20395
|
-
import { Command as
|
|
21101
|
+
import { Command as Command26 } from "commander";
|
|
20396
21102
|
init_errors();
|
|
20397
21103
|
init_credentials();
|
|
20398
21104
|
|
|
@@ -20415,7 +21121,7 @@ function untrustedFenceNotice(sentinel) {
|
|
|
20415
21121
|
init_ui();
|
|
20416
21122
|
init_version();
|
|
20417
21123
|
function readCommand() {
|
|
20418
|
-
return new
|
|
21124
|
+
return new Command26("read").description("read a judgment from the public layer into your context (nothing is installed)").argument("<full_slug>", "package identifier {username}/{slug} or {username}/{slug}@{version}").option("--allow-pending", "allow versions whose AI review has not passed", false).option("--vault <path>", "which brain records that this was read").option("--local", "record it beside the brain on this machine, not the hosted one").addHelpText(
|
|
20419
21125
|
"after",
|
|
20420
21126
|
"\nEnvironment:\n KORDIS_API_URL=<url> read from this registry instead of the linked one\n"
|
|
20421
21127
|
).action(async (rawSlug, opts) => {
|
|
@@ -20563,7 +21269,7 @@ async function recordUsage(verb, detail, where = {}) {
|
|
|
20563
21269
|
init_vault();
|
|
20564
21270
|
init_ui();
|
|
20565
21271
|
function publishCommand() {
|
|
20566
|
-
return new
|
|
21272
|
+
return new Command27("publish").description("publish one decision from this brain to the public layer").argument("<ref>", "handle, id, path, or exact title of the note to publish").option("--slug <name>", "the package name (default: derived from the note title)").option("--yes", "actually send it (without this, nothing leaves this machine)").option("--reason <text>", "why this is being published \u2014 the user's own words").option("--no-lineage", "do not propose lineage from what this machine has adapted").option(
|
|
20567
21273
|
"--bump <kind>",
|
|
20568
21274
|
"patch | minor | major \u2014 publish the next version of a package this note already produced"
|
|
20569
21275
|
).option("--wait <ms>", "how long to wait for the AI review before answering (default 3000)").option("--vault <path>", "which brain to read").option("--local", "read the brain on this machine, even when signed in to a hosted one").addHelpText(
|
|
@@ -20704,7 +21410,7 @@ async function hostedAssertion(target, ref) {
|
|
|
20704
21410
|
const cloud = await openCloudBrain(target);
|
|
20705
21411
|
const found = await cloudOpen(cloud, ref, await projectAskedFrom());
|
|
20706
21412
|
const memory = MemorySchema.safeParse(found.memory);
|
|
20707
|
-
const claims =
|
|
21413
|
+
const claims = z33.array(ClaimSchema).safeParse(found.claims);
|
|
20708
21414
|
if (!memory.success || !claims.success) {
|
|
20709
21415
|
throw memgError(
|
|
20710
21416
|
"server_refused",
|
|
@@ -20889,13 +21595,13 @@ function parseWait(raw) {
|
|
|
20889
21595
|
}
|
|
20890
21596
|
|
|
20891
21597
|
// src/commands/registry/adapt.ts
|
|
20892
|
-
import { Command as
|
|
21598
|
+
import { Command as Command28 } from "commander";
|
|
20893
21599
|
init_errors();
|
|
20894
21600
|
|
|
20895
21601
|
// src/lib/harness-context.ts
|
|
20896
21602
|
init_brand();
|
|
20897
|
-
import { access, readFile as
|
|
20898
|
-
import { join as
|
|
21603
|
+
import { access, readFile as readFile23 } from "fs/promises";
|
|
21604
|
+
import { join as join23 } from "path";
|
|
20899
21605
|
var PER_FILE_CAP = 16 * 1024;
|
|
20900
21606
|
var TOTAL_CAP = 48 * 1024;
|
|
20901
21607
|
var TRUNCATION_RESERVE = 64;
|
|
@@ -20940,13 +21646,13 @@ function extractHeadings(content) {
|
|
|
20940
21646
|
}
|
|
20941
21647
|
async function readHarnessContext(cwd = process.cwd(), home = agentHome()) {
|
|
20942
21648
|
const candidates = [
|
|
20943
|
-
{ path:
|
|
20944
|
-
{ path:
|
|
20945
|
-
{ path:
|
|
20946
|
-
{ path:
|
|
20947
|
-
{ path:
|
|
20948
|
-
{ path:
|
|
20949
|
-
{ path:
|
|
21649
|
+
{ path: join23(cwd, "CLAUDE.md"), display: "CLAUDE.md", scope: "project" },
|
|
21650
|
+
{ path: join23(cwd, "AGENTS.md"), display: "AGENTS.md", scope: "project" },
|
|
21651
|
+
{ path: join23(cwd, "GEMINI.md"), display: "GEMINI.md", scope: "project" },
|
|
21652
|
+
{ path: join23(cwd, ".claude", "CLAUDE.md"), display: ".claude/CLAUDE.md", scope: "project" },
|
|
21653
|
+
{ path: join23(home, ".claude", "CLAUDE.md"), display: "~/.claude/CLAUDE.md", scope: "global" },
|
|
21654
|
+
{ path: join23(home, ".codex", "AGENTS.md"), display: "~/.codex/AGENTS.md", scope: "global" },
|
|
21655
|
+
{ path: join23(home, ".gemini", "GEMINI.md"), display: "~/.gemini/GEMINI.md", scope: "global" }
|
|
20950
21656
|
];
|
|
20951
21657
|
const files2 = [];
|
|
20952
21658
|
let totalBytes = 0;
|
|
@@ -20954,7 +21660,7 @@ async function readHarnessContext(cwd = process.cwd(), home = agentHome()) {
|
|
|
20954
21660
|
if (!await pathExists(cand.path)) continue;
|
|
20955
21661
|
let raw;
|
|
20956
21662
|
try {
|
|
20957
|
-
raw = await
|
|
21663
|
+
raw = await readFile23(cand.path, "utf8");
|
|
20958
21664
|
} catch {
|
|
20959
21665
|
continue;
|
|
20960
21666
|
}
|
|
@@ -21025,7 +21731,7 @@ function renderBrief(res, harness) {
|
|
|
21025
21731
|
return out.join("\n");
|
|
21026
21732
|
}
|
|
21027
21733
|
function adaptCommand() {
|
|
21028
|
-
return new
|
|
21734
|
+
return new Command28("adapt").description("fit a public judgment to your existing harness (prints a brief; writes nothing)").argument("<full_slug>", "package identifier {username}/{slug} or {username}/{slug}@{version}").option("--allow-pending", "allow versions whose AI review has not passed", false).option("--vault <path>", "which brain records that this was adapted").option("--local", "record it beside the brain on this machine, not the hosted one").addHelpText(
|
|
21029
21735
|
"after",
|
|
21030
21736
|
"\nEnvironment:\n KORDIS_API_URL=<url> read from this registry instead of the linked one\n"
|
|
21031
21737
|
).action(async (rawSlug, opts) => {
|
|
@@ -21073,10 +21779,10 @@ function adaptCommand() {
|
|
|
21073
21779
|
}
|
|
21074
21780
|
|
|
21075
21781
|
// src/commands/registry/info.ts
|
|
21076
|
-
import { Command as
|
|
21782
|
+
import { Command as Command29 } from "commander";
|
|
21077
21783
|
init_ui();
|
|
21078
21784
|
function infoCommand() {
|
|
21079
|
-
return new
|
|
21785
|
+
return new Command29("info").description("what a package in the public layer is, without reading it").argument("<full_slug>", "package identifier {username}/{slug} or {username}/{slug}@{version}").addHelpText(
|
|
21080
21786
|
"after",
|
|
21081
21787
|
"\nEnvironment:\n KORDIS_API_URL=<url> ask this registry instead of the linked one\n"
|
|
21082
21788
|
).action(async (rawSlug) => {
|
|
@@ -21162,7 +21868,7 @@ function renderCanonical(component) {
|
|
|
21162
21868
|
}
|
|
21163
21869
|
|
|
21164
21870
|
// src/commands/registry/search.ts
|
|
21165
|
-
import { Command as
|
|
21871
|
+
import { Command as Command30 } from "commander";
|
|
21166
21872
|
init_errors();
|
|
21167
21873
|
init_ui();
|
|
21168
21874
|
var SEARCHABLE_TYPES = PHASE_1_TYPES;
|
|
@@ -21170,7 +21876,7 @@ var LIMIT_MIN = 1;
|
|
|
21170
21876
|
var LIMIT_MAX = 100;
|
|
21171
21877
|
var LIMIT_DEFAULT = 20;
|
|
21172
21878
|
function searchCommand() {
|
|
21173
|
-
return new
|
|
21879
|
+
return new Command30("search").description("find a judgment in the public layer (titles only; nothing is read or installed)").argument("[query...]", "words to match against title and description").option("--type <type>", `narrow by kind: ${SEARCHABLE_TYPES.join("|")}`).option("--limit <n>", `how many results (${LIMIT_MIN}-${LIMIT_MAX})`, String(LIMIT_DEFAULT)).addHelpText(
|
|
21174
21880
|
"after",
|
|
21175
21881
|
"\nEnvironment:\n KORDIS_API_URL=<url> search this registry instead of the linked one\n"
|
|
21176
21882
|
).action(async (query, opts) => {
|
|
@@ -21348,11 +22054,11 @@ function parseLimit2(raw) {
|
|
|
21348
22054
|
}
|
|
21349
22055
|
|
|
21350
22056
|
// src/commands/registry/pull.ts
|
|
21351
|
-
import { Command as
|
|
21352
|
-
import
|
|
22057
|
+
import { Command as Command31 } from "commander";
|
|
22058
|
+
import prompts4 from "prompts";
|
|
21353
22059
|
import { existsSync, lstatSync, realpathSync } from "fs";
|
|
21354
|
-
import { mkdir as
|
|
21355
|
-
import { dirname as dirname8, join as
|
|
22060
|
+
import { mkdir as mkdir16, readFile as readFile25, stat as stat8, writeFile as writeFile13 } from "fs/promises";
|
|
22061
|
+
import { dirname as dirname8, join as join25, resolve as resolve12, sep as sep3 } from "path";
|
|
21356
22062
|
|
|
21357
22063
|
// ../../packages/translators/src/skill/identity.ts
|
|
21358
22064
|
function buildSkillFile(input, outputPath) {
|
|
@@ -22077,17 +22783,17 @@ init_ui();
|
|
|
22077
22783
|
|
|
22078
22784
|
// src/lib/lockfile.ts
|
|
22079
22785
|
init_brand();
|
|
22080
|
-
import { copyFile, mkdir as
|
|
22786
|
+
import { copyFile, mkdir as mkdir15, readFile as readFile24, writeFile as writeFile12, constants as fsConstants } from "fs/promises";
|
|
22081
22787
|
import { homedir as homedir4 } from "os";
|
|
22082
|
-
import { join as
|
|
22788
|
+
import { join as join24 } from "path";
|
|
22083
22789
|
function effectiveRange(entry) {
|
|
22084
22790
|
return entry.requestedRange ?? `^${entry.version}`;
|
|
22085
22791
|
}
|
|
22086
22792
|
function lockfilePath() {
|
|
22087
|
-
return
|
|
22793
|
+
return join24(brandHome(), "installed.json");
|
|
22088
22794
|
}
|
|
22089
22795
|
function kordisLockfilePath() {
|
|
22090
|
-
return
|
|
22796
|
+
return join24(process.env["KORDIS_HOME"] ?? join24(homedir4(), ".kordis"), "installed.json");
|
|
22091
22797
|
}
|
|
22092
22798
|
function lockfileDisplayPath() {
|
|
22093
22799
|
const path = lockfilePath();
|
|
@@ -22098,13 +22804,13 @@ async function migrateFromKordis() {
|
|
|
22098
22804
|
const source = kordisLockfilePath();
|
|
22099
22805
|
const destination = lockfilePath();
|
|
22100
22806
|
try {
|
|
22101
|
-
await
|
|
22807
|
+
await mkdir15(brandHome(), { recursive: true });
|
|
22102
22808
|
await copyFile(source, destination, fsConstants.COPYFILE_EXCL);
|
|
22103
22809
|
} catch {
|
|
22104
22810
|
return;
|
|
22105
22811
|
}
|
|
22106
22812
|
try {
|
|
22107
|
-
const raw = await
|
|
22813
|
+
const raw = await readFile24(destination, "utf8");
|
|
22108
22814
|
const parsed = JSON.parse(raw);
|
|
22109
22815
|
if (parsed.migratedFrom === void 0) {
|
|
22110
22816
|
parsed.migratedFrom = source;
|
|
@@ -22115,18 +22821,18 @@ async function migrateFromKordis() {
|
|
|
22115
22821
|
}
|
|
22116
22822
|
async function readLockfile() {
|
|
22117
22823
|
try {
|
|
22118
|
-
return JSON.parse(await
|
|
22824
|
+
return JSON.parse(await readFile24(lockfilePath(), "utf8"));
|
|
22119
22825
|
} catch {
|
|
22120
22826
|
await migrateFromKordis();
|
|
22121
22827
|
}
|
|
22122
22828
|
try {
|
|
22123
|
-
return JSON.parse(await
|
|
22829
|
+
return JSON.parse(await readFile24(lockfilePath(), "utf8"));
|
|
22124
22830
|
} catch {
|
|
22125
22831
|
return { packages: {} };
|
|
22126
22832
|
}
|
|
22127
22833
|
}
|
|
22128
22834
|
async function writeLockfile(lf) {
|
|
22129
|
-
await
|
|
22835
|
+
await mkdir15(brandHome(), { recursive: true });
|
|
22130
22836
|
await writeFile12(lockfilePath(), JSON.stringify(lf, null, 2) + "\n", {
|
|
22131
22837
|
encoding: "utf8",
|
|
22132
22838
|
mode: 384
|
|
@@ -22134,7 +22840,7 @@ async function writeLockfile(lf) {
|
|
|
22134
22840
|
}
|
|
22135
22841
|
async function recordInstalled(fullSlug, entry) {
|
|
22136
22842
|
const home = brandHome();
|
|
22137
|
-
await withFileLock(
|
|
22843
|
+
await withFileLock(join24(home, "installed.lock"), home, async () => {
|
|
22138
22844
|
const lf = await readLockfile();
|
|
22139
22845
|
lf.packages[fullSlug] = entry;
|
|
22140
22846
|
await writeLockfile(lf);
|
|
@@ -22197,7 +22903,7 @@ async function promptForExecutableApproval(review) {
|
|
|
22197
22903
|
);
|
|
22198
22904
|
printHuman(c.gray(" \u2500\u2500 END EXECUTABLE CONFIG \u2500\u2500"));
|
|
22199
22905
|
}
|
|
22200
|
-
const { confirmed } = await
|
|
22906
|
+
const { confirmed } = await prompts4({
|
|
22201
22907
|
type: "confirm",
|
|
22202
22908
|
name: "confirmed",
|
|
22203
22909
|
message: "Install and activate these exact executable settings?",
|
|
@@ -22290,7 +22996,7 @@ async function doPullInstall(fullSlug, tool, installRoot, opts = {}) {
|
|
|
22290
22996
|
);
|
|
22291
22997
|
for (const f of translated.files) {
|
|
22292
22998
|
const abs = safeInstallPath(installRoot, f.path);
|
|
22293
|
-
await
|
|
22999
|
+
await mkdir16(dirname8(abs), { recursive: true });
|
|
22294
23000
|
await applyEmittedFile(abs, f, fullSlug, notes);
|
|
22295
23001
|
written.push(abs);
|
|
22296
23002
|
}
|
|
@@ -22319,7 +23025,7 @@ async function doPullInstall(fullSlug, tool, installRoot, opts = {}) {
|
|
|
22319
23025
|
};
|
|
22320
23026
|
}
|
|
22321
23027
|
function registryPullCommand() {
|
|
22322
|
-
return new
|
|
23028
|
+
return new Command31("pull").description("install a package from the public layer into this project").argument(
|
|
22323
23029
|
"<full_slug>",
|
|
22324
23030
|
"package identifier {username}/{slug}, optionally @{version} or @{range}"
|
|
22325
23031
|
).option("--tool <name>", "target tool format (default: work it out from this directory)").option("--target <path>", "install into this directory instead of the current one").option("--with-recommends", "also install recommended (depth-0) dependencies", false).option(
|
|
@@ -22446,7 +23152,7 @@ var TOOL_MARKERS = [
|
|
|
22446
23152
|
async function detectTool(root) {
|
|
22447
23153
|
for (const [path, tool] of TOOL_MARKERS) {
|
|
22448
23154
|
try {
|
|
22449
|
-
await
|
|
23155
|
+
await stat8(join25(root, path));
|
|
22450
23156
|
return tool;
|
|
22451
23157
|
} catch {
|
|
22452
23158
|
}
|
|
@@ -22462,7 +23168,7 @@ function safeInstallPath(installRoot, relPath) {
|
|
|
22462
23168
|
"Nothing was written. The package emits an absolute file path. Tell the author to publish it with relative paths only; if you did not publish it, treat it as an attempt to write outside your project."
|
|
22463
23169
|
);
|
|
22464
23170
|
}
|
|
22465
|
-
const abs =
|
|
23171
|
+
const abs = join25(installRoot, relPath);
|
|
22466
23172
|
const resolvedRoot = resolve12(installRoot);
|
|
22467
23173
|
const resolvedAbs = resolve12(abs);
|
|
22468
23174
|
if (resolvedAbs !== resolvedRoot && !resolvedAbs.startsWith(resolvedRoot + sep3)) {
|
|
@@ -22528,7 +23234,7 @@ async function applyEmittedFile(abs, f, fullSlug, notes) {
|
|
|
22528
23234
|
}
|
|
22529
23235
|
let existingRaw = null;
|
|
22530
23236
|
try {
|
|
22531
|
-
existingRaw = await
|
|
23237
|
+
existingRaw = await readFile25(abs, "utf8");
|
|
22532
23238
|
} catch (err) {
|
|
22533
23239
|
if (err.code !== "ENOENT") throw err;
|
|
22534
23240
|
}
|
|
@@ -22559,10 +23265,10 @@ async function applyEmittedFile(abs, f, fullSlug, notes) {
|
|
|
22559
23265
|
// src/commands/registry/update.ts
|
|
22560
23266
|
init_errors();
|
|
22561
23267
|
init_ui();
|
|
22562
|
-
import { Command as
|
|
23268
|
+
import { Command as Command32 } from "commander";
|
|
22563
23269
|
import semver2 from "semver";
|
|
22564
23270
|
function registryUpdateCommand() {
|
|
22565
|
-
return new
|
|
23271
|
+
return new Command32("update").description("update installed packages to their latest in-range versions").argument("[full_slug]", "package identifier {username}/{slug} (omit to update all)").option("--dry-run", "show what would be updated without doing it", false).addHelpText(
|
|
22566
23272
|
"after",
|
|
22567
23273
|
"\nEnvironment:\n KORDIS_API_URL=<url> ask this registry instead of the linked one\n"
|
|
22568
23274
|
).action(async (fullSlugArg, opts) => {
|
|
@@ -22696,10 +23402,10 @@ function registryUpdateCommand() {
|
|
|
22696
23402
|
|
|
22697
23403
|
// src/commands/registry/outdated.ts
|
|
22698
23404
|
init_ui();
|
|
22699
|
-
import { Command as
|
|
23405
|
+
import { Command as Command33 } from "commander";
|
|
22700
23406
|
import semver3 from "semver";
|
|
22701
23407
|
function outdatedCommand() {
|
|
22702
|
-
return new
|
|
23408
|
+
return new Command33("outdated").description("check installed packages for available updates").addHelpText(
|
|
22703
23409
|
"after",
|
|
22704
23410
|
"\nEnvironment:\n KORDIS_API_URL=<url> ask this registry instead of the linked one\n"
|
|
22705
23411
|
).action(async () => {
|
|
@@ -22791,9 +23497,9 @@ function outdatedCommand() {
|
|
|
22791
23497
|
// src/commands/registry/versions.ts
|
|
22792
23498
|
init_errors();
|
|
22793
23499
|
init_ui();
|
|
22794
|
-
import { Command as
|
|
23500
|
+
import { Command as Command34 } from "commander";
|
|
22795
23501
|
function versionsCommand() {
|
|
22796
|
-
return new
|
|
23502
|
+
return new Command34("versions").description("list every published version of a package").argument("<full_slug>", "package identifier {username}/{slug}").addHelpText(
|
|
22797
23503
|
"after",
|
|
22798
23504
|
"\nEnvironment:\n KORDIS_API_URL=<url> ask this registry instead of the linked one\n"
|
|
22799
23505
|
).action(async (fullSlug) => {
|
|
@@ -22857,9 +23563,9 @@ function relativeTime(isoString) {
|
|
|
22857
23563
|
// src/commands/registry/diff.ts
|
|
22858
23564
|
init_errors();
|
|
22859
23565
|
init_ui();
|
|
22860
|
-
import { Command as
|
|
23566
|
+
import { Command as Command35 } from "commander";
|
|
22861
23567
|
function diffCommand() {
|
|
22862
|
-
return new
|
|
23568
|
+
return new Command35("diff").description("show what changed between two versions of a package").argument(
|
|
22863
23569
|
"<full_slug>",
|
|
22864
23570
|
"package identifier {username}/{slug}, or {username}/{slug}@{from}..{to}"
|
|
22865
23571
|
).argument("[from]", "older version (omit to use the second-latest)").argument("[to]", "newer version (omit to use the latest)").addHelpText(
|
|
@@ -22936,7 +23642,7 @@ function diffCommand() {
|
|
|
22936
23642
|
}
|
|
22937
23643
|
|
|
22938
23644
|
// src/commands/registry/list.ts
|
|
22939
|
-
import { Command as
|
|
23645
|
+
import { Command as Command36 } from "commander";
|
|
22940
23646
|
init_errors();
|
|
22941
23647
|
init_ui();
|
|
22942
23648
|
var SORT_KEYWORDS = ["latest", "popular", "recent", "updated", "stars", "downloads"];
|
|
@@ -22959,7 +23665,7 @@ function parseUsername(raw) {
|
|
|
22959
23665
|
return parsed.data;
|
|
22960
23666
|
}
|
|
22961
23667
|
function listCommand() {
|
|
22962
|
-
return new
|
|
23668
|
+
return new Command36("list").description("list packages \u2014 your own with no argument, or a public user\u2019s").argument("[username]", "whose packages to list (omit for your own)").option("--limit <n>", "maximum results per page", (v) => parseInt(v, 10), 20).option("--page <n>", "page number for your own packages (1-based)", (v) => parseInt(v, 10), 1).option("--cursor <token>", "continue a public listing from a previous result").option(
|
|
22963
23669
|
"--sort <mode>",
|
|
22964
23670
|
"latest|popular for your own; stars|downloads|recent|updated for a public listing",
|
|
22965
23671
|
"latest"
|
|
@@ -23058,7 +23764,7 @@ init_push();
|
|
|
23058
23764
|
init_src();
|
|
23059
23765
|
init_exclude();
|
|
23060
23766
|
init_config();
|
|
23061
|
-
import { Command as
|
|
23767
|
+
import { Command as Command38 } from "commander";
|
|
23062
23768
|
import { basename as basename3, resolve as resolve13 } from "path";
|
|
23063
23769
|
init_index_build();
|
|
23064
23770
|
init_cloud_brain();
|
|
@@ -23067,7 +23773,7 @@ init_held_back();
|
|
|
23067
23773
|
init_vault();
|
|
23068
23774
|
init_ui();
|
|
23069
23775
|
function recallCommand() {
|
|
23070
|
-
return new
|
|
23776
|
+
return new Command38("recall").description("recall memory cards for a question").argument("<query>", "what you want to remember").option("--vault <path>", "which brain to search").option("--local", "search the brain on this machine, even when signed in to a hosted one").option(
|
|
23071
23777
|
"--brain <name>",
|
|
23072
23778
|
"search one existing hosted brain by name or id, without changing the pointer"
|
|
23073
23779
|
).option("--scope <scope>", "restrict to one scope").option("--limit <n>", "max cards", (v) => parseInt(v, 10), 8).option(
|
|
@@ -23742,13 +24448,13 @@ init_setup();
|
|
|
23742
24448
|
init_ui();
|
|
23743
24449
|
init_deadline();
|
|
23744
24450
|
init_src();
|
|
23745
|
-
import { Command as
|
|
24451
|
+
import { Command as Command40 } from "commander";
|
|
23746
24452
|
init_index_build();
|
|
23747
24453
|
init_cloud_brain();
|
|
23748
24454
|
init_vault();
|
|
23749
24455
|
init_ui();
|
|
23750
24456
|
function resurfaceCommand() {
|
|
23751
|
-
return new
|
|
24457
|
+
return new Command40("resurface").description("what is worth having in view right now, without being asked").option("--context-dir <path>", "where the work is happening (default: cwd)").option("--limit <n>", "how many cards", (v) => parseInt(v, 10), 5).option("--vault <path>", "which brain").option("--local", "use the brain on this machine, even when signed in to a hosted one").option(
|
|
23752
24458
|
"--brain <name>",
|
|
23753
24459
|
"read one existing hosted brain by name or id, without changing the pointer"
|
|
23754
24460
|
).option(
|
|
@@ -23975,11 +24681,11 @@ rank by project yet, so that is not one of the signals above.`
|
|
|
23975
24681
|
}
|
|
23976
24682
|
|
|
23977
24683
|
// src/commands/rules.ts
|
|
23978
|
-
import { Command as
|
|
24684
|
+
import { Command as Command41 } from "commander";
|
|
23979
24685
|
init_cloud_brain();
|
|
23980
24686
|
init_ui();
|
|
23981
24687
|
function rulesCommand() {
|
|
23982
|
-
return new
|
|
24688
|
+
return new Command41("rules").description("the user\u2019s standing decisions \u2014 what binds you here").option("--vault <path>", "which brain").option("--local", "use the brain on this machine, even when signed in to a hosted one").option(
|
|
23983
24689
|
"--brain <name>",
|
|
23984
24690
|
"read one existing hosted brain by name or id, without changing the pointer"
|
|
23985
24691
|
).action(async (opts) => {
|
|
@@ -24146,24 +24852,24 @@ init_next_step();
|
|
|
24146
24852
|
init_provenance();
|
|
24147
24853
|
import { spawn as spawn4 } from "child_process";
|
|
24148
24854
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
24149
|
-
import { mkdir as
|
|
24150
|
-
import { join as
|
|
24151
|
-
import { Command as
|
|
24855
|
+
import { mkdir as mkdir20, open, readFile as readFile30, rename as rename5, rm as rm8, stat as stat10, unlink as unlink7, writeFile as writeFile16 } from "fs/promises";
|
|
24856
|
+
import { join as join32 } from "path";
|
|
24857
|
+
import { Command as Command42 } from "commander";
|
|
24152
24858
|
|
|
24153
24859
|
// src/lib/update-check.ts
|
|
24154
24860
|
init_atomic();
|
|
24155
24861
|
init_brand();
|
|
24156
24862
|
import { execFile as execFile2 } from "child_process";
|
|
24157
|
-
import { mkdir as
|
|
24158
|
-
import { join as
|
|
24863
|
+
import { mkdir as mkdir19, readFile as readFile29, writeFile as writeFile15 } from "fs/promises";
|
|
24864
|
+
import { join as join31 } from "path";
|
|
24159
24865
|
import { promisify as promisify2 } from "util";
|
|
24160
24866
|
import semver4 from "semver";
|
|
24161
|
-
import { z as
|
|
24867
|
+
import { z as z34 } from "zod";
|
|
24162
24868
|
var run2 = promisify2(execFile2);
|
|
24163
|
-
var PolicySchema =
|
|
24164
|
-
latest:
|
|
24165
|
-
minimum_supported:
|
|
24166
|
-
notice:
|
|
24869
|
+
var PolicySchema = z34.object({
|
|
24870
|
+
latest: z34.string().optional(),
|
|
24871
|
+
minimum_supported: z34.string().optional(),
|
|
24872
|
+
notice: z34.string().optional()
|
|
24167
24873
|
});
|
|
24168
24874
|
var POLICY_URL = "https://memgineering.com/version-policy.json";
|
|
24169
24875
|
var NOTICE_MAX = 300;
|
|
@@ -24228,19 +24934,19 @@ function shouldCheck(lastCheck, now) {
|
|
|
24228
24934
|
if (!Number.isFinite(last)) return true;
|
|
24229
24935
|
return now.getTime() - last > 864e5;
|
|
24230
24936
|
}
|
|
24231
|
-
var UpdateStateSchema =
|
|
24232
|
-
at:
|
|
24233
|
-
ok:
|
|
24234
|
-
from:
|
|
24235
|
-
to:
|
|
24236
|
-
message:
|
|
24937
|
+
var UpdateStateSchema = z34.object({
|
|
24938
|
+
at: z34.string(),
|
|
24939
|
+
ok: z34.boolean(),
|
|
24940
|
+
from: z34.string(),
|
|
24941
|
+
to: z34.string().nullable(),
|
|
24942
|
+
message: z34.string().nullable()
|
|
24237
24943
|
});
|
|
24238
24944
|
function statePath() {
|
|
24239
|
-
return
|
|
24945
|
+
return join31(brandHome(), "update-state.json");
|
|
24240
24946
|
}
|
|
24241
24947
|
async function readUpdateState() {
|
|
24242
24948
|
try {
|
|
24243
|
-
const parsed = UpdateStateSchema.safeParse(JSON.parse(await
|
|
24949
|
+
const parsed = UpdateStateSchema.safeParse(JSON.parse(await readFile29(statePath(), "utf8")));
|
|
24244
24950
|
return parsed.success ? parsed.data : null;
|
|
24245
24951
|
} catch {
|
|
24246
24952
|
return null;
|
|
@@ -24248,7 +24954,7 @@ async function readUpdateState() {
|
|
|
24248
24954
|
}
|
|
24249
24955
|
async function writeUpdateState(state) {
|
|
24250
24956
|
try {
|
|
24251
|
-
await
|
|
24957
|
+
await mkdir19(brandHome(), { recursive: true });
|
|
24252
24958
|
await writeThenRename(statePath(), `${JSON.stringify(state, null, 2)}
|
|
24253
24959
|
`);
|
|
24254
24960
|
} catch {
|
|
@@ -24304,7 +25010,7 @@ function shortMessage(err) {
|
|
|
24304
25010
|
// src/commands/update.ts
|
|
24305
25011
|
init_ui();
|
|
24306
25012
|
function updateCommand() {
|
|
24307
|
-
return new
|
|
25013
|
+
return new Command42("update").description("update memgineering itself").option("--check", "report what is available and change nothing").action(async (opts) => {
|
|
24308
25014
|
const inherited = process.env[UPDATE_CLAIM_ENV] || void 0;
|
|
24309
25015
|
try {
|
|
24310
25016
|
await runUpdate(opts, inherited);
|
|
@@ -24360,7 +25066,7 @@ async function runUpdate(opts, inherited) {
|
|
|
24360
25066
|
}
|
|
24361
25067
|
const held = await holdUpdateSlot(inherited);
|
|
24362
25068
|
if (held === null && await blockedBy() === "stuck") {
|
|
24363
|
-
const lock =
|
|
25069
|
+
const lock = join32(brandHome(), RECLAIM_LOCK);
|
|
24364
25070
|
const hint = `A previous update did not finish, and clearing what it left is blocked by ${lock}. If no memgineering update is running, delete that folder and run \`memgineering update\` again.`;
|
|
24365
25071
|
printDual({
|
|
24366
25072
|
json: { ...status, provenance: provenance.kind, updated: false, reason: "update_claim_stuck", hint },
|
|
@@ -24475,14 +25181,14 @@ function newClaimToken() {
|
|
|
24475
25181
|
}
|
|
24476
25182
|
async function claimOwner() {
|
|
24477
25183
|
try {
|
|
24478
|
-
return (await
|
|
25184
|
+
return (await readFile30(join32(brandHome(), "update-running"), "utf8")).trim() || null;
|
|
24479
25185
|
} catch {
|
|
24480
25186
|
return null;
|
|
24481
25187
|
}
|
|
24482
25188
|
}
|
|
24483
25189
|
async function releaseUpdateSlot(token) {
|
|
24484
25190
|
if (await claimOwner() !== token) return;
|
|
24485
|
-
await
|
|
25191
|
+
await unlink7(join32(brandHome(), "update-running")).catch(() => void 0);
|
|
24486
25192
|
}
|
|
24487
25193
|
async function holdUpdateSlot(inherited) {
|
|
24488
25194
|
if (inherited !== void 0 && await claimOwner() === inherited) return inherited;
|
|
@@ -24494,9 +25200,9 @@ async function holdUpdateSlot(inherited) {
|
|
|
24494
25200
|
var HOOK_VERBS = /* @__PURE__ */ new Set(["guard", "resurface"]);
|
|
24495
25201
|
var UPDATE_CLAIM_MS = 15 * 6e4;
|
|
24496
25202
|
async function claimUpdateSlot(token = newClaimToken(), hooks = {}) {
|
|
24497
|
-
const path =
|
|
25203
|
+
const path = join32(brandHome(), "update-running");
|
|
24498
25204
|
try {
|
|
24499
|
-
await
|
|
25205
|
+
await mkdir20(brandHome(), { recursive: true });
|
|
24500
25206
|
const handle = await open(path, "wx");
|
|
24501
25207
|
await handle.writeFile(`${token}
|
|
24502
25208
|
`);
|
|
@@ -24506,12 +25212,12 @@ async function claimUpdateSlot(token = newClaimToken(), hooks = {}) {
|
|
|
24506
25212
|
if (err?.code !== "EEXIST") return false;
|
|
24507
25213
|
}
|
|
24508
25214
|
try {
|
|
24509
|
-
if (Date.now() - (await
|
|
25215
|
+
if (Date.now() - (await stat10(path)).mtimeMs >= UPDATE_CLAIM_MS) {
|
|
24510
25216
|
await hooks.afterObserve?.();
|
|
24511
25217
|
await withReclaimLock(async () => {
|
|
24512
|
-
if (Date.now() - (await
|
|
25218
|
+
if (Date.now() - (await stat10(path)).mtimeMs < UPDATE_CLAIM_MS) return;
|
|
24513
25219
|
await hooks.afterRecheck?.();
|
|
24514
|
-
await
|
|
25220
|
+
await unlink7(path);
|
|
24515
25221
|
});
|
|
24516
25222
|
}
|
|
24517
25223
|
} catch {
|
|
@@ -24522,10 +25228,10 @@ var RECLAIM_LOCK = "update-running.reclaim";
|
|
|
24522
25228
|
var RECLAIM_LOCK_MAX_MS = 10 * 6e4;
|
|
24523
25229
|
async function withReclaimLock(fn) {
|
|
24524
25230
|
const home = brandHome();
|
|
24525
|
-
const lock =
|
|
24526
|
-
const staging =
|
|
24527
|
-
await
|
|
24528
|
-
await writeFile16(
|
|
25231
|
+
const lock = join32(home, RECLAIM_LOCK);
|
|
25232
|
+
const staging = join32(home, `${RECLAIM_LOCK}.${process.pid}.${randomBytes2(4).toString("hex")}`);
|
|
25233
|
+
await mkdir20(staging, { recursive: true });
|
|
25234
|
+
await writeFile16(join32(staging, "owner"), `${process.pid} ${Date.now()}
|
|
24529
25235
|
`);
|
|
24530
25236
|
try {
|
|
24531
25237
|
await rename5(staging, lock);
|
|
@@ -24543,11 +25249,11 @@ async function withReclaimLock(fn) {
|
|
|
24543
25249
|
}
|
|
24544
25250
|
async function breakAbandonedLock(lock) {
|
|
24545
25251
|
try {
|
|
24546
|
-
const seen = (await
|
|
25252
|
+
const seen = (await readFile30(join32(lock, "owner"), "utf8")).trim();
|
|
24547
25253
|
if (!lockAbandoned(seen)) return;
|
|
24548
25254
|
const aside = `${lock}.dead.${randomBytes2(4).toString("hex")}`;
|
|
24549
25255
|
await rename5(lock, aside);
|
|
24550
|
-
const moved = (await
|
|
25256
|
+
const moved = (await readFile30(join32(aside, "owner"), "utf8").catch(() => "")).trim();
|
|
24551
25257
|
if (moved !== seen) {
|
|
24552
25258
|
await rename5(aside, lock).catch(() => void 0);
|
|
24553
25259
|
return;
|
|
@@ -24571,9 +25277,9 @@ function lockAbandoned(owner, now = Date.now()) {
|
|
|
24571
25277
|
}
|
|
24572
25278
|
async function blockedBy() {
|
|
24573
25279
|
try {
|
|
24574
|
-
const old = Date.now() - (await
|
|
25280
|
+
const old = Date.now() - (await stat10(join32(brandHome(), "update-running"))).mtimeMs >= UPDATE_CLAIM_MS;
|
|
24575
25281
|
if (old) {
|
|
24576
|
-
await
|
|
25282
|
+
await stat10(join32(brandHome(), RECLAIM_LOCK));
|
|
24577
25283
|
return "stuck";
|
|
24578
25284
|
}
|
|
24579
25285
|
} catch {
|
|
@@ -24605,16 +25311,17 @@ function reportBelowMinimum(below) {
|
|
|
24605
25311
|
|
|
24606
25312
|
// src/commands/undo.ts
|
|
24607
25313
|
init_src();
|
|
24608
|
-
import { readFile as
|
|
24609
|
-
import { join as
|
|
24610
|
-
import { Command as
|
|
25314
|
+
import { readFile as readFile31, rm as rm9 } from "fs/promises";
|
|
25315
|
+
import { join as join33 } from "path";
|
|
25316
|
+
import { Command as Command43 } from "commander";
|
|
25317
|
+
init_walk();
|
|
24611
25318
|
init_atomic();
|
|
24612
25319
|
init_errors();
|
|
24613
25320
|
init_cloud_brain();
|
|
24614
25321
|
init_vault();
|
|
24615
25322
|
init_ui();
|
|
24616
25323
|
function undoCommand() {
|
|
24617
|
-
return new
|
|
25324
|
+
return new Command43("undo").description("take back the last change, or a named one").argument("[op]", "operation id (default: the most recent)").option("--reason <text>", "why it is being taken back \u2014 kept in the ledger").option("--vault <path>", "which brain to act on").option("--local", "act on the brain on this machine, even when signed in to a hosted one").action(
|
|
24618
25325
|
async (opId, opts) => {
|
|
24619
25326
|
const rationale = sanitizeRationale(opts.reason);
|
|
24620
25327
|
const where = await resolveTarget({
|
|
@@ -24703,8 +25410,8 @@ ${matches.slice(0, 8).map((id) => ` ${id}`).join("\n")}${matches.length > 8 ? "
|
|
|
24703
25410
|
);
|
|
24704
25411
|
}
|
|
24705
25412
|
const record = await withWriteLock(brain.root, async () => {
|
|
24706
|
-
const absolute =
|
|
24707
|
-
const current = await
|
|
25413
|
+
const absolute = await containedTarget(brain.root, target);
|
|
25414
|
+
const current = await readFile31(absolute, "utf8").catch(() => null);
|
|
24708
25415
|
const actualHash = current === null ? null : hashContent(current);
|
|
24709
25416
|
if (actualHash !== target.hash_after) {
|
|
24710
25417
|
throw memgError(
|
|
@@ -24713,7 +25420,7 @@ ${matches.slice(0, 8).map((id) => ` ${id}`).join("\n")}${matches.length > 8 ? "
|
|
|
24713
25420
|
await conflictHint(brain.root, target)
|
|
24714
25421
|
);
|
|
24715
25422
|
}
|
|
24716
|
-
const reverted = await reverse(brain, target, current);
|
|
25423
|
+
const reverted = await reverse(brain, target, absolute, current);
|
|
24717
25424
|
return appendOp(brain.root, {
|
|
24718
25425
|
verb: "undo",
|
|
24719
25426
|
target: target.target,
|
|
@@ -24765,8 +25472,7 @@ function minutesSince(iso) {
|
|
|
24765
25472
|
if (!Number.isFinite(at)) return null;
|
|
24766
25473
|
return Math.max(0, Math.floor((Date.now() - at) / 6e4));
|
|
24767
25474
|
}
|
|
24768
|
-
async function reverse(brain, op, current) {
|
|
24769
|
-
const absolute = join32(brain.root, op.target);
|
|
25475
|
+
async function reverse(brain, op, absolute, current) {
|
|
24770
25476
|
if (op.verb === "remember") {
|
|
24771
25477
|
if (current === null) {
|
|
24772
25478
|
throw memgError(
|
|
@@ -24818,12 +25524,25 @@ async function reverse(brain, op, current) {
|
|
|
24818
25524
|
}
|
|
24819
25525
|
return reverted;
|
|
24820
25526
|
}
|
|
25527
|
+
async function containedTarget(root, op) {
|
|
25528
|
+
try {
|
|
25529
|
+
return await resolveRealInside(root, op.target);
|
|
25530
|
+
} catch (err) {
|
|
25531
|
+
const code = err.code;
|
|
25532
|
+
if (code === "ENOENT" || code === "ENOTDIR") return resolveInside(root, op.target);
|
|
25533
|
+
throw memgError(
|
|
25534
|
+
"ledger_divergence",
|
|
25535
|
+
`${oneLine(op.op_id, WIDTH.handle)} names a path outside this brain, or one that is not a plain file path inside it`,
|
|
25536
|
+
"The ledger names a path outside this brain (or one reached through a symlink), so that line was not acted on and nothing was created, changed or removed. This tool only records files inside the brain, so the line was added or edited by something else. `memgineering log --verbose` shows what the ledger says; check who can write this brain's folder, and do not undo by id until the line is explained."
|
|
25537
|
+
);
|
|
25538
|
+
}
|
|
25539
|
+
}
|
|
24821
25540
|
async function conflictHint(vaultRoot, op) {
|
|
24822
25541
|
const base2 = `Nothing was changed. Someone \u2014 you, an editor, or a sync \u2014 has written to that file since.
|
|
24823
25542
|
Read what it says now, then decide what should stay.`;
|
|
24824
25543
|
const snapshot = await readSnapshot(vaultRoot, op.op_id);
|
|
24825
25544
|
return snapshot === null ? base2 : `${base2}
|
|
24826
|
-
The text from before that change is still on this machine: ${
|
|
25545
|
+
The text from before that change is still on this machine: ${join33(snapshotDir(vaultRoot), `${op.op_id}.txt`)}`;
|
|
24827
25546
|
}
|
|
24828
25547
|
|
|
24829
25548
|
// src/commands/brains.ts
|
|
@@ -24832,11 +25551,11 @@ init_api_client();
|
|
|
24832
25551
|
init_cloud_brain();
|
|
24833
25552
|
init_config();
|
|
24834
25553
|
init_ui();
|
|
24835
|
-
import { Command as
|
|
25554
|
+
import { Command as Command44 } from "commander";
|
|
24836
25555
|
import stringWidth from "string-width";
|
|
24837
25556
|
var NAME_WIDTH2 = 48;
|
|
24838
25557
|
function brainsCommand() {
|
|
24839
|
-
return new
|
|
25558
|
+
return new Command44("brains").description("list the hosted brains on your account, and which one this machine reads").addHelpText(
|
|
24840
25559
|
"after",
|
|
24841
25560
|
"\nReads only. `memgineering use --brain <name>` points this machine at one of\nthem. `memgineering create <name>` makes a new empty one, and\n`push --brain <name>` makes one from a folder on this machine."
|
|
24842
25561
|
).action(async () => {
|
|
@@ -24916,7 +25635,7 @@ init_credentials();
|
|
|
24916
25635
|
init_cloud_brain();
|
|
24917
25636
|
init_config();
|
|
24918
25637
|
import { isAbsolute as isAbsolute5, relative as relative2, resolve as resolve16 } from "path";
|
|
24919
|
-
import { Command as
|
|
25638
|
+
import { Command as Command45 } from "commander";
|
|
24920
25639
|
init_vault();
|
|
24921
25640
|
init_ui();
|
|
24922
25641
|
function lostDefaultLines(missing) {
|
|
@@ -24935,7 +25654,7 @@ var VIA_MEANS = {
|
|
|
24935
25654
|
default: "because it is your default brain (`memgineering use --default <path>` changes it)"
|
|
24936
25655
|
};
|
|
24937
25656
|
function useCommand() {
|
|
24938
|
-
return new
|
|
25657
|
+
return new Command45("use").description(
|
|
24939
25658
|
"say which brain answers here \u2014 `--brain <name>` for the whole machine, or a path to bind this folder"
|
|
24940
25659
|
).argument("[brain]", "path to the brain \u2014 omit to show what this folder resolves to").option("--brain <name>", "point this machine at a hosted brain, by its name or id").option("--here <dir>", "write the pointer in this directory instead of the cwd").option(
|
|
24941
25660
|
"--default",
|
|
@@ -25243,9 +25962,9 @@ async function pointAtHosted(named, opts, path) {
|
|
|
25243
25962
|
// src/commands/whoami.ts
|
|
25244
25963
|
init_api_client();
|
|
25245
25964
|
init_ui();
|
|
25246
|
-
import { Command as
|
|
25965
|
+
import { Command as Command46 } from "commander";
|
|
25247
25966
|
function whoamiCommand() {
|
|
25248
|
-
return new
|
|
25967
|
+
return new Command46("whoami").description("show which account this machine is signed in as").action(async () => {
|
|
25249
25968
|
const base2 = apiUrl();
|
|
25250
25969
|
const credentials = await requireCredentials(base2);
|
|
25251
25970
|
const res = await apiRequest({
|
|
@@ -25320,7 +26039,7 @@ var NO_FLAT_ALIAS = new Set(HOMONYM_VERBS);
|
|
|
25320
26039
|
// src/program.ts
|
|
25321
26040
|
init_version();
|
|
25322
26041
|
function buildProgram() {
|
|
25323
|
-
const program = new
|
|
26042
|
+
const program = new Command47("memgineering").version(VERSION).description("memgineering \u2014 one memory for the AI you connect").option("--json", "emit JSON to stdout instead of markdown", false).hook("preAction", async (thisCommand, actionCommand) => {
|
|
25324
26043
|
const opts = thisCommand.optsWithGlobals();
|
|
25325
26044
|
if (opts.json || process.env[BRAND.jsonEnvVar] === "1") setJsonMode(true);
|
|
25326
26045
|
await announceNextStep(commandPath(actionCommand), "verb");
|
|
@@ -25349,7 +26068,7 @@ function buildProgram() {
|
|
|
25349
26068
|
diffCommand,
|
|
25350
26069
|
listCommand
|
|
25351
26070
|
];
|
|
25352
|
-
const registry = new
|
|
26071
|
+
const registry = new Command47("registry").description(
|
|
25353
26072
|
"the public layer: find, read, adapt, publish, install and keep packages current"
|
|
25354
26073
|
);
|
|
25355
26074
|
for (const factory of publicLayer) registry.addCommand(factory());
|
|
@@ -25387,6 +26106,7 @@ function buildProgram() {
|
|
|
25387
26106
|
program.addCommand(setupCommand());
|
|
25388
26107
|
program.addCommand(loginCommand());
|
|
25389
26108
|
program.addCommand(logoutCommand());
|
|
26109
|
+
program.addCommand(deleteAccountCommand());
|
|
25390
26110
|
program.addCommand(whoamiCommand());
|
|
25391
26111
|
program.addCommand(updateCommand());
|
|
25392
26112
|
makeParseErrorsActionable(program);
|
|
@@ -25406,6 +26126,7 @@ var WITHOUT_NEXT_STEP = /* @__PURE__ */ new Set([
|
|
|
25406
26126
|
"setup",
|
|
25407
26127
|
"login",
|
|
25408
26128
|
"logout",
|
|
26129
|
+
"delete-account",
|
|
25409
26130
|
"whoami",
|
|
25410
26131
|
"update",
|
|
25411
26132
|
"guard",
|