konoha-mcp 2.2.23 → 2.2.25

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 (132) hide show
  1. package/NOTICE +14 -8
  2. package/README.md +20 -5
  3. package/apps/web/build/adapter-node.js +1 -1
  4. package/apps/web/build/build-meta.json +2 -2
  5. package/apps/web/build/client/_app/immutable/entry/{app.TYH87iYy.js → app.DtoBIrs4.js} +2 -2
  6. package/apps/web/build/client/_app/immutable/entry/app.DtoBIrs4.js.br +0 -0
  7. package/apps/web/build/client/_app/immutable/entry/app.DtoBIrs4.js.gz +0 -0
  8. package/apps/web/build/client/_app/immutable/nodes/{0.D7dPIEWA.js → 0.B8Iw7Xl1.js} +1 -1
  9. package/apps/web/build/client/_app/immutable/nodes/0.B8Iw7Xl1.js.br +0 -0
  10. package/apps/web/build/client/_app/immutable/nodes/{0.D7dPIEWA.js.gz → 0.B8Iw7Xl1.js.gz} +0 -0
  11. package/apps/web/build/client/_app/immutable/nodes/{13.TOXVaTBr.js → 13.CQB_Ed6W.js} +1 -1
  12. package/apps/web/build/client/_app/immutable/nodes/13.CQB_Ed6W.js.br +0 -0
  13. package/apps/web/build/client/_app/immutable/nodes/{13.TOXVaTBr.js.gz → 13.CQB_Ed6W.js.gz} +0 -0
  14. package/apps/web/build/client/_app/version.json +1 -1
  15. package/apps/web/build/client/_app/version.json.br +0 -0
  16. package/apps/web/build/client/_app/version.json.gz +0 -0
  17. package/apps/web/build/server/chunks/instance.js +3 -3
  18. package/apps/web/build/server/chunks/internal.js +1 -1
  19. package/apps/web/build/server/entries/pages/_layout.svelte.js +1 -1
  20. package/apps/web/build/server/entries/pages/_layout.svelte.js.map +1 -1
  21. package/apps/web/build/server/entries/pages/docs/_page.svelte.js +1 -1
  22. package/apps/web/build/server/entries/pages/docs/_page.svelte.js.map +1 -1
  23. package/apps/web/build/server/manifest-full.js +1 -1
  24. package/apps/web/build/server/manifest.js +1 -1
  25. package/apps/web/build/server/nodes/0.js +1 -1
  26. package/apps/web/build/server/nodes/13.js +1 -1
  27. package/apps/web/build/server/server.js +1 -1
  28. package/apps/web/package.json +1 -1
  29. package/assets/demo-agy.webp +0 -0
  30. package/assets/demo-claude.webp +0 -0
  31. package/assets/demo-codex.webp +0 -0
  32. package/assets/demo-commandcode.webp +0 -0
  33. package/assets/demo-cursor.webp +0 -0
  34. package/assets/demo-opencode.webp +0 -0
  35. package/assets/demo-pi.webp +0 -0
  36. package/assets/demo-skill-embed.webp +0 -0
  37. package/assets/demo-skills.webp +0 -0
  38. package/assets/demo-web.webp +0 -0
  39. package/assets/demo.webp +0 -0
  40. package/assets/konoha-akatsuki-flow.webp +0 -0
  41. package/assets/konoha-anbu-flow.webp +0 -0
  42. package/assets/konoha-flow-12-cli-upgrade-progress-engine.webp +0 -0
  43. package/assets/konoha-jonin-flow.webp +0 -0
  44. package/assets/konoha-kage-gate.webp +0 -0
  45. package/assets/konoha-langgraph-flow.webp +0 -0
  46. package/assets/konoha-orchestration-flow.webp +0 -0
  47. package/assets/konoha-qa-flow.webp +0 -0
  48. package/assets/konoha-telegram-flow.webp +0 -0
  49. package/assets/testing.webp +0 -0
  50. package/bin/commands/bridge.js +62 -4
  51. package/bin/commands/doctor.js +2 -0
  52. package/bin/commands/doctor_services.js +57 -0
  53. package/bin/commands/init.js +29 -8
  54. package/bin/commands/init_clients.js +95 -8
  55. package/bin/commands/init_migration.js +32 -1
  56. package/bin/lib/config_defaults.js +3 -0
  57. package/bin/lib/runtime_install.js +147 -54
  58. package/node_modules/jszip/package.json +2 -2
  59. package/node_modules/string_decoder/package.json +1 -1
  60. package/package.json +10 -3
  61. package/patches/gpt-tokenizer@4.1.0.patch +15 -0
  62. package/patches/jszip@3.10.2.patch +11 -0
  63. package/patches/string_decoder@1.3.0.patch +12 -0
  64. package/src/agent_contract.js +2 -2
  65. package/src/agent_deployer.js +48 -35
  66. package/src/agent_file_safety.js +57 -0
  67. package/src/antigravity_subagent_hook.js +30 -12
  68. package/src/bridge/gateway.js +2 -0
  69. package/src/bridge/gateway_adapters.js +155 -29
  70. package/src/bridge/handlers/anthropic.js +95 -26
  71. package/src/bridge/handlers/openai.js +18 -5
  72. package/src/bridge/sidecar/raw.js +10 -2
  73. package/src/bridge/stream_usage.js +66 -0
  74. package/src/chunin_knowledge_ddl.js +95 -0
  75. package/src/client_commands.js +190 -0
  76. package/src/db_bridges.js +53 -7
  77. package/src/db_schema.js +14 -2
  78. package/src/deploy_installer.js +212 -11
  79. package/src/deploy_utils.js +4 -0
  80. package/src/file_tools/common.js +65 -3
  81. package/src/file_tools_mcp.js +17 -9
  82. package/src/file_tools_router.js +67 -6
  83. package/src/global_skill_sync.js +3 -1
  84. package/src/mcp/chunin_knowledge.js +509 -0
  85. package/src/mcp/langgraph/edges/router.js +3 -0
  86. package/src/mcp/langgraph/index.js +22 -3
  87. package/src/mcp/langgraph/nodes/dispatch.js +3 -0
  88. package/src/mcp/langgraph/nodes/execute.js +87 -13
  89. package/src/mcp/langgraph/nodes/review.js +13 -1
  90. package/src/mcp/langgraph/slice_executor_registry.js +22 -0
  91. package/src/mcp/langgraph/state.js +5 -0
  92. package/src/mcp/lazy_subagent.js +11 -1
  93. package/src/mcp/memory_project_context.js +4 -1
  94. package/src/mcp/memory_subagent_runner.js +2 -1
  95. package/src/mcp/skills_common.js +1 -0
  96. package/src/mcp/subagent_spawner.js +7 -0
  97. package/src/mcp/todo_walkthrough_sync.js +7 -0
  98. package/src/mcp/tool_dispatch.js +18 -1
  99. package/src/mcp/web_search.js +27 -3
  100. package/src/mcp/workflow_completion_helpers.js +6 -1
  101. package/src/mcp/workflow_gates.js +118 -5
  102. package/src/mcp/workflow_sannin.js +9 -3
  103. package/src/mcp_clients/common.js +31 -0
  104. package/src/mcp_tool_manifest.json +36 -1
  105. package/src/pi_fs_helpers.js +31 -0
  106. package/src/pi_manager.js +68 -28
  107. package/src/provider_usage_logger.js +92 -0
  108. package/src/schema_ddl.js +17 -1
  109. package/src/templates/AGENTS.md +1 -1
  110. package/src/templates/GEMINI.md +1 -1
  111. package/src/templates/skills/chunin-skill/SKILL.md +34 -0
  112. package/src/templates/skills/chunin-skill/references/deep-research-analyst.md +27 -10
  113. package/src/templates/skills/kage-skill/SKILL.md +1 -1
  114. package/src/templates/skills/konoha/SKILL.md +23 -165
  115. package/src/templates/skills/konoha/references/contract.md +2 -2
  116. package/src/templates/skills/konoha/references/peragent-usage.md +1 -1
  117. package/src/token_usage.js +57 -0
  118. package/src/tools_savings_logger.js +26 -8
  119. package/src/url_canonical.js +58 -0
  120. package/src/vector_pipeline.js +6 -4
  121. package/src/vector_search.js +4 -2
  122. package/src/web/controllers/core_controller.js +10 -1
  123. package/src/workflow/jonin-builder/live_browser_monitor.js +23 -7
  124. package/apps/web/build/client/_app/immutable/entry/app.TYH87iYy.js.br +0 -0
  125. package/apps/web/build/client/_app/immutable/entry/app.TYH87iYy.js.gz +0 -0
  126. package/apps/web/build/client/_app/immutable/nodes/0.D7dPIEWA.js.br +0 -0
  127. package/apps/web/build/client/_app/immutable/nodes/13.TOXVaTBr.js.br +0 -0
  128. package/src/templates/skills/konoha/references/architecture.md +0 -99
  129. package/src/templates/skills/konoha/references/benchmark.md +0 -123
  130. package/src/templates/skills/konoha/references/docs.md +0 -46
  131. package/src/templates/skills/konoha/references/test.md +0 -71
  132. package/src/templates/skills/konoha/references/workflow.md +0 -104
@@ -255,6 +255,12 @@ function copyRuntimeFiles(copyTree, sourceRoot = REPO_ROOT) {
255
255
  // trustworthy source for docs/, skills, CLI or manifest either.
256
256
  if (!srcFresh) return cliDest;
257
257
 
258
+ // The flat ~/.konoha/mcp copy loses a directory level relative to src/mcp, so
259
+ // modules below it that reach upward (../../web/...) must resolve against the
260
+ // mirrored src/ tree instead. Link the flat name at that tree.
261
+ deployUtils.ensureMirroredSubdirLinks(SKILLS_DB_DIR);
262
+ deployUtils.ensureMirroredRootFileLinks(SKILLS_DB_DIR);
263
+
258
264
  copyRuntimeAssets(path.join(sourceRoot, 'assets'), copyTree);
259
265
 
260
266
  const sourceCliPath = path.join(sourceRoot, 'bin', 'cli.js');
@@ -283,71 +289,138 @@ function copyRuntimeFiles(copyTree, sourceRoot = REPO_ROOT) {
283
289
  return cliDest;
284
290
  }
285
291
 
286
- function readBuildVersion(dir) {
287
- const meta = path.join(dir, 'build-meta.json');
288
- if (!fileExists(meta)) return null;
292
+ // A build is only usable if its own metadata says what it is. `handler.js` proves the
293
+ // tree was built, not which source produced it, and the destination package.json is
294
+ // copied from the source manifest — neither is provenance.
295
+ function readBuildMeta(dir) {
296
+ const metaPath = path.join(dir, 'build-meta.json');
297
+ if (!fileExists(metaPath)) return { ok: false, reason: 'missing build-meta.json' };
298
+ let raw;
289
299
  try {
290
- return JSON.parse(fs.readFileSync(meta, 'utf8')).version || null;
291
- } catch {
292
- return null;
300
+ raw = JSON.parse(fs.readFileSync(metaPath, 'utf8'));
301
+ } catch (err) {
302
+ return { ok: false, reason: `unreadable build-meta.json (${err.message})` };
293
303
  }
304
+ const version = raw && typeof raw.version === 'string' ? raw.version.trim() : '';
305
+ if (!version) return { ok: false, reason: 'build-meta.json has no string version' };
306
+ return { ok: true, version, builtAt: typeof raw.builtAt === 'string' ? raw.builtAt : null };
294
307
  }
295
308
 
296
- function resolveWebBuildSource(sourceRoot = REPO_ROOT, currentVersion = null) {
297
- const candidates = [
309
+ function readBuildVersion(dir) {
310
+ const meta = readBuildMeta(dir);
311
+ return meta.ok ? meta.version : null;
312
+ }
313
+
314
+ function defaultWebBuildCandidates(sourceRoot) {
315
+ return [
298
316
  path.join(sourceRoot, 'apps', 'web', 'build'),
299
317
  path.resolve(__dirname, '..', '..', 'apps', 'web', 'build'),
300
318
  path.join(process.cwd(), 'apps', 'web', 'build'),
301
319
  path.join(process.cwd(), 'build')
302
320
  ];
303
- const found = [];
321
+ }
322
+
323
+ function resolveWebBuildSource(sourceRoot = REPO_ROOT, currentVersion = null, candidates = defaultWebBuildCandidates(sourceRoot)) {
324
+ const rejected = [];
304
325
  for (const cand of candidates) {
305
- if (!fileExists(path.join(cand, 'handler.js'))) continue;
306
- const declared = readBuildVersion(cand);
307
- if (declared && currentVersion && declared !== currentVersion) {
308
- warn(`Skipping stale Web UI build ${declared} at ${cand} (installing ${currentVersion})`);
326
+ if (!fileExists(path.join(cand, 'handler.js'))) {
327
+ rejected.push(`${cand}: no handler.js`);
328
+ continue;
329
+ }
330
+ const meta = readBuildMeta(cand);
331
+ if (!meta.ok) {
332
+ warn(`Skipping unverified Web UI build at ${cand}: ${meta.reason}`);
333
+ rejected.push(`${cand}: ${meta.reason}`);
309
334
  continue;
310
335
  }
311
- found.push(cand);
336
+ if (currentVersion && meta.version !== currentVersion) {
337
+ warn(`Skipping stale Web UI build ${meta.version} at ${cand} (installing ${currentVersion})`);
338
+ rejected.push(`${cand}: stale ${meta.version}`);
339
+ continue;
340
+ }
341
+ if (rejected.length > 0) {
342
+ warn(`Web UI build accepted: ${cand} (v${meta.version}), ${rejected.length} candidate(s) rejected`);
343
+ }
344
+ return cand;
312
345
  }
313
- // Every candidate was stale. Returning the default path here would copy the
314
- // very artifact we just rejected, so signal "no usable source" and let the
315
- // caller fall back to an on-demand build.
316
- return found[0] || null;
346
+ // Every candidate was unverified or stale. Returning a default path here would copy
347
+ // the very artifact we just rejected, so signal "no usable source" and let the caller
348
+ // fall back to an on-demand build.
349
+ warn(`No verified Web UI build found among ${candidates.length} candidate(s): ${rejected.join('; ')}`);
350
+ return null;
317
351
  }
318
352
 
319
353
  function _syncWebBuildOutput(builtOutput, webBuildDest, destWebPkg, currentVersion) {
320
- try {
321
- fs.rmSync(webBuildDest, { recursive: true, force: true, maxRetries: 3 });
322
- } catch (rmErr) {
323
- if (process.platform === 'win32') {
324
- warn(`Web UI destination cleanup note (${rmErr.message}); proceeding with in-place synchronization.`);
325
- }
354
+ const srcMeta = readBuildMeta(builtOutput);
355
+ if (!srcMeta.ok) {
356
+ return { ok: false, reason: `source ${builtOutput} has no usable provenance: ${srcMeta.reason}` };
326
357
  }
327
- ensureDir(webBuildDest);
328
- try {
329
- fs.cpSync(builtOutput, webBuildDest, { recursive: true, force: true });
330
- } catch (cpErr) {
331
- warn(`Web UI assets sync note: ${cpErr.message}`);
358
+ if (currentVersion && srcMeta.version !== currentVersion) {
359
+ return { ok: false, reason: `source declares v${srcMeta.version}, expected v${currentVersion}` };
332
360
  }
333
- fs.writeFileSync(destWebPkg, JSON.stringify({ name: 'konoha-web', version: currentVersion, type: 'module', private: true }, null, 2) + '\n');
334
- fs.writeFileSync(path.join(webBuildDest, 'package.json'), '{\n "type": "module"\n}\n');
335
361
 
336
- // Report the version the artifact tree actually declares, not the one we hoped
337
- // for: a source build without build-meta.json has unknown provenance, and a
338
- // mismatched stamp must never be printed as the installed version.
339
- const installedVersion = readBuildVersion(webBuildDest);
340
- if (!installedVersion) {
341
- warn(`ERROR: Web UI provenance unknown at ${webBuildDest} (no build-meta.json); reported version ${currentVersion} is unverified.`);
342
- } else if (installedVersion !== currentVersion) {
343
- warn(`ERROR: Web UI version mismatch at ${webBuildDest}: expected ${currentVersion}, found ${installedVersion}.`);
362
+ const sameDir = path.resolve(builtOutput) === path.resolve(webBuildDest);
363
+ if (!sameDir) {
364
+ try {
365
+ fs.rmSync(webBuildDest, { recursive: true, force: true, maxRetries: 3 });
366
+ } catch (rmErr) {
367
+ if (process.platform === 'win32') {
368
+ warn(`Web UI destination cleanup note (${rmErr.message}); proceeding with in-place synchronization.`);
369
+ }
370
+ }
371
+ ensureDir(webBuildDest);
372
+ try {
373
+ fs.cpSync(builtOutput, webBuildDest, { recursive: true, force: true });
374
+ } catch (cpErr) {
375
+ warn(`Web UI assets sync note: ${cpErr.message}`);
376
+ }
377
+ fs.writeFileSync(
378
+ destWebPkg,
379
+ JSON.stringify({ name: 'konoha-web', version: srcMeta.version, type: 'module', private: true }, null, 2) + '\n'
380
+ );
381
+ fs.writeFileSync(path.join(webBuildDest, 'package.json'), '{\n "type": "module"\n}\n');
382
+ }
383
+
384
+ // The copy is only trusted once the destination's own metadata agrees with the
385
+ // source's. A failed verification removes the unverified tree: absence is a state
386
+ // the server reports, a garbage build is one it serves.
387
+ const destMeta = readBuildMeta(webBuildDest);
388
+ if (!destMeta.ok || destMeta.version !== srcMeta.version) {
389
+ const reason = destMeta.ok
390
+ ? `destination declares v${destMeta.version}, source v${srcMeta.version}`
391
+ : destMeta.reason;
392
+ if (!sameDir) {
393
+ try {
394
+ fs.rmSync(webBuildDest, { recursive: true, force: true, maxRetries: 3 });
395
+ } catch { /* best-effort removal of an unverified tree */ }
396
+ }
397
+ warn(`ERROR: Web UI provenance verification failed at ${webBuildDest}: ${reason}; the unverified build was removed`);
398
+ return { ok: false, reason };
344
399
  }
345
- info(`Pre-built Web UI installed to ${webBuildDest} (v${installedVersion || currentVersion})`);
400
+
401
+ info(`Pre-built Web UI installed to ${webBuildDest} (v${destMeta.version} verified)`);
402
+ return { ok: true, version: destMeta.version };
403
+ }
404
+
405
+ function shouldBuildWebUiOnDemand(webBuildDest, currentVersion) {
406
+ if (!fileExists(path.join(webBuildDest, 'handler.js'))) return { needed: true, reason: 'no-handler' };
407
+ const meta = readBuildMeta(webBuildDest);
408
+ if (!meta.ok) {
409
+ const slug = meta.reason.startsWith('missing ')
410
+ ? 'missing'
411
+ : meta.reason.startsWith('unreadable ') ? 'invalid' : 'no-version';
412
+ return { needed: true, reason: `provenance-${slug}` };
413
+ }
414
+ if (currentVersion && meta.version !== currentVersion) return { needed: true, reason: 'stale' };
415
+ return { needed: false, reason: 'verified' };
346
416
  }
347
417
 
348
418
  function buildWebUiOnDemand(webBuildDest, destWebPkg, currentVersion) {
349
419
  const sourceDir = deployUtils.resolveWebUiDir({ preferSources: true });
350
- if (!sourceDir || !fileExists(path.join(sourceDir, 'src', 'routes'))) return;
420
+ if (!sourceDir || !fileExists(path.join(sourceDir, 'src', 'routes'))) {
421
+ warn('No Web UI source found; cannot build on demand');
422
+ return false;
423
+ }
351
424
  try {
352
425
  const { execSync } = require('child_process');
353
426
  info(`Building Web UI v${currentVersion} during runtime initialization...`);
@@ -357,11 +430,17 @@ function buildWebUiOnDemand(webBuildDest, destWebPkg, currentVersion) {
357
430
  execSync('npm run build', { cwd: sourceDir, stdio: 'ignore', timeout: INSTALL_BUILD_MIGRATE_TIMEOUT_MS });
358
431
  }
359
432
  const builtOutput = path.join(sourceDir, 'build');
360
- if (fileExists(path.join(builtOutput, 'handler.js')) && path.resolve(builtOutput) !== path.resolve(webBuildDest)) {
361
- _syncWebBuildOutput(builtOutput, webBuildDest, destWebPkg, currentVersion);
433
+ const builtMeta = readBuildMeta(builtOutput);
434
+ if (!fileExists(path.join(builtOutput, 'handler.js')) || !builtMeta.ok || builtMeta.version !== currentVersion) {
435
+ const why = builtMeta.ok ? `declares v${builtMeta.version}, expected v${currentVersion}` : builtMeta.reason;
436
+ warn(`ERROR: on-demand Web UI build produced no verifiable metadata at ${builtOutput} (${why}); run \`pnpm run build:web\``);
437
+ return false;
362
438
  }
439
+ if (path.resolve(builtOutput) === path.resolve(webBuildDest)) return true;
440
+ return _syncWebBuildOutput(builtOutput, webBuildDest, destWebPkg, currentVersion).ok;
363
441
  } catch (buildErr) {
364
442
  warn(`Could not build Web UI automatically: ${buildErr.message}`);
443
+ return false;
365
444
  }
366
445
  }
367
446
 
@@ -377,23 +456,34 @@ function installWebUiRuntime(copyTree, sourceRoot = REPO_ROOT) {
377
456
  }
378
457
 
379
458
  const currentVersion = readPackageVersionSafe(path.join(sourceRoot, 'package.json')) || getCliVersion();
380
- const webBuildSrc = resolveWebBuildSource(sourceRoot, currentVersion);
381
459
  const webBuildDest = path.join(SKILLS_DB_DIR, 'apps', 'web', 'build');
382
460
  const destWebPkg = path.join(webDestDir, 'package.json');
383
- let destVersion = null;
384
- try {
385
- if (fileExists(destWebPkg)) destVersion = JSON.parse(fs.readFileSync(destWebPkg, 'utf8')).version;
386
- } catch (_) { /* best-effort */ }
387
- const isUiOutdated = !destVersion || destVersion !== currentVersion;
461
+ const destState = shouldBuildWebUiOnDemand(webBuildDest, currentVersion);
462
+ const webBuildSrc = resolveWebBuildSource(sourceRoot, currentVersion);
388
463
 
389
- if (webBuildSrc && fileExists(path.join(webBuildSrc, 'handler.js'))) {
390
- if (path.resolve(webBuildSrc) !== path.resolve(webBuildDest) || isUiOutdated) {
391
- _syncWebBuildOutput(webBuildSrc, webBuildDest, destWebPkg, currentVersion);
464
+ let synced = false;
465
+ if (webBuildSrc) {
466
+ if (path.resolve(webBuildSrc) !== path.resolve(webBuildDest) || !destState.needed) {
467
+ const result = _syncWebBuildOutput(webBuildSrc, webBuildDest, destWebPkg, currentVersion);
468
+ synced = result.ok;
469
+ if (!result.ok) warn(`Web UI sync rejected: ${result.reason}`);
392
470
  }
393
- } else if (!fileExists(path.join(webBuildDest, 'handler.js')) || isUiOutdated) {
394
- if (!webBuildSrc) warn('No Web UI build matches the installed version; building on demand.');
471
+ }
472
+ if (!synced && (destState.needed || !webBuildSrc)) {
473
+ if (!webBuildSrc && destState.needed) warn(`No Web UI build matches the installed version (${destState.reason}); building on demand.`);
395
474
  buildWebUiOnDemand(webBuildDest, destWebPkg, currentVersion);
396
475
  }
476
+
477
+ // The only place a version may be claimed: the metadata of the tree that will be served.
478
+ const finalMeta = readBuildMeta(webBuildDest);
479
+ if (finalMeta.ok && finalMeta.version === currentVersion && fileExists(path.join(webBuildDest, 'handler.js'))) {
480
+ info(`Web UI v${finalMeta.version} verified at ${webBuildDest}`);
481
+ } else {
482
+ warn(
483
+ `ERROR: Web UI at ${webBuildDest} is unverified (${finalMeta.ok ? `v${finalMeta.version}` : finalMeta.reason}); ` +
484
+ `reported version ${currentVersion} is not claimed. Run \`pnpm run build:web\` and re-run \`konoha init\`.`
485
+ );
486
+ }
397
487
  }
398
488
 
399
489
  function installMissingDependencies(deps) {
@@ -598,6 +688,9 @@ module.exports = {
598
688
  installCliRuntime,
599
689
  reconcileGlobalCommand,
600
690
  resolveWebBuildSource,
691
+ readBuildMeta,
601
692
  readBuildVersion,
693
+ _syncWebBuildOutput,
694
+ shouldBuildWebUiOnDemand,
602
695
  installWebUiRuntime
603
696
  };
@@ -56,8 +56,8 @@
56
56
  "dependencies": {
57
57
  "lie": "~3.3.0",
58
58
  "pako": "~1.0.2",
59
- "readable-stream": "~2.3.6",
60
- "setimmediate": "^1.0.5"
59
+ "readable-stream": "^3.6.2",
60
+ "setimmediate": "npm:immediate@^3.3.0"
61
61
  },
62
62
  "license": "(MIT OR GPL-3.0-or-later)"
63
63
  }
@@ -7,7 +7,7 @@
7
7
  "lib"
8
8
  ],
9
9
  "dependencies": {
10
- "safe-buffer": "~5.2.0"
10
+ "safe-buffer": "npm:@socketregistry/safe-buffer@1.0.9"
11
11
  },
12
12
  "devDependencies": {
13
13
  "babel-polyfill": "^6.23.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "konoha-mcp",
3
- "version": "2.2.23",
3
+ "version": "2.2.25",
4
4
  "description": "Autonomous multi-agent MCP orchestration platform powered by LangGraph state machines, 8 specialist ninja agents, SQLite FTS5 skill indexing, and per-turn token governors saving 83–98% context across 8 AI coding clients",
5
5
  "homepage": "https://github.com/andycungkrinx91/konoha#readme",
6
6
  "bugs": "https://github.com/andycungkrinx91/konoha/issues",
@@ -73,7 +73,11 @@
73
73
  },
74
74
  "overrides": {
75
75
  "image-size": ">=2.0.3",
76
- "globalthis": "npm:@socketregistry/globalthis@1.0.7"
76
+ "globalthis": "npm:@socketregistry/globalthis@1.0.7",
77
+ "isarray": "npm:@socketregistry/isarray@1.0.8",
78
+ "readable-stream": "^3.6.2",
79
+ "safe-buffer": "npm:@socketregistry/safe-buffer@1.0.9",
80
+ "setimmediate": "npm:immediate@^3.3.0"
77
81
  },
78
82
  "bundleDependencies": [
79
83
  "cfb",
@@ -91,8 +95,10 @@
91
95
  "@langchain/core": "1.3.2",
92
96
  "@langchain/langgraph": "1.6.0",
93
97
  "@langchain/langgraph-checkpoint": "1.2.2",
98
+ "@napi-rs/canvas": "^1.1.1",
94
99
  "cfb": "1.2.2",
95
100
  "docx": "9.14.0",
101
+ "gifenc": "^1.0.3",
96
102
  "gpt-tokenizer": "4.1.0",
97
103
  "hash-wasm": "4.12.0",
98
104
  "manifold-3d": "3.2.1",
@@ -115,8 +121,9 @@
115
121
  "test:e2e": "node scripts/rtk_exec.js pnpm --dir apps/web run test:e2e",
116
122
  "test:parallel": "node scripts/rtk_exec.js node tests/run_all.js --parallel",
117
123
  "ci:act": "act -W .github/workflows/cross-platform.yml -j checks --matrix os:ubuntu-latest",
118
- "ci:act:shard": "act -W .github/workflows/cross-platform.yml -j test --matrix os:ubuntu-latest --matrix shard:1",
124
+ "ci:act:shard": "act -W .github/workflows/cross-platform.yml -j test-ubuntu --matrix shard:1",
119
125
  "test:sandbox": "node scripts/rtk_exec.js node scripts/sandbox.js",
126
+ "audit:socket": "node scripts/rtk_exec.js node scripts/socket_audit_optional.js",
120
127
  "test:mcp": "node scripts/rtk_exec.js node tests/test_mcp_protocol.js && node scripts/rtk_exec.js node tests/test_mcp_e2e.js",
121
128
  "test:workflow": "node scripts/rtk_exec.js node tests/test_workflow_gates.js && node scripts/rtk_exec.js node tests/test_workflow_loop.js",
122
129
  "test:jonin": "node scripts/rtk_exec.js node tests/test_build_workflows.js && node scripts/rtk_exec.js node tests/test_taste_skill_jonin.js && node scripts/rtk_exec.js node tests/test_jonin_universal_design.js",
@@ -0,0 +1,15 @@
1
+ diff --git a/src/scraper/README.md b/src/scraper/README.md
2
+ deleted file mode 100644
3
+ index cd9594ccf987634b358aed651d6124f23bad158e..0000000000000000000000000000000000000000
4
+ diff --git a/src/scraper/modelScrape.browser.js b/src/scraper/modelScrape.browser.js
5
+ deleted file mode 100644
6
+ index cfd7ff875f242a1cffaa3a7bb252c13fb1fec2df..0000000000000000000000000000000000000000
7
+ diff --git a/src/scraper/modelScrape.browser.test.js b/src/scraper/modelScrape.browser.test.js
8
+ deleted file mode 100644
9
+ index 7819ced89dd9f55b68bddb39ef8c73f8644457fa..0000000000000000000000000000000000000000
10
+ diff --git a/src/scraper/modelScrape.node.test.ts b/src/scraper/modelScrape.node.test.ts
11
+ deleted file mode 100644
12
+ index 641575d4617f31f149d0943c80648faa0baa359e..0000000000000000000000000000000000000000
13
+ diff --git a/src/scraper/modelScrape.node.ts b/src/scraper/modelScrape.node.ts
14
+ deleted file mode 100644
15
+ index a4c3549d4e8ae710ffac351111f7a4270272cdd6..0000000000000000000000000000000000000000
@@ -19,3 +19,14 @@ index d167aab2597e79dd4a5f2332a82838dec76b5b9f..c41ce2e53fc2e89fc18c36b6c28d4708
19
19
  "types": "./index.d.ts",
20
20
  "repository": {
21
21
  "type": "git",
22
+ @@ -60,8 +56,8 @@
23
+ "dependencies": {
24
+ "lie": "~3.3.0",
25
+ "pako": "~1.0.2",
26
+ - "readable-stream": "~2.3.6",
27
+ - "setimmediate": "^1.0.5"
28
+ + "readable-stream": "^3.6.2",
29
+ + "setimmediate": "npm:immediate@^3.3.0"
30
+ },
31
+ "license": "(MIT OR GPL-3.0-or-later)"
32
+ }
@@ -0,0 +1,12 @@
1
+ diff --git a/package.json b/package.json
2
+ --- a/package.json
3
+ +++ b/package.json
4
+ @@ -7,7 +7,7 @@
5
+ "lib"
6
+ ],
7
+ "dependencies": {
8
+ - "safe-buffer": "~5.2.0"
9
+ + "safe-buffer": "npm:@socketregistry/safe-buffer@1.0.9"
10
+ },
11
+ "devDependencies": {
12
+ "babel-polyfill": "^6.23.0",
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const CONTRACT_VERSION = '2.2.23';
3
+ const CONTRACT_VERSION = '2.2.25';
4
4
  const CONTRACT_START = '<!-- KONOHA-CONTRACT-START -->';
5
5
  const CONTRACT_END = '<!-- KONOHA-CONTRACT-END -->';
6
6
 
@@ -54,7 +54,7 @@ You are the ${roleLabel} running through ${clientLabel}. This contract is mandat
54
54
  - **Konoha is mandatory**: use the \`konoha\` MCP for skill discovery, skill loading, and bounded file operations. All clients call skills through \`konoha.find_skills\` (or \`find_skill\`) to discover global and project skills before work, and load matching content with \`konoha.get_skill\`. When a project contains local skills, the client auto-migrates them into the skills database, and the project tree is read alongside it, so an unmigrated skill stays discoverable. Never load raw SKILL.md files directly.
55
55
  - **Code intelligence is mandatory**: use the \`konoha\` \`code_search\`, \`code_symbol\`, and \`code_impact\` tools (native SQLite FTS5 index) for all project codebase discovery and search. Always pass the absolute repository \`root\`; run \`code_index\` first. Do not replace them with native grep, glob, find, or IDE search.
56
56
  - **Project rules & skills are additive, never replaced**: text a project wrote into \`AGENTS.md\`/\`CLAUDE.md\`/\`GEMINI.md\` outside the \`KONOHA-*\` markers is preserved verbatim, and \`find_skill\`/\`get_skill\`/\`list_skills\` serve the project's own \`.agents/skills\` tree alongside the Konoha skill database, so an unmigrated project skill is still discoverable and loadable.
57
- - **Cross-platform e2e is mandatory**: a change is done only after 3-OS verification passes across Linux, Windows, and macOS — locally across all 3 CI environments (1. Linux: Debian \`pnpm test:sandbox [-- --shard=I/8]\` + Ubuntu \`pnpm ci:act\` / \`pnpm ci:act:shard\`; 2. Windows: \`docker/windows-vm/oem/run-ci.cmd [-Shard I/N]\` / \`retest.cmd\` via \`dockur/windows\`; 3. macOS: \`KONOHA_SANDBOX_RUNTIME=container pnpm test:sandbox [-- --shard=I/8]\` + native replay or symlinked-\`HOME\` proxy) and \`.github/workflows/cross-platform.yml\` (push, PR, tag, dispatch, 02:00 UTC nightly). A single-OS green is not a delivery verdict.
57
+ - **Cross-platform e2e is mandatory**: a change is done only after 3-OS verification passes across Linux, Windows, and macOS — locally across all 3 CI environments (1. Linux: Debian \`pnpm test:sandbox [-- --shard=I/N]\` + Ubuntu \`pnpm ci:act\` / \`pnpm ci:act:shard\`; 2. Windows: \`docker/windows-vm/oem/run-ci.cmd [-Shard I/N]\` / \`retest.cmd\` via \`dockur/windows\`; 3. macOS: \`KONOHA_SANDBOX_RUNTIME=container pnpm test:sandbox [-- --shard=I/N]\` + native replay or symlinked-\`HOME\` proxy) and \`.github/workflows/cross-platform.yml\` (push, PR, manual dispatch, 02:00 UTC nightly). A single-OS green is not a delivery verdict.
58
58
  - **RTK is mandatory for commands**: ALWAYS force-run all shell/command executions with \`rtk <command>\` first; prefix shell/command execution with \`rtk\` to filter noisy terminal output and minimize token consumption. When RTK is not installed, fails, or is unsupported for a specific command, immediately fall back to direct shell/bash (\`sh\` / \`bash\`) execution without silently claiming RTK was used.
59
59
  - **Review token hygiene & strict changed-files scoping (NEVER BURN TOKENS)**: Across all clients (Pi, Antigravity, Cursor, Claude Code, OpenCode, CommandCode, Codex, OMP), agents MUST NEVER execute unscoped full-repository scans (\`aislop_scan\` without target path or \`aislop scan\` without \`--changes\` or specific file arguments). Unscoped full-repo scans evaluate thousands of files, dump giant multi-megabyte payloads, and exhaust agent token context. When invoking \`aislop_scan\` or executing CLI scans, ALWAYS pass specific changed file paths or use \`--changes\` to ensure bounded, token-efficient execution. NEVER dump raw full-repo scan output into conversation context; summarize counts and key findings only (score, error count, rule IDs) or use \`get_slop_findings(compact: true)\`. Single-file edits, isolated bug fixes, or routine configuration changes must NEVER trigger repository-wide slop refactoring loops. Only verify the specific files modified.
60
60
  - **Test directory discovery & reuse**: ALWAYS explore the codebase first (\`get_file_structure\` or \`find_files_clean\`) to discover existing test folders (\`tests/\`, \`test/\`, \`spec/\`). NEVER create duplicate test folders (e.g. creating \`test/\` when \`tests/\` exists).
@@ -208,47 +208,58 @@ function cleanObsoleteAgentDirs(_home = null) {
208
208
  function deployGlobalClientConfigs(options) {
209
209
  const { pythonCmd, serverPath, agents, projectRoot, deployProject, home } = options;
210
210
  const effectiveHome = home || process.env.HOME || process.env.USERPROFILE || os.homedir();
211
-
212
- try {
213
- mcpClientsManager.ensureClaudeCodeSetup({
214
- pythonCmd, serverPath, silent: true,
215
- ruleContent: generateClaudeCodeMd(agents), agents, projectRoot, deployProject, home: effectiveHome
216
- });
217
- } catch (_) { /* intentional best-effort fallback */ }
218
-
219
- try {
220
- const opencodeManager = require('./opencode_manager');
221
- opencodeManager.ensureOpenCodeSetup({
222
- pythonCmd, serverPath, agents, projectRoot, deployProject, silent: true, home: effectiveHome
223
- });
224
- } catch (_) { /* intentional best-effort fallback */ }
225
-
226
- try {
227
- const codexManager = require('./codex_manager');
228
- codexManager.ensureCodexSetup({
229
- pythonCmd, serverPath, agents, projectRoot, deployProject, silent: true, home: effectiveHome
230
- });
231
- } catch (_) { /* intentional best-effort fallback */ }
232
-
233
- try {
234
- mcpClientsManager.ensureCommandCodeSetup({
235
- pythonCmd, serverPath, agents, projectRoot, deployProject, silent: true, home: effectiveHome
236
- });
237
- } catch (_) { /* intentional best-effort fallback */ }
238
-
239
- try {
240
- const piManager = require("./pi_manager");
211
+ // One client failing must not stop the others, but it must not disappear
212
+ // either: swallowing every error made a half-deployed setup look complete.
213
+ const failures = [];
214
+ const run = (client, fn) => {
215
+ try { fn(); } catch (err) { failures.push({ client, error: err.message }); }
216
+ };
217
+
218
+ run('claudecode', () => mcpClientsManager.ensureClaudeCodeSetup({
219
+ pythonCmd, serverPath, silent: true,
220
+ ruleContent: generateClaudeCodeMd(agents), agents, projectRoot, deployProject, home: effectiveHome
221
+ }));
222
+
223
+ run('opencode', () => require('./opencode_manager').ensureOpenCodeSetup({
224
+ pythonCmd, serverPath, agents, projectRoot, deployProject, silent: true, home: effectiveHome
225
+ }));
226
+
227
+ run('codex', () => require('./codex_manager').ensureCodexSetup({
228
+ pythonCmd, serverPath, agents, projectRoot, deployProject, silent: true, home: effectiveHome
229
+ }));
230
+
231
+ run('commandcode', () => mcpClientsManager.ensureCommandCodeSetup({
232
+ pythonCmd, serverPath, agents, projectRoot, deployProject, silent: true, home: effectiveHome
233
+ }));
234
+
235
+ run('pi', () => {
236
+ const piManager = require('./pi_manager');
241
237
  if (options.force || piManager.isPiInstalled()) {
242
238
  piManager.ensurePiSetup({ pythonCmd, serverPath, silent: true, home: effectiveHome, force: options.force, skipDetection: options.force });
243
239
  }
244
- } catch (_) { /* intentional best-effort fallback */ }
240
+ });
245
241
 
246
- try {
247
- const ompManager = require("./omp_manager");
242
+ run('omp', () => {
243
+ const ompManager = require('./omp_manager');
248
244
  if (options.force || ompManager.isOmpInstalled()) {
249
245
  ompManager.ensureOmpSetup({ pythonCmd, serverPath, silent: true, home: effectiveHome, force: options.force });
250
246
  }
251
- } catch (_) { /* intentional best-effort fallback */ }
247
+ });
248
+
249
+ let commands = null;
250
+ run('commands', () => {
251
+ commands = require('./client_commands').deployKonohaCommands({
252
+ home: effectiveHome,
253
+ projectRoot: deployProject ? projectRoot : null,
254
+ force: options.force
255
+ });
256
+ });
257
+
258
+ if (failures.length > 0) {
259
+ const detail = failures.map((f) => `${f.client}: ${f.error}`).join('; ');
260
+ process.stderr.write(`[konoha deploy] ${failures.length} client deployment(s) incomplete: ${detail}\n`);
261
+ }
262
+ return { failures, commands };
252
263
  }
253
264
 
254
265
  function regenerateAndDeploy(silentOrOptions = false) {
@@ -325,7 +336,7 @@ function regenerateAndDeploy(silentOrOptions = false) {
325
336
  } catch (_) { /* intentional fallback */ }
326
337
 
327
338
  cleanObsoleteAgentDirs(effectiveHome);
328
- deployGlobalClientConfigs({ pythonCmd, serverPath, agents, projectRoot, deployProject, home: effectiveHome, force });
339
+ const deployment = deployGlobalClientConfigs({ pythonCmd, serverPath, agents, projectRoot, deployProject, home: effectiveHome, force });
329
340
 
330
341
  try {
331
342
  deployUtils.syncSoulAcrossClients({ home: effectiveHome, silent });
@@ -343,6 +354,7 @@ function regenerateAndDeploy(silentOrOptions = false) {
343
354
  } catch { /* intentional fallback */ }
344
355
  }
345
356
 
357
+ return { ok: deployment.failures.length === 0, failures: deployment.failures, commands: deployment.commands };
346
358
  }
347
359
 
348
360
  function deployProjectWorkspace(_projectRoot, _options = {}) {
@@ -360,6 +372,7 @@ module.exports = {
360
372
  stripLegacyKonohaPreamble,
361
373
  isProtectedUserPath,
362
374
  cleanObsoleteAgentDirs,
375
+ deployGlobalClientConfigs,
363
376
  regenerateAndDeploy,
364
377
  deployProjectWorkspace
365
378
  };
@@ -152,6 +152,62 @@ function _writeProtectedFileSafe(targetPath, content, isOwnedFn, conflictMeta =
152
152
  return { status: 'written', path: targetPath };
153
153
  }
154
154
 
155
+ const AGENT_PROFILE_DIRS = Object.freeze([
156
+ ['.claude', 'agents'],
157
+ ['.cursor', 'agents'],
158
+ ['.codex', 'agents'],
159
+ ['.config', 'opencode', 'agents'],
160
+ ['.commandcode', 'agents'],
161
+ ['.omp', 'agent', 'agents']
162
+ ]);
163
+
164
+ /**
165
+ * Classifies one parked `.konoha-proposed` candidate against the live file:
166
+ * `foreign` the live file is not Konoha's (or is unreadable), so Konoha's
167
+ * version never landed
168
+ * `stale` the live file is Konoha's own and differs from the parked copy;
169
+ * the candidate is residue, since Konoha's content is in place
170
+ * `identical` the parked copy equals the live file exactly
171
+ */
172
+ function _classifyAgentConflict(dir, entry) {
173
+ const proposed = path.join(dir, entry);
174
+ const target = path.join(dir, entry.slice(0, -'.konoha-proposed'.length));
175
+ const backup = `${target}.konoha-backup`;
176
+ const record = (kind) => ({ path: target, proposed, backup: fileExists(backup) ? backup : null, kind });
177
+ if (!fileExists(target)) return record('foreign');
178
+ let live;
179
+ try {
180
+ live = fs.readFileSync(target, 'utf8');
181
+ if (live === fs.readFileSync(proposed, 'utf8')) return record('identical');
182
+ } catch (_) {
183
+ return record('foreign');
184
+ }
185
+ return record(isKonohaOwnedAgentFile(target) ? 'stale' : 'foreign');
186
+ }
187
+
188
+ /**
189
+ * Reports agent files where Konoha's candidate was parked at
190
+ * `.konoha-proposed` instead of being deployed. Read-only: nothing is applied
191
+ * and nothing is deleted, because the file in place may be user-owned. Without
192
+ * this the conflict is invisible and the foreign profile silently stays in
193
+ * effect — which is how a client ends up spawning an agent nobody can resolve.
194
+ * @param {string} home user home directory
195
+ * @returns {Array<{path:string, proposed:string, backup:string|null, kind:string}>}
196
+ */
197
+ function listAgentConflicts(home) {
198
+ const root = home || require('os').homedir();
199
+ const conflicts = [];
200
+ for (const segments of AGENT_PROFILE_DIRS) {
201
+ const dir = path.join(root, ...segments);
202
+ let entries = [];
203
+ try { entries = fs.readdirSync(dir); } catch (_) { continue; }
204
+ for (const entry of entries) {
205
+ if (entry.endsWith('.konoha-proposed')) conflicts.push(_classifyAgentConflict(dir, entry));
206
+ }
207
+ }
208
+ return conflicts;
209
+ }
210
+
155
211
  /**
156
212
  * Safely writes an agent definition file without clobbering user-authored files.
157
213
  * Pre-existing foreign files stay intact, receive a one-time `.konoha-backup`,
@@ -208,6 +264,7 @@ module.exports = {
208
264
  isKonohaManagedRuleFile,
209
265
  writeAgentFileSafe,
210
266
  writeManagedFileSafe,
267
+ listAgentConflicts,
211
268
  snapshotNonKonohaRuleFiles,
212
269
  restoreNonKonohaRuleFiles
213
270
  };