ai-execution-protocol 0.1.0 → 0.2.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.
@@ -10,6 +10,7 @@ const protocolFiles = [
10
10
  "README.yaml",
11
11
  "fast-path.yaml",
12
12
  "router.yaml",
13
+ "route-packs.yaml",
13
14
  "modes.yaml",
14
15
  "execution-rules.yaml",
15
16
  "risk-levels.yaml",
@@ -17,6 +18,7 @@ const protocolFiles = [
17
18
  "validation-checklist.yaml",
18
19
  "context-rules.yaml",
19
20
  "context-compiler.yaml",
21
+ "persistent-context.yaml",
20
22
  "formatting-rules.yaml",
21
23
  "prompt-economy.yaml",
22
24
  "spec-driven.yaml",
@@ -29,6 +31,50 @@ const aiignoreLines = [
29
31
  "scripts/__pycache__/",
30
32
  "*.pyc",
31
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
+ `;
32
78
  const requiredText = {
33
79
  "AGENTS.md": [
34
80
  "AI_PROTOCOL_BEGIN",
@@ -38,7 +84,14 @@ const requiredText = {
38
84
  "Nenhum arquivo deve passar de 400 linhas.",
39
85
  ],
40
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"],
41
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
+ ],
42
95
  "protocol/spec-driven.yaml": ["protocol_is_base_spec_is_tool", "do_not_create_spec_for_low_value_tasks"],
43
96
  };
44
97
 
@@ -77,13 +130,15 @@ editar, classifique risco, escolha rota e valide a entrega.
77
130
 
78
131
  1. \`protocol/fast-path.yaml\`
79
132
  2. \`protocol/router.yaml\`
80
- 3. Arquivo YAML especifico em \`protocol/\` conforme a rota.
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.
81
135
 
82
136
  ## Regras de execucao
83
137
 
84
138
  - Classifique o risco antes de agir.
85
139
  - Use o menor contexto suficiente.
86
140
  - Leia apenas os arquivos indicados por \`protocol/router.yaml\`.
141
+ - Use \`protocol/route-packs.yaml\` antes de abrir todos os arquivos da rota.
87
142
  - Quando houver contexto grande, historico longo ou risco de confusao, use
88
143
  \`protocol/context-compiler.yaml\` antes de abrir muitos arquivos.
89
144
  - Use \`protocol/spec-driven.yaml\` para feature, refatoracao grande ou tarefa
@@ -193,6 +248,17 @@ function installAiignore(target) {
193
248
  writeText(target, existing.join("\n").trim() + "\n");
194
249
  }
195
250
 
251
+ function writeIfMissing(file, text) {
252
+ if (fs.existsSync(file)) return;
253
+ writeText(file, text);
254
+ }
255
+
256
+ 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);
260
+ }
261
+
196
262
  function copyProtocol(target, force, backupRoot) {
197
263
  if (fs.existsSync(target) && !force) return;
198
264
  if (fs.existsSync(target)) {
@@ -218,6 +284,7 @@ function install(target, force, dryRun) {
218
284
  backup(path.join(targetRoot, ".aiignore"), backupRoot);
219
285
  installAgents(path.join(targetRoot, "AGENTS.md"));
220
286
  installAiignore(path.join(targetRoot, ".aiignore"));
287
+ installContextTemplates(targetRoot);
221
288
  copyProtocol(path.join(targetRoot, "protocol"), force, backupRoot);
222
289
  console.log(`installed protocol -> ${targetRoot}`);
223
290
  return verify(targetRoot);
@@ -226,7 +293,14 @@ function install(target, force, dryRun) {
226
293
  function verify(target) {
227
294
  const targetRoot = path.resolve(target);
228
295
  const errors = [];
229
- const requiredFiles = ["AGENTS.md", ".aiignore", ...protocolFiles.map((file) => `protocol/${file}`)];
296
+ const requiredFiles = [
297
+ "AGENTS.md",
298
+ ".aiignore",
299
+ "canonical-state.yaml",
300
+ "context-map.yaml",
301
+ "decisions/README.md",
302
+ ...protocolFiles.map((file) => `protocol/${file}`),
303
+ ];
230
304
  for (const item of requiredFiles) {
231
305
  const file = path.join(targetRoot, item);
232
306
  if (!fs.existsSync(file)) {
@@ -10,9 +10,13 @@ from pathlib import Path
10
10
  REQUIRED_FILES = [
11
11
  "AGENTS.md",
12
12
  ".aiignore",
13
+ "canonical-state.yaml",
14
+ "context-map.yaml",
15
+ "decisions/README.md",
13
16
  "protocol/README.yaml",
14
17
  "protocol/fast-path.yaml",
15
18
  "protocol/router.yaml",
19
+ "protocol/route-packs.yaml",
16
20
  "protocol/modes.yaml",
17
21
  "protocol/execution-rules.yaml",
18
22
  "protocol/risk-levels.yaml",
@@ -20,6 +24,7 @@ REQUIRED_FILES = [
20
24
  "protocol/validation-checklist.yaml",
21
25
  "protocol/context-rules.yaml",
22
26
  "protocol/context-compiler.yaml",
27
+ "protocol/persistent-context.yaml",
23
28
  "protocol/formatting-rules.yaml",
24
29
  "protocol/prompt-economy.yaml",
25
30
  "protocol/spec-driven.yaml",
@@ -41,11 +46,24 @@ REQUIRED_TEXT = {
41
46
  "dist/",
42
47
  "*.pyc",
43
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
+ ],
44
57
  "protocol/router.yaml": [
45
58
  "feature_or_spec",
46
59
  "spec-driven.yaml",
47
60
  "prompt_improvement",
48
61
  ],
62
+ "protocol/route-packs.yaml": [
63
+ "read_pack_first_expand_only_when_needed",
64
+ "simple_answer",
65
+ "context_optimization",
66
+ ],
49
67
  "protocol/spec-driven.yaml": [
50
68
  "protocol_is_base_spec_is_tool",
51
69
  "do_not_create_spec_for_low_value_tasks",