ai-execution-protocol 0.1.0__py3-none-any.whl
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.
- ai_execution_protocol/__init__.py +3 -0
- ai_execution_protocol/__main__.py +5 -0
- ai_execution_protocol/cli.py +283 -0
- ai_execution_protocol/protocol/README.yaml +35 -0
- ai_execution_protocol/protocol/__init__.py +0 -0
- ai_execution_protocol/protocol/context-compiler.yaml +110 -0
- ai_execution_protocol/protocol/context-rules.yaml +71 -0
- ai_execution_protocol/protocol/execution-rules.yaml +56 -0
- ai_execution_protocol/protocol/fast-path.yaml +33 -0
- ai_execution_protocol/protocol/formatting-rules.yaml +75 -0
- ai_execution_protocol/protocol/mapping-checklists.yaml +42 -0
- ai_execution_protocol/protocol/modes.yaml +42 -0
- ai_execution_protocol/protocol/prompt-economy.yaml +96 -0
- ai_execution_protocol/protocol/risk-levels.yaml +87 -0
- ai_execution_protocol/protocol/router.yaml +100 -0
- ai_execution_protocol/protocol/spec-driven.yaml +53 -0
- ai_execution_protocol/protocol/validation-checklist.yaml +59 -0
- ai_execution_protocol-0.1.0.dist-info/METADATA +180 -0
- ai_execution_protocol-0.1.0.dist-info/RECORD +23 -0
- ai_execution_protocol-0.1.0.dist-info/WHEEL +5 -0
- ai_execution_protocol-0.1.0.dist-info/entry_points.txt +2 -0
- ai_execution_protocol-0.1.0.dist-info/licenses/LICENSE +21 -0
- ai_execution_protocol-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""CLI for installing the minimal AI protocol into a project."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import shutil
|
|
8
|
+
from datetime import datetime
|
|
9
|
+
from importlib import resources
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
MARKER_START = "<!-- AI_PROTOCOL_BEGIN -->"
|
|
14
|
+
MARKER_END = "<!-- AI_PROTOCOL_END -->"
|
|
15
|
+
AIIGNORE_LINES = [
|
|
16
|
+
"results/",
|
|
17
|
+
"benchmarks/generated/",
|
|
18
|
+
"model-runs/generated/",
|
|
19
|
+
"dist/",
|
|
20
|
+
"scripts/__pycache__/",
|
|
21
|
+
"*.pyc",
|
|
22
|
+
]
|
|
23
|
+
REQUIRED_PROTOCOL_FILES = [
|
|
24
|
+
"README.yaml",
|
|
25
|
+
"fast-path.yaml",
|
|
26
|
+
"router.yaml",
|
|
27
|
+
"modes.yaml",
|
|
28
|
+
"execution-rules.yaml",
|
|
29
|
+
"risk-levels.yaml",
|
|
30
|
+
"mapping-checklists.yaml",
|
|
31
|
+
"validation-checklist.yaml",
|
|
32
|
+
"context-rules.yaml",
|
|
33
|
+
"context-compiler.yaml",
|
|
34
|
+
"formatting-rules.yaml",
|
|
35
|
+
"prompt-economy.yaml",
|
|
36
|
+
"spec-driven.yaml",
|
|
37
|
+
]
|
|
38
|
+
REQUIRED_FILES = [
|
|
39
|
+
"AGENTS.md",
|
|
40
|
+
".aiignore",
|
|
41
|
+
*[f"protocol/{name}" for name in REQUIRED_PROTOCOL_FILES],
|
|
42
|
+
]
|
|
43
|
+
REQUIRED_TEXT = {
|
|
44
|
+
"AGENTS.md": [
|
|
45
|
+
"AI_PROTOCOL_BEGIN",
|
|
46
|
+
"protocol/fast-path.yaml",
|
|
47
|
+
"protocol/router.yaml",
|
|
48
|
+
"Classifique o risco antes de agir",
|
|
49
|
+
"Nenhum arquivo deve passar de 400 linhas.",
|
|
50
|
+
],
|
|
51
|
+
".aiignore": [
|
|
52
|
+
"results/",
|
|
53
|
+
"dist/",
|
|
54
|
+
"*.pyc",
|
|
55
|
+
],
|
|
56
|
+
"protocol/router.yaml": [
|
|
57
|
+
"feature_or_spec",
|
|
58
|
+
"spec-driven.yaml",
|
|
59
|
+
"prompt_improvement",
|
|
60
|
+
],
|
|
61
|
+
"protocol/spec-driven.yaml": [
|
|
62
|
+
"protocol_is_base_spec_is_tool",
|
|
63
|
+
"do_not_create_spec_for_low_value_tasks",
|
|
64
|
+
],
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def protocol_source() -> resources.abc.Traversable:
|
|
69
|
+
return resources.files("ai_execution_protocol").joinpath("protocol")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def minimal_agents() -> str:
|
|
73
|
+
return """# AGENTS.md
|
|
74
|
+
|
|
75
|
+
## Regra principal
|
|
76
|
+
|
|
77
|
+
<!-- AI_PROTOCOL_BEGIN -->
|
|
78
|
+
|
|
79
|
+
Use `protocol/fast-path.yaml` como entrada operacional minima.
|
|
80
|
+
|
|
81
|
+
Siga `.aiignore` antes de abrir relatorios gerados.
|
|
82
|
+
|
|
83
|
+
Este protocolo e obrigatorio para tarefas tecnicas neste projeto. Antes de
|
|
84
|
+
editar, classifique risco, escolha rota e valide a entrega.
|
|
85
|
+
|
|
86
|
+
## Ordem de leitura
|
|
87
|
+
|
|
88
|
+
1. `protocol/fast-path.yaml`
|
|
89
|
+
2. `protocol/router.yaml`
|
|
90
|
+
3. Arquivo YAML especifico em `protocol/` conforme a rota.
|
|
91
|
+
|
|
92
|
+
## Regras de execucao
|
|
93
|
+
|
|
94
|
+
- Classifique o risco antes de agir.
|
|
95
|
+
- Use o menor contexto suficiente.
|
|
96
|
+
- Leia apenas os arquivos indicados por `protocol/router.yaml`.
|
|
97
|
+
- Quando houver contexto grande, historico longo ou risco de confusao, use
|
|
98
|
+
`protocol/context-compiler.yaml` antes de abrir muitos arquivos.
|
|
99
|
+
- Use `protocol/spec-driven.yaml` para feature, refatoracao grande ou tarefa
|
|
100
|
+
critica, sem criar spec pesada para tarefa simples.
|
|
101
|
+
- Sempre entregue `Prompt original` e `Prompt melhorado da IA`; em baixo risco,
|
|
102
|
+
prefira micro formato legivel com `PO`, `PM` e `OK`.
|
|
103
|
+
- Nao edite arquivo que nao foi identificado como candidato.
|
|
104
|
+
- Preserve documentos, regras de IDE e configuracoes de framework existentes,
|
|
105
|
+
salvo pedido explicito do usuario.
|
|
106
|
+
- Se o risco subir, atualize a classificacao antes de continuar.
|
|
107
|
+
- Para nivel critico, peca confirmacao antes de acao sensivel.
|
|
108
|
+
- Quando houver risco de quebrar fluxo existente, entregue uma lista do que
|
|
109
|
+
testar.
|
|
110
|
+
- Entregue com evidencia em poucas linhas: mudanca, validacao, limite e risco
|
|
111
|
+
residual.
|
|
112
|
+
- Explique o resultado em linguagem clara para uma pessoa leiga entender.
|
|
113
|
+
|
|
114
|
+
## Convivencia com arquivos existentes
|
|
115
|
+
|
|
116
|
+
Quando houver conflito, siga esta prioridade:
|
|
117
|
+
|
|
118
|
+
1. pedido atual do usuario;
|
|
119
|
+
2. este bloco obrigatorio em `AGENTS.md`;
|
|
120
|
+
3. regras especificas da IDE ou do projeto;
|
|
121
|
+
4. docs e historico somente quando a rota pedir.
|
|
122
|
+
|
|
123
|
+
Nao sobrescreva `README.md`, `docs/`, `.cursorrules`, `CLAUDE.md`,
|
|
124
|
+
`.github/copilot-instructions.md` ou configs de framework sem pedido claro.
|
|
125
|
+
|
|
126
|
+
## Regras de organizacao
|
|
127
|
+
|
|
128
|
+
- Nenhum arquivo deve passar de 400 linhas.
|
|
129
|
+
- Organize primeiro para legibilidade por IA.
|
|
130
|
+
- Use YAML para regras operacionais.
|
|
131
|
+
- Evite duplicar a mesma regra em muitos lugares.
|
|
132
|
+
|
|
133
|
+
<!-- AI_PROTOCOL_END -->
|
|
134
|
+
"""
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def protocol_block() -> str:
|
|
138
|
+
text = minimal_agents()
|
|
139
|
+
start = text.index(MARKER_START)
|
|
140
|
+
end = text.index(MARKER_END) + len(MARKER_END)
|
|
141
|
+
return text[start:end]
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def backup_path(path: Path, backup_root: Path) -> None:
|
|
145
|
+
if not path.exists():
|
|
146
|
+
return
|
|
147
|
+
backup_root.mkdir(parents=True, exist_ok=True)
|
|
148
|
+
destination = backup_root / path.name
|
|
149
|
+
if path.is_dir():
|
|
150
|
+
shutil.copytree(path, destination)
|
|
151
|
+
else:
|
|
152
|
+
shutil.copy2(path, destination)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def copy_protocol(target: Path, force: bool, backup_root: Path) -> None:
|
|
156
|
+
if target.exists() and not force:
|
|
157
|
+
return
|
|
158
|
+
if target.exists():
|
|
159
|
+
backup_path(target, backup_root)
|
|
160
|
+
shutil.rmtree(target)
|
|
161
|
+
target.mkdir(parents=True, exist_ok=True)
|
|
162
|
+
source = protocol_source()
|
|
163
|
+
for name in REQUIRED_PROTOCOL_FILES:
|
|
164
|
+
(target / name).write_text(source.joinpath(name).read_text(encoding="utf-8"), encoding="utf-8")
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def install_agents(target: Path) -> None:
|
|
168
|
+
block = protocol_block()
|
|
169
|
+
if not target.exists():
|
|
170
|
+
target.write_text(minimal_agents(), encoding="utf-8")
|
|
171
|
+
return
|
|
172
|
+
|
|
173
|
+
text = target.read_text(encoding="utf-8")
|
|
174
|
+
if MARKER_START in text and MARKER_END in text:
|
|
175
|
+
before, rest = text.split(MARKER_START, 1)
|
|
176
|
+
_, after = rest.split(MARKER_END, 1)
|
|
177
|
+
merged = before.rstrip() + "\n\n" + block + after
|
|
178
|
+
else:
|
|
179
|
+
merged = block + "\n\n## Instrucoes existentes do projeto\n\n" + text
|
|
180
|
+
target.write_text(merged.strip() + "\n", encoding="utf-8")
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def install_aiignore(target: Path) -> None:
|
|
184
|
+
existing = target.read_text(encoding="utf-8").splitlines() if target.exists() else []
|
|
185
|
+
lines = list(existing)
|
|
186
|
+
for item in AIIGNORE_LINES:
|
|
187
|
+
if item not in lines:
|
|
188
|
+
lines.append(item)
|
|
189
|
+
target.write_text("\n".join(lines).strip() + "\n", encoding="utf-8")
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def print_dry_run(target_root: Path, force: bool) -> None:
|
|
193
|
+
print(f"DRY-RUN target -> {target_root.resolve()}")
|
|
194
|
+
print(("update" if (target_root / "AGENTS.md").exists() else "create") + ":AGENTS.md")
|
|
195
|
+
print(("update" if (target_root / ".aiignore").exists() else "create") + ":.aiignore")
|
|
196
|
+
protocol_dir = target_root / "protocol"
|
|
197
|
+
if protocol_dir.exists() and force:
|
|
198
|
+
print("backup:protocol/")
|
|
199
|
+
print("replace:protocol/")
|
|
200
|
+
elif protocol_dir.exists():
|
|
201
|
+
print("keep:protocol/")
|
|
202
|
+
else:
|
|
203
|
+
print("create:protocol/")
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def install(target: str, force: bool, dry_run: bool = False) -> int:
|
|
207
|
+
target_root = Path(target).resolve()
|
|
208
|
+
if dry_run:
|
|
209
|
+
print_dry_run(target_root, force)
|
|
210
|
+
return 0
|
|
211
|
+
|
|
212
|
+
target_root.mkdir(parents=True, exist_ok=True)
|
|
213
|
+
backup_root = target_root / ".ai-protocol-backup" / datetime.now().strftime("%Y%m%d%H%M%S")
|
|
214
|
+
|
|
215
|
+
if (target_root / "AGENTS.md").exists():
|
|
216
|
+
backup_path(target_root / "AGENTS.md", backup_root)
|
|
217
|
+
if (target_root / ".aiignore").exists():
|
|
218
|
+
backup_path(target_root / ".aiignore", backup_root)
|
|
219
|
+
|
|
220
|
+
install_agents(target_root / "AGENTS.md")
|
|
221
|
+
install_aiignore(target_root / ".aiignore")
|
|
222
|
+
copy_protocol(target_root / "protocol", force, backup_root)
|
|
223
|
+
|
|
224
|
+
print(f"installed protocol -> {target_root}")
|
|
225
|
+
return verify(target)
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def verify(target: str) -> int:
|
|
229
|
+
root = Path(target).resolve()
|
|
230
|
+
errors: list[str] = []
|
|
231
|
+
|
|
232
|
+
for item in REQUIRED_FILES:
|
|
233
|
+
path = root / item
|
|
234
|
+
if not path.exists():
|
|
235
|
+
errors.append(f"missing:{item}")
|
|
236
|
+
continue
|
|
237
|
+
if path.is_file() and len(path.read_text(encoding="utf-8").splitlines()) > 400:
|
|
238
|
+
errors.append(f"line_limit:{item}")
|
|
239
|
+
|
|
240
|
+
for item, snippets in REQUIRED_TEXT.items():
|
|
241
|
+
path = root / item
|
|
242
|
+
if not path.exists() or not path.is_file():
|
|
243
|
+
continue
|
|
244
|
+
text = path.read_text(encoding="utf-8")
|
|
245
|
+
for snippet in snippets:
|
|
246
|
+
if snippet not in text:
|
|
247
|
+
errors.append(f"missing_text:{item}:{snippet}")
|
|
248
|
+
|
|
249
|
+
if errors:
|
|
250
|
+
print("FAIL")
|
|
251
|
+
for error in errors:
|
|
252
|
+
print(error)
|
|
253
|
+
return 1
|
|
254
|
+
|
|
255
|
+
print("PASS")
|
|
256
|
+
return 0
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def main() -> int:
|
|
260
|
+
parser = argparse.ArgumentParser(prog="ai-protocol")
|
|
261
|
+
subparsers = parser.add_subparsers(dest="command")
|
|
262
|
+
|
|
263
|
+
install_parser = subparsers.add_parser("install", help="Install protocol into a project")
|
|
264
|
+
install_parser.add_argument("target", nargs="?", default=".", help="Project root")
|
|
265
|
+
install_parser.add_argument("--no-force", action="store_true", help="Do not replace existing protocol folder")
|
|
266
|
+
install_parser.add_argument("--dry-run", action="store_true", help="Show planned changes without writing files")
|
|
267
|
+
|
|
268
|
+
init_parser = subparsers.add_parser("init", help="Initialize protocol in a new project")
|
|
269
|
+
init_parser.add_argument("target", nargs="?", default=".", help="Project root")
|
|
270
|
+
init_parser.add_argument("--no-force", action="store_true", help="Do not replace existing protocol folder")
|
|
271
|
+
init_parser.add_argument("--dry-run", action="store_true", help="Show planned changes without writing files")
|
|
272
|
+
|
|
273
|
+
verify_parser = subparsers.add_parser("verify", help="Verify protocol installation")
|
|
274
|
+
verify_parser.add_argument("target", nargs="?", default=".", help="Project root")
|
|
275
|
+
|
|
276
|
+
args = parser.parse_args()
|
|
277
|
+
if args.command in {"install", "init"}:
|
|
278
|
+
return install(args.target, force=not args.no_force, dry_run=args.dry_run)
|
|
279
|
+
if args.command == "verify":
|
|
280
|
+
return verify(args.target)
|
|
281
|
+
|
|
282
|
+
parser.print_help()
|
|
283
|
+
return 1
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
id: protocol_index
|
|
2
|
+
type: index
|
|
3
|
+
format: yaml
|
|
4
|
+
protocol_version: 0.1.0
|
|
5
|
+
purpose: ai_operational_rules
|
|
6
|
+
source_docs: ../docs
|
|
7
|
+
constraints:
|
|
8
|
+
max_lines_per_file: 400
|
|
9
|
+
ai_first_readability: true
|
|
10
|
+
compact_rules: true
|
|
11
|
+
files:
|
|
12
|
+
- path: fast-path.yaml
|
|
13
|
+
purpose: minimum_rules_to_start_any_task
|
|
14
|
+
- path: router.yaml
|
|
15
|
+
purpose: choose_minimum_files_to_read_by_task
|
|
16
|
+
- path: modes.yaml
|
|
17
|
+
purpose: choose_fast_balanced_or_strict_behavior
|
|
18
|
+
- path: execution-rules.yaml
|
|
19
|
+
purpose: execution_flow_and_core_behavior
|
|
20
|
+
- path: risk-levels.yaml
|
|
21
|
+
purpose: risk_classification_and_confirmation
|
|
22
|
+
- path: mapping-checklists.yaml
|
|
23
|
+
purpose: pre_change_maps_by_risk
|
|
24
|
+
- path: validation-checklist.yaml
|
|
25
|
+
purpose: validation_and_final_delivery
|
|
26
|
+
- path: context-rules.yaml
|
|
27
|
+
purpose: context_window_file_size_memory
|
|
28
|
+
- path: context-compiler.yaml
|
|
29
|
+
purpose: compile_minimum_context_package_and_canonical_state
|
|
30
|
+
- path: formatting-rules.yaml
|
|
31
|
+
purpose: ai_readable_file_format
|
|
32
|
+
- path: prompt-economy.yaml
|
|
33
|
+
purpose: improve_prompts_without_token_bloat
|
|
34
|
+
- path: spec-driven.yaml
|
|
35
|
+
purpose: use_light_or_full_specs_only_when_they_reduce_risk
|
|
File without changes
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
id: context_compiler
|
|
2
|
+
type: operational_rules
|
|
3
|
+
version: 0.1
|
|
4
|
+
purpose: build_minimum_context_package_before_model_reasoning
|
|
5
|
+
principle: conversation_is_interface_not_source_of_truth
|
|
6
|
+
canonical_state:
|
|
7
|
+
read_first:
|
|
8
|
+
- AGENTS.md
|
|
9
|
+
- INDEX.yaml
|
|
10
|
+
- config.yaml
|
|
11
|
+
- protocol/fast-path.yaml
|
|
12
|
+
- protocol/router.yaml
|
|
13
|
+
active_truth:
|
|
14
|
+
- current_user_request
|
|
15
|
+
- installed_protocol_block
|
|
16
|
+
- current_project_index
|
|
17
|
+
- current_config
|
|
18
|
+
- current_files_verified_this_turn
|
|
19
|
+
historical_only:
|
|
20
|
+
- old_chat_messages
|
|
21
|
+
- generated_reports
|
|
22
|
+
- archived_results
|
|
23
|
+
- revoked_or_replaced_decisions
|
|
24
|
+
context_build:
|
|
25
|
+
input:
|
|
26
|
+
- user_request
|
|
27
|
+
- route_from_router
|
|
28
|
+
- risk_level
|
|
29
|
+
- candidate_files_or_areas
|
|
30
|
+
- recent_validated_state
|
|
31
|
+
output:
|
|
32
|
+
- objective
|
|
33
|
+
- constraints
|
|
34
|
+
- relevant_rules
|
|
35
|
+
- candidate_files
|
|
36
|
+
- validation_plan
|
|
37
|
+
- excluded_context
|
|
38
|
+
selection_policy:
|
|
39
|
+
include:
|
|
40
|
+
- files_required_by_route
|
|
41
|
+
- snippets_matching_task_terms
|
|
42
|
+
- current_decisions_touching_candidate_area
|
|
43
|
+
- framework_configs_when_task_touches_framework
|
|
44
|
+
exclude:
|
|
45
|
+
- unrelated_docs
|
|
46
|
+
- old_generated_reports
|
|
47
|
+
- full_logs_without_error_focus
|
|
48
|
+
- revoked_decisions_unless_comparing_history
|
|
49
|
+
- entire_large_files_when_snippet_is_enough
|
|
50
|
+
memory_layers:
|
|
51
|
+
active:
|
|
52
|
+
definition: required_to_complete_current_task
|
|
53
|
+
token_policy: keep_in_context
|
|
54
|
+
archived:
|
|
55
|
+
definition: useful_only_if_evidence_matches_task
|
|
56
|
+
token_policy: retrieve_only_on_need
|
|
57
|
+
revoked:
|
|
58
|
+
definition: no_longer_valid_decision
|
|
59
|
+
token_policy: never_treat_as_current_truth
|
|
60
|
+
decision_rules:
|
|
61
|
+
- id: CTX_001
|
|
62
|
+
when: decision_has_status_revoked_or_replaced
|
|
63
|
+
do:
|
|
64
|
+
- use_only_to_explain_history
|
|
65
|
+
- prefer_replacement_decision
|
|
66
|
+
avoid:
|
|
67
|
+
- treating_as_current_instruction
|
|
68
|
+
- id: CTX_002
|
|
69
|
+
when: context_is_large
|
|
70
|
+
do:
|
|
71
|
+
- search_before_reading
|
|
72
|
+
- read_snippets_before_full_files
|
|
73
|
+
- stop_when_validation_plan_is_clear
|
|
74
|
+
- id: CTX_003
|
|
75
|
+
when: task_crosses_multiple_domains
|
|
76
|
+
do:
|
|
77
|
+
- build_context_by_domain
|
|
78
|
+
- include_only_domain_interfaces
|
|
79
|
+
- avoid_loading_all_domains
|
|
80
|
+
- id: CTX_004
|
|
81
|
+
when: context_gap_blocks_safe_execution
|
|
82
|
+
do:
|
|
83
|
+
- ask_one_short_question_or_read_next_mapped_file
|
|
84
|
+
retrieval_tiers:
|
|
85
|
+
mvp:
|
|
86
|
+
use:
|
|
87
|
+
- INDEX.yaml
|
|
88
|
+
- router.yaml
|
|
89
|
+
- targeted_search
|
|
90
|
+
- file_snippets
|
|
91
|
+
- handoff_summary
|
|
92
|
+
advanced:
|
|
93
|
+
use_when:
|
|
94
|
+
- thousands_of_files
|
|
95
|
+
- repeated_cross_session_work
|
|
96
|
+
- semantic_search_needed
|
|
97
|
+
options:
|
|
98
|
+
- decision_log
|
|
99
|
+
- lightweight_knowledge_graph
|
|
100
|
+
- semantic_cache
|
|
101
|
+
- vector_search
|
|
102
|
+
avoid_initially:
|
|
103
|
+
- mandatory_vector_database_for_small_projects
|
|
104
|
+
- sending_raw_project_state_to_model
|
|
105
|
+
- building_global_graph_before_real_need
|
|
106
|
+
delivery:
|
|
107
|
+
include_when_relevant:
|
|
108
|
+
- context_used
|
|
109
|
+
- context_excluded
|
|
110
|
+
- reason_for_not_reading_more
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
id: context_rules
|
|
2
|
+
type: operational_rules
|
|
3
|
+
version: 0.1
|
|
4
|
+
context_policy:
|
|
5
|
+
use: minimum_sufficient_context
|
|
6
|
+
prefer:
|
|
7
|
+
- targeted_search
|
|
8
|
+
- relevant_snippets
|
|
9
|
+
- current_state_over_old_history
|
|
10
|
+
- context_compiler_before_large_reads
|
|
11
|
+
avoid:
|
|
12
|
+
- reading_large_files_without_reason
|
|
13
|
+
- repeating_long_rules_in_chat
|
|
14
|
+
- mixing_old_and_current_docs
|
|
15
|
+
- treating_conversation_as_source_of_truth
|
|
16
|
+
file_size:
|
|
17
|
+
max_lines: 400
|
|
18
|
+
when_near_limit:
|
|
19
|
+
- split_by_subject
|
|
20
|
+
- keep_main_file_short
|
|
21
|
+
- update_index
|
|
22
|
+
memory:
|
|
23
|
+
record:
|
|
24
|
+
- stable_decision
|
|
25
|
+
- recurring_rule
|
|
26
|
+
- known_problem
|
|
27
|
+
- resume_checkpoint
|
|
28
|
+
- important_validation
|
|
29
|
+
avoid_recording:
|
|
30
|
+
- long_logs
|
|
31
|
+
- temporary_details
|
|
32
|
+
- unevidenced_conclusions
|
|
33
|
+
handoff_summary:
|
|
34
|
+
use_when: new_conversation_needed
|
|
35
|
+
fields:
|
|
36
|
+
- objective
|
|
37
|
+
- last_cut
|
|
38
|
+
- relevant_files_or_areas
|
|
39
|
+
- validations_done
|
|
40
|
+
- pending_items
|
|
41
|
+
- next_step
|
|
42
|
+
context_compiler:
|
|
43
|
+
source: context-compiler.yaml
|
|
44
|
+
use_when:
|
|
45
|
+
- risk_level_2_or_3
|
|
46
|
+
- large_project
|
|
47
|
+
- long_session
|
|
48
|
+
- conflicting_history
|
|
49
|
+
- task_crosses_domains
|
|
50
|
+
existing_project_files:
|
|
51
|
+
preserve:
|
|
52
|
+
- README.md
|
|
53
|
+
- docs/
|
|
54
|
+
- .cursorrules
|
|
55
|
+
- CLAUDE.md
|
|
56
|
+
- .github/copilot-instructions.md
|
|
57
|
+
- package_docs
|
|
58
|
+
- framework_configs
|
|
59
|
+
behavior:
|
|
60
|
+
- do_not_overwrite_user_docs_without_request
|
|
61
|
+
- read_project_docs_only_when_route_requires_context
|
|
62
|
+
- treat_generated_or_old_docs_as_untrusted_until_verified
|
|
63
|
+
- keep_protocol_rules_in_AGENTS_and_protocol_folder
|
|
64
|
+
- use_framework_configs_as_technical_source_when_task_touches_framework
|
|
65
|
+
- do_not_duplicate_protocol_rules_across_ide_files
|
|
66
|
+
conflict_order:
|
|
67
|
+
- current_user_request
|
|
68
|
+
- AGENTS_protocol_block
|
|
69
|
+
- ide_framework_or_project_specific_rules
|
|
70
|
+
- project_specific_docs
|
|
71
|
+
- old_generated_reports
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
id: execution_rules
|
|
2
|
+
type: operational_rules
|
|
3
|
+
version: 0.1
|
|
4
|
+
rules:
|
|
5
|
+
- id: EXEC_001
|
|
6
|
+
when: any_task
|
|
7
|
+
do:
|
|
8
|
+
- understand_goal
|
|
9
|
+
- classify_risk
|
|
10
|
+
- fetch_minimum_sufficient_context
|
|
11
|
+
- map_when_needed
|
|
12
|
+
- improve_prompt_proportional_to_risk_and_token_need
|
|
13
|
+
- execute_smallest_safe_change
|
|
14
|
+
- validate
|
|
15
|
+
- prepare_test_list_when_break_risk_exists
|
|
16
|
+
- deliver_with_evidence
|
|
17
|
+
- id: EXEC_002
|
|
18
|
+
when:
|
|
19
|
+
any:
|
|
20
|
+
- ambiguity
|
|
21
|
+
- risk
|
|
22
|
+
- multiple_interpretations
|
|
23
|
+
- user_requested_interpretation
|
|
24
|
+
do:
|
|
25
|
+
- show_technical_interpretation_before_action
|
|
26
|
+
- show_original_and_improved_prompt
|
|
27
|
+
- id: EXEC_003
|
|
28
|
+
when:
|
|
29
|
+
all:
|
|
30
|
+
- simple_task
|
|
31
|
+
- low_risk
|
|
32
|
+
do:
|
|
33
|
+
- solve_directly
|
|
34
|
+
avoid:
|
|
35
|
+
- heavy_plan
|
|
36
|
+
- unnecessary_confirmation
|
|
37
|
+
- id: EXEC_004
|
|
38
|
+
when:
|
|
39
|
+
any:
|
|
40
|
+
- multi_step_feature
|
|
41
|
+
- cross_file_change
|
|
42
|
+
- level_2_large
|
|
43
|
+
- level_3
|
|
44
|
+
do:
|
|
45
|
+
- create_light_or_full_spec_before_implementation
|
|
46
|
+
avoid:
|
|
47
|
+
- long_spec_for_simple_task
|
|
48
|
+
- spec_that_repeats_known_context
|
|
49
|
+
- id: EXEC_005
|
|
50
|
+
when: final_delivery
|
|
51
|
+
do:
|
|
52
|
+
- show_prompt_original
|
|
53
|
+
- show_prompt_melhorado_da_ia
|
|
54
|
+
- explain_what_was_done_in_plain_language
|
|
55
|
+
- list_validation_done_and_not_done
|
|
56
|
+
- list_manual_tests_when_break_risk_exists
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
id: fast_path
|
|
2
|
+
type: agent_entrypoint
|
|
3
|
+
version: 0.1
|
|
4
|
+
purpose: minimum_rules_to_start_any_task
|
|
5
|
+
read_next:
|
|
6
|
+
- router.yaml
|
|
7
|
+
- modes.yaml
|
|
8
|
+
core_rules:
|
|
9
|
+
- classify_risk_before_action
|
|
10
|
+
- use_minimum_sufficient_context
|
|
11
|
+
- read_only_files_required_by_router
|
|
12
|
+
- do_not_edit_unmapped_file
|
|
13
|
+
- raise_level_when_risk_appears
|
|
14
|
+
- confirm_before_level_3_sensitive_action
|
|
15
|
+
- deliver_changed_validated_not_validated_residual_risk
|
|
16
|
+
- use_balanced_mode_by_default
|
|
17
|
+
- show_original_and_improved_prompt_in_delivery
|
|
18
|
+
- improve_prompt_proportional_to_tokens_and_risk
|
|
19
|
+
- include_test_list_when_break_risk_exists
|
|
20
|
+
- explain_in_plain_language_for_non_experts
|
|
21
|
+
- use_context_compiler_when_context_or_history_is_large
|
|
22
|
+
risk_short:
|
|
23
|
+
level_0: answer_only
|
|
24
|
+
level_1: small_clear_reversible_isolated_change
|
|
25
|
+
level_2: user_flow_ambiguity_multiple_files_or_regression_risk
|
|
26
|
+
level_3: data_security_auth_database_deploy_production_secret_or_destructive
|
|
27
|
+
file_policy:
|
|
28
|
+
max_lines: 400
|
|
29
|
+
split_when_near_limit: true
|
|
30
|
+
prefer_snippets_over_full_files: true
|
|
31
|
+
stop_reading_when:
|
|
32
|
+
- enough_context_to_act_safely
|
|
33
|
+
- validation_plan_is_clear
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
id: formatting_rules
|
|
2
|
+
type: ai_readability_rules
|
|
3
|
+
version: 0.1
|
|
4
|
+
priority:
|
|
5
|
+
first: ai_readability
|
|
6
|
+
second: human_readability
|
|
7
|
+
principles:
|
|
8
|
+
- one_main_subject_per_file
|
|
9
|
+
- stable_keys
|
|
10
|
+
- direct_names
|
|
11
|
+
- short_lists
|
|
12
|
+
- plain_language_for_final_delivery
|
|
13
|
+
- technical_terms_explained_when_needed
|
|
14
|
+
- rules_before_examples
|
|
15
|
+
- separate_docs_from_protocol
|
|
16
|
+
- separate_criteria_templates_examples
|
|
17
|
+
- no_decorative_text
|
|
18
|
+
final_delivery:
|
|
19
|
+
default: micro_when_low_risk
|
|
20
|
+
compact_labels:
|
|
21
|
+
prompt_original: PO
|
|
22
|
+
prompt_melhorado_da_ia: PM
|
|
23
|
+
low_risk_summary: OK
|
|
24
|
+
what_was_done: Feito
|
|
25
|
+
validation: Validado
|
|
26
|
+
what_to_test_when_needed: Testar
|
|
27
|
+
limits_and_residual_risk: Risco
|
|
28
|
+
micro_format:
|
|
29
|
+
use_when:
|
|
30
|
+
- level_0
|
|
31
|
+
- level_1
|
|
32
|
+
lines:
|
|
33
|
+
- PO
|
|
34
|
+
- PM
|
|
35
|
+
- OK
|
|
36
|
+
ok_block:
|
|
37
|
+
- Feito
|
|
38
|
+
- Validado
|
|
39
|
+
- Risco
|
|
40
|
+
avoid:
|
|
41
|
+
- semicolon_only_ok_line
|
|
42
|
+
- one_line_micro_response
|
|
43
|
+
required_sections:
|
|
44
|
+
- prompt_original
|
|
45
|
+
- prompt_melhorado_da_ia
|
|
46
|
+
- what_was_done
|
|
47
|
+
- validation
|
|
48
|
+
- limits_and_residual_risk
|
|
49
|
+
conditional_sections:
|
|
50
|
+
- what_to_test_when_needed
|
|
51
|
+
clarity:
|
|
52
|
+
- use_simple_sentences
|
|
53
|
+
- explain_impact_for_user
|
|
54
|
+
- avoid_internal_jargon_without_context
|
|
55
|
+
- keep_each_section_to_one_line_when_possible
|
|
56
|
+
- keep_micro_format_with_readable_line_breaks
|
|
57
|
+
yaml_style:
|
|
58
|
+
prefer:
|
|
59
|
+
- ids
|
|
60
|
+
- type
|
|
61
|
+
- when
|
|
62
|
+
- do
|
|
63
|
+
- avoid
|
|
64
|
+
- deliver
|
|
65
|
+
- validation
|
|
66
|
+
avoid:
|
|
67
|
+
- long_paragraphs
|
|
68
|
+
- hidden_criteria
|
|
69
|
+
- synonyms_for_same_operational_concept
|
|
70
|
+
- oversized_files
|
|
71
|
+
maintenance:
|
|
72
|
+
max_lines_per_file: 400
|
|
73
|
+
if_near_limit:
|
|
74
|
+
- split_by_theme
|
|
75
|
+
- update_readme
|