mneme-ai 2.123.0 → 2.125.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `mneme outline <file>` (v2.124.0) — read a file's STRUCTURE for a fraction of
3
+ * the tokens, then fetch the EXACT slice you need.
4
+ *
5
+ * The honest answer to "context-loading hyper-inflation": instead of an agent
6
+ * Reading a whole 70-line (or 700-line) file into its context to orient itself,
7
+ * it reads the structural skeleton (every symbol + line range, bodies elided),
8
+ * then `--region <symbol|L1-L2>` fetches the byte-exact code only where it edits.
9
+ *
10
+ * mneme outline src/foo.ts # the skeleton (cheap orientation)
11
+ * mneme outline src/foo.ts --region add # byte-exact slice of `add`
12
+ * mneme outline src/foo.ts --region L40-L80 --json
13
+ */
14
+ import type { Command } from "commander";
15
+ export declare function registerOutlineCommands(program: Command): void;
16
+ //# sourceMappingURL=outline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../../src/commands/outline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASzC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkC9D"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * `mneme outline <file>` (v2.124.0) — read a file's STRUCTURE for a fraction of
3
+ * the tokens, then fetch the EXACT slice you need.
4
+ *
5
+ * The honest answer to "context-loading hyper-inflation": instead of an agent
6
+ * Reading a whole 70-line (or 700-line) file into its context to orient itself,
7
+ * it reads the structural skeleton (every symbol + line range, bodies elided),
8
+ * then `--region <symbol|L1-L2>` fetches the byte-exact code only where it edits.
9
+ *
10
+ * mneme outline src/foo.ts # the skeleton (cheap orientation)
11
+ * mneme outline src/foo.ts --region add # byte-exact slice of `add`
12
+ * mneme outline src/foo.ts --region L40-L80 --json
13
+ */
14
+ import { existsSync, readFileSync } from "node:fs";
15
+ import { resolve } from "node:path";
16
+ import { outline } from "@mneme-ai/core";
17
+ import { appendSaving } from "./savings.js";
18
+ function out(s) { process.stdout.write(s + "\n"); }
19
+ function outJson(o) { process.stdout.write(JSON.stringify(o, null, 2) + "\n"); }
20
+ export function registerOutlineCommands(program) {
21
+ program
22
+ .command("outline <file>")
23
+ .alias("glance")
24
+ .description("🔭 Read a file's STRUCTURE (every symbol + line range, bodies elided) for a fraction of the tokens, instead of loading the whole file. Multi-language (TS/JS/Python/Go/Rust/Java/C). `--region <symbol|L1-L2|a,b,...>` fetches the byte-EXACT slice(s) to edit. Orient cheap → edit exact.")
25
+ .option("--region <selector>", "byte-exact slice(s): a symbol name, an L<a>-L<b> range, or a comma-separated list of either (multi-region).")
26
+ .option("--json", "structured JSON output.")
27
+ .action((file, opts) => {
28
+ const cwd = process.cwd();
29
+ const p = resolve(cwd, file);
30
+ if (!existsSync(p)) {
31
+ out(`✗ file not found: ${file}`);
32
+ process.exitCode = 1;
33
+ return;
34
+ }
35
+ let src = "";
36
+ try {
37
+ src = readFileSync(p, "utf8");
38
+ }
39
+ catch (e) {
40
+ out(`✗ read failed: ${e.message}`);
41
+ process.exitCode = 1;
42
+ return;
43
+ }
44
+ if (opts.region) {
45
+ const r = outline.extractRegion(src, opts.region, { path: file });
46
+ if (!r.ok) {
47
+ out(`✗ ${r.note}`);
48
+ process.exitCode = 1;
49
+ return;
50
+ }
51
+ if (opts.json) {
52
+ outJson(r);
53
+ return;
54
+ }
55
+ out(`# ${file} · ${r.note}`);
56
+ out(r.text);
57
+ return;
58
+ }
59
+ const o = outline.extractOutline(src, { path: file });
60
+ const rendered = outline.renderOutline(o, { path: file });
61
+ const m = outline.measureReduction(src.length, rendered.length);
62
+ // record the measured saving into the signed treasury ledger (Pay-per-Token-Saved)
63
+ try {
64
+ appendSaving(cwd, { source: "outline", tokensBefore: m.estTokensBefore, tokensAfter: m.estTokensAfter });
65
+ }
66
+ catch { /* best-effort */ }
67
+ if (opts.json) {
68
+ outJson({ outline: o, rendered, measure: m });
69
+ return;
70
+ }
71
+ process.stdout.write(rendered);
72
+ out(`\n— ${o.symbolCount} symbols · ~${m.estTokensBefore} tok → ~${m.estTokensAfter} tok (${m.reductionPct}% less) · to edit: mneme outline ${file} --region <symbol|L1-L2>`);
73
+ out(` (${m.note})`);
74
+ });
75
+ }
76
+ //# sourceMappingURL=outline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outline.js","sourceRoot":"","sources":["../../src/commands/outline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,SAAS,GAAG,CAAC,CAAS,IAAU,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AACjE,SAAS,OAAO,CAAC,CAAU,IAAU,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAE/F,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,OAAO;SACJ,OAAO,CAAC,gBAAgB,CAAC;SACzB,KAAK,CAAC,QAAQ,CAAC;SACf,WAAW,CAAC,4RAA4R,CAAC;SACzS,MAAM,CAAC,qBAAqB,EAAE,6GAA6G,CAAC;SAC5I,MAAM,CAAC,QAAQ,EAAE,yBAAyB,CAAC;SAC3C,MAAM,CAAC,CAAC,IAAY,EAAE,IAAyC,EAAE,EAAE;QAClE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAC1B,M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Q,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,MAAM,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAChE,mFAAmF;QACnF,IAAI,CAAC;YAAC,YAAY,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC,eAAe,EAAE,WAAW,EAAE,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC;QAE7I,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;YAAC,OAAO;QAAC,CAAC;QACzE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC/B,GAAG,CAAC,OAAO,CAAC,CAAC,WAAW,eAAe,CAAC,CAAC,eAAe,WAAW,CAAC,CAAC,cAAc,SAAS,CAAC,CAAC,YAAY,oCAAoC,IAAI,0BAA0B,CAAC,CAAC;QAC9K,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqJA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAugNvD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsJA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAwgNvD"}
package/dist/index.js CHANGED
@@ -82,6 +82,7 @@ import { registerMapCommands } from "./commands/map.js";
82
82
  import { registerEgressCommands } from "./commands/egress.js";
83
83
  import { registerExecCommands } from "./commands/exec.js";
84
84
  import { registerBequestCommands } from "./commands/bequest.js";
85
+ import { registerOutlineCommands } from "./commands/outline.js";
85
86
  import { registerTrustCommands } from "./commands/trust.js";
86
87
  import { registerNuclearCommands } from "./commands/nuclear-cli.js";
87
88
  import { registerOvernightCommand } from "./commands/overnight.js";
@@ -4709,6 +4710,7 @@ export async function run(argv) {
4709
4710
  registerEgressCommands(program);
4710
4711
  registerExecCommands(program);
4711
4712
  registerBequestCommands(program);
4713
+ registerOutlineCommands(program);
4712
4714
  // ─── Trust calibrator (v1.31.0) -- per-subsystem precision/recall/band
4713
4715
  registerTrustCommands(program);
4714
4716
  // ─── Wisdom reactor (v1.33.0) -- five nuclear-physics formulas as Mneme metrics