gobby 0.2.5__py3-none-any.whl → 0.2.7__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.
- gobby/__init__.py +1 -1
- gobby/adapters/__init__.py +2 -1
- gobby/adapters/claude_code.py +13 -4
- gobby/adapters/codex_impl/__init__.py +28 -0
- gobby/adapters/codex_impl/adapter.py +722 -0
- gobby/adapters/codex_impl/client.py +679 -0
- gobby/adapters/codex_impl/protocol.py +20 -0
- gobby/adapters/codex_impl/types.py +68 -0
- gobby/agents/definitions.py +11 -1
- gobby/agents/isolation.py +395 -0
- gobby/agents/runner.py +8 -0
- gobby/agents/sandbox.py +261 -0
- gobby/agents/spawn.py +42 -287
- gobby/agents/spawn_executor.py +385 -0
- gobby/agents/spawners/__init__.py +24 -0
- gobby/agents/spawners/command_builder.py +189 -0
- gobby/agents/spawners/embedded.py +21 -2
- gobby/agents/spawners/headless.py +21 -2
- gobby/agents/spawners/prompt_manager.py +125 -0
- gobby/cli/__init__.py +6 -0
- gobby/cli/clones.py +419 -0
- gobby/cli/conductor.py +266 -0
- gobby/cli/install.py +4 -4
- gobby/cli/installers/antigravity.py +3 -9
- gobby/cli/installers/claude.py +15 -9
- gobby/cli/installers/codex.py +2 -8
- gobby/cli/installers/gemini.py +8 -8
- gobby/cli/installers/shared.py +175 -13
- gobby/cli/sessions.py +1 -1
- gobby/cli/skills.py +858 -0
- gobby/cli/tasks/ai.py +0 -440
- gobby/cli/tasks/crud.py +44 -6
- gobby/cli/tasks/main.py +0 -4
- gobby/cli/tui.py +2 -2
- gobby/cli/utils.py +12 -5
- gobby/clones/__init__.py +13 -0
- gobby/clones/git.py +547 -0
- gobby/conductor/__init__.py +16 -0
- gobby/conductor/alerts.py +135 -0
- gobby/conductor/loop.py +164 -0
- gobby/conductor/monitors/__init__.py +11 -0
- gobby/conductor/monitors/agents.py +116 -0
- gobby/conductor/monitors/tasks.py +155 -0
- gobby/conductor/pricing.py +234 -0
- gobby/conductor/token_tracker.py +160 -0
- gobby/config/__init__.py +12 -97
- gobby/config/app.py +69 -91
- gobby/config/extensions.py +2 -2
- gobby/config/features.py +7 -130
- gobby/config/search.py +110 -0
- gobby/config/servers.py +1 -1
- gobby/config/skills.py +43 -0
- gobby/config/tasks.py +9 -41
- gobby/hooks/__init__.py +0 -13
- gobby/hooks/event_handlers.py +188 -2
- gobby/hooks/hook_manager.py +50 -4
- gobby/hooks/plugins.py +1 -1
- gobby/hooks/skill_manager.py +130 -0
- gobby/hooks/webhooks.py +1 -1
- gobby/install/claude/hooks/hook_dispatcher.py +4 -4
- gobby/install/codex/hooks/hook_dispatcher.py +1 -1
- gobby/install/gemini/hooks/hook_dispatcher.py +87 -12
- gobby/llm/claude.py +22 -34
- gobby/llm/claude_executor.py +46 -256
- gobby/llm/codex_executor.py +59 -291
- gobby/llm/executor.py +21 -0
- gobby/llm/gemini.py +134 -110
- gobby/llm/litellm_executor.py +143 -6
- gobby/llm/resolver.py +98 -35
- gobby/mcp_proxy/importer.py +62 -4
- gobby/mcp_proxy/instructions.py +56 -0
- gobby/mcp_proxy/models.py +15 -0
- gobby/mcp_proxy/registries.py +68 -8
- gobby/mcp_proxy/server.py +33 -3
- gobby/mcp_proxy/services/recommendation.py +43 -11
- gobby/mcp_proxy/services/tool_proxy.py +81 -1
- gobby/mcp_proxy/stdio.py +2 -1
- gobby/mcp_proxy/tools/__init__.py +0 -2
- gobby/mcp_proxy/tools/agent_messaging.py +317 -0
- gobby/mcp_proxy/tools/agents.py +31 -731
- gobby/mcp_proxy/tools/clones.py +518 -0
- gobby/mcp_proxy/tools/memory.py +3 -26
- gobby/mcp_proxy/tools/metrics.py +65 -1
- gobby/mcp_proxy/tools/orchestration/__init__.py +3 -0
- gobby/mcp_proxy/tools/orchestration/cleanup.py +151 -0
- gobby/mcp_proxy/tools/orchestration/wait.py +467 -0
- gobby/mcp_proxy/tools/sessions/__init__.py +14 -0
- gobby/mcp_proxy/tools/sessions/_commits.py +232 -0
- gobby/mcp_proxy/tools/sessions/_crud.py +253 -0
- gobby/mcp_proxy/tools/sessions/_factory.py +63 -0
- gobby/mcp_proxy/tools/sessions/_handoff.py +499 -0
- gobby/mcp_proxy/tools/sessions/_messages.py +138 -0
- gobby/mcp_proxy/tools/skills/__init__.py +616 -0
- gobby/mcp_proxy/tools/spawn_agent.py +417 -0
- gobby/mcp_proxy/tools/task_orchestration.py +7 -0
- gobby/mcp_proxy/tools/task_readiness.py +14 -0
- gobby/mcp_proxy/tools/task_sync.py +1 -1
- gobby/mcp_proxy/tools/tasks/_context.py +0 -20
- gobby/mcp_proxy/tools/tasks/_crud.py +91 -4
- gobby/mcp_proxy/tools/tasks/_expansion.py +348 -0
- gobby/mcp_proxy/tools/tasks/_factory.py +6 -16
- gobby/mcp_proxy/tools/tasks/_lifecycle.py +110 -45
- gobby/mcp_proxy/tools/tasks/_lifecycle_validation.py +18 -29
- gobby/mcp_proxy/tools/workflows.py +1 -1
- gobby/mcp_proxy/tools/worktrees.py +0 -338
- gobby/memory/backends/__init__.py +6 -1
- gobby/memory/backends/mem0.py +6 -1
- gobby/memory/extractor.py +477 -0
- gobby/memory/ingestion/__init__.py +5 -0
- gobby/memory/ingestion/multimodal.py +221 -0
- gobby/memory/manager.py +73 -285
- gobby/memory/search/__init__.py +10 -0
- gobby/memory/search/coordinator.py +248 -0
- gobby/memory/services/__init__.py +5 -0
- gobby/memory/services/crossref.py +142 -0
- gobby/prompts/loader.py +5 -2
- gobby/runner.py +37 -16
- gobby/search/__init__.py +48 -6
- gobby/search/backends/__init__.py +159 -0
- gobby/search/backends/embedding.py +225 -0
- gobby/search/embeddings.py +238 -0
- gobby/search/models.py +148 -0
- gobby/search/unified.py +496 -0
- gobby/servers/http.py +24 -12
- gobby/servers/routes/admin.py +294 -0
- gobby/servers/routes/mcp/endpoints/__init__.py +61 -0
- gobby/servers/routes/mcp/endpoints/discovery.py +405 -0
- gobby/servers/routes/mcp/endpoints/execution.py +568 -0
- gobby/servers/routes/mcp/endpoints/registry.py +378 -0
- gobby/servers/routes/mcp/endpoints/server.py +304 -0
- gobby/servers/routes/mcp/hooks.py +1 -1
- gobby/servers/routes/mcp/tools.py +48 -1317
- gobby/servers/websocket.py +2 -2
- gobby/sessions/analyzer.py +2 -0
- gobby/sessions/lifecycle.py +1 -1
- gobby/sessions/processor.py +10 -0
- gobby/sessions/transcripts/base.py +2 -0
- gobby/sessions/transcripts/claude.py +79 -10
- gobby/skills/__init__.py +91 -0
- gobby/skills/loader.py +685 -0
- gobby/skills/manager.py +384 -0
- gobby/skills/parser.py +286 -0
- gobby/skills/search.py +463 -0
- gobby/skills/sync.py +119 -0
- gobby/skills/updater.py +385 -0
- gobby/skills/validator.py +368 -0
- gobby/storage/clones.py +378 -0
- gobby/storage/database.py +1 -1
- gobby/storage/memories.py +43 -13
- gobby/storage/migrations.py +162 -201
- gobby/storage/sessions.py +116 -7
- gobby/storage/skills.py +782 -0
- gobby/storage/tasks/_crud.py +4 -4
- gobby/storage/tasks/_lifecycle.py +57 -7
- gobby/storage/tasks/_manager.py +14 -5
- gobby/storage/tasks/_models.py +8 -3
- gobby/sync/memories.py +40 -5
- gobby/sync/tasks.py +83 -6
- gobby/tasks/__init__.py +1 -2
- gobby/tasks/external_validator.py +1 -1
- gobby/tasks/validation.py +46 -35
- gobby/tools/summarizer.py +91 -10
- gobby/tui/api_client.py +4 -7
- gobby/tui/app.py +5 -3
- gobby/tui/screens/orchestrator.py +1 -2
- gobby/tui/screens/tasks.py +2 -4
- gobby/tui/ws_client.py +1 -1
- gobby/utils/daemon_client.py +2 -2
- gobby/utils/project_context.py +2 -3
- gobby/utils/status.py +13 -0
- gobby/workflows/actions.py +221 -1135
- gobby/workflows/artifact_actions.py +31 -0
- gobby/workflows/autonomous_actions.py +11 -0
- gobby/workflows/context_actions.py +93 -1
- gobby/workflows/detection_helpers.py +115 -31
- gobby/workflows/enforcement/__init__.py +47 -0
- gobby/workflows/enforcement/blocking.py +269 -0
- gobby/workflows/enforcement/commit_policy.py +283 -0
- gobby/workflows/enforcement/handlers.py +269 -0
- gobby/workflows/{task_enforcement_actions.py → enforcement/task_policy.py} +29 -388
- gobby/workflows/engine.py +13 -2
- gobby/workflows/git_utils.py +106 -0
- gobby/workflows/lifecycle_evaluator.py +29 -1
- gobby/workflows/llm_actions.py +30 -0
- gobby/workflows/loader.py +19 -6
- gobby/workflows/mcp_actions.py +20 -1
- gobby/workflows/memory_actions.py +154 -0
- gobby/workflows/safe_evaluator.py +183 -0
- gobby/workflows/session_actions.py +44 -0
- gobby/workflows/state_actions.py +60 -1
- gobby/workflows/stop_signal_actions.py +55 -0
- gobby/workflows/summary_actions.py +111 -1
- gobby/workflows/task_sync_actions.py +347 -0
- gobby/workflows/todo_actions.py +34 -1
- gobby/workflows/webhook_actions.py +185 -0
- {gobby-0.2.5.dist-info → gobby-0.2.7.dist-info}/METADATA +87 -21
- {gobby-0.2.5.dist-info → gobby-0.2.7.dist-info}/RECORD +201 -172
- {gobby-0.2.5.dist-info → gobby-0.2.7.dist-info}/WHEEL +1 -1
- gobby/adapters/codex.py +0 -1292
- gobby/install/claude/commands/gobby/bug.md +0 -51
- gobby/install/claude/commands/gobby/chore.md +0 -51
- gobby/install/claude/commands/gobby/epic.md +0 -52
- gobby/install/claude/commands/gobby/eval.md +0 -235
- gobby/install/claude/commands/gobby/feat.md +0 -49
- gobby/install/claude/commands/gobby/nit.md +0 -52
- gobby/install/claude/commands/gobby/ref.md +0 -52
- gobby/install/codex/prompts/forget.md +0 -7
- gobby/install/codex/prompts/memories.md +0 -7
- gobby/install/codex/prompts/recall.md +0 -7
- gobby/install/codex/prompts/remember.md +0 -13
- gobby/llm/gemini_executor.py +0 -339
- gobby/mcp_proxy/tools/session_messages.py +0 -1056
- gobby/mcp_proxy/tools/task_expansion.py +0 -591
- gobby/prompts/defaults/expansion/system.md +0 -119
- gobby/prompts/defaults/expansion/user.md +0 -48
- gobby/prompts/defaults/external_validation/agent.md +0 -72
- gobby/prompts/defaults/external_validation/external.md +0 -63
- gobby/prompts/defaults/external_validation/spawn.md +0 -83
- gobby/prompts/defaults/external_validation/system.md +0 -6
- gobby/prompts/defaults/features/import_mcp.md +0 -22
- gobby/prompts/defaults/features/import_mcp_github.md +0 -17
- gobby/prompts/defaults/features/import_mcp_search.md +0 -16
- gobby/prompts/defaults/features/recommend_tools.md +0 -32
- gobby/prompts/defaults/features/recommend_tools_hybrid.md +0 -35
- gobby/prompts/defaults/features/recommend_tools_llm.md +0 -30
- gobby/prompts/defaults/features/server_description.md +0 -20
- gobby/prompts/defaults/features/server_description_system.md +0 -6
- gobby/prompts/defaults/features/task_description.md +0 -31
- gobby/prompts/defaults/features/task_description_system.md +0 -6
- gobby/prompts/defaults/features/tool_summary.md +0 -17
- gobby/prompts/defaults/features/tool_summary_system.md +0 -6
- gobby/prompts/defaults/research/step.md +0 -58
- gobby/prompts/defaults/validation/criteria.md +0 -47
- gobby/prompts/defaults/validation/validate.md +0 -38
- gobby/storage/migrations_legacy.py +0 -1359
- gobby/tasks/context.py +0 -747
- gobby/tasks/criteria.py +0 -342
- gobby/tasks/expansion.py +0 -626
- gobby/tasks/prompts/expand.py +0 -327
- gobby/tasks/research.py +0 -421
- gobby/tasks/tdd.py +0 -352
- {gobby-0.2.5.dist-info → gobby-0.2.7.dist-info}/entry_points.txt +0 -0
- {gobby-0.2.5.dist-info → gobby-0.2.7.dist-info}/licenses/LICENSE.md +0 -0
- {gobby-0.2.5.dist-info → gobby-0.2.7.dist-info}/top_level.txt +0 -0
gobby/tasks/prompts/expand.py
DELETED
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Expansion Prompt Builder.
|
|
3
|
-
|
|
4
|
-
Handles the construction of system and user prompts for task expansion,
|
|
5
|
-
instructing the agent to return structured JSON for subtask creation.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
import logging
|
|
9
|
-
from pathlib import Path
|
|
10
|
-
|
|
11
|
-
from gobby.config.app import TaskExpansionConfig
|
|
12
|
-
from gobby.prompts import PromptLoader
|
|
13
|
-
from gobby.storage.tasks import Task
|
|
14
|
-
from gobby.tasks.context import ExpansionContext
|
|
15
|
-
|
|
16
|
-
logger = logging.getLogger(__name__)
|
|
17
|
-
|
|
18
|
-
# JSON Schema for subtask output
|
|
19
|
-
SUBTASK_SCHEMA = """
|
|
20
|
-
{
|
|
21
|
-
"subtasks": [
|
|
22
|
-
{
|
|
23
|
-
"title": "string (required) - Short, actionable title",
|
|
24
|
-
"description": "string (optional) - Detailed description with implementation notes",
|
|
25
|
-
"priority": "integer (optional) - 1=High, 2=Medium (default), 3=Low",
|
|
26
|
-
"task_type": "string (optional) - task|bug|feature|epic (default: task)",
|
|
27
|
-
"category": "string (required for actionable tasks) - code|config|docs|research|planning|manual (NOT test)",
|
|
28
|
-
"validation": "string (optional) - Acceptance criteria with project commands",
|
|
29
|
-
"depends_on": ["integer (optional) - Array of 0-based indices of subtasks this depends on"]
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
"""
|
|
34
|
-
|
|
35
|
-
# Default System Prompt (Structured JSON output)
|
|
36
|
-
DEFAULT_SYSTEM_PROMPT = """You are a senior technical project manager and architect.
|
|
37
|
-
Your goal is to break down a high-level task into clear, actionable, and atomic subtasks.
|
|
38
|
-
|
|
39
|
-
## Output Format
|
|
40
|
-
|
|
41
|
-
You MUST respond with a JSON object containing a "subtasks" array. Each subtask has:
|
|
42
|
-
|
|
43
|
-
| Field | Type | Required | Description |
|
|
44
|
-
|-------|------|----------|-------------|
|
|
45
|
-
| title | string | Yes | Short, actionable title for the subtask |
|
|
46
|
-
| description | string | No | Detailed description including implementation notes |
|
|
47
|
-
| priority | integer | No | 1=High, 2=Medium (default), 3=Low |
|
|
48
|
-
| task_type | string | No | "task" (default), "bug", "feature", "epic" |
|
|
49
|
-
| category | string | Yes* | Task domain: code, config, docs, research, planning, manual (NOT test) |
|
|
50
|
-
| validation | string | No | Acceptance criteria with project commands |
|
|
51
|
-
| depends_on | array[int] | No | Indices (0-based) of subtasks this one depends on |
|
|
52
|
-
|
|
53
|
-
*Required for actionable tasks. Use "planning" for epic/phase tasks.
|
|
54
|
-
|
|
55
|
-
## Category Values
|
|
56
|
-
|
|
57
|
-
Choose the appropriate category for each subtask:
|
|
58
|
-
- **code**: Implementation tasks (write/modify source code)
|
|
59
|
-
- **config**: Configuration file changes (.yaml, .toml, .json, .env)
|
|
60
|
-
- **docs**: Documentation tasks (README, docstrings, guides)
|
|
61
|
-
- **refactor**: Refactoring tasks (updating existing code, including existing tests)
|
|
62
|
-
- **research**: Investigation/exploration tasks
|
|
63
|
-
- **planning**: Design/architecture tasks, parent phases
|
|
64
|
-
- **manual**: Manual functional testing (observe output, verify behavior)
|
|
65
|
-
|
|
66
|
-
NOTE: Do NOT use category "test" - TDD test tasks are created automatically.
|
|
67
|
-
Use "refactor" for tasks that update existing test files to work with new code.
|
|
68
|
-
|
|
69
|
-
## Example Output
|
|
70
|
-
|
|
71
|
-
```json
|
|
72
|
-
{
|
|
73
|
-
"subtasks": [
|
|
74
|
-
{
|
|
75
|
-
"title": "Create database schema",
|
|
76
|
-
"description": "Define tables for users, sessions, and permissions",
|
|
77
|
-
"priority": 1,
|
|
78
|
-
"category": "code",
|
|
79
|
-
"validation": "Run migrations and verify tables exist with `{unit_tests}`"
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
"title": "Implement data access layer",
|
|
83
|
-
"description": "Create repository classes for CRUD operations",
|
|
84
|
-
"depends_on": [0],
|
|
85
|
-
"category": "code",
|
|
86
|
-
"validation": "Unit tests for all repository methods pass"
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
"title": "Add API endpoints",
|
|
90
|
-
"description": "REST endpoints for user management",
|
|
91
|
-
"depends_on": [1],
|
|
92
|
-
"category": "code",
|
|
93
|
-
"validation": "Integration tests for all endpoints pass"
|
|
94
|
-
}
|
|
95
|
-
]
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## Dependency System
|
|
100
|
-
|
|
101
|
-
Use `depends_on` to specify execution order:
|
|
102
|
-
- Reference subtasks by their 0-based index in the array
|
|
103
|
-
- A subtask with `depends_on: [0, 2]` requires subtasks 0 and 2 to complete first
|
|
104
|
-
- Order your array logically - dependencies should come before dependents
|
|
105
|
-
|
|
106
|
-
## Rules
|
|
107
|
-
|
|
108
|
-
1. **Atomicity**: Each subtask should be small enough to be completed in one session (10-30 mins of work).
|
|
109
|
-
2. **Dependencies**: Use `depends_on` to enforce logical order (e.g., create file before importing it).
|
|
110
|
-
3. **Context Awareness**: Reference specific existing files or functions from the provided codebase context.
|
|
111
|
-
4. **Categories Required**: Every actionable subtask MUST have a category from the enum.
|
|
112
|
-
5. **Validation Criteria**: Include validation criteria for code/config tasks.
|
|
113
|
-
6. **Completeness**: The set of subtasks must fully accomplish the parent task.
|
|
114
|
-
7. **JSON Only**: Output ONLY valid JSON - no markdown, no explanation, no code blocks.
|
|
115
|
-
8. **No Scope Creep**: Do NOT include optional features, alternatives, or "nice-to-haves". Each subtask must be a concrete requirement from the parent task. Never invent additional features, suggest "consider also adding X", or include "(Optional)" sections. Implement exactly what is specified.
|
|
116
|
-
9. **NO TEST TASKS**: Do NOT create subtasks for writing tests. TDD is applied AUTOMATICALLY after expansion. Creating test tasks like "Write tests for X", "Add unit tests", "Create test file", "Verify with tests", or ANY task with category="test" will cause DUPLICATE test work. Only create implementation subtasks.
|
|
117
|
-
|
|
118
|
-
## Validation Criteria Rules
|
|
119
|
-
|
|
120
|
-
For each subtask, generate PRECISE validation criteria in the `validation` field.
|
|
121
|
-
Use the project's verification commands (provided in context) rather than hardcoded commands.
|
|
122
|
-
|
|
123
|
-
### 1. Measurable
|
|
124
|
-
Use exact commands from project context, not vague descriptions.
|
|
125
|
-
|
|
126
|
-
| BAD (Vague) | GOOD (Measurable) |
|
|
127
|
-
|-------------|-------------------|
|
|
128
|
-
| "Tests pass" | "`{unit_tests}` exits with code 0" |
|
|
129
|
-
| "No type errors" | "`{type_check}` reports no errors" |
|
|
130
|
-
| "Linting passes" | "`{lint}` exits with code 0" |
|
|
131
|
-
|
|
132
|
-
### 2. Specific
|
|
133
|
-
Reference actual files and functions from the provided context.
|
|
134
|
-
|
|
135
|
-
| BAD (Generic) | GOOD (Specific) |
|
|
136
|
-
|---------------|-----------------|
|
|
137
|
-
| "Function moved correctly" | "`ClassName` exists in `path/to/new/file.ext` with same signature" |
|
|
138
|
-
| "Tests updated" | "`tests/module/test_file.ext` imports from new location" |
|
|
139
|
-
| "Config added" | "`ConfigName` in `path/to/config.ext` has required fields" |
|
|
140
|
-
|
|
141
|
-
### 3. Verifiable
|
|
142
|
-
Include commands that can be executed to verify completion.
|
|
143
|
-
|
|
144
|
-
| BAD (Unverifiable) | GOOD (Verifiable) |
|
|
145
|
-
|--------------------|-------------------|
|
|
146
|
-
| "No regressions" | "No test files removed: `git diff --name-only HEAD~1 | grep -v test`" |
|
|
147
|
-
| "Module importable" | "Import succeeds without errors in project's runtime" |
|
|
148
|
-
| "File created" | "File exists at expected path with expected exports" |
|
|
149
|
-
|
|
150
|
-
**Important:** Replace `{unit_tests}`, `{type_check}`, `{lint}` with actual commands from the Project Verification Commands section in the context.
|
|
151
|
-
"""
|
|
152
|
-
|
|
153
|
-
# NOTE: TDD_MODE_INSTRUCTIONS removed - TDD is now applied automatically post-expansion
|
|
154
|
-
# by _apply_tdd_sandwich() in task_expansion.py for non-epic code/config tasks
|
|
155
|
-
|
|
156
|
-
# Default User Prompt Template
|
|
157
|
-
DEFAULT_USER_PROMPT = """Analyze and expand this task into subtasks.
|
|
158
|
-
|
|
159
|
-
## Parent Task
|
|
160
|
-
- **ID**: {task_id}
|
|
161
|
-
- **Title**: {title}
|
|
162
|
-
- **Description**: {description}
|
|
163
|
-
|
|
164
|
-
## Context
|
|
165
|
-
{context_str}
|
|
166
|
-
|
|
167
|
-
## Research Findings
|
|
168
|
-
{research_str}
|
|
169
|
-
|
|
170
|
-
## Instructions
|
|
171
|
-
|
|
172
|
-
Return a JSON object with a "subtasks" array. Remember to:
|
|
173
|
-
1. Use `depends_on` with 0-based indices to specify dependencies
|
|
174
|
-
2. Include a category for each coding subtask
|
|
175
|
-
3. Order subtasks logically - dependencies before dependents
|
|
176
|
-
4. Output ONLY valid JSON - no markdown, no explanation
|
|
177
|
-
|
|
178
|
-
Return the JSON now."""
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
class ExpansionPromptBuilder:
|
|
182
|
-
"""Builds prompts for task expansion."""
|
|
183
|
-
|
|
184
|
-
def __init__(self, config: TaskExpansionConfig, project_dir: Path | None = None):
|
|
185
|
-
self.config = config
|
|
186
|
-
self._loader = PromptLoader(project_dir=project_dir)
|
|
187
|
-
|
|
188
|
-
# Register fallbacks for strangler fig pattern
|
|
189
|
-
# NOTE: TDD is applied post-expansion, not in prompt
|
|
190
|
-
self._loader.register_fallback("expansion/system", lambda: DEFAULT_SYSTEM_PROMPT)
|
|
191
|
-
self._loader.register_fallback("expansion/user", lambda: DEFAULT_USER_PROMPT)
|
|
192
|
-
|
|
193
|
-
def get_system_prompt(self, tdd_mode: bool = False) -> str:
|
|
194
|
-
"""
|
|
195
|
-
Get the system prompt (from config, template file, or default).
|
|
196
|
-
|
|
197
|
-
Precedence order:
|
|
198
|
-
1. Inline config (deprecated): config.system_prompt
|
|
199
|
-
2. Config path: config.system_prompt_path
|
|
200
|
-
3. Template file: expansion/system.md
|
|
201
|
-
4. Python constant fallback: DEFAULT_SYSTEM_PROMPT
|
|
202
|
-
|
|
203
|
-
Args:
|
|
204
|
-
tdd_mode: Deprecated, ignored. TDD is now applied post-expansion.
|
|
205
|
-
"""
|
|
206
|
-
# 1. Inline config (deprecated, for backwards compatibility)
|
|
207
|
-
if self.config.system_prompt:
|
|
208
|
-
return self.config.system_prompt
|
|
209
|
-
|
|
210
|
-
# 2. Config path or 3. Template file
|
|
211
|
-
prompt_path = self.config.system_prompt_path or "expansion/system"
|
|
212
|
-
|
|
213
|
-
try:
|
|
214
|
-
# Pass empty context - tdd_mode no longer used in templates
|
|
215
|
-
return self._loader.render(prompt_path, {})
|
|
216
|
-
except FileNotFoundError:
|
|
217
|
-
logger.debug(f"Prompt template '{prompt_path}' not found, using fallback")
|
|
218
|
-
# 4. Python constant fallback
|
|
219
|
-
return DEFAULT_SYSTEM_PROMPT
|
|
220
|
-
|
|
221
|
-
def build_user_prompt(
|
|
222
|
-
self,
|
|
223
|
-
task: Task,
|
|
224
|
-
context: ExpansionContext,
|
|
225
|
-
user_instructions: str | None = None,
|
|
226
|
-
) -> str:
|
|
227
|
-
"""
|
|
228
|
-
Build the user prompt by injecting context into the template.
|
|
229
|
-
|
|
230
|
-
Precedence order:
|
|
231
|
-
1. Inline config (deprecated): config.prompt
|
|
232
|
-
2. Config path: config.prompt_path
|
|
233
|
-
3. Template file: expansion/user.md
|
|
234
|
-
4. Python constant fallback: DEFAULT_USER_PROMPT
|
|
235
|
-
"""
|
|
236
|
-
# Check if using inline config (deprecated)
|
|
237
|
-
use_legacy_template = self.config.prompt is not None
|
|
238
|
-
|
|
239
|
-
# Format context string
|
|
240
|
-
context_parts = []
|
|
241
|
-
if context.relevant_files:
|
|
242
|
-
context_parts.append("**Relevant Files:**")
|
|
243
|
-
for f in context.relevant_files:
|
|
244
|
-
context_parts.append(f"- {f}")
|
|
245
|
-
|
|
246
|
-
if context.existing_tests:
|
|
247
|
-
context_parts.append("\n**Existing Tests:**")
|
|
248
|
-
for module, test_files in context.existing_tests.items():
|
|
249
|
-
context_parts.append(f"- {module}:")
|
|
250
|
-
for tf in test_files:
|
|
251
|
-
context_parts.append(f" - {tf}")
|
|
252
|
-
context_parts.append(
|
|
253
|
-
"\n*Note: When creating test tasks for modules with existing tests, "
|
|
254
|
-
"update the existing test files rather than creating new ones.*"
|
|
255
|
-
)
|
|
256
|
-
|
|
257
|
-
if context.function_signatures:
|
|
258
|
-
context_parts.append("\n**Functions Being Modified:**")
|
|
259
|
-
for file_path, signatures in context.function_signatures.items():
|
|
260
|
-
context_parts.append(f"- {file_path}:")
|
|
261
|
-
for sig in signatures:
|
|
262
|
-
context_parts.append(f" - `{sig}`")
|
|
263
|
-
context_parts.append(
|
|
264
|
-
"\n*Note: Reference these signatures in validation criteria "
|
|
265
|
-
"to ensure functions are preserved or properly refactored.*"
|
|
266
|
-
)
|
|
267
|
-
|
|
268
|
-
if context.verification_commands:
|
|
269
|
-
context_parts.append("\n**Project Verification Commands:**")
|
|
270
|
-
context_parts.append("Use these commands in validation criteria:")
|
|
271
|
-
for name, cmd in context.verification_commands.items():
|
|
272
|
-
context_parts.append(f"- `{{{name}}}` = `{cmd}`")
|
|
273
|
-
|
|
274
|
-
if context.project_patterns:
|
|
275
|
-
context_parts.append("\n**Project Patterns:**")
|
|
276
|
-
for k, v in context.project_patterns.items():
|
|
277
|
-
context_parts.append(f"- {k}: {v}")
|
|
278
|
-
|
|
279
|
-
if context.related_tasks:
|
|
280
|
-
context_parts.append("\n**Related Tasks:**")
|
|
281
|
-
for t in context.related_tasks:
|
|
282
|
-
context_parts.append(f"- {t.title} ({t.status})")
|
|
283
|
-
|
|
284
|
-
if context.project_structure:
|
|
285
|
-
context_parts.append("\n**Project Structure:**")
|
|
286
|
-
context_parts.append(context.project_structure)
|
|
287
|
-
context_parts.append(
|
|
288
|
-
"\n*IMPORTANT: Use these actual paths when referencing files. "
|
|
289
|
-
"Do NOT invent paths like 'gt/core/' or 'lib/utils/' - only use paths shown above.*"
|
|
290
|
-
)
|
|
291
|
-
|
|
292
|
-
context_str = (
|
|
293
|
-
"\n".join(context_parts) if context_parts else "No additional context available."
|
|
294
|
-
)
|
|
295
|
-
|
|
296
|
-
# Format research findings
|
|
297
|
-
research_str = context.agent_findings or "No research performed."
|
|
298
|
-
|
|
299
|
-
# Build context for template rendering
|
|
300
|
-
template_context = {
|
|
301
|
-
"task_id": task.id,
|
|
302
|
-
"title": task.title,
|
|
303
|
-
"description": task.description or "",
|
|
304
|
-
"context_str": context_str,
|
|
305
|
-
"research_str": research_str,
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
# Render using appropriate method
|
|
309
|
-
if use_legacy_template:
|
|
310
|
-
# 1. Inline config (deprecated)
|
|
311
|
-
template = self.config.prompt or DEFAULT_USER_PROMPT
|
|
312
|
-
prompt = template.format(**template_context)
|
|
313
|
-
else:
|
|
314
|
-
# 2. Config path or 3. Template file
|
|
315
|
-
prompt_path = self.config.prompt_path or "expansion/user"
|
|
316
|
-
try:
|
|
317
|
-
prompt = self._loader.render(prompt_path, template_context)
|
|
318
|
-
except FileNotFoundError:
|
|
319
|
-
logger.debug(f"Prompt template '{prompt_path}' not found, using fallback")
|
|
320
|
-
# 4. Python constant fallback
|
|
321
|
-
prompt = DEFAULT_USER_PROMPT.format(**template_context)
|
|
322
|
-
|
|
323
|
-
# Append specific user instructions if provided
|
|
324
|
-
if user_instructions:
|
|
325
|
-
prompt += f"\n\n## Additional Instructions\n{user_instructions}"
|
|
326
|
-
|
|
327
|
-
return prompt
|