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,75 @@
|
|
|
1
|
+
import fs from "fs/promises"
|
|
2
|
+
import path from "path"
|
|
3
|
+
import type { ClaudeHomeConfig } from "../parsers/claude-home"
|
|
4
|
+
import type { ClaudeMcpServer } from "../types/claude"
|
|
5
|
+
import type { OpenCodeMcpServer } from "../types/opencode"
|
|
6
|
+
import { forceSymlink, isValidSkillName } from "../utils/symlink"
|
|
7
|
+
|
|
8
|
+
export async function syncToOpenCode(
|
|
9
|
+
config: ClaudeHomeConfig,
|
|
10
|
+
outputRoot: string,
|
|
11
|
+
): Promise<void> {
|
|
12
|
+
// Ensure output directories exist
|
|
13
|
+
const skillsDir = path.join(outputRoot, "skills")
|
|
14
|
+
await fs.mkdir(skillsDir, { recursive: true })
|
|
15
|
+
|
|
16
|
+
// Symlink skills (with validation)
|
|
17
|
+
for (const skill of config.skills) {
|
|
18
|
+
if (!isValidSkillName(skill.name)) {
|
|
19
|
+
console.warn(`Skipping skill with invalid name: ${skill.name}`)
|
|
20
|
+
continue
|
|
21
|
+
}
|
|
22
|
+
const target = path.join(skillsDir, skill.name)
|
|
23
|
+
await forceSymlink(skill.sourceDir, target)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Merge MCP servers into opencode.json
|
|
27
|
+
if (Object.keys(config.mcpServers).length > 0) {
|
|
28
|
+
const configPath = path.join(outputRoot, "opencode.json")
|
|
29
|
+
const existing = await readJsonSafe(configPath)
|
|
30
|
+
const mcpConfig = convertMcpForOpenCode(config.mcpServers)
|
|
31
|
+
existing.mcp = { ...(existing.mcp ?? {}), ...mcpConfig }
|
|
32
|
+
await fs.writeFile(configPath, JSON.stringify(existing, null, 2), { mode: 0o600 })
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function readJsonSafe(filePath: string): Promise<Record<string, unknown>> {
|
|
37
|
+
try {
|
|
38
|
+
const content = await fs.readFile(filePath, "utf-8")
|
|
39
|
+
return JSON.parse(content) as Record<string, unknown>
|
|
40
|
+
} catch (err) {
|
|
41
|
+
if ((err as NodeJS.ErrnoException).code === "ENOENT") {
|
|
42
|
+
return {}
|
|
43
|
+
}
|
|
44
|
+
throw err
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function convertMcpForOpenCode(
|
|
49
|
+
servers: Record<string, ClaudeMcpServer>,
|
|
50
|
+
): Record<string, OpenCodeMcpServer> {
|
|
51
|
+
const result: Record<string, OpenCodeMcpServer> = {}
|
|
52
|
+
|
|
53
|
+
for (const [name, server] of Object.entries(servers)) {
|
|
54
|
+
if (server.command) {
|
|
55
|
+
result[name] = {
|
|
56
|
+
type: "local",
|
|
57
|
+
command: [server.command, ...(server.args ?? [])],
|
|
58
|
+
environment: server.env,
|
|
59
|
+
enabled: true,
|
|
60
|
+
}
|
|
61
|
+
continue
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (server.url) {
|
|
65
|
+
result[name] = {
|
|
66
|
+
type: "remote",
|
|
67
|
+
url: server.url,
|
|
68
|
+
headers: server.headers,
|
|
69
|
+
enabled: true,
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return result
|
|
75
|
+
}
|
package/src/sync/pi.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import fs from "fs/promises"
|
|
2
|
+
import path from "path"
|
|
3
|
+
import type { ClaudeHomeConfig } from "../parsers/claude-home"
|
|
4
|
+
import type { ClaudeMcpServer } from "../types/claude"
|
|
5
|
+
import { forceSymlink, isValidSkillName } from "../utils/symlink"
|
|
6
|
+
|
|
7
|
+
type McporterServer = {
|
|
8
|
+
baseUrl?: string
|
|
9
|
+
command?: string
|
|
10
|
+
args?: string[]
|
|
11
|
+
env?: Record<string, string>
|
|
12
|
+
headers?: Record<string, string>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type McporterConfig = {
|
|
16
|
+
mcpServers: Record<string, McporterServer>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function syncToPi(
|
|
20
|
+
config: ClaudeHomeConfig,
|
|
21
|
+
outputRoot: string,
|
|
22
|
+
): Promise<void> {
|
|
23
|
+
const skillsDir = path.join(outputRoot, "skills")
|
|
24
|
+
const mcporterPath = path.join(outputRoot, "compound-engineering", "mcporter.json")
|
|
25
|
+
|
|
26
|
+
await fs.mkdir(skillsDir, { recursive: true })
|
|
27
|
+
|
|
28
|
+
for (const skill of config.skills) {
|
|
29
|
+
if (!isValidSkillName(skill.name)) {
|
|
30
|
+
console.warn(`Skipping skill with invalid name: ${skill.name}`)
|
|
31
|
+
continue
|
|
32
|
+
}
|
|
33
|
+
const target = path.join(skillsDir, skill.name)
|
|
34
|
+
await forceSymlink(skill.sourceDir, target)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (Object.keys(config.mcpServers).length > 0) {
|
|
38
|
+
await fs.mkdir(path.dirname(mcporterPath), { recursive: true })
|
|
39
|
+
|
|
40
|
+
const existing = await readJsonSafe(mcporterPath)
|
|
41
|
+
const converted = convertMcpToMcporter(config.mcpServers)
|
|
42
|
+
const merged: McporterConfig = {
|
|
43
|
+
mcpServers: {
|
|
44
|
+
...(existing.mcpServers ?? {}),
|
|
45
|
+
...converted.mcpServers,
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
await fs.writeFile(mcporterPath, JSON.stringify(merged, null, 2), { mode: 0o600 })
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function readJsonSafe(filePath: string): Promise<Partial<McporterConfig>> {
|
|
54
|
+
try {
|
|
55
|
+
const content = await fs.readFile(filePath, "utf-8")
|
|
56
|
+
return JSON.parse(content) as Partial<McporterConfig>
|
|
57
|
+
} catch (err) {
|
|
58
|
+
if ((err as NodeJS.ErrnoException).code === "ENOENT") {
|
|
59
|
+
return {}
|
|
60
|
+
}
|
|
61
|
+
throw err
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function convertMcpToMcporter(servers: Record<string, ClaudeMcpServer>): McporterConfig {
|
|
66
|
+
const mcpServers: Record<string, McporterServer> = {}
|
|
67
|
+
|
|
68
|
+
for (const [name, server] of Object.entries(servers)) {
|
|
69
|
+
if (server.command) {
|
|
70
|
+
mcpServers[name] = {
|
|
71
|
+
command: server.command,
|
|
72
|
+
args: server.args,
|
|
73
|
+
env: server.env,
|
|
74
|
+
headers: server.headers,
|
|
75
|
+
}
|
|
76
|
+
continue
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (server.url) {
|
|
80
|
+
mcpServers[name] = {
|
|
81
|
+
baseUrl: server.url,
|
|
82
|
+
headers: server.headers,
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return { mcpServers }
|
|
88
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import path from "path"
|
|
2
|
+
import { backupFile, copyDir, ensureDir, writeText } from "../utils/files"
|
|
3
|
+
import type { CodexBundle } from "../types/codex"
|
|
4
|
+
import type { ClaudeMcpServer } from "../types/claude"
|
|
5
|
+
|
|
6
|
+
export async function writeCodexBundle(outputRoot: string, bundle: CodexBundle): Promise<void> {
|
|
7
|
+
const codexRoot = resolveCodexRoot(outputRoot)
|
|
8
|
+
await ensureDir(codexRoot)
|
|
9
|
+
|
|
10
|
+
if (bundle.prompts.length > 0) {
|
|
11
|
+
const promptsDir = path.join(codexRoot, "prompts")
|
|
12
|
+
for (const prompt of bundle.prompts) {
|
|
13
|
+
await writeText(path.join(promptsDir, `${prompt.name}.md`), prompt.content + "\n")
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (bundle.skillDirs.length > 0) {
|
|
18
|
+
const skillsRoot = path.join(codexRoot, "skills")
|
|
19
|
+
for (const skill of bundle.skillDirs) {
|
|
20
|
+
await copyDir(skill.sourceDir, path.join(skillsRoot, skill.name))
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (bundle.generatedSkills.length > 0) {
|
|
25
|
+
const skillsRoot = path.join(codexRoot, "skills")
|
|
26
|
+
for (const skill of bundle.generatedSkills) {
|
|
27
|
+
await writeText(path.join(skillsRoot, skill.name, "SKILL.md"), skill.content + "\n")
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const config = renderCodexConfig(bundle.mcpServers)
|
|
32
|
+
if (config) {
|
|
33
|
+
const configPath = path.join(codexRoot, "config.toml")
|
|
34
|
+
const backupPath = await backupFile(configPath)
|
|
35
|
+
if (backupPath) {
|
|
36
|
+
console.log(`Backed up existing config to ${backupPath}`)
|
|
37
|
+
}
|
|
38
|
+
await writeText(configPath, config)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function resolveCodexRoot(outputRoot: string): string {
|
|
43
|
+
return path.basename(outputRoot) === ".codex" ? outputRoot : path.join(outputRoot, ".codex")
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function renderCodexConfig(mcpServers?: Record<string, ClaudeMcpServer>): string | null {
|
|
47
|
+
if (!mcpServers || Object.keys(mcpServers).length === 0) return null
|
|
48
|
+
|
|
49
|
+
const lines: string[] = ["# Generated by compound-plugin", ""]
|
|
50
|
+
|
|
51
|
+
for (const [name, server] of Object.entries(mcpServers)) {
|
|
52
|
+
const key = formatTomlKey(name)
|
|
53
|
+
lines.push(`[mcp_servers.${key}]`)
|
|
54
|
+
|
|
55
|
+
if (server.command) {
|
|
56
|
+
lines.push(`command = ${formatTomlString(server.command)}`)
|
|
57
|
+
if (server.args && server.args.length > 0) {
|
|
58
|
+
const args = server.args.map((arg) => formatTomlString(arg)).join(", ")
|
|
59
|
+
lines.push(`args = [${args}]`)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (server.env && Object.keys(server.env).length > 0) {
|
|
63
|
+
lines.push("")
|
|
64
|
+
lines.push(`[mcp_servers.${key}.env]`)
|
|
65
|
+
for (const [envKey, value] of Object.entries(server.env)) {
|
|
66
|
+
lines.push(`${formatTomlKey(envKey)} = ${formatTomlString(value)}`)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
} else if (server.url) {
|
|
70
|
+
lines.push(`url = ${formatTomlString(server.url)}`)
|
|
71
|
+
if (server.headers && Object.keys(server.headers).length > 0) {
|
|
72
|
+
lines.push(`http_headers = ${formatTomlInlineTable(server.headers)}`)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
lines.push("")
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return lines.join("\n")
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function formatTomlString(value: string): string {
|
|
83
|
+
return JSON.stringify(value)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function formatTomlKey(value: string): string {
|
|
87
|
+
if (/^[A-Za-z0-9_-]+$/.test(value)) return value
|
|
88
|
+
return JSON.stringify(value)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function formatTomlInlineTable(entries: Record<string, string>): string {
|
|
92
|
+
const parts = Object.entries(entries).map(
|
|
93
|
+
([key, value]) => `${formatTomlKey(key)} = ${formatTomlString(value)}`,
|
|
94
|
+
)
|
|
95
|
+
return `{ ${parts.join(", ")} }`
|
|
96
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ClaudePlugin } from "../types/claude"
|
|
2
|
+
import type { OpenCodeBundle } from "../types/opencode"
|
|
3
|
+
import type { CodexBundle } from "../types/codex"
|
|
4
|
+
import type { PiBundle } from "../types/pi"
|
|
5
|
+
import { convertClaudeToOpenCode, type ClaudeToOpenCodeOptions } from "../converters/claude-to-opencode"
|
|
6
|
+
import { convertClaudeToCodex } from "../converters/claude-to-codex"
|
|
7
|
+
import { convertClaudeToPi } from "../converters/claude-to-pi"
|
|
8
|
+
import { writeOpenCodeBundle } from "./opencode"
|
|
9
|
+
import { writeCodexBundle } from "./codex"
|
|
10
|
+
import { writePiBundle } from "./pi"
|
|
11
|
+
|
|
12
|
+
export type TargetHandler<TBundle = any> = {
|
|
13
|
+
name: string
|
|
14
|
+
implemented: boolean
|
|
15
|
+
convert: (plugin: ClaudePlugin, options: ClaudeToOpenCodeOptions) => TBundle | null
|
|
16
|
+
write: (outputRoot: string, bundle: TBundle) => Promise<void>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const targets: Record<string, TargetHandler> = {
|
|
20
|
+
opencode: {
|
|
21
|
+
name: "opencode",
|
|
22
|
+
implemented: true,
|
|
23
|
+
convert: convertClaudeToOpenCode,
|
|
24
|
+
write: writeOpenCodeBundle,
|
|
25
|
+
},
|
|
26
|
+
codex: {
|
|
27
|
+
name: "codex",
|
|
28
|
+
implemented: true,
|
|
29
|
+
convert: convertClaudeToCodex as TargetHandler<CodexBundle>["convert"],
|
|
30
|
+
write: writeCodexBundle as TargetHandler<CodexBundle>["write"],
|
|
31
|
+
},
|
|
32
|
+
pi: {
|
|
33
|
+
name: "pi",
|
|
34
|
+
implemented: true,
|
|
35
|
+
convert: convertClaudeToPi as TargetHandler<PiBundle>["convert"],
|
|
36
|
+
write: writePiBundle as TargetHandler<PiBundle>["write"],
|
|
37
|
+
},
|
|
38
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import path from "path"
|
|
2
|
+
import { backupFile, copyDir, ensureDir, writeJson, writeText } from "../utils/files"
|
|
3
|
+
import type { OpenCodeBundle } from "../types/opencode"
|
|
4
|
+
|
|
5
|
+
export async function writeOpenCodeBundle(outputRoot: string, bundle: OpenCodeBundle): Promise<void> {
|
|
6
|
+
const paths = resolveOpenCodePaths(outputRoot)
|
|
7
|
+
await ensureDir(paths.root)
|
|
8
|
+
|
|
9
|
+
const backupPath = await backupFile(paths.configPath)
|
|
10
|
+
if (backupPath) {
|
|
11
|
+
console.log(`Backed up existing config to ${backupPath}`)
|
|
12
|
+
}
|
|
13
|
+
await writeJson(paths.configPath, bundle.config)
|
|
14
|
+
|
|
15
|
+
const agentsDir = paths.agentsDir
|
|
16
|
+
for (const agent of bundle.agents) {
|
|
17
|
+
await writeText(path.join(agentsDir, `${agent.name}.md`), agent.content + "\n")
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (bundle.plugins.length > 0) {
|
|
21
|
+
const pluginsDir = paths.pluginsDir
|
|
22
|
+
for (const plugin of bundle.plugins) {
|
|
23
|
+
await writeText(path.join(pluginsDir, plugin.name), plugin.content + "\n")
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (bundle.skillDirs.length > 0) {
|
|
28
|
+
const skillsRoot = paths.skillsDir
|
|
29
|
+
for (const skill of bundle.skillDirs) {
|
|
30
|
+
await copyDir(skill.sourceDir, path.join(skillsRoot, skill.name))
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function resolveOpenCodePaths(outputRoot: string) {
|
|
36
|
+
const base = path.basename(outputRoot)
|
|
37
|
+
// Global install: ~/.config/opencode (basename is "opencode")
|
|
38
|
+
// Project install: .opencode (basename is ".opencode")
|
|
39
|
+
if (base === "opencode" || base === ".opencode") {
|
|
40
|
+
return {
|
|
41
|
+
root: outputRoot,
|
|
42
|
+
configPath: path.join(outputRoot, "opencode.json"),
|
|
43
|
+
agentsDir: path.join(outputRoot, "agents"),
|
|
44
|
+
pluginsDir: path.join(outputRoot, "plugins"),
|
|
45
|
+
skillsDir: path.join(outputRoot, "skills"),
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Custom output directory - nest under .opencode subdirectory
|
|
50
|
+
return {
|
|
51
|
+
root: outputRoot,
|
|
52
|
+
configPath: path.join(outputRoot, "opencode.json"),
|
|
53
|
+
agentsDir: path.join(outputRoot, ".opencode", "agents"),
|
|
54
|
+
pluginsDir: path.join(outputRoot, ".opencode", "plugins"),
|
|
55
|
+
skillsDir: path.join(outputRoot, ".opencode", "skills"),
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import path from "path"
|
|
2
|
+
import {
|
|
3
|
+
backupFile,
|
|
4
|
+
copyDir,
|
|
5
|
+
ensureDir,
|
|
6
|
+
pathExists,
|
|
7
|
+
readText,
|
|
8
|
+
writeJson,
|
|
9
|
+
writeText,
|
|
10
|
+
} from "../utils/files"
|
|
11
|
+
import type { PiBundle } from "../types/pi"
|
|
12
|
+
|
|
13
|
+
const PI_AGENTS_BLOCK_START = "<!-- BEGIN COMPOUND PI TOOL MAP -->"
|
|
14
|
+
const PI_AGENTS_BLOCK_END = "<!-- END COMPOUND PI TOOL MAP -->"
|
|
15
|
+
|
|
16
|
+
const PI_AGENTS_BLOCK_BODY = `## Compound Engineering (Pi compatibility)
|
|
17
|
+
|
|
18
|
+
This block is managed by compound-plugin.
|
|
19
|
+
|
|
20
|
+
Compatibility notes:
|
|
21
|
+
- Claude Task(agent, args) maps to the subagent extension tool
|
|
22
|
+
- For parallel agent runs, batch multiple subagent calls with multi_tool_use.parallel
|
|
23
|
+
- AskUserQuestion maps to the ask_user_question extension tool
|
|
24
|
+
- MCP access uses MCPorter via mcporter_list and mcporter_call extension tools
|
|
25
|
+
- MCPorter config path: .pi/compound-engineering/mcporter.json (project) or ~/.pi/agent/compound-engineering/mcporter.json (global)
|
|
26
|
+
`
|
|
27
|
+
|
|
28
|
+
export async function writePiBundle(outputRoot: string, bundle: PiBundle): Promise<void> {
|
|
29
|
+
const paths = resolvePiPaths(outputRoot)
|
|
30
|
+
|
|
31
|
+
await ensureDir(paths.skillsDir)
|
|
32
|
+
await ensureDir(paths.promptsDir)
|
|
33
|
+
await ensureDir(paths.extensionsDir)
|
|
34
|
+
|
|
35
|
+
for (const prompt of bundle.prompts) {
|
|
36
|
+
await writeText(path.join(paths.promptsDir, `${prompt.name}.md`), prompt.content + "\n")
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
for (const skill of bundle.skillDirs) {
|
|
40
|
+
await copyDir(skill.sourceDir, path.join(paths.skillsDir, skill.name))
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
for (const skill of bundle.generatedSkills) {
|
|
44
|
+
await writeText(path.join(paths.skillsDir, skill.name, "SKILL.md"), skill.content + "\n")
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
for (const extension of bundle.extensions) {
|
|
48
|
+
await writeText(path.join(paths.extensionsDir, extension.name), extension.content + "\n")
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (bundle.mcporterConfig) {
|
|
52
|
+
const backupPath = await backupFile(paths.mcporterConfigPath)
|
|
53
|
+
if (backupPath) {
|
|
54
|
+
console.log(`Backed up existing MCPorter config to ${backupPath}`)
|
|
55
|
+
}
|
|
56
|
+
await writeJson(paths.mcporterConfigPath, bundle.mcporterConfig)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
await ensurePiAgentsBlock(paths.agentsPath)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function resolvePiPaths(outputRoot: string) {
|
|
63
|
+
const base = path.basename(outputRoot)
|
|
64
|
+
|
|
65
|
+
// Global install root: ~/.pi/agent
|
|
66
|
+
if (base === "agent") {
|
|
67
|
+
return {
|
|
68
|
+
skillsDir: path.join(outputRoot, "skills"),
|
|
69
|
+
promptsDir: path.join(outputRoot, "prompts"),
|
|
70
|
+
extensionsDir: path.join(outputRoot, "extensions"),
|
|
71
|
+
mcporterConfigPath: path.join(outputRoot, "compound-engineering", "mcporter.json"),
|
|
72
|
+
agentsPath: path.join(outputRoot, "AGENTS.md"),
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Project local .pi directory
|
|
77
|
+
if (base === ".pi") {
|
|
78
|
+
return {
|
|
79
|
+
skillsDir: path.join(outputRoot, "skills"),
|
|
80
|
+
promptsDir: path.join(outputRoot, "prompts"),
|
|
81
|
+
extensionsDir: path.join(outputRoot, "extensions"),
|
|
82
|
+
mcporterConfigPath: path.join(outputRoot, "compound-engineering", "mcporter.json"),
|
|
83
|
+
agentsPath: path.join(outputRoot, "AGENTS.md"),
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Custom output root -> nest under .pi
|
|
88
|
+
return {
|
|
89
|
+
skillsDir: path.join(outputRoot, ".pi", "skills"),
|
|
90
|
+
promptsDir: path.join(outputRoot, ".pi", "prompts"),
|
|
91
|
+
extensionsDir: path.join(outputRoot, ".pi", "extensions"),
|
|
92
|
+
mcporterConfigPath: path.join(outputRoot, ".pi", "compound-engineering", "mcporter.json"),
|
|
93
|
+
agentsPath: path.join(outputRoot, "AGENTS.md"),
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function ensurePiAgentsBlock(filePath: string): Promise<void> {
|
|
98
|
+
const block = buildPiAgentsBlock()
|
|
99
|
+
|
|
100
|
+
if (!(await pathExists(filePath))) {
|
|
101
|
+
await writeText(filePath, block + "\n")
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const existing = await readText(filePath)
|
|
106
|
+
const updated = upsertBlock(existing, block)
|
|
107
|
+
if (updated !== existing) {
|
|
108
|
+
await writeText(filePath, updated)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function buildPiAgentsBlock(): string {
|
|
113
|
+
return [PI_AGENTS_BLOCK_START, PI_AGENTS_BLOCK_BODY.trim(), PI_AGENTS_BLOCK_END].join("\n")
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function upsertBlock(existing: string, block: string): string {
|
|
117
|
+
const startIndex = existing.indexOf(PI_AGENTS_BLOCK_START)
|
|
118
|
+
const endIndex = existing.indexOf(PI_AGENTS_BLOCK_END)
|
|
119
|
+
|
|
120
|
+
if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) {
|
|
121
|
+
const before = existing.slice(0, startIndex).trimEnd()
|
|
122
|
+
const after = existing.slice(endIndex + PI_AGENTS_BLOCK_END.length).trimStart()
|
|
123
|
+
return [before, block, after].filter(Boolean).join("\n\n") + "\n"
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (existing.trim().length === 0) {
|
|
127
|
+
return block + "\n"
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return existing.trimEnd() + "\n\n" + block + "\n"
|
|
131
|
+
}
|