ai-execution-protocol 0.2.1 → 0.3.0

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.
Files changed (44) hide show
  1. package/AGENTS.md +11 -1
  2. package/README.md +29 -6
  3. package/dist/minimal/.aiignore +8 -8
  4. package/dist/minimal/AGENTS.md +41 -63
  5. package/dist/minimal/candidate-memory/README.md +4 -0
  6. package/dist/minimal/canonical-state.yaml +16 -14
  7. package/dist/minimal/context-map.yaml +22 -20
  8. package/dist/minimal/decisions/README.md +4 -7
  9. package/dist/minimal/memory/INDEX.yaml +20 -0
  10. package/dist/minimal/protocol/README.yaml +7 -1
  11. package/dist/minimal/protocol/adaptive-memory.yaml +97 -0
  12. package/dist/minimal/protocol/context-budget.yaml +44 -0
  13. package/dist/minimal/protocol/context-compiler.yaml +24 -1
  14. package/dist/minimal/protocol/fast-path.yaml +6 -1
  15. package/dist/minimal/protocol/persistent-context.yaml +13 -3
  16. package/dist/minimal/protocol/prompt-economy.yaml +16 -8
  17. package/dist/minimal/protocol/route-packs.yaml +32 -1
  18. package/dist/minimal/protocol/router.yaml +23 -1
  19. package/dist/minimal/protocol/selective-validation.yaml +44 -0
  20. package/dist/minimal/protocol/validation-checklist.yaml +10 -1
  21. package/install-manifest.json +64 -0
  22. package/package.json +3 -1
  23. package/protocol/README.yaml +7 -1
  24. package/protocol/adaptive-memory.yaml +97 -0
  25. package/protocol/context-budget.yaml +44 -0
  26. package/protocol/context-compiler.yaml +24 -1
  27. package/protocol/fast-path.yaml +6 -1
  28. package/protocol/persistent-context.yaml +13 -3
  29. package/protocol/prompt-economy.yaml +16 -8
  30. package/protocol/route-packs.yaml +32 -1
  31. package/protocol/router.yaml +23 -1
  32. package/protocol/selective-validation.yaml +44 -0
  33. package/protocol/validation-checklist.yaml +10 -1
  34. package/scripts/README.md +43 -0
  35. package/scripts/build_dist.py +12 -151
  36. package/scripts/npm_install_protocol.js +10 -161
  37. package/scripts/verify_install.py +23 -79
  38. package/templates/minimal/.aiignore +8 -0
  39. package/templates/minimal/AGENTS.md +41 -0
  40. package/templates/minimal/candidate-memory/README.md +4 -0
  41. package/templates/minimal/canonical-state.yaml +16 -0
  42. package/templates/minimal/context-map.yaml +22 -0
  43. package/templates/minimal/decisions/README.md +4 -0
  44. package/templates/minimal/memory/INDEX.yaml +20 -0
@@ -1,6 +1,6 @@
1
1
  id: route_packs
2
2
  type: route_summary_index
3
- version: 0.1
3
+ version: 0.3
4
4
  purpose: compact_first_read_before_full_route_files
5
5
  principle: read_pack_first_expand_only_when_needed
6
6
  use:
@@ -151,3 +151,34 @@ packs:
151
151
  - read_atomic_subject_doc_before_broad_doc
152
152
  - search_with_rg_before_full_file_reads
153
153
  - expand_context_without_expanding_scope
154
+ memory_update:
155
+ risk: 1
156
+ read_if_pack_insufficient:
157
+ - adaptive-memory.yaml
158
+ - context-budget.yaml
159
+ - validation-checklist.yaml
160
+ do:
161
+ - extract_only_stable_non_sensitive_knowledge
162
+ - search_before_create
163
+ - merge_replace_or_keep_unchanged
164
+ - update_memory_index
165
+ - report_memory_update_result
166
+ memory_conflict_or_replacement:
167
+ risk: 2
168
+ read_if_pack_insufficient:
169
+ - adaptive-memory.yaml
170
+ - context-compiler.yaml
171
+ - validation-checklist.yaml
172
+ do:
173
+ - preserve_provenance
174
+ - mark_old_entry_replaced
175
+ - keep_current_request_authoritative
176
+ - validate_no_duplicate_active_entry
177
+ selective_validation:
178
+ risk: 1
179
+ read_if_pack_insufficient:
180
+ - selective-validation.yaml
181
+ do:
182
+ - infer_checks_from_changed_files
183
+ - run_smallest_sufficient_validation
184
+ - expand_when_shared_contract_changes
@@ -1,6 +1,6 @@
1
1
  id: protocol_router
2
2
  type: read_router
3
- version: 0.1
3
+ version: 0.3
4
4
  purpose: choose_minimum_protocol_files_by_task
5
5
  default_read:
6
6
  - fast-path.yaml
@@ -93,11 +93,33 @@ routes:
93
93
  - persistent-context.yaml
94
94
  - context-rules.yaml
95
95
  - context-compiler.yaml
96
+ - context-budget.yaml
97
+ memory_update:
98
+ risk: 1
99
+ read:
100
+ - fast-path.yaml
101
+ - adaptive-memory.yaml
102
+ - context-budget.yaml
103
+ - validation-checklist.yaml
104
+ memory_conflict_or_replacement:
105
+ risk: 2
106
+ read:
107
+ - fast-path.yaml
108
+ - adaptive-memory.yaml
109
+ - context-compiler.yaml
110
+ - validation-checklist.yaml
111
+ selective_validation:
112
+ risk: 1
113
+ read:
114
+ - fast-path.yaml
115
+ - selective-validation.yaml
96
116
  rules:
97
117
  - start_with_default_read
98
118
  - choose_one_route_if_task_type_is_clear
99
119
  - read_route_pack_before_full_route_files_when_available
100
120
  - expand_from_route_pack_only_when_needed
121
+ - apply_context_budget_to_selected_route
122
+ - retrieve_only_matching_memory_subjects
101
123
  - if_route_unclear_read_risk_levels_then_choose_route
102
124
  - do_not_read_docs_unless_protocol_is_insufficient
103
125
  - do_not_read_cases_unless_testing_or_comparing_behavior
@@ -0,0 +1,44 @@
1
+ id: selective_validation
2
+ type: operational_rules
3
+ version: 0.3
4
+ purpose: run_smallest_validation_set_that_proves_the_change
5
+ principle: validation_scales_with_behavior_and_blast_radius
6
+ selection:
7
+ docs_only:
8
+ run:
9
+ - link_check
10
+ - text_search
11
+ - schema_if_structured
12
+ protocol_rule:
13
+ run:
14
+ - schema_validation
15
+ - mirror_sync
16
+ - framework_targeted_tests
17
+ parser_or_evaluator:
18
+ run:
19
+ - parser_adversarial_tests
20
+ - framework_tests
21
+ - benchmark_runner
22
+ installer_or_package:
23
+ run:
24
+ - install_test
25
+ - verify_install
26
+ - package_dry_run
27
+ shared_or_cross_module:
28
+ run:
29
+ - framework_tests
30
+ - health_check
31
+ release:
32
+ run:
33
+ - framework_tests
34
+ - schema_strict
35
+ - health_check
36
+ - npm_dry_run
37
+ - python_build
38
+ - twine_check
39
+ rules:
40
+ - infer_validation_from_changed_files_and_behavior
41
+ - expand_validation_when_shared_contract_changes
42
+ - never_claim_unrun_validation
43
+ - full_health_check_is_not_required_for_every_small_change
44
+ - user_visible_or_critical_change_requires_manual_test_guidance
@@ -1,6 +1,7 @@
1
1
  id: validation_checklist
2
2
  type: checklist
3
- version: 0.1
3
+ version: 0.3
4
+ selection_source: protocol/selective-validation.yaml
4
5
  automatic_validation:
5
6
  - unit_tests
6
7
  - integration_tests
@@ -57,3 +58,11 @@ rules:
57
58
  - make_limits_and_residual_risk_understandable
58
59
  - prefer_one_line_per_delivery_field
59
60
  - use_micro_format_only_when_readable
61
+ - id: VAL_005
62
+ always:
63
+ - select_smallest_validation_set_that_proves_behavior
64
+ - expand_when_shared_contract_or_blast_radius_requires
65
+ - record_every_expected_validation_not_run
66
+ avoid:
67
+ - full_health_check_for_trivial_local_change
68
+ - unrelated_expensive_validation
package/scripts/README.md CHANGED
@@ -47,6 +47,32 @@ Para medir uma rota especifica:
47
47
  python scripts/token_report.py --route user_flow_bug --out results/token-user-flow-bug.yaml
48
48
  ```
49
49
 
50
+ ## context_package.py
51
+
52
+ Gera um pacote de contexto limitado por risco, rota, memoria e candidatos.
53
+
54
+ ```powershell
55
+ python scripts/context_package.py --objective "Revisar memoria" --route memory_update --risk 2 --term memory
56
+ ```
57
+
58
+ ## memory_manager.py
59
+
60
+ Inclui, consulta e valida memoria adaptativa com deduplicacao e bloqueio de
61
+ conteudo sensivel.
62
+
63
+ ```powershell
64
+ python scripts/memory_manager.py --root . validate
65
+ ```
66
+
67
+ ## selective_validation.py
68
+
69
+ Seleciona as verificacoes proporcionais aos arquivos alterados.
70
+
71
+ ```powershell
72
+ python scripts/selective_validation.py
73
+ python scripts/selective_validation.py --release
74
+ ```
75
+
50
76
  ## health_check.py
51
77
 
52
78
  Roda a validacao geral do framework.
@@ -102,6 +128,23 @@ python scripts/framework_tests.py
102
128
 
103
129
  O relatorio fica em `results/framework-test-report.yaml`.
104
130
 
131
+ ## v03_tests.py
132
+
133
+ Testa memoria, orcamento de contexto, validacao seletiva e manifesto de
134
+ instalacao.
135
+
136
+ ```powershell
137
+ python scripts/v03_tests.py
138
+ ```
139
+
140
+ ## context_economy_benchmark.py
141
+
142
+ Compara leitura ampla com rotas focadas da v0.3.0.
143
+
144
+ ```powershell
145
+ python scripts/context_economy_benchmark.py
146
+ ```
147
+
105
148
  ## build_dist.py
106
149
 
107
150
  Gera `dist/minimal/` a partir de `AGENTS.md` minimo e `protocol/`.
@@ -3,6 +3,7 @@
3
3
 
4
4
  from __future__ import annotations
5
5
 
6
+ import json
6
7
  import shutil
7
8
  from pathlib import Path
8
9
 
@@ -10,91 +11,7 @@ from pathlib import Path
10
11
  ROOT = Path(__file__).resolve().parents[1]
11
12
  DIST = ROOT / "dist" / "minimal"
12
13
  PYTHON_PACKAGE_PROTOCOL = ROOT / "ai_execution_protocol" / "protocol"
13
-
14
-
15
- PROTOCOL_FILES = [
16
- "README.yaml",
17
- "fast-path.yaml",
18
- "router.yaml",
19
- "route-packs.yaml",
20
- "modes.yaml",
21
- "execution-rules.yaml",
22
- "risk-levels.yaml",
23
- "mapping-checklists.yaml",
24
- "validation-checklist.yaml",
25
- "context-rules.yaml",
26
- "context-compiler.yaml",
27
- "persistent-context.yaml",
28
- "formatting-rules.yaml",
29
- "prompt-economy.yaml",
30
- "spec-driven.yaml",
31
- ]
32
-
33
-
34
- MINIMAL_AGENTS = """# AGENTS.md
35
-
36
- ## Regra principal
37
-
38
- <!-- AI_PROTOCOL_BEGIN -->
39
-
40
- Use `protocol/fast-path.yaml` como entrada operacional minima.
41
-
42
- Siga `.aiignore` antes de abrir relatorios gerados.
43
-
44
- Este protocolo e obrigatorio para tarefas tecnicas neste projeto. Antes de
45
- editar, classifique risco, escolha rota e valide a entrega.
46
-
47
- ## Ordem de leitura
48
-
49
- 1. `protocol/fast-path.yaml`
50
- 2. `protocol/router.yaml`
51
- 3. `protocol/route-packs.yaml` para ler o resumo compacto da rota.
52
- 4. Arquivo YAML especifico em `protocol/` somente quando o pack nao bastar.
53
-
54
- ## Regras de execucao
55
-
56
- - Classifique o risco antes de agir.
57
- - Use o menor contexto suficiente.
58
- - Leia apenas os arquivos indicados por `protocol/router.yaml`.
59
- - Use `protocol/route-packs.yaml` antes de abrir todos os arquivos da rota.
60
- - Quando houver contexto grande, historico longo ou risco de confusao, use
61
- `protocol/context-compiler.yaml` antes de abrir muitos arquivos.
62
- - Use `protocol/spec-driven.yaml` para feature, refatoracao grande ou tarefa
63
- critica, sem criar spec pesada para tarefa simples.
64
- - Sempre entregue `Prompt original` e `Prompt melhorado da IA`; em baixo risco,
65
- prefira micro formato legivel com `PO`, `PM` e `OK`.
66
- - Nao edite arquivo que nao foi identificado como candidato.
67
- - Preserve documentos, regras de IDE e configuracoes de framework existentes,
68
- salvo pedido explicito do usuario.
69
- - Se o risco subir, atualize a classificacao antes de continuar.
70
- - Para nivel critico, peca confirmacao antes de acao sensivel.
71
- - Quando houver risco de quebrar fluxo existente, entregue uma lista do que
72
- testar.
73
- - Entregue com evidencia em poucas linhas: mudanca, validacao, limite e risco
74
- residual.
75
- - Explique o resultado em linguagem clara para uma pessoa leiga entender.
76
-
77
- ## Convivencia com arquivos existentes
78
-
79
- Quando houver conflito, siga esta prioridade:
80
-
81
- 1. pedido atual do usuario;
82
- 2. este bloco obrigatorio em `AGENTS.md`;
83
- 3. regras especificas da IDE ou do projeto;
84
- 4. docs e historico somente quando a rota pedir.
85
-
86
- Nao sobrescreva `README.md`, `docs/`, `.cursorrules`, `CLAUDE.md`,
87
- `.github/copilot-instructions.md` ou configs de framework sem pedido claro.
88
-
89
- ## Regras de organizacao
90
-
91
- - Nenhum arquivo deve passar de 400 linhas.
92
- - Organize primeiro para legibilidade por IA.
93
- - Use YAML para regras operacionais.
94
- - Evite duplicar a mesma regra em muitos lugares.
95
-
96
- <!-- AI_PROTOCOL_END -->
97
- """
14
+ PYTHON_PACKAGE_TEMPLATES = ROOT / "ai_execution_protocol" / "templates" / "minimal"
98
15
 
99
16
 
100
17
  MINIMAL_README = """# Minimal AI Protocol
@@ -160,68 +77,15 @@ O `install.ps1` tambem roda a verificacao. O resultado esperado e `PASS`.
160
77
  """
161
78
 
162
79
 
163
- MINIMAL_AIIGNORE = """# Context files ignored by default for AI reading.
164
-
165
- results/
166
- benchmarks/generated/
167
- model-runs/generated/
168
- dist/
169
- scripts/__pycache__/
170
- *.pyc
171
- """
172
-
173
-
174
- MINIMAL_CANONICAL_STATE = """id: canonical_state
175
- type: project_state
176
- version: 0.1
177
- purpose: small_current_truth_summary_for_ai_navigation
178
- status: bootstrap_template
179
- truth_order:
180
- - current_user_request
181
- - verified_current_files
182
- - protocol_rules
183
- - project_docs
184
- - conversation_history
185
- notes:
186
- - update_this_file_when_project_state_or_decisions_change
187
- - do_not_treat_this_file_as_truth_without_current_file_verification
188
- """
189
-
190
-
191
- MINIMAL_CONTEXT_MAP = """id: project_context_map
192
- type: context_map
193
- version: 0.1
194
- purpose: small_index_for_progressive_context_retrieval
195
- maintenance:
196
- current_mode: manual_bootstrap
197
- rule: aliases_are_pointers_not_truth
198
- read_first:
199
- - canonical-state.yaml
200
- - protocol/fast-path.yaml
201
- - protocol/router.yaml
202
- - protocol/route-packs.yaml
203
- domains: {}
204
- retrieval_policy:
205
- order:
206
- - match_domain_by_alias
207
- - read_domain_docs_only_when_needed
208
- - search_candidate_files_or_symbols
209
- - read_relevant_snippet_first
210
- - read_full_file_when_snippet_is_not_enough
211
- """
212
-
213
-
214
- MINIMAL_DECISIONS_README = """# Decisions
215
-
216
- Use esta pasta para registrar decisoes estaveis que a IA deve considerar ao
217
- mapear contexto.
218
-
219
- Cada decisao deve indicar status, escopo, impacto e arquivo relacionado quando
220
- existir.
221
- """
80
+ def copy_tree(source: Path, target: Path) -> None:
81
+ if target.exists():
82
+ shutil.rmtree(target)
83
+ shutil.copytree(source, target)
222
84
 
223
85
 
224
86
  def main() -> int:
87
+ manifest = json.loads((ROOT / "install-manifest.json").read_text(encoding="utf-8"))
88
+ protocol_files = manifest["protocol_files"]
225
89
  if DIST.exists():
226
90
  shutil.rmtree(DIST)
227
91
  (DIST / "protocol").mkdir(parents=True, exist_ok=True)
@@ -229,17 +93,14 @@ def main() -> int:
229
93
  shutil.rmtree(PYTHON_PACKAGE_PROTOCOL)
230
94
  PYTHON_PACKAGE_PROTOCOL.mkdir(parents=True, exist_ok=True)
231
95
 
232
- (DIST / "AGENTS.md").write_text(MINIMAL_AGENTS, encoding="utf-8")
96
+ shutil.copytree(ROOT / "templates" / "minimal", DIST, dirs_exist_ok=True)
233
97
  (DIST / "README.md").write_text(MINIMAL_README, encoding="utf-8")
234
- (DIST / ".aiignore").write_text(MINIMAL_AIIGNORE, encoding="utf-8")
235
- (DIST / "canonical-state.yaml").write_text(MINIMAL_CANONICAL_STATE, encoding="utf-8")
236
- (DIST / "context-map.yaml").write_text(MINIMAL_CONTEXT_MAP, encoding="utf-8")
237
- (DIST / "decisions").mkdir(parents=True, exist_ok=True)
238
- (DIST / "decisions" / "README.md").write_text(MINIMAL_DECISIONS_README, encoding="utf-8")
239
- for name in PROTOCOL_FILES:
98
+ for name in protocol_files:
240
99
  shutil.copy2(ROOT / "protocol" / name, DIST / "protocol" / name)
241
100
  shutil.copy2(ROOT / "protocol" / name, PYTHON_PACKAGE_PROTOCOL / name)
242
101
  (PYTHON_PACKAGE_PROTOCOL / "__init__.py").write_text("", encoding="utf-8")
102
+ shutil.copy2(ROOT / "install-manifest.json", ROOT / "ai_execution_protocol" / "install-manifest.json")
103
+ copy_tree(ROOT / "templates" / "minimal", PYTHON_PACKAGE_TEMPLATES)
243
104
 
244
105
  print(f"built {DIST}")
245
106
  return 0
@@ -6,94 +6,10 @@ const path = require("path");
6
6
  const root = path.resolve(__dirname, "..");
7
7
  const markerStart = "<!-- AI_PROTOCOL_BEGIN -->";
8
8
  const markerEnd = "<!-- AI_PROTOCOL_END -->";
9
- const protocolFiles = [
10
- "README.yaml",
11
- "fast-path.yaml",
12
- "router.yaml",
13
- "route-packs.yaml",
14
- "modes.yaml",
15
- "execution-rules.yaml",
16
- "risk-levels.yaml",
17
- "mapping-checklists.yaml",
18
- "validation-checklist.yaml",
19
- "context-rules.yaml",
20
- "context-compiler.yaml",
21
- "persistent-context.yaml",
22
- "formatting-rules.yaml",
23
- "prompt-economy.yaml",
24
- "spec-driven.yaml",
25
- ];
26
- const aiignoreLines = [
27
- "results/",
28
- "benchmarks/generated/",
29
- "model-runs/generated/",
30
- "dist/",
31
- "scripts/__pycache__/",
32
- "*.pyc",
33
- ];
34
- const minimalCanonicalState = `id: canonical_state
35
- type: project_state
36
- version: 0.1
37
- purpose: small_current_truth_summary_for_ai_navigation
38
- status: bootstrap_template
39
- truth_order:
40
- - current_user_request
41
- - verified_current_files
42
- - protocol_rules
43
- - project_docs
44
- - conversation_history
45
- notes:
46
- - update_this_file_when_project_state_or_decisions_change
47
- - do_not_treat_this_file_as_truth_without_current_file_verification
48
- `;
49
- const minimalContextMap = `id: project_context_map
50
- type: context_map
51
- version: 0.1
52
- purpose: small_index_for_progressive_context_retrieval
53
- maintenance:
54
- current_mode: manual_bootstrap
55
- rule: aliases_are_pointers_not_truth
56
- read_first:
57
- - canonical-state.yaml
58
- - protocol/fast-path.yaml
59
- - protocol/router.yaml
60
- - protocol/route-packs.yaml
61
- domains: {}
62
- retrieval_policy:
63
- order:
64
- - match_domain_by_alias
65
- - read_domain_docs_only_when_needed
66
- - search_candidate_files_or_symbols
67
- - read_relevant_snippet_first
68
- - read_full_file_when_snippet_is_not_enough
69
- `;
70
- const minimalDecisionsReadme = `# Decisions
71
-
72
- Use esta pasta para registrar decisoes estaveis que a IA deve considerar ao
73
- mapear contexto.
74
-
75
- Cada decisao deve indicar status, escopo, impacto e arquivo relacionado quando
76
- existir.
77
- `;
78
- const requiredText = {
79
- "AGENTS.md": [
80
- "AI_PROTOCOL_BEGIN",
81
- "protocol/fast-path.yaml",
82
- "protocol/router.yaml",
83
- "Classifique o risco antes de agir",
84
- "Nenhum arquivo deve passar de 400 linhas.",
85
- ],
86
- ".aiignore": ["results/", "dist/", "*.pyc"],
87
- "canonical-state.yaml": ["canonical_state", "truth_order"],
88
- "context-map.yaml": ["project_context_map", "aliases_are_pointers_not_truth"],
89
- "protocol/router.yaml": ["feature_or_spec", "spec-driven.yaml", "prompt_improvement"],
90
- "protocol/route-packs.yaml": [
91
- "read_pack_first_expand_only_when_needed",
92
- "simple_answer",
93
- "context_optimization",
94
- ],
95
- "protocol/spec-driven.yaml": ["protocol_is_base_spec_is_tool", "do_not_create_spec_for_low_value_tasks"],
96
- };
9
+ const manifest = JSON.parse(fs.readFileSync(path.join(root, "install-manifest.json"), "utf8"));
10
+ const protocolFiles = manifest.protocol_files;
11
+ const aiignoreLines = manifest.aiignore_lines;
12
+ const requiredText = manifest.required_text;
97
13
 
98
14
  function readText(file) {
99
15
  return fs.readFileSync(file, "utf8");
@@ -112,71 +28,7 @@ function sourceProtocolDir() {
112
28
 
113
29
  function minimalAgents() {
114
30
  const file = path.join(root, "dist", "minimal", "AGENTS.md");
115
- if (fs.existsSync(file)) return readText(file);
116
- return `# AGENTS.md
117
-
118
- ## Regra principal
119
-
120
- ${markerStart}
121
-
122
- Use \`protocol/fast-path.yaml\` como entrada operacional minima.
123
-
124
- Siga \`.aiignore\` antes de abrir relatorios gerados.
125
-
126
- Este protocolo e obrigatorio para tarefas tecnicas neste projeto. Antes de
127
- editar, classifique risco, escolha rota e valide a entrega.
128
-
129
- ## Ordem de leitura
130
-
131
- 1. \`protocol/fast-path.yaml\`
132
- 2. \`protocol/router.yaml\`
133
- 3. \`protocol/route-packs.yaml\` para ler o resumo compacto da rota.
134
- 4. Arquivo YAML especifico em \`protocol/\` somente quando o pack nao bastar.
135
-
136
- ## Regras de execucao
137
-
138
- - Classifique o risco antes de agir.
139
- - Use o menor contexto suficiente.
140
- - Leia apenas os arquivos indicados por \`protocol/router.yaml\`.
141
- - Use \`protocol/route-packs.yaml\` antes de abrir todos os arquivos da rota.
142
- - Quando houver contexto grande, historico longo ou risco de confusao, use
143
- \`protocol/context-compiler.yaml\` antes de abrir muitos arquivos.
144
- - Use \`protocol/spec-driven.yaml\` para feature, refatoracao grande ou tarefa
145
- critica, sem criar spec pesada para tarefa simples.
146
- - Sempre entregue \`Prompt original\` e \`Prompt melhorado da IA\`; em baixo risco,
147
- prefira micro formato legivel com \`PO\`, \`PM\` e \`OK\`.
148
- - Nao edite arquivo que nao foi identificado como candidato.
149
- - Preserve documentos, regras de IDE e configuracoes de framework existentes,
150
- salvo pedido explicito do usuario.
151
- - Se o risco subir, atualize a classificacao antes de continuar.
152
- - Para nivel critico, peca confirmacao antes de acao sensivel.
153
- - Quando houver risco de quebrar fluxo existente, entregue uma lista do que
154
- testar.
155
- - Entregue com evidencia em poucas linhas: mudanca, validacao, limite e risco
156
- residual.
157
- - Explique o resultado em linguagem clara para uma pessoa leiga entender.
158
-
159
- ## Convivencia com arquivos existentes
160
-
161
- Quando houver conflito, siga esta prioridade:
162
-
163
- 1. pedido atual do usuario;
164
- 2. este bloco obrigatorio em \`AGENTS.md\`;
165
- 3. regras especificas da IDE ou do projeto;
166
- 4. docs e historico somente quando a rota pedir.
167
-
168
- Nao sobrescreva \`README.md\`, \`docs/\`, \`.cursorrules\`, \`CLAUDE.md\`,
169
- \`.github/copilot-instructions.md\` ou configs de framework sem pedido claro.
170
-
171
- ## Regras de organizacao
172
-
173
- - Nenhum arquivo deve passar de 400 linhas.
174
- - Organize primeiro para legibilidade por IA.
175
- - Use YAML para regras operacionais.
176
- - Evite duplicar a mesma regra em muitos lugares.
177
-
178
- ${markerEnd}
179
- `;
31
+ return readText(file);
180
32
  }
181
33
 
182
34
  function protocolBlock() {
@@ -254,9 +106,10 @@ function writeIfMissing(file, text) {
254
106
  }
255
107
 
256
108
  function installContextTemplates(targetRoot) {
257
- writeIfMissing(path.join(targetRoot, "canonical-state.yaml"), minimalCanonicalState);
258
- writeIfMissing(path.join(targetRoot, "context-map.yaml"), minimalContextMap);
259
- writeIfMissing(path.join(targetRoot, "decisions", "README.md"), minimalDecisionsReadme);
109
+ for (const item of manifest.required_files) {
110
+ if (item === "AGENTS.md" || item === ".aiignore") continue;
111
+ writeIfMissing(path.join(targetRoot, item), readText(path.join(root, "dist", "minimal", item)));
112
+ }
260
113
  }
261
114
 
262
115
  function copyProtocol(target, force, backupRoot) {
@@ -294,11 +147,7 @@ function verify(target) {
294
147
  const targetRoot = path.resolve(target);
295
148
  const errors = [];
296
149
  const requiredFiles = [
297
- "AGENTS.md",
298
- ".aiignore",
299
- "canonical-state.yaml",
300
- "context-map.yaml",
301
- "decisions/README.md",
150
+ ...manifest.required_files,
302
151
  ...protocolFiles.map((file) => `protocol/${file}`),
303
152
  ];
304
153
  for (const item of requiredFiles) {