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.
Files changed (39) hide show
  1. package/AGENTS.md +90 -0
  2. package/LICENSE +21 -0
  3. package/README.md +159 -0
  4. package/dist/minimal/.aiignore +8 -0
  5. package/dist/minimal/AGENTS.md +61 -0
  6. package/dist/minimal/README.md +60 -0
  7. package/dist/minimal/protocol/README.yaml +35 -0
  8. package/dist/minimal/protocol/context-compiler.yaml +110 -0
  9. package/dist/minimal/protocol/context-rules.yaml +71 -0
  10. package/dist/minimal/protocol/execution-rules.yaml +56 -0
  11. package/dist/minimal/protocol/fast-path.yaml +33 -0
  12. package/dist/minimal/protocol/formatting-rules.yaml +75 -0
  13. package/dist/minimal/protocol/mapping-checklists.yaml +42 -0
  14. package/dist/minimal/protocol/modes.yaml +42 -0
  15. package/dist/minimal/protocol/prompt-economy.yaml +96 -0
  16. package/dist/minimal/protocol/risk-levels.yaml +87 -0
  17. package/dist/minimal/protocol/router.yaml +100 -0
  18. package/dist/minimal/protocol/spec-driven.yaml +53 -0
  19. package/dist/minimal/protocol/validation-checklist.yaml +59 -0
  20. package/install.ps1 +16 -0
  21. package/package.json +46 -0
  22. package/protocol/README.yaml +35 -0
  23. package/protocol/context-compiler.yaml +110 -0
  24. package/protocol/context-rules.yaml +71 -0
  25. package/protocol/execution-rules.yaml +56 -0
  26. package/protocol/fast-path.yaml +33 -0
  27. package/protocol/formatting-rules.yaml +75 -0
  28. package/protocol/mapping-checklists.yaml +42 -0
  29. package/protocol/modes.yaml +42 -0
  30. package/protocol/prompt-economy.yaml +96 -0
  31. package/protocol/risk-levels.yaml +87 -0
  32. package/protocol/router.yaml +100 -0
  33. package/protocol/spec-driven.yaml +53 -0
  34. package/protocol/validation-checklist.yaml +59 -0
  35. package/scripts/README.md +222 -0
  36. package/scripts/build_dist.py +191 -0
  37. package/scripts/install_protocol.py +28 -0
  38. package/scripts/npm_install_protocol.js +278 -0
  39. package/scripts/verify_install.py +92 -0
@@ -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
@@ -0,0 +1,42 @@
1
+ id: mapping_checklists
2
+ type: checklist
3
+ version: 0.1
4
+ minimal_map:
5
+ use_for:
6
+ - level_1
7
+ fields:
8
+ - objective
9
+ - affected_area
10
+ - candidate_files
11
+ - risk
12
+ - plan
13
+ - validation
14
+ impact_map:
15
+ use_for:
16
+ - level_2
17
+ fields:
18
+ - real_objective
19
+ - affected_flow
20
+ - candidate_files
21
+ - risks_and_side_effects
22
+ - out_of_scope
23
+ - change_plan
24
+ - rollback_mental
25
+ - expected_validation
26
+ critical_map:
27
+ use_for:
28
+ - level_3
29
+ fields:
30
+ - affected_data_or_environment
31
+ - permissions
32
+ - security_surface
33
+ - critical_risks
34
+ - safe_plan
35
+ - required_confirmation
36
+ - rollback_or_mitigation
37
+ rules:
38
+ - id: MAP_001
39
+ do_not_edit_file_unless: identified_as_candidate
40
+ - id: MAP_002
41
+ if_new_file_needed: update_map_before_editing
42
+
@@ -0,0 +1,42 @@
1
+ id: modes
2
+ type: operational_modes
3
+ version: 0.1
4
+ default: balanced
5
+ modes:
6
+ fast:
7
+ purpose: minimum_context_and_fast_execution
8
+ use_when:
9
+ - low_risk
10
+ - clear_task
11
+ - reversible_change
12
+ behavior:
13
+ - read_fast_path_and_route_only
14
+ - show_compact_original_and_improved_prompt
15
+ - validate_minimum_required
16
+ balanced:
17
+ purpose: default_safe_execution
18
+ use_when:
19
+ - normal_task
20
+ - moderate_risk
21
+ behavior:
22
+ - classify_risk
23
+ - use_router
24
+ - map_when_level_2_or_3
25
+ - use_light_spec_when_scope_is_unclear_or_multi_step
26
+ - validate_and_report_limits
27
+ - show_original_and_improved_prompt
28
+ strict:
29
+ purpose: maximum_safety_and_auditability
30
+ use_when:
31
+ - level_3
32
+ - unclear_high_impact_task
33
+ - production_or_sensitive_data
34
+ behavior:
35
+ - show_compact_interpretation
36
+ - require_critical_map
37
+ - use_full_spec_for_level_3_or_multi_module_changes
38
+ - ask_confirmation_before_sensitive_action
39
+ - report_validation_and_residual_risk
40
+ - show_original_and_improved_prompt
41
+ - provide_test_list_when_break_risk_exists
42
+ - prefer_more_validation_over_speed
@@ -0,0 +1,96 @@
1
+ id: prompt_economy
2
+ type: operational_rules
3
+ version: 0.1
4
+ purpose: improve_user_prompt_without_token_bloat
5
+ principle: always_improve_prompt_only_as_much_as_needed_for_safe_execution
6
+ rules:
7
+ - id: PROMPT_001
8
+ name: keep_improved_prompt_short
9
+ do:
10
+ - preserve_user_intent
11
+ - add_missing_technical_constraints_only_when_needed
12
+ - avoid_rewriting_into_long_spec
13
+ - id: PROMPT_002
14
+ name: proportional_prompt_expansion
15
+ by_level:
16
+ level_0: micro_prompt_comparison
17
+ level_1: micro_prompt_comparison
18
+ level_2: compact_objective_scope_validation
19
+ level_3: compact_critical_intent_risk_confirmation
20
+ - id: PROMPT_003
21
+ name: no_prompt_bloat
22
+ avoid:
23
+ - repeating_full_context
24
+ - adding_unrequested_features
25
+ - creating_long_checklists_for_simple_tasks
26
+ - copying_protocol_text_into_user_prompt
27
+ - id: PROMPT_004
28
+ name: economical_improved_prompt_shape
29
+ format:
30
+ - original_prompt
31
+ - objective
32
+ - scope
33
+ - risk_level
34
+ - validation
35
+ - confirmation_if_needed
36
+ - id: PROMPT_005
37
+ name: always_show_prompt_comparison
38
+ do:
39
+ - include_user_original_prompt
40
+ - include_ai_improved_prompt
41
+ - keep_comparison_to_minimum_viable_words
42
+ - preserve_user_language_when_possible
43
+ avoid:
44
+ - hiding_interpretation_from_user
45
+ - expanding_simple_requests_into_large_specs
46
+ limits:
47
+ level_0:
48
+ max_lines: 5
49
+ max_expansion_ratio: 1.5
50
+ max_tokens_est: 80
51
+ level_1:
52
+ max_lines: 5
53
+ max_expansion_ratio: 2.0
54
+ max_tokens_est: 110
55
+ level_2:
56
+ max_lines: 5
57
+ max_expansion_ratio: 4.0
58
+ max_tokens_est: 160
59
+ level_3:
60
+ max_lines: 7
61
+ max_expansion_ratio: 6.0
62
+ max_tokens_est: 260
63
+ delivery_rule:
64
+ default_format: micro_when_low_risk
65
+ micro_template:
66
+ - "PO: <original in one short line>"
67
+ - "PM: <improved in one short line>"
68
+ - "OK:"
69
+ - " Feito: <done>"
70
+ - " Validado: <evidence or not run>"
71
+ - " Risco: <residual risk or none>"
72
+ ultra_compact_template:
73
+ - "PO: <original in one short line>"
74
+ - "PM: <improved in one short line>"
75
+ - "Feito: <what changed or answer>"
76
+ - "Validado: <evidence or not run>"
77
+ - "Risco: <residual risk or none>"
78
+ always_show:
79
+ - prompt_original
80
+ - prompt_melhorado_da_ia
81
+ comparison:
82
+ - original_prompt_must_keep_user_words_when_reasonable
83
+ - improved_prompt_must_state_objective_scope_risk_validation
84
+ - improved_prompt_must_fit_risk_level_limits
85
+ token_policy:
86
+ - use_abbreviated_labels_po_pm_when_user_did_not_request_full_form
87
+ - level_0_and_1_use_micro_template
88
+ - level_2_use_compact_objective_scope_validation
89
+ - level_3_include_risk_confirmation_without_long_spec
90
+ - omit_tests_line_when_no_break_risk_exists
91
+ - omit_not_validated_line_when_every_relevant_validation_is_reported
92
+ readability_policy:
93
+ - micro_template_must_keep_line_breaks
94
+ - ok_block_order_is_done_validated_risk
95
+ - do_not_merge_po_pm_ok_into_one_line
96
+ - do_not_separate_done_validated_risk_only_with_semicolons
@@ -0,0 +1,87 @@
1
+ id: risk_levels
2
+ type: risk_matrix
3
+ version: 0.1
4
+ levels:
5
+ level_0:
6
+ name: simple_answer
7
+ requires_mapping: false
8
+ requires_confirmation: false
9
+ when:
10
+ all:
11
+ - no_file_change
12
+ - no_sensitive_action
13
+ do:
14
+ - answer_directly
15
+ level_1:
16
+ name: fast_path
17
+ requires_mapping: minimal
18
+ requires_confirmation: false
19
+ when:
20
+ all:
21
+ - clear_task
22
+ - small_change
23
+ - reversible
24
+ - isolated
25
+ - direct_validation
26
+ do:
27
+ - read_focused_context
28
+ - change_minimum_needed
29
+ - validate_simple
30
+ level_2:
31
+ name: impact_map
32
+ requires_mapping: true
33
+ requires_confirmation: false
34
+ when:
35
+ any:
36
+ - user_visible_impact
37
+ - ambiguity
38
+ - multiple_files
39
+ - regression_risk
40
+ - relevant_behavior_change
41
+ do:
42
+ - map_objective_area_files_risks_plan_validation
43
+ - execute_smallest_safe_change
44
+ - validate_main_flow
45
+ level_3:
46
+ name: critical_map
47
+ requires_mapping: critical
48
+ requires_confirmation: true
49
+ when:
50
+ any:
51
+ - real_data
52
+ - database
53
+ - authentication
54
+ - authorization
55
+ - security
56
+ - secrets
57
+ - deploy
58
+ - production
59
+ - critical_integration
60
+ - destructive_command
61
+ do:
62
+ - map_critical_risk
63
+ - ask_confirmation_before_sensitive_action
64
+ - validate_before_and_after
65
+ escalation:
66
+ rule: raise_level_when_new_risk_evidence_appears
67
+ never: lower_level_by_ignoring_known_risk
68
+ blocked_critical_scope:
69
+ principle: do_not_lower_original_risk_because_sensitive_action_is_blocked
70
+ when:
71
+ all:
72
+ - level_3_was_identified
73
+ - critical_action_cannot_be_executed
74
+ do:
75
+ - keep_original_task_marked_level_3
76
+ - mark_critical_action_as_blocked_or_pending
77
+ - split_safe_subtasks_when_useful
78
+ - classify_each_safe_subtask_by_its_own_scope
79
+ - read_only_context_needed_for_the_executable_subtask
80
+ - report_blocked_level_3_part_in_delivery
81
+ allow_lower_scope_only_when:
82
+ - critical_action_is_explicitly_removed_from_scope
83
+ - new_evidence_proves_critical_risk_does_not_apply
84
+ avoid:
85
+ - lowering_risk_to_save_tokens
86
+ - treating_blocked_action_as_completed
87
+ - hiding_residual_critical_risk