mneme-ai 2.125.0 → 2.126.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 scaffold` (v2.126.0) — the honest core of "Blueprint Inflation": an
|
|
3
|
+
* agent emits a tiny spec, Mneme expands it into deterministic boilerplate
|
|
4
|
+
* locally (no syntax errors, no re-typing), saving OUTPUT tokens.
|
|
5
|
+
*
|
|
6
|
+
* HONEST scope: KNOWN templates only (ts-model + CRUD, test-skeleton, config).
|
|
7
|
+
* It does NOT generate arbitrary business logic — it leaves TODO markers exactly
|
|
8
|
+
* where you must write the real logic.
|
|
9
|
+
*
|
|
10
|
+
* mneme scaffold --spec '{"kind":"ts-model","model":"User","fields":{"id":"string","email":"string"},"crud":true}'
|
|
11
|
+
* mneme scaffold --spec-file blueprint.json --out src/ # write the files
|
|
12
|
+
* mneme scaffold --spec '{"kind":"config","format":"env","entries":{"port":3000}}' --json
|
|
13
|
+
*/
|
|
14
|
+
import type { Command } from "commander";
|
|
15
|
+
export declare function registerScaffoldCommands(program: Command): void;
|
|
16
|
+
//# sourceMappingURL=scaffold.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../src/commands/scaffold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASzC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmC/D"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mneme scaffold` (v2.126.0) — the honest core of "Blueprint Inflation": an
|
|
3
|
+
* agent emits a tiny spec, Mneme expands it into deterministic boilerplate
|
|
4
|
+
* locally (no syntax errors, no re-typing), saving OUTPUT tokens.
|
|
5
|
+
*
|
|
6
|
+
* HONEST scope: KNOWN templates only (ts-model + CRUD, test-skeleton, config).
|
|
7
|
+
* It does NOT generate arbitrary business logic — it leaves TODO markers exactly
|
|
8
|
+
* where you must write the real logic.
|
|
9
|
+
*
|
|
10
|
+
* mneme scaffold --spec '{"kind":"ts-model","model":"User","fields":{"id":"string","email":"string"},"crud":true}'
|
|
11
|
+
* mneme scaffold --spec-file blueprint.json --out src/ # write the files
|
|
12
|
+
* mneme scaffold --spec '{"kind":"config","format":"env","entries":{"port":3000}}' --json
|
|
13
|
+
*/
|
|
14
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
15
|
+
import { resolve, join, dirname } from "node:path";
|
|
16
|
+
import { scaffold } 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 registerScaffoldCommands(program) {
|
|
21
|
+
program
|
|
22
|
+
.command("scaffold")
|
|
23
|
+
.description("🧱 Expand a compact SPEC into deterministic boilerplate locally (saves OUTPUT tokens). KNOWN templates only: ts-model (+CRUD), test-skeleton, config — leaves TODO markers where YOU write the real logic. NOT a generator of arbitrary business logic.")
|
|
24
|
+
.option("--spec <json>", "the blueprint spec as inline JSON.")
|
|
25
|
+
.option("--spec-file <path>", "read the spec JSON from a file.")
|
|
26
|
+
.option("--out <dir>", "write the generated files under this dir (else print to stdout).")
|
|
27
|
+
.option("--json", "structured JSON output (files + measured saving).")
|
|
28
|
+
.action((opts) => {
|
|
29
|
+
let raw = opts.spec;
|
|
30
|
+
if (!raw && opts.specFile) {
|
|
31
|
+
try {
|
|
32
|
+
if (existsSync(opts.specFile))
|
|
33
|
+
raw = readFileSync(opts.specFile, "utf8");
|
|
34
|
+
}
|
|
35
|
+
catch { /* */ }
|
|
36
|
+
}
|
|
37
|
+
if (!raw) {
|
|
38
|
+
out("✗ provide --spec '<json>' or --spec-file <path>");
|
|
39
|
+
process.exitCode = 1;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
let spec;
|
|
43
|
+
try {
|
|
44
|
+
spec = JSON.parse(raw);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
out(`✗ invalid spec JSON: ${e.message}`);
|
|
48
|
+
process.exitCode = 1;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const r = scaffold.scaffold(spec);
|
|
52
|
+
if (!r.ok) {
|
|
53
|
+
out(`✗ ${r.error ?? "scaffold failed"}`);
|
|
54
|
+
out(` ${r.note}`);
|
|
55
|
+
process.exitCode = 1;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
// record the OUTPUT-token saving into the signed treasury ledger
|
|
59
|
+
try {
|
|
60
|
+
appendSaving(process.cwd(), { source: "scaffold", tokensBefore: r.measure.codeTokens, tokensAfter: r.measure.specTokens });
|
|
61
|
+
}
|
|
62
|
+
catch { /* */ }
|
|
63
|
+
if (opts.json) {
|
|
64
|
+
outJson(r);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (opts.out) {
|
|
68
|
+
const cwd = process.cwd();
|
|
69
|
+
for (const f of r.files) {
|
|
70
|
+
const p = resolve(cwd, join(opts.out, f.path));
|
|
71
|
+
try {
|
|
72
|
+
if (!existsSync(dirname(p)))
|
|
73
|
+
mkdirSync(dirname(p), { recursive: true });
|
|
74
|
+
writeFileSync(p, f.content);
|
|
75
|
+
out(`✓ wrote ${join(opts.out, f.path)} (${f.content.split("\n").length} lines)`);
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
out(`✗ write ${f.path}: ${e.message}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
for (const f of r.files) {
|
|
84
|
+
out(`# ── ${f.path} ──`);
|
|
85
|
+
process.stdout.write(f.content);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
out(`\n🧱 ${r.kind}: spec ~${r.measure.specTokens} tok → ~${r.measure.codeTokens} tok of code (${r.measure.outputReductionPct}% output-token saving, ${r.measure.expansionRatio}× expansion)`);
|
|
89
|
+
out(` ${r.note}`);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=scaffold.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/commands/scaffold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,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,wBAAwB,CAAC,OAAgB;IACvD,OAAO;SACJ,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,yPAAyP,CAAC;SACtQ,MAAM,CAAC,eAAe,EAAE,oCAAoC,CAAC;SAC7D,MAAM,CAAC,oBAAoB,EAAE,iCAAiC,CAAC;SAC/D,MAAM,CAAC,aAAa,EAAE,kEAAkE,CAAC;SACzF,MAAM,CAAC,QAAQ,EAAE,mDAAmD,CAAC;SACrE,MAAM,CAAC,CAAC,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CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YAAC,CAAC;QACzF,CAAC;QACD,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,OAAO,CAAC,UAAU,WAAW,CAAC,CAAC,OAAO,CAAC,UAAU,iBAAiB,CAAC,CAAC,OAAO,CAAC,kBAAkB,0BAA0B,CAAC,CAAC,OAAO,CAAC,cAAc,cAAc,CAAC,CAAC;QAC/L,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuJA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAygNvD"}
|
package/dist/index.js
CHANGED
|
@@ -83,6 +83,7 @@ import { registerEgressCommands } from "./commands/egress.js";
|
|
|
83
83
|
import { registerExecCommands } from "./commands/exec.js";
|
|
84
84
|
import { registerBequestCommands } from "./commands/bequest.js";
|
|
85
85
|
import { registerOutlineCommands } from "./commands/outline.js";
|
|
86
|
+
import { registerScaffoldCommands } from "./commands/scaffold.js";
|
|
86
87
|
import { registerTrustCommands } from "./commands/trust.js";
|
|
87
88
|
import { registerNuclearCommands } from "./commands/nuclear-cli.js";
|
|
88
89
|
import { registerOvernightCommand } from "./commands/overnight.js";
|
|
@@ -4711,6 +4712,7 @@ export async function run(argv) {
|
|
|
4711
4712
|
registerExecCommands(program);
|
|
4712
4713
|
registerBequestCommands(program);
|
|
4713
4714
|
registerOutlineCommands(program);
|
|
4715
|
+
registerScaffoldCommands(program);
|
|
4714
4716
|
// ─── Trust calibrator (v1.31.0) -- per-subsystem precision/recall/band
|
|
4715
4717
|
registerTrustCommands(program);
|
|
4716
4718
|
// ─── Wisdom reactor (v1.33.0) -- five nuclear-physics formulas as Mneme metrics
|