diff --git a/builtins/en/facets/instructions/team-leader-implement.md b/builtins/en/facets/instructions/team-leader-implement.md new file mode 100644 index 0000000..e598dc0 --- /dev/null +++ b/builtins/en/facets/instructions/team-leader-implement.md @@ -0,0 +1,27 @@ +Decompose the implementation task into subtasks by file ownership and execute them in parallel. Assign files exclusively to each part to prevent conflicts. + +**Important:** Reference the plan report: {report:plan.md} + +**Steps:** + +1. Identify files to create/modify + - Reference the plan report and test scope to list all files to change + - Review the actual codebase to fill in any missing information + +2. Group files by layer/module + - Create groups based on high cohesion (e.g., Domain layer / Infrastructure layer / API layer) + - If there are type or interface dependencies, keep both sides in the same group + - Never assign the same file to multiple parts + +3. Assign file ownership exclusively to each part + - Each part's instruction must clearly state: + - **Responsible files** (list of files to create/modify) + - **Reference-only files** (read-only, modification prohibited) + - **Implementation task** (what and how to implement) + - **Completion criteria** (implementation of responsible files is complete) + - If tests are already written, instruct parts to implement so existing tests pass + - Do not include build checks (all parts complete first, then build is verified together) + +**Constraints:** +- Parts do not run tests (handled by subsequent movements) +- Do not modify files outside your responsibility (causes conflicts) diff --git a/builtins/en/facets/knowledge/takt.md b/builtins/en/facets/knowledge/takt.md new file mode 100644 index 0000000..806a6f0 --- /dev/null +++ b/builtins/en/facets/knowledge/takt.md @@ -0,0 +1,151 @@ +# TAKT Architecture Knowledge + +## Core Structure + +PieceEngine is a state machine. It manages movement transitions via EventEmitter. + +``` +CLI → PieceEngine → Runner (4 types) → RuleEvaluator → next movement +``` + +| Runner | Purpose | When to Use | +|--------|---------|-------------| +| MovementExecutor | Standard 3-phase execution | Default | +| ParallelRunner | Concurrent sub-movements | parallel block | +| ArpeggioRunner | Data-driven batch processing | arpeggio block | +| TeamLeaderRunner | Task decomposition → parallel sub-agents | team_leader block | + +Runners are mutually exclusive. Do not specify multiple runner types on a single movement. + +### 3-Phase Execution Model + +Normal movements execute in up to 3 phases. Sessions persist across phases. + +| Phase | Purpose | Tools | Condition | +|-------|---------|-------|-----------| +| Phase 1 | Main work | Movement's allowed_tools | Always | +| Phase 2 | Report output | Write only | When output_contracts defined | +| Phase 3 | Status judgment | None (judgment only) | When tag-based rules exist | + +## Rule Evaluation + +RuleEvaluator determines the next movement via 5-stage fallback. Earlier match takes priority. + +| Priority | Method | Target | +|----------|--------|--------| +| 1 | aggregate | parallel parent (all/any) | +| 2 | Phase 3 tag | `[STEP:N]` output | +| 3 | Phase 1 tag | `[STEP:N]` output (fallback) | +| 4 | ai() judge | ai("condition") rules | +| 5 | AI fallback | AI evaluates all conditions | + +When multiple tags appear in output, the **last match** wins. + +### Condition Syntax + +| Syntax | Parsing | Regex | +|--------|---------|-------| +| `ai("...")` | AI condition evaluation | `AI_CONDITION_REGEX` | +| `all("...")` / `any("...")` | Aggregate condition | `AGGREGATE_CONDITION_REGEX` | +| Plain string | Tag or AI fallback | — | + +Adding new special syntax requires updating both pieceParser.ts regex and RuleEvaluator. + +## Provider Integration + +Abstracted through the Provider interface. SDK-specific details are encapsulated within each provider. + +``` +Provider.setup(AgentSetup) → ProviderAgent +ProviderAgent.call(prompt, options) → AgentResponse +``` + +| Criteria | Judgment | +|----------|----------| +| SDK-specific error handling leaking outside Provider | REJECT | +| Errors not propagated to AgentResponse.error | REJECT | +| Session key collision between providers | REJECT | +| Session key format `{persona}:{provider}` | OK | + +### Model Resolution + +Models resolve through 5-level priority. Higher takes precedence. + +1. persona_providers model specification +2. Movement model field +3. CLI `--model` override +4. config.yaml (when resolved provider matches) +5. Provider default + +## Facet Assembly + +The faceted-prompting module is independent from TAKT core. + +``` +compose(facets, options) → ComposedPrompt { systemPrompt, userMessage } +``` + +| Criteria | Judgment | +|----------|----------| +| Import from faceted-prompting to TAKT core | REJECT | +| TAKT core depending on faceted-prompting | OK | +| Facet path resolution logic outside faceted-prompting | Warning | + +### 3-Layer Facet Resolution Priority + +Project `.takt/` → User `~/.takt/` → Builtin `builtins/{lang}/` + +Same-named facets are overridden by higher-priority layers. Customize builtins by overriding in upper layers. + +## Testing Patterns + +Uses vitest. Test file naming conventions distinguish test types. + +| Prefix | Type | Content | +|--------|------|---------| +| None | Unit test | Individual function/class verification | +| `it-` | Integration test | Piece execution simulation | +| `engine-` | Engine test | PieceEngine scenario verification | + +### Mock Provider + +`--provider mock` returns deterministic responses. Scenario queues compose multi-turn tests. + +```typescript +// NG - Calling real API in tests +const response = await callClaude(prompt) + +// OK - Set up scenario with mock provider +setMockScenario([ + { persona: 'coder', status: 'done', content: '[STEP:1]\nDone.' }, + { persona: 'reviewer', status: 'done', content: '[STEP:1]\napproved' }, +]) +``` + +### Test Isolation + +| Criteria | Judgment | +|----------|----------| +| Tests sharing global state | REJECT | +| Environment variables not cleared in test setup | Warning | +| E2E tests assuming real API | Isolate via `provider` config | + +## Error Propagation + +Provider errors propagate through: `AgentResponse.error` → session log → console output. + +| Criteria | Judgment | +|----------|----------| +| SDK error results in empty `blocked` status | REJECT | +| Error details not recorded in session log | REJECT | +| No ABORT transition defined for error cases | Warning | + +## Session Management + +Agent sessions are stored per-cwd. Session resume is skipped during worktree/clone execution. + +| Criteria | Judgment | +|----------|----------| +| Session resuming when `cwd !== projectCwd` | REJECT (cross-project contamination) | +| Session key missing provider identifier | REJECT (cross-provider contamination) | +| Session broken between phases | REJECT (context loss) | diff --git a/builtins/en/piece-categories.yaml b/builtins/en/piece-categories.yaml index d2fb133..7f72c39 100644 --- a/builtins/en/piece-categories.yaml +++ b/builtins/en/piece-categories.yaml @@ -47,6 +47,10 @@ piece_categories: ✅ Test First: pieces: - default-test-first-mini + 🎵 TAKT Development: + pieces: + - takt-default + - takt-default-team-leader Others: pieces: - research diff --git a/builtins/en/pieces/takt-default-team-leader.yaml b/builtins/en/pieces/takt-default-team-leader.yaml new file mode 100644 index 0000000..e549e4f --- /dev/null +++ b/builtins/en/pieces/takt-default-team-leader.yaml @@ -0,0 +1,378 @@ +name: takt-default-team-leader +description: TAKT development piece with team leader (plan → write tests → team-leader implement → AI review → 5-parallel review → fix → supervise → complete) +piece_config: + provider_options: + codex: + network_access: true + opencode: + network_access: true +max_movements: 30 +initial_movement: plan +loop_monitors: + - cycle: + - ai_review + - ai_fix + threshold: 3 + judge: + persona: supervisor + instruction_template: | + The ai_review ↔ ai_fix loop has repeated {cycle_count} times. + + Review the reports from each cycle and determine whether this loop + is healthy (making progress) or unproductive (repeating the same issues). + + **Reports to reference:** + - AI Review results: {report:ai-review.md} + + **Judgment criteria:** + - Are new issues being found/fixed in each cycle? + - Are the same findings being repeated? + - Are fixes actually being applied? + rules: + - condition: Healthy (making progress) + next: ai_review + - condition: Unproductive (no improvement) + next: reviewers +movements: + - name: plan + edit: false + persona: planner + knowledge: architecture + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: Requirements are clear and implementable + next: write_tests + - condition: User is asking a question (not an implementation task) + next: COMPLETE + - condition: Requirements unclear, insufficient info + next: ABORT + appendix: | + Clarifications needed: + - {Question 1} + - {Question 2} + instruction: plan + output_contracts: + report: + - name: plan.md + format: plan + - name: write_tests + edit: true + persona: coder + policy: + - coding + - testing + knowledge: + - takt + - architecture + allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + required_permission_mode: edit + instruction: write-tests-first + rules: + - condition: Tests written successfully + next: implement + - condition: Cannot proceed because the test target is not implemented yet, so skip test writing + next: implement + - condition: Cannot proceed with test writing + next: ABORT + - condition: User input needed for clarification + next: write_tests + requires_user_input: true + interactive_only: true + output_contracts: + report: + - name: test-scope.md + format: coder-scope + - name: test-decisions.md + format: coder-decisions + - name: implement + edit: true + persona: coder + policy: + - coding + - testing + session: refresh + knowledge: + - takt + - architecture + allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + required_permission_mode: edit + team_leader: + max_parts: 2 + part_persona: coder + part_edit: true + part_permission_mode: edit + part_allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + instruction: team-leader-implement + rules: + - condition: Implementation complete + next: ai_review + - condition: No implementation (report only) + next: ai_review + - condition: Cannot proceed, insufficient info + next: ai_review + - condition: User input required + next: implement + requires_user_input: true + interactive_only: true + output_contracts: + report: + - name: coder-scope.md + format: coder-scope + - name: coder-decisions.md + format: coder-decisions + - name: ai_review + edit: false + persona: ai-antipattern-reviewer + policy: + - review + - ai-antipattern + allowed_tools: + - Read + - Glob + - Grep + - WebSearch + - WebFetch + rules: + - condition: No AI-specific issues + next: reviewers + - condition: AI-specific issues found + next: ai_fix + instruction: ai-review + output_contracts: + report: + - name: ai-review.md + format: ai-review + - name: ai_fix + edit: true + persona: coder + policy: + - coding + - testing + session: refresh + knowledge: + - takt + - architecture + allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + required_permission_mode: edit + pass_previous_response: false + rules: + - condition: AI issues fixed + next: ai_review + - condition: No fix needed (verified target files/spec) + next: ai_no_fix + - condition: Cannot proceed, insufficient info + next: ai_no_fix + instruction: ai-fix + - name: ai_no_fix + edit: false + persona: architecture-reviewer + policy: review + allowed_tools: + - Read + - Glob + - Grep + rules: + - condition: ai_review's findings are valid (fix required) + next: ai_fix + - condition: ai_fix's judgment is valid (no fix needed) + next: reviewers + instruction: arbitrate + - name: reviewers + parallel: + - name: arch-review + edit: false + persona: architecture-reviewer + policy: review + knowledge: + - architecture + - takt + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-arch + output_contracts: + report: + - name: architect-review.md + format: architecture-review + - name: security-review + edit: false + persona: security-reviewer + policy: review + knowledge: security + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-security + output_contracts: + report: + - name: security-review.md + format: security-review + - name: qa-review + edit: false + persona: qa-reviewer + policy: + - review + - qa + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-qa + output_contracts: + report: + - name: qa-review.md + format: qa-review + - name: testing-review + edit: false + persona: testing-reviewer + policy: + - review + - testing + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-test + output_contracts: + report: + - name: testing-review.md + format: testing-review + - name: requirements-review + edit: false + persona: requirements-reviewer + policy: review + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-requirements + output_contracts: + report: + - name: requirements-review.md + format: requirements-review + rules: + - condition: all("approved") + next: supervise + - condition: any("needs_fix") + next: fix + - name: fix + edit: true + persona: coder + policy: + - coding + - testing + knowledge: + - takt + - architecture + allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + required_permission_mode: edit + pass_previous_response: false + rules: + - condition: Fix complete + next: reviewers + - condition: Cannot proceed, insufficient info + next: plan + instruction: fix + - name: supervise + edit: false + persona: supervisor + policy: review + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + pass_previous_response: false + rules: + - condition: All checks passed + next: COMPLETE + - condition: Requirements unmet, tests failing, build errors + next: plan + instruction: supervise + output_contracts: + report: + - name: supervisor-validation.md + format: supervisor-validation + - name: summary.md + format: summary + use_judge: false diff --git a/builtins/en/pieces/takt-default.yaml b/builtins/en/pieces/takt-default.yaml new file mode 100644 index 0000000..65d8ac8 --- /dev/null +++ b/builtins/en/pieces/takt-default.yaml @@ -0,0 +1,364 @@ +name: takt-default +description: TAKT development piece (plan → write tests → implement → AI review → 5-parallel review → fix → supervise → complete) +piece_config: + provider_options: + codex: + network_access: true + opencode: + network_access: true +max_movements: 30 +initial_movement: plan +loop_monitors: + - cycle: + - ai_review + - ai_fix + threshold: 3 + judge: + persona: supervisor + instruction_template: | + The ai_review ↔ ai_fix loop has repeated {cycle_count} times. + + Review the reports from each cycle and determine whether this loop + is healthy (making progress) or unproductive (repeating the same issues). + + **Reports to reference:** + - AI Review results: {report:ai-review.md} + + **Judgment criteria:** + - Are new issues being found/fixed in each cycle? + - Are the same findings being repeated? + - Are fixes actually being applied? + rules: + - condition: Healthy (making progress) + next: ai_review + - condition: Unproductive (no improvement) + next: reviewers +movements: + - name: plan + edit: false + persona: planner + knowledge: architecture + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: Requirements are clear and implementable + next: write_tests + - condition: User is asking a question (not an implementation task) + next: COMPLETE + - condition: Requirements unclear, insufficient info + next: ABORT + appendix: | + Clarifications needed: + - {Question 1} + - {Question 2} + instruction: plan + output_contracts: + report: + - name: plan.md + format: plan + - name: write_tests + edit: true + persona: coder + policy: + - coding + - testing + knowledge: + - takt + - architecture + allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + required_permission_mode: edit + instruction: write-tests-first + rules: + - condition: Tests written successfully + next: implement + - condition: Cannot proceed because the test target is not implemented yet, so skip test writing + next: implement + - condition: Cannot proceed with test writing + next: ABORT + - condition: User input needed for clarification + next: write_tests + requires_user_input: true + interactive_only: true + output_contracts: + report: + - name: test-scope.md + format: coder-scope + - name: test-decisions.md + format: coder-decisions + - name: implement + edit: true + persona: coder + policy: + - coding + - testing + session: refresh + knowledge: + - takt + - architecture + allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + required_permission_mode: edit + rules: + - condition: Implementation complete + next: ai_review + - condition: No implementation (report only) + next: ai_review + - condition: Cannot proceed, insufficient info + next: ai_review + - condition: User input required + next: implement + requires_user_input: true + interactive_only: true + instruction: implement-after-tests + output_contracts: + report: + - name: coder-scope.md + format: coder-scope + - name: coder-decisions.md + format: coder-decisions + - name: ai_review + edit: false + persona: ai-antipattern-reviewer + policy: + - review + - ai-antipattern + allowed_tools: + - Read + - Glob + - Grep + - WebSearch + - WebFetch + rules: + - condition: No AI-specific issues + next: reviewers + - condition: AI-specific issues found + next: ai_fix + instruction: ai-review + output_contracts: + report: + - name: ai-review.md + format: ai-review + - name: ai_fix + edit: true + persona: coder + policy: + - coding + - testing + session: refresh + knowledge: + - takt + - architecture + allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + required_permission_mode: edit + pass_previous_response: false + rules: + - condition: AI issues fixed + next: ai_review + - condition: No fix needed (verified target files/spec) + next: ai_no_fix + - condition: Cannot proceed, insufficient info + next: ai_no_fix + instruction: ai-fix + - name: ai_no_fix + edit: false + persona: architecture-reviewer + policy: review + allowed_tools: + - Read + - Glob + - Grep + rules: + - condition: ai_review's findings are valid (fix required) + next: ai_fix + - condition: ai_fix's judgment is valid (no fix needed) + next: reviewers + instruction: arbitrate + - name: reviewers + parallel: + - name: arch-review + edit: false + persona: architecture-reviewer + policy: review + knowledge: + - architecture + - takt + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-arch + output_contracts: + report: + - name: architect-review.md + format: architecture-review + - name: security-review + edit: false + persona: security-reviewer + policy: review + knowledge: security + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-security + output_contracts: + report: + - name: security-review.md + format: security-review + - name: qa-review + edit: false + persona: qa-reviewer + policy: + - review + - qa + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-qa + output_contracts: + report: + - name: qa-review.md + format: qa-review + - name: testing-review + edit: false + persona: testing-reviewer + policy: + - review + - testing + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-test + output_contracts: + report: + - name: testing-review.md + format: testing-review + - name: requirements-review + edit: false + persona: requirements-reviewer + policy: review + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-requirements + output_contracts: + report: + - name: requirements-review.md + format: requirements-review + rules: + - condition: all("approved") + next: supervise + - condition: any("needs_fix") + next: fix + - name: fix + edit: true + persona: coder + policy: + - coding + - testing + knowledge: + - takt + - architecture + allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + required_permission_mode: edit + pass_previous_response: false + rules: + - condition: Fix complete + next: reviewers + - condition: Cannot proceed, insufficient info + next: plan + instruction: fix + - name: supervise + edit: false + persona: supervisor + policy: review + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + pass_previous_response: false + rules: + - condition: All checks passed + next: COMPLETE + - condition: Requirements unmet, tests failing, build errors + next: plan + instruction: supervise + output_contracts: + report: + - name: supervisor-validation.md + format: supervisor-validation + - name: summary.md + format: summary + use_judge: false diff --git a/builtins/ja/facets/instructions/team-leader-implement.md b/builtins/ja/facets/instructions/team-leader-implement.md new file mode 100644 index 0000000..80351c0 --- /dev/null +++ b/builtins/ja/facets/instructions/team-leader-implement.md @@ -0,0 +1,27 @@ +実装タスクをファイル担当単位でサブタスクに分解し、並列実行してください。各パートが担当するファイルが重複しないよう排他的に割り当てます。 + +**重要:** 計画レポートを参照してください: {report:plan.md} + +**やること:** + +1. 変更対象ファイルを特定する + - 計画レポートとテストスコープを参照して変更・作成するファイルを洗い出す + - 実際のコードベースを確認して不明点を補完する + +2. ファイルをレイヤー/モジュール単位でグループ化する + - 凝集度の高い単位でグループを作る(例: ドメイン層 / インフラ層 / API層) + - 型・インターフェースの依存がある場合は、依存元と依存先を同じグループにまとめる + - 1つのファイルを複数のパートに割り当てない + +3. 各パートに排他的なファイル担当を割り当てる + - 各パートの instruction に以下を必ず明記する: + - **担当ファイル**(作成・変更する対象ファイルのパス一覧) + - **参照専用ファイル**(変更禁止、読み取りのみ可) + - **実装内容**(何をどのように実装するか) + - **完了基準**(担当ファイルの実装が完了したこと) + - テスト済みの場合は「既存テストがパスするよう実装する」と明記する + - ビルドチェックは指示しない(他パートのファイルが揃ってから全体でまとめて確認するため) + +**制約:** +- 各パートはテスト実行を行わない(後続ムーブメントで実施する) +- 担当外のファイルを変更しない(コンフリクトの原因になる) diff --git a/builtins/ja/facets/knowledge/takt.md b/builtins/ja/facets/knowledge/takt.md new file mode 100644 index 0000000..a84ce4a --- /dev/null +++ b/builtins/ja/facets/knowledge/takt.md @@ -0,0 +1,151 @@ +# TAKT アーキテクチャ知識 + +## コア構造 + +PieceEngine は状態機械。movement 間の遷移を EventEmitter ベースで管理する。 + +``` +CLI → PieceEngine → Runner(4種) → RuleEvaluator → 次の movement +``` + +| Runner | 用途 | 使い分け | +|--------|------|---------| +| MovementExecutor | 通常の3フェーズ実行 | デフォルト | +| ParallelRunner | 並列サブムーブメント | parallel ブロック | +| ArpeggioRunner | データ駆動バッチ処理 | arpeggio ブロック | +| TeamLeaderRunner | タスク分解 → サブエージェント並列 | team_leader ブロック | + +各 Runner は排他。1つの movement に複数の Runner タイプを指定しない。 + +### 3フェーズ実行モデル + +通常 movement は最大3フェーズで実行される。セッションはフェーズ間で維持される。 + +| フェーズ | 目的 | ツール | 条件 | +|---------|------|--------|------| +| Phase 1 | メイン作業 | movement の allowed_tools | 常に | +| Phase 2 | レポート出力 | Write のみ | output_contracts 定義時 | +| Phase 3 | ステータス判定 | なし(判定のみ) | タグベースルール時 | + +## ルール評価 + +RuleEvaluator は5段階フォールバックで遷移先を決定する。先にマッチした方法が優先される。 + +| 優先度 | 方法 | 対象 | +|--------|------|------| +| 1 | aggregate | parallel 親(all/any) | +| 2 | Phase 3 タグ | `[STEP:N]` 出力 | +| 3 | Phase 1 タグ | `[STEP:N]` 出力(フォールバック) | +| 4 | ai() judge | ai("条件") ルール | +| 5 | AI fallback | 全条件を AI が判定 | + +タグが複数出現した場合は**最後のマッチ**が採用される。 + +### Condition の記法 + +| 記法 | パース | 正規表現 | +|------|--------|---------| +| `ai("...")` | AI 条件評価 | `AI_CONDITION_REGEX` | +| `all("...")` / `any("...")` | 集約条件 | `AGGREGATE_CONDITION_REGEX` | +| 文字列 | タグまたは AI フォールバック | — | + +新しい特殊構文を追加する場合は pieceParser.ts の正規表現と RuleEvaluator の両方を更新する。 + +## プロバイダー統合 + +Provider インターフェースで抽象化。具体的な SDK の差異は各プロバイダー内に閉じ込める。 + +``` +Provider.setup(AgentSetup) → ProviderAgent +ProviderAgent.call(prompt, options) → AgentResponse +``` + +| 基準 | 判定 | +|------|------| +| SDK 固有のエラーハンドリングが Provider 外に漏れている | REJECT | +| AgentResponse.error にエラーを伝播していない | REJECT | +| プロバイダー間でセッションキーが衝突する | REJECT | +| セッションキー形式 `{persona}:{provider}` | OK | + +### モデル解決 + +5段階の優先順位でモデルを解決する。上位が優先。 + +1. persona_providers のモデル指定 +2. movement の model フィールド +3. CLI `--model` オーバーライド +4. config.yaml(プロバイダー一致時) +5. プロバイダーデフォルト + +## ファセット組み立て + +faceted-prompting モジュールは TAKT 本体に依存しない独立モジュール。 + +``` +compose(facets, options) → ComposedPrompt { systemPrompt, userMessage } +``` + +| 基準 | 判定 | +|------|------| +| faceted-prompting から TAKT コアへの import | REJECT | +| TAKT コアから faceted-prompting への依存 | OK | +| ファセットパス解決のロジックが faceted-prompting 外にある | 警告 | + +### ファセット解決の3層優先順位 + +プロジェクト `.takt/` → ユーザー `~/.takt/` → ビルトイン `builtins/{lang}/` + +同名ファセットは上位が優先。ビルトインのカスタマイズは上位層でオーバーライドする。 + +## テストパターン + +vitest を使用。テストファイルの命名規約で種別を区別する。 + +| プレフィックス | 種別 | 内容 | +|--------------|------|------| +| なし | ユニットテスト | 個別関数・クラスの検証 | +| `it-` | 統合テスト | ピース実行のシミュレーション | +| `engine-` | エンジンテスト | PieceEngine シナリオ検証 | + +### Mock プロバイダー + +`--provider mock` でテスト用の決定論的レスポンスを返す。シナリオキューで複数ターンのテストを構成する。 + +```typescript +// NG - テストでリアル API を呼ぶ +const response = await callClaude(prompt) + +// OK - Mock プロバイダーでシナリオを設定 +setMockScenario([ + { persona: 'coder', status: 'done', content: '[STEP:1]\nDone.' }, + { persona: 'reviewer', status: 'done', content: '[STEP:1]\napproved' }, +]) +``` + +### テストの分離 + +| 基準 | 判定 | +|------|------| +| テスト間でグローバル状態を共有 | REJECT | +| 環境変数をテストセットアップでクリアしていない | 警告 | +| E2E テストで実 API を前提としている | `provider` 指定の config で分離 | + +## エラー伝播 + +プロバイダーエラーは `AgentResponse.error` → セッションログ → コンソール出力の経路で伝播する。 + +| 基準 | 判定 | +|------|------| +| SDK エラーが空の `blocked` ステータスになる | REJECT | +| エラー詳細がセッションログに記録されない | REJECT | +| エラー時に ABORT 遷移が定義されていない | 警告 | + +## セッション管理 + +エージェントセッションは cwd ごとに保存される。worktree/clone 実行時はセッション再開をスキップする。 + +| 基準 | 判定 | +|------|------| +| `cwd !== projectCwd` でセッション再開している | REJECT | +| セッションキーにプロバイダーが含まれない | REJECT(クロスプロバイダー汚染) | +| Phase 間でセッションが切れている | REJECT(コンテキスト喪失) | diff --git a/builtins/ja/piece-categories.yaml b/builtins/ja/piece-categories.yaml index 94264f1..45cdd99 100644 --- a/builtins/ja/piece-categories.yaml +++ b/builtins/ja/piece-categories.yaml @@ -47,6 +47,10 @@ piece_categories: ✅ テストファースト: pieces: - default-test-first-mini + 🎵 TAKT開発: + pieces: + - takt-default + - takt-default-team-leader その他: pieces: - research diff --git a/builtins/ja/pieces/takt-default-team-leader.yaml b/builtins/ja/pieces/takt-default-team-leader.yaml new file mode 100644 index 0000000..a77d2bd --- /dev/null +++ b/builtins/ja/pieces/takt-default-team-leader.yaml @@ -0,0 +1,378 @@ +name: takt-default-team-leader +description: TAKT開発ピース(チームリーダー版)(計画 → テスト作成 → チームリーダー実装 → AIレビュー → 5並列レビュー → 修正 → 監督 → 完了) +piece_config: + provider_options: + codex: + network_access: true + opencode: + network_access: true +max_movements: 30 +initial_movement: plan +loop_monitors: + - cycle: + - ai_review + - ai_fix + threshold: 3 + judge: + persona: supervisor + instruction_template: | + ai_review と ai_fix のループが {cycle_count} 回繰り返されました。 + + 各サイクルのレポートを確認し、このループが健全(進捗がある)か、 + 非生産的(同じ問題を繰り返している)かを判断してください。 + + **参照するレポート:** + - AIレビュー結果: {report:ai-review.md} + + **判断基準:** + - 各サイクルで新しい問題が発見・修正されているか + - 同じ指摘が繰り返されていないか + - 修正が実際に反映されているか + rules: + - condition: 健全(進捗あり) + next: ai_review + - condition: 非生産的(改善なし) + next: reviewers +movements: + - name: plan + edit: false + persona: planner + knowledge: architecture + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: 要件が明確で実装可能 + next: write_tests + - condition: ユーザーが質問をしている(実装タスクではない) + next: COMPLETE + - condition: 要件が不明確、情報不足 + next: ABORT + appendix: | + 確認事項: + - {質問1} + - {質問2} + instruction: plan + output_contracts: + report: + - name: plan.md + format: plan + - name: write_tests + edit: true + persona: coder + policy: + - coding + - testing + knowledge: + - takt + - architecture + allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + required_permission_mode: edit + instruction: write-tests-first + rules: + - condition: テスト作成が完了した + next: implement + - condition: テスト対象が未実装のためテスト作成をスキップする + next: implement + - condition: テスト作成を進行できない + next: ABORT + - condition: ユーザーへの確認事項があるためユーザー入力が必要 + next: write_tests + requires_user_input: true + interactive_only: true + output_contracts: + report: + - name: test-scope.md + format: coder-scope + - name: test-decisions.md + format: coder-decisions + - name: implement + edit: true + persona: coder + policy: + - coding + - testing + session: refresh + knowledge: + - takt + - architecture + allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + required_permission_mode: edit + team_leader: + max_parts: 2 + part_persona: coder + part_edit: true + part_permission_mode: edit + part_allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + instruction: team-leader-implement + rules: + - condition: 実装完了 + next: ai_review + - condition: 実装未着手(レポートのみ) + next: ai_review + - condition: 判断できない、情報不足 + next: ai_review + - condition: ユーザー入力が必要 + next: implement + requires_user_input: true + interactive_only: true + output_contracts: + report: + - name: coder-scope.md + format: coder-scope + - name: coder-decisions.md + format: coder-decisions + - name: ai_review + edit: false + persona: ai-antipattern-reviewer + policy: + - review + - ai-antipattern + allowed_tools: + - Read + - Glob + - Grep + - WebSearch + - WebFetch + rules: + - condition: AI特有の問題なし + next: reviewers + - condition: AI特有の問題あり + next: ai_fix + instruction: ai-review + output_contracts: + report: + - name: ai-review.md + format: ai-review + - name: ai_fix + edit: true + persona: coder + policy: + - coding + - testing + session: refresh + knowledge: + - takt + - architecture + allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + required_permission_mode: edit + pass_previous_response: false + rules: + - condition: AI問題の修正完了 + next: ai_review + - condition: 修正不要(指摘対象ファイル/仕様の確認済み) + next: ai_no_fix + - condition: 判断できない、情報不足 + next: ai_no_fix + instruction: ai-fix + - name: ai_no_fix + edit: false + persona: architecture-reviewer + policy: review + allowed_tools: + - Read + - Glob + - Grep + rules: + - condition: ai_reviewの指摘が妥当(修正すべき) + next: ai_fix + - condition: ai_fixの判断が妥当(修正不要) + next: reviewers + instruction: arbitrate + - name: reviewers + parallel: + - name: arch-review + edit: false + persona: architecture-reviewer + policy: review + knowledge: + - architecture + - takt + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-arch + output_contracts: + report: + - name: architect-review.md + format: architecture-review + - name: security-review + edit: false + persona: security-reviewer + policy: review + knowledge: security + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-security + output_contracts: + report: + - name: security-review.md + format: security-review + - name: qa-review + edit: false + persona: qa-reviewer + policy: + - review + - qa + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-qa + output_contracts: + report: + - name: qa-review.md + format: qa-review + - name: testing-review + edit: false + persona: testing-reviewer + policy: + - review + - testing + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-test + output_contracts: + report: + - name: testing-review.md + format: testing-review + - name: requirements-review + edit: false + persona: requirements-reviewer + policy: review + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-requirements + output_contracts: + report: + - name: requirements-review.md + format: requirements-review + rules: + - condition: all("approved") + next: supervise + - condition: any("needs_fix") + next: fix + - name: fix + edit: true + persona: coder + policy: + - coding + - testing + knowledge: + - takt + - architecture + allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + required_permission_mode: edit + pass_previous_response: false + rules: + - condition: 修正完了 + next: reviewers + - condition: 判断できない、情報不足 + next: plan + instruction: fix + - name: supervise + edit: false + persona: supervisor + policy: review + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + pass_previous_response: false + rules: + - condition: すべて問題なし + next: COMPLETE + - condition: 要求未達成、テスト失敗、ビルドエラー + next: plan + instruction: supervise + output_contracts: + report: + - name: supervisor-validation.md + format: supervisor-validation + - name: summary.md + format: summary + use_judge: false diff --git a/builtins/ja/pieces/takt-default.yaml b/builtins/ja/pieces/takt-default.yaml new file mode 100644 index 0000000..0e7efe8 --- /dev/null +++ b/builtins/ja/pieces/takt-default.yaml @@ -0,0 +1,364 @@ +name: takt-default +description: TAKT開発ピース(計画 → テスト作成 → 実装 → AIレビュー → 5並列レビュー → 修正 → 監督 → 完了) +piece_config: + provider_options: + codex: + network_access: true + opencode: + network_access: true +max_movements: 30 +initial_movement: plan +loop_monitors: + - cycle: + - ai_review + - ai_fix + threshold: 3 + judge: + persona: supervisor + instruction_template: | + ai_review と ai_fix のループが {cycle_count} 回繰り返されました。 + + 各サイクルのレポートを確認し、このループが健全(進捗がある)か、 + 非生産的(同じ問題を繰り返している)かを判断してください。 + + **参照するレポート:** + - AIレビュー結果: {report:ai-review.md} + + **判断基準:** + - 各サイクルで新しい問題が発見・修正されているか + - 同じ指摘が繰り返されていないか + - 修正が実際に反映されているか + rules: + - condition: 健全(進捗あり) + next: ai_review + - condition: 非生産的(改善なし) + next: reviewers +movements: + - name: plan + edit: false + persona: planner + knowledge: architecture + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: 要件が明確で実装可能 + next: write_tests + - condition: ユーザーが質問をしている(実装タスクではない) + next: COMPLETE + - condition: 要件が不明確、情報不足 + next: ABORT + appendix: | + 確認事項: + - {質問1} + - {質問2} + instruction: plan + output_contracts: + report: + - name: plan.md + format: plan + - name: write_tests + edit: true + persona: coder + policy: + - coding + - testing + knowledge: + - takt + - architecture + allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + required_permission_mode: edit + instruction: write-tests-first + rules: + - condition: テスト作成が完了した + next: implement + - condition: テスト対象が未実装のためテスト作成をスキップする + next: implement + - condition: テスト作成を進行できない + next: ABORT + - condition: ユーザーへの確認事項があるためユーザー入力が必要 + next: write_tests + requires_user_input: true + interactive_only: true + output_contracts: + report: + - name: test-scope.md + format: coder-scope + - name: test-decisions.md + format: coder-decisions + - name: implement + edit: true + persona: coder + policy: + - coding + - testing + session: refresh + knowledge: + - takt + - architecture + allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + required_permission_mode: edit + rules: + - condition: 実装完了 + next: ai_review + - condition: 実装未着手(レポートのみ) + next: ai_review + - condition: 判断できない、情報不足 + next: ai_review + - condition: ユーザー入力が必要 + next: implement + requires_user_input: true + interactive_only: true + instruction: implement-after-tests + output_contracts: + report: + - name: coder-scope.md + format: coder-scope + - name: coder-decisions.md + format: coder-decisions + - name: ai_review + edit: false + persona: ai-antipattern-reviewer + policy: + - review + - ai-antipattern + allowed_tools: + - Read + - Glob + - Grep + - WebSearch + - WebFetch + rules: + - condition: AI特有の問題なし + next: reviewers + - condition: AI特有の問題あり + next: ai_fix + instruction: ai-review + output_contracts: + report: + - name: ai-review.md + format: ai-review + - name: ai_fix + edit: true + persona: coder + policy: + - coding + - testing + session: refresh + knowledge: + - takt + - architecture + allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + required_permission_mode: edit + pass_previous_response: false + rules: + - condition: AI問題の修正完了 + next: ai_review + - condition: 修正不要(指摘対象ファイル/仕様の確認済み) + next: ai_no_fix + - condition: 判断できない、情報不足 + next: ai_no_fix + instruction: ai-fix + - name: ai_no_fix + edit: false + persona: architecture-reviewer + policy: review + allowed_tools: + - Read + - Glob + - Grep + rules: + - condition: ai_reviewの指摘が妥当(修正すべき) + next: ai_fix + - condition: ai_fixの判断が妥当(修正不要) + next: reviewers + instruction: arbitrate + - name: reviewers + parallel: + - name: arch-review + edit: false + persona: architecture-reviewer + policy: review + knowledge: + - architecture + - takt + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-arch + output_contracts: + report: + - name: architect-review.md + format: architecture-review + - name: security-review + edit: false + persona: security-reviewer + policy: review + knowledge: security + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-security + output_contracts: + report: + - name: security-review.md + format: security-review + - name: qa-review + edit: false + persona: qa-reviewer + policy: + - review + - qa + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-qa + output_contracts: + report: + - name: qa-review.md + format: qa-review + - name: testing-review + edit: false + persona: testing-reviewer + policy: + - review + - testing + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-test + output_contracts: + report: + - name: testing-review.md + format: testing-review + - name: requirements-review + edit: false + persona: requirements-reviewer + policy: review + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + rules: + - condition: approved + - condition: needs_fix + instruction: review-requirements + output_contracts: + report: + - name: requirements-review.md + format: requirements-review + rules: + - condition: all("approved") + next: supervise + - condition: any("needs_fix") + next: fix + - name: fix + edit: true + persona: coder + policy: + - coding + - testing + knowledge: + - takt + - architecture + allowed_tools: + - Read + - Glob + - Grep + - Edit + - Write + - Bash + - WebSearch + - WebFetch + required_permission_mode: edit + pass_previous_response: false + rules: + - condition: 修正完了 + next: reviewers + - condition: 判断できない、情報不足 + next: plan + instruction: fix + - name: supervise + edit: false + persona: supervisor + policy: review + allowed_tools: + - Read + - Glob + - Grep + - Bash + - WebSearch + - WebFetch + pass_previous_response: false + rules: + - condition: すべて問題なし + next: COMPLETE + - condition: 要求未達成、テスト失敗、ビルドエラー + next: plan + instruction: supervise + output_contracts: + report: + - name: supervisor-validation.md + format: supervisor-validation + - name: summary.md + format: summary + use_judge: false