@jahanxu/trellis 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +235 -0
- package/README.md +212 -0
- package/bin/trellis.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 +97 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/commands/init.d.ts +21 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +527 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/update.d.ts +27 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +1289 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/configurators/antigravity.d.ts +8 -0
- package/dist/configurators/antigravity.d.ts.map +1 -0
- package/dist/configurators/antigravity.js +18 -0
- package/dist/configurators/antigravity.js.map +1 -0
- package/dist/configurators/claude.d.ts +32 -0
- package/dist/configurators/claude.d.ts.map +1 -0
- package/dist/configurators/claude.js +98 -0
- package/dist/configurators/claude.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 +20 -0
- package/dist/configurators/codex.js.map +1 -0
- package/dist/configurators/cursor.d.ts +5 -0
- package/dist/configurators/cursor.d.ts.map +1 -0
- package/dist/configurators/cursor.js +52 -0
- package/dist/configurators/cursor.js.map +1 -0
- package/dist/configurators/gemini.d.ts +8 -0
- package/dist/configurators/gemini.d.ts.map +1 -0
- package/dist/configurators/gemini.js +52 -0
- package/dist/configurators/gemini.js.map +1 -0
- package/dist/configurators/iflow.d.ts +33 -0
- package/dist/configurators/iflow.d.ts.map +1 -0
- package/dist/configurators/iflow.js +99 -0
- package/dist/configurators/iflow.js.map +1 -0
- package/dist/configurators/index.d.ts +55 -0
- package/dist/configurators/index.d.ts.map +1 -0
- package/dist/configurators/index.js +220 -0
- package/dist/configurators/index.js.map +1 -0
- package/dist/configurators/kilo.d.ts +8 -0
- package/dist/configurators/kilo.d.ts.map +1 -0
- package/dist/configurators/kilo.js +51 -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 +20 -0
- package/dist/configurators/kiro.js.map +1 -0
- package/dist/configurators/opencode.d.ts +32 -0
- package/dist/configurators/opencode.d.ts.map +1 -0
- package/dist/configurators/opencode.js +92 -0
- package/dist/configurators/opencode.js.map +1 -0
- package/dist/configurators/shared.d.ts +12 -0
- package/dist/configurators/shared.d.ts.map +1 -0
- package/dist/configurators/shared.js +21 -0
- package/dist/configurators/shared.js.map +1 -0
- package/dist/configurators/workflow.d.ts +28 -0
- package/dist/configurators/workflow.d.ts.map +1 -0
- package/dist/configurators/workflow.js +134 -0
- package/dist/configurators/workflow.js.map +1 -0
- package/dist/constants/paths.d.ts +68 -0
- package/dist/constants/paths.d.ts.map +1 -0
- package/dist/constants/paths.js +77 -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 +54 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +160 -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 +278 -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/templates/antigravity/index.d.ts +12 -0
- package/dist/templates/antigravity/index.d.ts.map +1 -0
- package/dist/templates/antigravity/index.js +29 -0
- package/dist/templates/antigravity/index.js.map +1 -0
- package/dist/templates/claude/agents/check.md +122 -0
- package/dist/templates/claude/agents/debug.md +106 -0
- package/dist/templates/claude/agents/dispatch.md +214 -0
- package/dist/templates/claude/agents/implement.md +96 -0
- package/dist/templates/claude/agents/plan.md +396 -0
- package/dist/templates/claude/agents/research.md +120 -0
- package/dist/templates/claude/commands/trellis/before-backend-dev.md +13 -0
- package/dist/templates/claude/commands/trellis/before-frontend-dev.md +13 -0
- package/dist/templates/claude/commands/trellis/before-role-work.md +364 -0
- package/dist/templates/claude/commands/trellis/brainstorm.md +474 -0
- package/dist/templates/claude/commands/trellis/break-loop.md +125 -0
- package/dist/templates/claude/commands/trellis/check-backend.md +13 -0
- package/dist/templates/claude/commands/trellis/check-cross-layer.md +153 -0
- package/dist/templates/claude/commands/trellis/check-frontend.md +13 -0
- package/dist/templates/claude/commands/trellis/create-command.md +154 -0
- package/dist/templates/claude/commands/trellis/finish-work.md +153 -0
- package/dist/templates/claude/commands/trellis/handoff.md +445 -0
- package/dist/templates/claude/commands/trellis/integrate-skill.md +219 -0
- package/dist/templates/claude/commands/trellis/onboard.md +358 -0
- package/dist/templates/claude/commands/trellis/parallel.md +193 -0
- package/dist/templates/claude/commands/trellis/pick-task.md +515 -0
- package/dist/templates/claude/commands/trellis/record-session.md +62 -0
- package/dist/templates/claude/commands/trellis/start.md +373 -0
- package/dist/templates/claude/commands/trellis/update-spec.md +354 -0
- package/dist/templates/claude/hooks/inject-subagent-context.py +873 -0
- package/dist/templates/claude/hooks/ralph-loop.py +388 -0
- package/dist/templates/claude/hooks/session-start.py +200 -0
- package/dist/templates/claude/index.d.ts +54 -0
- package/dist/templates/claude/index.d.ts.map +1 -0
- package/dist/templates/claude/index.js +85 -0
- package/dist/templates/claude/index.js.map +1 -0
- package/dist/templates/claude/settings.json +41 -0
- package/dist/templates/codex/index.d.ts +18 -0
- package/dist/templates/codex/index.d.ts.map +1 -0
- package/dist/templates/codex/index.js +40 -0
- package/dist/templates/codex/index.js.map +1 -0
- package/dist/templates/codex/skills/before-backend-dev/SKILL.md +18 -0
- package/dist/templates/codex/skills/before-frontend-dev/SKILL.md +18 -0
- package/dist/templates/codex/skills/brainstorm/SKILL.md +479 -0
- package/dist/templates/codex/skills/break-loop/SKILL.md +130 -0
- package/dist/templates/codex/skills/check-backend/SKILL.md +18 -0
- package/dist/templates/codex/skills/check-cross-layer/SKILL.md +158 -0
- package/dist/templates/codex/skills/check-frontend/SKILL.md +18 -0
- package/dist/templates/codex/skills/create-command/SKILL.md +101 -0
- package/dist/templates/codex/skills/finish-work/SKILL.md +148 -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 +330 -0
- package/dist/templates/codex/skills/update-spec/SKILL.md +335 -0
- package/dist/templates/cursor/commands/trellis-before-backend-dev.md +13 -0
- package/dist/templates/cursor/commands/trellis-before-frontend-dev.md +13 -0
- package/dist/templates/cursor/commands/trellis-brainstorm.md +474 -0
- package/dist/templates/cursor/commands/trellis-break-loop.md +107 -0
- package/dist/templates/cursor/commands/trellis-check-backend.md +13 -0
- package/dist/templates/cursor/commands/trellis-check-cross-layer.md +153 -0
- package/dist/templates/cursor/commands/trellis-check-frontend.md +13 -0
- package/dist/templates/cursor/commands/trellis-create-command.md +154 -0
- package/dist/templates/cursor/commands/trellis-finish-work.md +143 -0
- package/dist/templates/cursor/commands/trellis-integrate-skill.md +219 -0
- package/dist/templates/cursor/commands/trellis-onboard.md +358 -0
- package/dist/templates/cursor/commands/trellis-record-session.md +62 -0
- package/dist/templates/cursor/commands/trellis-start.md +366 -0
- package/dist/templates/cursor/commands/trellis-update-spec.md +354 -0
- package/dist/templates/cursor/index.d.ts +24 -0
- package/dist/templates/cursor/index.d.ts.map +1 -0
- package/dist/templates/cursor/index.js +44 -0
- package/dist/templates/cursor/index.js.map +1 -0
- package/dist/templates/extract.d.ts +166 -0
- package/dist/templates/extract.d.ts.map +1 -0
- package/dist/templates/extract.js +296 -0
- package/dist/templates/extract.js.map +1 -0
- package/dist/templates/gemini/commands/trellis/before-backend-dev.toml +17 -0
- package/dist/templates/gemini/commands/trellis/before-frontend-dev.toml +17 -0
- package/dist/templates/gemini/commands/trellis/brainstorm.toml +420 -0
- package/dist/templates/gemini/commands/trellis/break-loop.toml +129 -0
- package/dist/templates/gemini/commands/trellis/check-backend.toml +17 -0
- package/dist/templates/gemini/commands/trellis/check-cross-layer.toml +147 -0
- package/dist/templates/gemini/commands/trellis/check-frontend.toml +17 -0
- package/dist/templates/gemini/commands/trellis/create-command.toml +119 -0
- package/dist/templates/gemini/commands/trellis/finish-work.toml +133 -0
- package/dist/templates/gemini/commands/trellis/integrate-skill.toml +104 -0
- package/dist/templates/gemini/commands/trellis/onboard.toml +111 -0
- package/dist/templates/gemini/commands/trellis/record-session.toml +66 -0
- package/dist/templates/gemini/commands/trellis/start.toml +292 -0
- package/dist/templates/gemini/commands/trellis/update-spec.toml +132 -0
- package/dist/templates/gemini/index.d.ts +21 -0
- package/dist/templates/gemini/index.d.ts.map +1 -0
- package/dist/templates/gemini/index.js +44 -0
- package/dist/templates/gemini/index.js.map +1 -0
- package/dist/templates/iflow/agents/check.md +122 -0
- package/dist/templates/iflow/agents/debug.md +106 -0
- package/dist/templates/iflow/agents/dispatch.md +214 -0
- package/dist/templates/iflow/agents/implement.md +96 -0
- package/dist/templates/iflow/agents/plan.md +396 -0
- package/dist/templates/iflow/agents/research.md +120 -0
- package/dist/templates/iflow/commands/trellis/before-backend-dev.md +13 -0
- package/dist/templates/iflow/commands/trellis/before-frontend-dev.md +13 -0
- package/dist/templates/iflow/commands/trellis/brainstorm.md +474 -0
- package/dist/templates/iflow/commands/trellis/break-loop.md +125 -0
- package/dist/templates/iflow/commands/trellis/check-backend.md +13 -0
- package/dist/templates/iflow/commands/trellis/check-cross-layer.md +153 -0
- package/dist/templates/iflow/commands/trellis/check-frontend.md +13 -0
- package/dist/templates/iflow/commands/trellis/create-command.md +152 -0
- package/dist/templates/iflow/commands/trellis/finish-work.md +153 -0
- package/dist/templates/iflow/commands/trellis/integrate-skill.md +219 -0
- package/dist/templates/iflow/commands/trellis/onboard.md +358 -0
- package/dist/templates/iflow/commands/trellis/parallel.md +193 -0
- package/dist/templates/iflow/commands/trellis/record-session.md +62 -0
- package/dist/templates/iflow/commands/trellis/start.md +373 -0
- package/dist/templates/iflow/commands/trellis/update-spec.md +354 -0
- package/dist/templates/iflow/hooks/inject-subagent-context.py +788 -0
- package/dist/templates/iflow/hooks/ralph-loop.py +388 -0
- package/dist/templates/iflow/hooks/session-start.py +143 -0
- package/dist/templates/iflow/index.d.ts +54 -0
- package/dist/templates/iflow/index.d.ts.map +1 -0
- package/dist/templates/iflow/index.js +85 -0
- package/dist/templates/iflow/index.js.map +1 -0
- package/dist/templates/iflow/settings.json +40 -0
- package/dist/templates/kilo/commands/trellis/before-backend-dev.md +13 -0
- package/dist/templates/kilo/commands/trellis/before-frontend-dev.md +13 -0
- package/dist/templates/kilo/commands/trellis/brainstorm.md +474 -0
- package/dist/templates/kilo/commands/trellis/break-loop.md +125 -0
- package/dist/templates/kilo/commands/trellis/check-backend.md +13 -0
- package/dist/templates/kilo/commands/trellis/check-cross-layer.md +153 -0
- package/dist/templates/kilo/commands/trellis/check-frontend.md +13 -0
- package/dist/templates/kilo/commands/trellis/create-command.md +152 -0
- package/dist/templates/kilo/commands/trellis/finish-work.md +129 -0
- package/dist/templates/kilo/commands/trellis/integrate-skill.md +219 -0
- package/dist/templates/kilo/commands/trellis/onboard.md +358 -0
- package/dist/templates/kilo/commands/trellis/parallel.md +194 -0
- package/dist/templates/kilo/commands/trellis/record-session.md +62 -0
- package/dist/templates/kilo/commands/trellis/start.md +321 -0
- package/dist/templates/kilo/commands/trellis/update-spec.md +285 -0
- package/dist/templates/kilo/index.d.ts +16 -0
- package/dist/templates/kilo/index.d.ts.map +1 -0
- package/dist/templates/kilo/index.js +39 -0
- package/dist/templates/kilo/index.js.map +1 -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 +40 -0
- package/dist/templates/kiro/index.js.map +1 -0
- package/dist/templates/kiro/skills/before-backend-dev/SKILL.md +18 -0
- package/dist/templates/kiro/skills/before-frontend-dev/SKILL.md +18 -0
- package/dist/templates/kiro/skills/brainstorm/SKILL.md +479 -0
- package/dist/templates/kiro/skills/break-loop/SKILL.md +130 -0
- package/dist/templates/kiro/skills/check-backend/SKILL.md +18 -0
- package/dist/templates/kiro/skills/check-cross-layer/SKILL.md +158 -0
- package/dist/templates/kiro/skills/check-frontend/SKILL.md +18 -0
- package/dist/templates/kiro/skills/create-command/SKILL.md +101 -0
- package/dist/templates/kiro/skills/finish-work/SKILL.md +148 -0
- package/dist/templates/kiro/skills/integrate-skill/SKILL.md +221 -0
- package/dist/templates/kiro/skills/onboard/SKILL.md +363 -0
- package/dist/templates/kiro/skills/record-session/SKILL.md +67 -0
- package/dist/templates/kiro/skills/start/SKILL.md +330 -0
- package/dist/templates/kiro/skills/update-spec/SKILL.md +335 -0
- package/dist/templates/markdown/agents.md +18 -0
- package/dist/templates/markdown/gitignore.txt +12 -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 +40 -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/backend/script-conventions.md +467 -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 +118 -0
- package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md.txt +92 -0
- package/dist/templates/markdown/spec/guides/cross-layer-thinking-guide.md.txt +94 -0
- package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md +394 -0
- package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +319 -0
- package/dist/templates/markdown/spec/guides/index.md.txt +79 -0
- package/dist/templates/markdown/workspace-index.md +123 -0
- package/dist/templates/markdown/worktree.yaml.txt +58 -0
- package/dist/templates/opencode/agents/check.md +146 -0
- package/dist/templates/opencode/agents/debug.md +129 -0
- package/dist/templates/opencode/agents/dispatch.md +223 -0
- package/dist/templates/opencode/agents/implement.md +120 -0
- package/dist/templates/opencode/agents/research.md +147 -0
- package/dist/templates/opencode/agents/trellis-plan.md +427 -0
- package/dist/templates/opencode/commands/trellis/before-backend-dev.md +13 -0
- package/dist/templates/opencode/commands/trellis/before-frontend-dev.md +13 -0
- package/dist/templates/opencode/commands/trellis/brainstorm.md +474 -0
- package/dist/templates/opencode/commands/trellis/break-loop.md +125 -0
- package/dist/templates/opencode/commands/trellis/check-backend.md +13 -0
- package/dist/templates/opencode/commands/trellis/check-cross-layer.md +153 -0
- package/dist/templates/opencode/commands/trellis/check-frontend.md +13 -0
- package/dist/templates/opencode/commands/trellis/create-command.md +154 -0
- package/dist/templates/opencode/commands/trellis/finish-work.md +144 -0
- package/dist/templates/opencode/commands/trellis/integrate-skill.md +219 -0
- package/dist/templates/opencode/commands/trellis/migrate-specs.md +0 -0
- package/dist/templates/opencode/commands/trellis/onboard.md +358 -0
- package/dist/templates/opencode/commands/trellis/parallel.md +194 -0
- package/dist/templates/opencode/commands/trellis/record-session.md +62 -0
- package/dist/templates/opencode/commands/trellis/start.md +338 -0
- package/dist/templates/opencode/commands/trellis/update-spec.md +354 -0
- package/dist/templates/opencode/lib/trellis-context.js +436 -0
- package/dist/templates/opencode/package.json +5 -0
- package/dist/templates/opencode/plugin/inject-subagent-context.js +538 -0
- package/dist/templates/opencode/plugin/session-start.js +192 -0
- package/dist/templates/trellis/VERSION +1 -0
- package/dist/templates/trellis/deliverables/README.md +51 -0
- package/dist/templates/trellis/gitignore.txt +29 -0
- package/dist/templates/trellis/index.d.ts +49 -0
- package/dist/templates/trellis/index.d.ts.map +1 -0
- package/dist/templates/trellis/index.js +92 -0
- package/dist/templates/trellis/index.js.map +1 -0
- package/dist/templates/trellis/paths.README.md +277 -0
- package/dist/templates/trellis/paths.yaml +41 -0
- package/dist/templates/trellis/pool/implementations.json +5 -0
- package/dist/templates/trellis/pool/prototypes.json +5 -0
- package/dist/templates/trellis/pool/requirements.json +5 -0
- package/dist/templates/trellis/scripts/__init__.py +5 -0
- package/dist/templates/trellis/scripts/add_session.py +391 -0
- package/dist/templates/trellis/scripts/common/__init__.py +80 -0
- package/dist/templates/trellis/scripts/common/cli_adapter.py +522 -0
- package/dist/templates/trellis/scripts/common/developer.py +189 -0
- package/dist/templates/trellis/scripts/common/git_context.py +383 -0
- package/dist/templates/trellis/scripts/common/paths.py +346 -0
- package/dist/templates/trellis/scripts/common/phase.py +253 -0
- package/dist/templates/trellis/scripts/common/project_paths.py +189 -0
- package/dist/templates/trellis/scripts/common/registry.py +365 -0
- package/dist/templates/trellis/scripts/common/task_queue.py +255 -0
- package/dist/templates/trellis/scripts/common/task_utils.py +177 -0
- package/dist/templates/trellis/scripts/common/worktree.py +218 -0
- package/dist/templates/trellis/scripts/create_bootstrap.py +290 -0
- package/dist/templates/trellis/scripts/get_context.py +16 -0
- package/dist/templates/trellis/scripts/get_developer.py +26 -0
- package/dist/templates/trellis/scripts/handoff_generator.py +380 -0
- package/dist/templates/trellis/scripts/init_developer.py +51 -0
- package/dist/templates/trellis/scripts/multi_agent/__init__.py +5 -0
- package/dist/templates/trellis/scripts/multi_agent/cleanup.py +403 -0
- package/dist/templates/trellis/scripts/multi_agent/create_pr.py +329 -0
- package/dist/templates/trellis/scripts/multi_agent/plan.py +233 -0
- package/dist/templates/trellis/scripts/multi_agent/start.py +461 -0
- package/dist/templates/trellis/scripts/multi_agent/status.py +817 -0
- package/dist/templates/trellis/scripts/pool.py +373 -0
- package/dist/templates/trellis/scripts/task.py +1162 -0
- package/dist/templates/trellis/scripts-shell-archive/add-session.sh +384 -0
- package/dist/templates/trellis/scripts-shell-archive/common/developer.sh +129 -0
- package/dist/templates/trellis/scripts-shell-archive/common/git-context.sh +263 -0
- package/dist/templates/trellis/scripts-shell-archive/common/paths.sh +208 -0
- package/dist/templates/trellis/scripts-shell-archive/common/phase.sh +150 -0
- package/dist/templates/trellis/scripts-shell-archive/common/registry.sh +247 -0
- package/dist/templates/trellis/scripts-shell-archive/common/task-queue.sh +142 -0
- package/dist/templates/trellis/scripts-shell-archive/common/task-utils.sh +151 -0
- package/dist/templates/trellis/scripts-shell-archive/common/worktree.sh +128 -0
- package/dist/templates/trellis/scripts-shell-archive/create-bootstrap.sh +299 -0
- package/dist/templates/trellis/scripts-shell-archive/get-context.sh +7 -0
- package/dist/templates/trellis/scripts-shell-archive/get-developer.sh +15 -0
- package/dist/templates/trellis/scripts-shell-archive/init-developer.sh +34 -0
- package/dist/templates/trellis/scripts-shell-archive/multi-agent/cleanup.sh +396 -0
- package/dist/templates/trellis/scripts-shell-archive/multi-agent/create-pr.sh +241 -0
- package/dist/templates/trellis/scripts-shell-archive/multi-agent/plan.sh +207 -0
- package/dist/templates/trellis/scripts-shell-archive/multi-agent/start.sh +317 -0
- package/dist/templates/trellis/scripts-shell-archive/multi-agent/status.sh +828 -0
- package/dist/templates/trellis/scripts-shell-archive/task.sh +1204 -0
- package/dist/templates/trellis/spec/roles/designer/index.md +243 -0
- package/dist/templates/trellis/spec/roles/designer/mock-data-standards.md +481 -0
- package/dist/templates/trellis/spec/roles/designer/prototype-guidelines.md +429 -0
- package/dist/templates/trellis/spec/roles/frontend-impl/api-integration.md +565 -0
- package/dist/templates/trellis/spec/roles/frontend-impl/index.md +321 -0
- package/dist/templates/trellis/spec/roles/frontend-impl/state-management.md +599 -0
- package/dist/templates/trellis/spec/roles/pm/index.md +112 -0
- package/dist/templates/trellis/spec/roles/pm/prd-template.md +124 -0
- package/dist/templates/trellis/tasks/.gitkeep +0 -0
- package/dist/templates/trellis/workflow.md +416 -0
- package/dist/templates/trellis/worktree.yaml +47 -0
- package/dist/types/ai-tools.d.ts +56 -0
- package/dist/types/ai-tools.d.ts.map +1 -0
- package/dist/types/ai-tools.js +103 -0
- package/dist/types/ai-tools.js.map +1 -0
- package/dist/types/migration.d.ts +86 -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 +76 -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 +140 -0
- package/dist/utils/file-writer.js.map +1 -0
- package/dist/utils/project-detector.d.ts +16 -0
- package/dist/utils/project-detector.d.ts.map +1 -0
- package/dist/utils/project-detector.js +186 -0
- package/dist/utils/project-detector.js.map +1 -0
- package/dist/utils/template-fetcher.d.ts +51 -0
- package/dist/utils/template-fetcher.d.ts.map +1 -0
- package/dist/utils/template-fetcher.js +174 -0
- package/dist/utils/template-fetcher.js.map +1 -0
- package/dist/utils/template-hash.d.ts +78 -0
- package/dist/utils/template-hash.d.ts.map +1 -0
- package/dist/utils/template-hash.js +233 -0
- package/dist/utils/template-hash.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# Designer (交互设计师) 工作规范
|
|
2
|
+
|
|
3
|
+
> 交互设计师在三角色协作中的职责、标准和工作流程
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 角色定位
|
|
8
|
+
|
|
9
|
+
**交互设计师(Designer)** 是三角色协作流水线的**第二环**:
|
|
10
|
+
- 从 `requirements` 池选择需求
|
|
11
|
+
- 基于PRD创建可运行的前端原型(带Mock数据)
|
|
12
|
+
- 产出物进入 `prototypes` 池,供 Frontend 消费
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 工作流程
|
|
17
|
+
|
|
18
|
+
### 1. 选择需求
|
|
19
|
+
```bash
|
|
20
|
+
# 查看可用需求
|
|
21
|
+
python3 .trellis/scripts/pool.py list requirements
|
|
22
|
+
|
|
23
|
+
# 选择需求并创建任务
|
|
24
|
+
/trellis:pick-task requirements <task-id>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
系统会自动:
|
|
28
|
+
- 创建任务目录
|
|
29
|
+
- 设置 `source.json` 引用上游产出
|
|
30
|
+
- 注入上游PRD和HANDOFF文档
|
|
31
|
+
|
|
32
|
+
### 2. 创建原型
|
|
33
|
+
|
|
34
|
+
参考上游的 `HANDOFF.md`,创建:
|
|
35
|
+
- React/Vue组件(推荐使用项目技术栈)
|
|
36
|
+
- Mock数据和Mock API
|
|
37
|
+
- 基本交互逻辑
|
|
38
|
+
|
|
39
|
+
### 3. 完成并交接
|
|
40
|
+
```bash
|
|
41
|
+
/trellis:handoff
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
产出自动进入 `deliverables/prototypes/{task-id}/`
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 原型代码标准
|
|
49
|
+
|
|
50
|
+
### 必需要素
|
|
51
|
+
|
|
52
|
+
#### 1. 可运行性
|
|
53
|
+
- ✅ 原型可以直接 `npm run dev` 运行
|
|
54
|
+
- ✅ 所有交互可以点击/操作
|
|
55
|
+
- ✅ 使用Mock数据模拟真实数据流
|
|
56
|
+
|
|
57
|
+
#### 2. Mock数据规范
|
|
58
|
+
```typescript
|
|
59
|
+
// Mock数据应该结构清晰,易于替换
|
|
60
|
+
// ✅ 推荐:集中管理Mock
|
|
61
|
+
// src/mocks/user.mock.ts
|
|
62
|
+
export const mockUser = {
|
|
63
|
+
id: "mock-user-1",
|
|
64
|
+
name: "张三",
|
|
65
|
+
email: "zhangsan@example.com"
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// ❌ 避免:硬编码分散各处
|
|
69
|
+
const user = { name: "张三" }; // 不易查找和替换
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### 3. Mock API位置标注
|
|
73
|
+
```typescript
|
|
74
|
+
// ✅ 使用清晰的TODO注释
|
|
75
|
+
const handleLogin = async (email: string, password: string) => {
|
|
76
|
+
// TODO: [Frontend] 替换为真实API调用 /api/auth/login
|
|
77
|
+
return new Promise(resolve => {
|
|
78
|
+
setTimeout(() => resolve(mockUser), 1000);
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 组件结构规范
|
|
84
|
+
|
|
85
|
+
**推荐分层**:
|
|
86
|
+
```
|
|
87
|
+
src/
|
|
88
|
+
├── pages/ # 页面级组件
|
|
89
|
+
│ └── LoginPage.tsx
|
|
90
|
+
├── components/ # 复用组件
|
|
91
|
+
│ ├── LoginForm.tsx
|
|
92
|
+
│ └── SocialLoginButtons.tsx
|
|
93
|
+
├── mocks/ # Mock数据
|
|
94
|
+
│ └── auth.mock.ts
|
|
95
|
+
└── types/ # TypeScript类型定义
|
|
96
|
+
└── user.ts
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 样式规范
|
|
100
|
+
|
|
101
|
+
根据项目技术栈选择:
|
|
102
|
+
- **Tailwind CSS** - 推荐用于快速原型
|
|
103
|
+
- **CSS Modules** - 适合组件隔离
|
|
104
|
+
- **Styled Components** - 适合复杂主题
|
|
105
|
+
|
|
106
|
+
**原则**:样式应该**接近最终效果**,但不必完美实现所有细节。
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## HANDOFF文档要点
|
|
111
|
+
|
|
112
|
+
AI生成的 `HANDOFF.md` 应包含:
|
|
113
|
+
|
|
114
|
+
### 设计说明
|
|
115
|
+
- 整体布局思路
|
|
116
|
+
- 主要组件设计理由
|
|
117
|
+
- 交互流程说明
|
|
118
|
+
|
|
119
|
+
### 组件结构
|
|
120
|
+
```
|
|
121
|
+
App
|
|
122
|
+
├── LoginPage
|
|
123
|
+
│ ├── LoginForm (核心表单)
|
|
124
|
+
│ │ ├── EmailInput
|
|
125
|
+
│ │ └── PasswordInput
|
|
126
|
+
│ └── SocialLoginButtons (第三方登录)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Mock数据说明
|
|
130
|
+
```typescript
|
|
131
|
+
// 清楚标注每个Mock数据的位置和用途
|
|
132
|
+
const mockUser = { ... }; // 位置:src/mocks/auth.mock.ts:10
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 需要Frontend补充的逻辑
|
|
136
|
+
|
|
137
|
+
**明确列出**:
|
|
138
|
+
1. **API集成点** - 哪些函数需要替换为真实API
|
|
139
|
+
- 文件:`LoginPage.tsx:45`
|
|
140
|
+
- Mock: `mockLogin()`
|
|
141
|
+
- 真实API: `POST /api/auth/login`
|
|
142
|
+
|
|
143
|
+
2. **状态管理** - 需要接入全局状态的部分
|
|
144
|
+
- 用户登录状态
|
|
145
|
+
- Token存储和刷新
|
|
146
|
+
|
|
147
|
+
3. **错误处理** - 需要完善的错误场景
|
|
148
|
+
- 网络超时
|
|
149
|
+
- 登录失败(密码错误、账号不存在)
|
|
150
|
+
- 表单验证错误
|
|
151
|
+
|
|
152
|
+
### 特别注意事项
|
|
153
|
+
|
|
154
|
+
**需要保留的设计**:
|
|
155
|
+
- 特定的交互动画
|
|
156
|
+
- 品牌色使用
|
|
157
|
+
- 布局细节
|
|
158
|
+
|
|
159
|
+
**可以优化的部分**:
|
|
160
|
+
- 性能优化(lazy loading等)
|
|
161
|
+
- 代码结构调整
|
|
162
|
+
- 组件拆分
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 质量检查清单
|
|
167
|
+
|
|
168
|
+
在执行 `/trellis:handoff` 前,确保:
|
|
169
|
+
|
|
170
|
+
- [ ] 原型可运行(npm run dev 无报错)
|
|
171
|
+
- [ ] 所有交互可操作(按钮、表单、链接)
|
|
172
|
+
- [ ] Mock数据结构合理(接近真实API)
|
|
173
|
+
- [ ] TODO注释清晰(标注需要替换的Mock)
|
|
174
|
+
- [ ] 组件命名语义化
|
|
175
|
+
- [ ] 已测试关键交互流程
|
|
176
|
+
- [ ] HANDOFF文档包含所有关键信息
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Mock数据最佳实践
|
|
181
|
+
|
|
182
|
+
### 1. 集中管理
|
|
183
|
+
```typescript
|
|
184
|
+
// src/mocks/index.ts
|
|
185
|
+
export { mockUser, mockUserList } from './user.mock';
|
|
186
|
+
export { mockProduct, mockProductList } from './product.mock';
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### 2. 类型安全
|
|
190
|
+
```typescript
|
|
191
|
+
// src/types/user.ts
|
|
192
|
+
export interface User {
|
|
193
|
+
id: string;
|
|
194
|
+
name: string;
|
|
195
|
+
email: string;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// src/mocks/user.mock.ts
|
|
199
|
+
import type { User } from '../types/user';
|
|
200
|
+
|
|
201
|
+
export const mockUser: User = {
|
|
202
|
+
id: "1",
|
|
203
|
+
name: "张三",
|
|
204
|
+
email: "zhangsan@example.com"
|
|
205
|
+
};
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### 3. 真实性
|
|
209
|
+
```typescript
|
|
210
|
+
// ✅ Mock数据应该接近真实场景
|
|
211
|
+
export const mockUserList: User[] = [
|
|
212
|
+
{ id: "1", name: "张三", email: "zhangsan@example.com" },
|
|
213
|
+
{ id: "2", name: "李四", email: "lisi@example.com" },
|
|
214
|
+
// ... 10-20条数据,测试分页、滚动等
|
|
215
|
+
];
|
|
216
|
+
|
|
217
|
+
// ❌ 避免过于简化
|
|
218
|
+
export const mockUserList = [{ id: "1", name: "test" }];
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## 常见问题
|
|
224
|
+
|
|
225
|
+
### Q: 原型需要实现所有PRD功能吗?
|
|
226
|
+
A: 实现核心流程即可。边缘场景可以用TODO注释标注,交给Frontend补充。
|
|
227
|
+
|
|
228
|
+
### Q: Mock数据应该多详细?
|
|
229
|
+
A: 结构完整、字段真实。数量上:列表型数据10-20条,单条数据包含所有字段。
|
|
230
|
+
|
|
231
|
+
### Q: 需要实现响应式设计吗?
|
|
232
|
+
A: 根据PRD要求。如果PRD要求多端适配,原型应体现主要断点。
|
|
233
|
+
|
|
234
|
+
### Q: 如何处理复杂交互?
|
|
235
|
+
A: 核心交互必须可操作,动画和过渡效果可简化。在HANDOFF中说明预期效果。
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## 参考资料
|
|
240
|
+
|
|
241
|
+
- [原型代码指南](./prototype-guidelines.md)
|
|
242
|
+
- [Mock数据标准](./mock-data-standards.md)
|
|
243
|
+
- [组件设计模式](./component-patterns.md)
|
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
# Mock 数据标准
|
|
2
|
+
|
|
3
|
+
> Designer 角色创建和管理 Mock 数据的规范
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 核心原则
|
|
8
|
+
|
|
9
|
+
Mock 数据应该:
|
|
10
|
+
1. **结构完整** - 包含所有必需字段
|
|
11
|
+
2. **类型安全** - 符合 TypeScript 类型定义
|
|
12
|
+
3. **接近真实** - 数据内容符合真实场景
|
|
13
|
+
4. **易于替换** - Frontend 可以快速找到并替换
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 数据组织规范
|
|
18
|
+
|
|
19
|
+
### 目录结构
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
src/mocks/
|
|
23
|
+
├── index.ts # 统一导出
|
|
24
|
+
├── auth.mock.ts # 认证相关
|
|
25
|
+
├── user.mock.ts # 用户数据
|
|
26
|
+
├── product.mock.ts # 产品数据
|
|
27
|
+
└── order.mock.ts # 订单数据
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 统一导出
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
// src/mocks/index.ts
|
|
34
|
+
export * from './auth.mock';
|
|
35
|
+
export * from './user.mock';
|
|
36
|
+
export * from './product.mock';
|
|
37
|
+
export * from './order.mock';
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**使用方式**:
|
|
41
|
+
```typescript
|
|
42
|
+
import { mockUser, mockProductList } from '@/mocks';
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 类型定义规范
|
|
48
|
+
|
|
49
|
+
### 1. 类型优先
|
|
50
|
+
|
|
51
|
+
先定义类型,再创建 Mock 数据:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
// src/types/user.ts
|
|
55
|
+
export interface User {
|
|
56
|
+
id: string;
|
|
57
|
+
name: string;
|
|
58
|
+
email: string;
|
|
59
|
+
avatar?: string;
|
|
60
|
+
role: 'admin' | 'user' | 'guest';
|
|
61
|
+
createdAt: string;
|
|
62
|
+
updatedAt: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/mocks/user.mock.ts
|
|
66
|
+
import type { User } from '@/types/user';
|
|
67
|
+
|
|
68
|
+
export const mockUser: User = {
|
|
69
|
+
id: "user-001",
|
|
70
|
+
name: "张三",
|
|
71
|
+
email: "zhangsan@example.com",
|
|
72
|
+
avatar: "https://i.pravatar.cc/150?img=1",
|
|
73
|
+
role: "user",
|
|
74
|
+
createdAt: "2026-01-01T00:00:00Z",
|
|
75
|
+
updatedAt: "2026-02-01T10:30:00Z"
|
|
76
|
+
};
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 2. 可选字段处理
|
|
80
|
+
|
|
81
|
+
对于可选字段,提供有值和无值两种 Mock:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
export const mockUserWithAvatar: User = {
|
|
85
|
+
id: "user-001",
|
|
86
|
+
name: "张三",
|
|
87
|
+
email: "zhangsan@example.com",
|
|
88
|
+
avatar: "https://i.pravatar.cc/150?img=1",
|
|
89
|
+
role: "user",
|
|
90
|
+
createdAt: "2026-01-01T00:00:00Z",
|
|
91
|
+
updatedAt: "2026-02-01T10:30:00Z"
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const mockUserWithoutAvatar: User = {
|
|
95
|
+
id: "user-002",
|
|
96
|
+
name: "李四",
|
|
97
|
+
email: "lisi@example.com",
|
|
98
|
+
// avatar: undefined (可选字段,不提供)
|
|
99
|
+
role: "user",
|
|
100
|
+
createdAt: "2026-01-02T00:00:00Z",
|
|
101
|
+
updatedAt: "2026-02-02T11:00:00Z"
|
|
102
|
+
};
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 数据真实性规范
|
|
108
|
+
|
|
109
|
+
### 1. 字段内容要求
|
|
110
|
+
|
|
111
|
+
| 字段类型 | Mock 数据要求 | 示例 |
|
|
112
|
+
|---------|-------------|------|
|
|
113
|
+
| **ID** | 语义化前缀 + 数字 | `user-001`, `prod-A123` |
|
|
114
|
+
| **姓名** | 常见中文姓名 | 张三、李四、王五 |
|
|
115
|
+
| **邮箱** | 真实邮箱格式 | `zhangsan@example.com` |
|
|
116
|
+
| **URL** | 可访问的占位图 | `https://via.placeholder.com/150` |
|
|
117
|
+
| **日期** | ISO 8601 格式 | `2026-01-01T00:00:00Z` |
|
|
118
|
+
| **枚举** | 覆盖所有可能值 | `'pending' | 'approved' | 'rejected'` |
|
|
119
|
+
|
|
120
|
+
### 2. 数量要求
|
|
121
|
+
|
|
122
|
+
**单条数据**:包含所有字段
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
export const mockProduct: Product = {
|
|
126
|
+
id: "prod-001",
|
|
127
|
+
name: "iPhone 15 Pro",
|
|
128
|
+
description: "苹果最新旗舰手机,搭载A17 Pro芯片",
|
|
129
|
+
price: 7999,
|
|
130
|
+
stock: 50,
|
|
131
|
+
category: "电子产品",
|
|
132
|
+
tags: ["手机", "苹果", "5G"],
|
|
133
|
+
images: [
|
|
134
|
+
"https://via.placeholder.com/400x300",
|
|
135
|
+
"https://via.placeholder.com/400x300"
|
|
136
|
+
],
|
|
137
|
+
createdAt: "2026-01-15T10:30:00Z"
|
|
138
|
+
};
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**列表数据**:10-20 条,覆盖边缘场景
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
export const mockProductList: Product[] = [
|
|
145
|
+
{
|
|
146
|
+
id: "prod-001",
|
|
147
|
+
name: "iPhone 15 Pro",
|
|
148
|
+
price: 7999,
|
|
149
|
+
stock: 50,
|
|
150
|
+
category: "电子产品",
|
|
151
|
+
// ...
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: "prod-002",
|
|
155
|
+
name: "MacBook Pro 16\"",
|
|
156
|
+
price: 19999,
|
|
157
|
+
stock: 20,
|
|
158
|
+
category: "电脑",
|
|
159
|
+
// ...
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
id: "prod-003",
|
|
163
|
+
name: "AirPods Pro 2",
|
|
164
|
+
price: 1899,
|
|
165
|
+
stock: 0, // ✅ 边缘场景:库存为0
|
|
166
|
+
category: "配件",
|
|
167
|
+
// ...
|
|
168
|
+
},
|
|
169
|
+
// ... 继续到 10-20 条
|
|
170
|
+
];
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 3. 边缘场景覆盖
|
|
174
|
+
|
|
175
|
+
Mock 数据应该包含边缘场景:
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
export const mockOrderList: Order[] = [
|
|
179
|
+
{
|
|
180
|
+
id: "order-001",
|
|
181
|
+
status: "pending", // 待支付
|
|
182
|
+
total: 7999,
|
|
183
|
+
// ...
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
id: "order-002",
|
|
187
|
+
status: "paid", // 已支付
|
|
188
|
+
total: 19999,
|
|
189
|
+
// ...
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
id: "order-003",
|
|
193
|
+
status: "cancelled", // 已取消
|
|
194
|
+
total: 1899,
|
|
195
|
+
// ...
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
id: "order-004",
|
|
199
|
+
status: "refunded", // 已退款
|
|
200
|
+
total: 5999,
|
|
201
|
+
// ...
|
|
202
|
+
},
|
|
203
|
+
];
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## API 响应格式规范
|
|
209
|
+
|
|
210
|
+
### 1. 统一响应结构
|
|
211
|
+
|
|
212
|
+
定义统一的 API 响应格式:
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
// src/types/api.ts
|
|
216
|
+
export interface ApiResponse<T> {
|
|
217
|
+
code: number;
|
|
218
|
+
message: string;
|
|
219
|
+
data: T;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface ApiListResponse<T> {
|
|
223
|
+
code: number;
|
|
224
|
+
message: string;
|
|
225
|
+
data: {
|
|
226
|
+
items: T[];
|
|
227
|
+
total: number;
|
|
228
|
+
page: number;
|
|
229
|
+
pageSize: number;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### 2. Mock API 响应
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
// src/mocks/auth.mock.ts
|
|
238
|
+
import type { ApiResponse } from '@/types/api';
|
|
239
|
+
import type { User } from '@/types/user';
|
|
240
|
+
|
|
241
|
+
export const mockLoginResponse: ApiResponse<{ user: User; token: string }> = {
|
|
242
|
+
code: 200,
|
|
243
|
+
message: "登录成功",
|
|
244
|
+
data: {
|
|
245
|
+
user: mockUser,
|
|
246
|
+
token: "mock-jwt-token-xxx"
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
export const mockLoginErrorResponse: ApiResponse<null> = {
|
|
251
|
+
code: 401,
|
|
252
|
+
message: "邮箱或密码错误",
|
|
253
|
+
data: null
|
|
254
|
+
};
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### 3. 分页数据 Mock
|
|
258
|
+
|
|
259
|
+
```typescript
|
|
260
|
+
export const mockProductListResponse: ApiListResponse<Product> = {
|
|
261
|
+
code: 200,
|
|
262
|
+
message: "成功",
|
|
263
|
+
data: {
|
|
264
|
+
items: mockProductList.slice(0, 10), // 第一页
|
|
265
|
+
total: 50,
|
|
266
|
+
page: 1,
|
|
267
|
+
pageSize: 10
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Mock 函数规范
|
|
275
|
+
|
|
276
|
+
### 1. Mock API 函数
|
|
277
|
+
|
|
278
|
+
每个 API 端点对应一个 Mock 函数:
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
// src/mocks/api/auth.mock.ts
|
|
282
|
+
import type { User } from '@/types/user';
|
|
283
|
+
import { mockUser, mockLoginErrorResponse } from '@/mocks/auth.mock';
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Mock 登录 API
|
|
287
|
+
* TODO: [Frontend] 替换为真实API调用 POST /api/auth/login
|
|
288
|
+
*/
|
|
289
|
+
export const mockLoginAPI = async (
|
|
290
|
+
email: string,
|
|
291
|
+
password: string
|
|
292
|
+
): Promise<{ user: User; token: string }> => {
|
|
293
|
+
return new Promise((resolve, reject) => {
|
|
294
|
+
setTimeout(() => {
|
|
295
|
+
// 模拟登录失败
|
|
296
|
+
if (email === "fail@example.com") {
|
|
297
|
+
reject(new Error(mockLoginErrorResponse.message));
|
|
298
|
+
} else {
|
|
299
|
+
resolve({
|
|
300
|
+
user: mockUser,
|
|
301
|
+
token: "mock-jwt-token-xxx"
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
}, 1000); // 模拟网络延迟
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### 2. Mock 函数文档注释
|
|
310
|
+
|
|
311
|
+
必须包含:
|
|
312
|
+
- 功能说明
|
|
313
|
+
- TODO 标记(指明需要 Frontend 替换)
|
|
314
|
+
- 真实 API 路径
|
|
315
|
+
|
|
316
|
+
```typescript
|
|
317
|
+
/**
|
|
318
|
+
* Mock 获取用户列表 API
|
|
319
|
+
*
|
|
320
|
+
* TODO: [Frontend] 替换为真实API调用 GET /api/users?page=1&pageSize=10
|
|
321
|
+
*
|
|
322
|
+
* @param page 页码
|
|
323
|
+
* @param pageSize 每页数量
|
|
324
|
+
* @returns 用户列表响应
|
|
325
|
+
*/
|
|
326
|
+
export const mockGetUsersAPI = async (
|
|
327
|
+
page: number = 1,
|
|
328
|
+
pageSize: number = 10
|
|
329
|
+
): Promise<ApiListResponse<User>> => {
|
|
330
|
+
// Mock 实现
|
|
331
|
+
};
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## 占位资源规范
|
|
337
|
+
|
|
338
|
+
### 1. 图片占位
|
|
339
|
+
|
|
340
|
+
推荐使用的占位图服务:
|
|
341
|
+
|
|
342
|
+
| 服务 | URL 格式 | 示例 |
|
|
343
|
+
|------|---------|------|
|
|
344
|
+
| **Placeholder.com** | `https://via.placeholder.com/{width}x{height}` | `https://via.placeholder.com/400x300` |
|
|
345
|
+
| **Pravatar** | `https://i.pravatar.cc/{size}?img={id}` | `https://i.pravatar.cc/150?img=1` |
|
|
346
|
+
| **Picsum** | `https://picsum.photos/{width}/{height}` | `https://picsum.photos/400/300` |
|
|
347
|
+
|
|
348
|
+
**示例**:
|
|
349
|
+
```typescript
|
|
350
|
+
export const mockProduct: Product = {
|
|
351
|
+
id: "prod-001",
|
|
352
|
+
name: "iPhone 15 Pro",
|
|
353
|
+
images: [
|
|
354
|
+
"https://via.placeholder.com/400x300?text=iPhone+15+Pro",
|
|
355
|
+
"https://via.placeholder.com/400x300?text=Detail+View",
|
|
356
|
+
],
|
|
357
|
+
// ...
|
|
358
|
+
};
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### 2. 头像占位
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
export const mockUser: User = {
|
|
365
|
+
id: "user-001",
|
|
366
|
+
name: "张三",
|
|
367
|
+
avatar: "https://i.pravatar.cc/150?img=1", // 固定头像 ID
|
|
368
|
+
// ...
|
|
369
|
+
};
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## Mock 数据维护规范
|
|
375
|
+
|
|
376
|
+
### 1. 文件大小控制
|
|
377
|
+
|
|
378
|
+
单个 Mock 文件不超过 **300 行**
|
|
379
|
+
|
|
380
|
+
**✅ 推荐**:按功能拆分
|
|
381
|
+
```
|
|
382
|
+
src/mocks/
|
|
383
|
+
├── user.mock.ts # 用户相关
|
|
384
|
+
├── product.mock.ts # 产品相关
|
|
385
|
+
└── order.mock.ts # 订单相关
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
**❌ 避免**:所有 Mock 放在一个文件
|
|
389
|
+
```
|
|
390
|
+
src/mocks/
|
|
391
|
+
└── data.mock.ts # 1000+ 行,难以维护
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### 2. 更新频率
|
|
395
|
+
|
|
396
|
+
- **需求变更时**:同步更新 Mock 数据结构
|
|
397
|
+
- **Frontend 反馈时**:补充缺失字段或场景
|
|
398
|
+
|
|
399
|
+
### 3. 删除时机
|
|
400
|
+
|
|
401
|
+
**不要删除 Mock 数据**!Frontend 需要用于测试。
|
|
402
|
+
|
|
403
|
+
建议:
|
|
404
|
+
- 保留在 `src/mocks/` 目录
|
|
405
|
+
- Frontend 会将其移动到 `__tests__/mocks/` 用于测试
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
## 检查清单
|
|
410
|
+
|
|
411
|
+
在交接给 Frontend 前,确保:
|
|
412
|
+
|
|
413
|
+
- [ ] 所有 Mock 数据符合 TypeScript 类型定义
|
|
414
|
+
- [ ] 列表数据包含 10-20 条记录
|
|
415
|
+
- [ ] 覆盖主要边缘场景(空值、错误状态等)
|
|
416
|
+
- [ ] Mock API 函数包含 TODO 注释
|
|
417
|
+
- [ ] 占位图片 URL 可访问
|
|
418
|
+
- [ ] 日期格式统一为 ISO 8601
|
|
419
|
+
- [ ] 统一导出到 `src/mocks/index.ts`
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
423
|
+
## 常见问题
|
|
424
|
+
|
|
425
|
+
### Q: Mock 数据量应该多大?
|
|
426
|
+
A:
|
|
427
|
+
- **单条数据**:完整包含所有字段
|
|
428
|
+
- **列表数据**:10-20 条,覆盖边缘场景
|
|
429
|
+
- **分页数据**:模拟 total 为 50-100,但只返回当前页
|
|
430
|
+
|
|
431
|
+
### Q: 如何处理关联数据?
|
|
432
|
+
A: 使用外键 ID 关联,但 Mock 数据中可以直接嵌套对象
|
|
433
|
+
|
|
434
|
+
```typescript
|
|
435
|
+
// ✅ 推荐:嵌套完整对象(原型阶段方便显示)
|
|
436
|
+
export const mockOrder: Order = {
|
|
437
|
+
id: "order-001",
|
|
438
|
+
user: mockUser, // 嵌套完整用户对象
|
|
439
|
+
products: mockProductList.slice(0, 2),
|
|
440
|
+
// ...
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
// Frontend 会改为:
|
|
444
|
+
export const mockOrder: Order = {
|
|
445
|
+
id: "order-001",
|
|
446
|
+
userId: "user-001", // 只保留 ID
|
|
447
|
+
productIds: ["prod-001", "prod-002"],
|
|
448
|
+
// ...
|
|
449
|
+
};
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
### Q: Mock 数据需要模拟权限吗?
|
|
453
|
+
A: 不需要。权限验证由 Frontend 实现。
|
|
454
|
+
|
|
455
|
+
### Q: 如何模拟 API 错误?
|
|
456
|
+
A: 提供特定输入触发错误
|
|
457
|
+
|
|
458
|
+
```typescript
|
|
459
|
+
export const mockLoginAPI = async (email: string, password: string) => {
|
|
460
|
+
// TODO: [Frontend] 替换为真实API调用
|
|
461
|
+
return new Promise((resolve, reject) => {
|
|
462
|
+
setTimeout(() => {
|
|
463
|
+
if (email === "error@example.com") {
|
|
464
|
+
reject(new Error("网络错误"));
|
|
465
|
+
} else if (password === "wrong") {
|
|
466
|
+
reject(new Error("密码错误"));
|
|
467
|
+
} else {
|
|
468
|
+
resolve({ user: mockUser, token: "xxx" });
|
|
469
|
+
}
|
|
470
|
+
}, 1000);
|
|
471
|
+
});
|
|
472
|
+
};
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
---
|
|
476
|
+
|
|
477
|
+
## 相关文档
|
|
478
|
+
|
|
479
|
+
- [原型代码指南](./prototype-guidelines.md)
|
|
480
|
+
- [Designer 工作规范](./index.md)
|
|
481
|
+
- [TypeScript 类型规范](../../frontend/type-safety.md)
|