@heytherevibin/skillforge 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (402) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/CODE_OF_CONDUCT.md +34 -0
  3. package/CONTRIBUTING.md +38 -0
  4. package/LICENSE +21 -0
  5. package/README.md +337 -0
  6. package/RELEASING.md +93 -0
  7. package/SECURITY.md +31 -0
  8. package/STRATEGY.md +26 -0
  9. package/bin/cli.js +547 -0
  10. package/lib/packs.js +184 -0
  11. package/package.json +38 -0
  12. package/python/app/__init__.py +0 -0
  13. package/python/app/__pycache__/__init__.cpython-312.pyc +0 -0
  14. package/python/app/__pycache__/auth.cpython-312.pyc +0 -0
  15. package/python/app/__pycache__/main.cpython-312.pyc +0 -0
  16. package/python/app/auth.py +63 -0
  17. package/python/app/cli.py +78 -0
  18. package/python/app/db_paths.py +26 -0
  19. package/python/app/events_cli.py +175 -0
  20. package/python/app/main.py +647 -0
  21. package/python/app/materialize.py +138 -0
  22. package/python/app/mcp_server.py +610 -0
  23. package/python/app/route_cli.py +117 -0
  24. package/python/requirements-dev.txt +1 -0
  25. package/python/requirements.txt +7 -0
  26. package/python/tests/test_db_paths.py +41 -0
  27. package/skills/accessibility/SKILL.md +145 -0
  28. package/skills/agent-architecture-audit/SKILL.md +256 -0
  29. package/skills/agent-eval/SKILL.md +144 -0
  30. package/skills/agent-harness-construction/SKILL.md +72 -0
  31. package/skills/agent-introspection-debugging/SKILL.md +152 -0
  32. package/skills/agent-payment-x402/SKILL.md +224 -0
  33. package/skills/agent-sort/SKILL.md +214 -0
  34. package/skills/agentic-engineering/SKILL.md +62 -0
  35. package/skills/agentic-os/SKILL.md +386 -0
  36. package/skills/ai-first-engineering/SKILL.md +50 -0
  37. package/skills/ai-regression-testing/SKILL.md +384 -0
  38. package/skills/android-clean-architecture/SKILL.md +338 -0
  39. package/skills/angular-developer/SKILL.md +153 -0
  40. package/skills/angular-developer/references/angular-animations.md +160 -0
  41. package/skills/angular-developer/references/angular-aria.md +410 -0
  42. package/skills/angular-developer/references/cli.md +86 -0
  43. package/skills/angular-developer/references/component-harnesses.md +59 -0
  44. package/skills/angular-developer/references/component-styling.md +91 -0
  45. package/skills/angular-developer/references/components.md +117 -0
  46. package/skills/angular-developer/references/creating-services.md +97 -0
  47. package/skills/angular-developer/references/data-resolvers.md +69 -0
  48. package/skills/angular-developer/references/define-routes.md +67 -0
  49. package/skills/angular-developer/references/defining-providers.md +72 -0
  50. package/skills/angular-developer/references/di-fundamentals.md +120 -0
  51. package/skills/angular-developer/references/e2e-testing.md +56 -0
  52. package/skills/angular-developer/references/effects.md +83 -0
  53. package/skills/angular-developer/references/hierarchical-injectors.md +43 -0
  54. package/skills/angular-developer/references/host-elements.md +80 -0
  55. package/skills/angular-developer/references/injection-context.md +63 -0
  56. package/skills/angular-developer/references/inputs.md +101 -0
  57. package/skills/angular-developer/references/linked-signal.md +59 -0
  58. package/skills/angular-developer/references/loading-strategies.md +61 -0
  59. package/skills/angular-developer/references/mcp.md +108 -0
  60. package/skills/angular-developer/references/navigate-to-routes.md +69 -0
  61. package/skills/angular-developer/references/outputs.md +86 -0
  62. package/skills/angular-developer/references/reactive-forms.md +122 -0
  63. package/skills/angular-developer/references/rendering-strategies.md +44 -0
  64. package/skills/angular-developer/references/resource.md +77 -0
  65. package/skills/angular-developer/references/route-animations.md +56 -0
  66. package/skills/angular-developer/references/route-guards.md +52 -0
  67. package/skills/angular-developer/references/router-lifecycle.md +45 -0
  68. package/skills/angular-developer/references/router-testing.md +87 -0
  69. package/skills/angular-developer/references/show-routes-with-outlets.md +68 -0
  70. package/skills/angular-developer/references/signal-forms.md +795 -0
  71. package/skills/angular-developer/references/signals-overview.md +94 -0
  72. package/skills/angular-developer/references/tailwind-css.md +69 -0
  73. package/skills/angular-developer/references/template-driven-forms.md +114 -0
  74. package/skills/angular-developer/references/testing-fundamentals.md +65 -0
  75. package/skills/api-connector-builder/SKILL.md +120 -0
  76. package/skills/api-design/SKILL.md +522 -0
  77. package/skills/architecture-decision-records/SKILL.md +178 -0
  78. package/skills/article-writing/SKILL.md +78 -0
  79. package/skills/automation-audit-ops/SKILL.md +141 -0
  80. package/skills/autonomous-agent-harness/SKILL.md +272 -0
  81. package/skills/autonomous-loops/SKILL.md +609 -0
  82. package/skills/backend-patterns/SKILL.md +560 -0
  83. package/skills/benchmark/SKILL.md +92 -0
  84. package/skills/blueprint/SKILL.md +104 -0
  85. package/skills/browser-qa/SKILL.md +86 -0
  86. package/skills/bun-runtime/SKILL.md +83 -0
  87. package/skills/canary-watch/SKILL.md +98 -0
  88. package/skills/carrier-relationship-management/SKILL.md +211 -0
  89. package/skills/cisco-ios-patterns/SKILL.md +163 -0
  90. package/skills/ck/SKILL.md +147 -0
  91. package/skills/ck/commands/forget.mjs +44 -0
  92. package/skills/ck/commands/info.mjs +24 -0
  93. package/skills/ck/commands/init.mjs +143 -0
  94. package/skills/ck/commands/list.mjs +40 -0
  95. package/skills/ck/commands/migrate.mjs +202 -0
  96. package/skills/ck/commands/resume.mjs +36 -0
  97. package/skills/ck/commands/save.mjs +210 -0
  98. package/skills/ck/commands/shared.mjs +387 -0
  99. package/skills/ck/hooks/session-start.mjs +224 -0
  100. package/skills/claude-devfleet/SKILL.md +103 -0
  101. package/skills/click-path-audit/SKILL.md +244 -0
  102. package/skills/clickhouse-io/SKILL.md +438 -0
  103. package/skills/code-tour/SKILL.md +235 -0
  104. package/skills/codebase-onboarding/SKILL.md +232 -0
  105. package/skills/coding-standards/SKILL.md +548 -0
  106. package/skills/compose-multiplatform-patterns/SKILL.md +298 -0
  107. package/skills/connections-optimizer/SKILL.md +188 -0
  108. package/skills/content-engine/SKILL.md +126 -0
  109. package/skills/content-hash-cache-pattern/SKILL.md +160 -0
  110. package/skills/context-budget/SKILL.md +134 -0
  111. package/skills/continuous-agent-loop/SKILL.md +44 -0
  112. package/skills/continuous-learning/SKILL.md +129 -0
  113. package/skills/continuous-learning/config.json +18 -0
  114. package/skills/continuous-learning/evaluate-session.sh +69 -0
  115. package/skills/continuous-learning-v2/SKILL.md +358 -0
  116. package/skills/continuous-learning-v2/agents/observer-loop.sh +322 -0
  117. package/skills/continuous-learning-v2/agents/observer.md +198 -0
  118. package/skills/continuous-learning-v2/agents/session-guardian.sh +150 -0
  119. package/skills/continuous-learning-v2/agents/start-observer.sh +248 -0
  120. package/skills/continuous-learning-v2/config.json +8 -0
  121. package/skills/continuous-learning-v2/hooks/observe.sh +476 -0
  122. package/skills/continuous-learning-v2/scripts/detect-project.sh +288 -0
  123. package/skills/continuous-learning-v2/scripts/instinct-cli.py +1519 -0
  124. package/skills/continuous-learning-v2/scripts/lib/homunculus-dir.sh +31 -0
  125. package/skills/continuous-learning-v2/scripts/migrate-homunculus.sh +62 -0
  126. package/skills/continuous-learning-v2/scripts/test_parse_instinct.py +1018 -0
  127. package/skills/cost-aware-llm-pipeline/SKILL.md +182 -0
  128. package/skills/cost-tracking/SKILL.md +147 -0
  129. package/skills/council/SKILL.md +202 -0
  130. package/skills/cpp-coding-standards/SKILL.md +722 -0
  131. package/skills/cpp-testing/SKILL.md +323 -0
  132. package/skills/crosspost/SKILL.md +110 -0
  133. package/skills/csharp-testing/SKILL.md +320 -0
  134. package/skills/customer-billing-ops/SKILL.md +139 -0
  135. package/skills/customs-trade-compliance/SKILL.md +262 -0
  136. package/skills/dart-flutter-patterns/SKILL.md +562 -0
  137. package/skills/dashboard-builder/SKILL.md +108 -0
  138. package/skills/data-scraper-agent/SKILL.md +764 -0
  139. package/skills/database-migrations/SKILL.md +428 -0
  140. package/skills/deep-research/SKILL.md +158 -0
  141. package/skills/defi-amm-security/SKILL.md +166 -0
  142. package/skills/deployment-patterns/SKILL.md +426 -0
  143. package/skills/design-system/SKILL.md +81 -0
  144. package/skills/django-celery/SKILL.md +456 -0
  145. package/skills/django-patterns/SKILL.md +733 -0
  146. package/skills/django-security/SKILL.md +592 -0
  147. package/skills/django-tdd/SKILL.md +728 -0
  148. package/skills/django-verification/SKILL.md +468 -0
  149. package/skills/dmux-workflows/SKILL.md +190 -0
  150. package/skills/docker-patterns/SKILL.md +363 -0
  151. package/skills/documentation-lookup/SKILL.md +89 -0
  152. package/skills/dotnet-patterns/SKILL.md +320 -0
  153. package/skills/e2e-testing/SKILL.md +325 -0
  154. package/skills/email-ops/SKILL.md +120 -0
  155. package/skills/energy-procurement/SKILL.md +227 -0
  156. package/skills/enterprise-agent-ops/SKILL.md +49 -0
  157. package/skills/error-handling/SKILL.md +375 -0
  158. package/skills/eval-harness/SKILL.md +269 -0
  159. package/skills/evm-token-decimals/SKILL.md +130 -0
  160. package/skills/exa-search/SKILL.md +106 -0
  161. package/skills/fal-ai-media/SKILL.md +287 -0
  162. package/skills/fastapi-patterns/SKILL.md +327 -0
  163. package/skills/finance-billing-ops/SKILL.md +126 -0
  164. package/skills/flox-environments/SKILL.md +496 -0
  165. package/skills/flutter-dart-code-review/SKILL.md +434 -0
  166. package/skills/foundation-models-on-device/SKILL.md +243 -0
  167. package/skills/frontend-design-direction/SKILL.md +92 -0
  168. package/skills/frontend-patterns/SKILL.md +641 -0
  169. package/skills/frontend-slides/SKILL.md +183 -0
  170. package/skills/frontend-slides/STYLE_PRESETS.md +330 -0
  171. package/skills/frontend-slides/animation-patterns.md +122 -0
  172. package/skills/frontend-slides/html-template.md +419 -0
  173. package/skills/frontend-slides/scripts/export-pdf.sh +418 -0
  174. package/skills/frontend-slides/scripts/extract-pptx.py +96 -0
  175. package/skills/frontend-slides/viewport-base.css +153 -0
  176. package/skills/fsharp-testing/SKILL.md +279 -0
  177. package/skills/gan-style-harness/SKILL.md +278 -0
  178. package/skills/gateguard/SKILL.md +125 -0
  179. package/skills/git-workflow/SKILL.md +714 -0
  180. package/skills/github-ops/SKILL.md +143 -0
  181. package/skills/golang-patterns/SKILL.md +673 -0
  182. package/skills/golang-testing/SKILL.md +719 -0
  183. package/skills/google-workspace-ops/SKILL.md +94 -0
  184. package/skills/healthcare-cdss-patterns/SKILL.md +245 -0
  185. package/skills/healthcare-emr-patterns/SKILL.md +159 -0
  186. package/skills/healthcare-eval-harness/SKILL.md +207 -0
  187. package/skills/healthcare-phi-compliance/SKILL.md +145 -0
  188. package/skills/hermes-imports/SKILL.md +87 -0
  189. package/skills/hexagonal-architecture/SKILL.md +275 -0
  190. package/skills/hipaa-compliance/SKILL.md +78 -0
  191. package/skills/homelab-network-readiness/SKILL.md +169 -0
  192. package/skills/homelab-network-setup/SKILL.md +129 -0
  193. package/skills/homelab-pihole-dns/SKILL.md +274 -0
  194. package/skills/homelab-vlan-segmentation/SKILL.md +311 -0
  195. package/skills/homelab-wireguard-vpn/SKILL.md +305 -0
  196. package/skills/hookify-rules/SKILL.md +128 -0
  197. package/skills/inventory-demand-planning/SKILL.md +246 -0
  198. package/skills/investor-materials/SKILL.md +95 -0
  199. package/skills/investor-outreach/SKILL.md +90 -0
  200. package/skills/ios-icon-gen/SKILL.md +157 -0
  201. package/skills/ios-icon-gen/scripts/generate_icons.swift +258 -0
  202. package/skills/ios-icon-gen/scripts/iconify_gen.sh +235 -0
  203. package/skills/iterative-retrieval/SKILL.md +209 -0
  204. package/skills/java-coding-standards/SKILL.md +382 -0
  205. package/skills/jira-integration/SKILL.md +292 -0
  206. package/skills/jpa-patterns/SKILL.md +150 -0
  207. package/skills/knowledge-ops/SKILL.md +153 -0
  208. package/skills/kotlin-coroutines-flows/SKILL.md +283 -0
  209. package/skills/kotlin-exposed-patterns/SKILL.md +718 -0
  210. package/skills/kotlin-ktor-patterns/SKILL.md +688 -0
  211. package/skills/kotlin-patterns/SKILL.md +710 -0
  212. package/skills/kotlin-testing/SKILL.md +823 -0
  213. package/skills/laravel-patterns/SKILL.md +414 -0
  214. package/skills/laravel-plugin-discovery/SKILL.md +228 -0
  215. package/skills/laravel-security/SKILL.md +284 -0
  216. package/skills/laravel-tdd/SKILL.md +282 -0
  217. package/skills/laravel-verification/SKILL.md +178 -0
  218. package/skills/lead-intelligence/SKILL.md +320 -0
  219. package/skills/lead-intelligence/agents/enrichment-agent.md +85 -0
  220. package/skills/lead-intelligence/agents/mutual-mapper.md +75 -0
  221. package/skills/lead-intelligence/agents/outreach-drafter.md +98 -0
  222. package/skills/lead-intelligence/agents/signal-scorer.md +60 -0
  223. package/skills/liquid-glass-design/SKILL.md +279 -0
  224. package/skills/llm-trading-agent-security/SKILL.md +146 -0
  225. package/skills/logistics-exception-management/SKILL.md +221 -0
  226. package/skills/make-interfaces-feel-better/SKILL.md +151 -0
  227. package/skills/manim-video/SKILL.md +88 -0
  228. package/skills/manim-video/assets/network_graph_scene.py +52 -0
  229. package/skills/market-research/SKILL.md +74 -0
  230. package/skills/mcp-server-patterns/SKILL.md +68 -0
  231. package/skills/messages-ops/SKILL.md +103 -0
  232. package/skills/mle-workflow/SKILL.md +345 -0
  233. package/skills/motion-advanced/SKILL.md +596 -0
  234. package/skills/motion-foundations/SKILL.md +299 -0
  235. package/skills/motion-patterns/SKILL.md +435 -0
  236. package/skills/motion-ui/SKILL.md +574 -0
  237. package/skills/mysql-patterns/SKILL.md +411 -0
  238. package/skills/nanoclaw-repl/SKILL.md +32 -0
  239. package/skills/nestjs-patterns/SKILL.md +229 -0
  240. package/skills/netmiko-ssh-automation/SKILL.md +173 -0
  241. package/skills/network-bgp-diagnostics/SKILL.md +167 -0
  242. package/skills/network-config-validation/SKILL.md +210 -0
  243. package/skills/network-interface-health/SKILL.md +152 -0
  244. package/skills/nextjs-turbopack/SKILL.md +43 -0
  245. package/skills/nodejs-keccak256/SKILL.md +102 -0
  246. package/skills/nutrient-document-processing/SKILL.md +166 -0
  247. package/skills/nuxt4-patterns/SKILL.md +99 -0
  248. package/skills/openclaw-persona-forge/SKILL.md +288 -0
  249. package/skills/openclaw-persona-forge/gacha.py +224 -0
  250. package/skills/openclaw-persona-forge/gacha.sh +5 -0
  251. package/skills/openclaw-persona-forge/references/avatar-style.md +124 -0
  252. package/skills/openclaw-persona-forge/references/boundary-rules.md +53 -0
  253. package/skills/openclaw-persona-forge/references/error-handling.md +53 -0
  254. package/skills/openclaw-persona-forge/references/identity-tension.md +48 -0
  255. package/skills/openclaw-persona-forge/references/naming-system.md +39 -0
  256. package/skills/openclaw-persona-forge/references/output-template.md +166 -0
  257. package/skills/opensource-pipeline/SKILL.md +254 -0
  258. package/skills/perl-patterns/SKILL.md +503 -0
  259. package/skills/perl-security/SKILL.md +502 -0
  260. package/skills/perl-testing/SKILL.md +474 -0
  261. package/skills/plan-orchestrate/SKILL.md +253 -0
  262. package/skills/plankton-code-quality/SKILL.md +236 -0
  263. package/skills/postgres-patterns/SKILL.md +146 -0
  264. package/skills/product-capability/SKILL.md +140 -0
  265. package/skills/product-lens/SKILL.md +91 -0
  266. package/skills/production-audit/SKILL.md +206 -0
  267. package/skills/production-scheduling/SKILL.md +237 -0
  268. package/skills/project-flow-ops/SKILL.md +110 -0
  269. package/skills/prompt-optimizer/SKILL.md +398 -0
  270. package/skills/python-patterns/SKILL.md +749 -0
  271. package/skills/python-testing/SKILL.md +815 -0
  272. package/skills/pytorch-patterns/SKILL.md +395 -0
  273. package/skills/quality-nonconformance/SKILL.md +259 -0
  274. package/skills/quarkus-patterns/SKILL.md +721 -0
  275. package/skills/quarkus-security/SKILL.md +466 -0
  276. package/skills/quarkus-tdd/SKILL.md +810 -0
  277. package/skills/quarkus-verification/SKILL.md +478 -0
  278. package/skills/ralphinho-rfc-pipeline/SKILL.md +66 -0
  279. package/skills/redis-patterns/SKILL.md +402 -0
  280. package/skills/regex-vs-llm-structured-text/SKILL.md +219 -0
  281. package/skills/remotion-video-creation/SKILL.md +43 -0
  282. package/skills/remotion-video-creation/rules/3d.md +86 -0
  283. package/skills/remotion-video-creation/rules/animations.md +29 -0
  284. package/skills/remotion-video-creation/rules/assets/charts-bar-chart.tsx +173 -0
  285. package/skills/remotion-video-creation/rules/assets/text-animations-typewriter.tsx +100 -0
  286. package/skills/remotion-video-creation/rules/assets/text-animations-word-highlight.tsx +108 -0
  287. package/skills/remotion-video-creation/rules/assets.md +78 -0
  288. package/skills/remotion-video-creation/rules/audio.md +172 -0
  289. package/skills/remotion-video-creation/rules/calculate-metadata.md +104 -0
  290. package/skills/remotion-video-creation/rules/can-decode.md +75 -0
  291. package/skills/remotion-video-creation/rules/charts.md +58 -0
  292. package/skills/remotion-video-creation/rules/compositions.md +146 -0
  293. package/skills/remotion-video-creation/rules/display-captions.md +126 -0
  294. package/skills/remotion-video-creation/rules/extract-frames.md +229 -0
  295. package/skills/remotion-video-creation/rules/fonts.md +152 -0
  296. package/skills/remotion-video-creation/rules/get-audio-duration.md +58 -0
  297. package/skills/remotion-video-creation/rules/get-video-dimensions.md +68 -0
  298. package/skills/remotion-video-creation/rules/get-video-duration.md +58 -0
  299. package/skills/remotion-video-creation/rules/gifs.md +138 -0
  300. package/skills/remotion-video-creation/rules/images.md +130 -0
  301. package/skills/remotion-video-creation/rules/import-srt-captions.md +67 -0
  302. package/skills/remotion-video-creation/rules/lottie.md +67 -0
  303. package/skills/remotion-video-creation/rules/measuring-dom-nodes.md +34 -0
  304. package/skills/remotion-video-creation/rules/measuring-text.md +143 -0
  305. package/skills/remotion-video-creation/rules/sequencing.md +106 -0
  306. package/skills/remotion-video-creation/rules/tailwind.md +11 -0
  307. package/skills/remotion-video-creation/rules/text-animations.md +20 -0
  308. package/skills/remotion-video-creation/rules/timing.md +179 -0
  309. package/skills/remotion-video-creation/rules/transcribe-captions.md +19 -0
  310. package/skills/remotion-video-creation/rules/transitions.md +122 -0
  311. package/skills/remotion-video-creation/rules/trimming.md +52 -0
  312. package/skills/remotion-video-creation/rules/videos.md +171 -0
  313. package/skills/repo-scan/SKILL.md +78 -0
  314. package/skills/research-ops/SKILL.md +111 -0
  315. package/skills/returns-reverse-logistics/SKILL.md +239 -0
  316. package/skills/rules-distill/SKILL.md +263 -0
  317. package/skills/rules-distill/scripts/scan-rules.sh +58 -0
  318. package/skills/rules-distill/scripts/scan-skills.sh +129 -0
  319. package/skills/rust-patterns/SKILL.md +498 -0
  320. package/skills/rust-testing/SKILL.md +499 -0
  321. package/skills/safety-guard/SKILL.md +74 -0
  322. package/skills/santa-method/SKILL.md +306 -0
  323. package/skills/scientific-db-pubmed-database/SKILL.md +175 -0
  324. package/skills/scientific-db-uspto-database/SKILL.md +177 -0
  325. package/skills/scientific-pkg-gget/SKILL.md +166 -0
  326. package/skills/scientific-thinking-literature-review/SKILL.md +192 -0
  327. package/skills/scientific-thinking-scholar-evaluation/SKILL.md +160 -0
  328. package/skills/search-first/SKILL.md +181 -0
  329. package/skills/security-bounty-hunter/SKILL.md +99 -0
  330. package/skills/security-review/SKILL.md +502 -0
  331. package/skills/security-review/cloud-infrastructure-security.md +361 -0
  332. package/skills/seo/SKILL.md +153 -0
  333. package/skills/skill-comply/SKILL.md +57 -0
  334. package/skills/skill-comply/fixtures/compliant_trace.jsonl +5 -0
  335. package/skills/skill-comply/fixtures/noncompliant_trace.jsonl +3 -0
  336. package/skills/skill-comply/fixtures/tdd_spec.yaml +44 -0
  337. package/skills/skill-comply/prompts/classifier.md +24 -0
  338. package/skills/skill-comply/prompts/scenario_generator.md +62 -0
  339. package/skills/skill-comply/prompts/spec_generator.md +42 -0
  340. package/skills/skill-comply/pyproject.toml +15 -0
  341. package/skills/skill-comply/scripts/__init__.py +0 -0
  342. package/skills/skill-comply/scripts/classifier.py +85 -0
  343. package/skills/skill-comply/scripts/grader.py +124 -0
  344. package/skills/skill-comply/scripts/parser.py +107 -0
  345. package/skills/skill-comply/scripts/report.py +170 -0
  346. package/skills/skill-comply/scripts/run.py +127 -0
  347. package/skills/skill-comply/scripts/runner.py +186 -0
  348. package/skills/skill-comply/scripts/scenario_generator.py +70 -0
  349. package/skills/skill-comply/scripts/spec_generator.py +72 -0
  350. package/skills/skill-comply/scripts/utils.py +13 -0
  351. package/skills/skill-comply/tests/test_grader.py +197 -0
  352. package/skills/skill-comply/tests/test_parser.py +90 -0
  353. package/skills/skill-comply/tests/test_runner.py +172 -0
  354. package/skills/skill-scout/SKILL.md +139 -0
  355. package/skills/skill-stocktake/SKILL.md +193 -0
  356. package/skills/skill-stocktake/scripts/quick-diff.sh +87 -0
  357. package/skills/skill-stocktake/scripts/save-results.sh +56 -0
  358. package/skills/skill-stocktake/scripts/scan.sh +170 -0
  359. package/skills/social-graph-ranker/SKILL.md +153 -0
  360. package/skills/springboot-patterns/SKILL.md +313 -0
  361. package/skills/springboot-security/SKILL.md +271 -0
  362. package/skills/springboot-tdd/SKILL.md +157 -0
  363. package/skills/springboot-verification/SKILL.md +230 -0
  364. package/skills/strategic-compact/SKILL.md +129 -0
  365. package/skills/strategic-compact/suggest-compact.sh +54 -0
  366. package/skills/swift-actor-persistence/SKILL.md +142 -0
  367. package/skills/swift-concurrency-6-2/SKILL.md +216 -0
  368. package/skills/swift-protocol-di-testing/SKILL.md +189 -0
  369. package/skills/swiftui-patterns/SKILL.md +259 -0
  370. package/skills/tdd-workflow/SKILL.md +462 -0
  371. package/skills/team-builder/SKILL.md +166 -0
  372. package/skills/terminal-ops/SKILL.md +108 -0
  373. package/skills/tinystruct-patterns/SKILL.md +130 -0
  374. package/skills/tinystruct-patterns/references/architecture.md +77 -0
  375. package/skills/tinystruct-patterns/references/data-handling.md +35 -0
  376. package/skills/tinystruct-patterns/references/routing.md +57 -0
  377. package/skills/tinystruct-patterns/references/system-usage.md +74 -0
  378. package/skills/tinystruct-patterns/references/testing.md +59 -0
  379. package/skills/token-budget-advisor/SKILL.md +133 -0
  380. package/skills/ui-demo/SKILL.md +464 -0
  381. package/skills/ui-to-vue/SKILL.md +134 -0
  382. package/skills/unified-notifications-ops/SKILL.md +186 -0
  383. package/skills/verification-loop/SKILL.md +125 -0
  384. package/skills/video-editing/SKILL.md +309 -0
  385. package/skills/videodb/SKILL.md +373 -0
  386. package/skills/videodb/reference/api-reference.md +550 -0
  387. package/skills/videodb/reference/capture-reference.md +407 -0
  388. package/skills/videodb/reference/capture.md +101 -0
  389. package/skills/videodb/reference/editor.md +443 -0
  390. package/skills/videodb/reference/generative.md +331 -0
  391. package/skills/videodb/reference/rtstream-reference.md +564 -0
  392. package/skills/videodb/reference/rtstream.md +65 -0
  393. package/skills/videodb/reference/search.md +230 -0
  394. package/skills/videodb/reference/streaming.md +406 -0
  395. package/skills/videodb/reference/use-cases.md +118 -0
  396. package/skills/videodb/scripts/ws_listener.py +282 -0
  397. package/skills/visa-doc-translate/README.md +86 -0
  398. package/skills/visa-doc-translate/SKILL.md +117 -0
  399. package/skills/vite-patterns/SKILL.md +448 -0
  400. package/skills/windows-desktop-e2e/SKILL.md +787 -0
  401. package/skills/workspace-surface-audit/SKILL.md +124 -0
  402. package/skills/x-api/SKILL.md +233 -0
@@ -0,0 +1,358 @@
1
+ ---
2
+ name: continuous-learning-v2
3
+ description: Instinct-based learning system that observes sessions via hooks, creates atomic instincts with confidence scoring, and evolves them into skills/commands/agents. v2.1 adds project-scoped instincts to prevent cross-project contamination.
4
+ origin: the toolset
5
+ version: 2.1.0
6
+ ---
7
+
8
+ # Continuous Learning v2.1 - Instinct
9
+ -Based Architecture
10
+
11
+ An advanced learning system that turns your Claude Code sessions into reusable knowledge through atomic "instincts" - small learned behaviors with confidence scoring.
12
+
13
+ **v2.1** adds **project-scoped instincts** — React patterns stay in your React project, Python conventions stay in your Python project, and universal patterns (like "always validate input") are shared globally.
14
+
15
+ ## When to Activate
16
+
17
+ - Setting up automatic learning from Claude Code sessions
18
+ - Configuring instinct-based behavior extraction via hooks
19
+ - Tuning confidence thresholds for learned behaviors
20
+ - Reviewing, exporting, or importing instinct libraries
21
+ - Evolving instincts into full skills, commands, or agents
22
+ - Managing project-scoped vs global instincts
23
+ - Promoting instincts from project to global scope
24
+
25
+ ## What's New in v2.1
26
+
27
+ | Feature | v2.0 | v2.1 |
28
+ |---------|------|------|
29
+ | Storage | Global (`~/.claude/homunculus/`) | Project-scoped (`${XDG_DATA_HOME:-~/.local/share}/skill-homunculus/projects/<hash>/`) |
30
+ | Scope | All instincts apply everywhere | Project-scoped + global |
31
+ | Detection | None | git remote URL / repo path |
32
+ | Promotion | N/A | Project → global when seen in 2+ projects |
33
+ | Commands | 4 (status/evolve/export/import) | 6 (+promote/projects) |
34
+ | Cross-project | Contamination risk | Isolated by default |
35
+
36
+ ## What's New in v2 (vs v1)
37
+
38
+ | Feature | v1 | v2 |
39
+ |---------|----|----|
40
+ | Observation | Stop hook (session end) | PreToolUse/PostToolUse (100% reliable) |
41
+ | Analysis | Main context | Background agent (Haiku) |
42
+ | Granularity | Full skills | Atomic "instincts" |
43
+ | Confidence | None | 0.3-0.9 weighted |
44
+ | Evolution | Direct to skill | Instincts -> cluster -> skill/command/agent |
45
+ | Sharing | None | Export/import instincts |
46
+
47
+ ## The Instinct Model
48
+
49
+ An instinct is a small learned behavior:
50
+
51
+ ```yaml
52
+ ---
53
+ id: prefer-functional-style
54
+ trigger: "when writing new functions"
55
+ confidence: 0.7
56
+ domain: "code-style"
57
+ source: "session-observation"
58
+ scope: project
59
+ project_id: "a1b2c3d4e5f6"
60
+ project_name: "my-react-app"
61
+ ---
62
+
63
+ # Prefer Functional Style
64
+
65
+ ## Action
66
+ Use functional patterns over classes when appropriate.
67
+
68
+ ## Evidence
69
+ - Observed 5 instances of functional pattern preference
70
+ - User corrected class-based approach to functional on 2025-01-15
71
+ ```
72
+
73
+ **Properties:**
74
+ - **Atomic** -- one trigger, one action
75
+ - **Confidence-weighted** -- 0.3 = tentative, 0.9 = near certain
76
+ - **Domain-tagged** -- code-style, testing, git, debugging, workflow, etc.
77
+ - **Evidence-backed** -- tracks what observations created it
78
+ - **Scope-aware** -- `project` (default) or `global`
79
+
80
+ ## How It Works
81
+
82
+ ```
83
+ Session Activity (in a git repo)
84
+ |
85
+ | Hooks capture prompts + tool use (100% reliable)
86
+ | + detect project context (git remote / repo path)
87
+ v
88
+ +---------------------------------------------+
89
+ | projects/<project-hash>/observations.jsonl |
90
+ | (prompts, tool calls, outcomes, project) |
91
+ +---------------------------------------------+
92
+ |
93
+ | Observer agent reads (background, Haiku)
94
+ v
95
+ +---------------------------------------------+
96
+ | PATTERN DETECTION |
97
+ | * User corrections -> instinct |
98
+ | * Error resolutions -> instinct |
99
+ | * Repeated workflows -> instinct |
100
+ | * Scope decision: project or global? |
101
+ +---------------------------------------------+
102
+ |
103
+ | Creates/updates
104
+ v
105
+ +---------------------------------------------+
106
+ | projects/<project-hash>/instincts/personal/ |
107
+ | * prefer-functional.yaml (0.7) [project] |
108
+ | * use-react-hooks.yaml (0.9) [project] |
109
+ +---------------------------------------------+
110
+ | instincts/personal/ (GLOBAL) |
111
+ | * always-validate-input.yaml (0.85) [global]|
112
+ | * grep-before-edit.yaml (0.6) [global] |
113
+ +---------------------------------------------+
114
+ |
115
+ | /evolve clusters + /promote
116
+ v
117
+ +---------------------------------------------+
118
+ | projects/<hash>/evolved/ (project-scoped) |
119
+ | evolved/ (global) |
120
+ | * commands/new-feature.md |
121
+ | * skills/testing-workflow.md |
122
+ | * agents/refactor-specialist.md |
123
+ +---------------------------------------------+
124
+ ```
125
+
126
+ ## Project Detection
127
+
128
+ The system automatically detects your current project:
129
+
130
+ 1. **`CLAUDE_PROJECT_DIR` env var** (highest priority)
131
+ 2. **`git remote get-url origin`** -- hashed to create a portable project ID (same repo on different machines gets the same ID)
132
+ 3. **`git rev-parse --show-toplevel`** -- fallback using repo path (machine-specific)
133
+ 4. **Global fallback** -- if no project is detected, instincts go to global scope
134
+
135
+ Each project gets a 12-character hash ID (e.g., `a1b2c3d4e5f6`). A registry file at `${XDG_DATA_HOME:-~/.local/share}/skill-homunculus/projects.json` maps IDs to human-readable names.
136
+
137
+ ### Data Directory
138
+
139
+ Continuous-learning-v2 stores observer data outside `~/.claude` so Claude Code's sensitive-path guard does not block background instinct writes:
140
+
141
+ 1. `CLV2_HOMUNCULUS_DIR` when set to an absolute path
142
+ 2. `$XDG_DATA_HOME/skill-homunculus`
143
+ 3. `$HOME/.local/share/skill-homunculus`
144
+
145
+ Existing users with data at `~/.claude/homunculus` can migrate once:
146
+
147
+ ```bash
148
+ bash skills/continuous-learning-v2/scripts/migrate-homunculus.sh
149
+ ```
150
+
151
+ ## Quick Start
152
+
153
+ ### 1. Enable Observation Hooks
154
+
155
+ **If installed as a plugin** (recommended):
156
+
157
+ No extra `settings.json` hook block is required. Claude Code v2.1+ auto-loads the plugin `hooks/hooks.json`, and `observe.sh` is already registered there.
158
+
159
+ If you previously copied `observe.sh` into `~/.claude/settings.json`, remove that duplicate `PreToolUse` / `PostToolUse` block. Duplicating the plugin hook causes double execution and `${CLAUDE_PLUGIN_ROOT}` resolution errors because that variable is only available inside plugin-managed `hooks/hooks.json` entries.
160
+
161
+ **If installed manually** to `~/.claude/skills`, add this to your `~/.claude/settings.json`:
162
+
163
+ ```json
164
+ {
165
+ "hooks": {
166
+ "PreToolUse": [{
167
+ "matcher": "*",
168
+ "hooks": [{
169
+ "type": "command",
170
+ "command": "~/.claude/skills/continuous-learning-v2/hooks/observe.sh"
171
+ }]
172
+ }],
173
+ "PostToolUse": [{
174
+ "matcher": "*",
175
+ "hooks": [{
176
+ "type": "command",
177
+ "command": "~/.claude/skills/continuous-learning-v2/hooks/observe.sh"
178
+ }]
179
+ }]
180
+ }
181
+ }
182
+ ```
183
+
184
+ ### 2. Initialize Directory Structure
185
+
186
+ The system creates directories automatically on first use, but you can also create them manually:
187
+
188
+ ```bash
189
+ # Global directories
190
+ mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/skill-homunculus"/{instincts/{personal,inherited},evolved/{agents,skills,commands},projects}
191
+
192
+ # Project directories are auto-created when the hook first runs in a git repo
193
+ ```
194
+
195
+ ### 3. Use the Instinct Commands
196
+
197
+ ```bash
198
+ /instinct-status # Show learned instincts (project + global)
199
+ /evolve # Cluster related instincts into skills/commands
200
+ /instinct-export # Export instincts to file
201
+ /instinct-import # Import instincts from others
202
+ /promote # Promote project instincts to global scope
203
+ /projects # List all known projects and their instinct counts
204
+ ```
205
+
206
+ ## Commands
207
+
208
+ | Command | Description |
209
+ |---------|-------------|
210
+ | `/instinct-status` | Show all instincts (project-scoped + global) with confidence |
211
+ | `/evolve` | Cluster related instincts into skills/commands, suggest promotions |
212
+ | `/instinct-export` | Export instincts (filterable by scope/domain) |
213
+ | `/instinct-import <file>` | Import instincts with scope control |
214
+ | `/promote [id]` | Promote project instincts to global scope |
215
+ | `/projects` | List all known projects and their instinct counts |
216
+
217
+ ## Configuration
218
+
219
+ Edit `config.json` to control the background observer:
220
+
221
+ ```json
222
+ {
223
+ "version": "2.1",
224
+ "observer": {
225
+ "enabled": false,
226
+ "run_interval_minutes": 5,
227
+ "min_observations_to_analyze": 20
228
+ }
229
+ }
230
+ ```
231
+
232
+ | Key | Default | Description |
233
+ |-----|---------|-------------|
234
+ | `observer.enabled` | `false` | Enable the background observer agent |
235
+ | `observer.run_interval_minutes` | `5` | How often the observer analyzes observations |
236
+ | `observer.min_observations_to_analyze` | `20` | Minimum observations before analysis runs |
237
+
238
+ Other behavior (observation capture, instinct thresholds, project scoping, promotion criteria) is configured via code defaults in `instinct-cli.py` and `observe.sh`.
239
+
240
+ ## File Structure
241
+
242
+ ```
243
+ ${XDG_DATA_HOME:-~/.local/share}/skill-homunculus/
244
+ +-- identity.json # Your profile, technical level
245
+ +-- projects.json # Registry: project hash -> name/path/remote
246
+ +-- observations.jsonl # Global observations (fallback)
247
+ +-- instincts/
248
+ | +-- personal/ # Global auto-learned instincts
249
+ | +-- inherited/ # Global imported instincts
250
+ +-- evolved/
251
+ | +-- agents/ # Global generated agents
252
+ | +-- skills/ # Global generated skills
253
+ | +-- commands/ # Global generated commands
254
+ +-- projects/
255
+ +-- a1b2c3d4e5f6/ # Project hash (from git remote URL)
256
+ | +-- project.json # Per-project metadata mirror (id/name/root/remote)
257
+ | +-- observations.jsonl
258
+ | +-- observations.archive/
259
+ | +-- instincts/
260
+ | | +-- personal/ # Project-specific auto-learned
261
+ | | +-- inherited/ # Project-specific imported
262
+ | +-- evolved/
263
+ | +-- skills/
264
+ | +-- commands/
265
+ | +-- agents/
266
+ +-- f6e5d4c3b2a1/ # Another project
267
+ +-- ...
268
+ ```
269
+
270
+ ## Scope Decision Guide
271
+
272
+ | Pattern Type | Scope | Examples |
273
+ |-------------|-------|---------|
274
+ | Language/framework conventions | **project** | "Use React hooks", "Follow Django REST patterns" |
275
+ | File structure preferences | **project** | "Tests in `__tests__`/", "Components in src/components/" |
276
+ | Code style | **project** | "Use functional style", "Prefer dataclasses" |
277
+ | Error handling strategies | **project** | "Use Result type for errors" |
278
+ | Security practices | **global** | "Validate user input", "Sanitize SQL" |
279
+ | General best practices | **global** | "Write tests first", "Always handle errors" |
280
+ | Tool workflow preferences | **global** | "Grep before Edit", "Read before Write" |
281
+ | Git practices | **global** | "Conventional commits", "Small focused commits" |
282
+
283
+ ## Instinct Promotion (Project -> Global)
284
+
285
+ When the same instinct appears in multiple projects with high confidence, it's a candidate for promotion to global scope.
286
+
287
+ **Auto-promotion criteria:**
288
+ - Same instinct ID in 2+ projects
289
+ - Average confidence >= 0.8
290
+
291
+ **How to promote:**
292
+
293
+ ```bash
294
+ # Promote a specific instinct
295
+ python3 instinct-cli.py promote prefer-explicit-errors
296
+
297
+ # Auto-promote all qualifying instincts
298
+ python3 instinct-cli.py promote
299
+
300
+ # Preview without changes
301
+ python3 instinct-cli.py promote --dry-run
302
+ ```
303
+
304
+ The `/evolve` command also suggests promotion candidates.
305
+
306
+ ## Confidence Scoring
307
+
308
+ Confidence evolves over time:
309
+
310
+ | Score | Meaning | Behavior |
311
+ |-------|---------|----------|
312
+ | 0.3 | Tentative | Suggested but not enforced |
313
+ | 0.5 | Moderate | Applied when relevant |
314
+ | 0.7 | Strong | Auto-approved for application |
315
+ | 0.9 | Near-certain | Core behavior |
316
+
317
+ **Confidence increases** when:
318
+ - Pattern is repeatedly observed
319
+ - User doesn't correct the suggested behavior
320
+ - Similar instincts from other sources agree
321
+
322
+ **Confidence decreases** when:
323
+ - User explicitly corrects the behavior
324
+ - Pattern isn't observed for extended periods
325
+ - Contradicting evidence appears
326
+
327
+ ## Why Hooks vs Skills for Observation?
328
+
329
+ > "v1 relied on skills to observe. Skills are probabilistic -- they fire ~50-80% of the time based on Claude's judgment."
330
+
331
+ Hooks fire **100% of the time**, deterministically. This means:
332
+ - Every tool call is observed
333
+ - No patterns are missed
334
+ - Learning is comprehensive
335
+
336
+ ## Backward Compatibility
337
+
338
+ v2.1 is fully compatible with v2.0 and v1:
339
+ - Existing global instincts can be migrated from `~/.claude/homunculus/instincts/` with `scripts/migrate-homunculus.sh`
340
+ - Existing `~/.claude/skills/learned/` skills from v1 still work
341
+ - Stop hook still runs (but now also feeds into v2)
342
+ - Gradual migration: run both in parallel
343
+
344
+ ## Privacy
345
+
346
+ - Observations stay **local** on your machine
347
+ - Project-scoped instincts are isolated per project
348
+ - Only **instincts** (patterns) can be exported — not raw observations
349
+ - No actual code or conversation content is shared
350
+ - You control what gets exported and promoted
351
+
352
+ ## Related
353
+
354
+ - Homunculus - Community project that inspired the v2 instinct-based architecture (atomic observations, confidence scoring, instinct evolution pipeline)
355
+
356
+ ---
357
+
358
+ *Instinct-based learning: teaching Claude your patterns, one project at a time.*
@@ -0,0 +1,322 @@
1
+ #!/usr/bin/env bash
2
+ # Continuous Learning v2 - Observer background loop
3
+ #
4
+ # Fix for #521: Added re-entrancy guard, cooldown throttle, and
5
+ # tail-based sampling to prevent memory explosion from runaway
6
+ # parallel Claude analysis processes.
7
+
8
+ set +e
9
+ unset CLAUDECODE
10
+
11
+ SLEEP_PID=""
12
+ USR1_FIRED=0
13
+ PENDING_ANALYSIS=0
14
+ ANALYZING=0
15
+ LAST_ANALYSIS_EPOCH=0
16
+ # Minimum seconds between analyses (prevents rapid re-triggering)
17
+ ANALYSIS_COOLDOWN="${SKILLFORGE_OBSERVER_ANALYSIS_COOLDOWN:-60}"
18
+ IDLE_TIMEOUT_SECONDS="${SKILLFORGE_OBSERVER_IDLE_TIMEOUT_SECONDS:-1800}"
19
+ SESSION_LEASE_DIR="${PROJECT_DIR}/.observer-sessions"
20
+ ACTIVITY_FILE="${PROJECT_DIR}/.observer-last-activity"
21
+
22
+ cleanup() {
23
+ [ -n "$SLEEP_PID" ] && kill "$SLEEP_PID" 2>/dev/null
24
+ if [ -f "$PID_FILE" ] && [ "$(cat "$PID_FILE" 2>/dev/null)" = "$$" ]; then
25
+ rm -f "$PID_FILE"
26
+ fi
27
+ exit 0
28
+ }
29
+ trap cleanup TERM INT
30
+
31
+ file_mtime_epoch() {
32
+ local file="$1"
33
+ if [ ! -f "$file" ]; then
34
+ printf '0\n'
35
+ return
36
+ fi
37
+
38
+ if stat -c %Y "$file" >/dev/null 2>&1; then
39
+ stat -c %Y "$file" 2>/dev/null || printf '0\n'
40
+ return
41
+ fi
42
+
43
+ if stat -f %m "$file" >/dev/null 2>&1; then
44
+ stat -f %m "$file" 2>/dev/null || printf '0\n'
45
+ return
46
+ fi
47
+
48
+ printf '0\n'
49
+ }
50
+
51
+ has_active_session_leases() {
52
+ if [ ! -d "$SESSION_LEASE_DIR" ]; then
53
+ return 1
54
+ fi
55
+
56
+ find "$SESSION_LEASE_DIR" -type f -name '*.json' -print -quit 2>/dev/null | grep -q .
57
+ }
58
+
59
+ latest_activity_epoch() {
60
+ local observations_epoch activity_epoch
61
+ observations_epoch="$(file_mtime_epoch "$OBSERVATIONS_FILE")"
62
+ activity_epoch="$(file_mtime_epoch "$ACTIVITY_FILE")"
63
+
64
+ if [ "$activity_epoch" -gt "$observations_epoch" ] 2>/dev/null; then
65
+ printf '%s\n' "$activity_epoch"
66
+ else
67
+ printf '%s\n' "$observations_epoch"
68
+ fi
69
+ }
70
+
71
+ exit_if_idle_without_sessions() {
72
+ if has_active_session_leases; then
73
+ return
74
+ fi
75
+
76
+ local last_activity now_epoch idle_for
77
+ last_activity="$(latest_activity_epoch)"
78
+ now_epoch="$(date +%s)"
79
+ idle_for=$(( now_epoch - last_activity ))
80
+
81
+ if [ "$last_activity" -eq 0 ] || [ "$idle_for" -ge "$IDLE_TIMEOUT_SECONDS" ]; then
82
+ echo "[$(date)] Observer idle without active session leases for ${idle_for}s; exiting" >> "$LOG_FILE"
83
+ cleanup
84
+ fi
85
+ }
86
+
87
+ wait_for_claude_analysis() {
88
+ local child_pid="$1"
89
+ local wait_status=0
90
+
91
+ while true; do
92
+ wait "$child_pid"
93
+ wait_status=$?
94
+
95
+ if [ "$wait_status" -eq 0 ]; then
96
+ return 0
97
+ fi
98
+
99
+ # SIGUSR1 can interrupt wait while the Claude child is still running.
100
+ # Re-wait in that case so a signal is not logged as a false child failure.
101
+ if kill -0 "$child_pid" 2>/dev/null; then
102
+ continue
103
+ fi
104
+
105
+ return "$wait_status"
106
+ done
107
+ }
108
+
109
+ analyze_observations() {
110
+ if [ ! -f "$OBSERVATIONS_FILE" ]; then
111
+ return
112
+ fi
113
+
114
+ obs_count=$(wc -l < "$OBSERVATIONS_FILE" 2>/dev/null || echo 0)
115
+ if [ "$obs_count" -lt "$MIN_OBSERVATIONS" ]; then
116
+ return
117
+ fi
118
+
119
+ echo "[$(date)] Analyzing $obs_count observations for project ${PROJECT_NAME}..." >> "$LOG_FILE"
120
+
121
+ if [ "${CLV2_IS_WINDOWS:-false}" = "true" ] && [ "${SKILLFORGE_OBSERVER_ALLOW_WINDOWS:-false}" != "true" ]; then
122
+ echo "[$(date)] Skipping claude analysis on Windows due to known non-interactive hang issue (#295). Set SKILLFORGE_OBSERVER_ALLOW_WINDOWS=true to override." >> "$LOG_FILE"
123
+ return
124
+ fi
125
+
126
+ if ! command -v claude >/dev/null 2>&1; then
127
+ echo "[$(date)] claude CLI not found, skipping analysis" >> "$LOG_FILE"
128
+ return
129
+ fi
130
+
131
+ # session-guardian: gate observer cycle (active hours, cooldown, idle detection)
132
+ if ! bash "$(dirname "$0")/session-guardian.sh"; then
133
+ echo "[$(date)] Observer cycle skipped by session-guardian" >> "$LOG_FILE"
134
+ return
135
+ fi
136
+
137
+ # Sample recent observations instead of loading the entire file (#521).
138
+ # This prevents multi-MB payloads from being passed to the LLM.
139
+ MAX_ANALYSIS_LINES="${SKILLFORGE_OBSERVER_MAX_ANALYSIS_LINES:-500}"
140
+ observer_tmp_dir="${PROJECT_DIR}/.observer-tmp"
141
+ mkdir -p "$observer_tmp_dir"
142
+ analysis_file="$(mktemp "${observer_tmp_dir}/sf-observer-analysis.XXXXXX.jsonl")"
143
+ tail -n "$MAX_ANALYSIS_LINES" "$OBSERVATIONS_FILE" > "$analysis_file"
144
+ analysis_count=$(wc -l < "$analysis_file" 2>/dev/null || echo 0)
145
+ echo "[$(date)] Using last $analysis_count of $obs_count observations for analysis" >> "$LOG_FILE"
146
+
147
+ # Use relative path from PROJECT_DIR for cross-platform compatibility (#842).
148
+ # On Windows (Git Bash/MSYS2), absolute paths from mktemp may use MSYS-style
149
+ # prefixes (e.g. /c/Users/...) that the Claude subprocess cannot resolve.
150
+ analysis_relpath=".observer-tmp/$(basename "$analysis_file")"
151
+
152
+ prompt_file="$(mktemp "${observer_tmp_dir}/sf-observer-prompt.XXXXXX")"
153
+ cat > "$prompt_file" <<PROMPT
154
+ IMPORTANT: You are running in non-interactive --print mode. You MUST use the Write tool directly to create files. Do NOT ask for permission, do NOT ask for confirmation, do NOT output summaries instead of writing. Just read, analyze, and write.
155
+
156
+ Read ${analysis_relpath} and identify patterns for the project ${PROJECT_NAME} (user corrections, error resolutions, repeated workflows, tool preferences).
157
+ If you find 3+ occurrences of the same pattern, you MUST write an instinct file directly to ${INSTINCTS_DIR}/<id>.md using the Write tool.
158
+ Do NOT ask for permission to write files, do NOT describe what you would write, and do NOT stop at analysis when a qualifying pattern exists.
159
+
160
+ CRITICAL: Every instinct file MUST use this exact format:
161
+
162
+ ---
163
+ id: kebab-case-name
164
+ trigger: when <specific condition>
165
+ confidence: <0.3-0.85 based on frequency: 3-5 times=0.5, 6-10=0.7, 11+=0.85>
166
+ domain: <one of: code-style, testing, git, debugging, workflow, file-patterns>
167
+ source: session-observation
168
+ scope: project
169
+ project_id: ${PROJECT_ID}
170
+ project_name: ${PROJECT_NAME}
171
+ ---
172
+
173
+ # Title
174
+
175
+ ## Action
176
+ <what to do, one clear sentence>
177
+
178
+ ## Evidence
179
+ - Observed N times in session <id>
180
+ - Pattern: <description>
181
+ - Last observed: <date>
182
+
183
+ Rules:
184
+ - Be conservative, only clear patterns with 3+ observations
185
+ - Use narrow, specific triggers
186
+ - Never include actual code snippets, only describe patterns
187
+ - When a qualifying pattern exists, write or update the instinct file in this run instead of asking for confirmation
188
+ - If a similar instinct already exists in ${INSTINCTS_DIR}/, update it instead of creating a duplicate
189
+ - The YAML frontmatter (between --- markers) with id field is MANDATORY
190
+ - If a pattern seems universal (not project-specific), set scope to global instead of project
191
+ - Examples of global patterns: always validate user input, prefer explicit error handling
192
+ - Examples of project patterns: use React functional components, follow Django REST framework conventions
193
+ PROMPT
194
+
195
+ # Read the prompt into memory before the Claude subprocess is spawned.
196
+ # On Windows/MSYS2, the mktemp path can differ from the shell's later path
197
+ # resolution, so relying on cat "$prompt_file" inside the claude invocation
198
+ # can fail even though the file was created successfully.
199
+ prompt_content="$(cat "$prompt_file" 2>/dev/null || true)"
200
+ rm -f "$prompt_file"
201
+ if [ -z "$prompt_content" ]; then
202
+ echo "[$(date)] Failed to load observer prompt content, skipping analysis" >> "$LOG_FILE"
203
+ rm -f "$analysis_file"
204
+ return
205
+ fi
206
+
207
+ timeout_seconds="${SKILLFORGE_OBSERVER_TIMEOUT_SECONDS:-120}"
208
+ max_turns="${SKILLFORGE_OBSERVER_MAX_TURNS:-20}"
209
+ exit_code=0
210
+
211
+ case "$max_turns" in
212
+ ''|*[!0-9]*)
213
+ max_turns=20
214
+ ;;
215
+ esac
216
+
217
+ if [ "$max_turns" -lt 4 ]; then
218
+ max_turns=20
219
+ fi
220
+
221
+ # Ensure CWD is PROJECT_DIR so the relative analysis_relpath resolves correctly
222
+ # on all platforms, not just when the observer happens to be launched from the project root.
223
+ cd "$PROJECT_DIR" || { echo "[$(date)] Failed to cd to PROJECT_DIR ($PROJECT_DIR), skipping analysis" >> "$LOG_FILE"; rm -f "$analysis_file"; return; }
224
+
225
+ # Prevent observe.sh from recording this automated Haiku session as observations.
226
+ # Pass prompt via -p flag instead of stdin redirect for Windows compatibility (#842).
227
+ # prompt_content is already loaded in-memory so this no longer depends on the
228
+ # mktemp absolute path continuing to resolve after cwd changes (#1296).
229
+ SKILLFORGE_SKIP_OBSERVE=1 SKILLFORGE_HOOK_PROFILE=minimal claude --model haiku --max-turns "$max_turns" --print \
230
+ --allowedTools "Read,Write" \
231
+ -p "$prompt_content" >> "$LOG_FILE" 2>&1 &
232
+ claude_pid=$!
233
+
234
+ (
235
+ sleep "$timeout_seconds"
236
+ if kill -0 "$claude_pid" 2>/dev/null; then
237
+ echo "[$(date)] Claude analysis timed out after ${timeout_seconds}s; terminating process" >> "$LOG_FILE"
238
+ kill "$claude_pid" 2>/dev/null || true
239
+ fi
240
+ ) &
241
+ watchdog_pid=$!
242
+
243
+ wait_for_claude_analysis "$claude_pid"
244
+ exit_code=$?
245
+ kill "$watchdog_pid" 2>/dev/null || true
246
+ rm -f "$analysis_file"
247
+
248
+ if [ "$exit_code" -ne 0 ]; then
249
+ echo "[$(date)] Claude analysis failed (exit $exit_code)" >> "$LOG_FILE"
250
+ fi
251
+
252
+ if [ -f "$OBSERVATIONS_FILE" ]; then
253
+ archive_dir="${PROJECT_DIR}/observations.archive"
254
+ mkdir -p "$archive_dir"
255
+ mv "$OBSERVATIONS_FILE" "$archive_dir/processed-$(date +%Y%m%d-%H%M%S)-$$.jsonl" 2>/dev/null || true
256
+ fi
257
+ }
258
+
259
+ on_usr1() {
260
+ [ -n "$SLEEP_PID" ] && kill "$SLEEP_PID" 2>/dev/null
261
+ SLEEP_PID=""
262
+
263
+ # Re-entrancy guard: defer the nudge so the main loop runs a follow-up
264
+ # analysis immediately after the current analysis finishes.
265
+ if [ "$ANALYZING" -eq 1 ]; then
266
+ PENDING_ANALYSIS=1
267
+ echo "[$(date)] Analysis already in progress, deferring signal" >> "$LOG_FILE"
268
+ return
269
+ fi
270
+
271
+ USR1_FIRED=1
272
+
273
+ # Cooldown: skip if last analysis was too recent (#521)
274
+ now_epoch=$(date +%s)
275
+ elapsed=$(( now_epoch - LAST_ANALYSIS_EPOCH ))
276
+ if [ "$elapsed" -lt "$ANALYSIS_COOLDOWN" ]; then
277
+ echo "[$(date)] Analysis cooldown active (${elapsed}s < ${ANALYSIS_COOLDOWN}s), skipping" >> "$LOG_FILE"
278
+ return
279
+ fi
280
+
281
+ ANALYZING=1
282
+ analyze_observations
283
+ LAST_ANALYSIS_EPOCH=$(date +%s)
284
+ ANALYZING=0
285
+ }
286
+ trap on_usr1 USR1
287
+
288
+ echo "$$" > "$PID_FILE"
289
+ echo "[$(date)] Observer started for ${PROJECT_NAME} (PID: $$)" >> "$LOG_FILE"
290
+
291
+ # Prune expired pending instincts before analysis
292
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
293
+ "${CLV2_PYTHON_CMD:-python3}" "${SCRIPT_DIR}/../scripts/instinct-cli.py" prune --quiet >> "$LOG_FILE" 2>&1 || echo "[$(date)] Warning: instinct prune failed (non-fatal)" >> "$LOG_FILE"
294
+
295
+ while true; do
296
+ exit_if_idle_without_sessions
297
+
298
+ if [ "$PENDING_ANALYSIS" -eq 1 ]; then
299
+ PENDING_ANALYSIS=0
300
+ USR1_FIRED=0
301
+ ANALYZING=1
302
+ analyze_observations
303
+ LAST_ANALYSIS_EPOCH=$(date +%s)
304
+ ANALYZING=0
305
+ continue
306
+ fi
307
+
308
+ sleep "$OBSERVER_INTERVAL_SECONDS" &
309
+ SLEEP_PID=$!
310
+ wait "$SLEEP_PID" 2>/dev/null
311
+ SLEEP_PID=""
312
+
313
+ exit_if_idle_without_sessions
314
+ if [ "$USR1_FIRED" -eq 1 ]; then
315
+ USR1_FIRED=0
316
+ else
317
+ ANALYZING=1
318
+ analyze_observations
319
+ LAST_ANALYSIS_EPOCH=$(date +%s)
320
+ ANALYZING=0
321
+ fi
322
+ done