From 40b3bb218583d266df6e67358a7e996b243dc482 Mon Sep 17 00:00:00 2001 From: nrslib <38722970+nrslib@users.noreply.github.com> Date: Mon, 9 Feb 2026 10:43:08 +0900 Subject: [PATCH] takt: refactor-builtin-pieces --- builtins/en/pieces/coding.yaml | 22 ---- builtins/en/pieces/compound-eye.yaml | 5 - builtins/en/pieces/default.yaml | 33 ------ builtins/en/pieces/expert-cqrs.yaml | 44 -------- builtins/en/pieces/expert.yaml | 42 ------- builtins/en/pieces/magi.yaml | 4 - builtins/en/pieces/minimal.yaml | 17 --- builtins/en/pieces/passthrough.yaml | 5 - builtins/en/pieces/research.yaml | 4 - builtins/en/pieces/review-fix-minimal.yaml | 17 --- builtins/en/pieces/review-only.yaml | 22 ---- builtins/en/pieces/structural-reform.yaml | 25 ----- builtins/en/pieces/unit-test.yaml | 31 ----- builtins/ja/pieces/coding.yaml | 22 ---- builtins/ja/pieces/compound-eye.yaml | 5 - builtins/ja/pieces/default.yaml | 33 ------ builtins/ja/pieces/expert-cqrs.yaml | 44 -------- builtins/ja/pieces/expert.yaml | 42 ------- builtins/ja/pieces/magi.yaml | 4 - builtins/ja/pieces/minimal.yaml | 17 --- builtins/ja/pieces/passthrough.yaml | 5 - builtins/ja/pieces/research.yaml | 4 - builtins/ja/pieces/review-fix-minimal.yaml | 17 --- builtins/ja/pieces/review-only.yaml | 22 ---- builtins/ja/pieces/structural-reform.yaml | 25 ----- builtins/ja/pieces/unit-test.yaml | 31 ----- docs/faceted-prompting.ja.md | 33 ++---- docs/faceted-prompting.md | 33 ++---- src/__tests__/config.test.ts | 9 ++ src/__tests__/facet-resolution.test.ts | 106 ++++++++++++++++++ src/infra/config/loaders/pieceParser.ts | 17 +-- src/infra/config/loaders/resource-resolver.ts | 4 +- 32 files changed, 141 insertions(+), 603 deletions(-) diff --git a/builtins/en/pieces/coding.yaml b/builtins/en/pieces/coding.yaml index 2cc3841..eea3462 100644 --- a/builtins/en/pieces/coding.yaml +++ b/builtins/en/pieces/coding.yaml @@ -1,24 +1,6 @@ name: coding description: Lightweight development piece with planning and parallel reviews (plan -> implement -> parallel review -> complete) max_iterations: 20 -policies: - coding: ../policies/coding.md - review: ../policies/review.md - testing: ../policies/testing.md - ai-antipattern: ../policies/ai-antipattern.md -knowledge: - architecture: ../knowledge/architecture.md -personas: - planner: ../personas/planner.md - coder: ../personas/coder.md - ai-antipattern-reviewer: ../personas/ai-antipattern-reviewer.md - architecture-reviewer: ../personas/architecture-reviewer.md -instructions: - plan: ../instructions/plan.md - implement: ../instructions/implement.md - ai-review: ../instructions/ai-review.md - review-arch: ../instructions/review-arch.md - fix: ../instructions/fix.md initial_movement: plan movements: - name: plan @@ -150,7 +132,3 @@ movements: - condition: Cannot determine, insufficient information next: ABORT instruction: fix -report_formats: - plan: ../output-contracts/plan.md - ai-review: ../output-contracts/ai-review.md - architecture-review: ../output-contracts/architecture-review.md diff --git a/builtins/en/pieces/compound-eye.yaml b/builtins/en/pieces/compound-eye.yaml index f0c5e69..9be6d4e 100644 --- a/builtins/en/pieces/compound-eye.yaml +++ b/builtins/en/pieces/compound-eye.yaml @@ -1,11 +1,6 @@ name: compound-eye description: Multi-model review - send the same instruction to Claude and Codex simultaneously, synthesize both responses max_iterations: 10 -knowledge: - architecture: ../knowledge/architecture.md -personas: - coder: ../personas/coder.md - supervisor: ../personas/supervisor.md initial_movement: evaluate movements: - name: evaluate diff --git a/builtins/en/pieces/default.yaml b/builtins/en/pieces/default.yaml index c52266d..bd7626e 100644 --- a/builtins/en/pieces/default.yaml +++ b/builtins/en/pieces/default.yaml @@ -1,32 +1,6 @@ name: default description: Standard development piece with planning and specialized reviews max_iterations: 30 -policies: - coding: ../policies/coding.md - review: ../policies/review.md - testing: ../policies/testing.md - ai-antipattern: ../policies/ai-antipattern.md - qa: ../policies/qa.md -knowledge: - backend: ../knowledge/backend.md - architecture: ../knowledge/architecture.md -personas: - planner: ../personas/planner.md - coder: ../personas/coder.md - ai-antipattern-reviewer: ../personas/ai-antipattern-reviewer.md - architecture-reviewer: ../personas/architecture-reviewer.md - qa-reviewer: ../personas/qa-reviewer.md - supervisor: ../personas/supervisor.md -instructions: - plan: ../instructions/plan.md - implement: ../instructions/implement.md - ai-review: ../instructions/ai-review.md - ai-fix: ../instructions/ai-fix.md - arbitrate: ../instructions/arbitrate.md - review-arch: ../instructions/review-arch.md - review-qa: ../instructions/review-qa.md - fix: ../instructions/fix.md - supervise: ../instructions/supervise.md initial_movement: plan loop_monitors: - cycle: @@ -282,10 +256,3 @@ movements: report: - Validation: 07-supervisor-validation.md - Summary: summary.md -report_formats: - plan: ../output-contracts/plan.md - ai-review: ../output-contracts/ai-review.md - architecture-review: ../output-contracts/architecture-review.md - qa-review: ../output-contracts/qa-review.md - validation: ../output-contracts/validation.md - summary: ../output-contracts/summary.md diff --git a/builtins/en/pieces/expert-cqrs.yaml b/builtins/en/pieces/expert-cqrs.yaml index 1bacccb..b668953 100644 --- a/builtins/en/pieces/expert-cqrs.yaml +++ b/builtins/en/pieces/expert-cqrs.yaml @@ -1,41 +1,6 @@ name: expert-cqrs description: CQRS+ES, Frontend, Security, QA Expert Review max_iterations: 30 -policies: - coding: ../policies/coding.md - review: ../policies/review.md - testing: ../policies/testing.md - ai-antipattern: ../policies/ai-antipattern.md - qa: ../policies/qa.md -knowledge: - frontend: ../knowledge/frontend.md - backend: ../knowledge/backend.md - cqrs-es: ../knowledge/cqrs-es.md - security: ../knowledge/security.md - architecture: ../knowledge/architecture.md -personas: - planner: ../personas/planner.md - coder: ../personas/coder.md - ai-antipattern-reviewer: ../personas/ai-antipattern-reviewer.md - architecture-reviewer: ../personas/architecture-reviewer.md - cqrs-es-reviewer: ../personas/cqrs-es-reviewer.md - frontend-reviewer: ../personas/frontend-reviewer.md - security-reviewer: ../personas/security-reviewer.md - qa-reviewer: ../personas/qa-reviewer.md - expert-supervisor: ../personas/expert-supervisor.md -instructions: - plan: ../instructions/plan.md - implement: ../instructions/implement.md - ai-review: ../instructions/ai-review.md - ai-fix: ../instructions/ai-fix.md - arbitrate: ../instructions/arbitrate.md - review-cqrs-es: ../instructions/review-cqrs-es.md - review-frontend: ../instructions/review-frontend.md - review-security: ../instructions/review-security.md - review-qa: ../instructions/review-qa.md - fix: ../instructions/fix.md - supervise: ../instructions/supervise.md - fix-supervisor: ../instructions/fix-supervisor.md initial_movement: plan movements: - name: plan @@ -323,12 +288,3 @@ movements: next: supervise - condition: Unable to proceed with fixes next: plan -report_formats: - plan: ../output-contracts/plan.md - ai-review: ../output-contracts/ai-review.md - cqrs-es-review: ../output-contracts/cqrs-es-review.md - frontend-review: ../output-contracts/frontend-review.md - security-review: ../output-contracts/security-review.md - qa-review: ../output-contracts/qa-review.md - validation: ../output-contracts/validation.md - summary: ../output-contracts/summary.md diff --git a/builtins/en/pieces/expert.yaml b/builtins/en/pieces/expert.yaml index f99e71f..6416ccb 100644 --- a/builtins/en/pieces/expert.yaml +++ b/builtins/en/pieces/expert.yaml @@ -1,39 +1,6 @@ name: expert description: Architecture, Frontend, Security, QA Expert Review max_iterations: 30 -policies: - coding: ../policies/coding.md - review: ../policies/review.md - testing: ../policies/testing.md - ai-antipattern: ../policies/ai-antipattern.md - qa: ../policies/qa.md -knowledge: - frontend: ../knowledge/frontend.md - backend: ../knowledge/backend.md - security: ../knowledge/security.md - architecture: ../knowledge/architecture.md -personas: - planner: ../personas/planner.md - coder: ../personas/coder.md - ai-antipattern-reviewer: ../personas/ai-antipattern-reviewer.md - architecture-reviewer: ../personas/architecture-reviewer.md - frontend-reviewer: ../personas/frontend-reviewer.md - security-reviewer: ../personas/security-reviewer.md - qa-reviewer: ../personas/qa-reviewer.md - expert-supervisor: ../personas/expert-supervisor.md -instructions: - plan: ../instructions/plan.md - implement: ../instructions/implement.md - ai-review: ../instructions/ai-review.md - ai-fix: ../instructions/ai-fix.md - arbitrate: ../instructions/arbitrate.md - review-arch: ../instructions/review-arch.md - review-frontend: ../instructions/review-frontend.md - review-security: ../instructions/review-security.md - review-qa: ../instructions/review-qa.md - fix: ../instructions/fix.md - supervise: ../instructions/supervise.md - fix-supervisor: ../instructions/fix-supervisor.md initial_movement: plan movements: - name: plan @@ -317,12 +284,3 @@ movements: next: supervise - condition: Unable to proceed with fixes next: plan -report_formats: - plan: ../output-contracts/plan.md - ai-review: ../output-contracts/ai-review.md - architecture-review: ../output-contracts/architecture-review.md - frontend-review: ../output-contracts/frontend-review.md - security-review: ../output-contracts/security-review.md - qa-review: ../output-contracts/qa-review.md - validation: ../output-contracts/validation.md - summary: ../output-contracts/summary.md diff --git a/builtins/en/pieces/magi.yaml b/builtins/en/pieces/magi.yaml index 2accc85..f6ee7a6 100644 --- a/builtins/en/pieces/magi.yaml +++ b/builtins/en/pieces/magi.yaml @@ -1,10 +1,6 @@ name: magi description: MAGI Deliberation System - Analyze from 3 perspectives and decide by majority max_iterations: 5 -personas: - melchior: ../personas/melchior.md - balthasar: ../personas/balthasar.md - casper: ../personas/casper.md initial_movement: melchior movements: - name: melchior diff --git a/builtins/en/pieces/minimal.yaml b/builtins/en/pieces/minimal.yaml index 56c9f5b..89017c3 100644 --- a/builtins/en/pieces/minimal.yaml +++ b/builtins/en/pieces/minimal.yaml @@ -1,21 +1,6 @@ name: minimal description: Minimal development piece (implement -> parallel review -> fix if needed -> complete) max_iterations: 20 -policies: - coding: ../policies/coding.md - review: ../policies/review.md - testing: ../policies/testing.md - ai-antipattern: ../policies/ai-antipattern.md -personas: - coder: ../personas/coder.md - ai-antipattern-reviewer: ../personas/ai-antipattern-reviewer.md - supervisor: ../personas/supervisor.md -instructions: - implement: ../instructions/implement.md - review-ai: ../instructions/review-ai.md - ai-fix: ../instructions/ai-fix.md - supervise: ../instructions/supervise.md - fix-supervisor: ../instructions/fix-supervisor.md initial_movement: implement movements: - name: implement @@ -190,5 +175,3 @@ movements: - condition: Cannot proceed, insufficient info next: implement instruction: fix-supervisor -report_formats: - ai-review: ../output-contracts/ai-review.md diff --git a/builtins/en/pieces/passthrough.yaml b/builtins/en/pieces/passthrough.yaml index fba61cd..e9ae5e1 100644 --- a/builtins/en/pieces/passthrough.yaml +++ b/builtins/en/pieces/passthrough.yaml @@ -1,11 +1,6 @@ name: passthrough description: Single-agent thin wrapper. Pass task directly to coder as-is. max_iterations: 10 -policies: - coding: ../policies/coding.md - testing: ../policies/testing.md -personas: - coder: ../personas/coder.md initial_movement: execute movements: - name: execute diff --git a/builtins/en/pieces/research.yaml b/builtins/en/pieces/research.yaml index b302272..f88ac39 100644 --- a/builtins/en/pieces/research.yaml +++ b/builtins/en/pieces/research.yaml @@ -1,10 +1,6 @@ name: research description: Research piece - autonomously executes research without asking questions max_iterations: 10 -personas: - research-planner: ../personas/research-planner.md - research-digger: ../personas/research-digger.md - research-supervisor: ../personas/research-supervisor.md initial_movement: plan movements: - name: plan diff --git a/builtins/en/pieces/review-fix-minimal.yaml b/builtins/en/pieces/review-fix-minimal.yaml index d942be9..79dbeab 100644 --- a/builtins/en/pieces/review-fix-minimal.yaml +++ b/builtins/en/pieces/review-fix-minimal.yaml @@ -1,21 +1,6 @@ name: review-fix-minimal description: Review and fix piece for existing code (starts with review, no implementation) max_iterations: 20 -policies: - coding: ../policies/coding.md - review: ../policies/review.md - testing: ../policies/testing.md - ai-antipattern: ../policies/ai-antipattern.md -personas: - coder: ../personas/coder.md - ai-antipattern-reviewer: ../personas/ai-antipattern-reviewer.md - supervisor: ../personas/supervisor.md -instructions: - implement: ../instructions/implement.md - review-ai: ../instructions/review-ai.md - ai-fix: ../instructions/ai-fix.md - supervise: ../instructions/supervise.md - fix-supervisor: ../instructions/fix-supervisor.md initial_movement: reviewers movements: - name: implement @@ -190,5 +175,3 @@ movements: - condition: Cannot proceed, insufficient info next: implement instruction: fix-supervisor -report_formats: - ai-review: ../output-contracts/ai-review.md diff --git a/builtins/en/pieces/review-only.yaml b/builtins/en/pieces/review-only.yaml index f547f95..eabf031 100644 --- a/builtins/en/pieces/review-only.yaml +++ b/builtins/en/pieces/review-only.yaml @@ -1,23 +1,6 @@ name: review-only description: Review-only piece - reviews code without making edits max_iterations: 10 -policies: - review: ../policies/review.md - ai-antipattern: ../policies/ai-antipattern.md -knowledge: - architecture: ../knowledge/architecture.md - security: ../knowledge/security.md -personas: - planner: ../personas/planner.md - architecture-reviewer: ../personas/architecture-reviewer.md - security-reviewer: ../personas/security-reviewer.md - ai-antipattern-reviewer: ../personas/ai-antipattern-reviewer.md - supervisor: ../personas/supervisor.md - pr-commenter: ../personas/pr-commenter.md -instructions: - review-arch: ../instructions/review-arch.md - review-security: ../instructions/review-security.md - review-ai: ../instructions/review-ai.md initial_movement: plan movements: - name: plan @@ -230,8 +213,3 @@ movements: --- *Generated by [takt](https://github.com/toruticas/takt) review-only piece* ``` -report_formats: - architecture-review: ../output-contracts/architecture-review.md - security-review: ../output-contracts/security-review.md - ai-review: ../output-contracts/ai-review.md - review-summary: ../output-contracts/review-summary.md diff --git a/builtins/en/pieces/structural-reform.yaml b/builtins/en/pieces/structural-reform.yaml index 07f8abc..bbff4b9 100644 --- a/builtins/en/pieces/structural-reform.yaml +++ b/builtins/en/pieces/structural-reform.yaml @@ -1,25 +1,6 @@ name: structural-reform description: Full project review and structural reform - iterative codebase restructuring with staged file splits max_iterations: 50 -policies: - coding: ../policies/coding.md - review: ../policies/review.md - testing: ../policies/testing.md - qa: ../policies/qa.md -knowledge: - backend: ../knowledge/backend.md - architecture: ../knowledge/architecture.md -personas: - planner: ../personas/planner.md - coder: ../personas/coder.md - architecture-reviewer: ../personas/architecture-reviewer.md - qa-reviewer: ../personas/qa-reviewer.md - supervisor: ../personas/supervisor.md -instructions: - implement: ../instructions/implement.md - review-arch: ../instructions/review-arch.md - review-qa: ../instructions/review-qa.md - fix: ../instructions/fix.md initial_movement: review loop_monitors: - cycle: @@ -447,9 +428,3 @@ movements: output_contracts: report: - name: 07-progress.md -report_formats: - plan: ../output-contracts/plan.md - architecture-review: ../output-contracts/architecture-review.md - qa-review: ../output-contracts/qa-review.md - validation: ../output-contracts/validation.md - summary: ../output-contracts/summary.md diff --git a/builtins/en/pieces/unit-test.yaml b/builtins/en/pieces/unit-test.yaml index dbae293..e8a1dfb 100644 --- a/builtins/en/pieces/unit-test.yaml +++ b/builtins/en/pieces/unit-test.yaml @@ -1,31 +1,6 @@ name: unit-test description: Unit test focused piece (test analysis → test implementation → review → fix) max_iterations: 20 -policies: - coding: ../policies/coding.md - review: ../policies/review.md - testing: ../policies/testing.md - ai-antipattern: ../policies/ai-antipattern.md - qa: ../policies/qa.md -knowledge: - architecture: ../knowledge/architecture.md - backend: ../knowledge/backend.md -personas: - test-planner: ../personas/test-planner.md - coder: ../personas/coder.md - ai-antipattern-reviewer: ../personas/ai-antipattern-reviewer.md - architecture-reviewer: ../personas/architecture-reviewer.md - qa-reviewer: ../personas/qa-reviewer.md - supervisor: ../personas/supervisor.md -instructions: - plan-test: ../instructions/plan-test.md - implement-test: ../instructions/implement-test.md - ai-review: ../instructions/ai-review.md - ai-fix: ../instructions/ai-fix.md - arbitrate: ../instructions/arbitrate.md - review-test: ../instructions/review-test.md - fix: ../instructions/fix.md - supervise: ../instructions/supervise.md initial_movement: plan_test loop_monitors: - cycle: @@ -259,9 +234,3 @@ movements: report: - Validation: 06-supervisor-validation.md - Summary: summary.md -report_formats: - test-plan: ../output-contracts/test-plan.md - ai-review: ../output-contracts/ai-review.md - qa-review: ../output-contracts/qa-review.md - validation: ../output-contracts/validation.md - summary: ../output-contracts/summary.md diff --git a/builtins/ja/pieces/coding.yaml b/builtins/ja/pieces/coding.yaml index 8b7413c..44908d0 100644 --- a/builtins/ja/pieces/coding.yaml +++ b/builtins/ja/pieces/coding.yaml @@ -1,24 +1,6 @@ name: coding description: Lightweight development piece with planning and parallel reviews (plan -> implement -> parallel review -> complete) max_iterations: 20 -policies: - coding: ../policies/coding.md - review: ../policies/review.md - testing: ../policies/testing.md - ai-antipattern: ../policies/ai-antipattern.md -knowledge: - architecture: ../knowledge/architecture.md -personas: - planner: ../personas/planner.md - coder: ../personas/coder.md - ai-antipattern-reviewer: ../personas/ai-antipattern-reviewer.md - architecture-reviewer: ../personas/architecture-reviewer.md -instructions: - plan: ../instructions/plan.md - implement: ../instructions/implement.md - ai-review: ../instructions/ai-review.md - review-arch: ../instructions/review-arch.md - fix: ../instructions/fix.md initial_movement: plan movements: - name: plan @@ -150,7 +132,3 @@ movements: - condition: 判断できない、情報不足 next: ABORT instruction: fix -report_formats: - plan: ../output-contracts/plan.md - ai-review: ../output-contracts/ai-review.md - architecture-review: ../output-contracts/architecture-review.md diff --git a/builtins/ja/pieces/compound-eye.yaml b/builtins/ja/pieces/compound-eye.yaml index d5a1962..e4c41bb 100644 --- a/builtins/ja/pieces/compound-eye.yaml +++ b/builtins/ja/pieces/compound-eye.yaml @@ -1,11 +1,6 @@ name: compound-eye description: 複眼レビュー - 同じ指示を Claude と Codex に同時に投げ、両者の回答を統合する max_iterations: 10 -knowledge: - architecture: ../knowledge/architecture.md -personas: - coder: ../personas/coder.md - supervisor: ../personas/supervisor.md initial_movement: evaluate movements: diff --git a/builtins/ja/pieces/default.yaml b/builtins/ja/pieces/default.yaml index dd7888c..3e26283 100644 --- a/builtins/ja/pieces/default.yaml +++ b/builtins/ja/pieces/default.yaml @@ -1,32 +1,6 @@ name: default description: Standard development piece with planning and specialized reviews max_iterations: 30 -policies: - coding: ../policies/coding.md - review: ../policies/review.md - testing: ../policies/testing.md - ai-antipattern: ../policies/ai-antipattern.md - qa: ../policies/qa.md -knowledge: - architecture: ../knowledge/architecture.md - backend: ../knowledge/backend.md -personas: - planner: ../personas/planner.md - coder: ../personas/coder.md - ai-antipattern-reviewer: ../personas/ai-antipattern-reviewer.md - architecture-reviewer: ../personas/architecture-reviewer.md - qa-reviewer: ../personas/qa-reviewer.md - supervisor: ../personas/supervisor.md -instructions: - plan: ../instructions/plan.md - implement: ../instructions/implement.md - ai-review: ../instructions/ai-review.md - ai-fix: ../instructions/ai-fix.md - arbitrate: ../instructions/arbitrate.md - review-arch: ../instructions/review-arch.md - review-qa: ../instructions/review-qa.md - fix: ../instructions/fix.md - supervise: ../instructions/supervise.md initial_movement: plan loop_monitors: - cycle: @@ -282,10 +256,3 @@ movements: report: - Validation: 07-supervisor-validation.md - Summary: summary.md -report_formats: - plan: ../output-contracts/plan.md - ai-review: ../output-contracts/ai-review.md - architecture-review: ../output-contracts/architecture-review.md - qa-review: ../output-contracts/qa-review.md - validation: ../output-contracts/validation.md - summary: ../output-contracts/summary.md diff --git a/builtins/ja/pieces/expert-cqrs.yaml b/builtins/ja/pieces/expert-cqrs.yaml index 130f81c..e4036cb 100644 --- a/builtins/ja/pieces/expert-cqrs.yaml +++ b/builtins/ja/pieces/expert-cqrs.yaml @@ -1,41 +1,6 @@ name: expert-cqrs description: CQRS+ES・フロントエンド・セキュリティ・QA専門家レビュー max_iterations: 30 -policies: - coding: ../policies/coding.md - review: ../policies/review.md - testing: ../policies/testing.md - ai-antipattern: ../policies/ai-antipattern.md - qa: ../policies/qa.md -knowledge: - frontend: ../knowledge/frontend.md - backend: ../knowledge/backend.md - cqrs-es: ../knowledge/cqrs-es.md - security: ../knowledge/security.md - architecture: ../knowledge/architecture.md -personas: - planner: ../personas/planner.md - coder: ../personas/coder.md - ai-antipattern-reviewer: ../personas/ai-antipattern-reviewer.md - architecture-reviewer: ../personas/architecture-reviewer.md - cqrs-es-reviewer: ../personas/cqrs-es-reviewer.md - frontend-reviewer: ../personas/frontend-reviewer.md - security-reviewer: ../personas/security-reviewer.md - qa-reviewer: ../personas/qa-reviewer.md - expert-supervisor: ../personas/expert-supervisor.md -instructions: - plan: ../instructions/plan.md - implement: ../instructions/implement.md - ai-review: ../instructions/ai-review.md - ai-fix: ../instructions/ai-fix.md - arbitrate: ../instructions/arbitrate.md - review-cqrs-es: ../instructions/review-cqrs-es.md - review-frontend: ../instructions/review-frontend.md - review-security: ../instructions/review-security.md - review-qa: ../instructions/review-qa.md - fix: ../instructions/fix.md - supervise: ../instructions/supervise.md - fix-supervisor: ../instructions/fix-supervisor.md initial_movement: plan movements: - name: plan @@ -323,12 +288,3 @@ movements: next: supervise - condition: 修正を進行できない next: plan -report_formats: - plan: ../output-contracts/plan.md - ai-review: ../output-contracts/ai-review.md - cqrs-es-review: ../output-contracts/cqrs-es-review.md - frontend-review: ../output-contracts/frontend-review.md - security-review: ../output-contracts/security-review.md - qa-review: ../output-contracts/qa-review.md - validation: ../output-contracts/validation.md - summary: ../output-contracts/summary.md diff --git a/builtins/ja/pieces/expert.yaml b/builtins/ja/pieces/expert.yaml index ae8ffa8..9a4220b 100644 --- a/builtins/ja/pieces/expert.yaml +++ b/builtins/ja/pieces/expert.yaml @@ -1,39 +1,6 @@ name: expert description: アーキテクチャ・フロントエンド・セキュリティ・QA専門家レビュー max_iterations: 30 -policies: - coding: ../policies/coding.md - review: ../policies/review.md - testing: ../policies/testing.md - ai-antipattern: ../policies/ai-antipattern.md - qa: ../policies/qa.md -knowledge: - frontend: ../knowledge/frontend.md - backend: ../knowledge/backend.md - security: ../knowledge/security.md - architecture: ../knowledge/architecture.md -personas: - planner: ../personas/planner.md - coder: ../personas/coder.md - ai-antipattern-reviewer: ../personas/ai-antipattern-reviewer.md - architecture-reviewer: ../personas/architecture-reviewer.md - frontend-reviewer: ../personas/frontend-reviewer.md - security-reviewer: ../personas/security-reviewer.md - qa-reviewer: ../personas/qa-reviewer.md - expert-supervisor: ../personas/expert-supervisor.md -instructions: - plan: ../instructions/plan.md - implement: ../instructions/implement.md - ai-review: ../instructions/ai-review.md - ai-fix: ../instructions/ai-fix.md - arbitrate: ../instructions/arbitrate.md - review-arch: ../instructions/review-arch.md - review-frontend: ../instructions/review-frontend.md - review-security: ../instructions/review-security.md - review-qa: ../instructions/review-qa.md - fix: ../instructions/fix.md - supervise: ../instructions/supervise.md - fix-supervisor: ../instructions/fix-supervisor.md initial_movement: plan movements: - name: plan @@ -317,12 +284,3 @@ movements: next: supervise - condition: 修正を進行できない next: plan -report_formats: - plan: ../output-contracts/plan.md - ai-review: ../output-contracts/ai-review.md - architecture-review: ../output-contracts/architecture-review.md - frontend-review: ../output-contracts/frontend-review.md - security-review: ../output-contracts/security-review.md - qa-review: ../output-contracts/qa-review.md - validation: ../output-contracts/validation.md - summary: ../output-contracts/summary.md diff --git a/builtins/ja/pieces/magi.yaml b/builtins/ja/pieces/magi.yaml index f905b37..679329b 100644 --- a/builtins/ja/pieces/magi.yaml +++ b/builtins/ja/pieces/magi.yaml @@ -1,10 +1,6 @@ name: magi description: MAGI合議システム - 3つの観点から分析し多数決で判定 max_iterations: 5 -personas: - melchior: ../personas/melchior.md - balthasar: ../personas/balthasar.md - casper: ../personas/casper.md initial_movement: melchior movements: - name: melchior diff --git a/builtins/ja/pieces/minimal.yaml b/builtins/ja/pieces/minimal.yaml index a0bfb8d..418f66a 100644 --- a/builtins/ja/pieces/minimal.yaml +++ b/builtins/ja/pieces/minimal.yaml @@ -1,21 +1,6 @@ name: minimal description: Minimal development piece (implement -> parallel review -> fix if needed -> complete) max_iterations: 20 -policies: - coding: ../policies/coding.md - review: ../policies/review.md - testing: ../policies/testing.md - ai-antipattern: ../policies/ai-antipattern.md -personas: - coder: ../personas/coder.md - ai-antipattern-reviewer: ../personas/ai-antipattern-reviewer.md - supervisor: ../personas/supervisor.md -instructions: - implement: ../instructions/implement.md - review-ai: ../instructions/review-ai.md - ai-fix: ../instructions/ai-fix.md - supervise: ../instructions/supervise.md - fix-supervisor: ../instructions/fix-supervisor.md initial_movement: implement movements: - name: implement @@ -190,5 +175,3 @@ movements: - condition: 修正を進行できない next: implement instruction: fix-supervisor -report_formats: - ai-review: ../output-contracts/ai-review.md diff --git a/builtins/ja/pieces/passthrough.yaml b/builtins/ja/pieces/passthrough.yaml index 1409cba..b2b9d48 100644 --- a/builtins/ja/pieces/passthrough.yaml +++ b/builtins/ja/pieces/passthrough.yaml @@ -1,11 +1,6 @@ name: passthrough description: Single-agent thin wrapper. Pass task directly to coder as-is. max_iterations: 10 -policies: - coding: ../policies/coding.md - testing: ../policies/testing.md -personas: - coder: ../personas/coder.md initial_movement: execute movements: - name: execute diff --git a/builtins/ja/pieces/research.yaml b/builtins/ja/pieces/research.yaml index 03b7653..67dbb4c 100644 --- a/builtins/ja/pieces/research.yaml +++ b/builtins/ja/pieces/research.yaml @@ -1,10 +1,6 @@ name: research description: 調査ピース - 質問せずに自律的に調査を実行 max_iterations: 10 -personas: - research-planner: ../personas/research-planner.md - research-digger: ../personas/research-digger.md - research-supervisor: ../personas/research-supervisor.md initial_movement: plan movements: - name: plan diff --git a/builtins/ja/pieces/review-fix-minimal.yaml b/builtins/ja/pieces/review-fix-minimal.yaml index 0c29773..e9b0fc9 100644 --- a/builtins/ja/pieces/review-fix-minimal.yaml +++ b/builtins/ja/pieces/review-fix-minimal.yaml @@ -1,21 +1,6 @@ name: review-fix-minimal description: 既存コードのレビューと修正ピース(レビュー開始、実装なし) max_iterations: 20 -policies: - coding: ../policies/coding.md - review: ../policies/review.md - testing: ../policies/testing.md - ai-antipattern: ../policies/ai-antipattern.md -personas: - coder: ../personas/coder.md - ai-antipattern-reviewer: ../personas/ai-antipattern-reviewer.md - supervisor: ../personas/supervisor.md -instructions: - implement: ../instructions/implement.md - review-ai: ../instructions/review-ai.md - ai-fix: ../instructions/ai-fix.md - supervise: ../instructions/supervise.md - fix-supervisor: ../instructions/fix-supervisor.md initial_movement: reviewers movements: - name: implement @@ -190,5 +175,3 @@ movements: - condition: 修正を進行できない next: implement instruction: fix-supervisor -report_formats: - ai-review: ../output-contracts/ai-review.md diff --git a/builtins/ja/pieces/review-only.yaml b/builtins/ja/pieces/review-only.yaml index 4075da0..75aea59 100644 --- a/builtins/ja/pieces/review-only.yaml +++ b/builtins/ja/pieces/review-only.yaml @@ -1,23 +1,6 @@ name: review-only description: レビュー専用ピース - コードをレビューするだけで編集は行わない max_iterations: 10 -policies: - review: ../policies/review.md - ai-antipattern: ../policies/ai-antipattern.md -knowledge: - architecture: ../knowledge/architecture.md - security: ../knowledge/security.md -personas: - planner: ../personas/planner.md - architecture-reviewer: ../personas/architecture-reviewer.md - security-reviewer: ../personas/security-reviewer.md - ai-antipattern-reviewer: ../personas/ai-antipattern-reviewer.md - supervisor: ../personas/supervisor.md - pr-commenter: ../personas/pr-commenter.md -instructions: - review-arch: ../instructions/review-arch.md - review-security: ../instructions/review-security.md - review-ai: ../instructions/review-ai.md initial_movement: plan movements: - name: plan @@ -231,8 +214,3 @@ movements: --- *[takt](https://github.com/toruticas/takt) review-only ピースで生成* ``` -report_formats: - architecture-review: ../output-contracts/architecture-review.md - security-review: ../output-contracts/security-review.md - ai-review: ../output-contracts/ai-review.md - review-summary: ../output-contracts/review-summary.md diff --git a/builtins/ja/pieces/structural-reform.yaml b/builtins/ja/pieces/structural-reform.yaml index 2445b6d..a765026 100644 --- a/builtins/ja/pieces/structural-reform.yaml +++ b/builtins/ja/pieces/structural-reform.yaml @@ -1,25 +1,6 @@ name: structural-reform description: プロジェクト全体レビューと構造改革 - 段階的なファイル分割による反復的コードベース再構築 max_iterations: 50 -policies: - coding: ../policies/coding.md - review: ../policies/review.md - testing: ../policies/testing.md - qa: ../policies/qa.md -knowledge: - backend: ../knowledge/backend.md - architecture: ../knowledge/architecture.md -personas: - planner: ../personas/planner.md - coder: ../personas/coder.md - architecture-reviewer: ../personas/architecture-reviewer.md - qa-reviewer: ../personas/qa-reviewer.md - supervisor: ../personas/supervisor.md -instructions: - implement: ../instructions/implement.md - review-arch: ../instructions/review-arch.md - review-qa: ../instructions/review-qa.md - fix: ../instructions/fix.md initial_movement: review loop_monitors: - cycle: @@ -447,9 +428,3 @@ movements: output_contracts: report: - name: 07-progress.md -report_formats: - plan: ../output-contracts/plan.md - architecture-review: ../output-contracts/architecture-review.md - qa-review: ../output-contracts/qa-review.md - validation: ../output-contracts/validation.md - summary: ../output-contracts/summary.md diff --git a/builtins/ja/pieces/unit-test.yaml b/builtins/ja/pieces/unit-test.yaml index ea8ad38..5859865 100644 --- a/builtins/ja/pieces/unit-test.yaml +++ b/builtins/ja/pieces/unit-test.yaml @@ -1,31 +1,6 @@ name: unit-test description: 単体テスト追加に特化したピース(テスト分析→テスト実装→レビュー→修正) max_iterations: 20 -policies: - coding: ../policies/coding.md - review: ../policies/review.md - testing: ../policies/testing.md - ai-antipattern: ../policies/ai-antipattern.md - qa: ../policies/qa.md -knowledge: - architecture: ../knowledge/architecture.md - backend: ../knowledge/backend.md -personas: - test-planner: ../personas/test-planner.md - coder: ../personas/coder.md - ai-antipattern-reviewer: ../personas/ai-antipattern-reviewer.md - architecture-reviewer: ../personas/architecture-reviewer.md - qa-reviewer: ../personas/qa-reviewer.md - supervisor: ../personas/supervisor.md -instructions: - plan-test: ../instructions/plan-test.md - implement-test: ../instructions/implement-test.md - ai-review: ../instructions/ai-review.md - ai-fix: ../instructions/ai-fix.md - arbitrate: ../instructions/arbitrate.md - review-test: ../instructions/review-test.md - fix: ../instructions/fix.md - supervise: ../instructions/supervise.md initial_movement: plan_test loop_monitors: - cycle: @@ -259,9 +234,3 @@ movements: report: - Validation: 06-supervisor-validation.md - Summary: summary.md -report_formats: - test-plan: ../output-contracts/test-plan.md - ai-review: ../output-contracts/ai-review.md - qa-review: ../output-contracts/qa-review.md - validation: ../output-contracts/validation.md - summary: ../output-contracts/summary.md diff --git a/docs/faceted-prompting.ja.md b/docs/faceted-prompting.ja.md index 50014b8..c6fe025 100644 --- a/docs/faceted-prompting.ja.md +++ b/docs/faceted-prompting.ja.md @@ -327,52 +327,33 @@ Faceted Promptingの中核メカニズムは**宣言的な合成**である。 ### TAKTでの実装例 -[TAKT](https://github.com/nrslib/takt) はFaceted PromptingをYAMLベースのワークフロー定義(「ピース」と呼ぶ)で実装している。各関心はセクションマップで短いキーにマッピングされ、各ステップ(TAKTでは「ムーブメント」と呼ぶ)からキーで参照される。 +[TAKT](https://github.com/nrslib/takt) はFaceted PromptingをYAMLベースのワークフロー定義(「ピース」と呼ぶ)で実装している。builtinの各ファセットは、各ステップ(TAKTでは「ムーブメント」と呼ぶ)から bare name で直接参照できる。セクションマップは「名前とファイル名が異なる」場合のカスタムエイリアス用途でのみ任意で使う。 ```yaml name: my-workflow max_iterations: 10 initial_movement: plan -# セクションマップ — キー: ファイルパス(このYAMLからの相対パス) -personas: - coder: ../personas/coder.md - reviewer: ../personas/architecture-reviewer.md - -policies: - coding: ../policies/coding.md - review: ../policies/review.md - -instructions: - plan: ../instructions/plan.md - implement: ../instructions/implement.md - -knowledge: - architecture: ../knowledge/architecture.md - -report_formats: - review: ../output-contracts/review.md - movements: - name: implement - persona: coder # WHO — personas.coder を参照 - policy: coding # RULES — policies.coding を参照 - instruction: implement # WHAT — instructions.implement を参照 - knowledge: architecture # CONTEXT — knowledge.architecture を参照 + persona: coder # WHO — builtins/{lang}/personas/coder.md + policy: coding # RULES — builtins/{lang}/policies/coding.md + instruction: implement # WHAT — builtins/{lang}/instructions/implement.md + knowledge: architecture # CONTEXT — builtins/{lang}/knowledge/architecture.md edit: true rules: - condition: Implementation complete next: review - name: review - persona: reviewer # 異なる WHO + persona: architecture-reviewer # 異なる WHO policy: review # 異なる RULES instruction: review # 異なる WHAT(共有も可能) knowledge: architecture # 同じ CONTEXT — 再利用 output_contracts: report: - name: review.md - format: review # OUTPUT — report_formats.review を参照 + format: architecture-review # OUTPUT — builtins/{lang}/output-contracts/architecture-review.md edit: false rules: - condition: Approved diff --git a/docs/faceted-prompting.md b/docs/faceted-prompting.md index e5e9f1a..0336288 100644 --- a/docs/faceted-prompting.md +++ b/docs/faceted-prompting.md @@ -327,52 +327,33 @@ Key properties: ### Implementation Example: TAKT -[TAKT](https://github.com/nrslib/takt) implements Faceted Prompting using YAML-based workflow definitions called "pieces." Concerns are mapped to short keys via section maps, then referenced by key in each step (called "movement" in TAKT): +[TAKT](https://github.com/nrslib/takt) implements Faceted Prompting using YAML-based workflow definitions called "pieces." Builtin facets can be referenced directly by bare name in each step (called "movement" in TAKT). Section maps are optional and only needed for custom aliases (name differs from file name): ```yaml name: my-workflow max_iterations: 10 initial_movement: plan -# Section maps — key: file path (relative to this YAML) -personas: - coder: ../personas/coder.md - reviewer: ../personas/architecture-reviewer.md - -policies: - coding: ../policies/coding.md - review: ../policies/review.md - -instructions: - plan: ../instructions/plan.md - implement: ../instructions/implement.md - -knowledge: - architecture: ../knowledge/architecture.md - -output_contracts: - review: ../output-contracts/review.md - movements: - name: implement - persona: coder # WHO — references personas.coder - policy: coding # RULES — references policies.coding - instruction: implement # WHAT — references instructions.implement - knowledge: architecture # CONTEXT — references knowledge.architecture + persona: coder # WHO — builtins/{lang}/personas/coder.md + policy: coding # RULES — builtins/{lang}/policies/coding.md + instruction: implement # WHAT — builtins/{lang}/instructions/implement.md + knowledge: architecture # CONTEXT — builtins/{lang}/knowledge/architecture.md edit: true rules: - condition: Implementation complete next: review - name: review - persona: reviewer # Different WHO + persona: architecture-reviewer # Different WHO policy: review # Different RULES instruction: review # Different WHAT (but could share) knowledge: architecture # Same CONTEXT — reused output_contracts: report: - name: review.md - format: review # OUTPUT — references report_formats.review + format: architecture-review # OUTPUT — builtins/{lang}/output-contracts/architecture-review.md edit: false rules: - condition: Approved diff --git a/src/__tests__/config.test.ts b/src/__tests__/config.test.ts index fa5b21d..ea73552 100644 --- a/src/__tests__/config.test.ts +++ b/src/__tests__/config.test.ts @@ -44,6 +44,15 @@ describe('getBuiltinPiece', () => { expect(piece!.name).toBe('default'); }); + it('should resolve builtin instruction_template without projectCwd', () => { + const piece = getBuiltinPiece('default'); + expect(piece).not.toBeNull(); + + const planMovement = piece!.movements.find((movement) => movement.name === 'plan'); + expect(planMovement).toBeDefined(); + expect(planMovement!.instructionTemplate).not.toBe('plan'); + }); + it('should return null for non-existent piece names', () => { expect(getBuiltinPiece('nonexistent-piece')).toBeNull(); expect(getBuiltinPiece('unknown')).toBeNull(); diff --git a/src/__tests__/facet-resolution.test.ts b/src/__tests__/facet-resolution.test.ts index 3070ecc..4a1e1d1 100644 --- a/src/__tests__/facet-resolution.test.ts +++ b/src/__tests__/facet-resolution.test.ts @@ -508,4 +508,110 @@ describe('normalizePieceConfig with layer resolution', () => { expect(config.movements[0]!.knowledgeContents).toBeDefined(); expect(config.movements[0]!.knowledgeContents![0]).toBe('# Domain Knowledge'); }); + + it('should resolve instruction_template from section map before layer resolution', () => { + const raw = { + name: 'test-piece', + instructions: { + implement: 'Mapped instruction template', + }, + movements: [ + { + name: 'step1', + persona: 'coder', + instruction_template: 'implement', + instruction: '{task}', + }, + ], + }; + + const context: FacetResolutionContext = { projectDir, lang: 'ja' }; + const config = normalizePieceConfig(raw, pieceDir, context); + + expect(config.movements[0]!.instructionTemplate).toBe('Mapped instruction template'); + }); + + it('should resolve instruction_template by name via layer resolution', () => { + const instructionsDir = join(projectDir, '.takt', 'instructions'); + mkdirSync(instructionsDir, { recursive: true }); + writeFileSync(join(instructionsDir, 'implement.md'), 'Project implement template'); + + const raw = { + name: 'test-piece', + movements: [ + { + name: 'step1', + persona: 'coder', + instruction_template: 'implement', + instruction: '{task}', + }, + ], + }; + + const context: FacetResolutionContext = { projectDir, lang: 'ja' }; + const config = normalizePieceConfig(raw, pieceDir, context); + + expect(config.movements[0]!.instructionTemplate).toBe('Project implement template'); + }); + + it('should keep inline instruction_template when no facet is found', () => { + const inlineTemplate = `Use this inline template. +Second line remains inline.`; + const raw = { + name: 'test-piece', + movements: [ + { + name: 'step1', + persona: 'coder', + instruction_template: inlineTemplate, + instruction: '{task}', + }, + ], + }; + + const context: FacetResolutionContext = { projectDir, lang: 'ja' }; + const config = normalizePieceConfig(raw, pieceDir, context); + + expect(config.movements[0]!.instructionTemplate).toBe(inlineTemplate); + }); + + it('should resolve loop monitor judge instruction_template via layer resolution', () => { + const instructionsDir = join(projectDir, '.takt', 'instructions'); + mkdirSync(instructionsDir, { recursive: true }); + writeFileSync(join(instructionsDir, 'judge-template.md'), 'Project judge template'); + + const raw = { + name: 'test-piece', + movements: [ + { + name: 'step1', + persona: 'coder', + instruction: '{task}', + rules: [{ condition: 'next', next: 'step2' }], + }, + { + name: 'step2', + persona: 'coder', + instruction: '{task}', + rules: [{ condition: 'done', next: 'COMPLETE' }], + }, + ], + loop_monitors: [ + { + cycle: ['step1', 'step2'], + threshold: 2, + judge: { + persona: 'coder', + instruction_template: 'judge-template', + rules: [{ condition: 'continue', next: 'step2' }], + }, + }, + ], + }; + + const context: FacetResolutionContext = { projectDir, lang: 'ja' }; + const config = normalizePieceConfig(raw, pieceDir, context); + + expect(config.loopMonitors?.[0]?.judge.instructionTemplate).toBe('Project judge template'); + }); }); diff --git a/src/infra/config/loaders/pieceParser.ts b/src/infra/config/loaders/pieceParser.ts index 9b17bd6..87d5039 100644 --- a/src/infra/config/loaders/pieceParser.ts +++ b/src/infra/config/loaders/pieceParser.ts @@ -15,7 +15,6 @@ import { getLanguage } from '../global/globalConfig.js'; import { type PieceSections, type FacetResolutionContext, - resolveResourceContent, resolveRefToContent, resolveRefList, resolveSectionMap, @@ -189,7 +188,9 @@ function normalizeStepFromRaw( model: step.model, permissionMode: step.permission_mode, edit: step.edit, - instructionTemplate: resolveResourceContent(step.instruction_template, pieceDir) || expandedInstruction || '{task}', + instructionTemplate: (step.instruction_template + ? resolveRefToContent(step.instruction_template, sections.resolvedInstructions, pieceDir, 'instructions', context) + : undefined) || expandedInstruction || '{task}', rules, outputContracts: normalizeOutputContracts(step.output_contracts, pieceDir, sections.resolvedReportFormats, context), qualityGates: step.quality_gates, @@ -217,7 +218,9 @@ function normalizeLoopMonitorJudge( return { persona: personaSpec, personaPath, - instructionTemplate: resolveResourceContent(raw.instruction_template, pieceDir), + instructionTemplate: raw.instruction_template + ? resolveRefToContent(raw.instruction_template, sections.resolvedInstructions, pieceDir, 'instructions', context) + : undefined, rules: raw.rules.map((r) => ({ condition: r.condition, next: r.next })), }; } @@ -297,10 +300,10 @@ export function loadPieceFromFile(filePath: string, projectDir?: string): PieceC const raw = parseYaml(content); const pieceDir = dirname(filePath); - let context: FacetResolutionContext | undefined; - if (projectDir) { - context = { projectDir, lang: getLanguage() }; - } + const context: FacetResolutionContext = { + lang: getLanguage(), + projectDir, + }; return normalizePieceConfig(raw, pieceDir, context); } diff --git a/src/infra/config/loaders/resource-resolver.ts b/src/infra/config/loaders/resource-resolver.ts index 99e250b..05a2765 100644 --- a/src/infra/config/loaders/resource-resolver.ts +++ b/src/infra/config/loaders/resource-resolver.ts @@ -15,7 +15,7 @@ import { getProjectFacetDir, getGlobalFacetDir, getBuiltinFacetDir } from '../pa /** Context for 3-layer facet resolution. */ export interface FacetResolutionContext { - projectDir: string; + projectDir?: string; lang: Language; } @@ -63,7 +63,7 @@ export function resolveFacetPath( context: FacetResolutionContext, ): string | undefined { const candidateDirs = [ - getProjectFacetDir(context.projectDir, facetType), + ...(context.projectDir ? [getProjectFacetDir(context.projectDir, facetType)] : []), getGlobalFacetDir(facetType), getBuiltinFacetDir(context.lang, facetType), ];