@slowcook-ai/cli 0.18.0-alpha.0 → 0.18.0-alpha.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/commands/port/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,MAAM,WAAW,mBAAmB;IAClC,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/commands/port/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,MAAM,WAAW,mBAAmB;IAClC,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAsBD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,mBAAmB,CAkFhG;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAajE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGrD"}
|
|
@@ -24,8 +24,22 @@
|
|
|
24
24
|
*
|
|
25
25
|
* Pure functions over strings. No fs access. Same input → same output.
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
// Match any import from @slowcook-ai/mock-runtime — capture the full
|
|
28
|
+
// named-import list. Port rewrites useScenarioFixture → useDataDomain,
|
|
29
|
+
// drops mock-only hooks (useScenario, useScenarioRunner) entirely
|
|
30
|
+
// (they have no prod analog), and routes any unknown names through
|
|
31
|
+
// a no-op shim path so the rewritten file still compiles.
|
|
32
|
+
const MOCK_RUNTIME_IMPORT_RE = /import\s+\{\s*([^}]+)\s*\}\s+from\s+["']@slowcook-ai\/mock-runtime["'];?\s*\n/g;
|
|
28
33
|
const SCENARIO_USE_RE = /\buseScenarioFixture\b/g;
|
|
34
|
+
// Hooks/utilities defined ONLY in mock-runtime — brew can't satisfy
|
|
35
|
+
// these in prod. Port replaces calls with safe no-ops + drops the
|
|
36
|
+
// import. Each of these returns a plausible "no scenario active"
|
|
37
|
+
// value so the component tree still renders.
|
|
38
|
+
const MOCK_ONLY_NAMES_TO_DROP = new Set([
|
|
39
|
+
"useScenario",
|
|
40
|
+
"useScenarioRunner",
|
|
41
|
+
"ScenarioRegistryProvider",
|
|
42
|
+
]);
|
|
29
43
|
/**
|
|
30
44
|
* Apply all port-time source transforms to a single file's contents.
|
|
31
45
|
* Returns the transformed body + the list of rewrites that fired.
|
|
@@ -33,20 +47,34 @@ const SCENARIO_USE_RE = /\buseScenarioFixture\b/g;
|
|
|
33
47
|
export function transformForPort(input, opts) {
|
|
34
48
|
let output = input;
|
|
35
49
|
const rewrites = [];
|
|
36
|
-
// 1) Rewrite mock-runtime imports
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
// 1) Rewrite mock-runtime imports. Three cases per imported name:
|
|
51
|
+
// - useScenarioFixture → useDataDomain (real hook brew implements)
|
|
52
|
+
// - useScenario, useScenarioRunner, ScenarioRegistryProvider:
|
|
53
|
+
// drop the import; replace call sites with safe no-ops below
|
|
54
|
+
// - anything else: pass through into a residual mock-runtime
|
|
55
|
+
// import line (rare; signals the consumer hand-extended)
|
|
56
|
+
if (MOCK_RUNTIME_IMPORT_RE.test(output)) {
|
|
57
|
+
MOCK_RUNTIME_IMPORT_RE.lastIndex = 0;
|
|
58
|
+
output = output.replace(MOCK_RUNTIME_IMPORT_RE, (_match, namedListRaw) => {
|
|
59
|
+
const names = String(namedListRaw)
|
|
60
|
+
.split(",")
|
|
61
|
+
.map((s) => s.trim())
|
|
62
|
+
.filter((s) => s.length > 0);
|
|
63
|
+
const wantsDataDomain = names.includes("useScenarioFixture");
|
|
64
|
+
const residual = names.filter((n) => n !== "useScenarioFixture" && !MOCK_ONLY_NAMES_TO_DROP.has(n));
|
|
65
|
+
const lines = [];
|
|
66
|
+
if (wantsDataDomain) {
|
|
67
|
+
lines.push(`import { useDataDomain } from "@/lib/data";`);
|
|
46
68
|
}
|
|
47
|
-
|
|
69
|
+
if (residual.length > 0) {
|
|
70
|
+
lines.push(`import { ${residual.join(", ")} } from "@slowcook-ai/mock-runtime";`);
|
|
71
|
+
}
|
|
72
|
+
// If only mock-only names were imported, the result is a single
|
|
73
|
+
// empty line (the import is dropped entirely). Caller's call sites
|
|
74
|
+
// are no-op'd by the next transform step.
|
|
75
|
+
return lines.length > 0 ? lines.join("\n") + "\n" : "";
|
|
48
76
|
});
|
|
49
|
-
rewrites.push("rewrote @slowcook-ai/mock-runtime →
|
|
77
|
+
rewrites.push("rewrote @slowcook-ai/mock-runtime imports (useScenarioFixture→useDataDomain; mock-only names dropped)");
|
|
50
78
|
}
|
|
51
79
|
// 2) Rewrite useScenarioFixture call sites → useDataDomain.
|
|
52
80
|
if (SCENARIO_USE_RE.test(output)) {
|
|
@@ -54,6 +82,23 @@ export function transformForPort(input, opts) {
|
|
|
54
82
|
output = output.replace(SCENARIO_USE_RE, "useDataDomain");
|
|
55
83
|
rewrites.push("rewrote useScenarioFixture(...) → useDataDomain(...)");
|
|
56
84
|
}
|
|
85
|
+
// 2b) Replace mock-only hook call sites with safe no-ops so the
|
|
86
|
+
// rewritten file still compiles when the component reads
|
|
87
|
+
// `scenario?.user` etc. Pattern: `useScenario()` → `(null as
|
|
88
|
+
// { user: { id: string } | null } | null)`. Conservative: only
|
|
89
|
+
// rewrite the bare call expression; if vibe was creative with the
|
|
90
|
+
// usage (destructuring directly from the call), brew will see a
|
|
91
|
+
// parse error and can adapt.
|
|
92
|
+
for (const name of MOCK_ONLY_NAMES_TO_DROP) {
|
|
93
|
+
const callRe = new RegExp(`\\b${name}\\s*\\(\\s*\\)`, "g");
|
|
94
|
+
if (callRe.test(output)) {
|
|
95
|
+
callRe.lastIndex = 0;
|
|
96
|
+
// Replace with `null` typed broadly so destructuring + member
|
|
97
|
+
// access stays type-safe. Brew rewires real auth in src/.
|
|
98
|
+
output = output.replace(callRe, `(null as any /* ${name}() — mock-only; brew wires real source */)`);
|
|
99
|
+
rewrites.push(`stubbed mock-only ${name}() call sites → null`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
57
102
|
// 3) Strip the `// @slowcook-mock-only` markers so the production
|
|
58
103
|
// file doesn't carry mock-only annotations (vibe sometimes adds
|
|
59
104
|
// these to flag temporary structures).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/commands/port/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AASH,MAAM,
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/commands/port/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AASH,qEAAqE;AACrE,uEAAuE;AACvE,kEAAkE;AAClE,mEAAmE;AACnE,0DAA0D;AAC1D,MAAM,sBAAsB,GAC1B,gFAAgF,CAAC;AAEnF,MAAM,eAAe,GAAG,yBAAyB,CAAC;AAElD,oEAAoE;AACpE,kEAAkE;AAClE,iEAAiE;AACjE,6CAA6C;AAC7C,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC;IACtC,aAAa;IACb,mBAAmB;IACnB,0BAA0B;CAC3B,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,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E,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slowcook-ai/cli",
|
|
3
|
-
"version": "0.18.0-alpha.
|
|
3
|
+
"version": "0.18.0-alpha.1",
|
|
4
4
|
"description": "CLI for the slowcook brewing harness",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "aminazar",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"ts-morph": "^24.0.0",
|
|
39
39
|
"yaml": "^2.6.0",
|
|
40
40
|
"zod": "^3.23.8",
|
|
41
|
-
"@slowcook-ai/core": "^0.13.0",
|
|
42
|
-
"@slowcook-ai/stack-ts": "^0.9.8",
|
|
43
41
|
"@slowcook-ai/forge-github": "^0.11.6",
|
|
42
|
+
"@slowcook-ai/stack-ts": "^0.9.8",
|
|
43
|
+
"@slowcook-ai/recorder": "^0.9.1",
|
|
44
44
|
"@slowcook-ai/llm-anthropic": "^0.14.0",
|
|
45
|
-
"@slowcook-ai/
|
|
46
|
-
"@slowcook-ai/
|
|
45
|
+
"@slowcook-ai/core": "^0.13.0",
|
|
46
|
+
"@slowcook-ai/review-overlay": "^0.5.3"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|