compound-engineering-pi 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +124 -0
- package/bin/compound-engineering-pi +12 -0
- package/bin/compound-plugin +12 -0
- package/compound-engineering-pi +12 -0
- package/compound-plugin +5 -0
- package/docs/pi.md +152 -0
- package/extensions/compound-engineering-compat.ts +452 -0
- package/package.json +84 -0
- package/pi-resources/compound-engineering/mcporter.json +7 -0
- package/plugins/coding-tutor/.claude-plugin/plugin.json +9 -0
- package/plugins/coding-tutor/README.md +37 -0
- package/plugins/coding-tutor/commands/quiz-me.md +1 -0
- package/plugins/coding-tutor/commands/sync-tutorials.md +25 -0
- package/plugins/coding-tutor/commands/teach-me.md +1 -0
- package/plugins/coding-tutor/skills/coding-tutor/SKILL.md +214 -0
- package/plugins/coding-tutor/skills/coding-tutor/scripts/create_tutorial.py +207 -0
- package/plugins/coding-tutor/skills/coding-tutor/scripts/index_tutorials.py +193 -0
- package/plugins/coding-tutor/skills/coding-tutor/scripts/quiz_priority.py +190 -0
- package/plugins/coding-tutor/skills/coding-tutor/scripts/setup_tutorials.py +118 -0
- package/plugins/compound-engineering/.claude-plugin/plugin.json +33 -0
- package/plugins/compound-engineering/CHANGELOG.md +457 -0
- package/plugins/compound-engineering/CLAUDE.md +89 -0
- package/plugins/compound-engineering/LICENSE +21 -0
- package/plugins/compound-engineering/README.md +232 -0
- package/plugins/compound-engineering/agents/design/design-implementation-reviewer.md +109 -0
- package/plugins/compound-engineering/agents/design/design-iterator.md +224 -0
- package/plugins/compound-engineering/agents/design/figma-design-sync.md +190 -0
- package/plugins/compound-engineering/agents/docs/ankane-readme-writer.md +65 -0
- package/plugins/compound-engineering/agents/research/best-practices-researcher.md +126 -0
- package/plugins/compound-engineering/agents/research/framework-docs-researcher.md +106 -0
- package/plugins/compound-engineering/agents/research/git-history-analyzer.md +59 -0
- package/plugins/compound-engineering/agents/research/learnings-researcher.md +264 -0
- package/plugins/compound-engineering/agents/research/repo-research-analyst.md +135 -0
- package/plugins/compound-engineering/agents/review/agent-native-reviewer.md +261 -0
- package/plugins/compound-engineering/agents/review/architecture-strategist.md +67 -0
- package/plugins/compound-engineering/agents/review/code-simplicity-reviewer.md +101 -0
- package/plugins/compound-engineering/agents/review/data-integrity-guardian.md +85 -0
- package/plugins/compound-engineering/agents/review/data-migration-expert.md +112 -0
- package/plugins/compound-engineering/agents/review/deployment-verification-agent.md +174 -0
- package/plugins/compound-engineering/agents/review/dhh-rails-reviewer.md +66 -0
- package/plugins/compound-engineering/agents/review/julik-frontend-races-reviewer.md +221 -0
- package/plugins/compound-engineering/agents/review/kieran-python-reviewer.md +133 -0
- package/plugins/compound-engineering/agents/review/kieran-rails-reviewer.md +115 -0
- package/plugins/compound-engineering/agents/review/kieran-typescript-reviewer.md +124 -0
- package/plugins/compound-engineering/agents/review/pattern-recognition-specialist.md +72 -0
- package/plugins/compound-engineering/agents/review/performance-oracle.md +137 -0
- package/plugins/compound-engineering/agents/review/schema-drift-detector.md +154 -0
- package/plugins/compound-engineering/agents/review/security-sentinel.md +114 -0
- package/plugins/compound-engineering/agents/workflow/bug-reproduction-validator.md +82 -0
- package/plugins/compound-engineering/agents/workflow/every-style-editor.md +64 -0
- package/plugins/compound-engineering/agents/workflow/lint.md +16 -0
- package/plugins/compound-engineering/agents/workflow/pr-comment-resolver.md +84 -0
- package/plugins/compound-engineering/agents/workflow/spec-flow-analyzer.md +134 -0
- package/plugins/compound-engineering/commands/agent-native-audit.md +278 -0
- package/plugins/compound-engineering/commands/changelog.md +138 -0
- package/plugins/compound-engineering/commands/create-agent-skill.md +9 -0
- package/plugins/compound-engineering/commands/deepen-plan.md +546 -0
- package/plugins/compound-engineering/commands/deploy-docs.md +113 -0
- package/plugins/compound-engineering/commands/feature-video.md +342 -0
- package/plugins/compound-engineering/commands/generate_command.md +163 -0
- package/plugins/compound-engineering/commands/heal-skill.md +143 -0
- package/plugins/compound-engineering/commands/lfg.md +20 -0
- package/plugins/compound-engineering/commands/release-docs.md +212 -0
- package/plugins/compound-engineering/commands/report-bug.md +151 -0
- package/plugins/compound-engineering/commands/reproduce-bug.md +100 -0
- package/plugins/compound-engineering/commands/resolve_parallel.md +35 -0
- package/plugins/compound-engineering/commands/resolve_todo_parallel.md +37 -0
- package/plugins/compound-engineering/commands/slfg.md +32 -0
- package/plugins/compound-engineering/commands/technical_review.md +8 -0
- package/plugins/compound-engineering/commands/test-browser.md +339 -0
- package/plugins/compound-engineering/commands/test-xcode.md +332 -0
- package/plugins/compound-engineering/commands/triage.md +311 -0
- package/plugins/compound-engineering/commands/workflows/brainstorm.md +124 -0
- package/plugins/compound-engineering/commands/workflows/compound.md +239 -0
- package/plugins/compound-engineering/commands/workflows/plan.md +551 -0
- package/plugins/compound-engineering/commands/workflows/review.md +526 -0
- package/plugins/compound-engineering/commands/workflows/work.md +433 -0
- package/plugins/compound-engineering/skills/agent-browser/SKILL.md +223 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/SKILL.md +435 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/action-parity-discipline.md +409 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/agent-execution-patterns.md +467 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/agent-native-testing.md +582 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/architecture-patterns.md +478 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/dynamic-context-injection.md +338 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/files-universal-interface.md +301 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/from-primitives-to-domain-tools.md +359 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/mcp-tool-design.md +506 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/mobile-patterns.md +871 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/product-implications.md +443 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/refactoring-to-prompt-native.md +317 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/self-modification.md +269 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/shared-workspace-architecture.md +680 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/system-prompt-design.md +250 -0
- package/plugins/compound-engineering/skills/andrew-kane-gem-writer/SKILL.md +184 -0
- package/plugins/compound-engineering/skills/andrew-kane-gem-writer/references/database-adapters.md +231 -0
- package/plugins/compound-engineering/skills/andrew-kane-gem-writer/references/module-organization.md +121 -0
- package/plugins/compound-engineering/skills/andrew-kane-gem-writer/references/rails-integration.md +183 -0
- package/plugins/compound-engineering/skills/andrew-kane-gem-writer/references/resources.md +119 -0
- package/plugins/compound-engineering/skills/andrew-kane-gem-writer/references/testing-patterns.md +261 -0
- package/plugins/compound-engineering/skills/brainstorming/SKILL.md +190 -0
- package/plugins/compound-engineering/skills/compound-docs/SKILL.md +511 -0
- package/plugins/compound-engineering/skills/compound-docs/assets/critical-pattern-template.md +34 -0
- package/plugins/compound-engineering/skills/compound-docs/assets/resolution-template.md +93 -0
- package/plugins/compound-engineering/skills/compound-docs/references/yaml-schema.md +65 -0
- package/plugins/compound-engineering/skills/compound-docs/schema.yaml +176 -0
- package/plugins/compound-engineering/skills/create-agent-skills/SKILL.md +275 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/api-security.md +226 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/be-clear-and-direct.md +531 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/best-practices.md +404 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/common-patterns.md +595 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/core-principles.md +437 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/executable-code.md +175 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/iteration-and-testing.md +474 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/official-spec.md +134 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/recommended-structure.md +168 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/skill-structure.md +152 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/using-scripts.md +113 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/using-templates.md +112 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/workflows-and-validation.md +510 -0
- package/plugins/compound-engineering/skills/create-agent-skills/templates/router-skill.md +73 -0
- package/plugins/compound-engineering/skills/create-agent-skills/templates/simple-skill.md +33 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/add-reference.md +96 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/add-script.md +93 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/add-template.md +74 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/add-workflow.md +120 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/audit-skill.md +138 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/create-domain-expertise-skill.md +605 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/create-new-skill.md +191 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/get-guidance.md +121 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/upgrade-to-router.md +161 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/verify-skill.md +204 -0
- package/plugins/compound-engineering/skills/dhh-rails-style/SKILL.md +185 -0
- package/plugins/compound-engineering/skills/dhh-rails-style/references/architecture.md +653 -0
- package/plugins/compound-engineering/skills/dhh-rails-style/references/controllers.md +303 -0
- package/plugins/compound-engineering/skills/dhh-rails-style/references/frontend.md +510 -0
- package/plugins/compound-engineering/skills/dhh-rails-style/references/gems.md +266 -0
- package/plugins/compound-engineering/skills/dhh-rails-style/references/models.md +359 -0
- package/plugins/compound-engineering/skills/dhh-rails-style/references/testing.md +338 -0
- package/plugins/compound-engineering/skills/document-review/SKILL.md +87 -0
- package/plugins/compound-engineering/skills/dspy-ruby/SKILL.md +737 -0
- package/plugins/compound-engineering/skills/dspy-ruby/assets/config-template.rb +187 -0
- package/plugins/compound-engineering/skills/dspy-ruby/assets/module-template.rb +300 -0
- package/plugins/compound-engineering/skills/dspy-ruby/assets/signature-template.rb +221 -0
- package/plugins/compound-engineering/skills/dspy-ruby/references/core-concepts.md +674 -0
- package/plugins/compound-engineering/skills/dspy-ruby/references/observability.md +366 -0
- package/plugins/compound-engineering/skills/dspy-ruby/references/optimization.md +603 -0
- package/plugins/compound-engineering/skills/dspy-ruby/references/providers.md +418 -0
- package/plugins/compound-engineering/skills/dspy-ruby/references/toolsets.md +502 -0
- package/plugins/compound-engineering/skills/every-style-editor/SKILL.md +134 -0
- package/plugins/compound-engineering/skills/every-style-editor/references/EVERY_WRITE_STYLE.md +529 -0
- package/plugins/compound-engineering/skills/file-todos/SKILL.md +252 -0
- package/plugins/compound-engineering/skills/file-todos/assets/todo-template.md +155 -0
- package/plugins/compound-engineering/skills/frontend-design/SKILL.md +42 -0
- package/plugins/compound-engineering/skills/gemini-imagegen/SKILL.md +237 -0
- package/plugins/compound-engineering/skills/gemini-imagegen/requirements.txt +2 -0
- package/plugins/compound-engineering/skills/gemini-imagegen/scripts/compose_images.py +157 -0
- package/plugins/compound-engineering/skills/gemini-imagegen/scripts/edit_image.py +144 -0
- package/plugins/compound-engineering/skills/gemini-imagegen/scripts/gemini_images.py +263 -0
- package/plugins/compound-engineering/skills/gemini-imagegen/scripts/generate_image.py +133 -0
- package/plugins/compound-engineering/skills/gemini-imagegen/scripts/multi_turn_chat.py +216 -0
- package/plugins/compound-engineering/skills/git-worktree/SKILL.md +302 -0
- package/plugins/compound-engineering/skills/git-worktree/scripts/worktree-manager.sh +337 -0
- package/plugins/compound-engineering/skills/orchestrating-swarms/SKILL.md +1718 -0
- package/plugins/compound-engineering/skills/rclone/SKILL.md +150 -0
- package/plugins/compound-engineering/skills/rclone/scripts/check_setup.sh +60 -0
- package/plugins/compound-engineering/skills/resolve-pr-parallel/SKILL.md +89 -0
- package/plugins/compound-engineering/skills/resolve-pr-parallel/scripts/get-pr-comments +68 -0
- package/plugins/compound-engineering/skills/resolve-pr-parallel/scripts/resolve-pr-thread +23 -0
- package/plugins/compound-engineering/skills/skill-creator/SKILL.md +210 -0
- package/plugins/compound-engineering/skills/skill-creator/scripts/init_skill.py +303 -0
- package/plugins/compound-engineering/skills/skill-creator/scripts/package_skill.py +110 -0
- package/plugins/compound-engineering/skills/skill-creator/scripts/quick_validate.py +65 -0
- package/prompts/deepen-plan.md +549 -0
- package/prompts/feature-video.md +341 -0
- package/prompts/resolve_todo_parallel.md +36 -0
- package/prompts/test-browser.md +342 -0
- package/prompts/workflows-brainstorm.md +123 -0
- package/prompts/workflows-compound.md +238 -0
- package/prompts/workflows-plan.md +550 -0
- package/prompts/workflows-review.md +529 -0
- package/prompts/workflows-work.md +432 -0
- package/skills/agent-browser/SKILL.md +223 -0
- package/skills/agent-native-architecture/SKILL.md +435 -0
- package/skills/agent-native-architecture/references/action-parity-discipline.md +409 -0
- package/skills/agent-native-architecture/references/agent-execution-patterns.md +467 -0
- package/skills/agent-native-architecture/references/agent-native-testing.md +582 -0
- package/skills/agent-native-architecture/references/architecture-patterns.md +478 -0
- package/skills/agent-native-architecture/references/dynamic-context-injection.md +338 -0
- package/skills/agent-native-architecture/references/files-universal-interface.md +301 -0
- package/skills/agent-native-architecture/references/from-primitives-to-domain-tools.md +359 -0
- package/skills/agent-native-architecture/references/mcp-tool-design.md +506 -0
- package/skills/agent-native-architecture/references/mobile-patterns.md +871 -0
- package/skills/agent-native-architecture/references/product-implications.md +443 -0
- package/skills/agent-native-architecture/references/refactoring-to-prompt-native.md +317 -0
- package/skills/agent-native-architecture/references/self-modification.md +269 -0
- package/skills/agent-native-architecture/references/shared-workspace-architecture.md +680 -0
- package/skills/agent-native-architecture/references/system-prompt-design.md +250 -0
- package/skills/agent-native-reviewer/SKILL.md +260 -0
- package/skills/andrew-kane-gem-writer/SKILL.md +184 -0
- package/skills/andrew-kane-gem-writer/references/database-adapters.md +231 -0
- package/skills/andrew-kane-gem-writer/references/module-organization.md +121 -0
- package/skills/andrew-kane-gem-writer/references/rails-integration.md +183 -0
- package/skills/andrew-kane-gem-writer/references/resources.md +119 -0
- package/skills/andrew-kane-gem-writer/references/testing-patterns.md +261 -0
- package/skills/ankane-readme-writer/SKILL.md +63 -0
- package/skills/architecture-strategist/SKILL.md +66 -0
- package/skills/best-practices-researcher/SKILL.md +125 -0
- package/skills/brainstorming/SKILL.md +190 -0
- package/skills/bug-reproduction-validator/SKILL.md +81 -0
- package/skills/code-simplicity-reviewer/SKILL.md +100 -0
- package/skills/compound-docs/SKILL.md +511 -0
- package/skills/compound-docs/assets/critical-pattern-template.md +34 -0
- package/skills/compound-docs/assets/resolution-template.md +93 -0
- package/skills/compound-docs/references/yaml-schema.md +65 -0
- package/skills/compound-docs/schema.yaml +176 -0
- package/skills/create-agent-skills/SKILL.md +275 -0
- package/skills/create-agent-skills/references/api-security.md +226 -0
- package/skills/create-agent-skills/references/be-clear-and-direct.md +531 -0
- package/skills/create-agent-skills/references/best-practices.md +404 -0
- package/skills/create-agent-skills/references/common-patterns.md +595 -0
- package/skills/create-agent-skills/references/core-principles.md +437 -0
- package/skills/create-agent-skills/references/executable-code.md +175 -0
- package/skills/create-agent-skills/references/iteration-and-testing.md +474 -0
- package/skills/create-agent-skills/references/official-spec.md +134 -0
- package/skills/create-agent-skills/references/recommended-structure.md +168 -0
- package/skills/create-agent-skills/references/skill-structure.md +152 -0
- package/skills/create-agent-skills/references/using-scripts.md +113 -0
- package/skills/create-agent-skills/references/using-templates.md +112 -0
- package/skills/create-agent-skills/references/workflows-and-validation.md +510 -0
- package/skills/create-agent-skills/templates/router-skill.md +73 -0
- package/skills/create-agent-skills/templates/simple-skill.md +33 -0
- package/skills/create-agent-skills/workflows/add-reference.md +96 -0
- package/skills/create-agent-skills/workflows/add-script.md +93 -0
- package/skills/create-agent-skills/workflows/add-template.md +74 -0
- package/skills/create-agent-skills/workflows/add-workflow.md +120 -0
- package/skills/create-agent-skills/workflows/audit-skill.md +138 -0
- package/skills/create-agent-skills/workflows/create-domain-expertise-skill.md +605 -0
- package/skills/create-agent-skills/workflows/create-new-skill.md +191 -0
- package/skills/create-agent-skills/workflows/get-guidance.md +121 -0
- package/skills/create-agent-skills/workflows/upgrade-to-router.md +161 -0
- package/skills/create-agent-skills/workflows/verify-skill.md +204 -0
- package/skills/data-integrity-guardian/SKILL.md +84 -0
- package/skills/data-migration-expert/SKILL.md +111 -0
- package/skills/deployment-verification-agent/SKILL.md +173 -0
- package/skills/design-implementation-reviewer/SKILL.md +107 -0
- package/skills/design-iterator/SKILL.md +222 -0
- package/skills/dhh-rails-reviewer/SKILL.md +65 -0
- package/skills/dhh-rails-style/SKILL.md +185 -0
- package/skills/dhh-rails-style/references/architecture.md +653 -0
- package/skills/dhh-rails-style/references/controllers.md +303 -0
- package/skills/dhh-rails-style/references/frontend.md +510 -0
- package/skills/dhh-rails-style/references/gems.md +266 -0
- package/skills/dhh-rails-style/references/models.md +359 -0
- package/skills/dhh-rails-style/references/testing.md +338 -0
- package/skills/document-review/SKILL.md +87 -0
- package/skills/dspy-ruby/SKILL.md +737 -0
- package/skills/dspy-ruby/assets/config-template.rb +187 -0
- package/skills/dspy-ruby/assets/module-template.rb +300 -0
- package/skills/dspy-ruby/assets/signature-template.rb +221 -0
- package/skills/dspy-ruby/references/core-concepts.md +674 -0
- package/skills/dspy-ruby/references/observability.md +366 -0
- package/skills/dspy-ruby/references/optimization.md +603 -0
- package/skills/dspy-ruby/references/providers.md +418 -0
- package/skills/dspy-ruby/references/toolsets.md +502 -0
- package/skills/every-style-editor/SKILL.md +134 -0
- package/skills/every-style-editor/references/EVERY_WRITE_STYLE.md +529 -0
- package/skills/every-style-editor-2/SKILL.md +62 -0
- package/skills/figma-design-sync/SKILL.md +188 -0
- package/skills/file-todos/SKILL.md +252 -0
- package/skills/file-todos/assets/todo-template.md +155 -0
- package/skills/framework-docs-researcher/SKILL.md +105 -0
- package/skills/frontend-design/SKILL.md +42 -0
- package/skills/gemini-imagegen/SKILL.md +237 -0
- package/skills/gemini-imagegen/requirements.txt +2 -0
- package/skills/gemini-imagegen/scripts/compose_images.py +157 -0
- package/skills/gemini-imagegen/scripts/edit_image.py +144 -0
- package/skills/gemini-imagegen/scripts/gemini_images.py +263 -0
- package/skills/gemini-imagegen/scripts/generate_image.py +133 -0
- package/skills/gemini-imagegen/scripts/multi_turn_chat.py +216 -0
- package/skills/git-history-analyzer/SKILL.md +58 -0
- package/skills/git-worktree/SKILL.md +302 -0
- package/skills/git-worktree/scripts/worktree-manager.sh +337 -0
- package/skills/julik-frontend-races-reviewer/SKILL.md +220 -0
- package/skills/kieran-python-reviewer/SKILL.md +132 -0
- package/skills/kieran-rails-reviewer/SKILL.md +114 -0
- package/skills/kieran-typescript-reviewer/SKILL.md +123 -0
- package/skills/learnings-researcher/SKILL.md +263 -0
- package/skills/lint/SKILL.md +14 -0
- package/skills/orchestrating-swarms/SKILL.md +1718 -0
- package/skills/pattern-recognition-specialist/SKILL.md +71 -0
- package/skills/performance-oracle/SKILL.md +136 -0
- package/skills/pr-comment-resolver/SKILL.md +82 -0
- package/skills/rclone/SKILL.md +150 -0
- package/skills/rclone/scripts/check_setup.sh +60 -0
- package/skills/repo-research-analyst/SKILL.md +134 -0
- package/skills/resolve_pr_parallel/SKILL.md +89 -0
- package/skills/resolve_pr_parallel/scripts/get-pr-comments +68 -0
- package/skills/resolve_pr_parallel/scripts/resolve-pr-thread +23 -0
- package/skills/schema-drift-detector/SKILL.md +153 -0
- package/skills/security-sentinel/SKILL.md +113 -0
- package/skills/skill-creator/SKILL.md +210 -0
- package/skills/skill-creator/scripts/init_skill.py +303 -0
- package/skills/skill-creator/scripts/package_skill.py +110 -0
- package/skills/skill-creator/scripts/quick_validate.py +65 -0
- package/skills/spec-flow-analyzer/SKILL.md +133 -0
- package/src/commands/convert.ts +183 -0
- package/src/commands/install.ts +273 -0
- package/src/commands/list.ts +37 -0
- package/src/commands/sync.ts +89 -0
- package/src/converters/claude-to-codex.ts +182 -0
- package/src/converters/claude-to-opencode.ts +395 -0
- package/src/converters/claude-to-pi.ts +205 -0
- package/src/index.ts +22 -0
- package/src/parsers/claude-home.ts +65 -0
- package/src/parsers/claude.ts +252 -0
- package/src/sync/codex.ts +92 -0
- package/src/sync/opencode.ts +75 -0
- package/src/sync/pi.ts +88 -0
- package/src/targets/codex.ts +96 -0
- package/src/targets/index.ts +38 -0
- package/src/targets/opencode.ts +57 -0
- package/src/targets/pi.ts +131 -0
- package/src/templates/pi/compat-extension.ts +452 -0
- package/src/types/claude.ts +90 -0
- package/src/types/codex.ts +23 -0
- package/src/types/opencode.ts +54 -0
- package/src/types/pi.ts +40 -0
- package/src/utils/codex-agents.ts +64 -0
- package/src/utils/files.ts +77 -0
- package/src/utils/frontmatter.ts +65 -0
- package/src/utils/symlink.ts +43 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
<overview>
|
|
2
|
+
How to write system prompts for prompt-native agents. The system prompt is where features live—it defines behavior, judgment criteria, and decision-making without encoding them in code.
|
|
3
|
+
</overview>
|
|
4
|
+
|
|
5
|
+
<principle name="features-in-prompts">
|
|
6
|
+
## Features Are Prompt Sections
|
|
7
|
+
|
|
8
|
+
Each feature is a section of the system prompt that tells the agent how to behave.
|
|
9
|
+
|
|
10
|
+
**Traditional approach:** Feature = function in codebase
|
|
11
|
+
```typescript
|
|
12
|
+
function processFeedback(message) {
|
|
13
|
+
const category = categorize(message);
|
|
14
|
+
const priority = calculatePriority(message);
|
|
15
|
+
await store(message, category, priority);
|
|
16
|
+
if (priority > 3) await notify();
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Prompt-native approach:** Feature = section in system prompt
|
|
21
|
+
```markdown
|
|
22
|
+
## Feedback Processing
|
|
23
|
+
|
|
24
|
+
When someone shares feedback:
|
|
25
|
+
1. Read the message to understand what they're saying
|
|
26
|
+
2. Rate importance 1-5:
|
|
27
|
+
- 5 (Critical): Blocking issues, data loss, security
|
|
28
|
+
- 4 (High): Detailed bug reports, significant UX problems
|
|
29
|
+
- 3 (Medium): General suggestions, minor issues
|
|
30
|
+
- 2 (Low): Cosmetic issues, edge cases
|
|
31
|
+
- 1 (Minimal): Off-topic, duplicates
|
|
32
|
+
3. Store using feedback.store_feedback
|
|
33
|
+
4. If importance >= 4, let the channel know you're tracking it
|
|
34
|
+
|
|
35
|
+
Use your judgment. Context matters.
|
|
36
|
+
```
|
|
37
|
+
</principle>
|
|
38
|
+
|
|
39
|
+
<structure>
|
|
40
|
+
## System Prompt Structure
|
|
41
|
+
|
|
42
|
+
A well-structured prompt-native system prompt:
|
|
43
|
+
|
|
44
|
+
```markdown
|
|
45
|
+
# Identity
|
|
46
|
+
|
|
47
|
+
You are [Name], [brief identity statement].
|
|
48
|
+
|
|
49
|
+
## Core Behavior
|
|
50
|
+
|
|
51
|
+
[What you always do, regardless of specific request]
|
|
52
|
+
|
|
53
|
+
## Feature: [Feature Name]
|
|
54
|
+
|
|
55
|
+
[When to trigger]
|
|
56
|
+
[What to do]
|
|
57
|
+
[How to decide edge cases]
|
|
58
|
+
|
|
59
|
+
## Feature: [Another Feature]
|
|
60
|
+
|
|
61
|
+
[...]
|
|
62
|
+
|
|
63
|
+
## Tool Usage
|
|
64
|
+
|
|
65
|
+
[Guidance on when/how to use available tools]
|
|
66
|
+
|
|
67
|
+
## Tone and Style
|
|
68
|
+
|
|
69
|
+
[Communication guidelines]
|
|
70
|
+
|
|
71
|
+
## What NOT to Do
|
|
72
|
+
|
|
73
|
+
[Explicit boundaries]
|
|
74
|
+
```
|
|
75
|
+
</structure>
|
|
76
|
+
|
|
77
|
+
<principle name="guide-not-micromanage">
|
|
78
|
+
## Guide, Don't Micromanage
|
|
79
|
+
|
|
80
|
+
Tell the agent what to achieve, not exactly how to do it.
|
|
81
|
+
|
|
82
|
+
**Micromanaging (bad):**
|
|
83
|
+
```markdown
|
|
84
|
+
When creating a summary:
|
|
85
|
+
1. Use exactly 3 bullet points
|
|
86
|
+
2. Each bullet under 20 words
|
|
87
|
+
3. Use em-dashes for sub-points
|
|
88
|
+
4. Bold the first word of each bullet
|
|
89
|
+
5. End with a colon if there are sub-points
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Guiding (good):**
|
|
93
|
+
```markdown
|
|
94
|
+
When creating summaries:
|
|
95
|
+
- Be concise but complete
|
|
96
|
+
- Highlight the most important points
|
|
97
|
+
- Use your judgment about format
|
|
98
|
+
|
|
99
|
+
The goal is clarity, not consistency.
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Trust the agent's intelligence. It knows how to communicate.
|
|
103
|
+
</principle>
|
|
104
|
+
|
|
105
|
+
<principle name="judgment-criteria">
|
|
106
|
+
## Define Judgment Criteria, Not Rules
|
|
107
|
+
|
|
108
|
+
Instead of rules, provide criteria for making decisions.
|
|
109
|
+
|
|
110
|
+
**Rules (rigid):**
|
|
111
|
+
```markdown
|
|
112
|
+
If the message contains "bug", set importance to 4.
|
|
113
|
+
If the message contains "crash", set importance to 5.
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Judgment criteria (flexible):**
|
|
117
|
+
```markdown
|
|
118
|
+
## Importance Rating
|
|
119
|
+
|
|
120
|
+
Rate importance based on:
|
|
121
|
+
- **Impact**: How many users affected? How severe?
|
|
122
|
+
- **Urgency**: Is this blocking? Time-sensitive?
|
|
123
|
+
- **Actionability**: Can we actually fix this?
|
|
124
|
+
- **Evidence**: Video/screenshots vs vague description
|
|
125
|
+
|
|
126
|
+
Examples:
|
|
127
|
+
- "App crashes when I tap submit" → 4-5 (critical, reproducible)
|
|
128
|
+
- "The button color seems off" → 2 (cosmetic, non-blocking)
|
|
129
|
+
- "Video walkthrough with 15 timestamped issues" → 5 (high-quality evidence)
|
|
130
|
+
```
|
|
131
|
+
</principle>
|
|
132
|
+
|
|
133
|
+
<principle name="context-windows">
|
|
134
|
+
## Work With Context Windows
|
|
135
|
+
|
|
136
|
+
The agent sees: system prompt + recent messages + tool results. Design for this.
|
|
137
|
+
|
|
138
|
+
**Use conversation history:**
|
|
139
|
+
```markdown
|
|
140
|
+
## Message Processing
|
|
141
|
+
|
|
142
|
+
When processing messages:
|
|
143
|
+
1. Check if this relates to recent conversation
|
|
144
|
+
2. If someone is continuing a previous thread, maintain context
|
|
145
|
+
3. Don't ask questions you already have answers to
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Acknowledge agent limitations:**
|
|
149
|
+
```markdown
|
|
150
|
+
## Memory Limitations
|
|
151
|
+
|
|
152
|
+
You don't persist memory between restarts. Use the memory server:
|
|
153
|
+
- Before responding, check memory.recall for relevant context
|
|
154
|
+
- After important decisions, use memory.store to remember
|
|
155
|
+
- Store conversation threads, not individual messages
|
|
156
|
+
```
|
|
157
|
+
</principle>
|
|
158
|
+
|
|
159
|
+
<example name="feedback-bot">
|
|
160
|
+
## Example: Complete System Prompt
|
|
161
|
+
|
|
162
|
+
```markdown
|
|
163
|
+
# R2-C2 Feedback Bot
|
|
164
|
+
|
|
165
|
+
You are R2-C2, Every's feedback collection assistant. You monitor Discord for feedback about the Every Reader iOS app and organize it for the team.
|
|
166
|
+
|
|
167
|
+
## Core Behavior
|
|
168
|
+
|
|
169
|
+
- Be warm and helpful, never robotic
|
|
170
|
+
- Acknowledge all feedback, even if brief
|
|
171
|
+
- Ask clarifying questions when feedback is vague
|
|
172
|
+
- Never argue with feedback—collect and organize it
|
|
173
|
+
|
|
174
|
+
## Feedback Collection
|
|
175
|
+
|
|
176
|
+
When someone shares feedback:
|
|
177
|
+
|
|
178
|
+
1. **Acknowledge** warmly: "Thanks for this!" or "Good catch!"
|
|
179
|
+
2. **Clarify** if needed: "Can you tell me more about when this happens?"
|
|
180
|
+
3. **Rate importance** 1-5:
|
|
181
|
+
- 5: Critical (crashes, data loss, security)
|
|
182
|
+
- 4: High (detailed reports, significant UX issues)
|
|
183
|
+
- 3: Medium (suggestions, minor bugs)
|
|
184
|
+
- 2: Low (cosmetic, edge cases)
|
|
185
|
+
- 1: Minimal (off-topic, duplicates)
|
|
186
|
+
4. **Store** using feedback.store_feedback
|
|
187
|
+
5. **Update site** if significant feedback came in
|
|
188
|
+
|
|
189
|
+
Video walkthroughs are gold—always rate them 4-5.
|
|
190
|
+
|
|
191
|
+
## Site Management
|
|
192
|
+
|
|
193
|
+
You maintain a public feedback site. When feedback accumulates:
|
|
194
|
+
|
|
195
|
+
1. Sync data to site/public/content/feedback.json
|
|
196
|
+
2. Update status counts and organization
|
|
197
|
+
3. Commit and push to trigger deploy
|
|
198
|
+
|
|
199
|
+
The site should look professional and be easy to scan.
|
|
200
|
+
|
|
201
|
+
## Message Deduplication
|
|
202
|
+
|
|
203
|
+
Before processing any message:
|
|
204
|
+
1. Check memory.recall(key: "processed_{messageId}")
|
|
205
|
+
2. Skip if already processed
|
|
206
|
+
3. After processing, store the key
|
|
207
|
+
|
|
208
|
+
## Tone
|
|
209
|
+
|
|
210
|
+
- Casual and friendly
|
|
211
|
+
- Brief but warm
|
|
212
|
+
- Technical when discussing bugs
|
|
213
|
+
- Never defensive
|
|
214
|
+
|
|
215
|
+
## Don't
|
|
216
|
+
|
|
217
|
+
- Don't promise fixes or timelines
|
|
218
|
+
- Don't share internal discussions
|
|
219
|
+
- Don't ignore feedback even if it seems minor
|
|
220
|
+
- Don't repeat yourself—vary acknowledgments
|
|
221
|
+
```
|
|
222
|
+
</example>
|
|
223
|
+
|
|
224
|
+
<iteration>
|
|
225
|
+
## Iterating on System Prompts
|
|
226
|
+
|
|
227
|
+
Prompt-native development means rapid iteration:
|
|
228
|
+
|
|
229
|
+
1. **Observe** agent behavior in production
|
|
230
|
+
2. **Identify** gaps: "It's not rating video feedback high enough"
|
|
231
|
+
3. **Add guidance**: "Video walkthroughs are gold—always rate them 4-5"
|
|
232
|
+
4. **Deploy** (just edit the prompt file)
|
|
233
|
+
5. **Repeat**
|
|
234
|
+
|
|
235
|
+
No code changes. No recompilation. Just prose.
|
|
236
|
+
</iteration>
|
|
237
|
+
|
|
238
|
+
<checklist>
|
|
239
|
+
## System Prompt Checklist
|
|
240
|
+
|
|
241
|
+
- [ ] Clear identity statement
|
|
242
|
+
- [ ] Core behaviors that always apply
|
|
243
|
+
- [ ] Features as separate sections
|
|
244
|
+
- [ ] Judgment criteria instead of rigid rules
|
|
245
|
+
- [ ] Examples for ambiguous cases
|
|
246
|
+
- [ ] Explicit boundaries (what NOT to do)
|
|
247
|
+
- [ ] Tone guidance
|
|
248
|
+
- [ ] Tool usage guidance (when to use each)
|
|
249
|
+
- [ ] Memory/context handling
|
|
250
|
+
</checklist>
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: andrew-kane-gem-writer
|
|
3
|
+
description: This skill should be used when writing Ruby gems following Andrew Kane's proven patterns and philosophy. It applies when creating new Ruby gems, refactoring existing gems, designing gem APIs, or when clean, minimal, production-ready Ruby library code is needed. Triggers on requests like "create a gem", "write a Ruby library", "design a gem API", or mentions of Andrew Kane's style.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Andrew Kane Gem Writer
|
|
7
|
+
|
|
8
|
+
Write Ruby gems following Andrew Kane's battle-tested patterns from 100+ gems with 374M+ downloads (Searchkick, PgHero, Chartkick, Strong Migrations, Lockbox, Ahoy, Blazer, Groupdate, Neighbor, Blind Index).
|
|
9
|
+
|
|
10
|
+
## Core Philosophy
|
|
11
|
+
|
|
12
|
+
**Simplicity over cleverness.** Zero or minimal dependencies. Explicit code over metaprogramming. Rails integration without Rails coupling. Every pattern serves production use cases.
|
|
13
|
+
|
|
14
|
+
## Entry Point Structure
|
|
15
|
+
|
|
16
|
+
Every gem follows this exact pattern in `lib/gemname.rb`:
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
# 1. Dependencies (stdlib preferred)
|
|
20
|
+
require "forwardable"
|
|
21
|
+
|
|
22
|
+
# 2. Internal modules
|
|
23
|
+
require_relative "gemname/model"
|
|
24
|
+
require_relative "gemname/version"
|
|
25
|
+
|
|
26
|
+
# 3. Conditional Rails (CRITICAL - never require Rails directly)
|
|
27
|
+
require_relative "gemname/railtie" if defined?(Rails)
|
|
28
|
+
|
|
29
|
+
# 4. Module with config and errors
|
|
30
|
+
module GemName
|
|
31
|
+
class Error < StandardError; end
|
|
32
|
+
class InvalidConfigError < Error; end
|
|
33
|
+
|
|
34
|
+
class << self
|
|
35
|
+
attr_accessor :timeout, :logger
|
|
36
|
+
attr_writer :client
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
self.timeout = 10 # Defaults set immediately
|
|
40
|
+
end
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Class Macro DSL Pattern
|
|
44
|
+
|
|
45
|
+
The signature Kane pattern—single method call configures everything:
|
|
46
|
+
|
|
47
|
+
```ruby
|
|
48
|
+
# Usage
|
|
49
|
+
class Product < ApplicationRecord
|
|
50
|
+
searchkick word_start: [:name]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Implementation
|
|
54
|
+
module GemName
|
|
55
|
+
module Model
|
|
56
|
+
def gemname(**options)
|
|
57
|
+
unknown = options.keys - KNOWN_KEYWORDS
|
|
58
|
+
raise ArgumentError, "unknown keywords: #{unknown.join(", ")}" if unknown.any?
|
|
59
|
+
|
|
60
|
+
mod = Module.new
|
|
61
|
+
mod.module_eval do
|
|
62
|
+
define_method :some_method do
|
|
63
|
+
# implementation
|
|
64
|
+
end unless method_defined?(:some_method)
|
|
65
|
+
end
|
|
66
|
+
include mod
|
|
67
|
+
|
|
68
|
+
class_eval do
|
|
69
|
+
cattr_reader :gemname_options, instance_reader: false
|
|
70
|
+
class_variable_set :@@gemname_options, options.dup
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Rails Integration
|
|
78
|
+
|
|
79
|
+
**Always use `ActiveSupport.on_load`—never require Rails gems directly:**
|
|
80
|
+
|
|
81
|
+
```ruby
|
|
82
|
+
# WRONG
|
|
83
|
+
require "active_record"
|
|
84
|
+
ActiveRecord::Base.include(MyGem::Model)
|
|
85
|
+
|
|
86
|
+
# CORRECT
|
|
87
|
+
ActiveSupport.on_load(:active_record) do
|
|
88
|
+
extend GemName::Model
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Use prepend for behavior modification
|
|
92
|
+
ActiveSupport.on_load(:active_record) do
|
|
93
|
+
ActiveRecord::Migration.prepend(GemName::Migration)
|
|
94
|
+
end
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Configuration Pattern
|
|
98
|
+
|
|
99
|
+
Use `class << self` with `attr_accessor`, not Configuration objects:
|
|
100
|
+
|
|
101
|
+
```ruby
|
|
102
|
+
module GemName
|
|
103
|
+
class << self
|
|
104
|
+
attr_accessor :timeout, :logger
|
|
105
|
+
attr_writer :master_key
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def self.master_key
|
|
109
|
+
@master_key ||= ENV["GEMNAME_MASTER_KEY"]
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
self.timeout = 10
|
|
113
|
+
self.logger = nil
|
|
114
|
+
end
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Error Handling
|
|
118
|
+
|
|
119
|
+
Simple hierarchy with informative messages:
|
|
120
|
+
|
|
121
|
+
```ruby
|
|
122
|
+
module GemName
|
|
123
|
+
class Error < StandardError; end
|
|
124
|
+
class ConfigError < Error; end
|
|
125
|
+
class ValidationError < Error; end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Validate early with ArgumentError
|
|
129
|
+
def initialize(key:)
|
|
130
|
+
raise ArgumentError, "Key must be 32 bytes" unless key&.bytesize == 32
|
|
131
|
+
end
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Testing (Minitest Only)
|
|
135
|
+
|
|
136
|
+
```ruby
|
|
137
|
+
# test/test_helper.rb
|
|
138
|
+
require "bundler/setup"
|
|
139
|
+
Bundler.require(:default)
|
|
140
|
+
require "minitest/autorun"
|
|
141
|
+
require "minitest/pride"
|
|
142
|
+
|
|
143
|
+
# test/model_test.rb
|
|
144
|
+
class ModelTest < Minitest::Test
|
|
145
|
+
def test_basic_functionality
|
|
146
|
+
assert_equal expected, actual
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Gemspec Pattern
|
|
152
|
+
|
|
153
|
+
Zero runtime dependencies when possible:
|
|
154
|
+
|
|
155
|
+
```ruby
|
|
156
|
+
Gem::Specification.new do |spec|
|
|
157
|
+
spec.name = "gemname"
|
|
158
|
+
spec.version = GemName::VERSION
|
|
159
|
+
spec.required_ruby_version = ">= 3.1"
|
|
160
|
+
spec.files = Dir["*.{md,txt}", "{lib}/**/*"]
|
|
161
|
+
spec.require_path = "lib"
|
|
162
|
+
# NO add_dependency lines - dev deps go in Gemfile
|
|
163
|
+
end
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Anti-Patterns to Avoid
|
|
167
|
+
|
|
168
|
+
- `method_missing` (use `define_method` instead)
|
|
169
|
+
- Configuration objects (use class accessors)
|
|
170
|
+
- `@@class_variables` (use `class << self`)
|
|
171
|
+
- Requiring Rails gems directly
|
|
172
|
+
- Many runtime dependencies
|
|
173
|
+
- Committing Gemfile.lock in gems
|
|
174
|
+
- RSpec (use Minitest)
|
|
175
|
+
- Heavy DSLs (prefer explicit Ruby)
|
|
176
|
+
|
|
177
|
+
## Reference Files
|
|
178
|
+
|
|
179
|
+
For deeper patterns, see:
|
|
180
|
+
- **[references/module-organization.md](references/module-organization.md)** - Directory layouts, method decomposition
|
|
181
|
+
- **[references/rails-integration.md](references/rails-integration.md)** - Railtie, Engine, on_load patterns
|
|
182
|
+
- **[references/database-adapters.md](references/database-adapters.md)** - Multi-database support patterns
|
|
183
|
+
- **[references/testing-patterns.md](references/testing-patterns.md)** - Multi-version testing, CI setup
|
|
184
|
+
- **[references/resources.md](references/resources.md)** - Links to Kane's repos and articles
|
package/plugins/compound-engineering/skills/andrew-kane-gem-writer/references/database-adapters.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# Database Adapter Patterns
|
|
2
|
+
|
|
3
|
+
## Abstract Base Class Pattern
|
|
4
|
+
|
|
5
|
+
```ruby
|
|
6
|
+
# lib/strong_migrations/adapters/abstract_adapter.rb
|
|
7
|
+
module StrongMigrations
|
|
8
|
+
module Adapters
|
|
9
|
+
class AbstractAdapter
|
|
10
|
+
def initialize(checker)
|
|
11
|
+
@checker = checker
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def min_version
|
|
15
|
+
nil
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def set_statement_timeout(timeout)
|
|
19
|
+
# no-op by default
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def check_lock_timeout
|
|
23
|
+
# no-op by default
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def connection
|
|
29
|
+
@checker.send(:connection)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def quote(value)
|
|
33
|
+
connection.quote(value)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## PostgreSQL Adapter
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
# lib/strong_migrations/adapters/postgresql_adapter.rb
|
|
44
|
+
module StrongMigrations
|
|
45
|
+
module Adapters
|
|
46
|
+
class PostgreSQLAdapter < AbstractAdapter
|
|
47
|
+
def min_version
|
|
48
|
+
"12"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def set_statement_timeout(timeout)
|
|
52
|
+
select_all("SET statement_timeout = #{timeout.to_i * 1000}")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def set_lock_timeout(timeout)
|
|
56
|
+
select_all("SET lock_timeout = #{timeout.to_i * 1000}")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def check_lock_timeout
|
|
60
|
+
lock_timeout = connection.select_value("SHOW lock_timeout")
|
|
61
|
+
lock_timeout_sec = timeout_to_sec(lock_timeout)
|
|
62
|
+
# validation logic
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
def select_all(sql)
|
|
68
|
+
connection.select_all(sql)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def timeout_to_sec(timeout)
|
|
72
|
+
units = {"us" => 1e-6, "ms" => 1e-3, "s" => 1, "min" => 60}
|
|
73
|
+
timeout.to_f * (units[timeout.gsub(/\d+/, "")] || 1e-3)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## MySQL Adapter
|
|
81
|
+
|
|
82
|
+
```ruby
|
|
83
|
+
# lib/strong_migrations/adapters/mysql_adapter.rb
|
|
84
|
+
module StrongMigrations
|
|
85
|
+
module Adapters
|
|
86
|
+
class MySQLAdapter < AbstractAdapter
|
|
87
|
+
def min_version
|
|
88
|
+
"8.0"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def set_statement_timeout(timeout)
|
|
92
|
+
select_all("SET max_execution_time = #{timeout.to_i * 1000}")
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def check_lock_timeout
|
|
96
|
+
lock_timeout = connection.select_value("SELECT @@lock_wait_timeout")
|
|
97
|
+
# validation logic
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## MariaDB Adapter (MySQL variant)
|
|
105
|
+
|
|
106
|
+
```ruby
|
|
107
|
+
# lib/strong_migrations/adapters/mariadb_adapter.rb
|
|
108
|
+
module StrongMigrations
|
|
109
|
+
module Adapters
|
|
110
|
+
class MariaDBAdapter < MySQLAdapter
|
|
111
|
+
def min_version
|
|
112
|
+
"10.5"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Override MySQL-specific behavior
|
|
116
|
+
def set_statement_timeout(timeout)
|
|
117
|
+
select_all("SET max_statement_time = #{timeout.to_i}")
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Adapter Detection Pattern
|
|
125
|
+
|
|
126
|
+
Use regex matching on adapter name:
|
|
127
|
+
|
|
128
|
+
```ruby
|
|
129
|
+
def adapter
|
|
130
|
+
@adapter ||= case connection.adapter_name
|
|
131
|
+
when /postg/i
|
|
132
|
+
Adapters::PostgreSQLAdapter.new(self)
|
|
133
|
+
when /mysql|trilogy/i
|
|
134
|
+
if connection.try(:mariadb?)
|
|
135
|
+
Adapters::MariaDBAdapter.new(self)
|
|
136
|
+
else
|
|
137
|
+
Adapters::MySQLAdapter.new(self)
|
|
138
|
+
end
|
|
139
|
+
when /sqlite/i
|
|
140
|
+
Adapters::SQLiteAdapter.new(self)
|
|
141
|
+
else
|
|
142
|
+
Adapters::AbstractAdapter.new(self)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Multi-Database Support (PgHero pattern)
|
|
148
|
+
|
|
149
|
+
```ruby
|
|
150
|
+
module PgHero
|
|
151
|
+
class << self
|
|
152
|
+
attr_accessor :databases
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
self.databases = {}
|
|
156
|
+
|
|
157
|
+
def self.primary_database
|
|
158
|
+
databases.values.first
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def self.capture_query_stats(database: nil)
|
|
162
|
+
db = database ? databases[database] : primary_database
|
|
163
|
+
db.capture_query_stats
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
class Database
|
|
167
|
+
attr_reader :id, :config
|
|
168
|
+
|
|
169
|
+
def initialize(id, config)
|
|
170
|
+
@id = id
|
|
171
|
+
@config = config
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def connection_model
|
|
175
|
+
@connection_model ||= begin
|
|
176
|
+
Class.new(ActiveRecord::Base) do
|
|
177
|
+
self.abstract_class = true
|
|
178
|
+
end.tap do |model|
|
|
179
|
+
model.establish_connection(config)
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def connection
|
|
185
|
+
connection_model.connection
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Connection Switching
|
|
192
|
+
|
|
193
|
+
```ruby
|
|
194
|
+
def with_connection(database_name)
|
|
195
|
+
db = databases[database_name.to_s]
|
|
196
|
+
raise Error, "Unknown database: #{database_name}" unless db
|
|
197
|
+
|
|
198
|
+
yield db.connection
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# Usage
|
|
202
|
+
PgHero.with_connection(:replica) do |conn|
|
|
203
|
+
conn.execute("SELECT * FROM users")
|
|
204
|
+
end
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## SQL Dialect Handling
|
|
208
|
+
|
|
209
|
+
```ruby
|
|
210
|
+
def quote_column(column)
|
|
211
|
+
case adapter_name
|
|
212
|
+
when /postg/i
|
|
213
|
+
%("#{column}")
|
|
214
|
+
when /mysql/i
|
|
215
|
+
"`#{column}`"
|
|
216
|
+
else
|
|
217
|
+
column
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def boolean_value(value)
|
|
222
|
+
case adapter_name
|
|
223
|
+
when /postg/i
|
|
224
|
+
value ? "true" : "false"
|
|
225
|
+
when /mysql/i
|
|
226
|
+
value ? "1" : "0"
|
|
227
|
+
else
|
|
228
|
+
value.to_s
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
```
|