@mengde1231/rudder 0.5.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 +235 -0
- package/README.md +136 -0
- package/bin/rudder.js +3 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +132 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/commands/init.d.ts +57 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +1465 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/uninstall.d.ts +27 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +322 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/commands/update.d.ts +72 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +1911 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/configurators/antigravity.d.ts +7 -0
- package/dist/configurators/antigravity.d.ts.map +1 -0
- package/dist/configurators/antigravity.js +19 -0
- package/dist/configurators/antigravity.js.map +1 -0
- package/dist/configurators/claude.d.ts +9 -0
- package/dist/configurators/claude.d.ts.map +1 -0
- package/dist/configurators/claude.js +69 -0
- package/dist/configurators/claude.js.map +1 -0
- package/dist/configurators/codebuddy.d.ts +10 -0
- package/dist/configurators/codebuddy.d.ts.map +1 -0
- package/dist/configurators/codebuddy.js +30 -0
- package/dist/configurators/codebuddy.js.map +1 -0
- package/dist/configurators/codex.d.ts +8 -0
- package/dist/configurators/codex.d.ts.map +1 -0
- package/dist/configurators/codex.js +85 -0
- package/dist/configurators/codex.js.map +1 -0
- package/dist/configurators/copilot.d.ts +10 -0
- package/dist/configurators/copilot.d.ts.map +1 -0
- package/dist/configurators/copilot.js +51 -0
- package/dist/configurators/copilot.js.map +1 -0
- package/dist/configurators/cursor.d.ts +10 -0
- package/dist/configurators/cursor.d.ts.map +1 -0
- package/dist/configurators/cursor.js +29 -0
- package/dist/configurators/cursor.js.map +1 -0
- package/dist/configurators/droid.d.ts +10 -0
- package/dist/configurators/droid.d.ts.map +1 -0
- package/dist/configurators/droid.js +30 -0
- package/dist/configurators/droid.js.map +1 -0
- package/dist/configurators/gemini.d.ts +16 -0
- package/dist/configurators/gemini.d.ts.map +1 -0
- package/dist/configurators/gemini.js +38 -0
- package/dist/configurators/gemini.js.map +1 -0
- package/dist/configurators/index.d.ts +65 -0
- package/dist/configurators/index.d.ts.map +1 -0
- package/dist/configurators/index.js +367 -0
- package/dist/configurators/index.js.map +1 -0
- package/dist/configurators/kilo.d.ts +7 -0
- package/dist/configurators/kilo.d.ts.map +1 -0
- package/dist/configurators/kilo.js +19 -0
- package/dist/configurators/kilo.js.map +1 -0
- package/dist/configurators/kiro.d.ts +8 -0
- package/dist/configurators/kiro.d.ts.map +1 -0
- package/dist/configurators/kiro.js +24 -0
- package/dist/configurators/kiro.js.map +1 -0
- package/dist/configurators/opencode.d.ts +14 -0
- package/dist/configurators/opencode.d.ts.map +1 -0
- package/dist/configurators/opencode.js +96 -0
- package/dist/configurators/opencode.js.map +1 -0
- package/dist/configurators/pi.d.ts +3 -0
- package/dist/configurators/pi.d.ts.map +1 -0
- package/dist/configurators/pi.js +45 -0
- package/dist/configurators/pi.js.map +1 -0
- package/dist/configurators/qoder.d.ts +11 -0
- package/dist/configurators/qoder.d.ts.map +1 -0
- package/dist/configurators/qoder.js +31 -0
- package/dist/configurators/qoder.js.map +1 -0
- package/dist/configurators/shared.d.ts +178 -0
- package/dist/configurators/shared.d.ts.map +1 -0
- package/dist/configurators/shared.js +546 -0
- package/dist/configurators/shared.js.map +1 -0
- package/dist/configurators/windsurf.d.ts +7 -0
- package/dist/configurators/windsurf.d.ts.map +1 -0
- package/dist/configurators/windsurf.js +19 -0
- package/dist/configurators/windsurf.js.map +1 -0
- package/dist/configurators/workflow.d.ts +34 -0
- package/dist/configurators/workflow.d.ts.map +1 -0
- package/dist/configurators/workflow.js +178 -0
- package/dist/configurators/workflow.js.map +1 -0
- package/dist/constants/paths.d.ts +70 -0
- package/dist/constants/paths.d.ts.map +1 -0
- package/dist/constants/paths.js +79 -0
- package/dist/constants/paths.js.map +1 -0
- package/dist/constants/version.d.ts +9 -0
- package/dist/constants/version.d.ts.map +1 -0
- package/dist/constants/version.js +15 -0
- package/dist/constants/version.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/index.d.ts +62 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +187 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/manifests/0.1.9.json +30 -0
- package/dist/migrations/manifests/0.2.0.json +49 -0
- package/dist/migrations/manifests/0.2.12.json +9 -0
- package/dist/migrations/manifests/0.2.13.json +9 -0
- package/dist/migrations/manifests/0.2.14.json +175 -0
- package/dist/migrations/manifests/0.2.15.json +33 -0
- package/dist/migrations/manifests/0.3.0-beta.0.json +297 -0
- package/dist/migrations/manifests/0.3.0-beta.1.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.10.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.11.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.12.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.13.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.14.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.15.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.16.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.2.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.3.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.4.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.5.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.6.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.7.json +11 -0
- package/dist/migrations/manifests/0.3.0-beta.8.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.9.json +9 -0
- package/dist/migrations/manifests/0.3.0-rc.0.json +9 -0
- package/dist/migrations/manifests/0.3.0-rc.1.json +9 -0
- package/dist/migrations/manifests/0.3.0-rc.2.json +9 -0
- package/dist/migrations/manifests/0.3.0-rc.3.json +9 -0
- package/dist/migrations/manifests/0.3.0-rc.4.json +9 -0
- package/dist/migrations/manifests/0.3.0-rc.5.json +9 -0
- package/dist/migrations/manifests/0.3.0-rc.6.json +9 -0
- package/dist/migrations/manifests/0.3.0.json +11 -0
- package/dist/migrations/manifests/0.3.1.json +9 -0
- package/dist/migrations/manifests/0.3.10.json +9 -0
- package/dist/migrations/manifests/0.3.2.json +9 -0
- package/dist/migrations/manifests/0.3.3.json +9 -0
- package/dist/migrations/manifests/0.3.4.json +21 -0
- package/dist/migrations/manifests/0.3.5.json +9 -0
- package/dist/migrations/manifests/0.3.6.json +9 -0
- package/dist/migrations/manifests/0.3.7.json +9 -0
- package/dist/migrations/manifests/0.3.8.json +9 -0
- package/dist/migrations/manifests/0.3.9.json +9 -0
- package/dist/migrations/manifests/0.4.0-beta.1.json +228 -0
- package/dist/migrations/manifests/0.4.0-beta.10.json +9 -0
- package/dist/migrations/manifests/0.4.0-beta.2.json +9 -0
- package/dist/migrations/manifests/0.4.0-beta.3.json +9 -0
- package/dist/migrations/manifests/0.4.0-beta.4.json +9 -0
- package/dist/migrations/manifests/0.4.0-beta.5.json +9 -0
- package/dist/migrations/manifests/0.4.0-beta.6.json +9 -0
- package/dist/migrations/manifests/0.4.0-beta.7.json +9 -0
- package/dist/migrations/manifests/0.4.0-beta.8.json +34 -0
- package/dist/migrations/manifests/0.4.0-beta.9.json +9 -0
- package/dist/migrations/manifests/0.4.0-rc.0.json +9 -0
- package/dist/migrations/manifests/0.4.0-rc.1.json +9 -0
- package/dist/migrations/manifests/0.4.0.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.0.json +1646 -0
- package/dist/migrations/manifests/0.5.0-beta.1.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.10.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.11.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.12.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.13.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.14.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.15.json +116 -0
- package/dist/migrations/manifests/0.5.0-beta.16.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.17.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.18.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.19.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.2.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.3.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.4.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.5.json +222 -0
- package/dist/migrations/manifests/0.5.0-beta.6.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.7.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.8.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.9.json +48 -0
- package/dist/migrations/manifests/0.5.0-rc.0.json +9 -0
- package/dist/migrations/manifests/0.5.0-rc.1.json +9 -0
- package/dist/migrations/manifests/0.5.0-rc.2.json +9 -0
- package/dist/migrations/manifests/0.5.0-rc.3.json +9 -0
- package/dist/migrations/manifests/0.5.0-rc.4.json +9 -0
- package/dist/migrations/manifests/0.5.0-rc.5.json +9 -0
- package/dist/migrations/manifests/0.5.0-rc.6.json +9 -0
- package/dist/migrations/manifests/0.5.0-rc.7.json +9 -0
- package/dist/migrations/manifests/0.5.0.json +9 -0
- package/dist/migrations/manifests/0.5.1.json +9 -0
- package/dist/migrations/manifests/0.5.10.json +9 -0
- package/dist/migrations/manifests/0.5.11.json +16 -0
- package/dist/migrations/manifests/0.5.12.json +9 -0
- package/dist/migrations/manifests/0.5.13.json +9 -0
- package/dist/migrations/manifests/0.5.2.json +9 -0
- package/dist/migrations/manifests/0.5.3.json +9 -0
- package/dist/migrations/manifests/0.5.4.json +9 -0
- package/dist/migrations/manifests/0.5.5.json +9 -0
- package/dist/migrations/manifests/0.5.6.json +9 -0
- package/dist/migrations/manifests/0.5.7.json +16 -0
- package/dist/migrations/manifests/0.5.8.json +9 -0
- package/dist/migrations/manifests/0.5.9.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.0.json +16 -0
- package/dist/migrations/manifests/0.6.0-beta.1.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.2.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.3.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.4.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.5.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.6.json +16 -0
- package/dist/migrations/manifests/0.6.0-beta.7.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.8.json +9 -0
- package/dist/templates/claude/agents/rudder-check.md +143 -0
- package/dist/templates/claude/agents/rudder-implement.md +109 -0
- package/dist/templates/claude/agents/rudder-research.md +137 -0
- package/dist/templates/claude/index.d.ts +22 -0
- package/dist/templates/claude/index.d.ts.map +1 -0
- package/dist/templates/claude/index.js +46 -0
- package/dist/templates/claude/index.js.map +1 -0
- package/dist/templates/claude/settings.json +73 -0
- package/dist/templates/codebuddy/agents/rudder-check.md +143 -0
- package/dist/templates/codebuddy/agents/rudder-implement.md +109 -0
- package/dist/templates/codebuddy/agents/rudder-research.md +137 -0
- package/dist/templates/codebuddy/index.d.ts +15 -0
- package/dist/templates/codebuddy/index.d.ts.map +1 -0
- package/dist/templates/codebuddy/index.js +15 -0
- package/dist/templates/codebuddy/index.js.map +1 -0
- package/dist/templates/codebuddy/settings.json +59 -0
- package/dist/templates/codex/agents/rudder-check.toml +91 -0
- package/dist/templates/codex/agents/rudder-implement.toml +65 -0
- package/dist/templates/codex/agents/rudder-research.toml +73 -0
- package/dist/templates/codex/config.toml +35 -0
- package/dist/templates/codex/hooks/session-start.py +459 -0
- package/dist/templates/codex/hooks.json +15 -0
- package/dist/templates/codex/index.d.ts +39 -0
- package/dist/templates/codex/index.d.ts.map +1 -0
- package/dist/templates/codex/index.js +85 -0
- package/dist/templates/codex/index.js.map +1 -0
- package/dist/templates/codex/skills/before-dev/SKILL.md +34 -0
- package/dist/templates/codex/skills/brainstorm/SKILL.md +500 -0
- package/dist/templates/codex/skills/break-loop/SKILL.md +130 -0
- package/dist/templates/codex/skills/check/SKILL.md +30 -0
- package/dist/templates/codex/skills/check-cross-layer/SKILL.md +158 -0
- package/dist/templates/codex/skills/create-command/SKILL.md +101 -0
- package/dist/templates/codex/skills/finish-work/SKILL.md +90 -0
- package/dist/templates/codex/skills/improve-ut/SKILL.md +69 -0
- package/dist/templates/codex/skills/integrate-skill/SKILL.md +221 -0
- package/dist/templates/codex/skills/onboard/SKILL.md +363 -0
- package/dist/templates/codex/skills/record-session/SKILL.md +67 -0
- package/dist/templates/codex/skills/start/SKILL.md +354 -0
- package/dist/templates/codex/skills/update-spec/SKILL.md +335 -0
- package/dist/templates/common/bundled-skills/rudder-meta/SKILL.md +73 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/customize-local/add-project-local-conventions.md +83 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/customize-local/change-agents.md +54 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/customize-local/change-context-loading.md +81 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/customize-local/change-hooks.md +57 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/customize-local/change-skills-or-commands.md +78 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/customize-local/change-spec-structure.md +83 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/customize-local/change-task-lifecycle.md +90 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/customize-local/change-workflow.md +64 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/customize-local/overview.md +55 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/local-architecture/context-injection.md +68 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/local-architecture/generated-files.md +80 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/local-architecture/overview.md +51 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/local-architecture/spec-system.md +102 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/local-architecture/task-system.md +101 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/local-architecture/workflow.md +75 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/local-architecture/workspace-memory.md +71 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/platform-files/agents.md +79 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/platform-files/hooks-and-settings.md +69 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/platform-files/overview.md +59 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/platform-files/platform-map.md +74 -0
- package/dist/templates/common/bundled-skills/rudder-meta/references/platform-files/skills-and-commands.md +83 -0
- package/dist/templates/common/commands/continue.md +55 -0
- package/dist/templates/common/commands/finish-work.md +66 -0
- package/dist/templates/common/commands/start.md +58 -0
- package/dist/templates/common/index.d.ts +48 -0
- package/dist/templates/common/index.d.ts.map +1 -0
- package/dist/templates/common/index.js +104 -0
- package/dist/templates/common/index.js.map +1 -0
- package/dist/templates/common/skills/before-dev.md +29 -0
- package/dist/templates/common/skills/brainstorm.md +543 -0
- package/dist/templates/common/skills/break-loop.md +125 -0
- package/dist/templates/common/skills/check.md +87 -0
- package/dist/templates/common/skills/update-spec.md +351 -0
- package/dist/templates/copilot/hooks/session-start.py +430 -0
- package/dist/templates/copilot/hooks.json +19 -0
- package/dist/templates/copilot/index.d.ts +23 -0
- package/dist/templates/copilot/index.d.ts.map +1 -0
- package/dist/templates/copilot/index.js +54 -0
- package/dist/templates/copilot/index.js.map +1 -0
- package/dist/templates/copilot/prompts/before-dev.prompt.md +33 -0
- package/dist/templates/copilot/prompts/brainstorm.prompt.md +499 -0
- package/dist/templates/copilot/prompts/break-loop.prompt.md +129 -0
- package/dist/templates/copilot/prompts/check-cross-layer.prompt.md +157 -0
- package/dist/templates/copilot/prompts/check.prompt.md +29 -0
- package/dist/templates/copilot/prompts/create-command.prompt.md +116 -0
- package/dist/templates/copilot/prompts/finish-work.prompt.md +99 -0
- package/dist/templates/copilot/prompts/integrate-skill.prompt.md +223 -0
- package/dist/templates/copilot/prompts/onboard.prompt.md +362 -0
- package/dist/templates/copilot/prompts/parallel.prompt.md +196 -0
- package/dist/templates/copilot/prompts/record-session.prompt.md +66 -0
- package/dist/templates/copilot/prompts/start.prompt.md +397 -0
- package/dist/templates/copilot/prompts/update-spec.prompt.md +358 -0
- package/dist/templates/cursor/agents/rudder-check.md +142 -0
- package/dist/templates/cursor/agents/rudder-implement.md +108 -0
- package/dist/templates/cursor/agents/rudder-research.md +136 -0
- package/dist/templates/cursor/hooks.json +24 -0
- package/dist/templates/cursor/index.d.ts +13 -0
- package/dist/templates/cursor/index.d.ts.map +1 -0
- package/dist/templates/cursor/index.js +13 -0
- package/dist/templates/cursor/index.js.map +1 -0
- package/dist/templates/droid/droids/rudder-check.md +135 -0
- package/dist/templates/droid/droids/rudder-implement.md +101 -0
- package/dist/templates/droid/droids/rudder-research.md +137 -0
- package/dist/templates/droid/index.d.ts +15 -0
- package/dist/templates/droid/index.d.ts.map +1 -0
- package/dist/templates/droid/index.js +15 -0
- package/dist/templates/droid/index.js.map +1 -0
- package/dist/templates/droid/settings.json +59 -0
- package/dist/templates/extract.d.ts +40 -0
- package/dist/templates/extract.d.ts.map +1 -0
- package/dist/templates/extract.js +106 -0
- package/dist/templates/extract.js.map +1 -0
- package/dist/templates/gemini/agents/rudder-check.md +135 -0
- package/dist/templates/gemini/agents/rudder-implement.md +101 -0
- package/dist/templates/gemini/agents/rudder-research.md +136 -0
- package/dist/templates/gemini/index.d.ts +13 -0
- package/dist/templates/gemini/index.d.ts.map +1 -0
- package/dist/templates/gemini/index.js +13 -0
- package/dist/templates/gemini/index.js.map +1 -0
- package/dist/templates/gemini/settings.json +28 -0
- package/dist/templates/kiro/agents/rudder-check.json +26 -0
- package/dist/templates/kiro/agents/rudder-implement.json +26 -0
- package/dist/templates/kiro/agents/rudder-research.json +30 -0
- package/dist/templates/kiro/index.d.ts +18 -0
- package/dist/templates/kiro/index.d.ts.map +1 -0
- package/dist/templates/kiro/index.js +18 -0
- package/dist/templates/kiro/index.js.map +1 -0
- package/dist/templates/markdown/agents.md +21 -0
- package/dist/templates/markdown/gitignore.txt +15 -0
- package/dist/templates/markdown/index.d.ts +27 -0
- package/dist/templates/markdown/index.d.ts.map +1 -0
- package/dist/templates/markdown/index.js +52 -0
- package/dist/templates/markdown/index.js.map +1 -0
- package/dist/templates/markdown/spec/backend/database-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/backend/directory-structure.md.txt +54 -0
- package/dist/templates/markdown/spec/backend/error-handling.md.txt +51 -0
- package/dist/templates/markdown/spec/backend/index.md.txt +38 -0
- package/dist/templates/markdown/spec/backend/logging-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/backend/quality-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/frontend/component-guidelines.md.txt +59 -0
- package/dist/templates/markdown/spec/frontend/directory-structure.md.txt +54 -0
- package/dist/templates/markdown/spec/frontend/hook-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/frontend/index.md.txt +39 -0
- package/dist/templates/markdown/spec/frontend/quality-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/frontend/state-management.md.txt +51 -0
- package/dist/templates/markdown/spec/frontend/type-safety.md.txt +51 -0
- package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md.txt +105 -0
- package/dist/templates/markdown/spec/guides/cross-layer-thinking-guide.md.txt +162 -0
- package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +595 -0
- package/dist/templates/markdown/spec/guides/index.md.txt +79 -0
- package/dist/templates/markdown/workspace-index.md +125 -0
- package/dist/templates/markdown/worktree.yaml.txt +58 -0
- package/dist/templates/opencode/agents/rudder-check.md +150 -0
- package/dist/templates/opencode/agents/rudder-implement.md +117 -0
- package/dist/templates/opencode/agents/rudder-research.md +145 -0
- package/dist/templates/opencode/lib/rudder-context.js +381 -0
- package/dist/templates/opencode/lib/session-utils.js +432 -0
- package/dist/templates/opencode/package.json +5 -0
- package/dist/templates/opencode/plugins/inject-subagent-context.js +497 -0
- package/dist/templates/opencode/plugins/inject-workflow-state.js +162 -0
- package/dist/templates/opencode/plugins/session-start.js +101 -0
- package/dist/templates/pi/agents/rudder-check.md +103 -0
- package/dist/templates/pi/agents/rudder-implement.md +41 -0
- package/dist/templates/pi/agents/rudder-research.md +25 -0
- package/dist/templates/pi/extensions/rudder/index.ts.txt +1172 -0
- package/dist/templates/pi/index.d.ts +5 -0
- package/dist/templates/pi/index.d.ts.map +1 -0
- package/dist/templates/pi/index.js +12 -0
- package/dist/templates/pi/index.js.map +1 -0
- package/dist/templates/pi/settings.json +21 -0
- package/dist/templates/qoder/agents/rudder-check.md +136 -0
- package/dist/templates/qoder/agents/rudder-implement.md +102 -0
- package/dist/templates/qoder/agents/rudder-research.md +137 -0
- package/dist/templates/qoder/index.d.ts +15 -0
- package/dist/templates/qoder/index.d.ts.map +1 -0
- package/dist/templates/qoder/index.js +15 -0
- package/dist/templates/qoder/index.js.map +1 -0
- package/dist/templates/qoder/settings.json +47 -0
- package/dist/templates/rudder/config.yaml +131 -0
- package/dist/templates/rudder/config_local.yml +17 -0
- package/dist/templates/rudder/gitignore.txt +35 -0
- package/dist/templates/rudder/index.d.ts +53 -0
- package/dist/templates/rudder/index.d.ts.map +1 -0
- package/dist/templates/rudder/index.js +98 -0
- package/dist/templates/rudder/index.js.map +1 -0
- package/dist/templates/rudder/scripts/__init__.py +5 -0
- package/dist/templates/rudder/scripts/add_session.py +547 -0
- package/dist/templates/rudder/scripts/common/__init__.py +92 -0
- package/dist/templates/rudder/scripts/common/active_task.py +626 -0
- package/dist/templates/rudder/scripts/common/cli_adapter.py +811 -0
- package/dist/templates/rudder/scripts/common/config.py +532 -0
- package/dist/templates/rudder/scripts/common/developer.py +190 -0
- package/dist/templates/rudder/scripts/common/git.py +31 -0
- package/dist/templates/rudder/scripts/common/git_context.py +106 -0
- package/dist/templates/rudder/scripts/common/io.py +37 -0
- package/dist/templates/rudder/scripts/common/log.py +45 -0
- package/dist/templates/rudder/scripts/common/packages_context.py +238 -0
- package/dist/templates/rudder/scripts/common/paths.py +447 -0
- package/dist/templates/rudder/scripts/common/rudder_config.py +201 -0
- package/dist/templates/rudder/scripts/common/safe_commit.py +255 -0
- package/dist/templates/rudder/scripts/common/session_context.py +839 -0
- package/dist/templates/rudder/scripts/common/task_context.py +223 -0
- package/dist/templates/rudder/scripts/common/task_queue.py +188 -0
- package/dist/templates/rudder/scripts/common/task_store.py +636 -0
- package/dist/templates/rudder/scripts/common/task_utils.py +274 -0
- package/dist/templates/rudder/scripts/common/tasks.py +112 -0
- package/dist/templates/rudder/scripts/common/types.py +110 -0
- package/dist/templates/rudder/scripts/common/workflow_phase.py +215 -0
- package/dist/templates/rudder/scripts/get_context.py +16 -0
- package/dist/templates/rudder/scripts/get_developer.py +26 -0
- package/dist/templates/rudder/scripts/hooks/linear_sync.py +243 -0
- package/dist/templates/rudder/scripts/init_developer.py +51 -0
- package/dist/templates/rudder/scripts/task.py +500 -0
- package/dist/templates/rudder/tasks/.gitkeep +0 -0
- package/dist/templates/rudder/workflow.md +710 -0
- package/dist/templates/shared-hooks/index.d.ts +50 -0
- package/dist/templates/shared-hooks/index.d.ts.map +1 -0
- package/dist/templates/shared-hooks/index.js +88 -0
- package/dist/templates/shared-hooks/index.js.map +1 -0
- package/dist/templates/shared-hooks/inject-shell-session-context.py +183 -0
- package/dist/templates/shared-hooks/inject-subagent-context.py +749 -0
- package/dist/templates/shared-hooks/inject-workflow-state.py +404 -0
- package/dist/templates/shared-hooks/session-start.py +827 -0
- package/dist/templates/template-utils.d.ts +26 -0
- package/dist/templates/template-utils.d.ts.map +1 -0
- package/dist/templates/template-utils.js +60 -0
- package/dist/templates/template-utils.js.map +1 -0
- package/dist/types/ai-tools.d.ts +95 -0
- package/dist/types/ai-tools.d.ts.map +1 -0
- package/dist/types/ai-tools.js +280 -0
- package/dist/types/ai-tools.js.map +1 -0
- package/dist/types/migration.d.ts +125 -0
- package/dist/types/migration.d.ts.map +1 -0
- package/dist/types/migration.js +8 -0
- package/dist/types/migration.js.map +1 -0
- package/dist/utils/compare-versions.d.ts +12 -0
- package/dist/utils/compare-versions.d.ts.map +1 -0
- package/dist/utils/compare-versions.js +86 -0
- package/dist/utils/compare-versions.js.map +1 -0
- package/dist/utils/file-writer.d.ts +23 -0
- package/dist/utils/file-writer.d.ts.map +1 -0
- package/dist/utils/file-writer.js +145 -0
- package/dist/utils/file-writer.js.map +1 -0
- package/dist/utils/posix.d.ts +13 -0
- package/dist/utils/posix.d.ts.map +1 -0
- package/dist/utils/posix.js +15 -0
- package/dist/utils/posix.js.map +1 -0
- package/dist/utils/project-detector.d.ts +46 -0
- package/dist/utils/project-detector.d.ts.map +1 -0
- package/dist/utils/project-detector.js +666 -0
- package/dist/utils/project-detector.js.map +1 -0
- package/dist/utils/proxy.d.ts +25 -0
- package/dist/utils/proxy.d.ts.map +1 -0
- package/dist/utils/proxy.js +60 -0
- package/dist/utils/proxy.js.map +1 -0
- package/dist/utils/task-json.d.ts +46 -0
- package/dist/utils/task-json.d.ts.map +1 -0
- package/dist/utils/task-json.js +49 -0
- package/dist/utils/task-json.js.map +1 -0
- package/dist/utils/template-fetcher.d.ts +150 -0
- package/dist/utils/template-fetcher.d.ts.map +1 -0
- package/dist/utils/template-fetcher.js +907 -0
- package/dist/utils/template-fetcher.js.map +1 -0
- package/dist/utils/template-hash.d.ts +112 -0
- package/dist/utils/template-hash.d.ts.map +1 -0
- package/dist/utils/template-hash.js +343 -0
- package/dist/utils/template-hash.js.map +1 -0
- package/dist/utils/trellis-migrate.d.ts +45 -0
- package/dist/utils/trellis-migrate.d.ts.map +1 -0
- package/dist/utils/trellis-migrate.js +240 -0
- package/dist/utils/trellis-migrate.js.map +1 -0
- package/dist/utils/uninstall-scrubbers.d.ts +66 -0
- package/dist/utils/uninstall-scrubbers.d.ts.map +1 -0
- package/dist/utils/uninstall-scrubbers.js +342 -0
- package/dist/utils/uninstall-scrubbers.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,1465 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import readline from "node:readline";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import figlet from "figlet";
|
|
7
|
+
import inquirer from "inquirer";
|
|
8
|
+
import { createWorkflowStructure } from "../configurators/workflow.js";
|
|
9
|
+
import { getInitToolChoices, resolveCliFlag, configurePlatform, getConfiguredPlatforms, getPlatformsWithPythonHooks, } from "../configurators/index.js";
|
|
10
|
+
import { getPythonCommandForPlatform, setResolvedPythonCommand, } from "../configurators/shared.js";
|
|
11
|
+
import { AI_TOOLS } from "../types/ai-tools.js";
|
|
12
|
+
import { DIR_NAMES, FILE_NAMES, PATHS } from "../constants/paths.js";
|
|
13
|
+
import { VERSION } from "../constants/version.js";
|
|
14
|
+
import { agentsMdContent } from "../templates/markdown/index.js";
|
|
15
|
+
import { setWriteMode, writeFile, } from "../utils/file-writer.js";
|
|
16
|
+
import { emptyTaskJson } from "../utils/task-json.js";
|
|
17
|
+
import { detectProjectType, detectMonorepo, sanitizePkgName, } from "../utils/project-detector.js";
|
|
18
|
+
import { initializeHashes } from "../utils/template-hash.js";
|
|
19
|
+
import { fetchTemplateIndex, probeRegistryIndex, downloadTemplateById, downloadRegistryDirect, parseRegistrySource, TIMEOUTS, TEMPLATE_INDEX_URL, } from "../utils/template-fetcher.js";
|
|
20
|
+
import { setupProxy, maskProxyUrl } from "../utils/proxy.js";
|
|
21
|
+
import { migrateFromTrellis } from "../utils/trellis-migrate.js";
|
|
22
|
+
const MIN_PYTHON_MAJOR = 3;
|
|
23
|
+
const MIN_PYTHON_MINOR = 9;
|
|
24
|
+
const PYTHON_VERSION_RE = /Python (\d+)\.(\d+)/;
|
|
25
|
+
export function isSupportedPythonVersion(versionOutput) {
|
|
26
|
+
const match = versionOutput.match(PYTHON_VERSION_RE);
|
|
27
|
+
if (!match)
|
|
28
|
+
return false;
|
|
29
|
+
const major = Number(match[1]);
|
|
30
|
+
const minor = Number(match[2]);
|
|
31
|
+
return (major > MIN_PYTHON_MAJOR ||
|
|
32
|
+
(major === MIN_PYTHON_MAJOR && minor >= MIN_PYTHON_MINOR));
|
|
33
|
+
}
|
|
34
|
+
function detectPythonVersion(command) {
|
|
35
|
+
try {
|
|
36
|
+
return execSync(`${command} --version`, {
|
|
37
|
+
encoding: "utf-8",
|
|
38
|
+
stdio: "pipe",
|
|
39
|
+
}).trim();
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
const code = err?.code;
|
|
43
|
+
if (code === "EPERM" || code === "EACCES") {
|
|
44
|
+
return "sandbox-restricted";
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function requireSupportedPython(command) {
|
|
50
|
+
// Final escape hatch — set when the user knows python3 is on PATH but
|
|
51
|
+
// the probe keeps failing for environment-specific reasons.
|
|
52
|
+
if (process.env.RUDDER_SKIP_PYTHON_CHECK === "1") {
|
|
53
|
+
return `version check skipped (RUDDER_SKIP_PYTHON_CHECK=1)`;
|
|
54
|
+
}
|
|
55
|
+
const versionOutput = detectPythonVersion(command);
|
|
56
|
+
if (versionOutput === "sandbox-restricted") {
|
|
57
|
+
console.warn(chalk.yellow(`⚠ Python version check skipped — sandboxed environment blocked ` +
|
|
58
|
+
`child_process spawn (EPERM/EACCES). Assuming "${command}" is on ` +
|
|
59
|
+
`PATH. If init fails later, re-run on the host or set ` +
|
|
60
|
+
`RUDDER_SKIP_PYTHON_CHECK=1.`));
|
|
61
|
+
return `version unknown (sandbox-restricted)`;
|
|
62
|
+
}
|
|
63
|
+
if (!versionOutput) {
|
|
64
|
+
throw new Error(`Python command "${command}" not found. Rudder init requires Python ≥ 3.9.`);
|
|
65
|
+
}
|
|
66
|
+
if (!isSupportedPythonVersion(versionOutput)) {
|
|
67
|
+
throw new Error(`${versionOutput} detected via "${command}", but Rudder init requires Python ≥ 3.9.`);
|
|
68
|
+
}
|
|
69
|
+
return versionOutput;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Candidate Python command list per platform.
|
|
73
|
+
*
|
|
74
|
+
* Windows: `python` is the usual python.org installer choice, but Microsoft
|
|
75
|
+
* Store ships `python3`, and the `py` launcher is `py -3`. We try all three
|
|
76
|
+
* before giving up — fixes #236 where users with only `python3` (not
|
|
77
|
+
* `python`) had `rudder init` fail outright.
|
|
78
|
+
*
|
|
79
|
+
* Non-Windows: `python3` is canonical; `python` is a fallback for systems
|
|
80
|
+
* where Python 3 is the only Python and is named `python` (some Arch
|
|
81
|
+
* configs, conda envs).
|
|
82
|
+
*/
|
|
83
|
+
const PYTHON_CANDIDATES = {
|
|
84
|
+
win32: ["python", "python3", "py -3"],
|
|
85
|
+
other: ["python3", "python"],
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Detect a working Python ≥ 3.9 command on the host platform.
|
|
89
|
+
*
|
|
90
|
+
* Honors `RUDDER_PYTHON_CMD` (explicit override, no probe) and
|
|
91
|
+
* `RUDDER_SKIP_PYTHON_CHECK=1` (skip probe, trust platform default).
|
|
92
|
+
*
|
|
93
|
+
* Otherwise tries each candidate in `PYTHON_CANDIDATES` in order and returns
|
|
94
|
+
* the first whose `--version` matches `Python ≥ 3.9`. Caches the result via
|
|
95
|
+
* `setResolvedPythonCommand` so all downstream template / configurator
|
|
96
|
+
* writes pick up the resolved value.
|
|
97
|
+
*
|
|
98
|
+
* Throws a helpful, Windows-aware error if no candidate works.
|
|
99
|
+
*/
|
|
100
|
+
export function resolveSupportedPython() {
|
|
101
|
+
// Explicit override — user knows their environment.
|
|
102
|
+
const override = process.env.RUDDER_PYTHON_CMD?.trim();
|
|
103
|
+
if (override) {
|
|
104
|
+
setResolvedPythonCommand(override);
|
|
105
|
+
return { command: override, version: "set via RUDDER_PYTHON_CMD" };
|
|
106
|
+
}
|
|
107
|
+
// Skip probe entirely.
|
|
108
|
+
if (process.env.RUDDER_SKIP_PYTHON_CHECK === "1") {
|
|
109
|
+
const fallback = getPythonCommandForPlatform();
|
|
110
|
+
setResolvedPythonCommand(fallback);
|
|
111
|
+
return {
|
|
112
|
+
command: fallback,
|
|
113
|
+
version: "version check skipped (RUDDER_SKIP_PYTHON_CHECK=1)",
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const candidates = process.platform === "win32"
|
|
117
|
+
? PYTHON_CANDIDATES.win32
|
|
118
|
+
: PYTHON_CANDIDATES.other;
|
|
119
|
+
const probeFailures = [];
|
|
120
|
+
for (const candidate of candidates) {
|
|
121
|
+
const probe = detectPythonVersion(candidate);
|
|
122
|
+
if (probe === "sandbox-restricted") {
|
|
123
|
+
console.warn(chalk.yellow(`⚠ Python version check skipped — sandboxed environment blocked ` +
|
|
124
|
+
`child_process spawn (EPERM/EACCES). Assuming "${candidate}" is ` +
|
|
125
|
+
`on PATH. If init fails later, re-run on the host or set ` +
|
|
126
|
+
`RUDDER_SKIP_PYTHON_CHECK=1.`));
|
|
127
|
+
setResolvedPythonCommand(candidate);
|
|
128
|
+
return {
|
|
129
|
+
command: candidate,
|
|
130
|
+
version: "version unknown (sandbox-restricted)",
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (!probe) {
|
|
134
|
+
probeFailures.push(`${candidate}: not found`);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (!isSupportedPythonVersion(probe)) {
|
|
138
|
+
probeFailures.push(`${candidate}: ${probe} (< 3.9)`);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
setResolvedPythonCommand(candidate);
|
|
142
|
+
return { command: candidate, version: probe };
|
|
143
|
+
}
|
|
144
|
+
const isWindows = process.platform === "win32";
|
|
145
|
+
const installHint = isWindows
|
|
146
|
+
? `Install Python ≥ 3.9 from https://www.python.org/downloads/windows/ — make sure ` +
|
|
147
|
+
`"Add Python to PATH" is checked in the installer. Or, if Python is ` +
|
|
148
|
+
`installed under a different name, set RUDDER_PYTHON_CMD=<your-cmd> ` +
|
|
149
|
+
`before re-running init (e.g. \`set RUDDER_PYTHON_CMD=py -3\`).`
|
|
150
|
+
: `Install Python ≥ 3.9 from https://www.python.org/downloads/ or via your ` +
|
|
151
|
+
`package manager. Or set RUDDER_PYTHON_CMD=<your-cmd> before re-running.`;
|
|
152
|
+
throw new Error(`No supported Python command found. Tried: ${candidates.join(", ")}.\n` +
|
|
153
|
+
`Probe results:\n ${probeFailures.join("\n ")}\n\n` +
|
|
154
|
+
`Rudder init requires Python ≥ 3.9. ${installHint}\n` +
|
|
155
|
+
`Last-resort escape hatch: set RUDDER_SKIP_PYTHON_CHECK=1 to skip the probe entirely.`);
|
|
156
|
+
}
|
|
157
|
+
function getOsDisplayName(platform = process.platform) {
|
|
158
|
+
switch (platform) {
|
|
159
|
+
case "win32":
|
|
160
|
+
return "Windows";
|
|
161
|
+
case "darwin":
|
|
162
|
+
return "macOS";
|
|
163
|
+
case "linux":
|
|
164
|
+
return "Linux";
|
|
165
|
+
default:
|
|
166
|
+
return platform;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function logPythonAdaptationNotice(command) {
|
|
170
|
+
const osName = getOsDisplayName();
|
|
171
|
+
console.log(chalk.blue(`📌 ${osName} detected: Rudder rendered Python commands as "${command}" in generated hooks, settings, and help text`));
|
|
172
|
+
}
|
|
173
|
+
// =============================================================================
|
|
174
|
+
// Bootstrap Task Creation
|
|
175
|
+
// =============================================================================
|
|
176
|
+
const BOOTSTRAP_TASK_NAME = "00-bootstrap-guidelines";
|
|
177
|
+
/**
|
|
178
|
+
* Slugify a developer name for safe use in task directory names.
|
|
179
|
+
*
|
|
180
|
+
* Unlike `sanitizePkgName` (which only strips npm @scope/ prefixes), this
|
|
181
|
+
* handles arbitrary developer input: spaces, Unicode letters, punctuation,
|
|
182
|
+
* path separators. Returns "user" fallback when input slugifies to empty.
|
|
183
|
+
*
|
|
184
|
+
* Exported for unit testing; not part of the public API.
|
|
185
|
+
*/
|
|
186
|
+
export function slugifyDeveloperName(name) {
|
|
187
|
+
const slug = name
|
|
188
|
+
.toLowerCase()
|
|
189
|
+
.normalize("NFKD")
|
|
190
|
+
.replace(/[^\p{Letter}\p{Number}]+/gu, "-")
|
|
191
|
+
.replace(/^-+|-+$/g, "");
|
|
192
|
+
return slug || "user";
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Write a task skeleton (task.json + prd.md).
|
|
196
|
+
*
|
|
197
|
+
* Idempotent: if the task dir already exists, returns true without touching
|
|
198
|
+
* anything. Shared by both creator bootstrap and joiner onboarding flows.
|
|
199
|
+
*/
|
|
200
|
+
function writeTaskSkeleton(cwd, taskName, taskJson, prdContent) {
|
|
201
|
+
const taskDir = path.join(cwd, PATHS.TASKS, taskName);
|
|
202
|
+
if (fs.existsSync(taskDir))
|
|
203
|
+
return true; // idempotent
|
|
204
|
+
try {
|
|
205
|
+
fs.mkdirSync(taskDir, { recursive: true });
|
|
206
|
+
fs.writeFileSync(path.join(taskDir, FILE_NAMES.TASK_JSON), JSON.stringify(taskJson, null, 2), "utf-8");
|
|
207
|
+
fs.writeFileSync(path.join(taskDir, FILE_NAMES.PRD), prdContent, "utf-8");
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Compute the bootstrap checklist items (previously stored as structured
|
|
216
|
+
* `subtasks: [{name, status}]` in task.json). Per task 04-21-task-schema-unify
|
|
217
|
+
* (D1), these live as markdown `- [ ]` items in prd.md instead, so task.json
|
|
218
|
+
* stays canonical with `subtasks: string[]` (child task dir names, same as
|
|
219
|
+
* task_store.py).
|
|
220
|
+
*/
|
|
221
|
+
function getBootstrapChecklistItems(projectType, packages) {
|
|
222
|
+
if (packages && packages.length > 0) {
|
|
223
|
+
const items = packages.map((pkg) => `Fill guidelines for ${pkg.name}`);
|
|
224
|
+
items.push("Add code examples");
|
|
225
|
+
return items;
|
|
226
|
+
}
|
|
227
|
+
if (projectType === "frontend") {
|
|
228
|
+
return ["Fill frontend guidelines", "Add code examples"];
|
|
229
|
+
}
|
|
230
|
+
if (projectType === "backend") {
|
|
231
|
+
return ["Fill backend guidelines", "Add code examples"];
|
|
232
|
+
}
|
|
233
|
+
return [
|
|
234
|
+
"Fill backend guidelines",
|
|
235
|
+
"Fill frontend guidelines",
|
|
236
|
+
"Add code examples",
|
|
237
|
+
];
|
|
238
|
+
}
|
|
239
|
+
function getBootstrapRelatedFiles(projectType, packages) {
|
|
240
|
+
if (packages && packages.length > 0) {
|
|
241
|
+
return packages.map((pkg) => `.rudder/spec/${sanitizePkgName(pkg.name)}/`);
|
|
242
|
+
}
|
|
243
|
+
if (projectType === "frontend") {
|
|
244
|
+
return [".rudder/spec/frontend/"];
|
|
245
|
+
}
|
|
246
|
+
if (projectType === "backend") {
|
|
247
|
+
return [".rudder/spec/backend/"];
|
|
248
|
+
}
|
|
249
|
+
return [".rudder/spec/backend/", ".rudder/spec/frontend/"];
|
|
250
|
+
}
|
|
251
|
+
function getBootstrapPrdContent(projectType, pythonCmd, packages) {
|
|
252
|
+
const checklistItems = getBootstrapChecklistItems(projectType, packages);
|
|
253
|
+
const checklistMarkdown = checklistItems
|
|
254
|
+
.map((item) => `- [ ] ${item}`)
|
|
255
|
+
.join("\n");
|
|
256
|
+
const header = `# Bootstrap Task: Fill Project Development Guidelines
|
|
257
|
+
|
|
258
|
+
**You (the AI) are running this task. The developer does not read this file.**
|
|
259
|
+
|
|
260
|
+
The developer just ran \`rudder init\` on this project for the first time.
|
|
261
|
+
\`.rudder/\` now exists with empty spec scaffolding, and this bootstrap task
|
|
262
|
+
exists under \`.rudder/tasks/\`. When they want to work on it, they should start
|
|
263
|
+
this task from a session that provides Rudder session identity.
|
|
264
|
+
|
|
265
|
+
**Your job**: help them populate \`.rudder/spec/\` with the team's real
|
|
266
|
+
coding conventions. Every future AI session — this project's
|
|
267
|
+
\`rudder-implement\` and \`rudder-check\` sub-agents — auto-loads spec files
|
|
268
|
+
listed in per-task jsonl manifests. Empty spec = sub-agents write generic
|
|
269
|
+
code. Real spec = sub-agents match the team's actual patterns.
|
|
270
|
+
|
|
271
|
+
Don't dump instructions. Open with a short greeting, figure out if the repo
|
|
272
|
+
has any existing convention docs (CLAUDE.md, .cursorrules, etc.), and drive
|
|
273
|
+
the rest conversationally.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Status (update the checkboxes as you complete each item)
|
|
278
|
+
|
|
279
|
+
${checklistMarkdown}
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Spec files to populate
|
|
284
|
+
`;
|
|
285
|
+
const backendSection = `
|
|
286
|
+
|
|
287
|
+
### Backend guidelines
|
|
288
|
+
|
|
289
|
+
| File | What to document |
|
|
290
|
+
|------|------------------|
|
|
291
|
+
| \`.rudder/spec/backend/directory-structure.md\` | Where different file types go (routes, services, utils) |
|
|
292
|
+
| \`.rudder/spec/backend/database-guidelines.md\` | ORM, migrations, query patterns, naming conventions |
|
|
293
|
+
| \`.rudder/spec/backend/error-handling.md\` | How errors are caught, logged, and returned |
|
|
294
|
+
| \`.rudder/spec/backend/logging-guidelines.md\` | Log levels, format, what to log |
|
|
295
|
+
| \`.rudder/spec/backend/quality-guidelines.md\` | Code review standards, testing requirements |
|
|
296
|
+
`;
|
|
297
|
+
const frontendSection = `
|
|
298
|
+
|
|
299
|
+
### Frontend guidelines
|
|
300
|
+
|
|
301
|
+
| File | What to document |
|
|
302
|
+
|------|------------------|
|
|
303
|
+
| \`.rudder/spec/frontend/directory-structure.md\` | Component/page/hook organization |
|
|
304
|
+
| \`.rudder/spec/frontend/component-guidelines.md\` | Component patterns, props conventions |
|
|
305
|
+
| \`.rudder/spec/frontend/hook-guidelines.md\` | Custom hook naming, patterns |
|
|
306
|
+
| \`.rudder/spec/frontend/state-management.md\` | State library, patterns, what goes where |
|
|
307
|
+
| \`.rudder/spec/frontend/type-safety.md\` | TypeScript conventions, type organization |
|
|
308
|
+
| \`.rudder/spec/frontend/quality-guidelines.md\` | Linting, testing, accessibility |
|
|
309
|
+
`;
|
|
310
|
+
const footer = `
|
|
311
|
+
|
|
312
|
+
### Thinking guides (already populated)
|
|
313
|
+
|
|
314
|
+
\`.rudder/spec/guides/\` contains general thinking guides pre-filled with
|
|
315
|
+
best practices. Customize only if something clearly doesn't fit this project.
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## How to fill the spec
|
|
320
|
+
|
|
321
|
+
### Step 1: Import from existing convention files first (preferred)
|
|
322
|
+
|
|
323
|
+
Search the repo for existing convention docs. If any exist, read them and
|
|
324
|
+
extract the relevant rules into the matching \`.rudder/spec/\` files —
|
|
325
|
+
usually much faster than documenting from scratch.
|
|
326
|
+
|
|
327
|
+
| File / Directory | Tool |
|
|
328
|
+
|------|------|
|
|
329
|
+
| \`CLAUDE.md\` / \`CLAUDE.local.md\` | Claude Code |
|
|
330
|
+
| \`AGENTS.md\` | Codex / Claude Code / agent-compatible tools |
|
|
331
|
+
| \`.cursorrules\` | Cursor |
|
|
332
|
+
| \`.cursor/rules/*.mdc\` | Cursor (rules directory) |
|
|
333
|
+
| \`.windsurfrules\` | Windsurf |
|
|
334
|
+
| \`.clinerules\` | Cline |
|
|
335
|
+
| \`.roomodes\` | Roo Code |
|
|
336
|
+
| \`.github/copilot-instructions.md\` | GitHub Copilot |
|
|
337
|
+
| \`.vscode/settings.json\` → \`github.copilot.chat.codeGeneration.instructions\` | VS Code Copilot |
|
|
338
|
+
| \`CONVENTIONS.md\` / \`.aider.conf.yml\` | aider |
|
|
339
|
+
| \`CONTRIBUTING.md\` | General project conventions |
|
|
340
|
+
| \`.editorconfig\` | Editor formatting rules |
|
|
341
|
+
|
|
342
|
+
### Step 2: Analyze the codebase for anything not covered by existing docs
|
|
343
|
+
|
|
344
|
+
Scan real code to discover patterns. Before writing each spec file:
|
|
345
|
+
- Find 2-3 real examples of each pattern in the codebase.
|
|
346
|
+
- Reference real file paths (not hypothetical ones).
|
|
347
|
+
- Document anti-patterns the team clearly avoids.
|
|
348
|
+
|
|
349
|
+
### Step 3: Document reality, not ideals
|
|
350
|
+
|
|
351
|
+
**Critical**: write what the code *actually does*, not what it should do.
|
|
352
|
+
Sub-agents match the spec, so aspirational patterns that don't exist in the
|
|
353
|
+
codebase will cause sub-agents to write code that looks out of place.
|
|
354
|
+
|
|
355
|
+
If the team has known tech debt, document the current state — improvement
|
|
356
|
+
is a separate conversation, not a bootstrap concern.
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## Quick explainer of the runtime (share when they ask "why do we need spec at all")
|
|
361
|
+
|
|
362
|
+
- Every AI coding task spawns two sub-agents: \`rudder-implement\` (writes
|
|
363
|
+
code) and \`rudder-check\` (verifies quality).
|
|
364
|
+
- Each task has \`implement.jsonl\` / \`check.jsonl\` manifests listing which
|
|
365
|
+
spec files to load.
|
|
366
|
+
- The platform hook auto-injects those spec files + the task's \`prd.md\`
|
|
367
|
+
into every sub-agent prompt, so the sub-agent codes/reviews per team
|
|
368
|
+
conventions without anyone pasting them manually.
|
|
369
|
+
- Source of truth: \`.rudder/spec/\`. That's why filling it well now pays
|
|
370
|
+
off forever.
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## Completion
|
|
375
|
+
|
|
376
|
+
When the developer confirms the checklist items above are done with real
|
|
377
|
+
examples (not placeholders), guide them to run:
|
|
378
|
+
|
|
379
|
+
\`\`\`bash
|
|
380
|
+
${pythonCmd} ./.rudder/scripts/task.py finish
|
|
381
|
+
${pythonCmd} ./.rudder/scripts/task.py archive 00-bootstrap-guidelines
|
|
382
|
+
\`\`\`
|
|
383
|
+
|
|
384
|
+
After archive, every new developer who joins this project will get a
|
|
385
|
+
\`00-join-<slug>\` onboarding task instead of this bootstrap task.
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
|
|
389
|
+
## Suggested opening line
|
|
390
|
+
|
|
391
|
+
"Welcome to Rudder! Your init just set me up to help you fill the project
|
|
392
|
+
spec — a one-time setup so every future AI session follows the team's
|
|
393
|
+
conventions instead of writing generic code. Before we start, do you have
|
|
394
|
+
any existing convention docs (CLAUDE.md, .cursorrules, CONTRIBUTING.md,
|
|
395
|
+
etc.) I can pull from, or should I scan the codebase from scratch?"
|
|
396
|
+
`;
|
|
397
|
+
let content = header;
|
|
398
|
+
if (packages && packages.length > 0) {
|
|
399
|
+
// Monorepo: generate per-package sections
|
|
400
|
+
for (const pkg of packages) {
|
|
401
|
+
const pkgType = pkg.type === "unknown" ? "fullstack" : pkg.type;
|
|
402
|
+
const specName = sanitizePkgName(pkg.name);
|
|
403
|
+
content += `\n### Package: ${pkg.name} (\`spec/${specName}/\`)\n`;
|
|
404
|
+
if (pkgType !== "frontend") {
|
|
405
|
+
content += `\n- Backend guidelines: \`.rudder/spec/${specName}/backend/\`\n`;
|
|
406
|
+
}
|
|
407
|
+
if (pkgType !== "backend") {
|
|
408
|
+
content += `\n- Frontend guidelines: \`.rudder/spec/${specName}/frontend/\`\n`;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
else if (projectType === "frontend") {
|
|
413
|
+
content += frontendSection;
|
|
414
|
+
}
|
|
415
|
+
else if (projectType === "backend") {
|
|
416
|
+
content += backendSection;
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
// fullstack
|
|
420
|
+
content += backendSection;
|
|
421
|
+
content += frontendSection;
|
|
422
|
+
}
|
|
423
|
+
content += footer;
|
|
424
|
+
return content;
|
|
425
|
+
}
|
|
426
|
+
function getBootstrapTaskJson(developer, projectType, packages) {
|
|
427
|
+
const today = new Date().toISOString().split("T")[0];
|
|
428
|
+
const relatedFiles = getBootstrapRelatedFiles(projectType, packages);
|
|
429
|
+
// Canonical 24-field shape via emptyTaskJson factory.
|
|
430
|
+
// Checklist items (previously stored as structured `subtasks`) are now
|
|
431
|
+
// rendered as `- [ ]` items in prd.md; task.json.subtasks is always
|
|
432
|
+
// string[] (child task dir names) per the canonical schema.
|
|
433
|
+
return emptyTaskJson({
|
|
434
|
+
id: BOOTSTRAP_TASK_NAME,
|
|
435
|
+
name: BOOTSTRAP_TASK_NAME,
|
|
436
|
+
title: "Bootstrap Guidelines",
|
|
437
|
+
description: "Fill in project development guidelines for AI agents",
|
|
438
|
+
status: "in_progress",
|
|
439
|
+
dev_type: "docs",
|
|
440
|
+
priority: "P1",
|
|
441
|
+
creator: developer,
|
|
442
|
+
assignee: developer,
|
|
443
|
+
createdAt: today,
|
|
444
|
+
relatedFiles,
|
|
445
|
+
notes: `First-time setup task created by rudder init (${projectType} project)`,
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Create bootstrap task for first-time setup
|
|
450
|
+
*/
|
|
451
|
+
function createBootstrapTask(cwd, developer, pythonCmd, projectType, packages) {
|
|
452
|
+
const taskJson = getBootstrapTaskJson(developer, projectType, packages);
|
|
453
|
+
const prdContent = getBootstrapPrdContent(projectType, pythonCmd, packages);
|
|
454
|
+
return writeTaskSkeleton(cwd, BOOTSTRAP_TASK_NAME, taskJson, prdContent);
|
|
455
|
+
}
|
|
456
|
+
// =============================================================================
|
|
457
|
+
// Joiner Onboarding Task Creation
|
|
458
|
+
// =============================================================================
|
|
459
|
+
/**
|
|
460
|
+
* task.json factory for joiner onboarding. Mirrors the bootstrap factory but
|
|
461
|
+
* uses dev_type "docs", higher priority "P1", and the developer-specific task
|
|
462
|
+
* name (so multiple joiners in the same checkout don't collide).
|
|
463
|
+
*/
|
|
464
|
+
function getJoinerTaskJson(developer, taskName) {
|
|
465
|
+
const today = new Date().toISOString().split("T")[0];
|
|
466
|
+
return emptyTaskJson({
|
|
467
|
+
id: taskName,
|
|
468
|
+
name: taskName,
|
|
469
|
+
title: `Joining: Onboard to this Rudder project (${developer})`,
|
|
470
|
+
description: "Onboard a new developer to an existing Rudder project: learn the workflow, conventions, and find assigned work",
|
|
471
|
+
status: "in_progress",
|
|
472
|
+
dev_type: "docs",
|
|
473
|
+
priority: "P1",
|
|
474
|
+
creator: developer,
|
|
475
|
+
assignee: developer,
|
|
476
|
+
createdAt: today,
|
|
477
|
+
notes: "Generated by rudder init for a new developer joining an existing Rudder project",
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* PRD content for joiner onboarding. Kept concise (~80 lines) — deeper
|
|
482
|
+
* guidance lives in skills and docs.
|
|
483
|
+
*/
|
|
484
|
+
function getJoinerPrdContent(developer, pythonCmd) {
|
|
485
|
+
const slug = slugifyDeveloperName(developer);
|
|
486
|
+
return `# Joiner Onboarding Task
|
|
487
|
+
|
|
488
|
+
**You (the AI) are running this task. The developer does not read this file.**
|
|
489
|
+
|
|
490
|
+
\`${developer}\` just ran \`rudder init\` on a fresh clone, saw "Developer
|
|
491
|
+
initialized", and will now start asking you questions in chat. This joiner task
|
|
492
|
+
exists under \`.rudder/tasks/\`; when they want to work on it, they should
|
|
493
|
+
start it from a session that provides Rudder session identity.
|
|
494
|
+
|
|
495
|
+
Your job is to orient them to Rudder. Don't dump all of this at them — open
|
|
496
|
+
with a short greeting, ask where they want to start, and fill in the rest as
|
|
497
|
+
they engage.
|
|
498
|
+
|
|
499
|
+
---
|
|
500
|
+
|
|
501
|
+
## Topics to cover (adapt order to their questions)
|
|
502
|
+
|
|
503
|
+
### 1. What Rudder is + the workflow
|
|
504
|
+
|
|
505
|
+
Rudder is a workflow layer over Claude Code / Cursor / etc. that keeps AI
|
|
506
|
+
agents consistent with project-specific conventions instead of writing generic
|
|
507
|
+
code every session.
|
|
508
|
+
|
|
509
|
+
- **Three phases**: Plan (brainstorm → \`prd.md\`) → Execute (code + check) →
|
|
510
|
+
Finish (capture + wrap). Full reference: \`.rudder/workflow.md\`.
|
|
511
|
+
- **Task lifecycle**: planning → in_progress → done → archive, under
|
|
512
|
+
\`.rudder/tasks/\`.
|
|
513
|
+
- **Core slash commands**:
|
|
514
|
+
- \`/rudder:continue\` — resume the current session's active task
|
|
515
|
+
- \`/rudder:finish-work\` — wrap up a finished task
|
|
516
|
+
- \`/rudder:start\` — session boot from scratch (not needed here; the
|
|
517
|
+
SessionStart hook does its job automatically)
|
|
518
|
+
|
|
519
|
+
### 2. Runtime mechanics (explain when they ask "how does it know what to do")
|
|
520
|
+
|
|
521
|
+
- **SessionStart hook** runs \`get_context.py\` and injects identity, git
|
|
522
|
+
status, session active task, active tasks, and workflow phase into the AI
|
|
523
|
+
conversation at every session start.
|
|
524
|
+
- **\`<workflow-state>\` tag** is auto-injected with every user message,
|
|
525
|
+
carrying the current task + phase hint.
|
|
526
|
+
- **\`/rudder:continue\`** loads the Phase Index, reads \`prd.md\` + recent
|
|
527
|
+
activity, and routes to the right skill (\`rudder-brainstorm\` for planning,
|
|
528
|
+
\`rudder-implement\` for coding, \`rudder-check\` for verification).
|
|
529
|
+
- **\`rudder-implement\` sub-agent** is spawned when code needs to be written.
|
|
530
|
+
The platform hook reads \`{TASK_DIR}/implement.jsonl\` and auto-injects those
|
|
531
|
+
spec files + \`prd.md\` into the sub-agent's prompt so it codes per project
|
|
532
|
+
conventions.
|
|
533
|
+
- **\`rudder-check\` sub-agent** follows the same pattern with \`check.jsonl\`
|
|
534
|
+
— reviews changes against specs, auto-fixes issues, runs lint/typecheck.
|
|
535
|
+
|
|
536
|
+
File layout (mention when they ask "where does what live"):
|
|
537
|
+
- \`.rudder/.runtime/sessions/<session>.json\` — session active-task state, gitignored
|
|
538
|
+
- \`.rudder/tasks/<task>/{implement,check}.jsonl\` — per-task context manifests
|
|
539
|
+
- \`.rudder/spec/\` — project-wide conventions (source of truth)
|
|
540
|
+
- \`.rudder/workspace/${developer}/journal-*.md\` — their session log,
|
|
541
|
+
rotated at ~2000 lines
|
|
542
|
+
|
|
543
|
+
### 3. This project's actual conventions
|
|
544
|
+
|
|
545
|
+
- Summarize \`.rudder/spec/\` for them — what coding conventions this
|
|
546
|
+
specific team enforces.
|
|
547
|
+
- Point at the last 5 entries in \`.rudder/tasks/archive/\` as a rhythm
|
|
548
|
+
example of how people actually work here. **If archive is empty** (the
|
|
549
|
+
project just started), skip this — don't invent examples.
|
|
550
|
+
- Not your job in this onboarding to teach them the business code itself —
|
|
551
|
+
the README and their teammates handle that.
|
|
552
|
+
|
|
553
|
+
### 4. Their assigned work
|
|
554
|
+
|
|
555
|
+
- Check if \`.rudder/workspace/${developer}/\` already exists — if yes, it's
|
|
556
|
+
their journal from another machine and worth mentioning.
|
|
557
|
+
- Run \`${pythonCmd} ./.rudder/scripts/task.py list --assignee ${developer}\` to
|
|
558
|
+
show tasks assigned to them. (Quote the name if it contains spaces.)
|
|
559
|
+
- Remind them that the "My Tasks" section appears in the SessionStart context
|
|
560
|
+
on every new session.
|
|
561
|
+
|
|
562
|
+
---
|
|
563
|
+
|
|
564
|
+
## Optional: walk through a small task end-to-end
|
|
565
|
+
|
|
566
|
+
If they want to practice before touching real work, offer to pick a tiny
|
|
567
|
+
P3 task or a typo fix and run the full cycle together: \`/rudder:continue\`
|
|
568
|
+
→ you implement via sub-agents → \`/rudder:finish-work\`.
|
|
569
|
+
|
|
570
|
+
---
|
|
571
|
+
|
|
572
|
+
## Completion
|
|
573
|
+
|
|
574
|
+
When they feel oriented (or after you've covered the four topics with
|
|
575
|
+
reasonable back-and-forth), guide them to run:
|
|
576
|
+
|
|
577
|
+
\`\`\`bash
|
|
578
|
+
${pythonCmd} ./.rudder/scripts/task.py finish
|
|
579
|
+
${pythonCmd} ./.rudder/scripts/task.py archive 00-join-${slug}
|
|
580
|
+
\`\`\`
|
|
581
|
+
|
|
582
|
+
---
|
|
583
|
+
|
|
584
|
+
## Suggested opening line
|
|
585
|
+
|
|
586
|
+
"Welcome! Your \`rudder init\` set me up to onboard you to this project. I
|
|
587
|
+
can walk you through the workflow, show you the runtime mechanics under the
|
|
588
|
+
hood, summarize the team's spec, or jump to what you're already curious about
|
|
589
|
+
— which would you prefer?"
|
|
590
|
+
`;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Create joiner onboarding task for a new developer on an existing Rudder
|
|
594
|
+
* project. Task name is slugified to be filesystem-safe for arbitrary
|
|
595
|
+
* developer names (spaces, Unicode, punctuation).
|
|
596
|
+
*/
|
|
597
|
+
function createJoinerOnboardingTask(cwd, developer, pythonCmd) {
|
|
598
|
+
const slug = slugifyDeveloperName(developer);
|
|
599
|
+
const taskName = `00-join-${slug}`;
|
|
600
|
+
const taskJson = getJoinerTaskJson(developer, taskName);
|
|
601
|
+
const prdContent = getJoinerPrdContent(developer, pythonCmd);
|
|
602
|
+
return writeTaskSkeleton(cwd, taskName, taskJson, prdContent);
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Handle re-init when .rudder/ already exists.
|
|
606
|
+
* Returns true if handled (caller should return), false if user chose full re-init.
|
|
607
|
+
*/
|
|
608
|
+
async function handleReinit(cwd, options, developerName, pythonCmd) {
|
|
609
|
+
const TOOLS = getInitToolChoices();
|
|
610
|
+
const configuredPlatforms = getConfiguredPlatforms(cwd);
|
|
611
|
+
const configuredNames = [...configuredPlatforms]
|
|
612
|
+
.map((id) => AI_TOOLS[id].name)
|
|
613
|
+
.join(", ");
|
|
614
|
+
// Determine explicit platform flags
|
|
615
|
+
const explicitTools = TOOLS.filter((t) => options[t.key]).map((t) => t.key);
|
|
616
|
+
let doAddPlatforms = explicitTools.length > 0;
|
|
617
|
+
let doAddDeveloper = !!options.user;
|
|
618
|
+
let platformsToAdd = explicitTools;
|
|
619
|
+
// No explicit flags → show menu
|
|
620
|
+
if (!doAddPlatforms && !doAddDeveloper) {
|
|
621
|
+
if (options.yes) {
|
|
622
|
+
console.log(chalk.gray(`Already initialized with: ${configuredNames}`));
|
|
623
|
+
console.log(chalk.gray("Use platform flags (e.g., --codex) or -u <name> to add platforms/developer."));
|
|
624
|
+
return true;
|
|
625
|
+
}
|
|
626
|
+
console.log(chalk.gray(`\n Already initialized with: ${configuredNames}\n`));
|
|
627
|
+
const { action } = await inquirer.prompt([
|
|
628
|
+
{
|
|
629
|
+
type: "list",
|
|
630
|
+
name: "action",
|
|
631
|
+
message: "Rudder is already initialized. What would you like to do?",
|
|
632
|
+
choices: [
|
|
633
|
+
{ name: "Add AI platform(s)", value: "add-platform" },
|
|
634
|
+
{
|
|
635
|
+
name: "Set up developer identity on this device",
|
|
636
|
+
value: "add-developer",
|
|
637
|
+
},
|
|
638
|
+
{ name: "Full re-initialize", value: "full" },
|
|
639
|
+
],
|
|
640
|
+
},
|
|
641
|
+
]);
|
|
642
|
+
if (action === "full") {
|
|
643
|
+
return false; // Fall through to full init
|
|
644
|
+
}
|
|
645
|
+
if (action === "add-platform")
|
|
646
|
+
doAddPlatforms = true;
|
|
647
|
+
if (action === "add-developer")
|
|
648
|
+
doAddDeveloper = true;
|
|
649
|
+
}
|
|
650
|
+
// --- Add platforms ---
|
|
651
|
+
if (doAddPlatforms) {
|
|
652
|
+
if (platformsToAdd.length === 0) {
|
|
653
|
+
// Interactive: show only unconfigured platforms
|
|
654
|
+
const unconfigured = TOOLS.filter((t) => {
|
|
655
|
+
const pid = resolveCliFlag(t.key);
|
|
656
|
+
return pid && !configuredPlatforms.has(pid);
|
|
657
|
+
});
|
|
658
|
+
if (unconfigured.length === 0) {
|
|
659
|
+
console.log(chalk.green("✓ All available platforms are already configured."));
|
|
660
|
+
}
|
|
661
|
+
else {
|
|
662
|
+
const answers = await inquirer.prompt([
|
|
663
|
+
{
|
|
664
|
+
type: "checkbox",
|
|
665
|
+
name: "tools",
|
|
666
|
+
message: "Select platforms to add:",
|
|
667
|
+
choices: unconfigured.map((t) => ({
|
|
668
|
+
name: t.name,
|
|
669
|
+
value: t.key,
|
|
670
|
+
})),
|
|
671
|
+
},
|
|
672
|
+
]);
|
|
673
|
+
platformsToAdd = answers.tools;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
for (const tool of platformsToAdd) {
|
|
677
|
+
const platformId = resolveCliFlag(tool);
|
|
678
|
+
if (platformId) {
|
|
679
|
+
if (configuredPlatforms.has(platformId)) {
|
|
680
|
+
console.log(chalk.gray(` ○ ${AI_TOOLS[platformId].name} already configured, skipping`));
|
|
681
|
+
}
|
|
682
|
+
else {
|
|
683
|
+
console.log(chalk.blue(`📝 Configuring ${AI_TOOLS[platformId].name}...`));
|
|
684
|
+
await configurePlatform(platformId, cwd);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
// Update template hashes
|
|
689
|
+
const hashedCount = initializeHashes(cwd);
|
|
690
|
+
if (hashedCount > 0) {
|
|
691
|
+
console.log(chalk.gray(`📋 Tracking ${hashedCount} template files for updates`));
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
// --- Add developer ---
|
|
695
|
+
if (doAddDeveloper) {
|
|
696
|
+
let devName = developerName;
|
|
697
|
+
if (!devName) {
|
|
698
|
+
devName = await askInput("Your name: ");
|
|
699
|
+
while (!devName) {
|
|
700
|
+
console.log(chalk.yellow("Name is required"));
|
|
701
|
+
devName = await askInput("Your name: ");
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
// Capture pre-init state: if .developer did not exist before we ran
|
|
705
|
+
// init_developer.py, this checkout had no identity → treat as a new
|
|
706
|
+
// joiner onboarding onto an existing Rudder project.
|
|
707
|
+
const hadDeveloperFileBefore = fs.existsSync(path.join(cwd, DIR_NAMES.WORKFLOW, FILE_NAMES.DEVELOPER));
|
|
708
|
+
try {
|
|
709
|
+
const scriptPath = path.join(cwd, PATHS.SCRIPTS, "init_developer.py");
|
|
710
|
+
execSync(`${pythonCmd} "${scriptPath}" "${devName}"`, {
|
|
711
|
+
cwd,
|
|
712
|
+
stdio: "pipe",
|
|
713
|
+
});
|
|
714
|
+
console.log(chalk.green(`✓ Developer "${devName}" initialized`));
|
|
715
|
+
}
|
|
716
|
+
catch {
|
|
717
|
+
console.log(chalk.yellow("⚠ Could not initialize developer. Run manually:"));
|
|
718
|
+
console.log(chalk.gray(` ${pythonCmd} .rudder/scripts/init_developer.py ${devName}`));
|
|
719
|
+
}
|
|
720
|
+
// Create joiner onboarding task for fresh checkouts (no prior .developer).
|
|
721
|
+
// Runs outside the init_developer try/catch so failures surface as warnings.
|
|
722
|
+
if (!hadDeveloperFileBefore) {
|
|
723
|
+
try {
|
|
724
|
+
if (!createJoinerOnboardingTask(cwd, devName, pythonCmd)) {
|
|
725
|
+
console.warn(chalk.yellow("⚠ Failed to create joiner onboarding task"));
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
catch (err) {
|
|
729
|
+
console.warn(chalk.yellow(`⚠ Joiner onboarding setup failed: ${err instanceof Error ? err.message : String(err)}`));
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
return true;
|
|
734
|
+
}
|
|
735
|
+
const _cliFlagCheck = true;
|
|
736
|
+
/**
|
|
737
|
+
* Write monorepo package configuration to config.yaml (non-destructive patch).
|
|
738
|
+
* Appends packages: and default_package: without disturbing existing config.
|
|
739
|
+
*/
|
|
740
|
+
function writeMonorepoConfig(cwd, packages) {
|
|
741
|
+
const configPath = path.join(cwd, DIR_NAMES.WORKFLOW, "config.yaml");
|
|
742
|
+
let content = "";
|
|
743
|
+
try {
|
|
744
|
+
content = fs.readFileSync(configPath, "utf-8");
|
|
745
|
+
}
|
|
746
|
+
catch {
|
|
747
|
+
// Config not created yet; will be created by createWorkflowStructure
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
// Don't overwrite if packages: already exists (re-init case)
|
|
751
|
+
if (/^packages\s*:/m.test(content)) {
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
const lines = ["\n# Auto-detected monorepo packages", "packages:"];
|
|
755
|
+
for (const pkg of packages) {
|
|
756
|
+
lines.push(` ${sanitizePkgName(pkg.name)}:`);
|
|
757
|
+
lines.push(` path: ${pkg.path}`);
|
|
758
|
+
if (pkg.isSubmodule) {
|
|
759
|
+
lines.push(" type: submodule");
|
|
760
|
+
}
|
|
761
|
+
else if (pkg.isGitRepo) {
|
|
762
|
+
lines.push(" git: true");
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
// Use first non-submodule package as default, fallback to first package
|
|
766
|
+
const defaultPkg = packages.find((p) => !p.isSubmodule)?.name ?? packages[0]?.name;
|
|
767
|
+
if (defaultPkg) {
|
|
768
|
+
lines.push(`default_package: ${defaultPkg}`);
|
|
769
|
+
}
|
|
770
|
+
fs.writeFileSync(configPath, content.trimEnd() + "\n" + lines.join("\n") + "\n", "utf-8");
|
|
771
|
+
}
|
|
772
|
+
export async function init(options) {
|
|
773
|
+
const cwd = process.cwd();
|
|
774
|
+
// Refuse to run in $HOME unless TRELLIS_ALLOW_HOMEDIR=1 is set.
|
|
775
|
+
// Running init in $HOME would scatter platform config files across the
|
|
776
|
+
// user's home directory, which is almost certainly a mistake.
|
|
777
|
+
const homeDir = process.env.HOME ?? process.env.USERPROFILE ?? "";
|
|
778
|
+
if (homeDir && cwd === homeDir && !process.env.TRELLIS_ALLOW_HOMEDIR) {
|
|
779
|
+
console.error(chalk.red("Refusing to run `rudder init` in the home directory ($HOME / %USERPROFILE%). " +
|
|
780
|
+
"This would create platform config files (.claude/, .codex/, etc.) directly in $HOME.\n" +
|
|
781
|
+
"If you really want to do this, set TRELLIS_ALLOW_HOMEDIR=1 and try again."));
|
|
782
|
+
process.exit(1);
|
|
783
|
+
}
|
|
784
|
+
// Auto-migrate from Trellis if .trellis/ directory is detected.
|
|
785
|
+
// This renames .trellis/ → .rudder/, updates system files, cleans up
|
|
786
|
+
// old trellis-* platform files, and preserves all task records.
|
|
787
|
+
const migration = migrateFromTrellis(cwd);
|
|
788
|
+
if (migration.migrated) {
|
|
789
|
+
console.log(chalk.green(`\n⚡ Migrated from Trellis: .trellis/ → .rudder/ (${migration.taskCount} task${migration.taskCount === 1 ? "" : "s"} preserved, ${migration.platformFilesRemoved} old platform files removed)`));
|
|
790
|
+
}
|
|
791
|
+
const isFirstInit = !fs.existsSync(path.join(cwd, DIR_NAMES.WORKFLOW));
|
|
792
|
+
// Captured here (before createWorkflowStructure + init_developer run) so
|
|
793
|
+
// the three-branch dispatch at the bottom can tell "fresh clone joiner"
|
|
794
|
+
// (.rudder/ exists, .developer missing) apart from "creator first init".
|
|
795
|
+
const hadDeveloperFileAtStart = fs.existsSync(path.join(cwd, DIR_NAMES.WORKFLOW, FILE_NAMES.DEVELOPER));
|
|
796
|
+
// Generate ASCII art banner dynamically using FIGlet "Rebel" font
|
|
797
|
+
const banner = figlet.textSync("Rudder", { font: "Rebel" });
|
|
798
|
+
console.log(chalk.cyan(`\n${banner.trimEnd()}`));
|
|
799
|
+
console.log(chalk.gray("\n All-in-one AI framework & toolkit for Claude Code & Cursor\n"));
|
|
800
|
+
// Set up proxy before any network calls
|
|
801
|
+
const proxyUrl = setupProxy();
|
|
802
|
+
if (proxyUrl) {
|
|
803
|
+
console.log(chalk.gray(` Using proxy: ${maskProxyUrl(proxyUrl)}\n`));
|
|
804
|
+
}
|
|
805
|
+
// Set write mode based on options
|
|
806
|
+
let writeMode = "ask";
|
|
807
|
+
if (options.force || migration.migrated) {
|
|
808
|
+
// After Trellis migration, force-overwrite all platform files so the new
|
|
809
|
+
// rudder-* skills/commands/agents replace the deleted trellis-* ones
|
|
810
|
+
// without prompting the user for each file.
|
|
811
|
+
writeMode = "force";
|
|
812
|
+
if (options.force) {
|
|
813
|
+
console.log(chalk.gray("Mode: Force overwrite existing files\n"));
|
|
814
|
+
}
|
|
815
|
+
else {
|
|
816
|
+
console.log(chalk.gray("Mode: Force overwrite (post-migration)\n"));
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
else if (options.skipExisting) {
|
|
820
|
+
writeMode = "skip";
|
|
821
|
+
console.log(chalk.gray("Mode: Skip existing files\n"));
|
|
822
|
+
}
|
|
823
|
+
else if (options.yes) {
|
|
824
|
+
// -y implies non-interactive: never prompt on conflicts. Default to skip
|
|
825
|
+
// (preserve user files) — explicit --force is required to overwrite.
|
|
826
|
+
writeMode = "skip";
|
|
827
|
+
console.log(chalk.gray("Mode: Non-interactive (skip existing files)\n"));
|
|
828
|
+
}
|
|
829
|
+
setWriteMode(writeMode);
|
|
830
|
+
// Detect developer name from git config or options
|
|
831
|
+
let developerName = options.user;
|
|
832
|
+
if (!developerName) {
|
|
833
|
+
// Only detect from git if current directory is a git repo
|
|
834
|
+
const isGitRepo = fs.existsSync(path.join(cwd, ".git"));
|
|
835
|
+
if (isGitRepo) {
|
|
836
|
+
try {
|
|
837
|
+
developerName = execSync("git config user.name", {
|
|
838
|
+
cwd,
|
|
839
|
+
encoding: "utf-8",
|
|
840
|
+
}).trim();
|
|
841
|
+
}
|
|
842
|
+
catch {
|
|
843
|
+
// Git not available or no user.name configured
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
if (developerName) {
|
|
848
|
+
console.log(chalk.blue("👤 Developer:"), chalk.gray(developerName));
|
|
849
|
+
}
|
|
850
|
+
const { command: pythonCmd } = resolveSupportedPython();
|
|
851
|
+
// ==========================================================================
|
|
852
|
+
// Re-init fast path: skip full flow when .rudder/ already exists
|
|
853
|
+
// ==========================================================================
|
|
854
|
+
// Aborted-init recovery (issue #204): if .rudder/ exists but tasks/ is
|
|
855
|
+
// empty, the previous init never reached bootstrap creation. Fall through
|
|
856
|
+
// to the full flow so the main-dispatch tasksEmpty fallback fires —
|
|
857
|
+
// handleReinit's joiner branch would otherwise mis-route the recovery.
|
|
858
|
+
const tasksDirEarly = path.join(cwd, PATHS.TASKS);
|
|
859
|
+
const tasksEmptyEarly = !fs.existsSync(tasksDirEarly) || fs.readdirSync(tasksDirEarly).length === 0;
|
|
860
|
+
if (!isFirstInit &&
|
|
861
|
+
!migration.migrated &&
|
|
862
|
+
!options.force &&
|
|
863
|
+
!options.skipExisting &&
|
|
864
|
+
!tasksEmptyEarly) {
|
|
865
|
+
const reinitDone = await handleReinit(cwd, options, developerName, pythonCmd);
|
|
866
|
+
if (reinitDone)
|
|
867
|
+
return;
|
|
868
|
+
// reinitDone === false means user chose "full re-initialize" → fall through
|
|
869
|
+
}
|
|
870
|
+
if (!developerName && !options.yes) {
|
|
871
|
+
// Ask for developer name if not detected and not in yes mode
|
|
872
|
+
console.log(chalk.gray("\nRudder supports team collaboration - each developer has their own\n" +
|
|
873
|
+
`workspace directory (${PATHS.WORKSPACE}/{name}/) to track AI sessions.\n` +
|
|
874
|
+
"Tip: Usually this is your git username (git config user.name).\n"));
|
|
875
|
+
developerName = await askInput("Your name: ");
|
|
876
|
+
while (!developerName) {
|
|
877
|
+
console.log(chalk.yellow("Name is required"));
|
|
878
|
+
developerName = await askInput("Your name: ");
|
|
879
|
+
}
|
|
880
|
+
console.log(chalk.blue("👤 Developer:"), chalk.gray(developerName));
|
|
881
|
+
}
|
|
882
|
+
// Detect project type (silent - no output)
|
|
883
|
+
const detectedType = detectProjectType(cwd);
|
|
884
|
+
// Parse custom registry source early (needed by both monorepo + single-repo flows)
|
|
885
|
+
let registry;
|
|
886
|
+
if (options.registry) {
|
|
887
|
+
try {
|
|
888
|
+
registry = parseRegistrySource(options.registry);
|
|
889
|
+
}
|
|
890
|
+
catch (error) {
|
|
891
|
+
console.log(chalk.red(error instanceof Error ? error.message : "Invalid registry source"));
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
// Determine template strategy from flags (needed before monorepo template downloads)
|
|
896
|
+
let templateStrategy = "skip";
|
|
897
|
+
if (options.overwrite) {
|
|
898
|
+
templateStrategy = "overwrite";
|
|
899
|
+
}
|
|
900
|
+
else if (options.append) {
|
|
901
|
+
templateStrategy = "append";
|
|
902
|
+
}
|
|
903
|
+
// ==========================================================================
|
|
904
|
+
// Monorepo Detection
|
|
905
|
+
// ==========================================================================
|
|
906
|
+
let monorepoPackages;
|
|
907
|
+
let remoteSpecPackages;
|
|
908
|
+
if (options.monorepo !== false) {
|
|
909
|
+
// options.monorepo: true = --monorepo, false = --no-monorepo, undefined = auto
|
|
910
|
+
const detected = detectMonorepo(cwd);
|
|
911
|
+
if (options.monorepo === true && !detected) {
|
|
912
|
+
console.log(chalk.red("Error: --monorepo specified but no multi-package layout detected."));
|
|
913
|
+
console.log("");
|
|
914
|
+
console.log(chalk.gray("Checked:"));
|
|
915
|
+
console.log(chalk.gray(" ✗ pnpm-workspace.yaml"));
|
|
916
|
+
console.log(chalk.gray(" ✗ package.json workspaces"));
|
|
917
|
+
console.log(chalk.gray(" ✗ Cargo.toml [workspace]"));
|
|
918
|
+
console.log(chalk.gray(" ✗ go.work"));
|
|
919
|
+
console.log(chalk.gray(" ✗ pyproject.toml [tool.uv.workspace]"));
|
|
920
|
+
console.log(chalk.gray(" ✗ .gitmodules"));
|
|
921
|
+
console.log(chalk.gray(" ✗ sibling .git directories (need ≥ 2)"));
|
|
922
|
+
console.log("");
|
|
923
|
+
console.log("To configure manually, add to .rudder/config.yaml:");
|
|
924
|
+
console.log("");
|
|
925
|
+
console.log(chalk.cyan(" packages:"));
|
|
926
|
+
console.log(chalk.cyan(" frontend:"));
|
|
927
|
+
console.log(chalk.cyan(" path: ./frontend"));
|
|
928
|
+
console.log(chalk.cyan(" git: true # if it has its own .git"));
|
|
929
|
+
console.log(chalk.cyan(" backend:"));
|
|
930
|
+
console.log(chalk.cyan(" path: ./backend"));
|
|
931
|
+
console.log(chalk.cyan(" git: true"));
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
if (detected && detected.length > 0) {
|
|
935
|
+
let enableMonorepo = false;
|
|
936
|
+
if (options.monorepo === true || options.yes) {
|
|
937
|
+
enableMonorepo = true;
|
|
938
|
+
}
|
|
939
|
+
else {
|
|
940
|
+
// Show detected packages and ask
|
|
941
|
+
console.log(chalk.blue("\n🔍 Detected monorepo packages:"));
|
|
942
|
+
for (const pkg of detected) {
|
|
943
|
+
const tag = pkg.isSubmodule
|
|
944
|
+
? chalk.gray(" (submodule)")
|
|
945
|
+
: pkg.isGitRepo
|
|
946
|
+
? chalk.gray(" (git repo)")
|
|
947
|
+
: "";
|
|
948
|
+
console.log(chalk.gray(` - ${pkg.name}`) +
|
|
949
|
+
chalk.gray(` (${pkg.path})`) +
|
|
950
|
+
chalk.gray(` [${pkg.type}]`) +
|
|
951
|
+
tag);
|
|
952
|
+
}
|
|
953
|
+
console.log("");
|
|
954
|
+
const { useMonorepo } = await inquirer.prompt([
|
|
955
|
+
{
|
|
956
|
+
type: "confirm",
|
|
957
|
+
name: "useMonorepo",
|
|
958
|
+
message: "Enable monorepo mode?",
|
|
959
|
+
default: true,
|
|
960
|
+
},
|
|
961
|
+
]);
|
|
962
|
+
enableMonorepo = useMonorepo;
|
|
963
|
+
}
|
|
964
|
+
if (enableMonorepo) {
|
|
965
|
+
monorepoPackages = detected;
|
|
966
|
+
remoteSpecPackages = new Set();
|
|
967
|
+
// Per-package template selection (unless -y mode: all use blank spec)
|
|
968
|
+
if (!options.yes && !options.template) {
|
|
969
|
+
for (const pkg of detected) {
|
|
970
|
+
const { specSource } = await inquirer.prompt([
|
|
971
|
+
{
|
|
972
|
+
type: "list",
|
|
973
|
+
name: "specSource",
|
|
974
|
+
message: `Spec source for ${pkg.name} (${pkg.path}):`,
|
|
975
|
+
choices: [
|
|
976
|
+
{ name: "From scratch (Rudder default)", value: "blank" },
|
|
977
|
+
{ name: "Download remote template", value: "remote" },
|
|
978
|
+
],
|
|
979
|
+
default: "blank",
|
|
980
|
+
},
|
|
981
|
+
]);
|
|
982
|
+
if (specSource === "remote") {
|
|
983
|
+
// Use existing template download flow, targeting spec/<name>/
|
|
984
|
+
const destDir = path.join(cwd, PATHS.SPEC, sanitizePkgName(pkg.name));
|
|
985
|
+
console.log(chalk.blue(`📦 Select template for ${pkg.name}...`));
|
|
986
|
+
// Fetch templates if not already done
|
|
987
|
+
const templates = await fetchTemplateIndex();
|
|
988
|
+
const specTemplates = templates
|
|
989
|
+
.filter((t) => t.type === "spec")
|
|
990
|
+
.map((t) => ({
|
|
991
|
+
name: `${t.id} (${t.name})`,
|
|
992
|
+
value: t.id,
|
|
993
|
+
}));
|
|
994
|
+
if (specTemplates.length > 0) {
|
|
995
|
+
const { templateId } = await inquirer.prompt([
|
|
996
|
+
{
|
|
997
|
+
type: "list",
|
|
998
|
+
name: "templateId",
|
|
999
|
+
message: `Select template for ${pkg.name}:`,
|
|
1000
|
+
choices: specTemplates,
|
|
1001
|
+
},
|
|
1002
|
+
]);
|
|
1003
|
+
const result = await downloadTemplateById(cwd, templateId, templateStrategy, templates.find((t) => t.id === templateId), undefined, destDir);
|
|
1004
|
+
if (result.success) {
|
|
1005
|
+
console.log(chalk.green(` ${result.message}`));
|
|
1006
|
+
remoteSpecPackages.add(sanitizePkgName(pkg.name));
|
|
1007
|
+
}
|
|
1008
|
+
else {
|
|
1009
|
+
console.log(chalk.yellow(` ${result.message}`));
|
|
1010
|
+
console.log(chalk.gray(" Falling back to blank spec..."));
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
else {
|
|
1014
|
+
console.log(chalk.gray(" No templates available. Using blank spec."));
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
else if (options.template) {
|
|
1020
|
+
// --template as default for all packages
|
|
1021
|
+
for (const pkg of detected) {
|
|
1022
|
+
const destDir = path.join(cwd, PATHS.SPEC, sanitizePkgName(pkg.name));
|
|
1023
|
+
const result = await downloadTemplateById(cwd, options.template, templateStrategy, undefined, registry, destDir);
|
|
1024
|
+
if (result.success && !result.skipped) {
|
|
1025
|
+
remoteSpecPackages.add(sanitizePkgName(pkg.name));
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
// Tool definitions derived from platform registry
|
|
1033
|
+
const TOOLS = getInitToolChoices();
|
|
1034
|
+
// Build tools from explicit flags
|
|
1035
|
+
const explicitTools = TOOLS.filter((t) => options[t.key]).map((t) => t.key);
|
|
1036
|
+
let tools;
|
|
1037
|
+
if (explicitTools.length > 0) {
|
|
1038
|
+
// Explicit flags take precedence (works with or without -y)
|
|
1039
|
+
tools = explicitTools;
|
|
1040
|
+
}
|
|
1041
|
+
else if (options.yes) {
|
|
1042
|
+
// No explicit tools + -y: default to Cursor and Claude
|
|
1043
|
+
tools = TOOLS.filter((t) => t.defaultChecked).map((t) => t.key);
|
|
1044
|
+
}
|
|
1045
|
+
else {
|
|
1046
|
+
// Interactive mode
|
|
1047
|
+
const answers = await inquirer.prompt([
|
|
1048
|
+
{
|
|
1049
|
+
type: "checkbox",
|
|
1050
|
+
name: "tools",
|
|
1051
|
+
message: "Select AI tools to configure:",
|
|
1052
|
+
choices: TOOLS.map((t) => ({
|
|
1053
|
+
name: t.name,
|
|
1054
|
+
value: t.key,
|
|
1055
|
+
checked: t.defaultChecked,
|
|
1056
|
+
})),
|
|
1057
|
+
},
|
|
1058
|
+
]);
|
|
1059
|
+
tools = answers.tools;
|
|
1060
|
+
}
|
|
1061
|
+
// Treat unknown project type as fullstack
|
|
1062
|
+
const projectType = detectedType === "unknown" ? "fullstack" : detectedType;
|
|
1063
|
+
if (tools.length === 0) {
|
|
1064
|
+
console.log(chalk.yellow("No tools selected. At least one tool is required."));
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
// ==========================================================================
|
|
1068
|
+
// Template Selection (single-repo only; monorepo handles templates above)
|
|
1069
|
+
// ==========================================================================
|
|
1070
|
+
let selectedTemplate = null;
|
|
1071
|
+
// Pre-fetched templates list (used to pass selected SpecTemplate to downloadTemplateById)
|
|
1072
|
+
let fetchedTemplates = [];
|
|
1073
|
+
let registryBackend;
|
|
1074
|
+
// Determine the index URL based on registry
|
|
1075
|
+
const indexUrl = registry
|
|
1076
|
+
? `${registry.rawBaseUrl}/index.json`
|
|
1077
|
+
: TEMPLATE_INDEX_URL;
|
|
1078
|
+
if (monorepoPackages) {
|
|
1079
|
+
// Monorepo: template selection already handled above
|
|
1080
|
+
}
|
|
1081
|
+
else if (options.template) {
|
|
1082
|
+
// Template specified via --template flag
|
|
1083
|
+
selectedTemplate = options.template;
|
|
1084
|
+
}
|
|
1085
|
+
else if (!options.yes) {
|
|
1086
|
+
// Interactive mode: show template selection
|
|
1087
|
+
const timeoutSec = TIMEOUTS.INDEX_FETCH_MS / 1000;
|
|
1088
|
+
const sourceLabel = registry ? registry.gigetSource : TEMPLATE_INDEX_URL;
|
|
1089
|
+
console.log(chalk.gray(` Fetching available templates from ${sourceLabel}`));
|
|
1090
|
+
let elapsed = 0;
|
|
1091
|
+
const ticker = setInterval(() => {
|
|
1092
|
+
elapsed++;
|
|
1093
|
+
process.stdout.write(`\r${chalk.gray(` Loading... ${elapsed}s/${timeoutSec}s`)}`);
|
|
1094
|
+
}, 1000);
|
|
1095
|
+
process.stdout.write(chalk.gray(` Loading... 0s/${timeoutSec}s`));
|
|
1096
|
+
let templates;
|
|
1097
|
+
let registryProbeNotFound = false;
|
|
1098
|
+
let registryProbeError;
|
|
1099
|
+
if (registry) {
|
|
1100
|
+
const probeResult = await probeRegistryIndex(indexUrl, registry);
|
|
1101
|
+
templates = probeResult.templates;
|
|
1102
|
+
registryProbeNotFound = probeResult.isNotFound;
|
|
1103
|
+
registryProbeError = probeResult.error;
|
|
1104
|
+
registryBackend = probeResult.backend;
|
|
1105
|
+
}
|
|
1106
|
+
else {
|
|
1107
|
+
templates = await fetchTemplateIndex(indexUrl);
|
|
1108
|
+
}
|
|
1109
|
+
clearInterval(ticker);
|
|
1110
|
+
// Clear the loading line
|
|
1111
|
+
process.stdout.write("\r\x1b[2K");
|
|
1112
|
+
fetchedTemplates = templates;
|
|
1113
|
+
if (templates.length === 0 && registry && registryProbeNotFound) {
|
|
1114
|
+
// Custom registry: confirmed no index.json — will try direct download later
|
|
1115
|
+
console.log(chalk.gray(" No index.json found at registry. Will download as direct spec template."));
|
|
1116
|
+
}
|
|
1117
|
+
else if (templates.length === 0 && registry) {
|
|
1118
|
+
// Custom registry: transient error (not a 404) — abort, don't misclassify
|
|
1119
|
+
console.log(chalk.red(` ${registryProbeError?.message ?? "Could not reach registry. Check your connection and try again."}`));
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
else if (templates.length === 0) {
|
|
1123
|
+
console.log(chalk.gray(" Could not fetch templates (offline or server unavailable)."));
|
|
1124
|
+
console.log(chalk.gray(" Using blank templates.\n"));
|
|
1125
|
+
}
|
|
1126
|
+
if (templates.length > 0) {
|
|
1127
|
+
// Build template choices
|
|
1128
|
+
const specTemplates = templates
|
|
1129
|
+
.filter((t) => t.type === "spec")
|
|
1130
|
+
.map((t) => ({
|
|
1131
|
+
name: `${t.id} (${t.name})`,
|
|
1132
|
+
value: t.id,
|
|
1133
|
+
}));
|
|
1134
|
+
const templateChoices = registry
|
|
1135
|
+
? specTemplates
|
|
1136
|
+
: [
|
|
1137
|
+
{
|
|
1138
|
+
name: "from scratch (default)",
|
|
1139
|
+
value: "blank",
|
|
1140
|
+
},
|
|
1141
|
+
...specTemplates,
|
|
1142
|
+
{
|
|
1143
|
+
name: "custom (enter a registry source)",
|
|
1144
|
+
value: "__custom__",
|
|
1145
|
+
},
|
|
1146
|
+
];
|
|
1147
|
+
// Loop to allow returning from custom source input back to the picker
|
|
1148
|
+
let templatePicked = false;
|
|
1149
|
+
while (templateChoices.length > 0 && !templatePicked) {
|
|
1150
|
+
const templateAnswer = await inquirer.prompt([
|
|
1151
|
+
{
|
|
1152
|
+
type: "list",
|
|
1153
|
+
name: "template",
|
|
1154
|
+
message: "Select a spec template:",
|
|
1155
|
+
choices: templateChoices,
|
|
1156
|
+
default: registry ? undefined : "blank",
|
|
1157
|
+
},
|
|
1158
|
+
]);
|
|
1159
|
+
if (templateAnswer.template === "__custom__") {
|
|
1160
|
+
// Prompt for custom registry source (empty → back to picker)
|
|
1161
|
+
const customSource = await askInput("Enter registry source (e.g., gh:myorg/myrepo/specs), or press Enter to go back: ");
|
|
1162
|
+
if (!customSource) {
|
|
1163
|
+
continue; // Back to picker
|
|
1164
|
+
}
|
|
1165
|
+
try {
|
|
1166
|
+
registry = parseRegistrySource(customSource);
|
|
1167
|
+
fetchedTemplates = []; // Reset so direct-download guard works correctly
|
|
1168
|
+
// Probe index.json to detect marketplace vs direct download
|
|
1169
|
+
const customIndexUrl = `${registry.rawBaseUrl}/index.json`;
|
|
1170
|
+
console.log(chalk.gray(` Checking for templates at ${registry.gigetSource}...`));
|
|
1171
|
+
const customProbe = await probeRegistryIndex(customIndexUrl, registry);
|
|
1172
|
+
const customTemplates = customProbe.templates;
|
|
1173
|
+
registryBackend = customProbe.backend;
|
|
1174
|
+
if (customTemplates.length > 0) {
|
|
1175
|
+
// Marketplace mode: show picker with custom templates
|
|
1176
|
+
fetchedTemplates = customTemplates;
|
|
1177
|
+
const customChoices = customTemplates
|
|
1178
|
+
.filter((t) => t.type === "spec")
|
|
1179
|
+
.map((t) => ({
|
|
1180
|
+
name: `${t.id} (${t.name})`,
|
|
1181
|
+
value: t.id,
|
|
1182
|
+
}));
|
|
1183
|
+
if (customChoices.length > 0) {
|
|
1184
|
+
const customAnswer = await inquirer.prompt([
|
|
1185
|
+
{
|
|
1186
|
+
type: "list",
|
|
1187
|
+
name: "template",
|
|
1188
|
+
message: "Select a spec template:",
|
|
1189
|
+
choices: customChoices,
|
|
1190
|
+
},
|
|
1191
|
+
]);
|
|
1192
|
+
selectedTemplate = customAnswer.template;
|
|
1193
|
+
// Check if spec directory already exists and ask what to do
|
|
1194
|
+
const specDir = path.join(cwd, PATHS.SPEC);
|
|
1195
|
+
if (fs.existsSync(specDir) &&
|
|
1196
|
+
!options.overwrite &&
|
|
1197
|
+
!options.append) {
|
|
1198
|
+
const actionAnswer = await inquirer.prompt([
|
|
1199
|
+
{
|
|
1200
|
+
type: "list",
|
|
1201
|
+
name: "action",
|
|
1202
|
+
message: `Directory ${PATHS.SPEC} already exists. What do you want to do?`,
|
|
1203
|
+
choices: [
|
|
1204
|
+
{ name: "Skip (keep existing)", value: "skip" },
|
|
1205
|
+
{
|
|
1206
|
+
name: "Overwrite (replace all)",
|
|
1207
|
+
value: "overwrite",
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
name: "Append (add missing files only)",
|
|
1211
|
+
value: "append",
|
|
1212
|
+
},
|
|
1213
|
+
],
|
|
1214
|
+
default: "skip",
|
|
1215
|
+
},
|
|
1216
|
+
]);
|
|
1217
|
+
templateStrategy = actionAnswer.action;
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
templatePicked = true;
|
|
1221
|
+
}
|
|
1222
|
+
else if (customProbe.isNotFound) {
|
|
1223
|
+
// No index.json → direct download mode
|
|
1224
|
+
templatePicked = true;
|
|
1225
|
+
}
|
|
1226
|
+
else {
|
|
1227
|
+
// Transient error (not 404) — loop back, don't misclassify
|
|
1228
|
+
console.log(chalk.yellow(` ${customProbe.error?.message ?? "Could not reach registry. Try again or enter a different source."}`));
|
|
1229
|
+
registry = undefined; // Reset so we don't fall through to direct download
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
catch (error) {
|
|
1233
|
+
console.log(chalk.red(error instanceof Error
|
|
1234
|
+
? error.message
|
|
1235
|
+
: "Invalid registry source"));
|
|
1236
|
+
// Loop back to picker
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
else {
|
|
1240
|
+
templatePicked = true;
|
|
1241
|
+
if (templateAnswer.template !== "blank") {
|
|
1242
|
+
selectedTemplate = templateAnswer.template;
|
|
1243
|
+
// Check if spec directory already exists and ask what to do
|
|
1244
|
+
const specDir = path.join(cwd, PATHS.SPEC);
|
|
1245
|
+
if (fs.existsSync(specDir) &&
|
|
1246
|
+
!options.overwrite &&
|
|
1247
|
+
!options.append) {
|
|
1248
|
+
const actionAnswer = await inquirer.prompt([
|
|
1249
|
+
{
|
|
1250
|
+
type: "list",
|
|
1251
|
+
name: "action",
|
|
1252
|
+
message: `Directory ${PATHS.SPEC} already exists. What do you want to do?`,
|
|
1253
|
+
choices: [
|
|
1254
|
+
{ name: "Skip (keep existing)", value: "skip" },
|
|
1255
|
+
{ name: "Overwrite (replace all)", value: "overwrite" },
|
|
1256
|
+
{
|
|
1257
|
+
name: "Append (add missing files only)",
|
|
1258
|
+
value: "append",
|
|
1259
|
+
},
|
|
1260
|
+
],
|
|
1261
|
+
default: "skip",
|
|
1262
|
+
},
|
|
1263
|
+
]);
|
|
1264
|
+
templateStrategy = actionAnswer.action;
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
// -y mode with --registry (no --template): probe index.json to detect mode
|
|
1272
|
+
// Skip when monorepo mode already handled templates above
|
|
1273
|
+
if (options.yes && registry && !selectedTemplate && !monorepoPackages) {
|
|
1274
|
+
const probeResult = await probeRegistryIndex(`${registry.rawBaseUrl}/index.json`, registry);
|
|
1275
|
+
registryBackend = probeResult.backend;
|
|
1276
|
+
if (probeResult.templates.length > 0) {
|
|
1277
|
+
// Marketplace mode requires interactive selection — can't auto-select
|
|
1278
|
+
console.log(chalk.red("Error: Registry is a marketplace with multiple templates. " +
|
|
1279
|
+
"Use --template <id> to specify which one, or remove -y for interactive selection."));
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
if (!probeResult.isNotFound) {
|
|
1283
|
+
// Transient error (not 404) — abort, don't misclassify as direct-download
|
|
1284
|
+
console.log(chalk.red(`Error: ${probeResult.error?.message ?? "Could not reach registry. Check your connection and try again."}`));
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
// isNotFound=true → no index.json, proceed with direct download (fetchedTemplates stays empty)
|
|
1288
|
+
}
|
|
1289
|
+
// ==========================================================================
|
|
1290
|
+
// Download Remote Template (if selected or direct registry download)
|
|
1291
|
+
// ==========================================================================
|
|
1292
|
+
let useRemoteTemplate = false;
|
|
1293
|
+
if (selectedTemplate) {
|
|
1294
|
+
// Marketplace mode: download specific template by ID
|
|
1295
|
+
console.log(chalk.blue(`📦 Downloading template "${selectedTemplate}"...`));
|
|
1296
|
+
console.log(chalk.gray(" This may take a moment on slow connections."));
|
|
1297
|
+
// Find pre-fetched SpecTemplate to avoid double-fetch
|
|
1298
|
+
const prefetched = fetchedTemplates.find((t) => t.id === selectedTemplate);
|
|
1299
|
+
const result = await downloadTemplateById(cwd, selectedTemplate, templateStrategy, prefetched, registry, undefined, registryBackend);
|
|
1300
|
+
if (result.success) {
|
|
1301
|
+
if (result.skipped) {
|
|
1302
|
+
console.log(chalk.gray(` ${result.message}`));
|
|
1303
|
+
}
|
|
1304
|
+
else {
|
|
1305
|
+
console.log(chalk.green(` ${result.message}`));
|
|
1306
|
+
useRemoteTemplate = true;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
else {
|
|
1310
|
+
console.log(chalk.yellow(` ${result.message}`));
|
|
1311
|
+
console.log(chalk.gray(" Falling back to blank templates..."));
|
|
1312
|
+
const retryCmd = registry
|
|
1313
|
+
? `rudder init --registry ${registry.gigetSource} --template ${selectedTemplate}`
|
|
1314
|
+
: `rudder init --template ${selectedTemplate}`;
|
|
1315
|
+
console.log(chalk.gray(` You can retry later: ${retryCmd}`));
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
else if (registry && fetchedTemplates.length === 0) {
|
|
1319
|
+
// Direct download mode: registry has no index.json, download directory directly
|
|
1320
|
+
console.log(chalk.blue(`📦 Downloading spec from ${registry.gigetSource}...`));
|
|
1321
|
+
console.log(chalk.gray(" This may take a moment on slow connections."));
|
|
1322
|
+
// Ask about existing spec dir in interactive mode
|
|
1323
|
+
if (!options.yes && !options.overwrite && !options.append) {
|
|
1324
|
+
const specDir = path.join(cwd, PATHS.SPEC);
|
|
1325
|
+
if (fs.existsSync(specDir)) {
|
|
1326
|
+
const actionAnswer = await inquirer.prompt([
|
|
1327
|
+
{
|
|
1328
|
+
type: "list",
|
|
1329
|
+
name: "action",
|
|
1330
|
+
message: `Directory ${PATHS.SPEC} already exists. What do you want to do?`,
|
|
1331
|
+
choices: [
|
|
1332
|
+
{ name: "Skip (keep existing)", value: "skip" },
|
|
1333
|
+
{ name: "Overwrite (replace all)", value: "overwrite" },
|
|
1334
|
+
{ name: "Append (add missing files only)", value: "append" },
|
|
1335
|
+
],
|
|
1336
|
+
default: "skip",
|
|
1337
|
+
},
|
|
1338
|
+
]);
|
|
1339
|
+
templateStrategy = actionAnswer.action;
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
const result = await downloadRegistryDirect(cwd, registry, templateStrategy, undefined, registryBackend);
|
|
1343
|
+
if (result.success) {
|
|
1344
|
+
if (result.skipped) {
|
|
1345
|
+
console.log(chalk.gray(` ${result.message}`));
|
|
1346
|
+
}
|
|
1347
|
+
else {
|
|
1348
|
+
console.log(chalk.green(` ${result.message}`));
|
|
1349
|
+
useRemoteTemplate = true;
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
else {
|
|
1353
|
+
console.log(chalk.yellow(` ${result.message}`));
|
|
1354
|
+
console.log(chalk.gray(" Falling back to blank templates..."));
|
|
1355
|
+
console.log(chalk.gray(` You can retry later: rudder init --registry ${registry.gigetSource}`));
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
// ==========================================================================
|
|
1359
|
+
// Create Workflow Structure
|
|
1360
|
+
// ==========================================================================
|
|
1361
|
+
// Create workflow structure with project type
|
|
1362
|
+
console.log(chalk.blue("📁 Creating workflow structure..."));
|
|
1363
|
+
await createWorkflowStructure(cwd, {
|
|
1364
|
+
projectType,
|
|
1365
|
+
skipSpecTemplates: useRemoteTemplate || migration.migrated,
|
|
1366
|
+
skipConfig: migration.migrated,
|
|
1367
|
+
packages: monorepoPackages,
|
|
1368
|
+
remoteSpecPackages,
|
|
1369
|
+
});
|
|
1370
|
+
// Write monorepo packages to config.yaml (non-destructive patch)
|
|
1371
|
+
if (monorepoPackages) {
|
|
1372
|
+
writeMonorepoConfig(cwd, monorepoPackages);
|
|
1373
|
+
console.log(chalk.blue("📦 Monorepo packages written to config.yaml"));
|
|
1374
|
+
}
|
|
1375
|
+
// Write version file for update tracking
|
|
1376
|
+
const versionPath = path.join(cwd, DIR_NAMES.WORKFLOW, ".version");
|
|
1377
|
+
fs.writeFileSync(versionPath, VERSION);
|
|
1378
|
+
// Configure selected tools by copying entire directories (dogfooding)
|
|
1379
|
+
for (const tool of tools) {
|
|
1380
|
+
const platformId = resolveCliFlag(tool);
|
|
1381
|
+
if (platformId) {
|
|
1382
|
+
console.log(chalk.blue(`📝 Configuring ${AI_TOOLS[platformId].name}...`));
|
|
1383
|
+
await configurePlatform(platformId, cwd);
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
const pythonPlatforms = getPlatformsWithPythonHooks();
|
|
1387
|
+
const hasSelectedPythonPlatform = pythonPlatforms.some((id) => tools.includes(AI_TOOLS[id].cliFlag));
|
|
1388
|
+
if (hasSelectedPythonPlatform) {
|
|
1389
|
+
logPythonAdaptationNotice(pythonCmd);
|
|
1390
|
+
}
|
|
1391
|
+
// Create root files (skip if exists)
|
|
1392
|
+
await createRootFiles(cwd);
|
|
1393
|
+
// Initialize template hashes for modification tracking
|
|
1394
|
+
const hashedCount = initializeHashes(cwd);
|
|
1395
|
+
if (hashedCount > 0) {
|
|
1396
|
+
console.log(chalk.gray(`📋 Tracking ${hashedCount} template files for updates`));
|
|
1397
|
+
}
|
|
1398
|
+
// Initialize developer identity (silent - no output)
|
|
1399
|
+
if (developerName) {
|
|
1400
|
+
try {
|
|
1401
|
+
const scriptPath = path.join(cwd, PATHS.SCRIPTS, "init_developer.py");
|
|
1402
|
+
execSync(`${pythonCmd} "${scriptPath}" "${developerName}"`, {
|
|
1403
|
+
cwd,
|
|
1404
|
+
stdio: "pipe", // Silent
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
catch {
|
|
1408
|
+
// Silent failure - user can run init_developer.py manually
|
|
1409
|
+
}
|
|
1410
|
+
// Three-branch dispatch using flags captured at init() start (before
|
|
1411
|
+
// createWorkflowStructure/init_developer ran, so they reflect the disk
|
|
1412
|
+
// state of the user's checkout, not the state this init just produced):
|
|
1413
|
+
// isFirstInit=true → creator bootstrap (new project)
|
|
1414
|
+
// isFirstInit=false + no .developer file → joiner onboarding (fresh clone)
|
|
1415
|
+
// isFirstInit=false + .developer exists → same-dev re-init, no task
|
|
1416
|
+
//
|
|
1417
|
+
// Tasks-empty fallback (issue #204): if .rudder/ exists but tasks dir is
|
|
1418
|
+
// empty, the previous init aborted before creating the bootstrap task. Run
|
|
1419
|
+
// bootstrap creation regardless of isFirstInit. writeTaskSkeleton is
|
|
1420
|
+
// idempotent so repeated triggers are safe.
|
|
1421
|
+
//
|
|
1422
|
+
// Runs OUTSIDE the init_developer try/catch (which uses stdio: "pipe")
|
|
1423
|
+
// so joiner failures surface as warnings instead of being silently
|
|
1424
|
+
// swallowed.
|
|
1425
|
+
const tasksDir = path.join(cwd, PATHS.TASKS);
|
|
1426
|
+
const tasksEmpty = !fs.existsSync(tasksDir) || fs.readdirSync(tasksDir).length === 0;
|
|
1427
|
+
if (isFirstInit || tasksEmpty) {
|
|
1428
|
+
createBootstrapTask(cwd, developerName, pythonCmd, projectType, monorepoPackages);
|
|
1429
|
+
}
|
|
1430
|
+
else if (!hadDeveloperFileAtStart) {
|
|
1431
|
+
try {
|
|
1432
|
+
if (!createJoinerOnboardingTask(cwd, developerName, pythonCmd)) {
|
|
1433
|
+
console.warn(chalk.yellow("⚠ Failed to create joiner onboarding task"));
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
catch (err) {
|
|
1437
|
+
console.warn(chalk.yellow(`⚠ Joiner onboarding setup failed: ${err instanceof Error ? err.message : String(err)}`));
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* Simple readline-based input (no flickering like inquirer)
|
|
1444
|
+
*/
|
|
1445
|
+
function askInput(prompt) {
|
|
1446
|
+
const rl = readline.createInterface({
|
|
1447
|
+
input: process.stdin,
|
|
1448
|
+
output: process.stdout,
|
|
1449
|
+
});
|
|
1450
|
+
return new Promise((resolve) => {
|
|
1451
|
+
rl.question(prompt, (answer) => {
|
|
1452
|
+
rl.close();
|
|
1453
|
+
resolve(answer.trim());
|
|
1454
|
+
});
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
async function createRootFiles(cwd) {
|
|
1458
|
+
const agentsPath = path.join(cwd, FILE_NAMES.AGENTS);
|
|
1459
|
+
// Write AGENTS.md from template
|
|
1460
|
+
const agentsWritten = await writeFile(agentsPath, agentsMdContent);
|
|
1461
|
+
if (agentsWritten) {
|
|
1462
|
+
console.log(chalk.blue("📄 Created AGENTS.md"));
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
//# sourceMappingURL=init.js.map
|