@netnodeag/kraftwerk 0.3.0 → 0.3.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.
Files changed (2) hide show
  1. package/dist/cli/ui.js +31 -4
  2. package/package.json +1 -1
package/dist/cli/ui.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { existsSync } from "node:fs";
2
+ import { cp, readFile } from "node:fs/promises";
3
+ import os from "node:os";
2
4
  import path from "node:path";
3
5
  import { fileURLToPath } from "node:url";
4
6
  import { spawn, spawnSync } from "node:child_process";
@@ -11,13 +13,38 @@ import { resolveProject } from "../config.js";
11
13
  * in the foreground until Ctrl-C.
12
14
  */
13
15
  /** Package root is two levels up from this file (src/cli/ or dist/cli/). */
14
- const inspectorDir = () => path.join(path.dirname(fileURLToPath(import.meta.url)), "../../inspector");
16
+ const packageRoot = () => path.join(path.dirname(fileURLToPath(import.meta.url)), "../..");
17
+ const inNodeModules = (p) => p.split(path.sep).includes("node_modules");
18
+ /**
19
+ * The inspector cannot run in place from an installed package: Next.js
20
+ * excludes everything under node_modules/ from compilation, so its .ts/.tsx
21
+ * sources would be served raw. Installed copies are materialized (sources
22
+ * only) into ~/.cache/kraftwerk/inspector-<version>/ and run from there;
23
+ * dev checkouts run in place.
24
+ */
25
+ async function materializeInspector() {
26
+ const src = path.join(packageRoot(), "inspector");
27
+ if (!inNodeModules(src))
28
+ return src;
29
+ const pkg = JSON.parse(await readFile(path.join(packageRoot(), "package.json"), "utf8"));
30
+ const dest = path.join(os.homedir(), ".cache", "kraftwerk", `inspector-${pkg.version}`);
31
+ if (!existsSync(path.join(dest, "package.json"))) {
32
+ await cp(src, dest, {
33
+ recursive: true,
34
+ filter: (s) => {
35
+ const parts = path.relative(src, s).split(path.sep);
36
+ return !parts.includes("node_modules") && !parts.includes(".next");
37
+ },
38
+ });
39
+ }
40
+ return dest;
41
+ }
15
42
  export async function runUi(cwd, opts) {
16
- const dir = inspectorDir();
17
- if (!existsSync(path.join(dir, "package.json"))) {
18
- console.error(chalk.red(`Inspector not found at ${dir} — broken install?`));
43
+ if (!existsSync(path.join(packageRoot(), "inspector", "package.json"))) {
44
+ console.error(chalk.red(`Inspector not found at ${path.join(packageRoot(), "inspector")} — broken install?`));
19
45
  process.exit(1);
20
46
  }
47
+ const dir = await materializeInspector();
21
48
  const outputDir = opts.output
22
49
  ? path.resolve(cwd, opts.output)
23
50
  : (await resolveProject(cwd)).outputDir;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netnodeag/kraftwerk",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Deterministic workflow-as-code framework: agents (persona + model + tools + harness) run in bounded phases on headless CLI harnesses (claude -p, codex exec, pi); code owns the control flow, envelopes + gates judge the results",
5
5
  "keywords": [
6
6
  "agents",