amness 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +237 -2
  3. package/dist/cli/acpcli.d.ts +7 -0
  4. package/dist/cli/acpcli.js +14 -0
  5. package/dist/cli/amness.d.ts +2 -0
  6. package/dist/cli/amness.js +694 -0
  7. package/dist/cli/benchcli.d.ts +5 -0
  8. package/dist/cli/benchcli.js +160 -0
  9. package/dist/cli/config.d.ts +79 -0
  10. package/dist/cli/config.js +111 -0
  11. package/dist/cli/demo.d.ts +13 -0
  12. package/dist/cli/demo.js +44 -0
  13. package/dist/cli/detect.d.ts +2 -0
  14. package/dist/cli/detect.js +20 -0
  15. package/dist/cli/evalcli.d.ts +15 -0
  16. package/dist/cli/evalcli.js +198 -0
  17. package/dist/cli/format.d.ts +5 -0
  18. package/dist/cli/format.js +55 -0
  19. package/dist/cli/headless.d.ts +2 -0
  20. package/dist/cli/headless.js +169 -0
  21. package/dist/cli/keystore.d.ts +9 -0
  22. package/dist/cli/keystore.js +108 -0
  23. package/dist/cli/model.d.ts +11 -0
  24. package/dist/cli/model.js +19 -0
  25. package/dist/cli/plugincli.d.ts +2 -0
  26. package/dist/cli/plugincli.js +176 -0
  27. package/dist/cli/schedulecli.d.ts +2 -0
  28. package/dist/cli/schedulecli.js +66 -0
  29. package/dist/cli/state.d.ts +11 -0
  30. package/dist/cli/state.js +19 -0
  31. package/dist/cli/tui/ansi.d.ts +38 -0
  32. package/dist/cli/tui/ansi.js +142 -0
  33. package/dist/cli/tui/app.d.ts +328 -0
  34. package/dist/cli/tui/app.js +1358 -0
  35. package/dist/cli/tui/blocks.d.ts +151 -0
  36. package/dist/cli/tui/blocks.js +128 -0
  37. package/dist/cli/tui/brand.d.ts +9 -0
  38. package/dist/cli/tui/brand.js +16 -0
  39. package/dist/cli/tui/canvas.d.ts +92 -0
  40. package/dist/cli/tui/canvas.js +199 -0
  41. package/dist/cli/tui/cards.d.ts +44 -0
  42. package/dist/cli/tui/cards.js +215 -0
  43. package/dist/cli/tui/clipboard.d.ts +5 -0
  44. package/dist/cli/tui/clipboard.js +29 -0
  45. package/dist/cli/tui/commands.d.ts +10 -0
  46. package/dist/cli/tui/commands.js +650 -0
  47. package/dist/cli/tui/complete.d.ts +39 -0
  48. package/dist/cli/tui/complete.js +113 -0
  49. package/dist/cli/tui/custom.d.ts +9 -0
  50. package/dist/cli/tui/custom.js +34 -0
  51. package/dist/cli/tui/diffview.d.ts +25 -0
  52. package/dist/cli/tui/diffview.js +130 -0
  53. package/dist/cli/tui/editor.d.ts +60 -0
  54. package/dist/cli/tui/editor.js +230 -0
  55. package/dist/cli/tui/full.d.ts +86 -0
  56. package/dist/cli/tui/full.js +630 -0
  57. package/dist/cli/tui/keys.d.ts +31 -0
  58. package/dist/cli/tui/keys.js +134 -0
  59. package/dist/cli/tui/markdown.d.ts +37 -0
  60. package/dist/cli/tui/markdown.js +155 -0
  61. package/dist/cli/tui/mentions.d.ts +15 -0
  62. package/dist/cli/tui/mentions.js +48 -0
  63. package/dist/cli/tui/modal.d.ts +26 -0
  64. package/dist/cli/tui/modal.js +107 -0
  65. package/dist/cli/tui/overlays.d.ts +98 -0
  66. package/dist/cli/tui/overlays.js +237 -0
  67. package/dist/cli/tui/pager.d.ts +15 -0
  68. package/dist/cli/tui/pager.js +66 -0
  69. package/dist/cli/tui/pricing.d.ts +9 -0
  70. package/dist/cli/tui/pricing.js +23 -0
  71. package/dist/cli/tui/rich.d.ts +16 -0
  72. package/dist/cli/tui/rich.js +72 -0
  73. package/dist/cli/tui/screen.d.ts +30 -0
  74. package/dist/cli/tui/screen.js +62 -0
  75. package/dist/cli/tui/session.d.ts +77 -0
  76. package/dist/cli/tui/session.js +103 -0
  77. package/dist/cli/tui/sidebar.d.ts +84 -0
  78. package/dist/cli/tui/sidebar.js +114 -0
  79. package/dist/cli/tui/text.d.ts +15 -0
  80. package/dist/cli/tui/text.js +94 -0
  81. package/dist/cli/tui/theme.d.ts +59 -0
  82. package/dist/cli/tui/theme.js +148 -0
  83. package/dist/cli/tui/themes.d.ts +56 -0
  84. package/dist/cli/tui/themes.js +80 -0
  85. package/dist/cli/tui/tokens.d.ts +39 -0
  86. package/dist/cli/tui/tokens.js +71 -0
  87. package/dist/cli/tui/view.d.ts +60 -0
  88. package/dist/cli/tui/view.js +178 -0
  89. package/dist/cli/ui.d.ts +34 -0
  90. package/dist/cli/ui.js +224 -0
  91. package/dist/src/acp.d.ts +28 -0
  92. package/dist/src/acp.js +111 -0
  93. package/dist/src/agents.d.ts +23 -0
  94. package/dist/src/agents.js +71 -0
  95. package/dist/src/anthropic.d.ts +30 -0
  96. package/dist/src/anthropic.js +91 -0
  97. package/dist/src/approver.d.ts +15 -0
  98. package/dist/src/approver.js +40 -0
  99. package/dist/src/bench.d.ts +67 -0
  100. package/dist/src/bench.js +201 -0
  101. package/dist/src/bundle.d.ts +36 -0
  102. package/dist/src/bundle.js +55 -0
  103. package/dist/src/chaos.d.ts +15 -0
  104. package/dist/src/chaos.js +26 -0
  105. package/dist/src/code.d.ts +187 -0
  106. package/dist/src/code.js +590 -0
  107. package/dist/src/codeindex.d.ts +65 -0
  108. package/dist/src/codeindex.js +300 -0
  109. package/dist/src/deep.d.ts +62 -0
  110. package/dist/src/deep.js +177 -0
  111. package/dist/src/diff.d.ts +8 -0
  112. package/dist/src/diff.js +74 -0
  113. package/dist/src/dynamic.d.ts +42 -0
  114. package/dist/src/dynamic.js +133 -0
  115. package/dist/src/embed.d.ts +8 -0
  116. package/dist/src/embed.js +25 -0
  117. package/dist/src/evalcases.d.ts +11 -0
  118. package/dist/src/evalcases.js +196 -0
  119. package/dist/src/evals.d.ts +197 -0
  120. package/dist/src/evals.js +340 -0
  121. package/dist/src/gitflow.d.ts +27 -0
  122. package/dist/src/gitflow.js +56 -0
  123. package/dist/src/grade.d.ts +42 -0
  124. package/dist/src/grade.js +96 -0
  125. package/dist/src/guidance.d.ts +15 -0
  126. package/dist/src/guidance.js +68 -0
  127. package/dist/src/hardcases.d.ts +2 -0
  128. package/dist/src/hardcases.js +94 -0
  129. package/dist/src/harness.d.ts +411 -0
  130. package/dist/src/harness.js +725 -0
  131. package/dist/src/hooks.d.ts +44 -0
  132. package/dist/src/hooks.js +116 -0
  133. package/dist/src/images.d.ts +13 -0
  134. package/dist/src/images.js +27 -0
  135. package/dist/src/index.d.ts +57 -0
  136. package/dist/src/index.js +57 -0
  137. package/dist/src/ledger.d.ts +58 -0
  138. package/dist/src/ledger.js +78 -0
  139. package/dist/src/live.d.ts +16 -0
  140. package/dist/src/live.js +80 -0
  141. package/dist/src/lsp.d.ts +31 -0
  142. package/dist/src/lsp.js +147 -0
  143. package/dist/src/memory.d.ts +128 -0
  144. package/dist/src/memory.js +390 -0
  145. package/dist/src/metrics.d.ts +3 -0
  146. package/dist/src/metrics.js +42 -0
  147. package/dist/src/mining.d.ts +49 -0
  148. package/dist/src/mining.js +126 -0
  149. package/dist/src/openai.d.ts +50 -0
  150. package/dist/src/openai.js +307 -0
  151. package/dist/src/parallel.d.ts +66 -0
  152. package/dist/src/parallel.js +135 -0
  153. package/dist/src/patch.d.ts +45 -0
  154. package/dist/src/patch.js +219 -0
  155. package/dist/src/permissions.d.ts +46 -0
  156. package/dist/src/permissions.js +245 -0
  157. package/dist/src/plugins.d.ts +148 -0
  158. package/dist/src/plugins.js +225 -0
  159. package/dist/src/pluginscan.d.ts +8 -0
  160. package/dist/src/pluginscan.js +20 -0
  161. package/dist/src/procs.d.ts +41 -0
  162. package/dist/src/procs.js +94 -0
  163. package/dist/src/profiles.d.ts +36 -0
  164. package/dist/src/profiles.js +61 -0
  165. package/dist/src/progress.d.ts +29 -0
  166. package/dist/src/progress.js +75 -0
  167. package/dist/src/prompts.d.ts +10 -0
  168. package/dist/src/prompts.js +28 -0
  169. package/dist/src/ratelimit.d.ts +34 -0
  170. package/dist/src/ratelimit.js +116 -0
  171. package/dist/src/replay.d.ts +25 -0
  172. package/dist/src/replay.js +99 -0
  173. package/dist/src/review.d.ts +20 -0
  174. package/dist/src/review.js +49 -0
  175. package/dist/src/route.d.ts +9 -0
  176. package/dist/src/route.js +30 -0
  177. package/dist/src/router.d.ts +61 -0
  178. package/dist/src/router.js +126 -0
  179. package/dist/src/sandbox.d.ts +13 -0
  180. package/dist/src/sandbox.js +68 -0
  181. package/dist/src/schedule.d.ts +20 -0
  182. package/dist/src/schedule.js +59 -0
  183. package/dist/src/schema.d.ts +13 -0
  184. package/dist/src/schema.js +36 -0
  185. package/dist/src/secrets.d.ts +10 -0
  186. package/dist/src/secrets.js +41 -0
  187. package/dist/src/shell.d.ts +34 -0
  188. package/dist/src/shell.js +95 -0
  189. package/dist/src/skills.d.ts +20 -0
  190. package/dist/src/skills.js +112 -0
  191. package/dist/src/snapshot.d.ts +20 -0
  192. package/dist/src/snapshot.js +93 -0
  193. package/dist/src/stats.d.ts +24 -0
  194. package/dist/src/stats.js +62 -0
  195. package/dist/src/strategies.d.ts +16 -0
  196. package/dist/src/strategies.js +35 -0
  197. package/dist/src/suites.d.ts +30 -0
  198. package/dist/src/suites.js +112 -0
  199. package/dist/src/trace.d.ts +63 -0
  200. package/dist/src/trace.js +153 -0
  201. package/dist/src/tune.d.ts +38 -0
  202. package/dist/src/tune.js +49 -0
  203. package/dist/src/web.d.ts +19 -0
  204. package/dist/src/web.js +56 -0
  205. package/dist/src/worktree.d.ts +24 -0
  206. package/dist/src/worktree.js +85 -0
  207. package/docs/agent-loop.md +222 -0
  208. package/docs/architecture.md +228 -0
  209. package/docs/bench.md +292 -0
  210. package/docs/budgets.md +185 -0
  211. package/docs/build-your-own-harness.md +424 -0
  212. package/docs/cookbook.md +375 -0
  213. package/docs/development.md +150 -0
  214. package/docs/evaluation.md +450 -0
  215. package/docs/features.md +1320 -0
  216. package/docs/getting-started.md +205 -0
  217. package/docs/headless.md +188 -0
  218. package/docs/images/approval.png +0 -0
  219. package/docs/images/chat.png +0 -0
  220. package/docs/images/daylight.png +0 -0
  221. package/docs/images/loop.png +0 -0
  222. package/docs/images/palette.png +0 -0
  223. package/docs/images/running.png +0 -0
  224. package/docs/images/subagent-done.png +0 -0
  225. package/docs/images/subagent-running.png +0 -0
  226. package/docs/images/welcome.png +0 -0
  227. package/docs/index.md +25 -0
  228. package/docs/library.md +267 -0
  229. package/docs/plugins.md +691 -0
  230. package/docs/providers.md +175 -0
  231. package/docs/safety.md +250 -0
  232. package/docs/usage.md +348 -0
  233. package/docs/why.md +155 -0
  234. package/docs/writing-guide.md +39 -0
  235. package/package.json +66 -4
@@ -0,0 +1,147 @@
1
+ // Language-server diagnostics after edits: the compiler's opinion of the file you just changed, one step after the edit instead of at the end of the task. A tiny LSP client over stdio
2
+ // (no dependencies). Servers are started lazily, only when one is installed, kept alive between edits and stopped on dispose(). Errors only, capped, and silent when all is well.
3
+ import { spawn, spawnSync } from "node:child_process";
4
+ import { existsSync, readFileSync } from "node:fs";
5
+ import { extname, resolve } from "node:path";
6
+ import { pathToFileURL } from "node:url";
7
+ export const DEFAULT_SERVERS = [
8
+ { name: "typescript", command: "typescript-language-server", args: ["--stdio"], extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"], languageId: (e) => ({ ".ts": "typescript", ".tsx": "typescriptreact", ".jsx": "javascriptreact", ".mts": "typescript", ".cts": "typescript" })[e] ?? "javascript" },
9
+ { name: "python", command: "pyright-langserver", args: ["--stdio"], extensions: [".py"], languageId: () => "python" },
10
+ { name: "go", command: "gopls", args: [], extensions: [".go"], languageId: () => "go" },
11
+ { name: "rust", command: "rust-analyzer", args: [], extensions: [".rs"], languageId: () => "rust" },
12
+ ];
13
+ const onPath = (bin) => spawnSync(process.platform === "win32" ? "where" : "which", [bin], { stdio: "ignore" }).status === 0;
14
+ class Client {
15
+ p;
16
+ buf = Buffer.alloc(0);
17
+ id = 0;
18
+ pending = new Map();
19
+ diags = new Map();
20
+ versions = new Map();
21
+ ready;
22
+ dead = false;
23
+ server;
24
+ root;
25
+ constructor(server, root) {
26
+ this.server = server;
27
+ this.root = root;
28
+ this.p = spawn(server.command, server.args, { cwd: root, stdio: ["pipe", "pipe", "ignore"] });
29
+ this.p.on("error", () => { this.dead = true; });
30
+ this.p.on("close", () => { this.dead = true; for (const w of this.pending.values())
31
+ w(undefined); });
32
+ this.p.stdout.on("data", (d) => this.onData(d));
33
+ this.p.stdin.on("error", () => { this.dead = true; });
34
+ this.ready = this.request("initialize", { processId: process.pid, rootUri: pathToFileURL(root).href, capabilities: { textDocument: { publishDiagnostics: { relatedInformation: false }, synchronization: { didSave: true } } }, workspaceFolders: [{ uri: pathToFileURL(root).href, name: "ws" }] }, 15_000).then((r) => { if (!r)
35
+ return false; this.notify("initialized", {}); return true; });
36
+ }
37
+ send(msg) { if (this.dead)
38
+ return; const body = JSON.stringify({ jsonrpc: "2.0", ...msg }); this.p.stdin.write(`Content-Length: ${Buffer.byteLength(body)}\r\n\r\n${body}`); }
39
+ notify(method, params) { this.send({ method, params }); }
40
+ request(method, params, timeout = 8000) {
41
+ if (this.dead)
42
+ return Promise.resolve(undefined);
43
+ return new Promise((res) => { const id = ++this.id, t = setTimeout(() => { this.pending.delete(id); res(undefined); }, timeout); this.pending.set(id, (v) => { clearTimeout(t); res(v); }); this.send({ id, method, params }); });
44
+ }
45
+ onData(d) {
46
+ this.buf = Buffer.concat([this.buf, d]);
47
+ for (;;) {
48
+ const h = this.buf.indexOf("\r\n\r\n");
49
+ if (h < 0)
50
+ return;
51
+ const m = /Content-Length:\s*(\d+)/i.exec(this.buf.slice(0, h).toString());
52
+ if (!m) {
53
+ this.buf = this.buf.slice(h + 4);
54
+ continue;
55
+ }
56
+ const len = Number(m[1]), end = h + 4 + len;
57
+ if (this.buf.length < end)
58
+ return;
59
+ const body = this.buf.slice(h + 4, end).toString("utf8");
60
+ this.buf = this.buf.slice(end);
61
+ let msg;
62
+ try {
63
+ msg = JSON.parse(body);
64
+ }
65
+ catch {
66
+ continue;
67
+ }
68
+ if (msg.id !== undefined && msg.method)
69
+ this.send({ id: msg.id, result: null }); // a request from the server (configuration, registerCapability...): acknowledge it
70
+ else if (msg.id !== undefined)
71
+ this.pending.get(msg.id)?.(msg.result ?? {}), this.pending.delete(msg.id);
72
+ else if (msg.method === "textDocument/publishDiagnostics") {
73
+ const uri = msg.params.uri, e = this.diags.get(uri) ?? { version: 0, list: [], waiters: [] };
74
+ e.list = (msg.params.diagnostics ?? []).map((x) => ({ line: (x.range?.start?.line ?? 0) + 1, col: (x.range?.start?.character ?? 0) + 1, message: String(x.message ?? "").split("\n")[0], severity: x.severity ?? 1, source: x.source }));
75
+ e.version++;
76
+ this.diags.set(uri, e);
77
+ for (const w of e.waiters.splice(0))
78
+ w();
79
+ }
80
+ }
81
+ }
82
+ /** Tell the server about the file's new content and wait (briefly) for its verdict. */
83
+ async check(file, languageId, ms = 5000) {
84
+ if (!(await this.ready) || this.dead)
85
+ return undefined;
86
+ const uri = pathToFileURL(file).href, text = readFileSync(file, "utf8"), v = (this.versions.get(uri) ?? 0) + 1, had = this.versions.has(uri);
87
+ this.versions.set(uri, v);
88
+ const e = this.diags.get(uri) ?? { version: 0, list: [], waiters: [] };
89
+ this.diags.set(uri, e);
90
+ const before = e.version;
91
+ if (!had)
92
+ this.notify("textDocument/didOpen", { textDocument: { uri, languageId, version: v, text } });
93
+ else {
94
+ this.notify("textDocument/didChange", { textDocument: { uri, version: v }, contentChanges: [{ text }] });
95
+ this.notify("textDocument/didSave", { textDocument: { uri }, text });
96
+ }
97
+ if (e.version === before)
98
+ await new Promise((res) => { const t = setTimeout(res, ms); e.waiters.push(() => { clearTimeout(t); setTimeout(res, 150); }); }); // a short grace period lets a second, fuller publish arrive
99
+ return e.version === before ? undefined : e.list;
100
+ }
101
+ async stop() { if (this.dead)
102
+ return; try {
103
+ await this.request("shutdown", {}, 1500);
104
+ this.notify("exit", {});
105
+ }
106
+ catch { /* gone */ } setTimeout(() => this.p.kill(), 300).unref(); }
107
+ }
108
+ export class Diagnostics {
109
+ clients = new Map();
110
+ root;
111
+ servers;
112
+ missing = new Set();
113
+ constructor(root, o = {}) { this.root = resolve(root); this.servers = o.servers ?? DEFAULT_SERVERS; }
114
+ /** Which server would handle this file, if one is installed. */
115
+ serverFor(path) { const ext = extname(path).toLowerCase(), s = this.servers.find((x) => x.extensions.includes(ext)); if (!s || this.missing.has(s.name))
116
+ return undefined; if (!onPath(s.command)) {
117
+ this.missing.add(s.name);
118
+ return undefined;
119
+ } return s; }
120
+ async errors(path) {
121
+ const s = this.serverFor(path);
122
+ if (!s)
123
+ return undefined;
124
+ const abs = resolve(this.root, path);
125
+ if (!existsSync(abs))
126
+ return undefined;
127
+ let c = this.clients.get(s.name);
128
+ if (!c || c.dead) {
129
+ c = new Client(s, this.root);
130
+ this.clients.set(s.name, c);
131
+ }
132
+ const all = await c.check(abs, s.languageId(extname(path).toLowerCase()));
133
+ return all?.filter((d) => d.severity === 1);
134
+ }
135
+ /** Text to append to an edit result: the errors the language server reports for these files, or "" when there are none (or no server). */
136
+ async report(paths) {
137
+ const out = [];
138
+ for (const p of [...new Set(paths)].slice(0, 4)) {
139
+ const errs = await this.errors(p).catch(() => undefined);
140
+ for (const d of (errs ?? []).slice(0, 6))
141
+ out.push(`${p}:${d.line}:${d.col} ${d.message}${d.source ? ` (${d.source})` : ""}`);
142
+ }
143
+ return out.length ? `\n\n[language server: ${out.length} error(s) in the file${new Set(paths).size > 1 ? "s" : ""} you just changed; fix them before moving on]\n${out.join("\n")}` : "";
144
+ }
145
+ async dispose() { await Promise.all([...this.clients.values()].map((c) => c.stop())); this.clients.clear(); }
146
+ installed() { return this.servers.filter((s) => onPath(s.command)).map((s) => s.name); }
147
+ }
@@ -0,0 +1,128 @@
1
+ import { type Embedder } from "./embed.ts";
2
+ import { type Model, type Tool } from "./harness.ts";
3
+ export type MemoryType = "user" | "project" | "feedback" | "reference";
4
+ export type Scope = "project" | "global";
5
+ export type MemoryEntry = {
6
+ name: string;
7
+ type: MemoryType;
8
+ description: string;
9
+ content: string;
10
+ scope: Scope;
11
+ updated: string; /** how often it was surfaced to the model */
12
+ hits?: number; /** last time it was surfaced (YYYY-MM-DD) */
13
+ used?: string; /** runs that used this note and ended well / badly: the evidence behind its ranking */
14
+ wins?: number;
15
+ losses?: number;
16
+ };
17
+ /** Chance a note helps, from the runs it was part of (Laplace-smoothed, so a new note starts at 0.5). */
18
+ export declare const utility: (e: {
19
+ wins?: number;
20
+ losses?: number;
21
+ }) => number;
22
+ /** Plain markdown files with frontmatter + a MEMORY.md index: human-editable, diffable, and portable between tools and machines. */
23
+ /**
24
+ * What the agent needs from a memory: save, find, list, forget, and the two places memory is injected (the first message of a conversation, and later messages).
25
+ * `MemoryStore` (files on disk, BM25 ranking, outcome learning) is the built-in one; a plugin can provide another (a vector database, a wiki, a ticket system).
26
+ */
27
+ export interface MemoryBackend {
28
+ list(): MemoryEntry[];
29
+ save(e: {
30
+ name: string;
31
+ type: MemoryType;
32
+ description: string;
33
+ content: string;
34
+ scope?: Scope;
35
+ }): MemoryEntry & {
36
+ merged?: string;
37
+ };
38
+ forget(name: string, scope?: Scope): boolean;
39
+ search(q: string, n?: number): MemoryEntry[] | Promise<MemoryEntry[]>;
40
+ /** notes to add to the first message of a conversation (empty string for none) */
41
+ context(task: string, maxChars?: number, seen?: Set<string>): string;
42
+ /** only the notes that are new and relevant for a follow-up message (so the cached prefix stays intact) */
43
+ delta(text: string, seen: Set<string>): string;
44
+ /** the run ended: true = finished and verified, false = gave up or got stuck, undefined = unknown (a backend can learn from this) */
45
+ endTurn(success: boolean | undefined): void;
46
+ /** optional: prepare a semantic search for this query */
47
+ warmQuery?(q: string): Promise<void>;
48
+ }
49
+ export declare const isMemoryBackend: (x: unknown) => x is MemoryBackend;
50
+ export declare class MemoryStore implements MemoryBackend {
51
+ dirs: Partial<Record<Scope, string>>;
52
+ /** Optional: enables semantic (embedding) retrieval on top of BM25. */
53
+ embedder?: Embedder;
54
+ private qv;
55
+ private vecs;
56
+ private turn;
57
+ constructor(dirs: Partial<Record<Scope, string>>);
58
+ static forWorkspace(cwd: string, globalDir?: string): MemoryStore;
59
+ list(): MemoryEntry[];
60
+ private write;
61
+ /**
62
+ * Save a note. A note that says nearly the same thing as an existing one (same type and scope) updates that note instead of piling up
63
+ * duplicates; the newer wording wins, and `merged` names the note that was updated.
64
+ */
65
+ save(e: {
66
+ name: string;
67
+ type: MemoryType;
68
+ description: string;
69
+ content: string;
70
+ scope?: Scope;
71
+ }): MemoryEntry & {
72
+ merged?: string;
73
+ };
74
+ forget(name: string, scope?: Scope): boolean;
75
+ private reindex;
76
+ /** BM25 over name, description and content (name and description count extra), nudged by how often a note has proved useful and how fresh it is. */
77
+ rank(q: string, from?: MemoryEntry[]): {
78
+ e: MemoryEntry;
79
+ score: number;
80
+ }[];
81
+ private vecFile;
82
+ /** Embed notes that have no current vector. Call before retrieval when an embedder is set; failures are ignored (BM25 still works). */
83
+ index(): Promise<number>;
84
+ /** Embed a query so the next (synchronous) rank() for the same text can use semantic similarity. */
85
+ warmQuery(q: string): Promise<void>;
86
+ /** Close a turn: credit (or blame) every note surfaced since the last call. `undefined` = inconclusive (a chat reply), nothing changes. */
87
+ endTurn(success: boolean | undefined): void;
88
+ search(q: string, n?: number): MemoryEntry[];
89
+ private linksFile;
90
+ private readLinks;
91
+ /** Notes tied to `e`: ones it links with [[name]], ones that link to it, and ones that were retrieved together with it at least twice. */
92
+ neighbors(e: MemoryEntry, all?: MemoryEntry[]): MemoryEntry[];
93
+ private coRetrieved;
94
+ /** Move a note out of the active set without deleting it (reversible forgetting). */
95
+ archive(name: string): boolean;
96
+ /**
97
+ * Ask a model to tidy memory (Infini Memory style maintenance): merge notes about one topic, drop ones that are obsolete or contradicted by newer ones.
98
+ * Returns a PLAN and changes nothing; show it to the user, then `applyPlan`.
99
+ */
100
+ consolidate(model: Model): Promise<ConsolidationPlan>;
101
+ applyPlan(plan: ConsolidationPlan): {
102
+ merged: number;
103
+ archived: number;
104
+ };
105
+ /** Record that these notes were surfaced to the model (feeds ranking and the decision to forget). */
106
+ touch(es: MemoryEntry[]): void;
107
+ /** Notes that were never useful (older than `days`, surfaced at most once) or that keep showing up in runs that fail (4+ runs, under 25% good). */
108
+ stale(days?: number): MemoryEntry[];
109
+ /** Forgetting that can be undone: stale notes move to an `archive/` folder next to the notes. */
110
+ prune(days?: number): string[];
111
+ /** Text to put in front of the model: the full index plus the few entries most relevant to the task. Framed as data, not orders. */
112
+ context(task: string, maxChars?: number, seen?: Set<string>): string;
113
+ /**
114
+ * Later turns of a conversation: only notes that match the new message and were not shown yet, appended at the END of that message.
115
+ * (The earlier part of the conversation never changes, so the provider's prompt cache keeps hitting.)
116
+ */
117
+ delta(text: string, seen: Set<string>, minScore?: number): string;
118
+ }
119
+ export type ConsolidationPlan = {
120
+ merges: {
121
+ keep: string;
122
+ from: string[];
123
+ description: string;
124
+ content: string;
125
+ }[];
126
+ archive: string[];
127
+ };
128
+ export declare function memoryTools(store: MemoryBackend, onSave?: (e: MemoryEntry) => void): Tool[];