opencode-agent-kit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +796 -0
- package/bin/commands/init.mjs +221 -0
- package/bin/init.mjs +21 -0
- package/package.json +22 -0
- package/template/.opencode/agent-docs/backend/README.md +0 -0
- package/template/.opencode/agent-docs/backend/node/BACKEND_PATTERNS.md +82 -0
- package/template/.opencode/agent-docs/backend/node/BACKEND_QUICK_START.md +49 -0
- package/template/.opencode/agent-docs/frontend/next/README.md +0 -0
- package/template/.opencode/agent-docs/frontend/nuxt/API_PATTERNS.md +807 -0
- package/template/.opencode/agent-docs/frontend/nuxt/CHEATSHEET.md +676 -0
- package/template/.opencode/agent-docs/frontend/nuxt/COMPLETION_REPORT.md +613 -0
- package/template/.opencode/agent-docs/frontend/nuxt/EXAMPLES.md +956 -0
- package/template/.opencode/agent-docs/frontend/nuxt/INDEX.md +596 -0
- package/template/.opencode/agent-docs/frontend/nuxt/MCP_GUIDE.md +881 -0
- package/template/.opencode/agent-docs/frontend/nuxt/MENTOR_CURRICULUM_30_DAYS.md +256 -0
- package/template/.opencode/agent-docs/frontend/nuxt/MENTOR_CURRICULUM_CHECKLIST.md +156 -0
- package/template/.opencode/agent-docs/frontend/nuxt/MENTOR_WEEKLY_ASSIGNMENTS.md +191 -0
- package/template/.opencode/agent-docs/frontend/nuxt/QUICK_START.md +509 -0
- package/template/.opencode/agent-docs/frontend/nuxt/README.md +506 -0
- package/template/.opencode/agent-docs/frontend/nuxt/README_AGENTS.md +140 -0
- package/template/.opencode/agent-docs/frontend/nuxt/README_DOCS.md +65 -0
- package/template/.opencode/agent-docs/frontend/nuxt/SUMMARY.md +474 -0
- package/template/.opencode/agent-docs/frontend/nuxt/TEAM_OPERATING_GUIDE.md +54 -0
- package/template/.opencode/agent-docs/frontend/nuxt/TESTING_GUIDE.md +904 -0
- package/template/.opencode/agent-docs/frontend/nuxt/WORKFLOWS.md +758 -0
- package/template/.opencode/agent-docs/frontend/react/API_PATTERNS.md +187 -0
- package/template/.opencode/agent-docs/frontend/react/CHEATSHEET.md +87 -0
- package/template/.opencode/agent-docs/frontend/react/INDEX.md +45 -0
- package/template/.opencode/agent-docs/frontend/react/QUICK_START.md +43 -0
- package/template/.opencode/agent-docs/frontend/react/README.md +159 -0
- package/template/.opencode/agent-docs/frontend/vue/README.md +0 -0
- package/template/.opencode/agent-docs/mobile/android/README.md +45 -0
- package/template/.opencode/agent-docs/mobile/flutter/README.md +44 -0
- package/template/.opencode/agents/android-developer.md +418 -0
- package/template/.opencode/agents/code-igniter-3-fullstack.md +345 -0
- package/template/.opencode/agents/code-reviewer.md +517 -0
- package/template/.opencode/agents/database-specialist.md +455 -0
- package/template/.opencode/agents/devops-specialist.md +562 -0
- package/template/.opencode/agents/flutter-developer.md +556 -0
- package/template/.opencode/agents/it-leader.md +911 -0
- package/template/.opencode/agents/laravel-advanced.md +691 -0
- package/template/.opencode/agents/node-backend-developer.md +343 -0
- package/template/.opencode/agents/nuxt-frontend-developer-mentor.md +402 -0
- package/template/.opencode/agents/nuxt-frontend-developer.md +1573 -0
- package/template/.opencode/agents/react-frontend-developer.md +1017 -0
- package/template/.opencode/agents/seo-specialist.md +681 -0
- package/template/.opencode/agents/ui-ux-designer.md +783 -0
- package/template/.opencode/commands/android-build/command.md +25 -0
- package/template/.opencode/commands/android-test/command.md +23 -0
- package/template/.opencode/commands/build-fix.md +29 -0
- package/template/.opencode/commands/checkpoint.md +74 -0
- package/template/.opencode/commands/code-review.md +40 -0
- package/template/.opencode/commands/e2e.md +363 -0
- package/template/.opencode/commands/eval.md +120 -0
- package/template/.opencode/commands/evolve.md +193 -0
- package/template/.opencode/commands/flutter-build/command.md +25 -0
- package/template/.opencode/commands/flutter-test/command.md +24 -0
- package/template/.opencode/commands/go-build.md +183 -0
- package/template/.opencode/commands/go-review.md +148 -0
- package/template/.opencode/commands/go-test.md +268 -0
- package/template/.opencode/commands/gpc-release/command.md +30 -0
- package/template/.opencode/commands/instinct-export.md +91 -0
- package/template/.opencode/commands/instinct-import.md +142 -0
- package/template/.opencode/commands/instinct-status.md +86 -0
- package/template/.opencode/commands/learn.md +70 -0
- package/template/.opencode/commands/multi-backend.md +158 -0
- package/template/.opencode/commands/multi-execute.md +310 -0
- package/template/.opencode/commands/multi-frontend.md +158 -0
- package/template/.opencode/commands/multi-plan.md +261 -0
- package/template/.opencode/commands/multi-workflow.md +183 -0
- package/template/.opencode/commands/orchestrate.md +172 -0
- package/template/.opencode/commands/plan.md +113 -0
- package/template/.opencode/commands/pm2.md +271 -0
- package/template/.opencode/commands/python-review.md +297 -0
- package/template/.opencode/commands/refactor-clean.md +28 -0
- package/template/.opencode/commands/sessions.md +305 -0
- package/template/.opencode/commands/setup-pm.md +80 -0
- package/template/.opencode/commands/skill-create.md +174 -0
- package/template/.opencode/commands/tdd.md +326 -0
- package/template/.opencode/commands/test-coverage.md +27 -0
- package/template/.opencode/commands/update-codemaps.md +17 -0
- package/template/.opencode/commands/update-docs.md +31 -0
- package/template/.opencode/commands/verify.md +59 -0
- package/template/.opencode/config.example.json +309 -0
- package/template/.opencode/config.json +341 -0
- package/template/.opencode/contexts/dev.md +20 -0
- package/template/.opencode/contexts/research.md +26 -0
- package/template/.opencode/contexts/review.md +22 -0
- package/template/.opencode/hooks/hooks.json +169 -0
- package/template/.opencode/instructions/INSTRUCTIONS.md +388 -0
- package/template/.opencode/package.json +5 -0
- package/template/.opencode/rules/README.md +82 -0
- package/template/.opencode/rules/android/gradle.md +62 -0
- package/template/.opencode/rules/android/testing.md +27 -0
- package/template/.opencode/rules/common/agents.md +49 -0
- package/template/.opencode/rules/common/coding-style.md +48 -0
- package/template/.opencode/rules/common/git-workflow.md +45 -0
- package/template/.opencode/rules/common/hooks.md +30 -0
- package/template/.opencode/rules/common/patterns.md +31 -0
- package/template/.opencode/rules/common/performance.md +55 -0
- package/template/.opencode/rules/common/security.md +29 -0
- package/template/.opencode/rules/common/testing.md +29 -0
- package/template/.opencode/rules/flutter/state-management.md +57 -0
- package/template/.opencode/rules/flutter/testing.md +42 -0
- package/template/.opencode/rules/golang/coding-style.md +26 -0
- package/template/.opencode/rules/golang/hooks.md +11 -0
- package/template/.opencode/rules/golang/patterns.md +39 -0
- package/template/.opencode/rules/golang/security.md +28 -0
- package/template/.opencode/rules/golang/testing.md +25 -0
- package/template/.opencode/rules/mobile/performance.md +36 -0
- package/template/.opencode/rules/python/coding-style.md +37 -0
- package/template/.opencode/rules/python/hooks.md +14 -0
- package/template/.opencode/rules/python/patterns.md +34 -0
- package/template/.opencode/rules/python/security.md +25 -0
- package/template/.opencode/rules/python/testing.md +33 -0
- package/template/.opencode/rules/typescript/coding-style.md +58 -0
- package/template/.opencode/rules/typescript/hooks.md +15 -0
- package/template/.opencode/rules/typescript/patterns.md +45 -0
- package/template/.opencode/rules/typescript/security.md +21 -0
- package/template/.opencode/rules/typescript/testing.md +11 -0
- package/template/.opencode/skills/api-documentation/SKILL.md +188 -0
- package/template/.opencode/skills/backend-patterns/SKILL.md +587 -0
- package/template/.opencode/skills/building-components/SKILL.md +37 -0
- package/template/.opencode/skills/building-components/references/accessibility.mdx +819 -0
- package/template/.opencode/skills/building-components/references/as-child.mdx +324 -0
- package/template/.opencode/skills/building-components/references/composition.mdx +239 -0
- package/template/.opencode/skills/building-components/references/data-attributes.mdx +413 -0
- package/template/.opencode/skills/building-components/references/definitions.mdx +258 -0
- package/template/.opencode/skills/building-components/references/design-tokens.mdx +57 -0
- package/template/.opencode/skills/building-components/references/docs.mdx +155 -0
- package/template/.opencode/skills/building-components/references/marketplaces.mdx +144 -0
- package/template/.opencode/skills/building-components/references/npm.mdx +166 -0
- package/template/.opencode/skills/building-components/references/polymorphism.mdx +583 -0
- package/template/.opencode/skills/building-components/references/principles.mdx +61 -0
- package/template/.opencode/skills/building-components/references/registry.mdx +169 -0
- package/template/.opencode/skills/building-components/references/state.mdx +99 -0
- package/template/.opencode/skills/building-components/references/styling.mdx +286 -0
- package/template/.opencode/skills/building-components/references/types.mdx +191 -0
- package/template/.opencode/skills/clickhouse-io/SKILL.md +429 -0
- package/template/.opencode/skills/coding-standards/SKILL.md +520 -0
- package/template/.opencode/skills/configure-ecc/SKILL.md +298 -0
- package/template/.opencode/skills/continuous-learning/SKILL.md +110 -0
- package/template/.opencode/skills/continuous-learning/config.json +18 -0
- package/template/.opencode/skills/continuous-learning/evaluate-session.sh +60 -0
- package/template/.opencode/skills/continuous-learning-v2/SKILL.md +284 -0
- package/template/.opencode/skills/continuous-learning-v2/agents/observer.md +137 -0
- package/template/.opencode/skills/continuous-learning-v2/agents/start-observer.sh +134 -0
- package/template/.opencode/skills/continuous-learning-v2/config.json +41 -0
- package/template/.opencode/skills/continuous-learning-v2/hooks/observe.sh +153 -0
- package/template/.opencode/skills/continuous-learning-v2/scripts/instinct-cli.py +489 -0
- package/template/.opencode/skills/continuous-learning-v2/scripts/test_parse_instinct.py +82 -0
- package/template/.opencode/skills/dart-add-unit-test/SKILL.md +122 -0
- package/template/.opencode/skills/dart-build-cli-app/SKILL.md +185 -0
- package/template/.opencode/skills/dart-collect-coverage/SKILL.md +141 -0
- package/template/.opencode/skills/dart-fix-runtime-errors/SKILL.md +166 -0
- package/template/.opencode/skills/dart-generate-test-mocks/SKILL.md +155 -0
- package/template/.opencode/skills/dart-migrate-to-checks-package/SKILL.md +126 -0
- package/template/.opencode/skills/dart-resolve-package-conflicts/SKILL.md +116 -0
- package/template/.opencode/skills/dart-run-static-analysis/SKILL.md +104 -0
- package/template/.opencode/skills/dart-use-pattern-matching/SKILL.md +146 -0
- package/template/.opencode/skills/django-patterns/SKILL.md +733 -0
- package/template/.opencode/skills/django-security/SKILL.md +592 -0
- package/template/.opencode/skills/django-tdd/SKILL.md +728 -0
- package/template/.opencode/skills/django-verification/SKILL.md +460 -0
- package/template/.opencode/skills/eval-harness/SKILL.md +227 -0
- package/template/.opencode/skills/firebase-basics/SKILL.md +103 -0
- package/template/.opencode/skills/firebase-basics/references/additional-skills.md +113 -0
- package/template/.opencode/skills/firebase-basics/references/cli-usage.md +31 -0
- package/template/.opencode/skills/firebase-basics/references/client-library-usage.md +45 -0
- package/template/.opencode/skills/firebase-basics/references/core-concepts.md +61 -0
- package/template/.opencode/skills/firebase-basics/references/iac-usage.md +40 -0
- package/template/.opencode/skills/firebase-basics/references/iam-security.md +74 -0
- package/template/.opencode/skills/firebase-basics/references/mcp-usage.md +63 -0
- package/template/.opencode/skills/flutter/SKILL.md +292 -0
- package/template/.opencode/skills/flutter-add-integration-test/SKILL.md +163 -0
- package/template/.opencode/skills/flutter-add-widget-preview/SKILL.md +145 -0
- package/template/.opencode/skills/flutter-add-widget-test/SKILL.md +154 -0
- package/template/.opencode/skills/flutter-apply-architecture-best-practices/SKILL.md +162 -0
- package/template/.opencode/skills/flutter-build-responsive-layout/SKILL.md +139 -0
- package/template/.opencode/skills/flutter-fix-layout-issues/SKILL.md +130 -0
- package/template/.opencode/skills/flutter-implement-json-serialization/SKILL.md +153 -0
- package/template/.opencode/skills/flutter-setup-declarative-routing/SKILL.md +255 -0
- package/template/.opencode/skills/flutter-setup-localization/SKILL.md +210 -0
- package/template/.opencode/skills/flutter-use-http-package/SKILL.md +174 -0
- package/template/.opencode/skills/frontend-design/SKILL.md +89 -0
- package/template/.opencode/skills/frontend-patterns/SKILL.md +631 -0
- package/template/.opencode/skills/golang-patterns/SKILL.md +673 -0
- package/template/.opencode/skills/golang-testing/SKILL.md +719 -0
- package/template/.opencode/skills/impeccable/SKILL.md +165 -0
- package/template/.opencode/skills/impeccable/agents/impeccable-asset-producer.md +101 -0
- package/template/.opencode/skills/impeccable/reference/adapt.md +190 -0
- package/template/.opencode/skills/impeccable/reference/animate.md +175 -0
- package/template/.opencode/skills/impeccable/reference/audit.md +133 -0
- package/template/.opencode/skills/impeccable/reference/bolder.md +113 -0
- package/template/.opencode/skills/impeccable/reference/brand.md +118 -0
- package/template/.opencode/skills/impeccable/reference/clarify.md +174 -0
- package/template/.opencode/skills/impeccable/reference/codex.md +105 -0
- package/template/.opencode/skills/impeccable/reference/cognitive-load.md +106 -0
- package/template/.opencode/skills/impeccable/reference/color-and-contrast.md +105 -0
- package/template/.opencode/skills/impeccable/reference/colorize.md +154 -0
- package/template/.opencode/skills/impeccable/reference/craft.md +123 -0
- package/template/.opencode/skills/impeccable/reference/critique.md +273 -0
- package/template/.opencode/skills/impeccable/reference/delight.md +302 -0
- package/template/.opencode/skills/impeccable/reference/distill.md +111 -0
- package/template/.opencode/skills/impeccable/reference/document.md +427 -0
- package/template/.opencode/skills/impeccable/reference/extract.md +69 -0
- package/template/.opencode/skills/impeccable/reference/harden.md +347 -0
- package/template/.opencode/skills/impeccable/reference/heuristics-scoring.md +234 -0
- package/template/.opencode/skills/impeccable/reference/interaction-design.md +195 -0
- package/template/.opencode/skills/impeccable/reference/layout.md +141 -0
- package/template/.opencode/skills/impeccable/reference/live.md +622 -0
- package/template/.opencode/skills/impeccable/reference/motion-design.md +109 -0
- package/template/.opencode/skills/impeccable/reference/onboard.md +234 -0
- package/template/.opencode/skills/impeccable/reference/optimize.md +258 -0
- package/template/.opencode/skills/impeccable/reference/overdrive.md +130 -0
- package/template/.opencode/skills/impeccable/reference/personas.md +179 -0
- package/template/.opencode/skills/impeccable/reference/polish.md +242 -0
- package/template/.opencode/skills/impeccable/reference/product.md +62 -0
- package/template/.opencode/skills/impeccable/reference/quieter.md +99 -0
- package/template/.opencode/skills/impeccable/reference/responsive-design.md +114 -0
- package/template/.opencode/skills/impeccable/reference/shape.md +165 -0
- package/template/.opencode/skills/impeccable/reference/spatial-design.md +100 -0
- package/template/.opencode/skills/impeccable/reference/teach.md +156 -0
- package/template/.opencode/skills/impeccable/reference/typeset.md +124 -0
- package/template/.opencode/skills/impeccable/reference/typography.md +159 -0
- package/template/.opencode/skills/impeccable/reference/ux-writing.md +107 -0
- package/template/.opencode/skills/impeccable/scripts/cleanup-deprecated.mjs +284 -0
- package/template/.opencode/skills/impeccable/scripts/command-metadata.json +94 -0
- package/template/.opencode/skills/impeccable/scripts/critique-storage.mjs +242 -0
- package/template/.opencode/skills/impeccable/scripts/design-parser.mjs +820 -0
- package/template/.opencode/skills/impeccable/scripts/detect-csp.mjs +198 -0
- package/template/.opencode/skills/impeccable/scripts/detect.mjs +21 -0
- package/template/.opencode/skills/impeccable/scripts/impeccable-paths.mjs +110 -0
- package/template/.opencode/skills/impeccable/scripts/is-generated.mjs +69 -0
- package/template/.opencode/skills/impeccable/scripts/live-accept.mjs +595 -0
- package/template/.opencode/skills/impeccable/scripts/live-browser-session.js +123 -0
- package/template/.opencode/skills/impeccable/scripts/live-browser.js +4860 -0
- package/template/.opencode/skills/impeccable/scripts/live-complete.mjs +75 -0
- package/template/.opencode/skills/impeccable/scripts/live-completion.mjs +18 -0
- package/template/.opencode/skills/impeccable/scripts/live-inject.mjs +446 -0
- package/template/.opencode/skills/impeccable/scripts/live-poll.mjs +200 -0
- package/template/.opencode/skills/impeccable/scripts/live-resume.mjs +48 -0
- package/template/.opencode/skills/impeccable/scripts/live-server.mjs +838 -0
- package/template/.opencode/skills/impeccable/scripts/live-session-store.mjs +254 -0
- package/template/.opencode/skills/impeccable/scripts/live-status.mjs +47 -0
- package/template/.opencode/skills/impeccable/scripts/live-wrap.mjs +632 -0
- package/template/.opencode/skills/impeccable/scripts/live.mjs +247 -0
- package/template/.opencode/skills/impeccable/scripts/load-context.mjs +141 -0
- package/template/.opencode/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
- package/template/.opencode/skills/impeccable/scripts/pin.mjs +214 -0
- package/template/.opencode/skills/iterative-retrieval/SKILL.md +202 -0
- package/template/.opencode/skills/java-coding-standards/SKILL.md +138 -0
- package/template/.opencode/skills/jetpack-compose/.skillfish.json +10 -0
- package/template/.opencode/skills/jetpack-compose/SKILL.md +420 -0
- package/template/.opencode/skills/jpa-patterns/SKILL.md +141 -0
- package/template/.opencode/skills/nutrient-document-processing/SKILL.md +165 -0
- package/template/.opencode/skills/nuxt-ui/SKILL.md +334 -0
- package/template/.opencode/skills/nuxt-ui/references/components.md +377 -0
- package/template/.opencode/skills/nuxt-ui/references/composables.md +127 -0
- package/template/.opencode/skills/nuxt-ui/references/layouts/chat.md +266 -0
- package/template/.opencode/skills/nuxt-ui/references/layouts/dashboard.md +220 -0
- package/template/.opencode/skills/nuxt-ui/references/layouts/docs.md +141 -0
- package/template/.opencode/skills/nuxt-ui/references/layouts/editor.md +168 -0
- package/template/.opencode/skills/nuxt-ui/references/layouts/page.md +260 -0
- package/template/.opencode/skills/nuxt-ui/references/theming.md +427 -0
- package/template/.opencode/skills/postgres-patterns/SKILL.md +146 -0
- package/template/.opencode/skills/project-guidelines-example/SKILL.md +345 -0
- package/template/.opencode/skills/python-patterns/SKILL.md +749 -0
- package/template/.opencode/skills/python-testing/SKILL.md +815 -0
- package/template/.opencode/skills/security-review/SKILL.md +494 -0
- package/template/.opencode/skills/security-review/cloud-infrastructure-security.md +361 -0
- package/template/.opencode/skills/shadcn-ui/README.md +248 -0
- package/template/.opencode/skills/shadcn-ui/SKILL.md +326 -0
- package/template/.opencode/skills/shadcn-ui/examples/auth-layout.tsx +177 -0
- package/template/.opencode/skills/shadcn-ui/examples/data-table.tsx +313 -0
- package/template/.opencode/skills/shadcn-ui/examples/form-pattern.tsx +177 -0
- package/template/.opencode/skills/shadcn-ui/resources/component-catalog.md +481 -0
- package/template/.opencode/skills/shadcn-ui/resources/customization-guide.md +516 -0
- package/template/.opencode/skills/shadcn-ui/resources/migration-guide.md +463 -0
- package/template/.opencode/skills/shadcn-ui/resources/setup-guide.md +412 -0
- package/template/.opencode/skills/shadcn-ui/scripts/verify-setup.sh +134 -0
- package/template/.opencode/skills/springboot-patterns/SKILL.md +304 -0
- package/template/.opencode/skills/springboot-security/SKILL.md +119 -0
- package/template/.opencode/skills/springboot-tdd/SKILL.md +157 -0
- package/template/.opencode/skills/springboot-verification/SKILL.md +100 -0
- package/template/.opencode/skills/strategic-compact/SKILL.md +63 -0
- package/template/.opencode/skills/strategic-compact/suggest-compact.sh +52 -0
- package/template/.opencode/skills/tdd-workflow/SKILL.md +409 -0
- package/template/.opencode/skills/vercel-composition-patterns/AGENTS.md +946 -0
- package/template/.opencode/skills/vercel-composition-patterns/SKILL.md +89 -0
- package/template/.opencode/skills/vercel-composition-patterns/rules/architecture-avoid-boolean-props.md +100 -0
- package/template/.opencode/skills/vercel-composition-patterns/rules/architecture-compound-components.md +112 -0
- package/template/.opencode/skills/vercel-composition-patterns/rules/patterns-children-over-render-props.md +87 -0
- package/template/.opencode/skills/vercel-composition-patterns/rules/patterns-explicit-variants.md +100 -0
- package/template/.opencode/skills/vercel-composition-patterns/rules/react19-no-forwardref.md +42 -0
- package/template/.opencode/skills/vercel-composition-patterns/rules/state-context-interface.md +191 -0
- package/template/.opencode/skills/vercel-composition-patterns/rules/state-decouple-implementation.md +113 -0
- package/template/.opencode/skills/vercel-composition-patterns/rules/state-lift-state.md +125 -0
- package/template/.opencode/skills/vercel-react-best-practices/AGENTS.md +2934 -0
- package/template/.opencode/skills/vercel-react-best-practices/SKILL.md +136 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/async-defer-await.md +80 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
- package/template/.opencode/skills/verification-loop/SKILL.md +120 -0
- package/template/.opencode/skills/web-design-guidelines/SKILL.md +39 -0
- package/template/AGENTS.md +32 -0
- package/template/opencode.json +354 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Continuous Learning v2 - Observation Hook
|
|
3
|
+
#
|
|
4
|
+
# Captures tool use events for pattern analysis.
|
|
5
|
+
# Claude Code passes hook data via stdin as JSON.
|
|
6
|
+
#
|
|
7
|
+
# Hook config (in ~/.claude/settings.json):
|
|
8
|
+
#
|
|
9
|
+
# If installed as a plugin, use ${CLAUDE_PLUGIN_ROOT}:
|
|
10
|
+
# {
|
|
11
|
+
# "hooks": {
|
|
12
|
+
# "PreToolUse": [{
|
|
13
|
+
# "matcher": "*",
|
|
14
|
+
# "hooks": [{ "type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/skills/continuous-learning-v2/hooks/observe.sh pre" }]
|
|
15
|
+
# }],
|
|
16
|
+
# "PostToolUse": [{
|
|
17
|
+
# "matcher": "*",
|
|
18
|
+
# "hooks": [{ "type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/skills/continuous-learning-v2/hooks/observe.sh post" }]
|
|
19
|
+
# }]
|
|
20
|
+
# }
|
|
21
|
+
# }
|
|
22
|
+
#
|
|
23
|
+
# If installed manually to ~/.claude/skills:
|
|
24
|
+
# {
|
|
25
|
+
# "hooks": {
|
|
26
|
+
# "PreToolUse": [{
|
|
27
|
+
# "matcher": "*",
|
|
28
|
+
# "hooks": [{ "type": "command", "command": "~/.claude/skills/continuous-learning-v2/hooks/observe.sh pre" }]
|
|
29
|
+
# }],
|
|
30
|
+
# "PostToolUse": [{
|
|
31
|
+
# "matcher": "*",
|
|
32
|
+
# "hooks": [{ "type": "command", "command": "~/.claude/skills/continuous-learning-v2/hooks/observe.sh post" }]
|
|
33
|
+
# }]
|
|
34
|
+
# }
|
|
35
|
+
# }
|
|
36
|
+
|
|
37
|
+
set -e
|
|
38
|
+
|
|
39
|
+
CONFIG_DIR="${HOME}/.claude/homunculus"
|
|
40
|
+
OBSERVATIONS_FILE="${CONFIG_DIR}/observations.jsonl"
|
|
41
|
+
MAX_FILE_SIZE_MB=10
|
|
42
|
+
|
|
43
|
+
# Ensure directory exists
|
|
44
|
+
mkdir -p "$CONFIG_DIR"
|
|
45
|
+
|
|
46
|
+
# Skip if disabled
|
|
47
|
+
if [ -f "$CONFIG_DIR/disabled" ]; then
|
|
48
|
+
exit 0
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
# Read JSON from stdin (Claude Code hook format)
|
|
52
|
+
INPUT_JSON=$(cat)
|
|
53
|
+
|
|
54
|
+
# Exit if no input
|
|
55
|
+
if [ -z "$INPUT_JSON" ]; then
|
|
56
|
+
exit 0
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
# Parse using python (more reliable than jq for complex JSON)
|
|
60
|
+
PARSED=$(python3 << EOF
|
|
61
|
+
import json
|
|
62
|
+
import sys
|
|
63
|
+
|
|
64
|
+
try:
|
|
65
|
+
data = json.loads('''$INPUT_JSON''')
|
|
66
|
+
|
|
67
|
+
# Extract fields - Claude Code hook format
|
|
68
|
+
hook_type = data.get('hook_type', 'unknown') # PreToolUse or PostToolUse
|
|
69
|
+
tool_name = data.get('tool_name', data.get('tool', 'unknown'))
|
|
70
|
+
tool_input = data.get('tool_input', data.get('input', {}))
|
|
71
|
+
tool_output = data.get('tool_output', data.get('output', ''))
|
|
72
|
+
session_id = data.get('session_id', 'unknown')
|
|
73
|
+
|
|
74
|
+
# Truncate large inputs/outputs
|
|
75
|
+
if isinstance(tool_input, dict):
|
|
76
|
+
tool_input_str = json.dumps(tool_input)[:5000]
|
|
77
|
+
else:
|
|
78
|
+
tool_input_str = str(tool_input)[:5000]
|
|
79
|
+
|
|
80
|
+
if isinstance(tool_output, dict):
|
|
81
|
+
tool_output_str = json.dumps(tool_output)[:5000]
|
|
82
|
+
else:
|
|
83
|
+
tool_output_str = str(tool_output)[:5000]
|
|
84
|
+
|
|
85
|
+
# Determine event type
|
|
86
|
+
event = 'tool_start' if 'Pre' in hook_type else 'tool_complete'
|
|
87
|
+
|
|
88
|
+
print(json.dumps({
|
|
89
|
+
'parsed': True,
|
|
90
|
+
'event': event,
|
|
91
|
+
'tool': tool_name,
|
|
92
|
+
'input': tool_input_str if event == 'tool_start' else None,
|
|
93
|
+
'output': tool_output_str if event == 'tool_complete' else None,
|
|
94
|
+
'session': session_id
|
|
95
|
+
}))
|
|
96
|
+
except Exception as e:
|
|
97
|
+
print(json.dumps({'parsed': False, 'error': str(e)}))
|
|
98
|
+
EOF
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
# Check if parsing succeeded
|
|
102
|
+
PARSED_OK=$(echo "$PARSED" | python3 -c "import json,sys; print(json.load(sys.stdin).get('parsed', False))")
|
|
103
|
+
|
|
104
|
+
if [ "$PARSED_OK" != "True" ]; then
|
|
105
|
+
# Fallback: log raw input for debugging
|
|
106
|
+
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
107
|
+
echo "{\"timestamp\":\"$timestamp\",\"event\":\"parse_error\",\"raw\":$(echo "$INPUT_JSON" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()[:1000]))')}" >> "$OBSERVATIONS_FILE"
|
|
108
|
+
exit 0
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
# Archive if file too large
|
|
112
|
+
if [ -f "$OBSERVATIONS_FILE" ]; then
|
|
113
|
+
file_size_mb=$(du -m "$OBSERVATIONS_FILE" 2>/dev/null | cut -f1)
|
|
114
|
+
if [ "${file_size_mb:-0}" -ge "$MAX_FILE_SIZE_MB" ]; then
|
|
115
|
+
archive_dir="${CONFIG_DIR}/observations.archive"
|
|
116
|
+
mkdir -p "$archive_dir"
|
|
117
|
+
mv "$OBSERVATIONS_FILE" "$archive_dir/observations-$(date +%Y%m%d-%H%M%S).jsonl"
|
|
118
|
+
fi
|
|
119
|
+
fi
|
|
120
|
+
|
|
121
|
+
# Build and write observation
|
|
122
|
+
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
123
|
+
|
|
124
|
+
python3 << EOF
|
|
125
|
+
import json
|
|
126
|
+
|
|
127
|
+
parsed = json.loads('''$PARSED''')
|
|
128
|
+
observation = {
|
|
129
|
+
'timestamp': '$timestamp',
|
|
130
|
+
'event': parsed['event'],
|
|
131
|
+
'tool': parsed['tool'],
|
|
132
|
+
'session': parsed['session']
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if parsed['input']:
|
|
136
|
+
observation['input'] = parsed['input']
|
|
137
|
+
if parsed['output']:
|
|
138
|
+
observation['output'] = parsed['output']
|
|
139
|
+
|
|
140
|
+
with open('$OBSERVATIONS_FILE', 'a') as f:
|
|
141
|
+
f.write(json.dumps(observation) + '\n')
|
|
142
|
+
EOF
|
|
143
|
+
|
|
144
|
+
# Signal observer if running
|
|
145
|
+
OBSERVER_PID_FILE="${CONFIG_DIR}/.observer.pid"
|
|
146
|
+
if [ -f "$OBSERVER_PID_FILE" ]; then
|
|
147
|
+
observer_pid=$(cat "$OBSERVER_PID_FILE")
|
|
148
|
+
if kill -0 "$observer_pid" 2>/dev/null; then
|
|
149
|
+
kill -USR1 "$observer_pid" 2>/dev/null || true
|
|
150
|
+
fi
|
|
151
|
+
fi
|
|
152
|
+
|
|
153
|
+
exit 0
|
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Instinct CLI - Manage instincts for Continuous Learning v2
|
|
4
|
+
|
|
5
|
+
Commands:
|
|
6
|
+
status - Show all instincts and their status
|
|
7
|
+
import - Import instincts from file or URL
|
|
8
|
+
export - Export instincts to file
|
|
9
|
+
evolve - Cluster instincts into skills/commands/agents
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import argparse
|
|
13
|
+
import json
|
|
14
|
+
import os
|
|
15
|
+
import sys
|
|
16
|
+
import re
|
|
17
|
+
import urllib.request
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
from datetime import datetime
|
|
20
|
+
from collections import defaultdict
|
|
21
|
+
from typing import Optional
|
|
22
|
+
|
|
23
|
+
# ─────────────────────────────────────────────
|
|
24
|
+
# Configuration
|
|
25
|
+
# ─────────────────────────────────────────────
|
|
26
|
+
|
|
27
|
+
HOMUNCULUS_DIR = Path.home() / ".claude" / "homunculus"
|
|
28
|
+
INSTINCTS_DIR = HOMUNCULUS_DIR / "instincts"
|
|
29
|
+
PERSONAL_DIR = INSTINCTS_DIR / "personal"
|
|
30
|
+
INHERITED_DIR = INSTINCTS_DIR / "inherited"
|
|
31
|
+
EVOLVED_DIR = HOMUNCULUS_DIR / "evolved"
|
|
32
|
+
OBSERVATIONS_FILE = HOMUNCULUS_DIR / "observations.jsonl"
|
|
33
|
+
|
|
34
|
+
# Ensure directories exist
|
|
35
|
+
for d in [PERSONAL_DIR, INHERITED_DIR, EVOLVED_DIR / "skills", EVOLVED_DIR / "commands", EVOLVED_DIR / "agents"]:
|
|
36
|
+
d.mkdir(parents=True, exist_ok=True)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# ─────────────────────────────────────────────
|
|
40
|
+
# Instinct Parser
|
|
41
|
+
# ─────────────────────────────────────────────
|
|
42
|
+
|
|
43
|
+
def parse_instinct_file(content: str) -> list[dict]:
|
|
44
|
+
"""Parse YAML-like instinct file format."""
|
|
45
|
+
instincts = []
|
|
46
|
+
current = {}
|
|
47
|
+
in_frontmatter = False
|
|
48
|
+
content_lines = []
|
|
49
|
+
|
|
50
|
+
for line in content.split('\n'):
|
|
51
|
+
if line.strip() == '---':
|
|
52
|
+
if in_frontmatter:
|
|
53
|
+
# End of frontmatter - content comes next, don't append yet
|
|
54
|
+
in_frontmatter = False
|
|
55
|
+
else:
|
|
56
|
+
# Start of frontmatter
|
|
57
|
+
in_frontmatter = True
|
|
58
|
+
if current:
|
|
59
|
+
current['content'] = '\n'.join(content_lines).strip()
|
|
60
|
+
instincts.append(current)
|
|
61
|
+
current = {}
|
|
62
|
+
content_lines = []
|
|
63
|
+
elif in_frontmatter:
|
|
64
|
+
# Parse YAML-like frontmatter
|
|
65
|
+
if ':' in line:
|
|
66
|
+
key, value = line.split(':', 1)
|
|
67
|
+
key = key.strip()
|
|
68
|
+
value = value.strip().strip('"').strip("'")
|
|
69
|
+
if key == 'confidence':
|
|
70
|
+
current[key] = float(value)
|
|
71
|
+
else:
|
|
72
|
+
current[key] = value
|
|
73
|
+
else:
|
|
74
|
+
content_lines.append(line)
|
|
75
|
+
|
|
76
|
+
# Don't forget the last instinct
|
|
77
|
+
if current:
|
|
78
|
+
current['content'] = '\n'.join(content_lines).strip()
|
|
79
|
+
instincts.append(current)
|
|
80
|
+
|
|
81
|
+
return [i for i in instincts if i.get('id')]
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def load_all_instincts() -> list[dict]:
|
|
85
|
+
"""Load all instincts from personal and inherited directories."""
|
|
86
|
+
instincts = []
|
|
87
|
+
|
|
88
|
+
for directory in [PERSONAL_DIR, INHERITED_DIR]:
|
|
89
|
+
if not directory.exists():
|
|
90
|
+
continue
|
|
91
|
+
for file in directory.glob("*.yaml"):
|
|
92
|
+
try:
|
|
93
|
+
content = file.read_text()
|
|
94
|
+
parsed = parse_instinct_file(content)
|
|
95
|
+
for inst in parsed:
|
|
96
|
+
inst['_source_file'] = str(file)
|
|
97
|
+
inst['_source_type'] = directory.name
|
|
98
|
+
instincts.extend(parsed)
|
|
99
|
+
except Exception as e:
|
|
100
|
+
print(f"Warning: Failed to parse {file}: {e}", file=sys.stderr)
|
|
101
|
+
|
|
102
|
+
return instincts
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
# ─────────────────────────────────────────────
|
|
106
|
+
# Status Command
|
|
107
|
+
# ─────────────────────────────────────────────
|
|
108
|
+
|
|
109
|
+
def cmd_status(args):
|
|
110
|
+
"""Show status of all instincts."""
|
|
111
|
+
instincts = load_all_instincts()
|
|
112
|
+
|
|
113
|
+
if not instincts:
|
|
114
|
+
print("No instincts found.")
|
|
115
|
+
print(f"\nInstinct directories:")
|
|
116
|
+
print(f" Personal: {PERSONAL_DIR}")
|
|
117
|
+
print(f" Inherited: {INHERITED_DIR}")
|
|
118
|
+
return
|
|
119
|
+
|
|
120
|
+
# Group by domain
|
|
121
|
+
by_domain = defaultdict(list)
|
|
122
|
+
for inst in instincts:
|
|
123
|
+
domain = inst.get('domain', 'general')
|
|
124
|
+
by_domain[domain].append(inst)
|
|
125
|
+
|
|
126
|
+
# Print header
|
|
127
|
+
print(f"\n{'='*60}")
|
|
128
|
+
print(f" INSTINCT STATUS - {len(instincts)} total")
|
|
129
|
+
print(f"{'='*60}\n")
|
|
130
|
+
|
|
131
|
+
# Summary by source
|
|
132
|
+
personal = [i for i in instincts if i.get('_source_type') == 'personal']
|
|
133
|
+
inherited = [i for i in instincts if i.get('_source_type') == 'inherited']
|
|
134
|
+
print(f" Personal: {len(personal)}")
|
|
135
|
+
print(f" Inherited: {len(inherited)}")
|
|
136
|
+
print()
|
|
137
|
+
|
|
138
|
+
# Print by domain
|
|
139
|
+
for domain in sorted(by_domain.keys()):
|
|
140
|
+
domain_instincts = by_domain[domain]
|
|
141
|
+
print(f"## {domain.upper()} ({len(domain_instincts)})")
|
|
142
|
+
print()
|
|
143
|
+
|
|
144
|
+
for inst in sorted(domain_instincts, key=lambda x: -x.get('confidence', 0.5)):
|
|
145
|
+
conf = inst.get('confidence', 0.5)
|
|
146
|
+
conf_bar = '█' * int(conf * 10) + '░' * (10 - int(conf * 10))
|
|
147
|
+
trigger = inst.get('trigger', 'unknown trigger')
|
|
148
|
+
source = inst.get('source', 'unknown')
|
|
149
|
+
|
|
150
|
+
print(f" {conf_bar} {int(conf*100):3d}% {inst.get('id', 'unnamed')}")
|
|
151
|
+
print(f" trigger: {trigger}")
|
|
152
|
+
|
|
153
|
+
# Extract action from content
|
|
154
|
+
content = inst.get('content', '')
|
|
155
|
+
action_match = re.search(r'## Action\s*\n\s*(.+?)(?:\n\n|\n##|$)', content, re.DOTALL)
|
|
156
|
+
if action_match:
|
|
157
|
+
action = action_match.group(1).strip().split('\n')[0]
|
|
158
|
+
print(f" action: {action[:60]}{'...' if len(action) > 60 else ''}")
|
|
159
|
+
|
|
160
|
+
print()
|
|
161
|
+
|
|
162
|
+
# Observations stats
|
|
163
|
+
if OBSERVATIONS_FILE.exists():
|
|
164
|
+
obs_count = sum(1 for _ in open(OBSERVATIONS_FILE))
|
|
165
|
+
print(f"─────────────────────────────────────────────────────────")
|
|
166
|
+
print(f" Observations: {obs_count} events logged")
|
|
167
|
+
print(f" File: {OBSERVATIONS_FILE}")
|
|
168
|
+
|
|
169
|
+
print(f"\n{'='*60}\n")
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
# ─────────────────────────────────────────────
|
|
173
|
+
# Import Command
|
|
174
|
+
# ─────────────────────────────────────────────
|
|
175
|
+
|
|
176
|
+
def cmd_import(args):
|
|
177
|
+
"""Import instincts from file or URL."""
|
|
178
|
+
source = args.source
|
|
179
|
+
|
|
180
|
+
# Fetch content
|
|
181
|
+
if source.startswith('http://') or source.startswith('https://'):
|
|
182
|
+
print(f"Fetching from URL: {source}")
|
|
183
|
+
try:
|
|
184
|
+
with urllib.request.urlopen(source) as response:
|
|
185
|
+
content = response.read().decode('utf-8')
|
|
186
|
+
except Exception as e:
|
|
187
|
+
print(f"Error fetching URL: {e}", file=sys.stderr)
|
|
188
|
+
return 1
|
|
189
|
+
else:
|
|
190
|
+
path = Path(source).expanduser()
|
|
191
|
+
if not path.exists():
|
|
192
|
+
print(f"File not found: {path}", file=sys.stderr)
|
|
193
|
+
return 1
|
|
194
|
+
content = path.read_text()
|
|
195
|
+
|
|
196
|
+
# Parse instincts
|
|
197
|
+
new_instincts = parse_instinct_file(content)
|
|
198
|
+
if not new_instincts:
|
|
199
|
+
print("No valid instincts found in source.")
|
|
200
|
+
return 1
|
|
201
|
+
|
|
202
|
+
print(f"\nFound {len(new_instincts)} instincts to import.\n")
|
|
203
|
+
|
|
204
|
+
# Load existing
|
|
205
|
+
existing = load_all_instincts()
|
|
206
|
+
existing_ids = {i.get('id') for i in existing}
|
|
207
|
+
|
|
208
|
+
# Categorize
|
|
209
|
+
to_add = []
|
|
210
|
+
duplicates = []
|
|
211
|
+
to_update = []
|
|
212
|
+
|
|
213
|
+
for inst in new_instincts:
|
|
214
|
+
inst_id = inst.get('id')
|
|
215
|
+
if inst_id in existing_ids:
|
|
216
|
+
# Check if we should update
|
|
217
|
+
existing_inst = next((e for e in existing if e.get('id') == inst_id), None)
|
|
218
|
+
if existing_inst:
|
|
219
|
+
if inst.get('confidence', 0) > existing_inst.get('confidence', 0):
|
|
220
|
+
to_update.append(inst)
|
|
221
|
+
else:
|
|
222
|
+
duplicates.append(inst)
|
|
223
|
+
else:
|
|
224
|
+
to_add.append(inst)
|
|
225
|
+
|
|
226
|
+
# Filter by minimum confidence
|
|
227
|
+
min_conf = args.min_confidence or 0.0
|
|
228
|
+
to_add = [i for i in to_add if i.get('confidence', 0.5) >= min_conf]
|
|
229
|
+
to_update = [i for i in to_update if i.get('confidence', 0.5) >= min_conf]
|
|
230
|
+
|
|
231
|
+
# Display summary
|
|
232
|
+
if to_add:
|
|
233
|
+
print(f"NEW ({len(to_add)}):")
|
|
234
|
+
for inst in to_add:
|
|
235
|
+
print(f" + {inst.get('id')} (confidence: {inst.get('confidence', 0.5):.2f})")
|
|
236
|
+
|
|
237
|
+
if to_update:
|
|
238
|
+
print(f"\nUPDATE ({len(to_update)}):")
|
|
239
|
+
for inst in to_update:
|
|
240
|
+
print(f" ~ {inst.get('id')} (confidence: {inst.get('confidence', 0.5):.2f})")
|
|
241
|
+
|
|
242
|
+
if duplicates:
|
|
243
|
+
print(f"\nSKIP ({len(duplicates)} - already exists with equal/higher confidence):")
|
|
244
|
+
for inst in duplicates[:5]:
|
|
245
|
+
print(f" - {inst.get('id')}")
|
|
246
|
+
if len(duplicates) > 5:
|
|
247
|
+
print(f" ... and {len(duplicates) - 5} more")
|
|
248
|
+
|
|
249
|
+
if args.dry_run:
|
|
250
|
+
print("\n[DRY RUN] No changes made.")
|
|
251
|
+
return 0
|
|
252
|
+
|
|
253
|
+
if not to_add and not to_update:
|
|
254
|
+
print("\nNothing to import.")
|
|
255
|
+
return 0
|
|
256
|
+
|
|
257
|
+
# Confirm
|
|
258
|
+
if not args.force:
|
|
259
|
+
response = input(f"\nImport {len(to_add)} new, update {len(to_update)}? [y/N] ")
|
|
260
|
+
if response.lower() != 'y':
|
|
261
|
+
print("Cancelled.")
|
|
262
|
+
return 0
|
|
263
|
+
|
|
264
|
+
# Write to inherited directory
|
|
265
|
+
timestamp = datetime.now().strftime('%Y%m%d-%H%M%S')
|
|
266
|
+
source_name = Path(source).stem if not source.startswith('http') else 'web-import'
|
|
267
|
+
output_file = INHERITED_DIR / f"{source_name}-{timestamp}.yaml"
|
|
268
|
+
|
|
269
|
+
all_to_write = to_add + to_update
|
|
270
|
+
output_content = f"# Imported from {source}\n# Date: {datetime.now().isoformat()}\n\n"
|
|
271
|
+
|
|
272
|
+
for inst in all_to_write:
|
|
273
|
+
output_content += "---\n"
|
|
274
|
+
output_content += f"id: {inst.get('id')}\n"
|
|
275
|
+
output_content += f"trigger: \"{inst.get('trigger', 'unknown')}\"\n"
|
|
276
|
+
output_content += f"confidence: {inst.get('confidence', 0.5)}\n"
|
|
277
|
+
output_content += f"domain: {inst.get('domain', 'general')}\n"
|
|
278
|
+
output_content += f"source: inherited\n"
|
|
279
|
+
output_content += f"imported_from: \"{source}\"\n"
|
|
280
|
+
if inst.get('source_repo'):
|
|
281
|
+
output_content += f"source_repo: {inst.get('source_repo')}\n"
|
|
282
|
+
output_content += "---\n\n"
|
|
283
|
+
output_content += inst.get('content', '') + "\n\n"
|
|
284
|
+
|
|
285
|
+
output_file.write_text(output_content)
|
|
286
|
+
|
|
287
|
+
print(f"\n✅ Import complete!")
|
|
288
|
+
print(f" Added: {len(to_add)}")
|
|
289
|
+
print(f" Updated: {len(to_update)}")
|
|
290
|
+
print(f" Saved to: {output_file}")
|
|
291
|
+
|
|
292
|
+
return 0
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
# ─────────────────────────────────────────────
|
|
296
|
+
# Export Command
|
|
297
|
+
# ─────────────────────────────────────────────
|
|
298
|
+
|
|
299
|
+
def cmd_export(args):
|
|
300
|
+
"""Export instincts to file."""
|
|
301
|
+
instincts = load_all_instincts()
|
|
302
|
+
|
|
303
|
+
if not instincts:
|
|
304
|
+
print("No instincts to export.")
|
|
305
|
+
return 1
|
|
306
|
+
|
|
307
|
+
# Filter by domain if specified
|
|
308
|
+
if args.domain:
|
|
309
|
+
instincts = [i for i in instincts if i.get('domain') == args.domain]
|
|
310
|
+
|
|
311
|
+
# Filter by minimum confidence
|
|
312
|
+
if args.min_confidence:
|
|
313
|
+
instincts = [i for i in instincts if i.get('confidence', 0.5) >= args.min_confidence]
|
|
314
|
+
|
|
315
|
+
if not instincts:
|
|
316
|
+
print("No instincts match the criteria.")
|
|
317
|
+
return 1
|
|
318
|
+
|
|
319
|
+
# Generate output
|
|
320
|
+
output = f"# Instincts export\n# Date: {datetime.now().isoformat()}\n# Total: {len(instincts)}\n\n"
|
|
321
|
+
|
|
322
|
+
for inst in instincts:
|
|
323
|
+
output += "---\n"
|
|
324
|
+
for key in ['id', 'trigger', 'confidence', 'domain', 'source', 'source_repo']:
|
|
325
|
+
if inst.get(key):
|
|
326
|
+
value = inst[key]
|
|
327
|
+
if key == 'trigger':
|
|
328
|
+
output += f'{key}: "{value}"\n'
|
|
329
|
+
else:
|
|
330
|
+
output += f"{key}: {value}\n"
|
|
331
|
+
output += "---\n\n"
|
|
332
|
+
output += inst.get('content', '') + "\n\n"
|
|
333
|
+
|
|
334
|
+
# Write to file or stdout
|
|
335
|
+
if args.output:
|
|
336
|
+
Path(args.output).write_text(output)
|
|
337
|
+
print(f"Exported {len(instincts)} instincts to {args.output}")
|
|
338
|
+
else:
|
|
339
|
+
print(output)
|
|
340
|
+
|
|
341
|
+
return 0
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
# ─────────────────────────────────────────────
|
|
345
|
+
# Evolve Command
|
|
346
|
+
# ─────────────────────────────────────────────
|
|
347
|
+
|
|
348
|
+
def cmd_evolve(args):
|
|
349
|
+
"""Analyze instincts and suggest evolutions to skills/commands/agents."""
|
|
350
|
+
instincts = load_all_instincts()
|
|
351
|
+
|
|
352
|
+
if len(instincts) < 3:
|
|
353
|
+
print("Need at least 3 instincts to analyze patterns.")
|
|
354
|
+
print(f"Currently have: {len(instincts)}")
|
|
355
|
+
return 1
|
|
356
|
+
|
|
357
|
+
print(f"\n{'='*60}")
|
|
358
|
+
print(f" EVOLVE ANALYSIS - {len(instincts)} instincts")
|
|
359
|
+
print(f"{'='*60}\n")
|
|
360
|
+
|
|
361
|
+
# Group by domain
|
|
362
|
+
by_domain = defaultdict(list)
|
|
363
|
+
for inst in instincts:
|
|
364
|
+
domain = inst.get('domain', 'general')
|
|
365
|
+
by_domain[domain].append(inst)
|
|
366
|
+
|
|
367
|
+
# High-confidence instincts by domain (candidates for skills)
|
|
368
|
+
high_conf = [i for i in instincts if i.get('confidence', 0) >= 0.8]
|
|
369
|
+
print(f"High confidence instincts (>=80%): {len(high_conf)}")
|
|
370
|
+
|
|
371
|
+
# Find clusters (instincts with similar triggers)
|
|
372
|
+
trigger_clusters = defaultdict(list)
|
|
373
|
+
for inst in instincts:
|
|
374
|
+
trigger = inst.get('trigger', '')
|
|
375
|
+
# Normalize trigger
|
|
376
|
+
trigger_key = trigger.lower()
|
|
377
|
+
for keyword in ['when', 'creating', 'writing', 'adding', 'implementing', 'testing']:
|
|
378
|
+
trigger_key = trigger_key.replace(keyword, '').strip()
|
|
379
|
+
trigger_clusters[trigger_key].append(inst)
|
|
380
|
+
|
|
381
|
+
# Find clusters with 3+ instincts (good skill candidates)
|
|
382
|
+
skill_candidates = []
|
|
383
|
+
for trigger, cluster in trigger_clusters.items():
|
|
384
|
+
if len(cluster) >= 2:
|
|
385
|
+
avg_conf = sum(i.get('confidence', 0.5) for i in cluster) / len(cluster)
|
|
386
|
+
skill_candidates.append({
|
|
387
|
+
'trigger': trigger,
|
|
388
|
+
'instincts': cluster,
|
|
389
|
+
'avg_confidence': avg_conf,
|
|
390
|
+
'domains': list(set(i.get('domain', 'general') for i in cluster))
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
# Sort by cluster size and confidence
|
|
394
|
+
skill_candidates.sort(key=lambda x: (-len(x['instincts']), -x['avg_confidence']))
|
|
395
|
+
|
|
396
|
+
print(f"\nPotential skill clusters found: {len(skill_candidates)}")
|
|
397
|
+
|
|
398
|
+
if skill_candidates:
|
|
399
|
+
print(f"\n## SKILL CANDIDATES\n")
|
|
400
|
+
for i, cand in enumerate(skill_candidates[:5], 1):
|
|
401
|
+
print(f"{i}. Cluster: \"{cand['trigger']}\"")
|
|
402
|
+
print(f" Instincts: {len(cand['instincts'])}")
|
|
403
|
+
print(f" Avg confidence: {cand['avg_confidence']:.0%}")
|
|
404
|
+
print(f" Domains: {', '.join(cand['domains'])}")
|
|
405
|
+
print(f" Instincts:")
|
|
406
|
+
for inst in cand['instincts'][:3]:
|
|
407
|
+
print(f" - {inst.get('id')}")
|
|
408
|
+
print()
|
|
409
|
+
|
|
410
|
+
# Command candidates (workflow instincts with high confidence)
|
|
411
|
+
workflow_instincts = [i for i in instincts if i.get('domain') == 'workflow' and i.get('confidence', 0) >= 0.7]
|
|
412
|
+
if workflow_instincts:
|
|
413
|
+
print(f"\n## COMMAND CANDIDATES ({len(workflow_instincts)})\n")
|
|
414
|
+
for inst in workflow_instincts[:5]:
|
|
415
|
+
trigger = inst.get('trigger', 'unknown')
|
|
416
|
+
# Suggest command name
|
|
417
|
+
cmd_name = trigger.replace('when ', '').replace('implementing ', '').replace('a ', '')
|
|
418
|
+
cmd_name = cmd_name.replace(' ', '-')[:20]
|
|
419
|
+
print(f" /{cmd_name}")
|
|
420
|
+
print(f" From: {inst.get('id')}")
|
|
421
|
+
print(f" Confidence: {inst.get('confidence', 0.5):.0%}")
|
|
422
|
+
print()
|
|
423
|
+
|
|
424
|
+
# Agent candidates (complex multi-step patterns)
|
|
425
|
+
agent_candidates = [c for c in skill_candidates if len(c['instincts']) >= 3 and c['avg_confidence'] >= 0.75]
|
|
426
|
+
if agent_candidates:
|
|
427
|
+
print(f"\n## AGENT CANDIDATES ({len(agent_candidates)})\n")
|
|
428
|
+
for cand in agent_candidates[:3]:
|
|
429
|
+
agent_name = cand['trigger'].replace(' ', '-')[:20] + '-agent'
|
|
430
|
+
print(f" {agent_name}")
|
|
431
|
+
print(f" Covers {len(cand['instincts'])} instincts")
|
|
432
|
+
print(f" Avg confidence: {cand['avg_confidence']:.0%}")
|
|
433
|
+
print()
|
|
434
|
+
|
|
435
|
+
if args.generate:
|
|
436
|
+
print("\n[Would generate evolved structures here]")
|
|
437
|
+
print(" Skills would be saved to:", EVOLVED_DIR / "skills")
|
|
438
|
+
print(" Commands would be saved to:", EVOLVED_DIR / "commands")
|
|
439
|
+
print(" Agents would be saved to:", EVOLVED_DIR / "agents")
|
|
440
|
+
|
|
441
|
+
print(f"\n{'='*60}\n")
|
|
442
|
+
return 0
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
# ─────────────────────────────────────────────
|
|
446
|
+
# Main
|
|
447
|
+
# ─────────────────────────────────────────────
|
|
448
|
+
|
|
449
|
+
def main():
|
|
450
|
+
parser = argparse.ArgumentParser(description='Instinct CLI for Continuous Learning v2')
|
|
451
|
+
subparsers = parser.add_subparsers(dest='command', help='Available commands')
|
|
452
|
+
|
|
453
|
+
# Status
|
|
454
|
+
status_parser = subparsers.add_parser('status', help='Show instinct status')
|
|
455
|
+
|
|
456
|
+
# Import
|
|
457
|
+
import_parser = subparsers.add_parser('import', help='Import instincts')
|
|
458
|
+
import_parser.add_argument('source', help='File path or URL')
|
|
459
|
+
import_parser.add_argument('--dry-run', action='store_true', help='Preview without importing')
|
|
460
|
+
import_parser.add_argument('--force', action='store_true', help='Skip confirmation')
|
|
461
|
+
import_parser.add_argument('--min-confidence', type=float, help='Minimum confidence threshold')
|
|
462
|
+
|
|
463
|
+
# Export
|
|
464
|
+
export_parser = subparsers.add_parser('export', help='Export instincts')
|
|
465
|
+
export_parser.add_argument('--output', '-o', help='Output file')
|
|
466
|
+
export_parser.add_argument('--domain', help='Filter by domain')
|
|
467
|
+
export_parser.add_argument('--min-confidence', type=float, help='Minimum confidence')
|
|
468
|
+
|
|
469
|
+
# Evolve
|
|
470
|
+
evolve_parser = subparsers.add_parser('evolve', help='Analyze and evolve instincts')
|
|
471
|
+
evolve_parser.add_argument('--generate', action='store_true', help='Generate evolved structures')
|
|
472
|
+
|
|
473
|
+
args = parser.parse_args()
|
|
474
|
+
|
|
475
|
+
if args.command == 'status':
|
|
476
|
+
return cmd_status(args)
|
|
477
|
+
elif args.command == 'import':
|
|
478
|
+
return cmd_import(args)
|
|
479
|
+
elif args.command == 'export':
|
|
480
|
+
return cmd_export(args)
|
|
481
|
+
elif args.command == 'evolve':
|
|
482
|
+
return cmd_evolve(args)
|
|
483
|
+
else:
|
|
484
|
+
parser.print_help()
|
|
485
|
+
return 1
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
if __name__ == '__main__':
|
|
489
|
+
sys.exit(main() or 0)
|