ai-execution-protocol 0.1.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.
- package/AGENTS.md +90 -0
- package/LICENSE +21 -0
- package/README.md +159 -0
- package/dist/minimal/.aiignore +8 -0
- package/dist/minimal/AGENTS.md +61 -0
- package/dist/minimal/README.md +60 -0
- package/dist/minimal/protocol/README.yaml +35 -0
- package/dist/minimal/protocol/context-compiler.yaml +110 -0
- package/dist/minimal/protocol/context-rules.yaml +71 -0
- package/dist/minimal/protocol/execution-rules.yaml +56 -0
- package/dist/minimal/protocol/fast-path.yaml +33 -0
- package/dist/minimal/protocol/formatting-rules.yaml +75 -0
- package/dist/minimal/protocol/mapping-checklists.yaml +42 -0
- package/dist/minimal/protocol/modes.yaml +42 -0
- package/dist/minimal/protocol/prompt-economy.yaml +96 -0
- package/dist/minimal/protocol/risk-levels.yaml +87 -0
- package/dist/minimal/protocol/router.yaml +100 -0
- package/dist/minimal/protocol/spec-driven.yaml +53 -0
- package/dist/minimal/protocol/validation-checklist.yaml +59 -0
- package/install.ps1 +16 -0
- package/package.json +46 -0
- package/protocol/README.yaml +35 -0
- package/protocol/context-compiler.yaml +110 -0
- package/protocol/context-rules.yaml +71 -0
- package/protocol/execution-rules.yaml +56 -0
- package/protocol/fast-path.yaml +33 -0
- package/protocol/formatting-rules.yaml +75 -0
- package/protocol/mapping-checklists.yaml +42 -0
- package/protocol/modes.yaml +42 -0
- package/protocol/prompt-economy.yaml +96 -0
- package/protocol/risk-levels.yaml +87 -0
- package/protocol/router.yaml +100 -0
- package/protocol/spec-driven.yaml +53 -0
- package/protocol/validation-checklist.yaml +59 -0
- package/scripts/README.md +222 -0
- package/scripts/build_dist.py +191 -0
- package/scripts/install_protocol.py +28 -0
- package/scripts/npm_install_protocol.js +278 -0
- package/scripts/verify_install.py +92 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
id: protocol_router
|
|
2
|
+
type: read_router
|
|
3
|
+
version: 0.1
|
|
4
|
+
purpose: choose_minimum_protocol_files_by_task
|
|
5
|
+
default_read:
|
|
6
|
+
- fast-path.yaml
|
|
7
|
+
- modes.yaml
|
|
8
|
+
routes:
|
|
9
|
+
simple_answer:
|
|
10
|
+
risk: 0
|
|
11
|
+
read:
|
|
12
|
+
- fast-path.yaml
|
|
13
|
+
small_fix:
|
|
14
|
+
risk: 1
|
|
15
|
+
read:
|
|
16
|
+
- fast-path.yaml
|
|
17
|
+
- validation-checklist.yaml
|
|
18
|
+
user_flow_bug:
|
|
19
|
+
risk: 2
|
|
20
|
+
read:
|
|
21
|
+
- fast-path.yaml
|
|
22
|
+
- context-compiler.yaml
|
|
23
|
+
- risk-levels.yaml
|
|
24
|
+
- mapping-checklists.yaml
|
|
25
|
+
- validation-checklist.yaml
|
|
26
|
+
refactor:
|
|
27
|
+
risk: 2
|
|
28
|
+
read:
|
|
29
|
+
- fast-path.yaml
|
|
30
|
+
- context-compiler.yaml
|
|
31
|
+
- mapping-checklists.yaml
|
|
32
|
+
- validation-checklist.yaml
|
|
33
|
+
- spec-driven.yaml
|
|
34
|
+
feature_or_spec:
|
|
35
|
+
risk: 2
|
|
36
|
+
read:
|
|
37
|
+
- fast-path.yaml
|
|
38
|
+
- context-compiler.yaml
|
|
39
|
+
- risk-levels.yaml
|
|
40
|
+
- mapping-checklists.yaml
|
|
41
|
+
- validation-checklist.yaml
|
|
42
|
+
- spec-driven.yaml
|
|
43
|
+
docs_update:
|
|
44
|
+
risk: 1
|
|
45
|
+
read:
|
|
46
|
+
- fast-path.yaml
|
|
47
|
+
- context-rules.yaml
|
|
48
|
+
- formatting-rules.yaml
|
|
49
|
+
database_or_data:
|
|
50
|
+
risk: 3
|
|
51
|
+
read:
|
|
52
|
+
- fast-path.yaml
|
|
53
|
+
- context-compiler.yaml
|
|
54
|
+
- risk-levels.yaml
|
|
55
|
+
- mapping-checklists.yaml
|
|
56
|
+
- validation-checklist.yaml
|
|
57
|
+
- spec-driven.yaml
|
|
58
|
+
auth_security_secret:
|
|
59
|
+
risk: 3
|
|
60
|
+
read:
|
|
61
|
+
- fast-path.yaml
|
|
62
|
+
- context-compiler.yaml
|
|
63
|
+
- risk-levels.yaml
|
|
64
|
+
- mapping-checklists.yaml
|
|
65
|
+
- validation-checklist.yaml
|
|
66
|
+
- spec-driven.yaml
|
|
67
|
+
deploy_or_production:
|
|
68
|
+
risk: 3
|
|
69
|
+
read:
|
|
70
|
+
- fast-path.yaml
|
|
71
|
+
- context-compiler.yaml
|
|
72
|
+
- risk-levels.yaml
|
|
73
|
+
- validation-checklist.yaml
|
|
74
|
+
- context-rules.yaml
|
|
75
|
+
- spec-driven.yaml
|
|
76
|
+
evaluate_response:
|
|
77
|
+
read:
|
|
78
|
+
- fast-path.yaml
|
|
79
|
+
- ../eval/rubric.yaml
|
|
80
|
+
- ../schema/evaluated-response.schema.json
|
|
81
|
+
create_or_edit_yaml:
|
|
82
|
+
read:
|
|
83
|
+
- fast-path.yaml
|
|
84
|
+
- formatting-rules.yaml
|
|
85
|
+
- ../schema/protocol-rule.schema.yaml
|
|
86
|
+
prompt_improvement:
|
|
87
|
+
read:
|
|
88
|
+
- fast-path.yaml
|
|
89
|
+
- prompt-economy.yaml
|
|
90
|
+
context_optimization:
|
|
91
|
+
read:
|
|
92
|
+
- fast-path.yaml
|
|
93
|
+
- context-rules.yaml
|
|
94
|
+
- context-compiler.yaml
|
|
95
|
+
rules:
|
|
96
|
+
- start_with_default_read
|
|
97
|
+
- choose_one_route_if_task_type_is_clear
|
|
98
|
+
- if_route_unclear_read_risk_levels_then_choose_route
|
|
99
|
+
- do_not_read_docs_unless_protocol_is_insufficient
|
|
100
|
+
- do_not_read_cases_unless_testing_or_comparing_behavior
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
id: spec_driven
|
|
2
|
+
type: operational_rules
|
|
3
|
+
version: 0.1
|
|
4
|
+
purpose: use_spec_driven_only_when_it_improves_safety_or_clarity
|
|
5
|
+
principle: protocol_is_base_spec_is_tool
|
|
6
|
+
when_to_use:
|
|
7
|
+
- feature_with_multiple_steps
|
|
8
|
+
- unclear_scope_with_real_implementation
|
|
9
|
+
- level_2_change_with_cross_file_impact
|
|
10
|
+
- level_3_change_before_sensitive_action
|
|
11
|
+
- user_requests_spec_or_roadmap
|
|
12
|
+
when_not_to_use:
|
|
13
|
+
- simple_answer
|
|
14
|
+
- tiny_reversible_fix
|
|
15
|
+
- clear_low_risk_change
|
|
16
|
+
- user_only_wants_quick_explanation
|
|
17
|
+
spec_levels:
|
|
18
|
+
light_spec:
|
|
19
|
+
use_when:
|
|
20
|
+
- level_1_or_2
|
|
21
|
+
- small_feature_or_bug
|
|
22
|
+
max_lines: 12
|
|
23
|
+
fields:
|
|
24
|
+
- objective
|
|
25
|
+
- scope
|
|
26
|
+
- affected_area
|
|
27
|
+
- validation
|
|
28
|
+
full_spec:
|
|
29
|
+
use_when:
|
|
30
|
+
- level_2_large
|
|
31
|
+
- level_3
|
|
32
|
+
- multi_module_change
|
|
33
|
+
max_lines: 40
|
|
34
|
+
fields:
|
|
35
|
+
- objective
|
|
36
|
+
- non_goals
|
|
37
|
+
- assumptions
|
|
38
|
+
- affected_area
|
|
39
|
+
- risk
|
|
40
|
+
- implementation_steps
|
|
41
|
+
- validation
|
|
42
|
+
- rollback_or_recovery
|
|
43
|
+
rules:
|
|
44
|
+
- keep_spec_shorter_than_context_it_saves
|
|
45
|
+
- do_not_create_spec_for_low_value_tasks
|
|
46
|
+
- use_spec_to_reduce_ambiguity_not_to_delay_execution
|
|
47
|
+
- after_spec_execute_with_fast_path_router_and_validation
|
|
48
|
+
- update_spec_only_when_scope_changes
|
|
49
|
+
delivery:
|
|
50
|
+
include:
|
|
51
|
+
- spec_used_or_skipped
|
|
52
|
+
- reason
|
|
53
|
+
- validation_result
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
id: validation_checklist
|
|
2
|
+
type: checklist
|
|
3
|
+
version: 0.1
|
|
4
|
+
automatic_validation:
|
|
5
|
+
- unit_tests
|
|
6
|
+
- integration_tests
|
|
7
|
+
- typecheck
|
|
8
|
+
- build
|
|
9
|
+
- lint
|
|
10
|
+
- link_check
|
|
11
|
+
- diff_check
|
|
12
|
+
manual_validation:
|
|
13
|
+
fields:
|
|
14
|
+
- where_to_test
|
|
15
|
+
- steps
|
|
16
|
+
- expected_result
|
|
17
|
+
- regression_signals
|
|
18
|
+
required_when:
|
|
19
|
+
- user_visible_impact
|
|
20
|
+
- regression_risk
|
|
21
|
+
- could_break_existing_flow
|
|
22
|
+
- validation_not_fully_automated
|
|
23
|
+
delivery:
|
|
24
|
+
default_style: micro_when_low_risk
|
|
25
|
+
required_fields:
|
|
26
|
+
- prompt_original
|
|
27
|
+
- prompt_melhorado_da_ia
|
|
28
|
+
- changed
|
|
29
|
+
- validated
|
|
30
|
+
- residual_risk
|
|
31
|
+
- plain_language_summary
|
|
32
|
+
conditional_fields:
|
|
33
|
+
- not_validated_when_any_expected_validation_was_not_run
|
|
34
|
+
- tests_to_run_when_break_risk_exists
|
|
35
|
+
optional_fields:
|
|
36
|
+
- next_step
|
|
37
|
+
rules:
|
|
38
|
+
- id: VAL_001
|
|
39
|
+
never: claim_tested_if_not_tested
|
|
40
|
+
- id: VAL_002
|
|
41
|
+
if_validation_not_possible:
|
|
42
|
+
- record_reason
|
|
43
|
+
- indicate_expected_test
|
|
44
|
+
- id: VAL_003
|
|
45
|
+
when:
|
|
46
|
+
any:
|
|
47
|
+
- could_break_existing_flow
|
|
48
|
+
- regression_risk
|
|
49
|
+
- user_visible_impact
|
|
50
|
+
do:
|
|
51
|
+
- provide_manual_test_list
|
|
52
|
+
- include_where_to_test_steps_expected_result
|
|
53
|
+
- id: VAL_004
|
|
54
|
+
always:
|
|
55
|
+
- explain_changes_in_plain_language
|
|
56
|
+
- avoid_unexplained_jargon
|
|
57
|
+
- make_limits_and_residual_risk_understandable
|
|
58
|
+
- prefer_one_line_per_delivery_field
|
|
59
|
+
- use_micro_format_only_when_readable
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# Scripts
|
|
2
|
+
|
|
3
|
+
Esta pasta guarda automacoes simples do framework.
|
|
4
|
+
|
|
5
|
+
## eval_runner.py
|
|
6
|
+
|
|
7
|
+
Avalia uma resposta YAML contra um caso YAML.
|
|
8
|
+
|
|
9
|
+
Exemplo:
|
|
10
|
+
|
|
11
|
+
```powershell
|
|
12
|
+
python scripts/eval_runner.py --case cases/03-bug-medio.yaml --response responses/sample-response.yaml --out results/sample-run.yaml
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
O runner nao chama IA. Ele compara uma resposta estruturada com o caso e gera um
|
|
16
|
+
resultado em `results/`.
|
|
17
|
+
|
|
18
|
+
## response_parser.py
|
|
19
|
+
|
|
20
|
+
Converte uma resposta em texto livre para `evaluated_response` YAML.
|
|
21
|
+
|
|
22
|
+
Exemplo:
|
|
23
|
+
|
|
24
|
+
```powershell
|
|
25
|
+
python scripts/response_parser.py --case cases/03-bug-medio.yaml --text responses/natural-sample.txt --out responses/parsed-sample.yaml
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Depois rode o avaliador:
|
|
29
|
+
|
|
30
|
+
```powershell
|
|
31
|
+
python scripts/eval_runner.py --case cases/03-bug-medio.yaml --response responses/parsed-sample.yaml --out results/parsed-sample-run.yaml
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## token_report.py
|
|
35
|
+
|
|
36
|
+
Estima custo de leitura das rotas em `protocol/router.yaml`.
|
|
37
|
+
|
|
38
|
+
Exemplo:
|
|
39
|
+
|
|
40
|
+
```powershell
|
|
41
|
+
python scripts/token_report.py --out results/token-report.yaml
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Para medir uma rota especifica:
|
|
45
|
+
|
|
46
|
+
```powershell
|
|
47
|
+
python scripts/token_report.py --route user_flow_bug --out results/token-user-flow-bug.yaml
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## health_check.py
|
|
51
|
+
|
|
52
|
+
Roda a validacao geral do framework.
|
|
53
|
+
|
|
54
|
+
Verifica:
|
|
55
|
+
|
|
56
|
+
- arquivos com no maximo 400 linhas;
|
|
57
|
+
- ASCII;
|
|
58
|
+
- links Markdown;
|
|
59
|
+
- campos obrigatorios dos casos;
|
|
60
|
+
- JSON valido nos schemas;
|
|
61
|
+
- parser, runner, token report e custo de prompt.
|
|
62
|
+
|
|
63
|
+
Exemplo:
|
|
64
|
+
|
|
65
|
+
```powershell
|
|
66
|
+
python scripts/health_check.py
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## benchmark_runner.py
|
|
70
|
+
|
|
71
|
+
Executa a suite em `benchmarks/benchmark-suite.yaml` e compara respostas sem
|
|
72
|
+
protocolo contra respostas com protocolo.
|
|
73
|
+
|
|
74
|
+
Exemplo:
|
|
75
|
+
|
|
76
|
+
```powershell
|
|
77
|
+
python scripts/benchmark_runner.py --out benchmarks/generated/report.yaml
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## model_runs_runner.py
|
|
81
|
+
|
|
82
|
+
Avalia respostas reais salvas em `model-runs/<modelo>/*.txt`.
|
|
83
|
+
|
|
84
|
+
Exemplo:
|
|
85
|
+
|
|
86
|
+
```powershell
|
|
87
|
+
python scripts/model_runs_runner.py
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
O relatorio fica em `model-runs/generated/report.yaml`.
|
|
91
|
+
|
|
92
|
+
## framework_tests.py
|
|
93
|
+
|
|
94
|
+
Roda testes extras de estrutura, rotas, parser, token report, pacote minimo e
|
|
95
|
+
model-runs.
|
|
96
|
+
|
|
97
|
+
Exemplo:
|
|
98
|
+
|
|
99
|
+
```powershell
|
|
100
|
+
python scripts/framework_tests.py
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
O relatorio fica em `results/framework-test-report.yaml`.
|
|
104
|
+
|
|
105
|
+
## build_dist.py
|
|
106
|
+
|
|
107
|
+
Gera `dist/minimal/` a partir de `AGENTS.md` minimo e `protocol/`.
|
|
108
|
+
|
|
109
|
+
Exemplo:
|
|
110
|
+
|
|
111
|
+
```powershell
|
|
112
|
+
python scripts/build_dist.py
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## install_protocol.py
|
|
116
|
+
|
|
117
|
+
Instala o pacote minimo em outro projeto.
|
|
118
|
+
|
|
119
|
+
Exemplo:
|
|
120
|
+
|
|
121
|
+
```powershell
|
|
122
|
+
python scripts/install_protocol.py --target C:\caminho\projeto --force
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Atalho:
|
|
126
|
+
|
|
127
|
+
```powershell
|
|
128
|
+
.\install.ps1 C:\caminho\projeto -Force
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Atalho via npm:
|
|
132
|
+
|
|
133
|
+
```powershell
|
|
134
|
+
npm run init-protocol -- C:\caminho\projeto
|
|
135
|
+
npm run install-protocol -- C:\caminho\projeto
|
|
136
|
+
npm run dry-run-protocol -- C:\caminho\projeto
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Quando publicado como pacote npm:
|
|
140
|
+
|
|
141
|
+
```powershell
|
|
142
|
+
npm install -g ai-execution-protocol
|
|
143
|
+
ai-protocol init C:\caminho\projeto
|
|
144
|
+
ai-protocol install C:\caminho\projeto
|
|
145
|
+
ai-protocol install C:\caminho\projeto --dry-run
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## npm_install_protocol.js
|
|
149
|
+
|
|
150
|
+
Wrapper de conveniencia para chamar `install.ps1` via `npm run`.
|
|
151
|
+
|
|
152
|
+
Exemplo:
|
|
153
|
+
|
|
154
|
+
```powershell
|
|
155
|
+
npm run install-protocol -- C:\caminho\projeto
|
|
156
|
+
npm run dry-run-protocol -- C:\caminho\projeto
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Para conferir manualmente pelo mesmo wrapper:
|
|
160
|
+
|
|
161
|
+
```powershell
|
|
162
|
+
npm run verify-protocol -- C:\caminho\projeto
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## ai_execution_protocol
|
|
166
|
+
|
|
167
|
+
Pacote Python com CLI propria e arquivos YAML embutidos.
|
|
168
|
+
|
|
169
|
+
Uso local:
|
|
170
|
+
|
|
171
|
+
```powershell
|
|
172
|
+
python -m ai_execution_protocol install C:\caminho\projeto
|
|
173
|
+
python -m ai_execution_protocol init C:\caminho\projeto
|
|
174
|
+
python -m ai_execution_protocol install C:\caminho\projeto --dry-run
|
|
175
|
+
python -m ai_execution_protocol verify C:\caminho\projeto
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Quando publicado como pacote Python:
|
|
179
|
+
|
|
180
|
+
```powershell
|
|
181
|
+
pip install ai-execution-protocol
|
|
182
|
+
ai-protocol install C:\caminho\projeto
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## verify_install.py
|
|
186
|
+
|
|
187
|
+
Verifica se o protocolo obrigatorio esta instalado no projeto alvo.
|
|
188
|
+
|
|
189
|
+
Exemplo:
|
|
190
|
+
|
|
191
|
+
```powershell
|
|
192
|
+
python scripts/verify_install.py --target C:\caminho\projeto
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## validate_schema.py
|
|
196
|
+
|
|
197
|
+
Valida YAML com JSON Schema quando as dependencias opcionais estao instaladas.
|
|
198
|
+
|
|
199
|
+
Instalacao:
|
|
200
|
+
|
|
201
|
+
```powershell
|
|
202
|
+
pip install -r requirements.txt
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Execucao:
|
|
206
|
+
|
|
207
|
+
```powershell
|
|
208
|
+
python scripts/validate_schema.py
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## prompt_cost.py
|
|
212
|
+
|
|
213
|
+
Mede se o prompt melhorado ficou economico para o nivel de risco.
|
|
214
|
+
|
|
215
|
+
O calculo valida limite de linhas, limite de tokens estimados e proporcao de
|
|
216
|
+
expansao entre prompt original e prompt melhorado.
|
|
217
|
+
|
|
218
|
+
Exemplo:
|
|
219
|
+
|
|
220
|
+
```powershell
|
|
221
|
+
python scripts/prompt_cost.py --original prompts/original-sample.txt --improved prompts/improved-sample.txt --level 2
|
|
222
|
+
```
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Build the minimal distributable package from source files."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import shutil
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
11
|
+
DIST = ROOT / "dist" / "minimal"
|
|
12
|
+
PYTHON_PACKAGE_PROTOCOL = ROOT / "ai_execution_protocol" / "protocol"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
PROTOCOL_FILES = [
|
|
16
|
+
"README.yaml",
|
|
17
|
+
"fast-path.yaml",
|
|
18
|
+
"router.yaml",
|
|
19
|
+
"modes.yaml",
|
|
20
|
+
"execution-rules.yaml",
|
|
21
|
+
"risk-levels.yaml",
|
|
22
|
+
"mapping-checklists.yaml",
|
|
23
|
+
"validation-checklist.yaml",
|
|
24
|
+
"context-rules.yaml",
|
|
25
|
+
"context-compiler.yaml",
|
|
26
|
+
"formatting-rules.yaml",
|
|
27
|
+
"prompt-economy.yaml",
|
|
28
|
+
"spec-driven.yaml",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
MINIMAL_AGENTS = """# AGENTS.md
|
|
33
|
+
|
|
34
|
+
## Regra principal
|
|
35
|
+
|
|
36
|
+
<!-- AI_PROTOCOL_BEGIN -->
|
|
37
|
+
|
|
38
|
+
Use `protocol/fast-path.yaml` como entrada operacional minima.
|
|
39
|
+
|
|
40
|
+
Siga `.aiignore` antes de abrir relatorios gerados.
|
|
41
|
+
|
|
42
|
+
Este protocolo e obrigatorio para tarefas tecnicas neste projeto. Antes de
|
|
43
|
+
editar, classifique risco, escolha rota e valide a entrega.
|
|
44
|
+
|
|
45
|
+
## Ordem de leitura
|
|
46
|
+
|
|
47
|
+
1. `protocol/fast-path.yaml`
|
|
48
|
+
2. `protocol/router.yaml`
|
|
49
|
+
3. Arquivo YAML especifico em `protocol/` conforme a rota.
|
|
50
|
+
|
|
51
|
+
## Regras de execucao
|
|
52
|
+
|
|
53
|
+
- Classifique o risco antes de agir.
|
|
54
|
+
- Use o menor contexto suficiente.
|
|
55
|
+
- Leia apenas os arquivos indicados por `protocol/router.yaml`.
|
|
56
|
+
- Quando houver contexto grande, historico longo ou risco de confusao, use
|
|
57
|
+
`protocol/context-compiler.yaml` antes de abrir muitos arquivos.
|
|
58
|
+
- Use `protocol/spec-driven.yaml` para feature, refatoracao grande ou tarefa
|
|
59
|
+
critica, sem criar spec pesada para tarefa simples.
|
|
60
|
+
- Sempre entregue `Prompt original` e `Prompt melhorado da IA`; em baixo risco,
|
|
61
|
+
prefira micro formato legivel com `PO`, `PM` e `OK`.
|
|
62
|
+
- Nao edite arquivo que nao foi identificado como candidato.
|
|
63
|
+
- Preserve documentos, regras de IDE e configuracoes de framework existentes,
|
|
64
|
+
salvo pedido explicito do usuario.
|
|
65
|
+
- Se o risco subir, atualize a classificacao antes de continuar.
|
|
66
|
+
- Para nivel critico, peca confirmacao antes de acao sensivel.
|
|
67
|
+
- Quando houver risco de quebrar fluxo existente, entregue uma lista do que
|
|
68
|
+
testar.
|
|
69
|
+
- Entregue com evidencia em poucas linhas: mudanca, validacao, limite e risco
|
|
70
|
+
residual.
|
|
71
|
+
- Explique o resultado em linguagem clara para uma pessoa leiga entender.
|
|
72
|
+
|
|
73
|
+
## Convivencia com arquivos existentes
|
|
74
|
+
|
|
75
|
+
Quando houver conflito, siga esta prioridade:
|
|
76
|
+
|
|
77
|
+
1. pedido atual do usuario;
|
|
78
|
+
2. este bloco obrigatorio em `AGENTS.md`;
|
|
79
|
+
3. regras especificas da IDE ou do projeto;
|
|
80
|
+
4. docs e historico somente quando a rota pedir.
|
|
81
|
+
|
|
82
|
+
Nao sobrescreva `README.md`, `docs/`, `.cursorrules`, `CLAUDE.md`,
|
|
83
|
+
`.github/copilot-instructions.md` ou configs de framework sem pedido claro.
|
|
84
|
+
|
|
85
|
+
## Regras de organizacao
|
|
86
|
+
|
|
87
|
+
- Nenhum arquivo deve passar de 400 linhas.
|
|
88
|
+
- Organize primeiro para legibilidade por IA.
|
|
89
|
+
- Use YAML para regras operacionais.
|
|
90
|
+
- Evite duplicar a mesma regra em muitos lugares.
|
|
91
|
+
|
|
92
|
+
<!-- AI_PROTOCOL_END -->
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
MINIMAL_README = """# Minimal AI Protocol
|
|
97
|
+
|
|
98
|
+
Pacote minimo para aplicar o protocolo em outro projeto.
|
|
99
|
+
|
|
100
|
+
Copie estes itens para a raiz do projeto alvo:
|
|
101
|
+
|
|
102
|
+
- `AGENTS.md`
|
|
103
|
+
- `.aiignore`
|
|
104
|
+
- `protocol/`
|
|
105
|
+
|
|
106
|
+
Use `AGENTS.md` como instrucao principal do agente.
|
|
107
|
+
|
|
108
|
+
Para instalar automaticamente:
|
|
109
|
+
|
|
110
|
+
```powershell
|
|
111
|
+
python scripts/install_protocol.py --target C:\\caminho\\projeto --force
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Comando unico facil de lembrar dentro deste repositorio:
|
|
115
|
+
|
|
116
|
+
```powershell
|
|
117
|
+
.\\install.ps1 C:\\caminho\\projeto -Force
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Atalho via npm:
|
|
121
|
+
|
|
122
|
+
```powershell
|
|
123
|
+
npm run install-protocol -- C:\\caminho\\projeto
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Como pacote npm publicado:
|
|
127
|
+
|
|
128
|
+
```powershell
|
|
129
|
+
npm install -g ai-execution-protocol
|
|
130
|
+
ai-protocol init C:\\caminho\\projeto
|
|
131
|
+
ai-protocol install C:\\caminho\\projeto
|
|
132
|
+
ai-protocol install C:\\caminho\\projeto --dry-run
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Como pacote Python publicado:
|
|
136
|
+
|
|
137
|
+
```powershell
|
|
138
|
+
pip install ai-execution-protocol
|
|
139
|
+
ai-protocol install C:\\caminho\\projeto
|
|
140
|
+
ai-protocol verify C:\\caminho\\projeto
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Se o terminal ja estiver no projeto alvo:
|
|
144
|
+
|
|
145
|
+
```powershell
|
|
146
|
+
C:\\caminho\\ai-research\\install.ps1 . -Force
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
No CMD:
|
|
150
|
+
|
|
151
|
+
```bat
|
|
152
|
+
install.bat C:\\caminho\\projeto
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
O `install.ps1` tambem roda a verificacao. O resultado esperado e `PASS`.
|
|
156
|
+
"""
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
MINIMAL_AIIGNORE = """# Context files ignored by default for AI reading.
|
|
160
|
+
|
|
161
|
+
results/
|
|
162
|
+
benchmarks/generated/
|
|
163
|
+
model-runs/generated/
|
|
164
|
+
dist/
|
|
165
|
+
scripts/__pycache__/
|
|
166
|
+
*.pyc
|
|
167
|
+
"""
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def main() -> int:
|
|
171
|
+
if DIST.exists():
|
|
172
|
+
shutil.rmtree(DIST)
|
|
173
|
+
(DIST / "protocol").mkdir(parents=True, exist_ok=True)
|
|
174
|
+
if PYTHON_PACKAGE_PROTOCOL.exists():
|
|
175
|
+
shutil.rmtree(PYTHON_PACKAGE_PROTOCOL)
|
|
176
|
+
PYTHON_PACKAGE_PROTOCOL.mkdir(parents=True, exist_ok=True)
|
|
177
|
+
|
|
178
|
+
(DIST / "AGENTS.md").write_text(MINIMAL_AGENTS, encoding="utf-8")
|
|
179
|
+
(DIST / "README.md").write_text(MINIMAL_README, encoding="utf-8")
|
|
180
|
+
(DIST / ".aiignore").write_text(MINIMAL_AIIGNORE, encoding="utf-8")
|
|
181
|
+
for name in PROTOCOL_FILES:
|
|
182
|
+
shutil.copy2(ROOT / "protocol" / name, DIST / "protocol" / name)
|
|
183
|
+
shutil.copy2(ROOT / "protocol" / name, PYTHON_PACKAGE_PROTOCOL / name)
|
|
184
|
+
(PYTHON_PACKAGE_PROTOCOL / "__init__.py").write_text("", encoding="utf-8")
|
|
185
|
+
|
|
186
|
+
print(f"built {DIST}")
|
|
187
|
+
return 0
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
if __name__ == "__main__":
|
|
191
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Install the minimal AI protocol into another project."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
11
|
+
if str(ROOT) not in sys.path:
|
|
12
|
+
sys.path.insert(0, str(ROOT))
|
|
13
|
+
|
|
14
|
+
from ai_execution_protocol.cli import install
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def main() -> int:
|
|
18
|
+
parser = argparse.ArgumentParser()
|
|
19
|
+
parser.add_argument("--target", default=".", help="Project root to install into")
|
|
20
|
+
parser.add_argument("--force", action="store_true", help="Replace existing protocol folder")
|
|
21
|
+
parser.add_argument("--dry-run", action="store_true", help="Show planned changes without writing files")
|
|
22
|
+
args = parser.parse_args()
|
|
23
|
+
|
|
24
|
+
return install(args.target, force=args.force, dry_run=args.dry_run)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
if __name__ == "__main__":
|
|
28
|
+
raise SystemExit(main())
|