tribunal-kit 9.0.2 → 9.2.3

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 (691) hide show
  1. package/.agent/agents/backend-specialist.md +1 -1
  2. package/.agent/agents/code-archaeologist.md +1 -1
  3. package/.agent/agents/database-architect.md +1 -1
  4. package/.agent/agents/debugger.md +1 -1
  5. package/.agent/agents/devops-engineer.md +1 -1
  6. package/.agent/agents/documentation-writer.md +1 -1
  7. package/.agent/agents/explorer-agent.md +1 -1
  8. package/.agent/agents/game-developer.md +1 -1
  9. package/.agent/agents/minimalist-reviewer.md +1 -1
  10. package/.agent/agents/mobile-developer.md +1 -1
  11. package/.agent/agents/orchestrator.md +44 -2
  12. package/.agent/agents/penetration-tester.md +1 -1
  13. package/.agent/agents/performance-optimizer.md +1 -1
  14. package/.agent/agents/product-manager.md +1 -1
  15. package/.agent/agents/product-owner.md +1 -1
  16. package/.agent/agents/project-planner.md +1 -1
  17. package/.agent/agents/qa-automation-engineer.md +1 -1
  18. package/.agent/agents/seo-specialist.md +1 -1
  19. package/.agent/agents/test-engineer.md +1 -1
  20. package/.agent/config/claude.json +1 -1
  21. package/.agent/config/plugin.json +1 -1
  22. package/.agent/history/architecture-explorer.html +352 -0
  23. package/.agent/history/architecture-graph.yaml +181 -1
  24. package/.agent/history/graph-cache.json +323 -13
  25. package/.agent/history/integrity_manifest.json +3937 -299
  26. package/.agent/history/memory/.memory.idx +50 -50
  27. package/.agent/history/snapshots/.opencode__plugins__tribunal.js.json +12 -0
  28. package/.agent/history/snapshots/.pi__extensions__tribunal.ts.json +12 -0
  29. package/.agent/history/snapshots/bin__adapter-install.js.json +1 -1
  30. package/.agent/history/snapshots/bin__mcp-server.js.json +4 -2
  31. package/.agent/history/snapshots/bin__proxy-server.js.json +1 -1
  32. package/.agent/history/snapshots/bin__spawn-agent.js.json +1 -1
  33. package/.agent/history/snapshots/bin__wrapper.js.json +1 -1
  34. package/.agent/history/snapshots/eslint.config.js.json +1 -1
  35. package/.agent/history/snapshots/hooks__session-start.js.json +11 -0
  36. package/.agent/history/snapshots/scripts__apply-version.js.json +11 -0
  37. package/.agent/history/snapshots/scripts__audit_skill_sdo.js.json +11 -0
  38. package/.agent/history/snapshots/scripts__clean-pycache.js.json +11 -0
  39. package/.agent/history/snapshots/scripts__context_compiler.js.json +17 -0
  40. package/.agent/history/snapshots/scripts__modernize_skills.js.json +11 -0
  41. package/.agent/history/snapshots/scripts__package-cores.js.json +12 -0
  42. package/.agent/history/snapshots/scripts__skill_enhancement_engine.js.json +11 -0
  43. package/.agent/history/snapshots/scripts__sync-skills.js.json +11 -0
  44. package/.agent/history/snapshots/scripts__telemetry_gc.js.json +11 -0
  45. package/.agent/history/snapshots/scripts__validate-payload.js.json +1 -1
  46. package/.agent/history/snapshots/test__integration__browser_cli.test.js.json +12 -0
  47. package/.agent/history/snapshots/test__integration__sync_status.test.js.json +1 -1
  48. package/.agent/history/snapshots/test__unit__ast_context_loader.test.js.json +12 -0
  49. package/.agent/history/snapshots/test__unit__browser_case_bridge.test.js.json +11 -0
  50. package/.agent/history/snapshots/test__unit__browser_discovery.test.js.json +10 -0
  51. package/.agent/history/snapshots/test__unit__browser_idpi.test.js.json +10 -0
  52. package/.agent/history/snapshots/test__unit__browser_sentinel.test.js.json +11 -0
  53. package/.agent/history/snapshots/test__unit__browser_synapse.test.js.json +10 -0
  54. package/.agent/history/snapshots/test__unit__browser_trimmer.test.js.json +10 -0
  55. package/.agent/history/snapshots/test__unit__context_compiler.test.js.json +26 -0
  56. package/.agent/history/snapshots/test__unit__init.test.js.json +1 -1
  57. package/.agent/history/snapshots/test__unit__learn.test.js.json +1 -1
  58. package/.agent/history/snapshots/test__unit__mcp_server.test.js.json +1 -1
  59. package/.agent/history/snapshots/test__unit__platform_download_audit.test.js.json +11 -0
  60. package/.agent/history/snapshots/test__unit__prompt_compiler.test.js.json +10 -0
  61. package/.agent/history/snapshots/test__unit__sdd_integration.test.js.json +12 -0
  62. package/.agent/history/snapshots/test__unit__stress.test.js.json +1 -1
  63. package/.agent/history/snapshots/test__unit__token_budget_broker.test.js.json +10 -0
  64. package/.agent/history/snapshots/test__unit__tui.test.js.json +10 -0
  65. package/.agent/routing_index.json +266 -1531
  66. package/.agent/rules/kernel.md +86 -0
  67. package/.agent/scripts/_utils.js +78 -0
  68. package/.agent/scripts/browser_audit.js +13 -5
  69. package/.agent/scripts/bundle_analyzer.js +7 -3
  70. package/.agent/scripts/context_broker.js +0 -8
  71. package/.agent/scripts/context_compiler.js +1106 -3
  72. package/.agent/scripts/dependency_analyzer.js +16 -16
  73. package/.agent/scripts/guardrail_engine.js +48 -11
  74. package/.agent/scripts/inner_loop_validator.js +1 -1
  75. package/.agent/scripts/memory_engine.js +490 -329
  76. package/.agent/scripts/payload_schemas.js +18 -0
  77. package/.agent/scripts/pipeline_engine.js +29 -105
  78. package/.agent/scripts/schema_validator.js +2 -1
  79. package/.agent/scripts/swarm_dispatcher.js +148 -46
  80. package/.agent/scripts/test_runner.js +1 -2
  81. package/.agent/skill_topic_map.json +71 -22
  82. package/.agent/skills/12-principles-of-animation/SKILL.md +1 -76
  83. package/.agent/skills/60fps-animation/SKILL.md +4 -77
  84. package/.agent/skills/accessible-animation/SKILL.md +9 -86
  85. package/.agent/skills/adapt/SKILL.md +1 -76
  86. package/.agent/skills/advanced-rag-pipelines/SKILL.md +1 -76
  87. package/.agent/skills/agent-organizer/SKILL.md +1 -76
  88. package/.agent/skills/agentic-patterns/SKILL.md +1 -76
  89. package/.agent/skills/agentic-workflows-2026/SKILL.md +1 -75
  90. package/.agent/skills/ai-app-hardening/SKILL.md +1 -75
  91. package/.agent/skills/ai-prompt-injection-defense/SKILL.md +1 -76
  92. package/.agent/skills/animation-on-scroll/SKILL.md +16 -87
  93. package/.agent/skills/animation-systems/SKILL.md +15 -90
  94. package/.agent/skills/antfu-conventions/SKILL.md +0 -75
  95. package/.agent/skills/api-patterns/SKILL.md +1 -76
  96. package/.agent/skills/api-security-auditor/SKILL.md +1 -76
  97. package/.agent/skills/app-builder/SKILL.md +1 -76
  98. package/.agent/skills/appflow-wireframe/SKILL.md +1 -78
  99. package/.agent/skills/apple-design/SKILL.md +1 -76
  100. package/.agent/skills/architecture/SKILL.md +1 -76
  101. package/.agent/skills/audit-and-fix/SKILL.md +41 -77
  102. package/.agent/skills/authentication-best-practices/SKILL.md +1 -76
  103. package/.agent/skills/backend-security-expert/SKILL.md +1 -76
  104. package/.agent/skills/baseline-ui/SKILL.md +1 -76
  105. package/.agent/skills/bash-linux/SKILL.md +1 -76
  106. package/.agent/skills/behavioral-modes/SKILL.md +1 -76
  107. package/.agent/skills/better-colors/SKILL.md +1 -76
  108. package/.agent/skills/better-typography/SKILL.md +1 -75
  109. package/.agent/skills/better-ui/SKILL.md +18 -81
  110. package/.agent/skills/bolder/SKILL.md +1 -76
  111. package/.agent/skills/brainstorming/SKILL.md +1 -75
  112. package/.agent/skills/browser-audit/SKILL.md +15 -83
  113. package/.agent/skills/browser-native-ai/SKILL.md +1 -76
  114. package/.agent/skills/build-primitive/SKILL.md +1 -76
  115. package/.agent/skills/building-native-ui/SKILL.md +1 -76
  116. package/.agent/skills/cicd-pro/SKILL.md +1 -76
  117. package/.agent/skills/clarify/SKILL.md +1 -76
  118. package/.agent/skills/clean-code/SKILL.md +1 -76
  119. package/.agent/skills/cloud-architect/SKILL.md +1 -76
  120. package/.agent/skills/cobejs/SKILL.md +1 -76
  121. package/.agent/skills/code-review-checklist/SKILL.md +1 -76
  122. package/.agent/skills/codebase-design/SKILL.md +1 -76
  123. package/.agent/skills/colorize/SKILL.md +1 -76
  124. package/.agent/skills/compact-landing/SKILL.md +1 -76
  125. package/.agent/skills/company-logos/SKILL.md +1 -76
  126. package/.agent/skills/config-validator/SKILL.md +1 -76
  127. package/.agent/skills/containerization-pro/SKILL.md +1 -76
  128. package/.agent/skills/context-engineering-pro/SKILL.md +1 -75
  129. package/.agent/skills/create-design-md/SKILL.md +1 -76
  130. package/.agent/skills/critique/SKILL.md +1 -76
  131. package/.agent/skills/csharp-developer/SKILL.md +1 -76
  132. package/.agent/skills/data-validation-schemas/SKILL.md +1 -76
  133. package/.agent/skills/database-design/SKILL.md +1 -76
  134. package/.agent/skills/delight/SKILL.md +1 -76
  135. package/.agent/skills/deployment-procedures/SKILL.md +1 -76
  136. package/.agent/skills/design-lab/SKILL.md +0 -75
  137. package/.agent/skills/devops-engineer/SKILL.md +1 -76
  138. package/.agent/skills/devops-incident-responder/SKILL.md +1 -76
  139. package/.agent/skills/diagnosing-bugs/SKILL.md +0 -75
  140. package/.agent/skills/distill/SKILL.md +1 -76
  141. package/.agent/skills/documentation-templates/SKILL.md +1 -76
  142. package/.agent/skills/domain-modeling/SKILL.md +1 -76
  143. package/.agent/skills/duckdb-analytical-sql/SKILL.md +1 -75
  144. package/.agent/skills/edge-ai-mobile/SKILL.md +1 -75
  145. package/.agent/skills/edge-computing/SKILL.md +1 -76
  146. package/.agent/skills/emil-design-eng/SKILL.md +1 -76
  147. package/.agent/skills/error-resilience/SKILL.md +1 -76
  148. package/.agent/skills/expo-router-v4/SKILL.md +1 -75
  149. package/.agent/skills/extract-design-system/SKILL.md +1 -76
  150. package/.agent/skills/fabel-protocol/SKILL.md +1 -76
  151. package/.agent/skills/fixing-accessibility/SKILL.md +1 -76
  152. package/.agent/skills/fixing-metadata/SKILL.md +1 -76
  153. package/.agent/skills/fixing-motion-performance/SKILL.md +1 -76
  154. package/.agent/skills/framer-motion-expert/SKILL.md +1 -76
  155. package/.agent/skills/frontend-design/SKILL.md +1 -76
  156. package/.agent/skills/frontend-security-expert/SKILL.md +1 -76
  157. package/.agent/skills/game-design-expert/SKILL.md +1 -76
  158. package/.agent/skills/game-engineering-expert/SKILL.md +1 -76
  159. package/.agent/skills/generative-ui-expert/SKILL.md +1 -76
  160. package/.agent/skills/geo-fundamentals/SKILL.md +1 -76
  161. package/.agent/skills/git-pro/SKILL.md +1 -76
  162. package/.agent/skills/github-operations/SKILL.md +1 -76
  163. package/.agent/skills/gpt-taste/SKILL.md +1 -76
  164. package/.agent/skills/gsap-core/SKILL.md +1 -76
  165. package/.agent/skills/gsap-frameworks/SKILL.md +1 -76
  166. package/.agent/skills/gsap-performance/SKILL.md +1 -76
  167. package/.agent/skills/gsap-plugins/SKILL.md +1 -76
  168. package/.agent/skills/gsap-react/SKILL.md +1 -76
  169. package/.agent/skills/gsap-scrolltrigger/SKILL.md +1 -76
  170. package/.agent/skills/gsap-timeline/SKILL.md +1 -76
  171. package/.agent/skills/gsap-utils/SKILL.md +1 -76
  172. package/.agent/skills/harden/SKILL.md +1 -76
  173. package/.agent/skills/harness-protocol/SKILL.md +1 -76
  174. package/.agent/skills/i18n-localization/SKILL.md +1 -76
  175. package/.agent/skills/impeccable/SKILL.md +1 -76
  176. package/.agent/skills/improve-codebase-architecture/SKILL.md +1 -76
  177. package/.agent/skills/improve-ui/SKILL.md +1 -76
  178. package/.agent/skills/intelligent-routing/SKILL.md +2 -87
  179. package/.agent/skills/knowledge-graph/SKILL.md +1 -76
  180. package/.agent/skills/landing-page/SKILL.md +1 -76
  181. package/.agent/skills/lint-and-validate/SKILL.md +1 -76
  182. package/.agent/skills/llm-engineering/SKILL.md +1 -76
  183. package/.agent/skills/local-first/SKILL.md +1 -76
  184. package/.agent/skills/local-first-architecture/SKILL.md +1 -76
  185. package/.agent/skills/lottie-animation/SKILL.md +1 -76
  186. package/.agent/skills/marquee-loop/SKILL.md +1 -76
  187. package/.agent/skills/masked-reveal/SKILL.md +1 -76
  188. package/.agent/skills/mcp-builder/SKILL.md +1 -76
  189. package/.agent/skills/micro-interaction/SKILL.md +19 -87
  190. package/.agent/skills/mobile-design/SKILL.md +1 -76
  191. package/.agent/skills/monorepo-management/SKILL.md +1 -76
  192. package/.agent/skills/morphing-icons/SKILL.md +1 -76
  193. package/.agent/skills/motion-engineering/SKILL.md +1 -76
  194. package/.agent/skills/nextjs-react-expert/SKILL.md +1 -76
  195. package/.agent/skills/nodejs-best-practices/SKILL.md +1 -76
  196. package/.agent/skills/observability/SKILL.md +1 -76
  197. package/.agent/skills/opentelemetry-observability/SKILL.md +1 -75
  198. package/.agent/skills/page-transition-animation/SKILL.md +1 -76
  199. package/.agent/skills/parallel-agents/SKILL.md +1 -76
  200. package/.agent/skills/performance-profiling/SKILL.md +1 -76
  201. package/.agent/skills/plan-writing/SKILL.md +1 -76
  202. package/.agent/skills/platform-engineer/SKILL.md +1 -76
  203. package/.agent/skills/platform-engineering-opentofu/SKILL.md +1 -75
  204. package/.agent/skills/playwright-ai-e2e/SKILL.md +1 -75
  205. package/.agent/skills/playwright-best-practices/SKILL.md +1 -76
  206. package/.agent/skills/polish/SKILL.md +1 -76
  207. package/.agent/skills/powershell-windows/SKILL.md +1 -76
  208. package/.agent/skills/pricing-page/SKILL.md +1 -76
  209. package/.agent/skills/product-aware-heuristics/SKILL.md +1 -76
  210. package/.agent/skills/progressive-blur/SKILL.md +1 -76
  211. package/.agent/skills/project-idioms/SKILL.md +1 -76
  212. package/.agent/skills/property-based-testing/SKILL.md +1 -75
  213. package/.agent/skills/python-patterns/SKILL.md +1 -76
  214. package/.agent/skills/python-pro/SKILL.md +1 -76
  215. package/.agent/skills/quieter/SKILL.md +1 -76
  216. package/.agent/skills/react-doctor/SKILL.md +1 -76
  217. package/.agent/skills/react-specialist/SKILL.md +1 -76
  218. package/.agent/skills/readme-builder/SKILL.md +1 -76
  219. package/.agent/skills/realtime-patterns/SKILL.md +1 -76
  220. package/.agent/skills/red-team-tactics/SKILL.md +1 -76
  221. package/.agent/skills/redesign-skill/SKILL.md +1 -76
  222. package/.agent/skills/review-animations/SKILL.md +1 -76
  223. package/.agent/skills/rust-pro/SKILL.md +1 -76
  224. package/.agent/skills/seo-fundamentals/SKILL.md +1 -76
  225. package/.agent/skills/server-management/SKILL.md +1 -76
  226. package/.agent/skills/shadcn-ui-expert/SKILL.md +1 -76
  227. package/.agent/skills/shape/SKILL.md +1 -76
  228. package/.agent/skills/skill-creator/SKILL.md +127 -86
  229. package/.agent/skills/soft-skill/SKILL.md +1 -76
  230. package/.agent/skills/sounds-on-the-web/SKILL.md +1 -76
  231. package/.agent/skills/sql-pro/SKILL.md +1 -76
  232. package/.agent/skills/supabase-postgres-best-practices/SKILL.md +1 -76
  233. package/.agent/skills/svg-animation/SKILL.md +1 -76
  234. package/.agent/skills/swiftui-expert/SKILL.md +1 -76
  235. package/.agent/skills/swiss-design/SKILL.md +1 -76
  236. package/.agent/skills/system-design-pro/SKILL.md +1 -76
  237. package/.agent/skills/systematic-debugging/SKILL.md +2 -76
  238. package/.agent/skills/systematic-debugging/condition-based-waiting.md +14 -9
  239. package/.agent/skills/systematic-debugging/defense-in-depth.md +9 -3
  240. package/.agent/skills/systematic-debugging/root-cause-tracing.md +14 -0
  241. package/.agent/skills/tailwind-patterns/SKILL.md +1 -76
  242. package/.agent/skills/taste-skill/SKILL.md +1 -76
  243. package/.agent/skills/tdd-workflow/SKILL.md +8 -82
  244. package/.agent/skills/test-result-analyzer/SKILL.md +1 -76
  245. package/.agent/skills/testing-patterns/SKILL.md +1 -76
  246. package/.agent/skills/thermo-nuclear-code-quality-review/SKILL.md +1 -76
  247. package/.agent/skills/thinking-protocol/SKILL.md +1 -77
  248. package/.agent/skills/to-spring-or-not-to-spring/SKILL.md +1 -76
  249. package/.agent/skills/transitions-dev/SKILL.md +1 -76
  250. package/.agent/skills/trend-researcher/SKILL.md +1 -76
  251. package/.agent/skills/typescript-advanced/SKILL.md +1 -76
  252. package/.agent/skills/typeset/SKILL.md +1 -76
  253. package/.agent/skills/ui-reasoning-engine/SKILL.md +1 -76
  254. package/.agent/skills/ui-skill-packs/SKILL.md +1 -76
  255. package/.agent/skills/ui-skills-root/SKILL.md +1 -76
  256. package/.agent/skills/ui-ux-pro-max/SKILL.md +1 -76
  257. package/.agent/skills/ui-ux-researcher/SKILL.md +1 -76
  258. package/.agent/skills/vector-search-pgvector/SKILL.md +1 -75
  259. package/.agent/skills/verification-before-completion/SKILL.md +20 -91
  260. package/.agent/skills/vue-expert/SKILL.md +1 -76
  261. package/.agent/skills/vulnerability-scanner/SKILL.md +1 -76
  262. package/.agent/skills/web-accessibility-auditor/SKILL.md +1 -76
  263. package/.agent/skills/web-design-guidelines/SKILL.md +1 -76
  264. package/.agent/skills/web-quality-audit/SKILL.md +1 -76
  265. package/.agent/skills/webapp-testing/SKILL.md +1 -76
  266. package/.agent/skills/webgpu-performance/SKILL.md +1 -76
  267. package/.agent/skills/whimsy-injector/SKILL.md +1 -76
  268. package/.agent/skills/workflow-optimizer/SKILL.md +1 -76
  269. package/.agent/skills/zero-trust-passkeys/SKILL.md +1 -75
  270. package/.agent/templates/DESIGN.md +312 -290
  271. package/.agent/templates/sdd/task-reviewer-prompt.md +2 -2
  272. package/.agent/workflows/audit-live.md +4 -3
  273. package/.agent/workflows/brainstorm.md +1 -0
  274. package/.agent/workflows/context.md +9 -7
  275. package/.agent/workflows/generate.md +1 -1
  276. package/.agent/workflows/minimal.md +3 -2
  277. package/.agent/workflows/orchestrate.md +1 -1
  278. package/.agent/workflows/plan.md +1 -1
  279. package/.agent/workflows/review-ai.md +1 -1
  280. package/.agent/workflows/sdd.md +15 -0
  281. package/.agent/workflows/skill-enhancement-engine.md +17 -21
  282. package/.agent/workflows/super-prompt.md +25 -24
  283. package/.agent/workflows/swarm.md +1 -1
  284. package/.agent/workflows/tribunal-backend.md +1 -1
  285. package/.agent/workflows/tribunal-cicd.md +1 -1
  286. package/.agent/workflows/tribunal-database.md +1 -1
  287. package/.agent/workflows/tribunal-frontend.md +1 -1
  288. package/.agent/workflows/tribunal-full.md +9 -9
  289. package/.agent/workflows/tribunal-mobile.md +1 -1
  290. package/.agent/workflows/tribunal-speed.md +1 -1
  291. package/.agent/workflows/tribunal-ui.md +1 -1
  292. package/.agents/skills/12-principles-of-animation/SKILL.md +1 -76
  293. package/.agents/skills/60fps-animation/SKILL.md +4 -77
  294. package/.agents/skills/accessible-animation/SKILL.md +9 -86
  295. package/.agents/skills/adapt/SKILL.md +1 -76
  296. package/.agents/skills/advanced-rag-pipelines/SKILL.md +1 -76
  297. package/.agents/skills/agent-organizer/SKILL.md +1 -76
  298. package/.agents/skills/agentic-patterns/SKILL.md +1 -76
  299. package/.agents/skills/agentic-workflows-2026/SKILL.md +1 -75
  300. package/.agents/skills/ai-app-hardening/SKILL.md +1 -75
  301. package/.agents/skills/ai-prompt-injection-defense/SKILL.md +1 -76
  302. package/.agents/skills/animation-on-scroll/SKILL.md +16 -87
  303. package/.agents/skills/animation-systems/SKILL.md +15 -90
  304. package/.agents/skills/antfu-conventions/SKILL.md +0 -75
  305. package/.agents/skills/api-patterns/SKILL.md +1 -76
  306. package/.agents/skills/api-security-auditor/SKILL.md +1 -76
  307. package/.agents/skills/app-builder/SKILL.md +1 -76
  308. package/.agents/skills/appflow-wireframe/SKILL.md +1 -78
  309. package/.agents/skills/apple-design/SKILL.md +1 -76
  310. package/.agents/skills/architecture/SKILL.md +1 -76
  311. package/.agents/skills/audit-and-fix/SKILL.md +41 -77
  312. package/.agents/skills/authentication-best-practices/SKILL.md +1 -76
  313. package/.agents/skills/backend-security-expert/SKILL.md +1 -76
  314. package/.agents/skills/baseline-ui/SKILL.md +1 -76
  315. package/.agents/skills/bash-linux/SKILL.md +1 -76
  316. package/.agents/skills/behavioral-modes/SKILL.md +1 -76
  317. package/.agents/skills/better-colors/SKILL.md +1 -76
  318. package/.agents/skills/better-typography/SKILL.md +1 -75
  319. package/.agents/skills/better-ui/SKILL.md +18 -81
  320. package/.agents/skills/bolder/SKILL.md +1 -76
  321. package/.agents/skills/brainstorming/SKILL.md +1 -75
  322. package/.agents/skills/browser-audit/SKILL.md +15 -83
  323. package/.agents/skills/browser-native-ai/SKILL.md +1 -76
  324. package/.agents/skills/build-primitive/SKILL.md +1 -76
  325. package/.agents/skills/building-native-ui/SKILL.md +1 -76
  326. package/.agents/skills/cicd-pro/SKILL.md +1 -76
  327. package/.agents/skills/clarify/SKILL.md +1 -76
  328. package/.agents/skills/clean-code/SKILL.md +1 -76
  329. package/.agents/skills/cloud-architect/SKILL.md +1 -76
  330. package/.agents/skills/cobejs/SKILL.md +1 -76
  331. package/.agents/skills/code-review-checklist/SKILL.md +1 -76
  332. package/.agents/skills/codebase-design/SKILL.md +1 -76
  333. package/.agents/skills/colorize/SKILL.md +1 -76
  334. package/.agents/skills/compact-landing/SKILL.md +1 -76
  335. package/.agents/skills/company-logos/SKILL.md +1 -76
  336. package/.agents/skills/config-validator/SKILL.md +1 -76
  337. package/.agents/skills/containerization-pro/SKILL.md +1 -76
  338. package/.agents/skills/context-engineering-pro/SKILL.md +1 -75
  339. package/.agents/skills/create-design-md/SKILL.md +1 -76
  340. package/.agents/skills/critique/SKILL.md +1 -76
  341. package/.agents/skills/csharp-developer/SKILL.md +1 -76
  342. package/.agents/skills/data-validation-schemas/SKILL.md +1 -76
  343. package/.agents/skills/database-design/SKILL.md +1 -76
  344. package/.agents/skills/delight/SKILL.md +1 -76
  345. package/.agents/skills/deployment-procedures/SKILL.md +1 -76
  346. package/.agents/skills/design-lab/SKILL.md +0 -75
  347. package/.agents/skills/devops-engineer/SKILL.md +1 -76
  348. package/.agents/skills/devops-incident-responder/SKILL.md +1 -76
  349. package/.agents/skills/diagnosing-bugs/SKILL.md +0 -75
  350. package/.agents/skills/distill/SKILL.md +1 -76
  351. package/.agents/skills/documentation-templates/SKILL.md +1 -76
  352. package/.agents/skills/domain-modeling/SKILL.md +1 -76
  353. package/.agents/skills/duckdb-analytical-sql/SKILL.md +1 -75
  354. package/.agents/skills/edge-ai-mobile/SKILL.md +1 -75
  355. package/.agents/skills/edge-computing/SKILL.md +1 -76
  356. package/.agents/skills/emil-design-eng/SKILL.md +1 -76
  357. package/.agents/skills/error-resilience/SKILL.md +1 -76
  358. package/.agents/skills/expo-router-v4/SKILL.md +1 -75
  359. package/.agents/skills/extract-design-system/SKILL.md +1 -76
  360. package/.agents/skills/fabel-protocol/SKILL.md +1 -76
  361. package/.agents/skills/fixing-accessibility/SKILL.md +1 -76
  362. package/.agents/skills/fixing-metadata/SKILL.md +1 -76
  363. package/.agents/skills/fixing-motion-performance/SKILL.md +1 -76
  364. package/.agents/skills/framer-motion-expert/SKILL.md +1 -76
  365. package/.agents/skills/frontend-design/SKILL.md +1 -76
  366. package/.agents/skills/frontend-security-expert/SKILL.md +1 -76
  367. package/.agents/skills/game-design-expert/SKILL.md +1 -76
  368. package/.agents/skills/game-engineering-expert/SKILL.md +1 -76
  369. package/.agents/skills/generative-ui-expert/SKILL.md +1 -76
  370. package/.agents/skills/geo-fundamentals/SKILL.md +1 -76
  371. package/.agents/skills/git-pro/SKILL.md +1 -76
  372. package/.agents/skills/github-operations/SKILL.md +1 -76
  373. package/.agents/skills/gpt-taste/SKILL.md +1 -76
  374. package/.agents/skills/gsap-core/SKILL.md +1 -76
  375. package/.agents/skills/gsap-frameworks/SKILL.md +1 -76
  376. package/.agents/skills/gsap-performance/SKILL.md +1 -76
  377. package/.agents/skills/gsap-plugins/SKILL.md +1 -76
  378. package/.agents/skills/gsap-react/SKILL.md +1 -76
  379. package/.agents/skills/gsap-scrolltrigger/SKILL.md +1 -76
  380. package/.agents/skills/gsap-timeline/SKILL.md +1 -76
  381. package/.agents/skills/gsap-utils/SKILL.md +1 -76
  382. package/.agents/skills/harden/SKILL.md +1 -76
  383. package/.agents/skills/harness-protocol/SKILL.md +1 -76
  384. package/.agents/skills/i18n-localization/SKILL.md +1 -76
  385. package/.agents/skills/impeccable/SKILL.md +1 -76
  386. package/.agents/skills/improve-codebase-architecture/SKILL.md +1 -76
  387. package/.agents/skills/improve-ui/SKILL.md +1 -76
  388. package/.agents/skills/intelligent-routing/SKILL.md +2 -87
  389. package/.agents/skills/knowledge-graph/SKILL.md +1 -76
  390. package/.agents/skills/landing-page/SKILL.md +1 -76
  391. package/.agents/skills/lint-and-validate/SKILL.md +1 -76
  392. package/.agents/skills/llm-engineering/SKILL.md +1 -76
  393. package/.agents/skills/local-first/SKILL.md +1 -76
  394. package/.agents/skills/local-first-architecture/SKILL.md +1 -76
  395. package/.agents/skills/lottie-animation/SKILL.md +1 -76
  396. package/.agents/skills/marquee-loop/SKILL.md +1 -76
  397. package/.agents/skills/masked-reveal/SKILL.md +1 -76
  398. package/.agents/skills/mcp-builder/SKILL.md +1 -76
  399. package/.agents/skills/micro-interaction/SKILL.md +19 -87
  400. package/.agents/skills/mobile-design/SKILL.md +1 -76
  401. package/.agents/skills/monorepo-management/SKILL.md +1 -76
  402. package/.agents/skills/morphing-icons/SKILL.md +1 -76
  403. package/.agents/skills/motion-engineering/SKILL.md +1 -76
  404. package/.agents/skills/nextjs-react-expert/SKILL.md +1 -76
  405. package/.agents/skills/nodejs-best-practices/SKILL.md +1 -76
  406. package/.agents/skills/observability/SKILL.md +1 -76
  407. package/.agents/skills/opentelemetry-observability/SKILL.md +1 -75
  408. package/.agents/skills/page-transition-animation/SKILL.md +1 -76
  409. package/.agents/skills/parallel-agents/SKILL.md +1 -76
  410. package/.agents/skills/performance-profiling/SKILL.md +1 -76
  411. package/.agents/skills/plan-writing/SKILL.md +1 -76
  412. package/.agents/skills/platform-engineer/SKILL.md +1 -76
  413. package/.agents/skills/platform-engineering-opentofu/SKILL.md +1 -75
  414. package/.agents/skills/playwright-ai-e2e/SKILL.md +1 -75
  415. package/.agents/skills/playwright-best-practices/SKILL.md +1 -76
  416. package/.agents/skills/polish/SKILL.md +1 -76
  417. package/.agents/skills/powershell-windows/SKILL.md +1 -76
  418. package/.agents/skills/pricing-page/SKILL.md +1 -76
  419. package/.agents/skills/product-aware-heuristics/SKILL.md +1 -76
  420. package/.agents/skills/progressive-blur/SKILL.md +1 -76
  421. package/.agents/skills/project-idioms/SKILL.md +1 -76
  422. package/.agents/skills/property-based-testing/SKILL.md +1 -75
  423. package/.agents/skills/python-patterns/SKILL.md +1 -76
  424. package/.agents/skills/python-pro/SKILL.md +1 -76
  425. package/.agents/skills/quieter/SKILL.md +1 -76
  426. package/.agents/skills/react-doctor/SKILL.md +1 -76
  427. package/.agents/skills/react-specialist/SKILL.md +1 -76
  428. package/.agents/skills/readme-builder/SKILL.md +1 -76
  429. package/.agents/skills/realtime-patterns/SKILL.md +1 -76
  430. package/.agents/skills/red-team-tactics/SKILL.md +1 -76
  431. package/.agents/skills/redesign-skill/SKILL.md +1 -76
  432. package/.agents/skills/review-animations/SKILL.md +1 -76
  433. package/.agents/skills/rust-pro/SKILL.md +1 -76
  434. package/.agents/skills/seo-fundamentals/SKILL.md +1 -76
  435. package/.agents/skills/server-management/SKILL.md +1 -76
  436. package/.agents/skills/shadcn-ui-expert/SKILL.md +1 -76
  437. package/.agents/skills/shape/SKILL.md +1 -76
  438. package/.agents/skills/skill-creator/SKILL.md +127 -86
  439. package/.agents/skills/soft-skill/SKILL.md +1 -76
  440. package/.agents/skills/sounds-on-the-web/SKILL.md +1 -76
  441. package/.agents/skills/sql-pro/SKILL.md +1 -76
  442. package/.agents/skills/supabase-postgres-best-practices/SKILL.md +1 -76
  443. package/.agents/skills/svg-animation/SKILL.md +1 -76
  444. package/.agents/skills/swiftui-expert/SKILL.md +1 -76
  445. package/.agents/skills/swiss-design/SKILL.md +1 -76
  446. package/.agents/skills/system-design-pro/SKILL.md +1 -76
  447. package/.agents/skills/systematic-debugging/SKILL.md +2 -76
  448. package/.agents/skills/systematic-debugging/condition-based-waiting.md +14 -9
  449. package/.agents/skills/systematic-debugging/defense-in-depth.md +9 -3
  450. package/.agents/skills/systematic-debugging/root-cause-tracing.md +14 -0
  451. package/.agents/skills/tailwind-patterns/SKILL.md +1 -76
  452. package/.agents/skills/taste-skill/SKILL.md +1 -76
  453. package/.agents/skills/tdd-workflow/SKILL.md +8 -82
  454. package/.agents/skills/test-result-analyzer/SKILL.md +1 -76
  455. package/.agents/skills/testing-patterns/SKILL.md +1 -76
  456. package/.agents/skills/thermo-nuclear-code-quality-review/SKILL.md +1 -76
  457. package/.agents/skills/thinking-protocol/SKILL.md +1 -77
  458. package/.agents/skills/to-spring-or-not-to-spring/SKILL.md +1 -76
  459. package/.agents/skills/transitions-dev/SKILL.md +1 -76
  460. package/.agents/skills/trend-researcher/SKILL.md +1 -76
  461. package/.agents/skills/typescript-advanced/SKILL.md +1 -76
  462. package/.agents/skills/typeset/SKILL.md +1 -76
  463. package/.agents/skills/ui-reasoning-engine/SKILL.md +1 -76
  464. package/.agents/skills/ui-skill-packs/SKILL.md +1 -76
  465. package/.agents/skills/ui-skills-root/SKILL.md +1 -76
  466. package/.agents/skills/ui-ux-pro-max/SKILL.md +1 -76
  467. package/.agents/skills/ui-ux-researcher/SKILL.md +1 -76
  468. package/.agents/skills/vector-search-pgvector/SKILL.md +1 -75
  469. package/.agents/skills/verification-before-completion/SKILL.md +20 -91
  470. package/.agents/skills/vue-expert/SKILL.md +1 -76
  471. package/.agents/skills/vulnerability-scanner/SKILL.md +1 -76
  472. package/.agents/skills/web-accessibility-auditor/SKILL.md +1 -76
  473. package/.agents/skills/web-design-guidelines/SKILL.md +1 -76
  474. package/.agents/skills/web-quality-audit/SKILL.md +1 -76
  475. package/.agents/skills/webapp-testing/SKILL.md +1 -76
  476. package/.agents/skills/webgpu-performance/SKILL.md +1 -76
  477. package/.agents/skills/whimsy-injector/SKILL.md +1 -76
  478. package/.agents/skills/workflow-optimizer/SKILL.md +1 -76
  479. package/.agents/skills/zero-trust-passkeys/SKILL.md +1 -75
  480. package/.codex-plugin/plugin.json +1 -5
  481. package/.kimi-plugin/plugin.json +1 -5
  482. package/.opencode/INSTALL.md +1 -0
  483. package/.opencode/plugins/tribunal.js +15 -6
  484. package/.pi/extensions/tribunal.ts +26 -29
  485. package/AGENTS.md +15 -13
  486. package/CLAUDE.md +3 -1
  487. package/README.md +23 -16
  488. package/bin/adapter-install.js +1 -1
  489. package/bin/mcp-server.js +88 -58
  490. package/bin/wrapper.js +22 -2
  491. package/dist/commands/init.js +25 -11
  492. package/dist/tui/banner.js +77 -77
  493. package/gemini-extension.json +1 -1
  494. package/package.json +13 -10
  495. package/plugin.json +1 -1
  496. package/scripts/apply-version.js +2 -2
  497. package/scripts/audit_skill_sdo.js +6 -4
  498. package/scripts/context_compiler.js +256 -83
  499. package/scripts/modernize_skills.js +25 -11
  500. package/scripts/package-cores.js +4 -1
  501. package/scripts/skill_enhancement_engine.js +212 -77
  502. package/scripts/telemetry_gc.js +156 -0
  503. package/scripts/validate-payload.js +1 -6
  504. package/skills/12-principles-of-animation/SKILL.md +1 -76
  505. package/skills/60fps-animation/SKILL.md +4 -77
  506. package/skills/accessible-animation/SKILL.md +9 -86
  507. package/skills/adapt/SKILL.md +1 -76
  508. package/skills/advanced-rag-pipelines/SKILL.md +1 -76
  509. package/skills/agent-organizer/SKILL.md +1 -76
  510. package/skills/agentic-patterns/SKILL.md +1 -76
  511. package/skills/agentic-workflows-2026/SKILL.md +1 -75
  512. package/skills/ai-app-hardening/SKILL.md +1 -75
  513. package/skills/ai-prompt-injection-defense/SKILL.md +1 -76
  514. package/skills/animation-on-scroll/SKILL.md +16 -87
  515. package/skills/animation-systems/SKILL.md +15 -90
  516. package/skills/antfu-conventions/SKILL.md +0 -75
  517. package/skills/api-patterns/SKILL.md +1 -76
  518. package/skills/api-security-auditor/SKILL.md +1 -76
  519. package/skills/app-builder/SKILL.md +1 -76
  520. package/skills/appflow-wireframe/SKILL.md +1 -78
  521. package/skills/apple-design/SKILL.md +1 -76
  522. package/skills/architecture/SKILL.md +1 -76
  523. package/skills/audit-and-fix/SKILL.md +41 -77
  524. package/skills/authentication-best-practices/SKILL.md +1 -76
  525. package/skills/backend-security-expert/SKILL.md +1 -76
  526. package/skills/baseline-ui/SKILL.md +1 -76
  527. package/skills/bash-linux/SKILL.md +1 -76
  528. package/skills/behavioral-modes/SKILL.md +1 -76
  529. package/skills/better-colors/SKILL.md +1 -76
  530. package/skills/better-typography/SKILL.md +1 -75
  531. package/skills/better-ui/SKILL.md +18 -81
  532. package/skills/bolder/SKILL.md +1 -76
  533. package/skills/brainstorming/SKILL.md +1 -75
  534. package/skills/browser-audit/SKILL.md +15 -83
  535. package/skills/browser-native-ai/SKILL.md +1 -76
  536. package/skills/build-primitive/SKILL.md +1 -76
  537. package/skills/building-native-ui/SKILL.md +1 -76
  538. package/skills/cicd-pro/SKILL.md +1 -76
  539. package/skills/clarify/SKILL.md +1 -76
  540. package/skills/clean-code/SKILL.md +1 -76
  541. package/skills/cloud-architect/SKILL.md +1 -76
  542. package/skills/cobejs/SKILL.md +1 -76
  543. package/skills/code-review-checklist/SKILL.md +1 -76
  544. package/skills/codebase-design/SKILL.md +1 -76
  545. package/skills/colorize/SKILL.md +1 -76
  546. package/skills/compact-landing/SKILL.md +1 -76
  547. package/skills/company-logos/SKILL.md +1 -76
  548. package/skills/config-validator/SKILL.md +1 -76
  549. package/skills/containerization-pro/SKILL.md +1 -76
  550. package/skills/context-engineering-pro/SKILL.md +1 -75
  551. package/skills/create-design-md/SKILL.md +1 -76
  552. package/skills/critique/SKILL.md +1 -76
  553. package/skills/csharp-developer/SKILL.md +1 -76
  554. package/skills/data-validation-schemas/SKILL.md +1 -76
  555. package/skills/database-design/SKILL.md +1 -76
  556. package/skills/delight/SKILL.md +1 -76
  557. package/skills/deployment-procedures/SKILL.md +1 -76
  558. package/skills/design-lab/SKILL.md +0 -75
  559. package/skills/devops-engineer/SKILL.md +1 -76
  560. package/skills/devops-incident-responder/SKILL.md +1 -76
  561. package/skills/diagnosing-bugs/SKILL.md +0 -75
  562. package/skills/distill/SKILL.md +1 -76
  563. package/skills/documentation-templates/SKILL.md +1 -76
  564. package/skills/domain-modeling/SKILL.md +1 -76
  565. package/skills/duckdb-analytical-sql/SKILL.md +1 -75
  566. package/skills/edge-ai-mobile/SKILL.md +1 -75
  567. package/skills/edge-computing/SKILL.md +1 -76
  568. package/skills/emil-design-eng/SKILL.md +1 -76
  569. package/skills/error-resilience/SKILL.md +1 -76
  570. package/skills/expo-router-v4/SKILL.md +1 -75
  571. package/skills/extract-design-system/SKILL.md +1 -76
  572. package/skills/fabel-protocol/SKILL.md +1 -76
  573. package/skills/fixing-accessibility/SKILL.md +1 -76
  574. package/skills/fixing-metadata/SKILL.md +1 -76
  575. package/skills/fixing-motion-performance/SKILL.md +1 -76
  576. package/skills/framer-motion-expert/SKILL.md +1 -76
  577. package/skills/frontend-design/SKILL.md +1 -76
  578. package/skills/frontend-security-expert/SKILL.md +1 -76
  579. package/skills/game-design-expert/SKILL.md +1 -76
  580. package/skills/game-engineering-expert/SKILL.md +1 -76
  581. package/skills/generative-ui-expert/SKILL.md +1 -76
  582. package/skills/geo-fundamentals/SKILL.md +1 -76
  583. package/skills/git-pro/SKILL.md +1 -76
  584. package/skills/github-operations/SKILL.md +1 -76
  585. package/skills/gpt-taste/SKILL.md +1 -76
  586. package/skills/gsap-core/SKILL.md +1 -76
  587. package/skills/gsap-frameworks/SKILL.md +1 -76
  588. package/skills/gsap-performance/SKILL.md +1 -76
  589. package/skills/gsap-plugins/SKILL.md +1 -76
  590. package/skills/gsap-react/SKILL.md +1 -76
  591. package/skills/gsap-scrolltrigger/SKILL.md +1 -76
  592. package/skills/gsap-timeline/SKILL.md +1 -76
  593. package/skills/gsap-utils/SKILL.md +1 -76
  594. package/skills/harden/SKILL.md +1 -76
  595. package/skills/harness-protocol/SKILL.md +1 -76
  596. package/skills/i18n-localization/SKILL.md +1 -76
  597. package/skills/impeccable/SKILL.md +1 -76
  598. package/skills/improve-codebase-architecture/SKILL.md +1 -76
  599. package/skills/improve-ui/SKILL.md +1 -76
  600. package/skills/intelligent-routing/SKILL.md +2 -87
  601. package/skills/knowledge-graph/SKILL.md +1 -76
  602. package/skills/landing-page/SKILL.md +1 -76
  603. package/skills/lint-and-validate/SKILL.md +1 -76
  604. package/skills/llm-engineering/SKILL.md +1 -76
  605. package/skills/local-first/SKILL.md +1 -76
  606. package/skills/local-first-architecture/SKILL.md +1 -76
  607. package/skills/lottie-animation/SKILL.md +1 -76
  608. package/skills/marquee-loop/SKILL.md +1 -76
  609. package/skills/masked-reveal/SKILL.md +1 -76
  610. package/skills/mcp-builder/SKILL.md +1 -76
  611. package/skills/micro-interaction/SKILL.md +19 -87
  612. package/skills/mobile-design/SKILL.md +1 -76
  613. package/skills/monorepo-management/SKILL.md +1 -76
  614. package/skills/morphing-icons/SKILL.md +1 -76
  615. package/skills/motion-engineering/SKILL.md +1 -76
  616. package/skills/nextjs-react-expert/SKILL.md +1 -76
  617. package/skills/nodejs-best-practices/SKILL.md +1 -76
  618. package/skills/observability/SKILL.md +1 -76
  619. package/skills/opentelemetry-observability/SKILL.md +1 -75
  620. package/skills/page-transition-animation/SKILL.md +1 -76
  621. package/skills/parallel-agents/SKILL.md +1 -76
  622. package/skills/performance-profiling/SKILL.md +1 -76
  623. package/skills/plan-writing/SKILL.md +1 -76
  624. package/skills/platform-engineer/SKILL.md +1 -76
  625. package/skills/platform-engineering-opentofu/SKILL.md +1 -75
  626. package/skills/playwright-ai-e2e/SKILL.md +1 -75
  627. package/skills/playwright-best-practices/SKILL.md +1 -76
  628. package/skills/polish/SKILL.md +1 -76
  629. package/skills/powershell-windows/SKILL.md +1 -76
  630. package/skills/pricing-page/SKILL.md +1 -76
  631. package/skills/product-aware-heuristics/SKILL.md +1 -76
  632. package/skills/progressive-blur/SKILL.md +1 -76
  633. package/skills/project-idioms/SKILL.md +1 -76
  634. package/skills/property-based-testing/SKILL.md +1 -75
  635. package/skills/python-patterns/SKILL.md +1 -76
  636. package/skills/python-pro/SKILL.md +1 -76
  637. package/skills/quieter/SKILL.md +1 -76
  638. package/skills/react-doctor/SKILL.md +1 -76
  639. package/skills/react-specialist/SKILL.md +1 -76
  640. package/skills/readme-builder/SKILL.md +1 -76
  641. package/skills/realtime-patterns/SKILL.md +1 -76
  642. package/skills/red-team-tactics/SKILL.md +1 -76
  643. package/skills/redesign-skill/SKILL.md +1 -76
  644. package/skills/review-animations/SKILL.md +1 -76
  645. package/skills/rust-pro/SKILL.md +1 -76
  646. package/skills/seo-fundamentals/SKILL.md +1 -76
  647. package/skills/server-management/SKILL.md +1 -76
  648. package/skills/shadcn-ui-expert/SKILL.md +1 -76
  649. package/skills/shape/SKILL.md +1 -76
  650. package/skills/skill-creator/SKILL.md +127 -86
  651. package/skills/soft-skill/SKILL.md +1 -76
  652. package/skills/sounds-on-the-web/SKILL.md +1 -76
  653. package/skills/sql-pro/SKILL.md +1 -76
  654. package/skills/supabase-postgres-best-practices/SKILL.md +1 -76
  655. package/skills/svg-animation/SKILL.md +1 -76
  656. package/skills/swiftui-expert/SKILL.md +1 -76
  657. package/skills/swiss-design/SKILL.md +1 -76
  658. package/skills/system-design-pro/SKILL.md +1 -76
  659. package/skills/systematic-debugging/SKILL.md +2 -76
  660. package/skills/systematic-debugging/condition-based-waiting.md +14 -9
  661. package/skills/systematic-debugging/defense-in-depth.md +9 -3
  662. package/skills/systematic-debugging/root-cause-tracing.md +14 -0
  663. package/skills/tailwind-patterns/SKILL.md +1 -76
  664. package/skills/taste-skill/SKILL.md +1 -76
  665. package/skills/tdd-workflow/SKILL.md +8 -82
  666. package/skills/test-result-analyzer/SKILL.md +1 -76
  667. package/skills/testing-patterns/SKILL.md +1 -76
  668. package/skills/thermo-nuclear-code-quality-review/SKILL.md +1 -76
  669. package/skills/thinking-protocol/SKILL.md +1 -77
  670. package/skills/to-spring-or-not-to-spring/SKILL.md +1 -76
  671. package/skills/transitions-dev/SKILL.md +1 -76
  672. package/skills/trend-researcher/SKILL.md +1 -76
  673. package/skills/typescript-advanced/SKILL.md +1 -76
  674. package/skills/typeset/SKILL.md +1 -76
  675. package/skills/ui-reasoning-engine/SKILL.md +1 -76
  676. package/skills/ui-skill-packs/SKILL.md +1 -76
  677. package/skills/ui-skills-root/SKILL.md +1 -76
  678. package/skills/ui-ux-pro-max/SKILL.md +1 -76
  679. package/skills/ui-ux-researcher/SKILL.md +1 -76
  680. package/skills/vector-search-pgvector/SKILL.md +1 -75
  681. package/skills/verification-before-completion/SKILL.md +20 -91
  682. package/skills/vue-expert/SKILL.md +1 -76
  683. package/skills/vulnerability-scanner/SKILL.md +1 -76
  684. package/skills/web-accessibility-auditor/SKILL.md +1 -76
  685. package/skills/web-design-guidelines/SKILL.md +1 -76
  686. package/skills/web-quality-audit/SKILL.md +1 -76
  687. package/skills/webapp-testing/SKILL.md +1 -76
  688. package/skills/webgpu-performance/SKILL.md +1 -76
  689. package/skills/whimsy-injector/SKILL.md +1 -76
  690. package/skills/workflow-optimizer/SKILL.md +1 -76
  691. package/skills/zero-trust-passkeys/SKILL.md +1 -75
@@ -2,27 +2,26 @@
2
2
  /**
3
3
  * memory_engine.js — Tribunal Kit 4-Type Taxonomy Persistent Memory Engine
4
4
  * ==============================================================================
5
- * SQLite-backed memory storage with budget-constrained recall.
5
+ * Persistent, file-backed memory storage with atomic locking, budget-constrained
6
+ * recall, and human-readable MEMORY.md projection.
6
7
  *
7
- * Memory Types:
8
- * - semantic: Permanent facts (no expiration)
9
- * - procedural: How-to recipes (no expiration)
10
- * - episodic: Events with 30-day TTL
11
- * - working: Session scratch (cleared on restart)
8
+ * Fully unified and cross-compatible with:
9
+ * - Rust Core: crates/core/src/commands/memory.rs
10
+ * - TypeScript CLI: dist/commands/memory.js
11
+ * - Tribunal MCP Server
12
12
  *
13
- * Recall Algorithm:
14
- * score = relevance × recency × priority
15
- * where relevance = token overlap with query
16
- * recency = -0.1 × days since last access
17
- * priority = explicit priority (default: 1.0)
13
+ * Memory Types:
14
+ * - semantic: Permanent project facts and rules (no expiration)
15
+ * - procedural: How-to recipes and steps (no expiration)
16
+ * - episodic: Session events and decisions (auto-decays after 30 days)
17
+ * - working: Current session scratchpad (cleared on gc/session reset)
18
18
  *
19
- * Usage:
20
- * const { MemoryEngine } = require('./memory_engine');
21
- * const mem = new MemoryEngine(agentDir);
22
- * mem.store('semantic', 'User prefers TypeScript', ['typescript', 'preference']);
23
- * const { results } = mem.recall('typescript', 2000);
19
+ * Storage Architecture:
20
+ * - Index: .agent/history/memory/.memory.idx (atomic JSON index)
21
+ * - Projection: .agent/history/memory/MEMORY.md (human-readable markdown)
22
+ * - Lock: .agent/history/memory/.memory.idx.lock
24
23
  *
25
- * Zero external dependencies beyond better-sqlite3 (already installed).
24
+ * Zero external dependencies beyond native Node.js core modules.
26
25
  */
27
26
 
28
27
  'use strict';
@@ -30,120 +29,117 @@
30
29
  const fs = require('fs');
31
30
  const path = require('path');
32
31
 
33
- // Lazy-load better-sqlite3 (optional dependency for environments without native compilation)
34
- let Database = null;
35
- try {
36
- Database = require('better-sqlite3');
37
- } catch (_err) {
38
- // Fallback to in-memory storage if better-sqlite3 not available
39
- console.warn('[Memory] better-sqlite3 not available, using in-memory fallback');
40
- }
32
+ // ─── Constants & Configuration ────────────────────────────────────────────────
41
33
 
42
- // ─── Memory Types ─────────────────────────────────────────────────────────────
34
+ const MEMORY_DIR = path.join('history', 'memory');
35
+ const INDEX_FILE = '.memory.idx';
36
+ const PROJECTION_FILE = 'MEMORY.md';
37
+ const MAX_ENTRIES = 500;
38
+ const EPISODIC_TTL_DAYS = 30;
39
+ const DEFAULT_BUDGET = 2000;
43
40
 
44
41
  const MEMORY_TYPES = {
45
- SEMANTIC: 'semantic', // Permanent facts
46
- PROCEDURAL: 'procedural', // How-to recipes
47
- EPISODIC: 'episodic', // Events (30-day TTL)
48
- WORKING: 'working', // Session scratch
42
+ SEMANTIC: 'semantic',
43
+ PROCEDURAL: 'procedural',
44
+ EPISODIC: 'episodic',
45
+ WORKING: 'working',
49
46
  };
50
47
 
51
48
  const VALID_TYPES = Object.values(MEMORY_TYPES);
52
49
 
53
- // ─── In-Memory Fallback Storage ───────────────────────────────────────────────
50
+ const TYPE_PRIORITY = {
51
+ semantic: 1.0,
52
+ procedural: 0.9,
53
+ episodic: 0.7,
54
+ working: 0.5,
55
+ };
54
56
 
55
- class InMemoryStore {
56
- constructor() {
57
- this.memories = new Map();
58
- this.nextId = 1;
59
- }
57
+ // ─── Utility Helpers ──────────────────────────────────────────────────────────
60
58
 
61
- prepare(sql) {
62
- const self = this;
59
+ function estimateTokens(text) {
60
+ if (!text) return 0;
61
+ return Math.ceil(text.length / 4);
62
+ }
63
63
 
64
- // Simple SQL-like operations on in-memory Map
65
- return {
66
- run(...params) {
67
- // INSERT
68
- if (sql.includes('INSERT INTO memories')) {
69
- const [type, content, tags, priority, expiresAt] = params;
70
- const id = self.nextId++;
71
- self.memories.set(id, {
72
- id,
73
- type,
74
- content,
75
- tags: JSON.parse(tags),
76
- priority,
77
- created_at: new Date().toISOString(),
78
- accessed_at: new Date().toISOString(),
79
- expires_at: expiresAt,
80
- access_count: 0,
81
- });
82
- return { lastInsertRowid: id, changes: 1 };
83
- }
84
- // UPDATE
85
- if (sql.includes('UPDATE memories')) {
86
- for (const [_id, mem] of self.memories) {
87
- mem.accessed_at = new Date().toISOString();
88
- mem.access_count++;
89
- }
90
- return { changes: self.memories.size };
91
- }
92
- // DELETE
93
- if (sql.includes('DELETE FROM memories')) {
94
- const before = self.memories.size;
95
- for (const [id, mem] of self.memories) {
96
- if (
97
- mem.type === 'episodic' &&
98
- mem.expires_at &&
99
- new Date(mem.expires_at) < new Date()
100
- ) {
101
- self.memories.delete(id);
102
- }
103
- }
104
- return { changes: before - self.memories.size };
105
- }
106
- return { changes: 0 };
107
- },
108
-
109
- all(...params) {
110
- const [query] = params;
111
- const results = [];
112
-
113
- for (const [_id, mem] of self.memories) {
114
- // Filter expired
115
- if (mem.expires_at && new Date(mem.expires_at) < new Date()) {
116
- continue;
117
- }
118
-
119
- // Calculate score
120
- const relevance = (
121
- mem.content.toLowerCase().match(new RegExp(query.toLowerCase(), 'g')) || []
122
- ).length;
123
- const daysSinceAccess =
124
- (Date.now() - new Date(mem.accessed_at).getTime()) / (1000 * 60 * 60 * 24);
125
- const score = relevance * 3.0 + daysSinceAccess * -0.1 + mem.priority;
126
-
127
- results.push({ ...mem, score });
128
- }
64
+ function nowEpochStr() {
65
+ return `${Math.floor(Date.now() / 1000)}Z`;
66
+ }
129
67
 
130
- return results.sort((a, b) => b.score - a.score);
131
- },
68
+ function daysSince(ts) {
69
+ if (!ts) return 0;
70
+ const created = parseInt(String(ts).replace('Z', ''), 10) || 0;
71
+ const now = Math.floor(Date.now() / 1000);
72
+ return Math.max(0, Math.floor((now - created) / 86400));
73
+ }
132
74
 
133
- get(...params) {
134
- const [id] = params;
135
- return self.memories.get(id) || undefined;
136
- },
137
- };
75
+ // ─── Lock Management ──────────────────────────────────────────────────────────
76
+
77
+ function acquireLock(indexPath) {
78
+ const lockPath = indexPath + '.lock';
79
+ const maxRetries = 10;
80
+ for (let i = 0; i < maxRetries; i++) {
81
+ try {
82
+ const fd = fs.openSync(lockPath, 'wx');
83
+ fs.closeSync(fd);
84
+ return lockPath;
85
+ } catch (err) {
86
+ if (err.code !== 'EEXIST') {
87
+ throw err;
88
+ }
89
+ const waitBuf = new Int32Array(new SharedArrayBuffer(4));
90
+ Atomics.wait(waitBuf, 0, 0, 50);
91
+ }
138
92
  }
139
93
 
140
- exec(_sql) {
141
- // No-op for in-memory
94
+ // Check for stale lock (older than 10s)
95
+ try {
96
+ const stats = fs.statSync(lockPath);
97
+ if (Date.now() - stats.mtimeMs > 10000) {
98
+ fs.unlinkSync(lockPath);
99
+ const fd = fs.openSync(lockPath, 'wx');
100
+ fs.closeSync(fd);
101
+ return lockPath;
102
+ }
103
+ } catch {}
104
+
105
+ throw new Error('Could not acquire lock for memory index');
106
+ }
107
+
108
+ function releaseLock(lockPath) {
109
+ try {
110
+ if (lockPath && fs.existsSync(lockPath)) {
111
+ fs.unlinkSync(lockPath);
112
+ }
113
+ } catch {}
114
+ }
115
+
116
+ // ─── Scoring Engine ───────────────────────────────────────────────────────────
117
+
118
+ function computeScore(entry, query) {
119
+ if (!query || !entry.content) return 0;
120
+ const queryLower = query.toLowerCase();
121
+ const contentLower = entry.content.toLowerCase();
122
+
123
+ let relevance = 0;
124
+ if (contentLower.includes(queryLower)) {
125
+ relevance = 1.0;
126
+ } else if (entry.tags && entry.tags.some(t => t.toLowerCase().includes(queryLower))) {
127
+ relevance = 0.8;
128
+ } else if (queryLower.split(/\s+/).some(word => word.length > 2 && contentLower.includes(word))) {
129
+ relevance = 0.3;
142
130
  }
143
131
 
144
- close() {
145
- this.memories.clear();
132
+ if (relevance === 0) return 0;
133
+
134
+ const priority = entry.priority != null ? entry.priority : (TYPE_PRIORITY[entry.memory_type] || 0.5);
135
+ let recency = 0;
136
+ if (entry.memory_type === 'episodic') {
137
+ const age = daysSince(entry.created_at);
138
+ recency = Math.exp(-age / 30);
146
139
  }
140
+ const freqBoost = Math.max(0, Math.log(entry.access_count || 1)) * 0.05;
141
+
142
+ return (relevance * priority) + recency + freqBoost;
147
143
  }
148
144
 
149
145
  // ─── Memory Engine Class ──────────────────────────────────────────────────────
@@ -151,300 +147,436 @@ class InMemoryStore {
151
147
  class MemoryEngine {
152
148
  /**
153
149
  * Initialize the Memory Engine.
154
- * @param {string} agentDir - Path to .agent/ directory
155
- * @param {object} options - Configuration options
150
+ * @param {string} agentDir - Path to .agent/ directory or workspace root
151
+ * @param {object} [options] - Configuration options
156
152
  */
157
153
  constructor(agentDir, options = {}) {
158
- this.agentDir = agentDir;
159
- this.dbPath = path.join(agentDir, 'history', 'memory.db');
154
+ let resolved = path.resolve(agentDir || process.cwd());
155
+ // Auto-detect .agent directory if parent workspace given
156
+ if (!resolved.endsWith('.agent') && !resolved.endsWith('.agent' + path.sep)) {
157
+ const nested = path.join(resolved, '.agent');
158
+ if (fs.existsSync(nested) && fs.statSync(nested).isDirectory()) {
159
+ resolved = nested;
160
+ }
161
+ }
162
+
163
+ this.agentDir = resolved;
164
+ this.memoryDir = path.join(this.agentDir, MEMORY_DIR);
165
+ this.indexPath = path.join(this.memoryDir, INDEX_FILE);
166
+ this.projectionPath = path.join(this.memoryDir, PROJECTION_FILE);
160
167
  this.options = {
161
- defaultTTL: 30 * 24 * 60 * 60 * 1000, // 30 days for episodic
162
- maxWorkingMemorySize: 100, // Max working memory entries
168
+ defaultTTL: EPISODIC_TTL_DAYS * 24 * 60 * 60 * 1000,
169
+ maxEntries: MAX_ENTRIES,
163
170
  ...options,
164
171
  };
165
172
 
166
- // Ensure history directory exists
167
- const historyDir = path.dirname(this.dbPath);
168
- if (!fs.existsSync(historyDir)) {
169
- fs.mkdirSync(historyDir, { recursive: true });
173
+ if (!fs.existsSync(this.memoryDir)) {
174
+ fs.mkdirSync(this.memoryDir, { recursive: true });
170
175
  }
171
-
172
- // Initialize database
173
- this.db = this.initDatabase();
174
- this.initSchema();
175
176
  }
176
177
 
177
178
  /**
178
- * Initialize database connection (SQLite or in-memory fallback).
179
+ * Load index from disk safely.
180
+ * @returns {{ version: number, entries: Array<object>, next_id: number }}
179
181
  */
180
- initDatabase() {
181
- if (Database) {
182
- return new Database(this.dbPath);
182
+ loadIndex() {
183
+ if (!fs.existsSync(this.indexPath)) {
184
+ return { version: 1, entries: [], next_id: 1 };
185
+ }
186
+ try {
187
+ const content = fs.readFileSync(this.indexPath, 'utf8');
188
+ return JSON.parse(content);
189
+ } catch {
190
+ return { version: 1, entries: [], next_id: 1 };
183
191
  }
184
- return new InMemoryStore();
185
192
  }
186
193
 
187
194
  /**
188
- * Create database schema if not exists.
195
+ * Atomically persist index to disk.
196
+ * @param {object} index
189
197
  */
190
- initSchema() {
191
- this.db.exec(`
192
- CREATE TABLE IF NOT EXISTS memories (
193
- id INTEGER PRIMARY KEY AUTOINCREMENT,
194
- type TEXT NOT NULL CHECK(type IN ('semantic', 'procedural', 'episodic', 'working')),
195
- content TEXT NOT NULL,
196
- tags TEXT,
197
- priority REAL DEFAULT 1.0,
198
- created_at TEXT DEFAULT CURRENT_TIMESTAMP,
199
- accessed_at TEXT DEFAULT CURRENT_TIMESTAMP,
200
- expires_at TEXT,
201
- access_count INTEGER DEFAULT 0
202
- );
203
-
204
- CREATE INDEX IF NOT EXISTS idx_memories_type ON memories(type);
205
- CREATE INDEX IF NOT EXISTS idx_memories_accessed ON memories(accessed_at);
206
- `);
198
+ saveIndex(index) {
199
+ fs.mkdirSync(this.memoryDir, { recursive: true });
200
+ const tmpPath = this.indexPath + '.tmp';
201
+ fs.writeFileSync(tmpPath, JSON.stringify(index, null, 2), 'utf8');
202
+ fs.renameSync(tmpPath, this.indexPath);
207
203
  }
208
204
 
209
205
  /**
210
206
  * Store a new memory entry.
211
- * @param {string} type - Memory type (semantic, procedural, episodic, working)
207
+ * @param {string} type - 'semantic' | 'procedural' | 'episodic' | 'working'
212
208
  * @param {string} content - Memory content
213
- * @param {string[]} tags - Searchable tags
214
- * @param {object} options - Additional options (priority, expiresIn)
209
+ * @param {string[]} [tags] - Searchable tags
210
+ * @param {object} [options] - Additional options (priority, source, sessionId)
215
211
  * @returns {{ id: number, type: string, token_estimate: number }}
216
212
  */
217
213
  store(type, content, tags = [], options = {}) {
218
- // Validate type
219
214
  if (!VALID_TYPES.includes(type)) {
220
215
  throw new Error(`Invalid memory type: "${type}". Must be one of: ${VALID_TYPES.join(', ')}`);
221
216
  }
222
217
 
223
- // Validate content
224
- if (!content || typeof content !== 'string') {
225
- throw new Error('Memory content must be a non-empty string');
218
+ if (!content || typeof content !== 'string' || content.trim().length === 0) {
219
+ throw new Error('Memory content cannot be empty');
226
220
  }
227
221
 
228
- // Calculate expiration
229
- let expiresAt = null;
230
- if (type === MEMORY_TYPES.EPISODIC) {
231
- const expiresIn = options.expiresIn || this.options.defaultTTL;
232
- expiresAt = new Date(Date.now() + expiresIn).toISOString();
233
- }
222
+ const lockPath = acquireLock(this.indexPath);
223
+ try {
224
+ const index = this.loadIndex();
225
+
226
+ // Enforce capacity (500)
227
+ if (index.entries.length >= this.options.maxEntries) {
228
+ index.entries = index.entries.filter(e => e.memory_type !== 'working');
229
+ if (index.entries.length >= this.options.maxEntries) {
230
+ index.entries = index.entries.filter(e => {
231
+ if (e.memory_type === 'episodic') {
232
+ return daysSince(e.created_at) < EPISODIC_TTL_DAYS;
233
+ }
234
+ return true;
235
+ });
236
+ }
237
+ if (index.entries.length >= this.options.maxEntries) {
238
+ throw new Error(`Memory at capacity (${this.options.maxEntries}). Run: tk memory gc`);
239
+ }
240
+ }
234
241
 
235
- // Insert into database
236
- const stmt = this.db.prepare(`
237
- INSERT INTO memories (type, content, tags, priority, expires_at)
238
- VALUES (?, ?, ?, ?, ?)
239
- `);
242
+ const now = nowEpochStr();
243
+ const nextId = index.next_id || (index.entries.length > 0 ? Math.max(...index.entries.map(e => e.id)) + 1 : 1);
244
+ const cleanTags = Array.isArray(tags)
245
+ ? tags.filter(t => typeof t === 'string' && t.trim().length > 0).map(t => t.trim())
246
+ : [];
247
+
248
+ const entry = {
249
+ id: nextId,
250
+ memory_type: type,
251
+ content: content.trim(),
252
+ tags: cleanTags,
253
+ created_at: now,
254
+ last_accessed: now,
255
+ access_count: 0,
256
+ token_estimate: estimateTokens(content),
257
+ source: options.source || (type === 'working' ? 'session' : 'manual'),
258
+ session_id: options.sessionId || options.session_id || null,
259
+ priority: typeof options.priority === 'number' ? options.priority : 1.0,
260
+ };
240
261
 
241
- const result = stmt.run(
242
- type,
243
- content,
244
- JSON.stringify(tags),
245
- options.priority || 1.0,
246
- expiresAt,
247
- );
262
+ index.entries.push(entry);
263
+ index.next_id = nextId + 1;
248
264
 
249
- return {
250
- id: result.lastInsertRowid,
251
- type,
252
- token_estimate: this.estimateTokens(content),
253
- };
265
+ this.saveIndex(index);
266
+ this.generateProjection(index);
267
+
268
+ return {
269
+ id: entry.id,
270
+ type: entry.memory_type,
271
+ token_estimate: entry.token_estimate,
272
+ };
273
+ } finally {
274
+ releaseLock(lockPath);
275
+ }
254
276
  }
255
277
 
256
278
  /**
257
- * Recall memories matching a query, within token budget.
279
+ * Recall memories matching a query within a token budget.
258
280
  * @param {string} query - Search query
259
- * @param {number} budget - Maximum token budget
260
- * @returns {{ results: array, tokens_used: number }}
281
+ * @param {number} [budget] - Token budget (default 2000)
282
+ * @returns {{ results: Array<object>, tokens_used: number, budget: number }}
261
283
  */
262
- recall(query, budget = 2000) {
263
- const _tokens = this.tokenize(query);
264
-
265
- // Score by relevance × recency × priority
266
- const memories = this.db
267
- .prepare(
268
- `
269
- SELECT *, (
270
- (length(content) - length(replace(lower(content), lower(?), ''))) / length(?) * 3.0
271
- + (julianday('now') - julianday(accessed_at)) * -0.1
272
- + priority
273
- ) as score
274
- FROM memories
275
- WHERE expires_at IS NULL OR expires_at > datetime('now')
276
- ORDER BY score DESC
277
- `,
278
- )
279
- .all(query, query);
280
-
281
- // Fit within budget
282
- const selected = [];
283
- let usedTokens = 0;
284
-
285
- for (const mem of memories) {
286
- const tokens = this.estimateTokens(mem.content);
287
- if (usedTokens + tokens <= budget) {
288
- selected.push({
289
- id: mem.id,
290
- memory_type: mem.type,
291
- content: mem.content,
292
- tags: mem.tags ? JSON.parse(mem.tags) : [],
293
- priority: mem.priority,
294
- score: mem.score,
284
+ recall(query, budget = DEFAULT_BUDGET) {
285
+ const lockPath = acquireLock(this.indexPath);
286
+ try {
287
+ const index = this.loadIndex();
288
+
289
+ const scored = index.entries
290
+ .map(entry => ({ entry, score: computeScore(entry, query) }))
291
+ .filter(s => s.score > 0)
292
+ .sort((a, b) => b.score - a.score);
293
+
294
+ let totalTokens = 0;
295
+ const results = [];
296
+ let indexModified = false;
297
+
298
+ for (const { entry, score } of scored) {
299
+ if (totalTokens + entry.token_estimate > budget) break;
300
+ totalTokens += entry.token_estimate;
301
+
302
+ entry.last_accessed = nowEpochStr();
303
+ entry.access_count = (entry.access_count || 0) + 1;
304
+ indexModified = true;
305
+
306
+ results.push({
307
+ id: entry.id,
308
+ memory_type: entry.memory_type,
309
+ content: entry.content,
310
+ tags: entry.tags || [],
311
+ priority: entry.priority != null ? entry.priority : 1.0,
312
+ score,
313
+ token_estimate: entry.token_estimate,
314
+ created_at: entry.created_at,
315
+ last_accessed: entry.last_accessed,
316
+ access_count: entry.access_count,
295
317
  });
296
- usedTokens += tokens;
297
-
298
- // Update access stats
299
- this.db
300
- .prepare(
301
- `
302
- UPDATE memories
303
- SET accessed_at = CURRENT_TIMESTAMP, access_count = access_count + 1
304
- WHERE id = ?
305
- `,
306
- )
307
- .run(mem.id);
308
318
  }
309
- }
310
319
 
311
- return { results: selected, tokens_used: usedTokens };
320
+ if (indexModified) {
321
+ this.saveIndex(index);
322
+ }
323
+
324
+ return { results, tokens_used: totalTokens, budget };
325
+ } finally {
326
+ releaseLock(lockPath);
327
+ }
312
328
  }
313
329
 
314
330
  /**
315
- * Get a specific memory by ID.
316
- * @param {number} id - Memory ID
331
+ * Retrieve a specific memory entry by ID.
332
+ * @param {number} id
317
333
  * @returns {object|null}
318
334
  */
319
335
  get(id) {
320
- const mem = this.db
321
- .prepare(
322
- `
323
- SELECT * FROM memories WHERE id = ?
324
- `,
325
- )
326
- .get(id);
327
-
328
- if (!mem) return null;
336
+ const targetId = Number(id);
337
+ const index = this.loadIndex();
338
+ const entry = index.entries.find(e => e.id === targetId);
339
+ if (!entry) return null;
329
340
 
330
341
  return {
331
- id: mem.id,
332
- memory_type: mem.type,
333
- content: mem.content,
334
- tags: mem.tags ? JSON.parse(mem.tags) : [],
335
- priority: mem.priority,
336
- created_at: mem.created_at,
337
- accessed_at: mem.accessed_at,
338
- access_count: mem.access_count,
339
- expires_at: mem.expires_at,
342
+ id: entry.id,
343
+ memory_type: entry.memory_type,
344
+ content: entry.content,
345
+ tags: entry.tags || [],
346
+ priority: entry.priority != null ? entry.priority : 1.0,
347
+ created_at: entry.created_at,
348
+ last_accessed: entry.last_accessed,
349
+ access_count: entry.access_count || 0,
350
+ token_estimate: entry.token_estimate,
351
+ source: entry.source,
352
+ session_id: entry.session_id,
340
353
  };
341
354
  }
342
355
 
343
356
  /**
344
- * Delete a memory by ID.
345
- * @param {number} id - Memory ID
346
- * @returns {boolean} True if deleted
357
+ * Delete a memory entry by ID.
358
+ * @param {number} id
359
+ * @returns {boolean} True if deleted, false if not found
347
360
  */
348
361
  delete(id) {
349
- const result = this.db
350
- .prepare(
351
- `
352
- DELETE FROM memories WHERE id = ?
353
- `,
354
- )
355
- .run(id);
356
-
357
- return result.changes > 0;
362
+ const targetId = Number(id);
363
+ const lockPath = acquireLock(this.indexPath);
364
+ try {
365
+ const index = this.loadIndex();
366
+ const before = index.entries.length;
367
+ index.entries = index.entries.filter(e => e.id !== targetId);
368
+
369
+ if (index.entries.length === before) {
370
+ return false;
371
+ }
372
+
373
+ this.saveIndex(index);
374
+ this.generateProjection(index);
375
+ return true;
376
+ } finally {
377
+ releaseLock(lockPath);
378
+ }
358
379
  }
359
380
 
360
381
  /**
361
- * Clear all working memories (session scratch).
382
+ * Clear all working memories (session scratchpad).
383
+ * @returns {number} Number of cleared entries
362
384
  */
363
385
  clearWorking() {
364
- this.db
365
- .prepare(
366
- `
367
- DELETE FROM memories WHERE type = 'working'
368
- `,
369
- )
370
- .run();
386
+ const lockPath = acquireLock(this.indexPath);
387
+ try {
388
+ const index = this.loadIndex();
389
+ const before = index.entries.length;
390
+ index.entries = index.entries.filter(e => e.memory_type !== 'working');
391
+ const removed = before - index.entries.length;
392
+
393
+ if (removed > 0) {
394
+ this.saveIndex(index);
395
+ this.generateProjection(index);
396
+ }
397
+
398
+ return removed;
399
+ } finally {
400
+ releaseLock(lockPath);
401
+ }
371
402
  }
372
403
 
373
404
  /**
374
- * Auto-expire episodic memories.
405
+ * Expire old memories and perform garbage collection.
406
+ * Clears all working memories and episodic memories older than 30 days.
407
+ * @returns {{ working_removed: number, episodic_removed: number, before: number, after: number }}
375
408
  */
376
409
  expire() {
377
- this.db
378
- .prepare(
379
- `
380
- DELETE FROM memories
381
- WHERE type = 'episodic' AND expires_at < datetime('now')
382
- `,
383
- )
384
- .run();
410
+ const lockPath = acquireLock(this.indexPath);
411
+ try {
412
+ const index = this.loadIndex();
413
+ const before = index.entries.length;
414
+
415
+ let workingRemoved = 0;
416
+ let episodicRemoved = 0;
417
+
418
+ index.entries = index.entries.filter(e => {
419
+ if (e.memory_type === 'working') {
420
+ workingRemoved++;
421
+ return false;
422
+ }
423
+ if (e.memory_type === 'episodic' && daysSince(e.created_at) >= EPISODIC_TTL_DAYS) {
424
+ episodicRemoved++;
425
+ return false;
426
+ }
427
+ return true;
428
+ });
429
+
430
+ this.saveIndex(index);
431
+ this.generateProjection(index);
432
+
433
+ return {
434
+ working_removed: workingRemoved,
435
+ episodic_removed: episodicRemoved,
436
+ before,
437
+ after: index.entries.length,
438
+ };
439
+ } finally {
440
+ releaseLock(lockPath);
441
+ }
385
442
  }
386
443
 
387
444
  /**
388
- * Get memory statistics.
445
+ * Alias for expire() to match CLI terminology.
389
446
  */
390
- stats() {
391
- const stats = this.db
392
- .prepare(
393
- `
394
- SELECT
395
- type,
396
- COUNT(*) as count,
397
- SUM(length(content)) as total_chars
398
- FROM memories
399
- WHERE expires_at IS NULL OR expires_at > datetime('now')
400
- GROUP BY type
401
- `,
402
- )
403
- .all();
404
-
405
- const result = {
406
- total: 0,
407
- by_type: {},
408
- };
447
+ gc() {
448
+ return this.expire();
449
+ }
409
450
 
410
- for (const stat of stats) {
411
- result.total += stat.count;
412
- result.by_type[stat.type] = {
413
- count: stat.count,
414
- total_chars: stat.total_chars,
415
- estimated_tokens: Math.ceil(stat.total_chars / 4),
451
+ /**
452
+ * Compute memory statistics.
453
+ * @returns {object}
454
+ */
455
+ stats() {
456
+ const index = this.loadIndex();
457
+ const total = index.entries.length;
458
+ const semantic = index.entries.filter(e => e.memory_type === 'semantic').length;
459
+ const procedural = index.entries.filter(e => e.memory_type === 'procedural').length;
460
+ const episodic = index.entries.filter(e => e.memory_type === 'episodic').length;
461
+ const working = index.entries.filter(e => e.memory_type === 'working').length;
462
+ const totalTokens = index.entries.reduce((sum, e) => sum + (e.token_estimate || 0), 0);
463
+
464
+ const byType = {};
465
+ for (const type of VALID_TYPES) {
466
+ const typeEntries = index.entries.filter(e => e.memory_type === type);
467
+ const typeChars = typeEntries.reduce((sum, e) => sum + (e.content ? e.content.length : 0), 0);
468
+ const typeTokens = typeEntries.reduce((sum, e) => sum + (e.token_estimate || 0), 0);
469
+ byType[type] = {
470
+ count: typeEntries.length,
471
+ total_chars: typeChars,
472
+ estimated_tokens: typeTokens,
416
473
  };
417
474
  }
418
475
 
419
- return result;
476
+ return {
477
+ total,
478
+ semantic,
479
+ procedural,
480
+ episodic,
481
+ working,
482
+ total_tokens: totalTokens,
483
+ capacity: this.options.maxEntries,
484
+ by_type: byType,
485
+ };
420
486
  }
421
487
 
422
488
  /**
423
- * Close database connection.
489
+ * Generate human-readable Markdown projection (MEMORY.md).
490
+ * @param {object} [index]
491
+ * @returns {string} Absolute path to projection file
424
492
  */
425
- close() {
426
- if (this.db && this.db.close) {
427
- this.db.close();
493
+ generateProjection(index) {
494
+ if (!index) index = this.loadIndex();
495
+
496
+ let md = '# 🧠 Tribunal Memory Index\n';
497
+ md += '> Auto-generated by `tribunal-kit memory export`. Do not edit manually.\n';
498
+
499
+ const sem = index.entries.filter(e => e.memory_type === 'semantic');
500
+ const proc = index.entries.filter(e => e.memory_type === 'procedural');
501
+ const ep = index.entries.filter(e => e.memory_type === 'episodic');
502
+ const work = index.entries.filter(e => e.memory_type === 'working');
503
+
504
+ md += `> Entries: ${index.entries.length} | Semantic: ${sem.length} | Procedural: ${proc.length} | Episodic: ${ep.length} | Working: ${work.length}\n\n`;
505
+
506
+ if (sem.length > 0) {
507
+ md += '## SEMANTIC (Permanent Facts)\n';
508
+ md += '| ID | Content | Tags | Source | Created |\n';
509
+ md += '|----|---------|------|--------|---------|\n';
510
+ for (const e of sem) {
511
+ md += `| ${e.id} | ${e.content.replace(/\|/g, '\\|')} | ${(e.tags || []).join(', ')} | ${e.source || 'manual'} | ${e.created_at} |\n`;
512
+ }
513
+ md += '\n';
514
+ }
515
+
516
+ if (proc.length > 0) {
517
+ md += '## PROCEDURAL (How-To Recipes)\n';
518
+ md += '| ID | Content | Tags | Source | Created |\n';
519
+ md += '|----|---------|------|--------|---------|\n';
520
+ for (const e of proc) {
521
+ md += `| ${e.id} | ${e.content.replace(/\|/g, '\\|')} | ${(e.tags || []).join(', ')} | ${e.source || 'manual'} | ${e.created_at} |\n`;
522
+ }
523
+ md += '\n';
428
524
  }
525
+
526
+ if (ep.length > 0) {
527
+ md += '## EPISODIC (Session History — auto-decays after 30 days)\n';
528
+ md += '| ID | Content | Tags | Source | Created | Days Remaining |\n';
529
+ md += '|----|---------|------|--------|---------|----------------|\n';
530
+ for (const e of ep) {
531
+ const remaining = Math.max(0, EPISODIC_TTL_DAYS - daysSince(e.created_at));
532
+ md += `| ${e.id} | ${e.content.replace(/\|/g, '\\|')} | ${(e.tags || []).join(', ')} | ${e.source || 'manual'} | ${e.created_at} | ${remaining} |\n`;
533
+ }
534
+ md += '\n';
535
+ }
536
+
537
+ if (work.length > 0) {
538
+ md += '## WORKING (Current Session — cleared on GC)\n';
539
+ md += '| ID | Content | Tags | Session |\n';
540
+ md += '|----|---------|------|---------|\n';
541
+ for (const e of work) {
542
+ md += `| ${e.id} | ${e.content.replace(/\|/g, '\\|')} | ${(e.tags || []).join(', ')} | ${e.session_id || '—'} |\n`;
543
+ }
544
+ md += '\n';
545
+ }
546
+
547
+ if (index.entries.length === 0) {
548
+ md += '*No memories recorded yet. Run `tk memory store` to add your first memory.*\n';
549
+ }
550
+
551
+ fs.mkdirSync(path.dirname(this.projectionPath), { recursive: true });
552
+ fs.writeFileSync(this.projectionPath, md, 'utf8');
553
+
554
+ return this.projectionPath;
429
555
  }
430
556
 
431
- // ─── Helpers ───────────────────────────────────────────────────────────────
557
+ /**
558
+ * Export the markdown projection text.
559
+ * @returns {string}
560
+ */
561
+ export() {
562
+ this.generateProjection();
563
+ return fs.readFileSync(this.projectionPath, 'utf8');
564
+ }
432
565
 
433
566
  /**
434
- * Estimate token count for text.
435
- * Uses rough approximation: 1 token ≈ 4 characters.
567
+ * Estimate token count.
568
+ * @param {string} text
569
+ * @returns {number}
436
570
  */
437
571
  estimateTokens(text) {
438
- if (!text) return 0;
439
- return Math.ceil(text.length / 4);
572
+ return estimateTokens(text);
440
573
  }
441
574
 
442
575
  /**
443
- * Tokenize text into lowercase words.
576
+ * Close connection (no-op for file-backed storage, preserved for API parity).
444
577
  */
445
- tokenize(text) {
446
- if (!text) return [];
447
- return (text.match(/\b[a-zA-Z_][a-zA-Z0-9_]{2,}\b/g) || []).map(t => t.toLowerCase());
578
+ close() {
579
+ // No-op for file-backed engine
448
580
  }
449
581
  }
450
582
 
@@ -454,6 +586,8 @@ module.exports = {
454
586
  MemoryEngine,
455
587
  MEMORY_TYPES,
456
588
  VALID_TYPES,
589
+ TYPE_PRIORITY,
590
+ estimateTokens,
457
591
  };
458
592
 
459
593
  // ─── CLI Entry Point ───────────────────────────────────────────────────────────
@@ -466,18 +600,20 @@ if (require.main === module) {
466
600
  \x1b[1mmemory_engine.js\x1b[0m — Tribunal Kit 4-Type Taxonomy Persistent Memory Engine
467
601
 
468
602
  \x1b[1mUsage:\x1b[0m
469
- node .agent/scripts/memory_engine.js store <type> <content> [--tags tag1,tag2]
603
+ node .agent/scripts/memory_engine.js store <type> <content> [--tags tag1,tag2] [--source manual]
470
604
  node .agent/scripts/memory_engine.js recall <query> [--budget 2000]
471
605
  node .agent/scripts/memory_engine.js get <id>
472
606
  node .agent/scripts/memory_engine.js delete <id>
473
607
  node .agent/scripts/memory_engine.js stats
474
608
  node .agent/scripts/memory_engine.js expire
609
+ node .agent/scripts/memory_engine.js gc
610
+ node .agent/scripts/memory_engine.js export
475
611
 
476
612
  \x1b[1mMemory Types:\x1b[0m
477
613
  semantic — Permanent facts (no expiration)
478
614
  procedural — How-to recipes (no expiration)
479
615
  episodic — Events with 30-day TTL
480
- working — Session scratch (cleared on restart)
616
+ working — Session scratch (cleared on GC)
481
617
 
482
618
  \x1b[1mExamples:\x1b[0m
483
619
  node .agent/scripts/memory_engine.js store semantic "User prefers TypeScript strict mode" --tags typescript,preference
@@ -487,11 +623,15 @@ if (require.main === module) {
487
623
  process.exit(0);
488
624
  }
489
625
 
490
- const { findAgentDir } = require('./_utils');
491
- const agentDir = findAgentDir() || path.resolve(__dirname, '..');
626
+ let agentDir = null;
627
+ try {
628
+ const { findAgentDir } = require('./_utils');
629
+ agentDir = findAgentDir();
630
+ } catch (_) {
631
+ agentDir = path.resolve(process.cwd(), '.agent');
632
+ }
492
633
 
493
634
  const mem = new MemoryEngine(agentDir);
494
-
495
635
  const command = args[0];
496
636
 
497
637
  try {
@@ -504,8 +644,10 @@ if (require.main === module) {
504
644
  tagsIdx !== -1 && args[tagsIdx + 1]
505
645
  ? args[tagsIdx + 1].split(',').map(t => t.trim())
506
646
  : [];
647
+ const sourceIdx = args.indexOf('--source');
648
+ const source = sourceIdx !== -1 && args[sourceIdx + 1] ? args[sourceIdx + 1] : undefined;
507
649
 
508
- const result = mem.store(type, content, tags);
650
+ const result = mem.store(type, content, tags, { source });
509
651
  console.log(
510
652
  `\x1b[32m✓\x1b[0m Memory stored: #${result.id} (${result.type}, ~${result.token_estimate} tokens)`,
511
653
  );
@@ -514,6 +656,10 @@ if (require.main === module) {
514
656
 
515
657
  case 'recall': {
516
658
  const query = args[1];
659
+ if (!query) {
660
+ console.error('\x1b[31m✖ Missing search query\x1b[0m');
661
+ process.exit(1);
662
+ }
517
663
  const budgetIdx = args.indexOf('--budget');
518
664
  const budget =
519
665
  budgetIdx !== -1 && args[budgetIdx + 1] ? parseInt(args[budgetIdx + 1], 10) : 2000;
@@ -524,7 +670,7 @@ if (require.main === module) {
524
670
  );
525
671
  for (const entry of results) {
526
672
  console.log(`- **[${entry.memory_type.toUpperCase()}]** #${entry.id}: ${entry.content}`);
527
- if (entry.tags.length > 0) console.log(` _(${entry.tags.join(', ')})_`);
673
+ if (entry.tags && entry.tags.length > 0) console.log(` _(${entry.tags.join(', ')})_`);
528
674
  }
529
675
  break;
530
676
  }
@@ -562,9 +708,24 @@ if (require.main === module) {
562
708
  break;
563
709
  }
564
710
 
711
+ case 'gc':
565
712
  case 'expire': {
566
- mem.expire();
567
- console.log(`\x1b[32m✓\x1b[0m Expired episodic memories cleaned up`);
713
+ const res = mem.expire();
714
+ console.log(
715
+ `\x1b[32m✓\x1b[0m Memory GC complete: ${res.working_removed} working, ${res.episodic_removed} episodic removed (${res.before} -> ${res.after})`,
716
+ );
717
+ break;
718
+ }
719
+
720
+ case 'clear-working': {
721
+ const cleared = mem.clearWorking();
722
+ console.log(`\x1b[32m✓\x1b[0m Cleared ${cleared} working memory entries`);
723
+ break;
724
+ }
725
+
726
+ case 'export': {
727
+ const proj = mem.export();
728
+ console.log(proj);
568
729
  break;
569
730
  }
570
731