4.7 KiB
4.7 KiB
Vertical Slice + Core ハイブリッド構成 マッピング案
目的
- CLI中心の機能(コマンド)を slice 化し、変更影響を局所化する。
- Workflow Engine などのコアは内向き依存(Clean)で保護する。
- Public API(
index.ts)で境界を固定し、深い import を避ける。
依存ルール(簡易)
coreは外側に依存しない。infraはcoreに依存できる。featuresはcore/infra/sharedに依存できる。appは配線専用(入口)。
移行マップ
1) app/cli(CLI入口・配線)
src/cli/index.ts -> src/app/cli/index.ts
src/cli/program.ts -> src/app/cli/program.ts
src/cli/commands.ts -> src/app/cli/commands.ts
src/cli/routing.ts -> src/app/cli/routing.ts
src/cli/helpers.ts -> src/app/cli/helpers.ts
app/cli/index.tsは CLI エントリのみ。- ルーティングは
featuresの Public API を呼ぶだけにする。
2) features(コマンド単位)
src/commands/index.ts -> src/features/tasks/index.ts
src/commands/runAllTasks.ts -> src/features/tasks/run/index.ts
src/commands/watchTasks.ts -> src/features/tasks/watch/index.ts
src/commands/addTask.ts -> src/features/tasks/add/index.ts
src/commands/listTasks.ts -> src/features/tasks/list/index.ts
src/commands/execution/selectAndExecute.ts -> src/features/tasks/execute/selectAndExecute.ts
src/commands/execution/types.ts -> src/features/tasks/execute/types.ts
src/commands/pipeline/executePipeline.ts -> src/features/pipeline/execute.ts
src/commands/pipeline/index.ts -> src/features/pipeline/index.ts
src/commands/switchWorkflow.ts -> src/features/config/switchWorkflow.ts
src/commands/switchConfig.ts -> src/features/config/switchConfig.ts
src/commands/ejectBuiltin.ts -> src/features/config/ejectBuiltin.ts
features/tasksは run/watch/add/list の共通入口を持つ。features/pipelineは pipeline モードの専用 slice。features/configは設定系(switch/eject)を集約。
3) core/workflow(中核ロジック)
src/workflow/engine/* -> src/core/workflow/engine/*
src/workflow/instruction/* -> src/core/workflow/instruction/*
src/workflow/evaluation/* -> src/core/workflow/evaluation/*
src/workflow/types.ts -> src/core/workflow/types.ts
src/workflow/constants.ts -> src/core/workflow/constants.ts
src/workflow/index.ts -> src/core/workflow/index.ts
core/workflow/index.tsだけを Public API として使用。engine/,instruction/,evaluation/間の依存は内向き(core 内のみ)。
4) core/models(型・スキーマ)
src/models/schemas.ts -> src/core/models/schemas.ts
src/models/types.ts -> src/core/models/types.ts
src/models/workflow-types.ts -> src/core/models/workflow-types.ts
src/models/index.ts -> src/core/models/index.ts
core/models/index.tsを Public API 化。
5) infra(外部I/O)
src/providers/* -> src/infra/providers/*
src/github/* -> src/infra/github/*
src/config/* -> src/infra/config/*
src/task/* -> src/infra/task/*
src/utils/session.ts -> src/infra/fs/session.ts
src/utils/git/* -> src/infra/git/*
- GitHub API / FS / Git / Provider など外部依存は
infraに集約。
6) shared(横断ユーティリティ)
src/utils/error.ts -> src/shared/utils/error.ts
src/utils/debug.ts -> src/shared/utils/debug.ts
src/utils/ui.ts -> src/shared/ui/index.ts
src/utils/* -> src/shared/utils/* (外部I/O以外)
- 共有は
sharedに集めるが、肥大化は避ける。
7) docs(参照パス修正)
docs/data-flow.md -> パス参照を app/core/features に合わせて更新
`src/cli.ts` 参照 -> `src/app/cli/index.ts` に更新
`src/workflow/state-manager.ts` 参照 -> `src/core/workflow/engine/state-manager.ts`
`src/workflow/transitions.ts` 参照 -> `src/core/workflow/engine/transitions.ts`
Public API ルール
core/*とfeatures/*は 必ずindex.tsから import。- 深い import(
../engine/xxxなど)は禁止。
移行順序(推奨)
core/に workflow + models を集約infra/に外部I/Oを移動features/にコマンド単位で集約app/cliにエントリを移す- Public API を整理し、深い import を排除
- docs の参照を更新
備考
src/workflow/index.tsはcore/workflow/index.tsに移し、外部からはここだけを参照。src/models/workflow.tsのようなプレースホルダは廃止するか、core/models/index.tsへ統合する。