aidp 0.40.0 → 0.41.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.
- checksums.yaml +4 -4
- data/lib/aidp/execute/work_loop_runner.rb +64 -190
- data/lib/aidp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3f3d8cc88b8d264095f965487244c597be15336e889a57babebf8bc6da70cb17
|
|
4
|
+
data.tar.gz: c1cb36afa4ae243874087152715829f72f72a8a530d8168c872cbe36367a7659
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d8f4bd6b9900a418406f72e34c52daecca793284f137ea28227503d723495cf9c7a3f03910474bce6d460c37f51773c16e96a012612680342791b41e0cbd076f
|
|
7
|
+
data.tar.gz: b797ddd64998481040f02a10a830fab2f7f739fd83e0d7d69b97cbc3a77816e3d1781a97910d57cebcabf2f6fe76c214a82650fec575f8a412c9a831e68e6602
|
|
@@ -11,6 +11,7 @@ require_relative "agent_signal_parser"
|
|
|
11
11
|
require_relative "steps"
|
|
12
12
|
require_relative "../harness/test_runner"
|
|
13
13
|
require_relative "../errors"
|
|
14
|
+
require_relative "../prompts/prompt_template_manager"
|
|
14
15
|
require_relative "../style_guide/selector"
|
|
15
16
|
require_relative "../security"
|
|
16
17
|
|
|
@@ -44,7 +45,7 @@ module Aidp
|
|
|
44
45
|
# Expose state for testability
|
|
45
46
|
attr_accessor :iteration_count, :step_name, :options, :persistent_tasklist
|
|
46
47
|
attr_reader :project_dir, :current_state, :state_history, :test_runner, :prompt_manager, :checkpoint
|
|
47
|
-
attr_writer :guard_policy, :prompt_manager, :style_guide_selector
|
|
48
|
+
attr_writer :guard_policy, :prompt_manager, :prompt_template_manager, :style_guide_selector
|
|
48
49
|
|
|
49
50
|
MAX_ITERATIONS = 50 # Safety limit
|
|
50
51
|
CHECKPOINT_INTERVAL = 5 # Record checkpoint every N iterations
|
|
@@ -87,6 +88,7 @@ module Aidp
|
|
|
87
88
|
|
|
88
89
|
# FIX for issue #391: Initialize prompt evaluator for iteration threshold assessment
|
|
89
90
|
@prompt_evaluator = options[:prompt_evaluator] || PromptEvaluator.new(config)
|
|
91
|
+
@prompt_template_manager = options[:prompt_template_manager] || Prompts::PromptTemplateManager.new(project_dir: project_dir)
|
|
90
92
|
|
|
91
93
|
# Initialize security adapter for Rule of Two enforcement
|
|
92
94
|
@security_adapter = options[:security_adapter] || Aidp::Security::WorkLoopAdapter.new(project_dir: project_dir)
|
|
@@ -1039,71 +1041,20 @@ module Aidp
|
|
|
1039
1041
|
end
|
|
1040
1042
|
|
|
1041
1043
|
def build_initial_prompt_content(template:, prd:, style_guide:, user_input:, step_name:, deterministic_outputs:, previous_agent_summary:, task_description:, additional_context:)
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
parts << "4. After you finish, tests and linters will run automatically"
|
|
1056
|
-
parts << "5. If tests/linters fail, you'll see the errors in the next iteration"
|
|
1057
|
-
parts << ""
|
|
1058
|
-
parts << "## Completion Criteria"
|
|
1059
|
-
parts << "Mark this step COMPLETE by adding this line to `.aidp/PROMPT.md`:"
|
|
1060
|
-
parts << "```"
|
|
1061
|
-
parts << "STATUS: COMPLETE"
|
|
1062
|
-
parts << "```"
|
|
1063
|
-
parts << ""
|
|
1064
|
-
|
|
1065
|
-
if user_input && !user_input.empty?
|
|
1066
|
-
parts << "## User Input"
|
|
1067
|
-
parts << user_input
|
|
1068
|
-
parts << ""
|
|
1069
|
-
end
|
|
1070
|
-
|
|
1071
|
-
if previous_agent_summary && !previous_agent_summary.empty?
|
|
1072
|
-
parts << "## Previous Agent Summary"
|
|
1073
|
-
parts << previous_agent_summary
|
|
1074
|
-
parts << ""
|
|
1075
|
-
end
|
|
1076
|
-
|
|
1077
|
-
unless deterministic_outputs.empty?
|
|
1078
|
-
parts << "## Recent Deterministic Outputs"
|
|
1079
|
-
deterministic_outputs.each do |entry|
|
|
1080
|
-
parts << "- #{entry[:name]} (status: #{entry[:status]})"
|
|
1081
|
-
parts << " Output: #{entry[:output_path] || "n/a"}"
|
|
1082
|
-
end
|
|
1083
|
-
parts << ""
|
|
1084
|
-
end
|
|
1085
|
-
|
|
1086
|
-
if style_guide
|
|
1087
|
-
parts << "## LLM Style Guide"
|
|
1088
|
-
parts << style_guide
|
|
1089
|
-
parts << ""
|
|
1090
|
-
end
|
|
1091
|
-
|
|
1092
|
-
if prd
|
|
1093
|
-
parts << "## Product Requirements (PRD)"
|
|
1094
|
-
parts << prd
|
|
1095
|
-
parts << ""
|
|
1096
|
-
end
|
|
1097
|
-
|
|
1098
|
-
parts << "## Task Template"
|
|
1099
|
-
parts << interpolate_task_template(
|
|
1100
|
-
template,
|
|
1101
|
-
task_description: task_description,
|
|
1102
|
-
additional_context: additional_context
|
|
1044
|
+
@prompt_template_manager.render(
|
|
1045
|
+
"work_loop/initial_prompt",
|
|
1046
|
+
STEP_NAME: step_name,
|
|
1047
|
+
USER_INPUT_SECTION: optional_section("## User Input", user_input),
|
|
1048
|
+
PREVIOUS_AGENT_SUMMARY_SECTION: optional_section("## Previous Agent Summary", previous_agent_summary),
|
|
1049
|
+
DETERMINISTIC_OUTPUTS_SECTION: deterministic_outputs_section(deterministic_outputs),
|
|
1050
|
+
STYLE_GUIDE_SECTION: optional_section("## LLM Style Guide", style_guide),
|
|
1051
|
+
PRD_SECTION: optional_section("## Product Requirements (PRD)", prd),
|
|
1052
|
+
TASK_TEMPLATE: interpolate_task_template(
|
|
1053
|
+
template,
|
|
1054
|
+
task_description: task_description,
|
|
1055
|
+
additional_context: additional_context
|
|
1056
|
+
)
|
|
1103
1057
|
)
|
|
1104
|
-
parts << ""
|
|
1105
|
-
|
|
1106
|
-
parts.join("\n")
|
|
1107
1058
|
end
|
|
1108
1059
|
|
|
1109
1060
|
def send_to_agent(selected_provider: nil, selected_model: nil)
|
|
@@ -1325,88 +1276,14 @@ module Aidp
|
|
|
1325
1276
|
|
|
1326
1277
|
# FIX for issue #391: Enhanced work loop header with upfront task filing requirements
|
|
1327
1278
|
def build_work_loop_header(step_name, iteration)
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
parts << "4. Run tests to verify your changes work correctly"
|
|
1337
|
-
parts << "5. Update task status as you complete items"
|
|
1338
|
-
parts << "6. When ALL tasks are complete and tests pass, mark the step COMPLETE"
|
|
1339
|
-
parts << ""
|
|
1340
|
-
parts << "## Important Notes"
|
|
1341
|
-
parts << "- You have full file system access - create and edit files as needed"
|
|
1342
|
-
parts << "- The working directory is: #{@project_dir}"
|
|
1343
|
-
parts << "- After you finish, tests and linters will run automatically"
|
|
1344
|
-
parts << "- If tests/linters fail, you'll see the errors in the next iteration and can fix them"
|
|
1345
|
-
parts << ""
|
|
1346
|
-
parts << "## ⚠️ Code Changes Required"
|
|
1347
|
-
parts << "**IMPORTANT**: This implementation requires actual code changes."
|
|
1348
|
-
parts << "- Documentation-only changes will NOT be accepted as complete"
|
|
1349
|
-
parts << "- Configuration-only changes will NOT be accepted as complete"
|
|
1350
|
-
parts << "- You must modify/create code files (.rb, .py, .js, etc.) to implement the feature/fix"
|
|
1351
|
-
parts << "- Tests should accompany code changes"
|
|
1352
|
-
parts << ""
|
|
1353
|
-
|
|
1354
|
-
if @config.task_completion_required?
|
|
1355
|
-
parts << "## Task Filing (REQUIRED - DO THIS FIRST)"
|
|
1356
|
-
parts << "**CRITICAL**: This work loop requires task tracking. You MUST file tasks before implementation."
|
|
1357
|
-
parts << ""
|
|
1358
|
-
parts << "### Step 1: File Tasks Immediately"
|
|
1359
|
-
parts << "In your FIRST iteration, analyze the requirements and file tasks for ALL work:"
|
|
1360
|
-
parts << ""
|
|
1361
|
-
parts << "```text"
|
|
1362
|
-
parts << "File task: \"Implement [feature/fix description]\" priority: high tags: implementation"
|
|
1363
|
-
parts << "File task: \"Add unit tests for [feature]\" priority: high tags: testing"
|
|
1364
|
-
parts << "File task: \"Add integration tests if needed\" priority: medium tags: testing"
|
|
1365
|
-
parts << "```"
|
|
1366
|
-
parts << ""
|
|
1367
|
-
parts << "### Step 2: Work Through Tasks"
|
|
1368
|
-
parts << "- Pick the highest priority pending task"
|
|
1369
|
-
parts << "- Implement it completely"
|
|
1370
|
-
parts << "- Mark it done: `Update task: task_id status: done`"
|
|
1371
|
-
parts << "- Repeat until all tasks are complete"
|
|
1372
|
-
parts << ""
|
|
1373
|
-
parts << "### Step 3: Complete the Work Loop"
|
|
1374
|
-
parts << "Only after ALL tasks are done:"
|
|
1375
|
-
parts << "- Verify tests pass"
|
|
1376
|
-
parts << "- Add STATUS: COMPLETE to `.aidp/PROMPT.md`"
|
|
1377
|
-
parts << ""
|
|
1378
|
-
parts << "### Task Rules"
|
|
1379
|
-
parts << "- **At least ONE task must be filed** - completion blocked without tasks"
|
|
1380
|
-
parts << "- **At least ONE task must be DONE** - completion blocked if all abandoned"
|
|
1381
|
-
parts << "- **Substantive work required** - doc-only changes rejected"
|
|
1382
|
-
parts << ""
|
|
1383
|
-
parts << "**Important**: Tasks exist due to careful planning. Do NOT abandon tasks due to"
|
|
1384
|
-
parts << "perceived complexity - these factors were considered during planning. Only abandon"
|
|
1385
|
-
parts << "when truly obsolete (requirements changed, duplicate, external blockers)."
|
|
1386
|
-
parts << ""
|
|
1387
|
-
parts << "### Task Filing Examples"
|
|
1388
|
-
parts << "- `File task: \"Implement user authentication\" priority: high tags: security,auth`"
|
|
1389
|
-
parts << "- `File task: \"Add tests for login flow\" priority: medium tags: testing`"
|
|
1390
|
-
parts << "- `File task: \"Update documentation\" priority: low tags: docs`"
|
|
1391
|
-
parts << ""
|
|
1392
|
-
parts << "### Task Status Update Examples"
|
|
1393
|
-
parts << "- `Update task: task_123_abc status: in_progress`"
|
|
1394
|
-
parts << "- `Update task: task_456_def status: done`"
|
|
1395
|
-
parts << "- `Update task: task_789_ghi status: abandoned reason: \"Requirements changed\"`"
|
|
1396
|
-
parts << ""
|
|
1397
|
-
end
|
|
1398
|
-
|
|
1399
|
-
parts << "## Completion Criteria"
|
|
1400
|
-
parts << "Mark this step COMPLETE by adding these lines to `.aidp/PROMPT.md`:"
|
|
1401
|
-
parts << "```"
|
|
1402
|
-
parts << "STATUS: COMPLETE"
|
|
1403
|
-
if @config.task_completion_required?
|
|
1404
|
-
parts << ""
|
|
1405
|
-
parts << "Update task: task_xxx_yyy status: done # Mark ALL your tasks as done"
|
|
1406
|
-
end
|
|
1407
|
-
parts << "```"
|
|
1408
|
-
parts << ""
|
|
1409
|
-
parts.join("\n")
|
|
1279
|
+
@prompt_template_manager.render(
|
|
1280
|
+
"work_loop/header",
|
|
1281
|
+
STEP_NAME: step_name,
|
|
1282
|
+
ITERATION: iteration,
|
|
1283
|
+
PROJECT_DIR: @project_dir,
|
|
1284
|
+
TASK_FILING_SECTION: task_filing_section,
|
|
1285
|
+
TASK_COMPLETION_LINE: task_completion_line
|
|
1286
|
+
)
|
|
1410
1287
|
end
|
|
1411
1288
|
|
|
1412
1289
|
def iteration_context_metadata
|
|
@@ -2131,51 +2008,48 @@ module Aidp
|
|
|
2131
2008
|
|
|
2132
2009
|
# Append task completion requirement to PROMPT.md
|
|
2133
2010
|
def append_task_requirement_to_prompt(message)
|
|
2134
|
-
task_requirement = []
|
|
2135
|
-
|
|
2136
|
-
task_requirement << "## Task Completion Requirement"
|
|
2137
|
-
task_requirement << ""
|
|
2138
|
-
task_requirement << "**CRITICAL**: #{message}"
|
|
2139
|
-
task_requirement << ""
|
|
2140
|
-
task_requirement << "### How to Complete Tasks"
|
|
2141
|
-
task_requirement << ""
|
|
2142
|
-
task_requirement << "Update task status using these signals in your output:"
|
|
2143
|
-
task_requirement << ""
|
|
2144
|
-
task_requirement << "**Creating tasks:**"
|
|
2145
|
-
task_requirement << "```"
|
|
2146
|
-
task_requirement << 'File task: "Implement feature X" priority: high tags: feature,backend'
|
|
2147
|
-
task_requirement << 'File task: "Add tests for feature X" priority: medium tags: testing'
|
|
2148
|
-
task_requirement << "```"
|
|
2149
|
-
task_requirement << ""
|
|
2150
|
-
task_requirement << "**Updating task status:**"
|
|
2151
|
-
task_requirement << "```"
|
|
2152
|
-
task_requirement << "Update task: task_123_abc status: in_progress"
|
|
2153
|
-
task_requirement << "Update task: task_123_abc status: done"
|
|
2154
|
-
task_requirement << 'Update task: task_456_def status: abandoned reason: "Requirements changed"'
|
|
2155
|
-
task_requirement << "```"
|
|
2156
|
-
task_requirement << ""
|
|
2157
|
-
task_requirement << "**Task states:**"
|
|
2158
|
-
task_requirement << "- ⏳ **pending** - Not started yet"
|
|
2159
|
-
task_requirement << "- 🚧 **in_progress** - Currently working on it"
|
|
2160
|
-
task_requirement << "- ✅ **done** - Completed successfully"
|
|
2161
|
-
task_requirement << "- ❌ **abandoned** - Not doing this (requires reason)"
|
|
2162
|
-
task_requirement << ""
|
|
2163
|
-
task_requirement << "**Completion requirement:**"
|
|
2164
|
-
task_requirement << "All tasks for this session must be marked as DONE or ABANDONED (with reason) before the work loop can complete."
|
|
2165
|
-
task_requirement << ""
|
|
2166
|
-
task_requirement << "**Action Required**: Review the current task list and update status for all tasks."
|
|
2167
|
-
task_requirement << ""
|
|
2168
|
-
|
|
2169
2011
|
# Append to PROMPT.md - ensure directory exists
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2012
|
+
current_prompt = @prompt_manager.read || ""
|
|
2013
|
+
task_requirement = @prompt_template_manager.render(
|
|
2014
|
+
"work_loop/task_completion_requirement",
|
|
2015
|
+
MESSAGE: message
|
|
2016
|
+
)
|
|
2017
|
+
updated_prompt = current_prompt + "\n\n---\n\n" + task_requirement
|
|
2018
|
+
@prompt_manager.write(updated_prompt, step_name: @step_name)
|
|
2019
|
+
display_message(" [TASK_REQ] Added task completion requirement to PROMPT.md", type: :warning)
|
|
2020
|
+
rescue => e
|
|
2021
|
+
Aidp.log_warn("work_loop", "Failed to append task requirement to PROMPT.md", error: e.message)
|
|
2022
|
+
display_message(" [TASK_REQ] Warning: Could not update PROMPT.md: #{e.message}", type: :warning)
|
|
2023
|
+
end
|
|
2024
|
+
|
|
2025
|
+
def optional_section(title, body)
|
|
2026
|
+
return "" if body.nil? || body.empty?
|
|
2027
|
+
|
|
2028
|
+
[title, body, ""].join("\n")
|
|
2029
|
+
end
|
|
2030
|
+
|
|
2031
|
+
def deterministic_outputs_section(deterministic_outputs)
|
|
2032
|
+
return "" if deterministic_outputs.empty?
|
|
2033
|
+
|
|
2034
|
+
lines = ["## Recent Deterministic Outputs"]
|
|
2035
|
+
deterministic_outputs.each do |entry|
|
|
2036
|
+
lines << "- #{entry[:name]} (status: #{entry[:status]})"
|
|
2037
|
+
lines << " Output: #{entry[:output_path] || "n/a"}"
|
|
2178
2038
|
end
|
|
2039
|
+
lines << ""
|
|
2040
|
+
lines.join("\n")
|
|
2041
|
+
end
|
|
2042
|
+
|
|
2043
|
+
def task_filing_section
|
|
2044
|
+
return "" unless @config.task_completion_required?
|
|
2045
|
+
|
|
2046
|
+
@prompt_template_manager.render("work_loop/task_filing")
|
|
2047
|
+
end
|
|
2048
|
+
|
|
2049
|
+
def task_completion_line
|
|
2050
|
+
return "" unless @config.task_completion_required?
|
|
2051
|
+
|
|
2052
|
+
"Update task: task_xxx_yyy status: done # Mark ALL your tasks as done\n"
|
|
2179
2053
|
end
|
|
2180
2054
|
|
|
2181
2055
|
# Validate changes against guard policy
|
data/lib/aidp/version.rb
CHANGED