deviatdd 2.5.1__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.
- deviatdd-2.5.1.dist-info/METADATA +386 -0
- deviatdd-2.5.1.dist-info/RECORD +124 -0
- deviatdd-2.5.1.dist-info/WHEEL +4 -0
- deviatdd-2.5.1.dist-info/entry_points.txt +2 -0
- deviatdd-2.5.1.dist-info/licenses/LICENSE +21 -0
- deviate/__init__.py +3 -0
- deviate/cli/__init__.py +824 -0
- deviate/cli/_common.py +155 -0
- deviate/cli/adhoc.py +183 -0
- deviate/cli/constitution.py +113 -0
- deviate/cli/feature.py +94 -0
- deviate/cli/init.py +485 -0
- deviate/cli/inspect.py +208 -0
- deviate/cli/macro.py +937 -0
- deviate/cli/meso.py +1894 -0
- deviate/cli/micro.py +3249 -0
- deviate/cli/review.py +441 -0
- deviate/core/__init__.py +0 -0
- deviate/core/_shared.py +20 -0
- deviate/core/agent.py +505 -0
- deviate/core/cache_discipline.py +65 -0
- deviate/core/commands.py +202 -0
- deviate/core/commit.py +86 -0
- deviate/core/complexity.py +36 -0
- deviate/core/constitution.py +85 -0
- deviate/core/contract.py +17 -0
- deviate/core/convention.py +147 -0
- deviate/core/epic.py +73 -0
- deviate/core/issues.py +46 -0
- deviate/core/prd.py +18 -0
- deviate/core/profile.py +33 -0
- deviate/core/repo.py +47 -0
- deviate/core/run_logger.py +50 -0
- deviate/core/tasks_ledger.py +69 -0
- deviate/core/treesitter/__init__.py +31 -0
- deviate/core/treesitter/analysis.py +457 -0
- deviate/core/treesitter/models.py +35 -0
- deviate/core/treesitter/parser.py +184 -0
- deviate/core/treesitter/queries/bash.scm +7 -0
- deviate/core/treesitter/queries/c_sharp.scm +11 -0
- deviate/core/treesitter/queries/cpp.scm +9 -0
- deviate/core/treesitter/queries/css.scm +4 -0
- deviate/core/treesitter/queries/dockerfile.scm +8 -0
- deviate/core/treesitter/queries/elixir.scm +6 -0
- deviate/core/treesitter/queries/go.scm +9 -0
- deviate/core/treesitter/queries/hcl.scm +3 -0
- deviate/core/treesitter/queries/html.scm +3 -0
- deviate/core/treesitter/queries/javascript.scm +12 -0
- deviate/core/treesitter/queries/json.scm +4 -0
- deviate/core/treesitter/queries/kotlin.scm +8 -0
- deviate/core/treesitter/queries/markdown.scm +4 -0
- deviate/core/treesitter/queries/python.scm +10 -0
- deviate/core/treesitter/queries/rust.scm +12 -0
- deviate/core/treesitter/queries/sql.scm +7 -0
- deviate/core/treesitter/queries/swift.scm +10 -0
- deviate/core/treesitter/queries/toml.scm +3 -0
- deviate/core/treesitter/queries/tsx.scm +14 -0
- deviate/core/treesitter/queries/typescript.scm +14 -0
- deviate/core/treesitter/queries/yaml.scm +4 -0
- deviate/core/validation.py +153 -0
- deviate/core/worktree.py +141 -0
- deviate/main.py +4 -0
- deviate/prompts/__init__.py +0 -0
- deviate/prompts/assembly.py +122 -0
- deviate/prompts/auto/__init__.py +1 -0
- deviate/prompts/auto/execute.md +62 -0
- deviate/prompts/auto/explore.md +103 -0
- deviate/prompts/auto/green.md +137 -0
- deviate/prompts/auto/judge.md +260 -0
- deviate/prompts/auto/plan.md +127 -0
- deviate/prompts/auto/prd.md +108 -0
- deviate/prompts/auto/red.md +156 -0
- deviate/prompts/auto/refactor.md +166 -0
- deviate/prompts/auto/research.md +111 -0
- deviate/prompts/auto/shard.md +90 -0
- deviate/prompts/auto/specify.md +77 -0
- deviate/prompts/auto/tasks.md +191 -0
- deviate/prompts/commands/deviate-adhoc.md +216 -0
- deviate/prompts/commands/deviate-architecture.md +147 -0
- deviate/prompts/commands/deviate-constitution.md +215 -0
- deviate/prompts/commands/deviate-e2e.md +264 -0
- deviate/prompts/commands/deviate-execute.md +223 -0
- deviate/prompts/commands/deviate-explore.md +253 -0
- deviate/prompts/commands/deviate-flows.md +226 -0
- deviate/prompts/commands/deviate-green.md +217 -0
- deviate/prompts/commands/deviate-hotfix.md +188 -0
- deviate/prompts/commands/deviate-init.md +170 -0
- deviate/prompts/commands/deviate-judge.md +193 -0
- deviate/prompts/commands/deviate-merge.md +221 -0
- deviate/prompts/commands/deviate-plan.md +158 -0
- deviate/prompts/commands/deviate-pr.md +144 -0
- deviate/prompts/commands/deviate-prd.md +216 -0
- deviate/prompts/commands/deviate-prune.md +260 -0
- deviate/prompts/commands/deviate-red.md +231 -0
- deviate/prompts/commands/deviate-refactor.md +211 -0
- deviate/prompts/commands/deviate-release.md +123 -0
- deviate/prompts/commands/deviate-research.md +359 -0
- deviate/prompts/commands/deviate-review.md +289 -0
- deviate/prompts/commands/deviate-shard.md +226 -0
- deviate/prompts/commands/deviate-tasks.md +281 -0
- deviate/prompts/commands/deviate-triage.md +141 -0
- deviate/prompts/constitution_seed.md +51 -0
- deviate/prompts/core/core.md +21 -0
- deviate/prompts/core/macro-auto.md +59 -0
- deviate/prompts/core/macro-command.md +54 -0
- deviate/prompts/core/macro-skill.md +54 -0
- deviate/prompts/core/meso-auto.md +63 -0
- deviate/prompts/core/meso-command.md +58 -0
- deviate/prompts/core/meso-skill.md +58 -0
- deviate/prompts/core/micro-auto.md +76 -0
- deviate/prompts/core/micro-command.md +67 -0
- deviate/prompts/core/micro-skill.md +67 -0
- deviate/prompts/extras/deviate-pr-graphite-routing.md +20 -0
- deviate/prompts/governance/__init__.py +0 -0
- deviate/prompts/governance/agents_seed.md +1 -0
- deviate/prompts/governance/claudemd_seed.md +1 -0
- deviate/prompts/governance/graphite_seed.md +18 -0
- deviate/prompts/governance/libref_seed.md +3 -0
- deviate/state/__init__.py +0 -0
- deviate/state/config.py +257 -0
- deviate/state/ledger.py +407 -0
- deviate/ui/__init__.py +5 -0
- deviate/ui/monitor.py +187 -0
- deviate/ui/render.py +26 -0
deviate/core/worktree.py
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import subprocess
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from deviate.core._shared import git_env as _git_env
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def find_worktree_for_branch(branch: str, repo: Path | None = None) -> Path | None:
|
|
10
|
+
"""Return the worktree path for an existing branch, or None."""
|
|
11
|
+
repo = repo or Path.cwd()
|
|
12
|
+
result = subprocess.run(
|
|
13
|
+
["git", "worktree", "list"],
|
|
14
|
+
cwd=repo,
|
|
15
|
+
env=_git_env(),
|
|
16
|
+
capture_output=True,
|
|
17
|
+
text=True,
|
|
18
|
+
check=True,
|
|
19
|
+
)
|
|
20
|
+
for line in result.stdout.strip().splitlines():
|
|
21
|
+
parts = line.split()
|
|
22
|
+
if len(parts) >= 3 and parts[2].strip("[]") == branch:
|
|
23
|
+
return Path(parts[0])
|
|
24
|
+
return None
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def detect_remote(repo: Path | None = None) -> str:
|
|
28
|
+
"""Return the default git remote name, preferring ``origin``."""
|
|
29
|
+
repo = repo or Path.cwd()
|
|
30
|
+
result = subprocess.run(
|
|
31
|
+
["git", "remote"],
|
|
32
|
+
cwd=repo,
|
|
33
|
+
env=_git_env(),
|
|
34
|
+
capture_output=True,
|
|
35
|
+
text=True,
|
|
36
|
+
check=True,
|
|
37
|
+
)
|
|
38
|
+
remotes = result.stdout.strip().splitlines()
|
|
39
|
+
if not remotes:
|
|
40
|
+
msg = "no git remotes configured"
|
|
41
|
+
raise RuntimeError(msg)
|
|
42
|
+
return "origin" if "origin" in remotes else remotes[0]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def branch_exists_on_remote(
|
|
46
|
+
branch: str, repo: Path | None = None, remote: str | None = None
|
|
47
|
+
) -> bool:
|
|
48
|
+
"""Check if a branch exists on the remote (auto-detected by default).
|
|
49
|
+
|
|
50
|
+
Returns ``False`` if the remote is unreachable (network error) —
|
|
51
|
+
the caller's ``detect_remote`` already validated the remote exists.
|
|
52
|
+
"""
|
|
53
|
+
repo = repo or Path.cwd()
|
|
54
|
+
remote = remote or detect_remote(repo)
|
|
55
|
+
result = subprocess.run(
|
|
56
|
+
["git", "ls-remote", "--heads", remote, branch],
|
|
57
|
+
cwd=repo,
|
|
58
|
+
env=_git_env(),
|
|
59
|
+
capture_output=True,
|
|
60
|
+
text=True,
|
|
61
|
+
)
|
|
62
|
+
return bool(result.stdout.strip())
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def create_worktree(branch: str, path: Path, repo: Path | None = None) -> Path:
|
|
66
|
+
repo = repo or Path.cwd()
|
|
67
|
+
existing = find_worktree_for_branch(branch, repo)
|
|
68
|
+
if existing is not None:
|
|
69
|
+
return existing
|
|
70
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
71
|
+
result = subprocess.run(
|
|
72
|
+
["git", "branch", "--list", branch],
|
|
73
|
+
cwd=repo,
|
|
74
|
+
env=_git_env(),
|
|
75
|
+
capture_output=True,
|
|
76
|
+
text=True,
|
|
77
|
+
)
|
|
78
|
+
branch_exists = bool(result.stdout.strip())
|
|
79
|
+
if not branch_exists:
|
|
80
|
+
subprocess.run(
|
|
81
|
+
["git", "branch", branch, "HEAD"],
|
|
82
|
+
cwd=repo,
|
|
83
|
+
env=_git_env(),
|
|
84
|
+
check=True,
|
|
85
|
+
)
|
|
86
|
+
subprocess.run(
|
|
87
|
+
["git", "worktree", "add", str(path), branch],
|
|
88
|
+
cwd=repo,
|
|
89
|
+
env=_git_env(),
|
|
90
|
+
check=True,
|
|
91
|
+
)
|
|
92
|
+
return path
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def detect_worktree(repo: Path | None = None) -> dict[str, str]:
|
|
96
|
+
repo = repo or Path.cwd()
|
|
97
|
+
result = subprocess.run(
|
|
98
|
+
["git", "worktree", "list"],
|
|
99
|
+
cwd=repo,
|
|
100
|
+
env=_git_env(),
|
|
101
|
+
capture_output=True,
|
|
102
|
+
text=True,
|
|
103
|
+
check=True,
|
|
104
|
+
)
|
|
105
|
+
worktrees: dict[str, str] = {}
|
|
106
|
+
for line in result.stdout.strip().splitlines():
|
|
107
|
+
parts = line.split()
|
|
108
|
+
if len(parts) >= 2:
|
|
109
|
+
worktrees[parts[1]] = parts[0]
|
|
110
|
+
return worktrees
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def remove_worktree(branch: str, path: Path, repo: Path | None = None) -> None:
|
|
114
|
+
"""Remove a worktree and its local branch (best-effort, no-op on failure)."""
|
|
115
|
+
repo = repo or Path.cwd()
|
|
116
|
+
try:
|
|
117
|
+
subprocess.run(
|
|
118
|
+
["git", "worktree", "remove", "--force", str(path)],
|
|
119
|
+
cwd=repo,
|
|
120
|
+
env=_git_env(),
|
|
121
|
+
check=True,
|
|
122
|
+
capture_output=True,
|
|
123
|
+
)
|
|
124
|
+
except subprocess.CalledProcessError:
|
|
125
|
+
pass
|
|
126
|
+
try:
|
|
127
|
+
subprocess.run(
|
|
128
|
+
["git", "branch", "-D", branch],
|
|
129
|
+
cwd=repo,
|
|
130
|
+
env=_git_env(),
|
|
131
|
+
check=True,
|
|
132
|
+
capture_output=True,
|
|
133
|
+
)
|
|
134
|
+
except subprocess.CalledProcessError:
|
|
135
|
+
pass
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def validate_worktree(path: Path) -> bool:
|
|
139
|
+
if not path.exists():
|
|
140
|
+
return False
|
|
141
|
+
return (path / ".git").exists()
|
deviate/main.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import importlib.resources as resources
|
|
4
|
+
import logging
|
|
5
|
+
import re
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
logger = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
# ---------------------------------------------------------------------------
|
|
11
|
+
# Layer routing
|
|
12
|
+
# ---------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
_LAYER_MAP: dict[str, str | None] = {
|
|
15
|
+
# Macro layer — auto prefix (CLI orchestrates pre/post)
|
|
16
|
+
"explore": "macro-auto",
|
|
17
|
+
"research": "macro-auto",
|
|
18
|
+
"prd": "macro-auto",
|
|
19
|
+
"shard": "macro-auto",
|
|
20
|
+
"specify": "macro-auto",
|
|
21
|
+
# Meso layer — auto prefix
|
|
22
|
+
"plan": "meso-auto",
|
|
23
|
+
"tasks": "meso-auto",
|
|
24
|
+
# Micro layer — auto prefix
|
|
25
|
+
"red": "micro-auto",
|
|
26
|
+
"green": "micro-auto",
|
|
27
|
+
"refactor": "micro-auto",
|
|
28
|
+
"judge": "micro-auto",
|
|
29
|
+
"execute": "micro-auto",
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# Slash commands live as package resources under `src/deviate/prompts/commands/<name>.md`
|
|
33
|
+
# and are installed to `<workdir>/.<agent>/commands/<name>.md` by `deviate setup`.
|
|
34
|
+
# No `.sh` wrappers in `prompts/` — every template is loaded with `importlib.resources.files()`.
|
|
35
|
+
|
|
36
|
+
_CORE_DIR = "deviate.prompts.core"
|
|
37
|
+
_AUTO_DIR = "deviate.prompts.auto"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _read_resource(package: str, filename: str) -> str | None:
|
|
41
|
+
path = resources.files(package) / filename
|
|
42
|
+
if path.is_file():
|
|
43
|
+
return path.read_text(encoding="utf-8")
|
|
44
|
+
return None
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def load_template(
|
|
48
|
+
template_name: str,
|
|
49
|
+
constitution_path: Path | None = None,
|
|
50
|
+
) -> str:
|
|
51
|
+
"""Load and compose a prompt template from its constituent parts.
|
|
52
|
+
|
|
53
|
+
Assembly order::
|
|
54
|
+
|
|
55
|
+
specs/constitution.md — project governance (from *constitution_path*)
|
|
56
|
+
core/core.md — universal invariants (shared by ALL phases)
|
|
57
|
+
core/{layer}.md — layer-specific preamble (macro / meso / micro)
|
|
58
|
+
auto/{template}.md — phase-specific instructions
|
|
59
|
+
|
|
60
|
+
Constitution and layer files are optional — if they don't exist the
|
|
61
|
+
remaining tiers are used standalone.
|
|
62
|
+
"""
|
|
63
|
+
parts: list[str] = []
|
|
64
|
+
|
|
65
|
+
# 0. Constitution (project governance) — optional
|
|
66
|
+
if constitution_path is not None:
|
|
67
|
+
try:
|
|
68
|
+
constitution_content = constitution_path.read_text(encoding="utf-8")
|
|
69
|
+
parts.append(constitution_content)
|
|
70
|
+
except OSError as exc:
|
|
71
|
+
logger.warning("CONSTITUTION_MISSING: %s: %s", constitution_path, exc)
|
|
72
|
+
|
|
73
|
+
# 1. Universal core
|
|
74
|
+
core = _read_resource(_CORE_DIR, "core.md")
|
|
75
|
+
if core:
|
|
76
|
+
parts.append(core)
|
|
77
|
+
|
|
78
|
+
# 2. Layer-specific preamble
|
|
79
|
+
layer = _LAYER_MAP.get(template_name)
|
|
80
|
+
if layer:
|
|
81
|
+
layer_content = _read_resource(_CORE_DIR, f"{layer}.md")
|
|
82
|
+
if layer_content:
|
|
83
|
+
parts.append(layer_content)
|
|
84
|
+
|
|
85
|
+
# 3. Phase-specific template
|
|
86
|
+
phase = _read_resource(_AUTO_DIR, f"{template_name}.md")
|
|
87
|
+
if not phase:
|
|
88
|
+
raise FileNotFoundError(f"Template '{template_name}' not found in {_AUTO_DIR}")
|
|
89
|
+
parts.append(phase)
|
|
90
|
+
|
|
91
|
+
return "\n\n".join(parts)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def inject_constitution(
|
|
95
|
+
prompt: str,
|
|
96
|
+
constitution_path: Path,
|
|
97
|
+
) -> str:
|
|
98
|
+
try:
|
|
99
|
+
constitution_content = constitution_path.read_text(encoding="utf-8")
|
|
100
|
+
except OSError as exc:
|
|
101
|
+
logger.warning("CONSTITUTION_MISSING: %s: %s", constitution_path, exc)
|
|
102
|
+
return prompt
|
|
103
|
+
|
|
104
|
+
return f"{constitution_content}\n\n{prompt}"
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
_PLACEHOLDER_RE = re.compile(r"\$\{(.+?)\}|\$(\w+)|{(.+?)}")
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def _replace_placeholder(match: re.Match[str], context: dict[str, str]) -> str:
|
|
111
|
+
key = match.group(1) or match.group(2) or match.group(3)
|
|
112
|
+
return context.get(key, match.group(0))
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def assemble_prompt(
|
|
116
|
+
template_name: str,
|
|
117
|
+
context: dict[str, str],
|
|
118
|
+
constitution_path: Path,
|
|
119
|
+
) -> str:
|
|
120
|
+
prompt = load_template(template_name, constitution_path=constitution_path)
|
|
121
|
+
prompt = _PLACEHOLDER_RE.sub(lambda m: _replace_placeholder(m, context), prompt)
|
|
122
|
+
return prompt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<system_instructions>
|
|
2
|
+
|
|
3
|
+
## Role Definition
|
|
4
|
+
|
|
5
|
+
You are a **DIRECT_TASK_EXECUTION_ENGINEER** operating inside the **DeviaTDD DIRECT EXECUTION layer**. Your objective is to execute a single task end-to-end with minimal, focused modifications.
|
|
6
|
+
|
|
7
|
+
</system_instructions>
|
|
8
|
+
|
|
9
|
+
<task_content>
|
|
10
|
+
{task_content}
|
|
11
|
+
</task_content>
|
|
12
|
+
|
|
13
|
+
<spec_content>
|
|
14
|
+
{spec_content}
|
|
15
|
+
</spec_content>
|
|
16
|
+
|
|
17
|
+
<execution_sequence>
|
|
18
|
+
|
|
19
|
+
<step id="context_loading">
|
|
20
|
+
1. Extract the target `{TASK_ID}` from `<task_content>` above
|
|
21
|
+
2. Read `<spec_content>` above for relevant data definitions and API constraints
|
|
22
|
+
</step>
|
|
23
|
+
|
|
24
|
+
<step id="implementation">
|
|
25
|
+
1. Implement the task using minimal, focused modifications
|
|
26
|
+
2. Run the verification command:
|
|
27
|
+
```bash
|
|
28
|
+
{verification_command}
|
|
29
|
+
```
|
|
30
|
+
3. Run lint to ensure code quality:
|
|
31
|
+
```bash
|
|
32
|
+
{lint_command}
|
|
33
|
+
```
|
|
34
|
+
If lint fails, fix issues and re-run both until both pass.
|
|
35
|
+
</step>
|
|
36
|
+
|
|
37
|
+
<step id="handover_emission">
|
|
38
|
+
After implementation is verified, emit the handover manifest:
|
|
39
|
+
|
|
40
|
+
**ORCHESTRATOR LIFECYCLE**: The CLI orchestrator handles ALL git operations after your response (add, commit, branch management). Do NOT run `git add`, `git commit`, `git checkout -b`, or any other git mutation command. Writing files to disk is sufficient. Any git commands you run will create duplicate commits and corrupt the pipeline.
|
|
41
|
+
|
|
42
|
+
<handover_manifest>
|
|
43
|
+
```yaml
|
|
44
|
+
phase: EXECUTE
|
|
45
|
+
status: "PASS"
|
|
46
|
+
task_id: "{TASK_ID}"
|
|
47
|
+
next_phase: "IDLE"
|
|
48
|
+
```
|
|
49
|
+
</handover_manifest>
|
|
50
|
+
</step>
|
|
51
|
+
|
|
52
|
+
</execution_sequence>
|
|
53
|
+
|
|
54
|
+
<edge_case_handling>
|
|
55
|
+
|
|
56
|
+
| Condition | Action |
|
|
57
|
+
|---|---|
|
|
58
|
+
| Verification fails | Fix implementation iteratively until all checks pass |
|
|
59
|
+
| Lint fails | Fix lint issues, re-run verification and lint until both pass |
|
|
60
|
+
| No spec content available | Proceed with task description only |
|
|
61
|
+
|
|
62
|
+
</edge_case_handling>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<system_instructions>
|
|
2
|
+
|
|
3
|
+
## Role Definition
|
|
4
|
+
|
|
5
|
+
You are an **EXPLORATION_CONTEXT_SCANNER** operating inside the **MACRO LAYER / PHASE_EXPLORE**. Your objective is a fast, cheap, deterministic, and purely factual scan of the active repository — never a design or recommendation pass. The architectural reasoning phase belongs to `/research`; do not preempt it.
|
|
6
|
+
|
|
7
|
+
Your job is to ingest a JSON contract emitted by `deviate explore pre`, perform a structural scan, and write **exactly one** file: `explore.md`. The post-script `deviate explore post` validates and commits the artifact.
|
|
8
|
+
|
|
9
|
+
### Phase-Specific Invariants
|
|
10
|
+
|
|
11
|
+
1. **Factual-Only Discipline**: Emit only what EXISTS. Trade-off analysis, recommendations, design decisions, and risk evaluations are explicitly deferred to `/research`. Prefer observational language ("the project contains", "the manifest declares") over prescriptive language ("we should", "we recommend").
|
|
12
|
+
|
|
13
|
+
</system_instructions>
|
|
14
|
+
|
|
15
|
+
<traceability_mandates>
|
|
16
|
+
1. **Verbatim Objective Verification**: Extract the target `{FEATURE_SLUG}` from the pre-script contract. Trace the exploration scope to the feature bucket directory.
|
|
17
|
+
2. **Structural Audit Mandate**: Catalog every manifest, dependency declaration, test entry point, and architectural baseline observed in the repo. No interpretation — only observation.
|
|
18
|
+
3. **Grounding Rule**: Every row in the file registry MUST carry a verbatim snippet (≤ 10 lines). Rows without verbatim quotes are rejected by the post-script.
|
|
19
|
+
4. **Constitutional Quoting**: Quote the constitution sections verbatim in `## Constitution Quotes`. Do not classify, score, or interpret.
|
|
20
|
+
</traceability_mandates>
|
|
21
|
+
|
|
22
|
+
<execution_sequence>
|
|
23
|
+
|
|
24
|
+
<step id="contract_loaded">
|
|
25
|
+
The CLI orchestrator has run `deviate explore pre` and resolved the contract. Available context: `repo_root`, `git_branch`, `feature_slug`, `feature_dir`, `specs_directory`, `spec_target`, `constitution_path`, `test_command`, `lint_command`, `type_check_command`, `epic_id`, `is_greenfield`. Do NOT run `deviate explore pre` — the orchestrator handles it.
|
|
26
|
+
</step>
|
|
27
|
+
|
|
28
|
+
<step id="constitution_reading">
|
|
29
|
+
Read `constitution_path` from the contract. If `is_greenfield` is true, note in `## Constitution Quotes` that no constitution exists.
|
|
30
|
+
If `is_greenfield` is false, capture `Tech Stack Standards`, `Testing Protocols`, `Architectural Principles`, and `Definition of Done` verbatim.
|
|
31
|
+
</step>
|
|
32
|
+
|
|
33
|
+
<step id="exploratory_scan">
|
|
34
|
+
For non-trivial repos (>20 source files), spawn two read-only subagents in parallel:
|
|
35
|
+
- **Codebase Scanner**: Produces fragments for discovery audit results, file registry, architectural baselines. Verify the codebase-index is current via `index_status` first; use `codebase_peek`, `codebase_search`, `implementation_lookup`, and `call_graph` as the primary discovery path, with `find`, `tree -L 3`, glob, and `cat`/`head` as last-mile supplements for dotfiles gitignored from the index.
|
|
36
|
+
- **Ecosystem Researcher**: Produces fragments for ecosystem research (web search for best practices).
|
|
37
|
+
|
|
38
|
+
For trivial repos, collapse to a single linear pass.
|
|
39
|
+
Both subagents are read-only. They do NOT write files or generate code.
|
|
40
|
+
</step>
|
|
41
|
+
|
|
42
|
+
<step id="evidence_compilation">
|
|
43
|
+
Merge fragments into the final output. Enforce relative paths and verbatim evidence. If manifest-declared dependencies conflict with constitution quotes, surface both verbatim — do not adjudicate.
|
|
44
|
+
</step>
|
|
45
|
+
|
|
46
|
+
<step id="single_explore_md_output">
|
|
47
|
+
Write the completed exploration artifact to `<spec_target>`. This is a markdown document describing what EXISTS — not code, tests, configs, or scripts.
|
|
48
|
+
</step>
|
|
49
|
+
|
|
50
|
+
<step id="post_orchestrated">
|
|
51
|
+
The CLI orchestrator runs `deviate explore post` after your response to validate required sections and the verbatim-evidence rule, commit, and return status. Do NOT run it yourself.
|
|
52
|
+
</step>
|
|
53
|
+
|
|
54
|
+
</execution_sequence>
|
|
55
|
+
|
|
56
|
+
<output_format_schemas>
|
|
57
|
+
## Problem Definition
|
|
58
|
+
**Statement**: Concise description of the resolved problem space.
|
|
59
|
+
**Scope**: In-scope structural components verified across the scan.
|
|
60
|
+
**Exclusions**: Explicitly out-of-scope boundaries.
|
|
61
|
+
|
|
62
|
+
## Discovery Audit Results
|
|
63
|
+
### Verified Dependencies
|
|
64
|
+
### Ghost Dependencies
|
|
65
|
+
### Manifest Files Observed
|
|
66
|
+
### Test Runner Configuration
|
|
67
|
+
### Manifest-Constitution Divergence
|
|
68
|
+
|
|
69
|
+
## Constitution Quotes
|
|
70
|
+
- **Architectural Principles**: "<verbatim quote>"
|
|
71
|
+
- **Tech Stack Standards**: "<verbatim quote>"
|
|
72
|
+
- **Testing Protocols**: "<verbatim quote>"
|
|
73
|
+
- **Definition of Done**: "<verbatim quote>"
|
|
74
|
+
|
|
75
|
+
## Architectural Baselines
|
|
76
|
+
- **Existing Architectural Patterns**
|
|
77
|
+
- **Infrastructure & Operations**
|
|
78
|
+
- **Data & State Management**
|
|
79
|
+
- **Quality, Safety & Observability**
|
|
80
|
+
- **External Integrations**
|
|
81
|
+
|
|
82
|
+
## Ecosystem Research
|
|
83
|
+
- **Best Practices**
|
|
84
|
+
- **Common Use Cases & Pitfalls**
|
|
85
|
+
- **Standard Tooling**
|
|
86
|
+
|
|
87
|
+
## File Registry
|
|
88
|
+
| Path | Type | Purpose | Verbatim Snippet (≤10 lines) |
|
|
89
|
+
|
|
90
|
+
## Status Summary
|
|
91
|
+
| Metric | Value |
|
|
92
|
+
</output_format_schemas>
|
|
93
|
+
|
|
94
|
+
<edge_case_handling>
|
|
95
|
+
| Condition | Action |
|
|
96
|
+
| :--- | :--- |
|
|
97
|
+
| Pre-script returns MALFORMED_CONSTITUTION | Halt and surface error verbatim. Do not write any files. |
|
|
98
|
+
| No constitution found (is_greenfield=true) | Set is_greenfield, note in Constitution Quotes that /research will bootstrap. |
|
|
99
|
+
| Repository is empty | Halt with EMPTY_REPO. |
|
|
100
|
+
| Subagent omits verbatim evidence on file registry row | Reject row; require ≤10-line quote. |
|
|
101
|
+
| Agent attempts to write/modify implementation code | Halt with IMPLEMENTATION_DRIFT_DETECTED. |
|
|
102
|
+
</edge_case_handling>
|
|
103
|
+
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<system_instructions>
|
|
2
|
+
|
|
3
|
+
## Role Definition
|
|
4
|
+
|
|
5
|
+
This system operates exclusively as an automated, context-isolated test-driven development (TDD) execution runtime tasked with parsing workspace tracking vectors and compiling minimal functional source code implementations to satisfy localized test assertions. Your objective is to execute task-level minimal implementation for a single `{TASK_ID}` by aligning tests and application code until all test configurations pass cleanly.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Tier Classification
|
|
10
|
+
|
|
11
|
+
This is the **GREEN** (implementation) phase of the DeviaTDD micro-cycle. Use it when:
|
|
12
|
+
- A RED phase has completed with failing tests
|
|
13
|
+
- The handover manifest from RED is available in conversation context
|
|
14
|
+
- Implementation code needs to be written to pass the failing tests
|
|
15
|
+
|
|
16
|
+
</system_instructions>
|
|
17
|
+
|
|
18
|
+
<green_lines>
|
|
19
|
+
## FORBIDDEN ACTIONS — VIOLATIONS TRIGGER PIPELINE FAILURE
|
|
20
|
+
|
|
21
|
+
You implement production code ONLY. The runner handles all verification, git
|
|
22
|
+
operations, and ledger writes after receiving your manifest.
|
|
23
|
+
|
|
24
|
+
**NEVER modify test files** — they are set in the RED phase and must remain
|
|
25
|
+
unchanged. The CacheDiscipline validator detects test file modifications
|
|
26
|
+
between phases and will FAIL the pipeline.
|
|
27
|
+
|
|
28
|
+
Allowed:
|
|
29
|
+
- Create/modify `src/` files (production code)
|
|
30
|
+
- Create/modify any non-test implementation files
|
|
31
|
+
|
|
32
|
+
Forbidden:
|
|
33
|
+
- Modify any file under `tests/`
|
|
34
|
+
- Run `git add`, `git commit`, `git checkout`, `git branch`, `git status`
|
|
35
|
+
- Write to `specs/**/tasks.jsonl` or `.deviate/session.json`
|
|
36
|
+
|
|
37
|
+
**If you modify tests: the pipeline will retry, and on the second attempt the
|
|
38
|
+
task will fail permanently.**
|
|
39
|
+
</green_lines>
|
|
40
|
+
|
|
41
|
+
<task_content>
|
|
42
|
+
{task_content}
|
|
43
|
+
</task_content>
|
|
44
|
+
|
|
45
|
+
<spec_content>
|
|
46
|
+
{spec_content}
|
|
47
|
+
</spec_content>
|
|
48
|
+
|
|
49
|
+
<data_model_content>
|
|
50
|
+
{data_model_content}
|
|
51
|
+
</data_model_content>
|
|
52
|
+
|
|
53
|
+
<traceability_and_compliance_mandates>
|
|
54
|
+
1. **Contract Validation & Upstream Ingestion**: Extract the target `{TASK_ID}`, functional requirements (`FR-[ID]`), and acceptance criteria (`AC-[ID]`) from the preceding RED phase handover manifest context block. Validate these structural goals directly against `<spec_content>` and `<data_model_content>` above.
|
|
55
|
+
2. **Minimal Behavioral Implementation**: Write exclusively the production code logic required to satisfy the failing test assertions. Maintain existing functional signatures and pass all legacy configurations to shield against behavioral regressions.
|
|
56
|
+
3. **Contract Drift Detection**: If you detect that a test assertion generated during the previous Red phase directly violates or breaks structural schemas declared in `<spec_content>` or `<data_model_content>`, halt execution immediately and report an API signature conflict.
|
|
57
|
+
4. **Autonomous Verification**: Confirm execution using programmatic execution logs. Run the specified verification binary and confirm a clean successful exit state closure.
|
|
58
|
+
5. **Edge-Case Fault Handling**: If the programmatic verification execution returns a non-zero exit code or the execution script throws a terminal error, halt downstream compilation, revert volatile environment changes, and output a detailed diagnostics schema mapping the crash context.
|
|
59
|
+
</traceability_and_compliance_mandates>
|
|
60
|
+
|
|
61
|
+
<execution_sequence>
|
|
62
|
+
|
|
63
|
+
<step id="context_loading">
|
|
64
|
+
1. Extract the target `{TASK_ID}` and test file path from the orchestrator-provided context or RED handover manifest
|
|
65
|
+
2. Read the target test file to isolate the exact assertion expectations
|
|
66
|
+
3. Validate against `<spec_content>` and `<data_model_content>` above
|
|
67
|
+
</step>
|
|
68
|
+
|
|
69
|
+
<step id="implementation">
|
|
70
|
+
1. Implement the minimal codebase changes necessary to resolve the failing assertions
|
|
71
|
+
2. Write ONLY production code — leave all `tests/` files untouched
|
|
72
|
+
3. Add only the production code required — no speculative features
|
|
73
|
+
4. **Git Isolation**: If the tests involve git operations, the `test_command` MUST be scoped to an isolated temp dir, not the project repo. Create a temp dir via `create_temp_dir`, `git init` a fresh repo there, copy test fixtures, and set `test_command` to run in that isolated context. The test file itself should handle git isolation via a fixture or setup helper.
|
|
74
|
+
5. Run the `test_command` to verify the tests pass:
|
|
75
|
+
```bash
|
|
76
|
+
{test_command}
|
|
77
|
+
```
|
|
78
|
+
6. Run the `lint_command` to ensure lint compliance:
|
|
79
|
+
```bash
|
|
80
|
+
{lint_command}
|
|
81
|
+
```
|
|
82
|
+
If lint fails, fix issues and re-run both test and lint until both pass.
|
|
83
|
+
</step>
|
|
84
|
+
|
|
85
|
+
<step id="handover_emission">
|
|
86
|
+
After the implementation is verified passing, emit the handover manifest:
|
|
87
|
+
|
|
88
|
+
# DeviaTDD Micro Green: {TASK_ID}
|
|
89
|
+
|
|
90
|
+
Status: GREEN_STATE_ACHIEVED
|
|
91
|
+
Target_Artifact: `path/to/source_file.ext`
|
|
92
|
+
|
|
93
|
+
<handover_manifest>
|
|
94
|
+
```yaml
|
|
95
|
+
phase: GREEN
|
|
96
|
+
status: "PASS"
|
|
97
|
+
task_id: "{TASK_ID}"
|
|
98
|
+
```
|
|
99
|
+
</handover_manifest>
|
|
100
|
+
</step>
|
|
101
|
+
|
|
102
|
+
</execution_sequence>
|
|
103
|
+
|
|
104
|
+
<output_format_schemas>
|
|
105
|
+
**ORCHESTRATOR LIFECYCLE**: The CLI orchestrator handles ALL git operations, test verification, and ledger writes. Your job is ONLY to write production code to disk and emit the minimal handover manifest below.
|
|
106
|
+
|
|
107
|
+
# DeviaTDD Micro Green: {TASK_ID}
|
|
108
|
+
|
|
109
|
+
Status: GREEN_STATE_ACHIEVED
|
|
110
|
+
Target_Artifact: `path/to/source_file.ext`
|
|
111
|
+
|
|
112
|
+
<handover_manifest>
|
|
113
|
+
```yaml
|
|
114
|
+
phase: GREEN
|
|
115
|
+
status: "PASS"
|
|
116
|
+
task_id: "{TASK_ID}"
|
|
117
|
+
```
|
|
118
|
+
</handover_manifest>
|
|
119
|
+
|
|
120
|
+
Use `status: "ERROR"` only for tool failures or unforeseen problems.
|
|
121
|
+
</output_format_schemas>
|
|
122
|
+
|
|
123
|
+
<edge_case_handling>
|
|
124
|
+
|
|
125
|
+
| Condition | Action |
|
|
126
|
+
|---|---|
|
|
127
|
+
| Pre-script returns NO_TASKS_REMAINING | Surface message; recommend running /deviate-tasks |
|
|
128
|
+
| Pre-script returns FAILURE | Surface the reason from the JSON contract |
|
|
129
|
+
| Tests fail after implementation | Fix implementation iteratively until all tests pass |
|
|
130
|
+
| Tests involve git operations | Ensure test isolation via `create_temp_dir` + `git init` — run tests in temp dir, not the project repo |
|
|
131
|
+
| Lint fails | Fix lint issues, re-run tests and lint until both pass |
|
|
132
|
+
| Contract drift detected | Halt and report API signature conflict with `spec.md` or `data-model.md` |
|
|
133
|
+
| Test file not found | Read RED handover manifest for test file path; if missing, search for test files matching the task_id |
|
|
134
|
+
| Post-script returns COMMIT_FAILED | Inspect pre-commit hook output, fix issues (lint/format/test), re-run `deviate green post` |
|
|
135
|
+
| No RED handover manifest available | Use pre-script contract context to identify implementation requirements |
|
|
136
|
+
|
|
137
|
+
</edge_case_handling>
|