karajan-code 3.7.0 → 3.7.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.
package/README.md CHANGED
@@ -23,7 +23,7 @@
23
23
 
24
24
  ---
25
25
 
26
- > **v3.7.0 released** — Autonomous delivery: `kj autorun <spec>` chains spec → plan → run every user story → outcome in one command, unattended. An **Arbiter** resolves agent conflicts by picking the least-bad call (acceptance tests > must-fix > nice-to-have), no stage blocks for a human, a wall-clock backstop stops runaways, and it ends with an auditable "delivered, with known defects" report. Autonomy is opt-in (`--autonomous` / `--autonomy <level>`); interactive runs are unchanged. Verified live end-to-end. Full notes in [CHANGELOG.md](CHANGELOG.md).
26
+ > **v3.7.1 released** — Patch: fixes a `kj init` crash when configuring the Plan B fallback, and makes pnpm installs safe — `kj doctor` now flags when pnpm skipped `better-sqlite3`'s native build and tells you exactly how to fix it (`pnpm approve-builds better-sqlite3`). The release gate checks pnpm too. Built on **v3.7.0 — Autonomous delivery**: `kj autorun <spec>` chains spec → plan → run every user story → outcome in one command, unattended, with an **Arbiter** that resolves agent conflicts by picking the least-bad call; autonomy is opt-in, interactive runs are unchanged. Full notes in [CHANGELOG.md](CHANGELOG.md).
27
27
 
28
28
  You describe what you want to build. Karajan orchestrates multiple AI agents to plan it, implement it, test it, review it with SonarQube, and iterate. No babysitting required.
29
29
 
@@ -71,6 +71,33 @@ Two technical facts worth keeping straight:
71
71
 
72
72
  Full write-up with mental mapping for Genkit / Mastra / LangChain / Vercel AI SDK developers: **[docs/COMPARISON.md](./docs/COMPARISON.md)**.
73
73
 
74
+ ## Loop engineering
75
+
76
+ Prompt engineering got one good answer from one good prompt. Context engineering
77
+ curated what the model saw. The 2026 frontier is **loop engineering**: you stop
78
+ prompting the agent by hand and design the control system that prompts it, checks
79
+ it, and decides what happens next — until the goal is met or it hands back to you.
80
+
81
+ Karajan is a loop-engineering runtime, built around the loop before the term
82
+ caught on:
83
+
84
+ - **Maker / checker split** — a coder against independent reviewer / tester /
85
+ security roles, with Solomon judging disputes. The maker never grades its own work.
86
+ - **Deterministic verification** — TDD, per-HU acceptance tests, SonarQube gates,
87
+ and deterministic guards. Checking is tests, not vibes.
88
+ - **The autonomy ladder (L1 → L2 → L3)** — the `interactive | assisted |
89
+ autonomous` axis (v3.7.0). Report, then assisted fixes, then unattended
90
+ `kj autorun` — defaulting to `interactive`, so you opt in.
91
+ - **A durable state spine** — sessions, the HU Board, journals, the RAG index and
92
+ `kj resume` keep the loop alive outside any one conversation.
93
+
94
+ The honest caveat loop engineering insists on — *unattended loops make unattended
95
+ mistakes* — is designed in: autonomous runs list their residual defects, every HU
96
+ lands behind a PR, and `kj-trash` snapshots destructive operations.
97
+
98
+ Full mapping of the loop-engineering building blocks onto Karajan:
99
+ **[docs/loop-engineering.md](./docs/loop-engineering.md)**.
100
+
74
101
  ## Install
75
102
 
76
103
  **npm** (recommended):
@@ -83,6 +110,8 @@ npm install -g karajan-code
83
110
  brew install manufosela/tap/karajan-code
84
111
  ```
85
112
 
113
+ > **Installing with pnpm?** pnpm blocks dependency build scripts by default, so `better-sqlite3`'s native addon won't compile on install and DB-backed commands (`board`, `rag`, cost tracking) will fail. After installing, run `pnpm approve-builds better-sqlite3` — or just use npm. `kj doctor` flags this if it happens.
114
+
86
115
  **Standalone binary** (no Node.js needed):
87
116
  ```bash
88
117
  # macOS (Apple Silicon)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karajan-code",
3
- "version": "3.7.0",
3
+ "version": "3.7.1",
4
4
  "description": "Local multi-agent coding orchestrator with TDD, SonarQube, and code review pipeline",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0",
@@ -50,6 +50,7 @@ function fail(msg, detail) {
50
50
 
51
51
  let tgzPath = null;
52
52
  let tmpDir = null;
53
+ let pnpmTmp = null;
53
54
  try {
54
55
  console.log(`verify-pack: packing karajan-code@${expectedVersion}…`);
55
56
  // --json gives us the exact filename without parsing human output.
@@ -114,8 +115,48 @@ try {
114
115
  }
115
116
  console.log("verify-pack: kj-trash ships + boots ✓");
116
117
 
118
+ // 5. pnpm install smoke (KJC-TSK-0580). pnpm's layout differs from npm's
119
+ // (a symlinked virtual store), so it can break resolution of the bundled
120
+ // @karajan/core the way npm packaging breakage did before (KJC-BUG-0082/0086).
121
+ // Verify a pnpm install resolves the JS tree and `kj --version` boots — every
122
+ // release catches a pnpm packaging regression. (pnpm also blocks
123
+ // better-sqlite3's native build by default, so DB-backed commands need
124
+ // `pnpm approve-builds`; that's surfaced as a doctor warning, KJC-BUG-0092 —
125
+ // not a gate failure, since it's inherent to pnpm.) Auto-skips without pnpm.
126
+ const hasPnpm = spawnSync("pnpm", ["--version"], { encoding: "utf8", env: childEnv }).status === 0;
127
+ if (!hasPnpm) {
128
+ console.log("verify-pack: pnpm not installed — skipping pnpm smoke (npm path covered above) ⚠");
129
+ } else {
130
+ pnpmTmp = fs.mkdtempSync(path.join(os.tmpdir(), "kj-verify-pnpm-"));
131
+ fs.writeFileSync(
132
+ path.join(pnpmTmp, "package.json"),
133
+ JSON.stringify({ name: "kj-verify-pnpm", private: true }),
134
+ );
135
+ console.log(`verify-pack: installing the tarball with pnpm into ${pnpmTmp}…`);
136
+ // pnpm exits non-zero on ERR_PNPM_IGNORED_BUILDS (it skips native build
137
+ // scripts by default) — expected here, so don't treat the exit as failure.
138
+ spawnSync("pnpm", ["add", tgzPath, "--store-dir", path.join(pnpmTmp, ".store")], {
139
+ encoding: "utf8",
140
+ env: childEnv,
141
+ cwd: pnpmTmp,
142
+ });
143
+ const pnpmBin = path.join(pnpmTmp, "node_modules", ".bin", "kj");
144
+ if (!fs.existsSync(pnpmBin)) fail(`kj binary missing after pnpm install: ${pnpmBin}`);
145
+ let pnpmVersion;
146
+ try {
147
+ pnpmVersion = run(pnpmBin, ["--version"], { cwd: pnpmTmp }).trim();
148
+ } catch (err) {
149
+ fail("`kj --version` crashed under a pnpm install (packaging regression)", err.stderr || err.message);
150
+ }
151
+ if (!pnpmVersion.includes(expectedVersion)) {
152
+ fail(`kj --version under pnpm returned "${pnpmVersion}", expected ${expectedVersion}`);
153
+ }
154
+ console.log(`verify-pack: pnpm install + kj --version → ${pnpmVersion} ✓ (DB build needs \`pnpm approve-builds\`)`);
155
+ }
156
+
117
157
  console.log(`\n✓ verify-pack: karajan-code@${expectedVersion} installs clean and runs.`);
118
158
  } finally {
119
159
  if (tgzPath && fs.existsSync(tgzPath)) fs.rmSync(tgzPath, { force: true });
120
160
  if (tmpDir && fs.existsSync(tmpDir)) fs.rmSync(tmpDir, { recursive: true, force: true });
161
+ if (pnpmTmp && fs.existsSync(pnpmTmp)) fs.rmSync(pnpmTmp, { recursive: true, force: true });
121
162
  }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Native build availability check (KJC-BUG-0092).
3
+ *
4
+ * better-sqlite3 ships a native addon compiled in a postinstall step. pnpm
5
+ * blocks dependency build scripts by default (ERR_PNPM_IGNORED_BUILDS), so a
6
+ * `pnpm add -g karajan-code` leaves the addon uncompiled: `kj --version` still
7
+ * works (it never opens a DB) but any DB-backed command (board, rag, cost
8
+ * tracking) crashes with "Cannot find module 'better-sqlite3'". This surfaces a
9
+ * WARN in `kj doctor` with the exact remedy instead of a cryptic runtime crash.
10
+ */
11
+
12
+ import { STRATEGY } from "./types.js";
13
+
14
+ /** pnpm lays packages out under a `.pnpm` virtual store and symlinks them in. */
15
+ function isPnpmInstall() {
16
+ return (
17
+ import.meta.url.includes("/.pnpm/") ||
18
+ (process.env.npm_config_user_agent || "").includes("pnpm")
19
+ );
20
+ }
21
+
22
+ /** Force the native binding to load by opening an in-memory database. */
23
+ async function defaultLoadDb() {
24
+ const Database = (await import("better-sqlite3")).default;
25
+ new Database(":memory:").close();
26
+ }
27
+
28
+ export function createNativeBuildCheck({ loadDb = defaultLoadDb, isPnpm = isPnpmInstall } = {}) {
29
+ return {
30
+ name: "native-build",
31
+ label: "native modules (better-sqlite3)",
32
+ strategy: STRATEGY.MANUAL,
33
+ async detect() {
34
+ try {
35
+ await loadDb();
36
+ return {
37
+ ok: true,
38
+ severity: "info",
39
+ detail: "better-sqlite3 native addon loads — DB-backed commands available",
40
+ };
41
+ } catch (err) {
42
+ const firstLine = String(err?.message || err).split("\n")[0];
43
+ if (isPnpm()) {
44
+ return {
45
+ ok: false,
46
+ severity: "warn",
47
+ detail: "better-sqlite3 native build was skipped — pnpm blocks dependency build scripts by default",
48
+ fix: "Approve the build then reinstall: `pnpm approve-builds better-sqlite3` — or install with npm: `npm i -g karajan-code`",
49
+ };
50
+ }
51
+ return {
52
+ ok: false,
53
+ severity: "warn",
54
+ detail: `better-sqlite3 failed to load: ${firstLine}`,
55
+ fix: "Reinstall to rebuild native modules: `npm i -g karajan-code`",
56
+ };
57
+ }
58
+ },
59
+ };
60
+ }
61
+
62
+ export function getNativeBuildChecks() {
63
+ return [createNativeBuildCheck()];
64
+ }
@@ -26,6 +26,7 @@ import { getSqueezrChecks } from "../checks/squeezr.js";
26
26
  import { getAiTrashChecks } from "../checks/ai-trash.js";
27
27
  import { getQmdChecks } from "../checks/qmd.js";
28
28
  import { getNodeChecks } from "../checks/node.js";
29
+ import { getNativeBuildChecks } from "../checks/native-build.js";
29
30
  import { getPortChecks } from "../checks/ports.js";
30
31
  import { getTokenChecks } from "../checks/tokens.js";
31
32
  import { getMcpHealthChecks } from "../checks/mcp-health.js";
@@ -54,6 +55,7 @@ function buildChecks(config, { projectOnly = false } = {}) {
54
55
  return [
55
56
  ...getSystemChecks(),
56
57
  ...getNodeChecks(),
58
+ ...getNativeBuildChecks(),
57
59
  ...getHardwareChecks(),
58
60
  ...getDirSetupChecks(),
59
61
  ...getConfigFileChecks(),
@@ -1,7 +1,7 @@
1
1
  import readline from "node:readline";
2
2
 
3
- export function createWizard(input = process.stdin, output = process.stdout) {
4
- const rl = readline.createInterface({ input, output, terminal: false });
3
+ export function createWizard(inputStream = process.stdin, output = process.stdout) {
4
+ const rl = readline.createInterface({ input: inputStream, output, terminal: false });
5
5
 
6
6
  function ask(question) {
7
7
  return new Promise((resolve) => {
@@ -16,6 +16,12 @@ export function createWizard(input = process.stdin, output = process.stdout) {
16
16
  return /^y(es)?$/i.test(answer);
17
17
  }
18
18
 
19
+ async function input(question, defaultValue = "") {
20
+ const hint = defaultValue !== "" ? ` [${defaultValue}]` : "";
21
+ const answer = await ask(`${question}${hint} `);
22
+ return answer === "" ? defaultValue : answer;
23
+ }
24
+
19
25
  async function select(question, options) {
20
26
  output.write(`${question}\n`);
21
27
  for (let i = 0; i < options.length; i++) {
@@ -33,7 +39,7 @@ export function createWizard(input = process.stdin, output = process.stdout) {
33
39
  rl.close();
34
40
  }
35
41
 
36
- return { ask, confirm, select, close };
42
+ return { ask, confirm, input, select, close };
37
43
  }
38
44
 
39
45
  export function isTTY() {