ai-execution-protocol 0.2.1 → 0.3.1
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 +18 -1
- package/README.md +42 -6
- package/dist/minimal/.aiignore +8 -8
- package/dist/minimal/AGENTS.md +45 -63
- package/dist/minimal/candidate-memory/README.md +4 -0
- package/dist/minimal/canonical-state.yaml +16 -14
- package/dist/minimal/capabilities/registry.yaml +48 -0
- package/dist/minimal/context-map.yaml +23 -20
- package/dist/minimal/decisions/README.md +4 -7
- package/dist/minimal/memory/INDEX.yaml +20 -0
- package/dist/minimal/protocol/README.yaml +9 -1
- package/dist/minimal/protocol/adaptive-memory.yaml +97 -0
- package/dist/minimal/protocol/capability-router.yaml +123 -0
- package/dist/minimal/protocol/context-budget.yaml +44 -0
- package/dist/minimal/protocol/context-compiler.yaml +24 -1
- package/dist/minimal/protocol/fast-path.yaml +8 -1
- package/dist/minimal/protocol/persistent-context.yaml +13 -3
- package/dist/minimal/protocol/prompt-economy.yaml +16 -8
- package/dist/minimal/protocol/route-packs.yaml +43 -1
- package/dist/minimal/protocol/router.yaml +30 -1
- package/dist/minimal/protocol/selective-validation.yaml +44 -0
- package/dist/minimal/protocol/validation-checklist.yaml +10 -1
- package/install-manifest.json +75 -0
- package/package.json +3 -1
- package/protocol/README.yaml +9 -1
- package/protocol/adaptive-memory.yaml +97 -0
- package/protocol/capability-router.yaml +123 -0
- package/protocol/context-budget.yaml +44 -0
- package/protocol/context-compiler.yaml +24 -1
- package/protocol/fast-path.yaml +8 -1
- package/protocol/persistent-context.yaml +13 -3
- package/protocol/prompt-economy.yaml +16 -8
- package/protocol/route-packs.yaml +43 -1
- package/protocol/router.yaml +30 -1
- package/protocol/selective-validation.yaml +44 -0
- package/protocol/validation-checklist.yaml +10 -1
- package/scripts/README.md +75 -0
- package/scripts/build_dist.py +12 -151
- package/scripts/npm_install_protocol.js +10 -161
- package/scripts/verify_install.py +23 -79
- package/templates/minimal/.aiignore +8 -0
- package/templates/minimal/AGENTS.md +45 -0
- package/templates/minimal/candidate-memory/README.md +4 -0
- package/templates/minimal/canonical-state.yaml +16 -0
- package/templates/minimal/capabilities/registry.yaml +48 -0
- package/templates/minimal/context-map.yaml +23 -0
- package/templates/minimal/decisions/README.md +4 -0
- package/templates/minimal/memory/INDEX.yaml +20 -0
package/scripts/README.md
CHANGED
|
@@ -47,6 +47,46 @@ 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
|
+
|
|
76
|
+
## capability_router.py
|
|
77
|
+
|
|
78
|
+
Seleciona o menor conjunto de skills, MCPs e ferramentas que cobre a tarefa.
|
|
79
|
+
|
|
80
|
+
```powershell
|
|
81
|
+
python scripts/capability_router.py --risk 1 --operation read --tag code_search
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Capacidades marcadas como `runtime` precisam ser informadas:
|
|
85
|
+
|
|
86
|
+
```powershell
|
|
87
|
+
python scripts/capability_router.py --risk 2 --operation read --tag external_context --available targeted_mcp
|
|
88
|
+
```
|
|
89
|
+
|
|
50
90
|
## health_check.py
|
|
51
91
|
|
|
52
92
|
Roda a validacao geral do framework.
|
|
@@ -102,6 +142,41 @@ python scripts/framework_tests.py
|
|
|
102
142
|
|
|
103
143
|
O relatorio fica em `results/framework-test-report.yaml`.
|
|
104
144
|
|
|
145
|
+
## v03_tests.py
|
|
146
|
+
|
|
147
|
+
Testa memoria, orcamento de contexto, validacao seletiva e manifesto de
|
|
148
|
+
instalacao.
|
|
149
|
+
|
|
150
|
+
```powershell
|
|
151
|
+
python scripts/v03_tests.py
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## v031_tests.py
|
|
155
|
+
|
|
156
|
+
Testa cobertura, custo, disponibilidade e confirmacao do roteador de
|
|
157
|
+
capacidades.
|
|
158
|
+
|
|
159
|
+
```powershell
|
|
160
|
+
python scripts/v031_tests.py
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## context_economy_benchmark.py
|
|
164
|
+
|
|
165
|
+
Compara leitura ampla com rotas focadas do protocolo atual.
|
|
166
|
+
|
|
167
|
+
```powershell
|
|
168
|
+
python scripts/context_economy_benchmark.py
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## capability_economy_benchmark.py
|
|
172
|
+
|
|
173
|
+
Compara carregar o catalogo inteiro com selecionar apenas capacidades
|
|
174
|
+
necessarias.
|
|
175
|
+
|
|
176
|
+
```powershell
|
|
177
|
+
python scripts/capability_economy_benchmark.py
|
|
178
|
+
```
|
|
179
|
+
|
|
105
180
|
## build_dist.py
|
|
106
181
|
|
|
107
182
|
Gera `dist/minimal/` a partir de `AGENTS.md` minimo e `protocol/`.
|
package/scripts/build_dist.py
CHANGED
|
@@ -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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
(
|
|
96
|
+
shutil.copytree(ROOT / "templates" / "minimal", DIST, dirs_exist_ok=True)
|
|
233
97
|
(DIST / "README.md").write_text(MINIMAL_README, encoding="utf-8")
|
|
234
|
-
|
|
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
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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
|
-
|
|
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) {
|
|
@@ -1,93 +1,34 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""Verify
|
|
2
|
+
"""Verify an installed protocol using the shared install manifest."""
|
|
3
3
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
|
|
6
6
|
import argparse
|
|
7
|
+
import json
|
|
7
8
|
from pathlib import Path
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
"AGENTS.md",
|
|
12
|
-
".aiignore",
|
|
13
|
-
"canonical-state.yaml",
|
|
14
|
-
"context-map.yaml",
|
|
15
|
-
"decisions/README.md",
|
|
16
|
-
"protocol/README.yaml",
|
|
17
|
-
"protocol/fast-path.yaml",
|
|
18
|
-
"protocol/router.yaml",
|
|
19
|
-
"protocol/route-packs.yaml",
|
|
20
|
-
"protocol/modes.yaml",
|
|
21
|
-
"protocol/execution-rules.yaml",
|
|
22
|
-
"protocol/risk-levels.yaml",
|
|
23
|
-
"protocol/mapping-checklists.yaml",
|
|
24
|
-
"protocol/validation-checklist.yaml",
|
|
25
|
-
"protocol/context-rules.yaml",
|
|
26
|
-
"protocol/context-compiler.yaml",
|
|
27
|
-
"protocol/persistent-context.yaml",
|
|
28
|
-
"protocol/formatting-rules.yaml",
|
|
29
|
-
"protocol/prompt-economy.yaml",
|
|
30
|
-
"protocol/spec-driven.yaml",
|
|
31
|
-
]
|
|
11
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
32
12
|
|
|
33
|
-
REQUIRED_TEXT = {
|
|
34
|
-
"AGENTS.md": [
|
|
35
|
-
"AI_PROTOCOL_BEGIN",
|
|
36
|
-
"protocol/fast-path.yaml",
|
|
37
|
-
"protocol/router.yaml",
|
|
38
|
-
"Classifique o risco antes de agir",
|
|
39
|
-
"Prompt original",
|
|
40
|
-
"Prompt melhorado da IA",
|
|
41
|
-
"lista do que",
|
|
42
|
-
"Nenhum arquivo deve passar de 400 linhas.",
|
|
43
|
-
],
|
|
44
|
-
".aiignore": [
|
|
45
|
-
"results/",
|
|
46
|
-
"dist/",
|
|
47
|
-
"*.pyc",
|
|
48
|
-
],
|
|
49
|
-
"canonical-state.yaml": [
|
|
50
|
-
"canonical_state",
|
|
51
|
-
"truth_order",
|
|
52
|
-
],
|
|
53
|
-
"context-map.yaml": [
|
|
54
|
-
"project_context_map",
|
|
55
|
-
"aliases_are_pointers_not_truth",
|
|
56
|
-
],
|
|
57
|
-
"protocol/router.yaml": [
|
|
58
|
-
"feature_or_spec",
|
|
59
|
-
"spec-driven.yaml",
|
|
60
|
-
"prompt_improvement",
|
|
61
|
-
],
|
|
62
|
-
"protocol/route-packs.yaml": [
|
|
63
|
-
"read_pack_first_expand_only_when_needed",
|
|
64
|
-
"simple_answer",
|
|
65
|
-
"context_optimization",
|
|
66
|
-
],
|
|
67
|
-
"protocol/spec-driven.yaml": [
|
|
68
|
-
"protocol_is_base_spec_is_tool",
|
|
69
|
-
"do_not_create_spec_for_low_value_tasks",
|
|
70
|
-
],
|
|
71
|
-
}
|
|
72
13
|
|
|
14
|
+
def load_manifest() -> dict:
|
|
15
|
+
return json.loads((ROOT / "install-manifest.json").read_text(encoding="utf-8"))
|
|
73
16
|
|
|
74
|
-
def main() -> int:
|
|
75
|
-
parser = argparse.ArgumentParser()
|
|
76
|
-
parser.add_argument("--target", required=True, help="Project root to verify")
|
|
77
|
-
args = parser.parse_args()
|
|
78
|
-
|
|
79
|
-
root = Path(args.target).resolve()
|
|
80
|
-
errors: list[str] = []
|
|
81
17
|
|
|
82
|
-
|
|
18
|
+
def verify(root: Path) -> list[str]:
|
|
19
|
+
manifest = load_manifest()
|
|
20
|
+
required = manifest["required_files"] + [
|
|
21
|
+
f"protocol/{name}" for name in manifest["protocol_files"]
|
|
22
|
+
]
|
|
23
|
+
errors = []
|
|
24
|
+
for item in required:
|
|
83
25
|
path = root / item
|
|
84
26
|
if not path.exists():
|
|
85
27
|
errors.append(f"missing:{item}")
|
|
86
28
|
continue
|
|
87
29
|
if path.is_file() and len(path.read_text(encoding="utf-8").splitlines()) > 400:
|
|
88
30
|
errors.append(f"line_limit:{item}")
|
|
89
|
-
|
|
90
|
-
for item, snippets in REQUIRED_TEXT.items():
|
|
31
|
+
for item, snippets in manifest["required_text"].items():
|
|
91
32
|
path = root / item
|
|
92
33
|
if not path.exists() or not path.is_file():
|
|
93
34
|
continue
|
|
@@ -95,15 +36,18 @@ def main() -> int:
|
|
|
95
36
|
for snippet in snippets:
|
|
96
37
|
if snippet not in text:
|
|
97
38
|
errors.append(f"missing_text:{item}:{snippet}")
|
|
39
|
+
return errors
|
|
98
40
|
|
|
99
|
-
if errors:
|
|
100
|
-
print("FAIL")
|
|
101
|
-
for error in errors:
|
|
102
|
-
print(error)
|
|
103
|
-
return 1
|
|
104
41
|
|
|
105
|
-
|
|
106
|
-
|
|
42
|
+
def main() -> int:
|
|
43
|
+
parser = argparse.ArgumentParser()
|
|
44
|
+
parser.add_argument("--target", required=True, help="Project root to verify")
|
|
45
|
+
args = parser.parse_args()
|
|
46
|
+
errors = verify(Path(args.target).resolve())
|
|
47
|
+
print("PASS" if not errors else "FAIL")
|
|
48
|
+
for error in errors:
|
|
49
|
+
print(error)
|
|
50
|
+
return 1 if errors else 0
|
|
107
51
|
|
|
108
52
|
|
|
109
53
|
if __name__ == "__main__":
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
## Regra principal
|
|
4
|
+
|
|
5
|
+
<!-- AI_PROTOCOL_BEGIN -->
|
|
6
|
+
|
|
7
|
+
Use `protocol/fast-path.yaml` como entrada operacional minima.
|
|
8
|
+
|
|
9
|
+
Este protocolo e obrigatorio para tarefas tecnicas. Classifique risco, escolha
|
|
10
|
+
rota, consulte o pack compacto, carregue somente memoria relevante e valide a
|
|
11
|
+
entrega.
|
|
12
|
+
|
|
13
|
+
## Ordem de leitura
|
|
14
|
+
|
|
15
|
+
1. `protocol/fast-path.yaml`
|
|
16
|
+
2. `protocol/router.yaml`
|
|
17
|
+
3. `protocol/route-packs.yaml`
|
|
18
|
+
4. `memory/INDEX.yaml` somente quando memoria puder ajudar
|
|
19
|
+
5. `capabilities/registry.yaml` somente quando a tarefa exigir ferramenta
|
|
20
|
+
6. YAML completo da rota somente quando o pack nao bastar
|
|
21
|
+
|
|
22
|
+
## Regras de execucao
|
|
23
|
+
|
|
24
|
+
- Classifique o risco antes de agir.
|
|
25
|
+
- Use o menor contexto suficiente e respeite `protocol/context-budget.yaml`.
|
|
26
|
+
- Use `protocol/capability-router.yaml` para carregar somente skills, MCPs e
|
|
27
|
+
ferramentas necessarias.
|
|
28
|
+
- Risco maior restringe permissao; nao aumenta a quantidade por padrao.
|
|
29
|
+
- Memoria orienta; pedido atual autoriza; codigo verificado define realidade.
|
|
30
|
+
- Nunca amplie escopo com base em previsao ou preferencia antiga.
|
|
31
|
+
- Use `protocol/selective-validation.yaml` para escolher a menor prova suficiente.
|
|
32
|
+
- Ao terminar, verifique memoria: updated, unchanged, candidate, replaced ou
|
|
33
|
+
blocked_sensitive.
|
|
34
|
+
- Nao persista segredo, token, dado de cliente ou informacao pessoal desnecessaria.
|
|
35
|
+
- Para nivel critico, peca confirmacao antes de acao sensivel.
|
|
36
|
+
- Entregue mudanca, validacao, limite e risco residual em poucas linhas.
|
|
37
|
+
|
|
38
|
+
## Regras de organizacao
|
|
39
|
+
|
|
40
|
+
- Nenhum arquivo fonte deve passar de 400 linhas.
|
|
41
|
+
- Organize por assunto rastreavel.
|
|
42
|
+
- Use YAML para operacao e Markdown para explicacao.
|
|
43
|
+
- Evite duplicar regras e memoria.
|
|
44
|
+
|
|
45
|
+
<!-- AI_PROTOCOL_END -->
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
id: canonical_state
|
|
2
|
+
type: project_state
|
|
3
|
+
version: 0.3.1
|
|
4
|
+
purpose: small_current_truth_summary_for_ai_navigation
|
|
5
|
+
status: bootstrap_template
|
|
6
|
+
truth_order:
|
|
7
|
+
- current_user_request
|
|
8
|
+
- verified_current_files
|
|
9
|
+
- active_project_decisions
|
|
10
|
+
- explicit_user_preferences
|
|
11
|
+
- inferred_patterns_with_evidence
|
|
12
|
+
- project_docs
|
|
13
|
+
- conversation_history
|
|
14
|
+
notes:
|
|
15
|
+
- memory_guides_current_request_authorizes
|
|
16
|
+
- update_when_verified_project_state_changes
|