tribunal-kit 5.8.5 → 6.0.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.
Files changed (298) hide show
  1. package/.agent/ARCHITECTURE.md +219 -215
  2. package/.agent/agents/accessibility-reviewer.md +66 -151
  3. package/.agent/agents/ai-code-reviewer.md +22 -2
  4. package/.agent/agents/anti-pattern-reviewer.md +99 -0
  5. package/.agent/agents/api-architect.md +19 -2
  6. package/.agent/agents/backend-specialist.md +25 -3
  7. package/.agent/agents/cloud-engineer.md +21 -0
  8. package/.agent/agents/code-archaeologist.md +20 -3
  9. package/.agent/agents/complexity-reviewer.md +22 -2
  10. package/.agent/agents/database-architect.md +24 -3
  11. package/.agent/agents/db-latency-auditor.md +22 -2
  12. package/.agent/agents/debugger.md +19 -3
  13. package/.agent/agents/dependency-reviewer.md +19 -2
  14. package/.agent/agents/devops-engineer.md +24 -3
  15. package/.agent/agents/documentation-writer.md +21 -3
  16. package/.agent/agents/explorer-agent.md +21 -3
  17. package/.agent/agents/frontend-reviewer.md +19 -3
  18. package/.agent/agents/frontend-specialist.md +72 -224
  19. package/.agent/agents/game-developer.md +22 -3
  20. package/.agent/agents/interaction-reviewer.md +118 -0
  21. package/.agent/agents/logic-reviewer.md +18 -3
  22. package/.agent/agents/minimalist-reviewer.md +98 -0
  23. package/.agent/agents/mobile-developer.md +21 -3
  24. package/.agent/agents/mobile-reviewer.md +22 -2
  25. package/.agent/agents/orchestrator.md +19 -3
  26. package/.agent/agents/penetration-tester.md +22 -3
  27. package/.agent/agents/performance-optimizer.md +21 -3
  28. package/.agent/agents/performance-reviewer.md +2 -0
  29. package/.agent/agents/precedence-reviewer.md +19 -5
  30. package/.agent/agents/product-manager.md +20 -3
  31. package/.agent/agents/product-owner.md +22 -1
  32. package/.agent/agents/product-reviewer.md +98 -0
  33. package/.agent/agents/project-planner.md +19 -3
  34. package/.agent/agents/qa-automation-engineer.md +24 -3
  35. package/.agent/agents/resilience-reviewer.md +21 -2
  36. package/.agent/agents/schema-reviewer.md +21 -2
  37. package/.agent/agents/security-auditor.md +7 -1
  38. package/.agent/agents/seo-specialist.md +18 -3
  39. package/.agent/agents/sql-reviewer.md +22 -2
  40. package/.agent/agents/supervisor-agent.md +22 -3
  41. package/.agent/agents/swarm-worker-registry.md +7 -0
  42. package/.agent/agents/system-architect.md +19 -0
  43. package/.agent/agents/test-coverage-reviewer.md +22 -2
  44. package/.agent/agents/test-engineer.md +21 -2
  45. package/.agent/agents/throughput-optimizer.md +22 -2
  46. package/.agent/agents/type-safety-reviewer.md +21 -2
  47. package/.agent/agents/ui-ux-auditor.md +44 -242
  48. package/.agent/agents/ui-visual-auditor.md +99 -0
  49. package/.agent/agents/ux-reviewer.md +104 -0
  50. package/.agent/agents/visual-reviewer.md +98 -0
  51. package/.agent/agents/vitals-reviewer.md +23 -2
  52. package/.agent/history/README.md +53 -0
  53. package/.agent/history/case-law/cases/template-case.json +19 -0
  54. package/.agent/history/integrity_manifest.json +63 -33
  55. package/.agent/history/memory/.memory.idx +517 -1
  56. package/.agent/history/memory/MEMORY.md +35 -1
  57. package/.agent/routing_index.json +272 -690
  58. package/.agent/rules/GEMINI.md +10 -12
  59. package/.agent/rules/GEMINI_PLANNER.md +84 -0
  60. package/.agent/scripts/case_law_manager.js +2 -0
  61. package/.agent/scripts/context_broker.js +152 -0
  62. package/.agent/scripts/guardrail_engine.js +59 -4
  63. package/.agent/scripts/impact_classifier.js +167 -0
  64. package/.agent/scripts/minimal_change_engine.js +437 -0
  65. package/.agent/scripts/pipeline_engine.js +856 -0
  66. package/.agent/scripts/socratic_gate_policy.js +60 -0
  67. package/.agent/scripts/token_budget_broker.js +52 -0
  68. package/.agent/scripts/verify_all.js +13 -0
  69. package/.agent/scripts/visual_audit.js +92 -0
  70. package/.agent/skills/12-principles-of-animation/SKILL.md +19 -10
  71. package/.agent/skills/60fps-animation/SKILL.md +19 -10
  72. package/.agent/skills/accessible-animation/SKILL.md +19 -10
  73. package/.agent/skills/adapt/SKILL.md +19 -10
  74. package/.agent/skills/advanced-rag-pipelines/SKILL.md +21 -3
  75. package/.agent/skills/agent-organizer/SKILL.md +21 -7
  76. package/.agent/skills/agentic-patterns/SKILL.md +19 -7
  77. package/.agent/skills/ai-prompt-injection-defense/SKILL.md +21 -7
  78. package/.agent/skills/animation-on-scroll/SKILL.md +19 -10
  79. package/.agent/skills/animation-systems/SKILL.md +19 -10
  80. package/.agent/skills/antfu-conventions/SKILL.md +21 -10
  81. package/.agent/skills/api-patterns/SKILL.md +21 -7
  82. package/.agent/skills/api-security-auditor/SKILL.md +21 -7
  83. package/.agent/skills/app-builder/SKILL.md +21 -7
  84. package/.agent/skills/apple-design/SKILL.md +19 -10
  85. package/.agent/skills/architecture/SKILL.md +21 -7
  86. package/.agent/skills/audit-and-fix/SKILL.md +19 -10
  87. package/.agent/skills/authentication-best-practices/SKILL.md +21 -7
  88. package/.agent/skills/backend-security-expert/SKILL.md +21 -7
  89. package/.agent/skills/baseline-ui/SKILL.md +19 -10
  90. package/.agent/skills/bash-linux/SKILL.md +21 -7
  91. package/.agent/skills/behavioral-modes/SKILL.md +19 -7
  92. package/.agent/skills/better-colors/SKILL.md +19 -10
  93. package/.agent/skills/better-ui/SKILL.md +19 -10
  94. package/.agent/skills/bolder/SKILL.md +19 -10
  95. package/.agent/skills/brainstorming/SKILL.md +17 -7
  96. package/.agent/skills/browser-native-ai/SKILL.md +19 -3
  97. package/.agent/skills/build-primitive/SKILL.md +19 -10
  98. package/.agent/skills/building-native-ui/SKILL.md +21 -7
  99. package/.agent/skills/cicd-pro/SKILL.md +21 -10
  100. package/.agent/skills/clarify/SKILL.md +19 -10
  101. package/.agent/skills/clean-code/SKILL.md +21 -7
  102. package/.agent/skills/cloud-architect/SKILL.md +21 -10
  103. package/.agent/skills/cobejs/SKILL.md +19 -10
  104. package/.agent/skills/code-review-checklist/SKILL.md +21 -7
  105. package/.agent/skills/codebase-design/SKILL.md +21 -10
  106. package/.agent/skills/colorize/SKILL.md +19 -10
  107. package/.agent/skills/compact-landing/SKILL.md +19 -10
  108. package/.agent/skills/company-logos/SKILL.md +19 -10
  109. package/.agent/skills/config-validator/SKILL.md +21 -7
  110. package/.agent/skills/containerization-pro/SKILL.md +21 -10
  111. package/.agent/skills/create-design-md/SKILL.md +19 -10
  112. package/.agent/skills/critique/SKILL.md +19 -10
  113. package/.agent/skills/csharp-developer/SKILL.md +21 -7
  114. package/.agent/skills/data-validation-schemas/SKILL.md +21 -7
  115. package/.agent/skills/database-design/SKILL.md +21 -7
  116. package/.agent/skills/delight/SKILL.md +19 -10
  117. package/.agent/skills/deployment-procedures/SKILL.md +21 -7
  118. package/.agent/skills/design-lab/SKILL.md +21 -10
  119. package/.agent/skills/devops-engineer/SKILL.md +21 -7
  120. package/.agent/skills/devops-incident-responder/SKILL.md +21 -7
  121. package/.agent/skills/diagnosing-bugs/SKILL.md +21 -10
  122. package/.agent/skills/distill/SKILL.md +19 -10
  123. package/.agent/skills/documentation-templates/SKILL.md +21 -7
  124. package/.agent/skills/domain-modeling/SKILL.md +21 -10
  125. package/.agent/skills/edge-computing/SKILL.md +21 -7
  126. package/.agent/skills/emil-design-eng/SKILL.md +19 -10
  127. package/.agent/skills/error-resilience/SKILL.md +21 -7
  128. package/.agent/skills/extract-design-system/SKILL.md +21 -7
  129. package/.agent/skills/fabel-protocol/SKILL.md +19 -2
  130. package/.agent/skills/fixing-accessibility/SKILL.md +19 -10
  131. package/.agent/skills/fixing-metadata/SKILL.md +19 -10
  132. package/.agent/skills/fixing-motion-performance/SKILL.md +19 -10
  133. package/.agent/skills/framer-motion-expert/SKILL.md +19 -6
  134. package/.agent/skills/frontend-design/SKILL.md +64 -201
  135. package/.agent/skills/frontend-security-expert/SKILL.md +21 -7
  136. package/.agent/skills/game-design-expert/SKILL.md +21 -7
  137. package/.agent/skills/game-engineering-expert/SKILL.md +21 -7
  138. package/.agent/skills/generative-ui-expert/SKILL.md +19 -3
  139. package/.agent/skills/geo-fundamentals/SKILL.md +21 -7
  140. package/.agent/skills/git-pro/SKILL.md +21 -10
  141. package/.agent/skills/github-operations/SKILL.md +21 -7
  142. package/.agent/skills/gpt-taste/SKILL.md +19 -10
  143. package/.agent/skills/gsap-core/SKILL.md +21 -4
  144. package/.agent/skills/gsap-frameworks/SKILL.md +21 -4
  145. package/.agent/skills/gsap-performance/SKILL.md +20 -5
  146. package/.agent/skills/gsap-plugins/SKILL.md +20 -5
  147. package/.agent/skills/gsap-react/SKILL.md +20 -5
  148. package/.agent/skills/gsap-scrolltrigger/SKILL.md +21 -4
  149. package/.agent/skills/gsap-timeline/SKILL.md +20 -5
  150. package/.agent/skills/gsap-utils/SKILL.md +20 -5
  151. package/.agent/skills/harden/SKILL.md +19 -10
  152. package/.agent/skills/harness-protocol/SKILL.md +20 -4
  153. package/.agent/skills/i18n-localization/SKILL.md +21 -7
  154. package/.agent/skills/impeccable/SKILL.md +19 -10
  155. package/.agent/skills/improve-codebase-architecture/SKILL.md +21 -10
  156. package/.agent/skills/improve-ui/SKILL.md +19 -10
  157. package/.agent/skills/intelligent-routing/SKILL.md +19 -7
  158. package/.agent/skills/knowledge-graph/SKILL.md +20 -4
  159. package/.agent/skills/landing-page/SKILL.md +20 -10
  160. package/.agent/skills/lint-and-validate/SKILL.md +21 -7
  161. package/.agent/skills/llm-engineering/SKILL.md +21 -7
  162. package/.agent/skills/local-first/SKILL.md +21 -7
  163. package/.agent/skills/local-first-architecture/SKILL.md +19 -10
  164. package/.agent/skills/lottie-animation/SKILL.md +19 -10
  165. package/.agent/skills/marquee-loop/SKILL.md +19 -10
  166. package/.agent/skills/masked-reveal/SKILL.md +19 -10
  167. package/.agent/skills/mcp-builder/SKILL.md +21 -7
  168. package/.agent/skills/micro-interaction/SKILL.md +19 -10
  169. package/.agent/skills/mobile-design/SKILL.md +21 -6
  170. package/.agent/skills/monorepo-management/SKILL.md +21 -7
  171. package/.agent/skills/morphing-icons/SKILL.md +19 -10
  172. package/.agent/skills/motion-engineering/SKILL.md +20 -7
  173. package/.agent/skills/nextjs-react-expert/SKILL.md +19 -7
  174. package/.agent/skills/nodejs-best-practices/SKILL.md +21 -7
  175. package/.agent/skills/observability/SKILL.md +21 -7
  176. package/.agent/skills/page-transition-animation/SKILL.md +19 -10
  177. package/.agent/skills/parallel-agents/SKILL.md +23 -7
  178. package/.agent/skills/performance-profiling/SKILL.md +21 -7
  179. package/.agent/skills/plan-writing/SKILL.md +21 -7
  180. package/.agent/skills/platform-engineer/SKILL.md +21 -7
  181. package/.agent/skills/playwright-best-practices/SKILL.md +21 -7
  182. package/.agent/skills/polish/SKILL.md +19 -10
  183. package/.agent/skills/powershell-windows/SKILL.md +21 -7
  184. package/.agent/skills/pricing-page/SKILL.md +19 -10
  185. package/.agent/skills/product-aware-heuristics/SKILL.md +358 -0
  186. package/.agent/skills/progressive-blur/SKILL.md +19 -10
  187. package/.agent/skills/project-idioms/SKILL.md +20 -8
  188. package/.agent/skills/python-patterns/SKILL.md +21 -7
  189. package/.agent/skills/python-pro/SKILL.md +21 -6
  190. package/.agent/skills/quieter/SKILL.md +19 -10
  191. package/.agent/skills/react-doctor/SKILL.md +19 -10
  192. package/.agent/skills/react-specialist/SKILL.md +19 -6
  193. package/.agent/skills/readme-builder/SKILL.md +21 -7
  194. package/.agent/skills/realtime-patterns/SKILL.md +21 -7
  195. package/.agent/skills/red-team-tactics/SKILL.md +21 -7
  196. package/.agent/skills/redesign-skill/SKILL.md +19 -10
  197. package/.agent/skills/review-animations/SKILL.md +21 -10
  198. package/.agent/skills/rust-pro/SKILL.md +21 -7
  199. package/.agent/skills/seo-fundamentals/SKILL.md +21 -7
  200. package/.agent/skills/server-management/SKILL.md +21 -7
  201. package/.agent/skills/shadcn-ui-expert/SKILL.md +21 -7
  202. package/.agent/skills/shape/SKILL.md +19 -10
  203. package/.agent/skills/skill-creator/SKILL.md +21 -7
  204. package/.agent/skills/soft-skill/SKILL.md +19 -10
  205. package/.agent/skills/sounds-on-the-web/SKILL.md +19 -10
  206. package/.agent/skills/sql-pro/SKILL.md +21 -7
  207. package/.agent/skills/supabase-postgres-best-practices/SKILL.md +21 -7
  208. package/.agent/skills/svg-animation/SKILL.md +19 -10
  209. package/.agent/skills/swiftui-expert/SKILL.md +21 -7
  210. package/.agent/skills/swiss-design/SKILL.md +19 -10
  211. package/.agent/skills/system-design-pro/SKILL.md +21 -9
  212. package/.agent/skills/systematic-debugging/SKILL.md +21 -7
  213. package/.agent/skills/tailwind-patterns/SKILL.md +21 -7
  214. package/.agent/skills/taste-skill/SKILL.md +19 -10
  215. package/.agent/skills/tdd-workflow/SKILL.md +21 -10
  216. package/.agent/skills/test-result-analyzer/SKILL.md +18 -6
  217. package/.agent/skills/testing-patterns/SKILL.md +21 -7
  218. package/.agent/skills/thermo-nuclear-code-quality-review/SKILL.md +21 -10
  219. package/.agent/skills/thinking-protocol/SKILL.md +20 -8
  220. package/.agent/skills/to-spring-or-not-to-spring/SKILL.md +19 -10
  221. package/.agent/skills/transitions-dev/SKILL.md +19 -10
  222. package/.agent/skills/trend-researcher/SKILL.md +17 -6
  223. package/.agent/skills/typescript-advanced/SKILL.md +21 -7
  224. package/.agent/skills/typeset/SKILL.md +19 -10
  225. package/.agent/skills/ui-reasoning-engine/SKILL.md +154 -0
  226. package/.agent/skills/ui-skill-packs/SKILL.md +77 -0
  227. package/.agent/skills/ui-skills-root/SKILL.md +21 -9
  228. package/.agent/skills/ui-ux-pro-max/SKILL.md +62 -583
  229. package/.agent/skills/ui-ux-researcher/SKILL.md +17 -6
  230. package/.agent/skills/vue-expert/SKILL.md +19 -6
  231. package/.agent/skills/vulnerability-scanner/SKILL.md +21 -7
  232. package/.agent/skills/web-accessibility-auditor/SKILL.md +21 -7
  233. package/.agent/skills/web-design-guidelines/SKILL.md +32 -206
  234. package/.agent/skills/web-quality-audit/SKILL.md +19 -10
  235. package/.agent/skills/webapp-testing/SKILL.md +21 -7
  236. package/.agent/skills/webgpu-performance/SKILL.md +19 -3
  237. package/.agent/skills/whimsy-injector/SKILL.md +20 -10
  238. package/.agent/skills/workflow-optimizer/SKILL.md +16 -6
  239. package/.agent/templates/DESIGN.md +292 -0
  240. package/.agent/templates/design-tokens.json +137 -0
  241. package/.agent/workflows/acf.md +13 -6
  242. package/.agent/workflows/api-tester.md +15 -8
  243. package/.agent/workflows/audit.md +19 -8
  244. package/.agent/workflows/brainstorm.md +14 -9
  245. package/.agent/workflows/changelog.md +14 -8
  246. package/.agent/workflows/create.md +16 -8
  247. package/.agent/workflows/debug.md +15 -10
  248. package/.agent/workflows/deploy.md +16 -8
  249. package/.agent/workflows/enhance.md +15 -10
  250. package/.agent/workflows/fix.md +15 -8
  251. package/.agent/workflows/generate.md +17 -11
  252. package/.agent/workflows/marathon.md +15 -8
  253. package/.agent/workflows/migrate.md +16 -8
  254. package/.agent/workflows/minimal.md +94 -0
  255. package/.agent/workflows/orchestrate.md +15 -8
  256. package/.agent/workflows/performance-benchmarker.md +15 -8
  257. package/.agent/workflows/pipeline.md +155 -0
  258. package/.agent/workflows/plan.md +14 -10
  259. package/.agent/workflows/preview.md +14 -7
  260. package/.agent/workflows/refactor.md +16 -8
  261. package/.agent/workflows/review-ai.md +15 -7
  262. package/.agent/workflows/review.md +15 -7
  263. package/.agent/workflows/session.md +14 -7
  264. package/.agent/workflows/status.md +13 -7
  265. package/.agent/workflows/strengthen-skills.md +15 -6
  266. package/.agent/workflows/super-prompt.md +19 -10
  267. package/.agent/workflows/swarm.md +15 -7
  268. package/.agent/workflows/test.md +15 -8
  269. package/.agent/workflows/tribunal-backend.md +16 -9
  270. package/.agent/workflows/tribunal-database.md +15 -8
  271. package/.agent/workflows/tribunal-frontend.md +26 -11
  272. package/.agent/workflows/tribunal-full.md +29 -14
  273. package/.agent/workflows/tribunal-mobile.md +15 -8
  274. package/.agent/workflows/tribunal-performance.md +15 -8
  275. package/.agent/workflows/tribunal-speed.md +16 -9
  276. package/.agent/workflows/tribunal-ui.md +82 -0
  277. package/.agent/workflows/ui-ux-pro-max.md +51 -107
  278. package/CONTRIBUTING.md +2 -2
  279. package/README.md +5 -5
  280. package/bin/mcp-server.js +81 -31
  281. package/bin/wrapper.js +17 -6
  282. package/dist/cli.js +9 -1
  283. package/dist/commands/compile.js +7 -0
  284. package/dist/commands/context.js +8 -3
  285. package/dist/commands/graph.js +8 -2
  286. package/dist/commands/init.js +13 -2
  287. package/dist/commands/memory.js +119 -68
  288. package/dist/commands/minimal.js +71 -0
  289. package/dist/commands/optimize.js +15 -5
  290. package/dist/esm/index.mjs +26 -32
  291. package/dist/utils/fs.js +10 -4
  292. package/dist/utils/helpers.js +10 -1
  293. package/dist/utils/version.js +9 -2
  294. package/mcp_config.json +10 -1
  295. package/package.json +17 -14
  296. package/scripts/benchmark.js +16 -0
  297. package/scripts/sync-version.js +1 -1
  298. package/scripts/visual_audit.js +126 -0
package/dist/cli.js CHANGED
@@ -247,6 +247,11 @@ async function runWithUpdateCheck(command, flags) {
247
247
  await cmdMarathon(flags, process.argv, quiet);
248
248
  break;
249
249
  }
250
+ case 'minimal': {
251
+ const cmdMinimal = loadCmd('./commands/minimal', 'cmdMinimal');
252
+ cmdMinimal(flags, quiet);
253
+ break;
254
+ }
250
255
  case 'compile': {
251
256
  const cmdCompile = loadCmd('./commands/compile', 'cmdCompile');
252
257
  await cmdCompile(flags, quiet);
@@ -317,5 +322,8 @@ async function main() {
317
322
  await runWithUpdateCheck(command, flags);
318
323
  }
319
324
  if (require.main === module) {
320
- main();
325
+ main().catch(err => {
326
+ console.error(`\x1b[91m✖ Fatal Error:\x1b[0m ${err.message || err}`);
327
+ process.exit(1);
328
+ });
321
329
  }
@@ -74,6 +74,13 @@ async function cmdCompile(flags, quiet) {
74
74
  if (flags.target === "claude") targetFile = ".claude.json";
75
75
  }
76
76
 
77
+ const byteLength = Buffer.byteLength(compiledContext, "utf-8");
78
+ const mbSize = byteLength / (1024 * 1024);
79
+ if (mbSize > 5.0 && !quiet) {
80
+ const { warn } = require("../utils/logger");
81
+ warn(`Compiled context is very large (~${mbSize.toFixed(2)} MB). This might overload some LLM context windows.`);
82
+ }
83
+
77
84
  const outputPath = path.join(cwd, targetFile);
78
85
  fs.writeFileSync(outputPath, compiledContext, "utf-8");
79
86
 
@@ -19,11 +19,16 @@ function cmdContext(flags, processArgs) {
19
19
  console.error('Usage: npx tribunal-kit context <target_file>');
20
20
  process.exit(1);
21
21
  }
22
- const targetFile = args[0].replace(/\\/g, '/');
23
- const snapshotName = targetFile.replace(/[\\\/]/g, '__') + '.json';
22
+ const resolvedTarget = path_1.default.resolve(targetDir, args[0]);
23
+ const relativePath = path_1.default.relative(targetDir, resolvedTarget).replace(/\\/g, '/');
24
+ if (relativePath.startsWith('../') || relativePath === '..' || path_1.default.isAbsolute(relativePath)) {
25
+ console.error(' \x1b[91m✖\x1b[0m File must be within the project directory: ' + args[0]);
26
+ process.exit(1);
27
+ }
28
+ const snapshotName = relativePath.replace(/[\\\/]/g, '__') + '.json';
24
29
  const snapshotPath = path_1.default.join(agentDest, 'history', 'snapshots', snapshotName);
25
30
  if (!fs_1.default.existsSync(snapshotPath)) {
26
- console.error(' \x1b[91m✖\x1b[0m Context Snapshot not found for: ' + targetFile);
31
+ console.error(' \x1b[91m✖\x1b[0m Context Snapshot not found for: ' + args[0]);
27
32
  console.log(' Run: npx tribunal-kit graph (to generate snapshots)');
28
33
  process.exit(1);
29
34
  }
@@ -23,8 +23,14 @@ async function cmdGraph(flags, quiet = false) {
23
23
  await (0, helpers_1.runShellAsync)(`node "${builderScript}"`, { stdio: 'inherit', cwd: targetDir });
24
24
  await (0, helpers_1.runShellAsync)(`node "${visualizerScript}"`, { stdio: 'inherit', cwd: targetDir });
25
25
  (0, logger_1.log)(` ${(0, logger_1.c)('cyan', '▸')} Opening visualizer in browser...`);
26
- const opener = process.platform === 'win32' ? 'start' : process.platform === 'darwin' ? 'open' : 'xdg-open';
27
- await (0, helpers_1.runShellAsync)(`${opener} "${htmlFile}"`, { stdio: 'ignore' });
26
+ const child_process = require('child_process');
27
+ if (process.platform === 'win32') {
28
+ child_process.spawn('cmd.exe', ['/c', 'start', '', htmlFile], { stdio: 'ignore', detached: true }).unref();
29
+ } else if (process.platform === 'darwin') {
30
+ child_process.spawn('open', [htmlFile], { stdio: 'ignore', detached: true }).unref();
31
+ } else {
32
+ child_process.spawn('xdg-open', [htmlFile], { stdio: 'ignore', detached: true }).unref();
33
+ }
28
34
  }
29
35
  catch (e) {
30
36
  if (e instanceof Error) {
@@ -26,13 +26,22 @@ const CORE_AGENTS = new Set([
26
26
  'explorer-agent.md',
27
27
  'project-planner.md',
28
28
  'test-engineer.md',
29
+ 'ui-ux-auditor.md',
30
+ 'ui-visual-auditor.md',
31
+ 'accessibility-reviewer.md',
32
+ 'ux-reviewer.md',
33
+ 'visual-reviewer.md',
34
+ 'interaction-reviewer.md',
35
+ 'anti-pattern-reviewer.md',
36
+ 'product-reviewer.md',
29
37
  ]);
30
38
  // Core skills to install in --minimal mode
31
39
  const CORE_SKILLS = new Set([
32
40
  'clean-code', 'architecture', 'testing-patterns', 'systematic-debugging',
33
41
  'frontend-design', 'database-design', 'api-patterns', 'nodejs-best-practices',
34
42
  'vulnerability-scanner', 'typescript-advanced', 'python-pro', 'nextjs-react-expert',
35
- 'react-specialist', 'performance-profiling', 'lint-and-validate',
43
+ 'react-specialist', 'performance-profiling', 'lint-and-validate', 'ui-ux-pro-max',
44
+ 'ui-reasoning-engine', 'product-aware-heuristics', 'web-design-guidelines',
36
45
  ]);
37
46
  async function cmdInit(flags, quiet = false) {
38
47
  const agentSrc = (0, helpers_1.getKitAgent)();
@@ -267,7 +276,7 @@ async function cmdInit(flags, quiet = false) {
267
276
  console.log(drawRow(' Next Steps:', (0, logger_1.c)('gray', ' Next Steps:')));
268
277
  console.log(stepRow('/generate', 'Generate code with reviews'));
269
278
  console.log(stepRow('/review', 'Audit existing code for issues'));
270
- console.log(stepRow('/tribunal-full', 'Run all 19 reviewers in parallel'));
279
+ console.log(stepRow('/tribunal-full', 'Run all 21 reviewers in parallel'));
271
280
  console.log(drawRow('', ''));
272
281
  console.log(` ${(0, logger_1.c)(borderCol, '└' + '─'.repeat(W) + '┘')}`);
273
282
  console.log();
@@ -399,4 +408,6 @@ async function scaffoldDesignSystem(targetDir, agentSrc, dryRun = false) {
399
408
  await copyIfMissing(designMdSrc, designMdDest, 'DESIGN.md System');
400
409
  await copyIfMissing(designTokensSrc, designTokensDest, 'Design Tokens');
401
410
  }
411
+ exports.CORE_AGENTS = CORE_AGENTS;
412
+ exports.CORE_SKILLS = CORE_SKILLS;
402
413
 
@@ -31,6 +31,42 @@ const PROJECTION_FILE = 'MEMORY.md';
31
31
  const MAX_ENTRIES = 500;
32
32
  const EPISODIC_TTL_DAYS = 30;
33
33
 
34
+ function acquireLock(agentDest) {
35
+ const lockPath = getIndexPath(agentDest) + '.lock';
36
+ const maxRetries = 10;
37
+ for (let i = 0; i < maxRetries; i++) {
38
+ try {
39
+ const fd = fs_1.default.openSync(lockPath, 'wx');
40
+ fs_1.default.closeSync(fd);
41
+ return lockPath;
42
+ } catch (err) {
43
+ if (err.code !== 'EEXIST') {
44
+ throw err;
45
+ }
46
+ const start = Date.now();
47
+ while (Date.now() - start < 50) {}
48
+ }
49
+ }
50
+ try {
51
+ const stats = fs_1.default.statSync(lockPath);
52
+ if (Date.now() - stats.mtimeMs > 10000) {
53
+ fs_1.default.unlinkSync(lockPath);
54
+ const fd = fs_1.default.openSync(lockPath, 'wx');
55
+ fs_1.default.closeSync(fd);
56
+ return lockPath;
57
+ }
58
+ } catch {}
59
+ throw new Error('Could not acquire lock for memory index');
60
+ }
61
+
62
+ function releaseLock(lockPath) {
63
+ try {
64
+ if (lockPath && fs_1.default.existsSync(lockPath)) {
65
+ fs_1.default.unlinkSync(lockPath);
66
+ }
67
+ } catch {}
68
+ }
69
+
34
70
  function getMemoryDir(agentDest) {
35
71
  return path_1.default.join(agentDest, MEMORY_DIR);
36
72
  }
@@ -121,95 +157,110 @@ function memoryStore(agentDest, type, content, tags, sessionId) {
121
157
  throw new Error('Memory content cannot be empty');
122
158
  }
123
159
 
124
- const index = loadIndex(agentDest);
160
+ const lockPath = acquireLock(agentDest);
161
+ try {
162
+ const index = loadIndex(agentDest);
125
163
 
126
- // Enforce cap — auto-GC if needed
127
- if (index.entries.length >= MAX_ENTRIES) {
128
- index.entries = index.entries.filter(e => e.memory_type !== 'working');
129
- if (index.entries.length >= MAX_ENTRIES) {
130
- index.entries = index.entries.filter(e => {
131
- if (e.memory_type === 'episodic') {
132
- return daysSince(e.created_at) < EPISODIC_TTL_DAYS;
133
- }
134
- return true;
135
- });
136
- }
164
+ // Enforce cap — auto-GC if needed
137
165
  if (index.entries.length >= MAX_ENTRIES) {
138
- throw new Error(`Memory at capacity (${MAX_ENTRIES}). Run: tk memory gc`);
166
+ index.entries = index.entries.filter(e => e.memory_type !== 'working');
167
+ if (index.entries.length >= MAX_ENTRIES) {
168
+ index.entries = index.entries.filter(e => {
169
+ if (e.memory_type === 'episodic') {
170
+ return daysSince(e.created_at) < EPISODIC_TTL_DAYS; // Typo correction or TTL match
171
+ }
172
+ return true;
173
+ });
174
+ }
175
+ if (index.entries.length >= MAX_ENTRIES) {
176
+ throw new Error(`Memory at capacity (${MAX_ENTRIES}). Run: tk memory gc`);
177
+ }
139
178
  }
140
- }
141
179
 
142
- const now = nowEpochStr();
143
- const id = index.next_id || (index.entries.length > 0 ? Math.max(...index.entries.map(e => e.id)) + 1 : 1);
144
- const entry = {
145
- id,
146
- memory_type: type,
147
- content: content.trim(),
148
- tags: tags.filter(t => t.length > 0),
149
- created_at: now,
150
- last_accessed: now,
151
- access_count: 0,
152
- token_estimate: estimateTokens(content),
153
- source: type === 'working' ? 'session' : 'manual',
154
- session_id: sessionId || null,
155
- };
156
-
157
- index.entries.push(entry);
158
- index.next_id = id + 1;
159
- saveIndex(agentDest, index);
160
- generateProjection(agentDest, index);
161
-
162
- return { id, token_estimate: entry.token_estimate };
180
+ const now = nowEpochStr();
181
+ const id = index.next_id || (index.entries.length > 0 ? Math.max(...index.entries.map(e => e.id)) + 1 : 1);
182
+ const entry = {
183
+ id,
184
+ memory_type: type,
185
+ content: content.trim(),
186
+ tags: tags.filter(t => t.length > 0),
187
+ created_at: now,
188
+ last_accessed: now,
189
+ access_count: 0,
190
+ token_estimate: estimateTokens(content),
191
+ source: type === 'working' ? 'session' : 'manual',
192
+ session_id: sessionId || null,
193
+ };
194
+
195
+ index.entries.push(entry);
196
+ index.next_id = id + 1;
197
+ saveIndex(agentDest, index);
198
+ generateProjection(agentDest, index);
199
+
200
+ return { id, token_estimate: entry.token_estimate };
201
+ } finally {
202
+ releaseLock(lockPath);
203
+ }
163
204
  }
164
205
 
165
206
  // ── Recall ──────────────────────────────────────────────────────────────────
166
207
 
167
208
  function memoryRecall(agentDest, query, budget = 2000) {
168
- const index = loadIndex(agentDest);
169
-
170
- const scored = index.entries
171
- .map(entry => ({ entry, score: computeScore(entry, query) }))
172
- .filter(s => s.score > 0)
173
- .sort((a, b) => b.score - a.score);
209
+ const lockPath = acquireLock(agentDest);
210
+ try {
211
+ const index = loadIndex(agentDest);
212
+
213
+ const scored = index.entries
214
+ .map(entry => ({ entry, score: computeScore(entry, query) }))
215
+ .filter(s => s.score > 0)
216
+ .sort((a, b) => b.score - a.score);
217
+
218
+ let totalTokens = 0;
219
+ const results = [];
220
+
221
+ for (const { entry, score } of scored) {
222
+ if (totalTokens + entry.token_estimate > budget) break;
223
+ totalTokens += entry.token_estimate;
224
+ entry.last_accessed = nowEpochStr();
225
+ entry.access_count = (entry.access_count || 0) + 1;
226
+ results.push({ ...entry, score });
227
+ }
174
228
 
175
- let totalTokens = 0;
176
- const results = [];
229
+ // Save updated access counts
230
+ saveIndex(agentDest, index);
177
231
 
178
- for (const { entry, score } of scored) {
179
- if (totalTokens + entry.token_estimate > budget) break;
180
- totalTokens += entry.token_estimate;
181
- entry.last_accessed = nowEpochStr();
182
- entry.access_count = (entry.access_count || 0) + 1;
183
- results.push({ ...entry, score });
232
+ return { results, tokens_used: totalTokens, budget };
233
+ } finally {
234
+ releaseLock(lockPath);
184
235
  }
185
-
186
- // Save updated access counts
187
- saveIndex(agentDest, index);
188
-
189
- return { results, tokens_used: totalTokens, budget };
190
236
  }
191
237
 
192
238
  // ── Garbage Collect ─────────────────────────────────────────────────────────
193
239
 
194
240
  function memoryGc(agentDest) {
195
- const index = loadIndex(agentDest);
196
- const before = index.entries.length;
241
+ const lockPath = acquireLock(agentDest);
242
+ try {
243
+ const index = loadIndex(agentDest);
244
+ const before = index.entries.length;
197
245
 
198
- let workingRemoved = 0;
199
- let episodicRemoved = 0;
246
+ let workingRemoved = 0;
247
+ let episodicRemoved = 0;
200
248
 
201
- index.entries = index.entries.filter(e => {
202
- if (e.memory_type === 'working') { workingRemoved++; return false; }
203
- if (e.memory_type === 'episodic' && daysSince(e.created_at) >= EPISODIC_TTL_DAYS) {
204
- episodicRemoved++; return false;
205
- }
206
- return true;
207
- });
249
+ index.entries = index.entries.filter(e => {
250
+ if (e.memory_type === 'working') { workingRemoved++; return false; }
251
+ if (e.memory_type === 'episodic' && daysSince(e.created_at) >= EPISODIC_TTL_DAYS) {
252
+ episodicRemoved++; return false;
253
+ }
254
+ return true;
255
+ });
208
256
 
209
- saveIndex(agentDest, index);
210
- generateProjection(agentDest, index);
257
+ saveIndex(agentDest, index);
258
+ generateProjection(agentDest, index);
211
259
 
212
- return { working_removed: workingRemoved, episodic_removed: episodicRemoved, before, after: index.entries.length };
260
+ return { working_removed: workingRemoved, episodic_removed: episodicRemoved, before, after: index.entries.length };
261
+ } finally {
262
+ releaseLock(lockPath);
263
+ }
213
264
  }
214
265
 
215
266
  // ── Stats ───────────────────────────────────────────────────────────────────
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.cmdMinimal = cmdMinimal;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const logger_1 = require("../utils/logger");
10
+ const helpers_1 = require("../utils/helpers");
11
+
12
+ function cmdMinimal(flags, quiet = false) {
13
+ const targetDir = flags.path ? path_1.default.resolve(flags.path) : process.cwd();
14
+ const agentDest = path_1.default.join(targetDir, '.agent');
15
+ (0, helpers_1.banner)(quiet);
16
+
17
+ if (!fs_1.default.existsSync(agentDest)) {
18
+ (0, logger_1.log)(` ${(0, logger_1.c)('red', '✖')} ${(0, logger_1.bold)('Not installed')} in this project`);
19
+ return;
20
+ }
21
+
22
+ const enginePath = path_1.default.join(agentDest, 'scripts', 'minimal_change_engine.js');
23
+ if (!fs_1.default.existsSync(enginePath)) {
24
+ (0, logger_1.log)(` ${(0, logger_1.c)('red', '✖')} minimal_change_engine.js not found`);
25
+ return;
26
+ }
27
+
28
+ try {
29
+ const engine = require(enginePath);
30
+ const task = flags.task || flags._?.slice(1).join(' ') || 'Default task evaluation';
31
+ const mode = flags.mode || 'balanced';
32
+ const result = engine.evaluateMinimalChange(task, {
33
+ files_added: flags.filesAdded ? parseInt(flags.filesAdded, 10) : 0,
34
+ files_modified: flags.filesModified ? parseInt(flags.filesModified, 10) : 1,
35
+ estimated_lines_added: flags.linesAdded ? parseInt(flags.linesAdded, 10) : 20,
36
+ }, { mode, cwd: targetDir });
37
+
38
+ if (flags.json) {
39
+ console.log(JSON.stringify(result, null, 2));
40
+ return;
41
+ }
42
+
43
+ (0, logger_1.log)(` ${(0, logger_1.bold)('Minimal Change Governance Audit')}`);
44
+ (0, logger_1.log)(` Minimality Score: ${result.passed ? (0, logger_1.c)('green', result.minimality_score + '/100') : (0, logger_1.c)('red', result.minimality_score + '/100')}`);
45
+ (0, logger_1.log)(` Decision Classification: ${(0, logger_1.c)('cyan', result.minimality_classification)}`);
46
+ (0, logger_1.log)(` Strictness Mode: ${(0, logger_1.c)('yellow', mode)}`);
47
+ console.log();
48
+
49
+ if (result.change_budget) {
50
+ (0, logger_1.log)(` ${(0, logger_1.bold)('Change Budget:')}`);
51
+ (0, logger_1.log)(` files_added: ${result.change_budget.files_added}`);
52
+ (0, logger_1.log)(` files_modified: ${result.change_budget.files_modified}`);
53
+ (0, logger_1.log)(` dependencies_added: ${result.change_budget.dependencies_added}`);
54
+ (0, logger_1.log)(` new_abstractions: ${result.change_budget.new_abstractions}`);
55
+ console.log();
56
+ }
57
+
58
+ if (result.complexity_flags.length > 0) {
59
+ (0, logger_1.log)(` ${(0, logger_1.c)('yellow', 'Complexity Flags Detected:')}`);
60
+ result.complexity_flags.forEach(f => {
61
+ (0, logger_1.log)(` • [${f.severity.toUpperCase()}] ${f.type}: ${f.evidence}`);
62
+ });
63
+ console.log();
64
+ } else {
65
+ (0, logger_1.log)(` ${(0, logger_1.c)('green', '✔ Zero Complexity Flags Detected')}`);
66
+ console.log();
67
+ }
68
+ } catch (err) {
69
+ (0, logger_1.log)(` ${(0, logger_1.c)('red', '✖ Error executing Minimal Change Engine:')} ${err.message}`);
70
+ }
71
+ }
@@ -9,7 +9,7 @@ const fs = __importDefault(require("fs"));
9
9
  const path = __importDefault(require("path"));
10
10
  const os = __importDefault(require("os"));
11
11
  const https = __importDefault(require("https"));
12
- const { execSync } = require("child_process");
12
+ const { execSync, spawnSync } = require("child_process");
13
13
  const logger = require("../utils/logger");
14
14
  const helpers = require("../utils/helpers");
15
15
 
@@ -253,10 +253,20 @@ Each edit must follow this schema:
253
253
  const tempFile = path.default.join(os.default.tmpdir(), `edits-${Date.now()}.json`);
254
254
  fs.default.writeFileSync(tempFile, cleanedJson, 'utf8');
255
255
 
256
- optResultStr = execSync(
257
- `"${binPath}" optimize-step --skill-path "${skillPath}" --edits-json "${cleanedJson.replace(/"/g, '\\"')}" --budget ${editBudget}`,
258
- { encoding: 'utf8', cwd: targetDir, stdio: 'pipe' }
259
- );
256
+ const result = spawnSync(binPath, [
257
+ "optimize-step",
258
+ "--skill-path",
259
+ skillPath,
260
+ "--edits-json",
261
+ cleanedJson,
262
+ "--budget",
263
+ String(editBudget)
264
+ ], { encoding: 'utf8', cwd: targetDir, stdio: 'pipe' });
265
+
266
+ if (result.error) {
267
+ throw result.error;
268
+ }
269
+ optResultStr = result.stdout || "";
260
270
 
261
271
  try { fs.default.unlinkSync(tempFile); } catch {}
262
272
  } catch (e) {
@@ -34,83 +34,77 @@ export const runShellAsync = helpers.runShellAsync;
34
34
  export const getKitAgent = helpers.getKitAgent;
35
35
  export const banner = helpers.banner;
36
36
 
37
+ // Helper to wrap CommonJS requires in friendly error diagnostics
38
+ function loadCommand(modulePath, functionName, ...args) {
39
+ try {
40
+ const mod = require(modulePath);
41
+ return mod[functionName](...args);
42
+ } catch (err) {
43
+ throw new Error(`Tribunal ESM wrapper failed to load command '${functionName}' from '${modulePath}': ${err.message}`);
44
+ }
45
+ }
46
+
37
47
  // ── Lazy command loaders (imported on demand) ────────────
38
48
  export async function cmdInit(flags, quiet) {
39
- const mod = require('../commands/init.js');
40
- return mod.cmdInit(flags, quiet);
49
+ return loadCommand('../commands/init.js', 'cmdInit', flags, quiet);
41
50
  }
42
51
 
43
52
  export async function cmdUpdate(flags) {
44
- const mod = require('../commands/update.js');
45
- return mod.cmdUpdate(flags);
53
+ return loadCommand('../commands/update.js', 'cmdUpdate', flags);
46
54
  }
47
55
 
48
56
  export function cmdStatus(flags, quiet) {
49
- const mod = require('../commands/status.js');
50
- return mod.cmdStatus(flags, quiet);
57
+ return loadCommand('../commands/status.js', 'cmdStatus', flags, quiet);
51
58
  }
52
59
 
53
60
  export async function cmdLearn(flags, quiet) {
54
- const mod = require('../commands/learn.js');
55
- return mod.cmdLearn(flags, quiet);
61
+ return loadCommand('../commands/learn.js', 'cmdLearn', flags, quiet);
56
62
  }
57
63
 
58
64
  export async function cmdCase(flags, argv, quiet) {
59
- const mod = require('../commands/case.js');
60
- return mod.cmdCase(flags, argv, quiet);
65
+ return loadCommand('../commands/case.js', 'cmdCase', flags, argv, quiet);
61
66
  }
62
67
 
63
68
  export function cmdHook(flags) {
64
- const mod = require('../commands/hook.js');
65
- return mod.cmdHook(flags);
69
+ return loadCommand('../commands/hook.js', 'cmdHook', flags);
66
70
  }
67
71
 
68
72
  export async function cmdGraph(flags, quiet) {
69
- const mod = require('../commands/graph.js');
70
- return mod.cmdGraph(flags, quiet);
73
+ return loadCommand('../commands/graph.js', 'cmdGraph', flags, quiet);
71
74
  }
72
75
 
73
76
  export async function cmdMutate(flags, argv) {
74
- const mod = require('../commands/mutate.js');
75
- return mod.cmdMutate(flags, argv);
77
+ return loadCommand('../commands/mutate.js', 'cmdMutate', flags, argv);
76
78
  }
77
79
 
78
80
  export function cmdContext(flags, argv) {
79
- const mod = require('../commands/context.js');
80
- return mod.cmdContext(flags, argv);
81
+ return loadCommand('../commands/context.js', 'cmdContext', flags, argv);
81
82
  }
82
83
 
83
84
  export async function cmdSync() {
84
- const mod = require('../commands/sync.js');
85
- return mod.cmdSync();
85
+ return loadCommand('../commands/sync.js', 'cmdSync');
86
86
  }
87
87
 
88
88
  export async function cmdAlign(flags, argv, quiet) {
89
- const mod = require('../commands/align.js');
90
- return mod.cmdAlign(flags, argv, quiet);
89
+ return loadCommand('../commands/align.js', 'cmdAlign', flags, argv, quiet);
91
90
  }
92
91
 
93
92
  export async function cmdMarathon(flags, argv, quiet) {
94
- const mod = require('../commands/marathon.js');
95
- return mod.cmdMarathon(flags, argv, quiet);
93
+ return loadCommand('../commands/marathon.js', 'cmdMarathon', flags, argv, quiet);
96
94
  }
97
95
 
98
96
  export async function cmdCompile(flags, quiet) {
99
- const mod = require('../commands/compile.js');
100
- return mod.cmdCompile(flags, quiet);
97
+ return loadCommand('../commands/compile.js', 'cmdCompile', flags, quiet);
101
98
  }
102
99
 
103
100
  export async function cmdMemory(flags, argv, quiet) {
104
- const mod = require('../commands/memory.js');
105
- return mod.cmdMemory(flags, argv, quiet);
101
+ return loadCommand('../commands/memory.js', 'cmdMemory', flags, argv, quiet);
106
102
  }
107
103
 
108
104
  export function cmdUninstall(flags, quiet) {
109
- const mod = require('../commands/uninstall.js');
110
- return mod.cmdUninstall(flags, quiet);
105
+ return loadCommand('../commands/uninstall.js', 'cmdUninstall', flags, quiet);
111
106
  }
112
107
 
113
108
  export async function generateIDEBridges(cwd, agentDest, quiet) {
114
- const mod = require('../commands/init.js');
115
- return mod.generateIDEBridges(cwd, agentDest, quiet);
109
+ return loadCommand('../commands/init.js', 'generateIDEBridges', cwd, agentDest, quiet);
116
110
  }
package/dist/utils/fs.js CHANGED
@@ -12,7 +12,10 @@ const logger_1 = require("./logger");
12
12
  // Concurrency limit for parallel file operations to avoid fd exhaustion
13
13
  const COPY_CONCURRENCY = 32;
14
14
 
15
- async function copyDir(src, dest, dryRun = false, filter = null) {
15
+ async function copyDir(src, dest, dryRun = false, filter = null, currentDepth = 0) {
16
+ if (currentDepth > 20) {
17
+ throw new Error(`Maximum directory copy depth (20) exceeded at: ${src}`);
18
+ }
16
19
  if (!dryRun) {
17
20
  await fs_1.default.promises.mkdir(dest, { recursive: true });
18
21
  }
@@ -51,7 +54,7 @@ async function copyDir(src, dest, dryRun = false, filter = null) {
51
54
 
52
55
  // Recurse into directories in parallel (dirs are I/O-independent)
53
56
  const dirResults = await Promise.all(
54
- dirs.map(({ srcPath, destPath }) => copyDir(srcPath, destPath, dryRun, filter))
57
+ dirs.map(({ srcPath, destPath }) => copyDir(srcPath, destPath, dryRun, filter, currentDepth + 1))
55
58
  );
56
59
  for (const dirCount of dirResults) {
57
60
  count += dirCount;
@@ -59,12 +62,15 @@ async function copyDir(src, dest, dryRun = false, filter = null) {
59
62
 
60
63
  return count;
61
64
  }
62
- async function countDir(dir) {
65
+ async function countDir(dir, currentDepth = 0) {
66
+ if (currentDepth > 20) {
67
+ throw new Error(`Maximum directory count depth (20) exceeded at: ${dir}`);
68
+ }
63
69
  let count = 0;
64
70
  const entries = await fs_1.default.promises.readdir(dir, { withFileTypes: true });
65
71
  for (const e of entries) {
66
72
  if (e.isDirectory())
67
- count += await countDir(path_1.default.join(dir, e.name));
73
+ count += await countDir(path_1.default.join(dir, e.name), currentDepth + 1);
68
74
  else
69
75
  count++;
70
76
  }
@@ -12,14 +12,23 @@ const path_1 = __importDefault(require("path"));
12
12
  const logger_1 = require("./logger");
13
13
  function runShellAsync(command, options) {
14
14
  return new Promise((resolve, reject) => {
15
+ const timeoutMs = (options && options.timeout) || 120000;
15
16
  const child = (0, child_process_1.spawn)(command, [], { ...options, shell: true });
17
+ const timer = setTimeout(() => {
18
+ child.kill('SIGTERM');
19
+ reject(new Error(`Command timed out after ${timeoutMs}ms: ${command}`));
20
+ }, timeoutMs);
16
21
  child.on('close', code => {
22
+ clearTimeout(timer);
17
23
  if (code !== 0)
18
24
  reject(new Error(`Command failed with exit code ${code}`));
19
25
  else
20
26
  resolve();
21
27
  });
22
- child.on('error', reject);
28
+ child.on('error', err => {
29
+ clearTimeout(timer);
30
+ reject(err);
31
+ });
23
32
  });
24
33
  }
25
34
  function getKitAgent() {
@@ -119,18 +119,25 @@ function fetchLatestVersion(currentVersion) {
119
119
  *
120
120
  * Returns true if a re-invoke happened (caller should exit), false otherwise.
121
121
  */
122
+ let hasRegisteredUpdateNotifier = false;
123
+
122
124
  async function autoUpdateCheck(originalArgs, currentVersion) {
123
125
  // Recursion guard: if we're already a re-invoked process, skip
124
126
  if (process.env.TK_SKIP_UPDATE_CHECK === '1') {
125
127
  return false;
126
128
  }
127
129
 
130
+ if (hasRegisteredUpdateNotifier) {
131
+ return false;
132
+ }
133
+ hasRegisteredUpdateNotifier = true;
134
+
128
135
  // Fire the fetch but DON'T await it immediately — let the command run first
129
136
  const versionPromise = fetchLatestVersion(currentVersion);
130
137
 
131
- // Register a process.on('beforeExit') hook to show the update notification
138
+ // Register a process.once('beforeExit') hook to show the update notification
132
139
  // AFTER the command has finished executing
133
- process.on('beforeExit', async () => {
140
+ process.once('beforeExit', async () => {
134
141
  try {
135
142
  const latestVersion = await versionPromise;
136
143
  if (!latestVersion) return;