devflow-toolkit 0.3.0__py3-none-any.whl → 0.3.2__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.
- devflow/cli.py +5 -1
- devflow/commands/approve.py +1 -1
- devflow/commands/doctor.py +133 -0
- devflow/commands/init.py +34 -0
- devflow/commands/recover.py +78 -0
- devflow/commands/spec.py +20 -0
- devflow/core/config.py +66 -0
- devflow/core/discovery.py +43 -0
- devflow/core/recovery.py +259 -0
- devflow/core/spec_workflow.py +2 -0
- devflow/core/state/manager.py +3 -1
- devflow/prompts/__init__.py +16 -0
- devflow/prompts/spec.greenfield.md +4 -0
- devflow/prompts/spec.md +4 -0
- {devflow_toolkit-0.3.0.dist-info → devflow_toolkit-0.3.2.dist-info}/METADATA +65 -7
- {devflow_toolkit-0.3.0.dist-info → devflow_toolkit-0.3.2.dist-info}/RECORD +19 -16
- {devflow_toolkit-0.3.0.dist-info → devflow_toolkit-0.3.2.dist-info}/WHEEL +0 -0
- {devflow_toolkit-0.3.0.dist-info → devflow_toolkit-0.3.2.dist-info}/entry_points.txt +0 -0
- {devflow_toolkit-0.3.0.dist-info → devflow_toolkit-0.3.2.dist-info}/licenses/LICENSE +0 -0
devflow/cli.py
CHANGED
|
@@ -6,7 +6,9 @@ import typer
|
|
|
6
6
|
from rich.console import Console
|
|
7
7
|
|
|
8
8
|
from devflow.commands.approve import approve as approve_command
|
|
9
|
+
from devflow.commands.doctor import doctor as doctor_command
|
|
9
10
|
from devflow.commands.init import init as init_command
|
|
11
|
+
from devflow.commands.recover import recover as recover_command
|
|
10
12
|
from devflow.commands.spec import spec as spec_command
|
|
11
13
|
from devflow.commands.status import status as status_command
|
|
12
14
|
|
|
@@ -23,6 +25,8 @@ app.command("init")(init_command)
|
|
|
23
25
|
app.command("spec")(spec_command)
|
|
24
26
|
app.command("approve")(approve_command)
|
|
25
27
|
app.command("status")(status_command)
|
|
28
|
+
app.command("doctor")(doctor_command)
|
|
29
|
+
app.command("recover")(recover_command)
|
|
26
30
|
|
|
27
31
|
|
|
28
32
|
@app.command()
|
|
@@ -31,7 +35,7 @@ def version() -> None:
|
|
|
31
35
|
try:
|
|
32
36
|
current_version = package_version("devflow-toolkit")
|
|
33
37
|
except PackageNotFoundError:
|
|
34
|
-
current_version = "0.3.
|
|
38
|
+
current_version = "0.3.2"
|
|
35
39
|
console.print(f"DevFlow v{current_version}")
|
|
36
40
|
|
|
37
41
|
|
devflow/commands/approve.py
CHANGED
|
@@ -57,7 +57,7 @@ def _approve(spec_id: str, path: Path, stage: str) -> None:
|
|
|
57
57
|
normalized = stage.strip().lower()
|
|
58
58
|
if normalized != "spec":
|
|
59
59
|
msg = (
|
|
60
|
-
f"Stage '{stage}' is not available in DevFlow 0.3.
|
|
60
|
+
f"Stage '{stage}' is not available in DevFlow 0.3.2. "
|
|
61
61
|
"Only the 'spec' stage can be approved."
|
|
62
62
|
)
|
|
63
63
|
raise UnsupportedStageError(msg)
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""Implementation of the devflow doctor command."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
from rich.console import Console
|
|
9
|
+
|
|
10
|
+
from devflow.core.artifacts.errors import ArtifactError
|
|
11
|
+
from devflow.core.config import ConfigError, ConfigManager
|
|
12
|
+
from devflow.core.discovery import DiscoveryError
|
|
13
|
+
from devflow.core.project import ProjectDetector
|
|
14
|
+
from devflow.core.recovery import ChangeInspection, inspect_change
|
|
15
|
+
from devflow.core.state import StateError, WorkflowLocator
|
|
16
|
+
|
|
17
|
+
console = Console()
|
|
18
|
+
error_console = Console(stderr=True)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def doctor(
|
|
22
|
+
spec_id: str = typer.Argument(
|
|
23
|
+
...,
|
|
24
|
+
help="Change id (001) or change directory (001-add-health).",
|
|
25
|
+
),
|
|
26
|
+
path: Path = typer.Argument(
|
|
27
|
+
Path("."),
|
|
28
|
+
help="Project root or a path inside it.",
|
|
29
|
+
),
|
|
30
|
+
) -> None:
|
|
31
|
+
"""Diagnose a change, including artifacts written without state."""
|
|
32
|
+
try:
|
|
33
|
+
healthy = _doctor(spec_id, path)
|
|
34
|
+
except (
|
|
35
|
+
ArtifactError,
|
|
36
|
+
ConfigError,
|
|
37
|
+
DiscoveryError,
|
|
38
|
+
StateError,
|
|
39
|
+
FileNotFoundError,
|
|
40
|
+
NotADirectoryError,
|
|
41
|
+
OSError,
|
|
42
|
+
) as error:
|
|
43
|
+
error_console.print(f"[red]Error:[/red] {error}")
|
|
44
|
+
raise typer.Exit(code=1) from error
|
|
45
|
+
if not healthy:
|
|
46
|
+
raise typer.Exit(code=1)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _doctor(spec_id: str, path: Path) -> bool:
|
|
50
|
+
root = ProjectDetector().find_root(path)
|
|
51
|
+
config = ConfigManager(root).load()
|
|
52
|
+
location = WorkflowLocator(config.specifications_path).find(spec_id)
|
|
53
|
+
inspection = inspect_change(config, location)
|
|
54
|
+
|
|
55
|
+
console.print(f"[bold]Change:[/bold] {location.change}")
|
|
56
|
+
console.print(f"[bold]Directory:[/bold] {location.directory}")
|
|
57
|
+
console.print(
|
|
58
|
+
"[bold]Workflow:[/bold] "
|
|
59
|
+
+ (
|
|
60
|
+
f"present ({inspection.workflow_status})"
|
|
61
|
+
if inspection.workflow_present
|
|
62
|
+
else "[yellow]missing[/yellow]"
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
console.print(
|
|
66
|
+
"[bold]Events:[/bold] "
|
|
67
|
+
+ ("present" if inspection.events_present else "[yellow]missing[/yellow]")
|
|
68
|
+
)
|
|
69
|
+
_print_discovery(inspection)
|
|
70
|
+
_print_spec(inspection)
|
|
71
|
+
|
|
72
|
+
if inspection.warnings:
|
|
73
|
+
console.print("\n[bold]Warnings[/bold]")
|
|
74
|
+
for warning in inspection.warnings:
|
|
75
|
+
console.print(f"[yellow]- {warning}[/yellow]")
|
|
76
|
+
if inspection.orphans:
|
|
77
|
+
console.print("\n[bold]Orphan artifacts[/bold]")
|
|
78
|
+
for orphan in inspection.orphans:
|
|
79
|
+
console.print(f"[yellow]- {orphan} is not registered[/yellow]")
|
|
80
|
+
|
|
81
|
+
if inspection.healthy:
|
|
82
|
+
console.print("\n[bold green]Diagnosis: healthy.[/bold green]")
|
|
83
|
+
return True
|
|
84
|
+
|
|
85
|
+
if inspection.can_recover:
|
|
86
|
+
console.print(
|
|
87
|
+
"\n[bold yellow]Diagnosis: recoverable without regenerating the "
|
|
88
|
+
"artifacts.[/bold yellow]"
|
|
89
|
+
)
|
|
90
|
+
console.print(
|
|
91
|
+
"[bold]Next:[/bold] "
|
|
92
|
+
f"devflow recover {location.spec_id} {root}"
|
|
93
|
+
)
|
|
94
|
+
else:
|
|
95
|
+
console.print(
|
|
96
|
+
"\n[bold yellow]Diagnosis: needs attention.[/bold yellow]"
|
|
97
|
+
)
|
|
98
|
+
console.print(
|
|
99
|
+
"[dim]Resolve the issues above before approving or continuing "
|
|
100
|
+
"this change.[/dim]"
|
|
101
|
+
)
|
|
102
|
+
return False
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _print_discovery(inspection: ChangeInspection) -> None:
|
|
106
|
+
console.print("\n[bold]Discovery[/bold]")
|
|
107
|
+
if not inspection.discovery_present:
|
|
108
|
+
console.print(" [yellow]missing discovery.yaml[/yellow]")
|
|
109
|
+
return
|
|
110
|
+
if inspection.discovery_error:
|
|
111
|
+
console.print(
|
|
112
|
+
f" [yellow]invalid: {inspection.discovery_error}[/yellow]"
|
|
113
|
+
)
|
|
114
|
+
return
|
|
115
|
+
console.print(
|
|
116
|
+
f" status: {inspection.discovery_status} · "
|
|
117
|
+
f"digest: {inspection.discovery_digest}"
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _print_spec(inspection: ChangeInspection) -> None:
|
|
122
|
+
console.print("\n[bold]Specification[/bold]")
|
|
123
|
+
if not inspection.spec_present:
|
|
124
|
+
console.print(" [yellow]missing spec.md[/yellow]")
|
|
125
|
+
return
|
|
126
|
+
if inspection.spec_valid:
|
|
127
|
+
console.print(
|
|
128
|
+
f" valid · digest: {inspection.spec_digest}"
|
|
129
|
+
)
|
|
130
|
+
else:
|
|
131
|
+
console.print(
|
|
132
|
+
f" [yellow]invalid: {inspection.spec_error}[/yellow]"
|
|
133
|
+
)
|
devflow/commands/init.py
CHANGED
|
@@ -22,10 +22,12 @@ from devflow.core.architecture import (
|
|
|
22
22
|
create_architecture_template,
|
|
23
23
|
)
|
|
24
24
|
from devflow.core.config import (
|
|
25
|
+
DEFAULT_DOCUMENTATION_LANGUAGE,
|
|
25
26
|
EXECUTION_MODES,
|
|
26
27
|
ConfigError,
|
|
27
28
|
ConfigManager,
|
|
28
29
|
DevFlowConfig,
|
|
30
|
+
canonical_documentation_language,
|
|
29
31
|
canonical_execution_mode,
|
|
30
32
|
)
|
|
31
33
|
from devflow.core.constitution import Constitution, ConstitutionLoader
|
|
@@ -94,6 +96,13 @@ def init(
|
|
|
94
96
|
"Default specification context: existing or greenfield."
|
|
95
97
|
),
|
|
96
98
|
),
|
|
99
|
+
language: Optional[str] = typer.Option(
|
|
100
|
+
None,
|
|
101
|
+
"--language",
|
|
102
|
+
help=(
|
|
103
|
+
"Language for specification prose, for example en, es or es-MX."
|
|
104
|
+
),
|
|
105
|
+
),
|
|
97
106
|
) -> None:
|
|
98
107
|
"""Initialize DevFlow in a project."""
|
|
99
108
|
try:
|
|
@@ -106,6 +115,7 @@ def init(
|
|
|
106
115
|
mode,
|
|
107
116
|
no_agent,
|
|
108
117
|
project_mode,
|
|
118
|
+
language,
|
|
109
119
|
)
|
|
110
120
|
except (
|
|
111
121
|
ArchitectureError,
|
|
@@ -128,10 +138,19 @@ def _initialize(
|
|
|
128
138
|
mode: Optional[str],
|
|
129
139
|
no_agent: bool,
|
|
130
140
|
project_mode: Optional[str],
|
|
141
|
+
language: Optional[str],
|
|
131
142
|
) -> None:
|
|
132
143
|
requested_harness = _requested_harness(harness, no_agent)
|
|
133
144
|
execution_mode = _requested_mode(mode)
|
|
134
145
|
requested_project_mode = _requested_project_mode(project_mode)
|
|
146
|
+
requested_language = (
|
|
147
|
+
canonical_documentation_language(language)
|
|
148
|
+
if language is not None
|
|
149
|
+
else DEFAULT_DOCUMENTATION_LANGUAGE
|
|
150
|
+
)
|
|
151
|
+
if not requested_language:
|
|
152
|
+
msg = "The documentation language cannot be empty."
|
|
153
|
+
raise ConfigError(msg)
|
|
135
154
|
|
|
136
155
|
root = path.resolve()
|
|
137
156
|
if not root.exists():
|
|
@@ -176,6 +195,8 @@ def _initialize(
|
|
|
176
195
|
mode_override=mode is not None,
|
|
177
196
|
project_mode=requested_project_mode,
|
|
178
197
|
project_mode_override=project_mode is not None,
|
|
198
|
+
language=requested_language,
|
|
199
|
+
language_override=language is not None,
|
|
179
200
|
allow_prompt=not yes and sys.stdin.isatty(),
|
|
180
201
|
)
|
|
181
202
|
return
|
|
@@ -209,6 +230,7 @@ def _initialize(
|
|
|
209
230
|
project_mode=requested_project_mode,
|
|
210
231
|
agent_harness=requested_harness,
|
|
211
232
|
execution_mode=execution_mode,
|
|
233
|
+
documentation_language=requested_language,
|
|
212
234
|
)
|
|
213
235
|
config_manager.ensure_directories(config)
|
|
214
236
|
_ensure_architecture_template(config, requested_project_mode)
|
|
@@ -231,6 +253,10 @@ def _initialize(
|
|
|
231
253
|
console.print(
|
|
232
254
|
f"[bold]Project mode:[/bold] {config.project_mode}"
|
|
233
255
|
)
|
|
256
|
+
console.print(
|
|
257
|
+
f"[bold]Documentation language:[/bold] "
|
|
258
|
+
f"{config.documentation_language}"
|
|
259
|
+
)
|
|
234
260
|
console.print(
|
|
235
261
|
"[bold]Detected profiles:[/bold] "
|
|
236
262
|
+ (", ".join(detected_names) or "none")
|
|
@@ -290,6 +316,8 @@ def _refresh_existing(
|
|
|
290
316
|
mode_override: bool,
|
|
291
317
|
project_mode: str,
|
|
292
318
|
project_mode_override: bool,
|
|
319
|
+
language: str,
|
|
320
|
+
language_override: bool,
|
|
293
321
|
allow_prompt: bool,
|
|
294
322
|
) -> None:
|
|
295
323
|
if explicit_profiles:
|
|
@@ -316,6 +344,8 @@ def _refresh_existing(
|
|
|
316
344
|
)
|
|
317
345
|
if project_mode_override:
|
|
318
346
|
config = config_manager.set_project_mode(project_mode)
|
|
347
|
+
if language_override:
|
|
348
|
+
config = config_manager.set_documentation_language(language)
|
|
319
349
|
|
|
320
350
|
profiles = profile_manager.resolve(configured)
|
|
321
351
|
installed = profile_manager.install_constitution(
|
|
@@ -344,6 +374,10 @@ def _refresh_existing(
|
|
|
344
374
|
console.print(
|
|
345
375
|
f"[bold]Project mode:[/bold] {config.project_mode}"
|
|
346
376
|
)
|
|
377
|
+
console.print(
|
|
378
|
+
f"[bold]Documentation language:[/bold] "
|
|
379
|
+
f"{config.documentation_language}"
|
|
380
|
+
)
|
|
347
381
|
if installed.copied:
|
|
348
382
|
console.print(
|
|
349
383
|
"[green]Missing constitution files restored:[/green] "
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""Implementation of the devflow recover command."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
from rich.console import Console
|
|
9
|
+
|
|
10
|
+
from devflow.core.artifacts.errors import ArtifactError
|
|
11
|
+
from devflow.core.config import ConfigError, ConfigManager
|
|
12
|
+
from devflow.core.discovery import DiscoveryError
|
|
13
|
+
from devflow.core.project import ProjectDetector
|
|
14
|
+
from devflow.core.recovery import recover_change
|
|
15
|
+
from devflow.core.state import StateError, WorkflowLocator
|
|
16
|
+
|
|
17
|
+
console = Console()
|
|
18
|
+
error_console = Console(stderr=True)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def recover(
|
|
22
|
+
spec_id: str = typer.Argument(
|
|
23
|
+
...,
|
|
24
|
+
help="Change id (001) or change directory (001-add-health).",
|
|
25
|
+
),
|
|
26
|
+
path: Path = typer.Argument(
|
|
27
|
+
Path("."),
|
|
28
|
+
help="Project root or a path inside it.",
|
|
29
|
+
),
|
|
30
|
+
) -> None:
|
|
31
|
+
"""Register existing valid artifacts in a missing workflow state."""
|
|
32
|
+
try:
|
|
33
|
+
_recover(spec_id, path)
|
|
34
|
+
except (
|
|
35
|
+
ArtifactError,
|
|
36
|
+
ConfigError,
|
|
37
|
+
DiscoveryError,
|
|
38
|
+
StateError,
|
|
39
|
+
FileNotFoundError,
|
|
40
|
+
NotADirectoryError,
|
|
41
|
+
OSError,
|
|
42
|
+
) as error:
|
|
43
|
+
error_console.print(f"[red]Error:[/red] {error}")
|
|
44
|
+
raise typer.Exit(code=1) from error
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _recover(spec_id: str, path: Path) -> None:
|
|
48
|
+
root = ProjectDetector().find_root(path)
|
|
49
|
+
config = ConfigManager(root).load()
|
|
50
|
+
location = WorkflowLocator(config.specifications_path).find(spec_id)
|
|
51
|
+
result = recover_change(config, location)
|
|
52
|
+
|
|
53
|
+
if not result.recovered:
|
|
54
|
+
console.print(
|
|
55
|
+
f"[bold]{location.change}[/bold] already has workflow state "
|
|
56
|
+
f"([bold]{result.state.status}[/bold]). Nothing to recover."
|
|
57
|
+
)
|
|
58
|
+
console.print(
|
|
59
|
+
f"[dim]Run 'devflow status {location.spec_id}' to inspect it.[/dim]"
|
|
60
|
+
)
|
|
61
|
+
return
|
|
62
|
+
|
|
63
|
+
console.print(
|
|
64
|
+
f"[bold green]Recovered[/bold green] {location.change} without "
|
|
65
|
+
"regenerating its artifacts."
|
|
66
|
+
)
|
|
67
|
+
console.print(f"Workflow status: {result.state.status}")
|
|
68
|
+
console.print(
|
|
69
|
+
"Registered: discovery "
|
|
70
|
+
f"{result.inspection.discovery_digest}"
|
|
71
|
+
)
|
|
72
|
+
console.print(
|
|
73
|
+
f"Registered: spec {result.inspection.spec_digest}"
|
|
74
|
+
)
|
|
75
|
+
console.print(
|
|
76
|
+
"\n[bold]Next:[/bold] review the specification, then run "
|
|
77
|
+
f"'devflow approve {location.spec_id}'."
|
|
78
|
+
)
|
devflow/commands/spec.py
CHANGED
|
@@ -23,6 +23,7 @@ from devflow.core.config import (
|
|
|
23
23
|
ConfigError,
|
|
24
24
|
ConfigManager,
|
|
25
25
|
DevFlowConfig,
|
|
26
|
+
canonical_documentation_language,
|
|
26
27
|
canonical_execution_mode,
|
|
27
28
|
)
|
|
28
29
|
from devflow.core.constitution import ConstitutionError
|
|
@@ -94,6 +95,14 @@ def spec(
|
|
|
94
95
|
"Does not create a new specification."
|
|
95
96
|
),
|
|
96
97
|
),
|
|
98
|
+
language: Optional[str] = typer.Option(
|
|
99
|
+
None,
|
|
100
|
+
"--language",
|
|
101
|
+
help=(
|
|
102
|
+
"Language for specification prose, for example en, es or es-MX. "
|
|
103
|
+
"Defaults to the configured language."
|
|
104
|
+
),
|
|
105
|
+
),
|
|
97
106
|
) -> None:
|
|
98
107
|
"""Generate or resume a specification for a change request."""
|
|
99
108
|
try:
|
|
@@ -105,6 +114,7 @@ def spec(
|
|
|
105
114
|
no_agent,
|
|
106
115
|
project_mode,
|
|
107
116
|
continue_id,
|
|
117
|
+
language,
|
|
108
118
|
)
|
|
109
119
|
except (
|
|
110
120
|
ArchitectureError,
|
|
@@ -131,6 +141,7 @@ def _create_specification(
|
|
|
131
141
|
no_agent: bool,
|
|
132
142
|
project_mode: Optional[str],
|
|
133
143
|
continue_id: Optional[str],
|
|
144
|
+
language: Optional[str] = None,
|
|
134
145
|
) -> None:
|
|
135
146
|
request = (description or "").strip()
|
|
136
147
|
resume = (continue_id or "").strip() or None
|
|
@@ -171,6 +182,14 @@ def _create_specification(
|
|
|
171
182
|
effective_project_mode = _project_mode(
|
|
172
183
|
project_mode or config.project_mode,
|
|
173
184
|
)
|
|
185
|
+
documentation_language = (
|
|
186
|
+
canonical_documentation_language(language)
|
|
187
|
+
if language is not None
|
|
188
|
+
else config.documentation_language
|
|
189
|
+
)
|
|
190
|
+
if not documentation_language:
|
|
191
|
+
msg = "The documentation language cannot be empty."
|
|
192
|
+
raise ConfigError(msg)
|
|
174
193
|
|
|
175
194
|
allow_prompt = sys.stdin.isatty()
|
|
176
195
|
selected_harness, selection_warnings = resolve_harness(
|
|
@@ -190,6 +209,7 @@ def _create_specification(
|
|
|
190
209
|
warnings=tuple([*mode_warnings, *selection_warnings]),
|
|
191
210
|
project_mode=effective_project_mode,
|
|
192
211
|
continue_spec_id=resume,
|
|
212
|
+
language=documentation_language,
|
|
193
213
|
)
|
|
194
214
|
)
|
|
195
215
|
|
devflow/core/config.py
CHANGED
|
@@ -22,6 +22,25 @@ DEFAULT_CONSTITUTION_PATH = Path(".devflow") / "constitution"
|
|
|
22
22
|
DEFAULT_SPECIFICATIONS_PATH = Path(".devflow") / "specs"
|
|
23
23
|
DEFAULT_PLANS_PATH = Path(".devflow") / "plans"
|
|
24
24
|
DEFAULT_TEMPLATES_PATH = Path(".devflow") / "templates"
|
|
25
|
+
DEFAULT_DOCUMENTATION_LANGUAGE = "en"
|
|
26
|
+
|
|
27
|
+
_LANGUAGE_ALIASES = {
|
|
28
|
+
"aleman": "de",
|
|
29
|
+
"alemán": "de",
|
|
30
|
+
"english": "en",
|
|
31
|
+
"espanol": "es",
|
|
32
|
+
"español": "es",
|
|
33
|
+
"frances": "fr",
|
|
34
|
+
"francés": "fr",
|
|
35
|
+
"german": "de",
|
|
36
|
+
"ingles": "en",
|
|
37
|
+
"inglés": "en",
|
|
38
|
+
"italian": "it",
|
|
39
|
+
"italiano": "it",
|
|
40
|
+
"portugues": "pt",
|
|
41
|
+
"português": "pt",
|
|
42
|
+
"spanish": "es",
|
|
43
|
+
}
|
|
25
44
|
|
|
26
45
|
SUPPORTED_HARNESSES = (
|
|
27
46
|
"auto",
|
|
@@ -74,6 +93,12 @@ def canonical_harness_name(value: str) -> str:
|
|
|
74
93
|
return _HARNESS_ALIASES.get(normalized, normalized)
|
|
75
94
|
|
|
76
95
|
|
|
96
|
+
def canonical_documentation_language(value: str) -> str:
|
|
97
|
+
"""Normalize a documentation language name or common alias."""
|
|
98
|
+
normalized = value.strip().lower()
|
|
99
|
+
return _LANGUAGE_ALIASES.get(normalized, normalized)
|
|
100
|
+
|
|
101
|
+
|
|
77
102
|
def canonical_execution_mode(value: str) -> str:
|
|
78
103
|
"""Normalize an execution mode name."""
|
|
79
104
|
normalized = value.strip().lower().replace("_", "-")
|
|
@@ -193,6 +218,7 @@ class DevFlowConfig:
|
|
|
193
218
|
specifications_path: Path
|
|
194
219
|
plans_path: Path
|
|
195
220
|
templates_path: Path
|
|
221
|
+
documentation_language: str
|
|
196
222
|
agent: AgentSettings
|
|
197
223
|
|
|
198
224
|
@property
|
|
@@ -260,6 +286,10 @@ class ConfigManager:
|
|
|
260
286
|
data.get("templates", {}),
|
|
261
287
|
"templates",
|
|
262
288
|
)
|
|
289
|
+
documentation = self._mapping(
|
|
290
|
+
data.get("documentation", {}),
|
|
291
|
+
"documentation",
|
|
292
|
+
)
|
|
263
293
|
agent = self._mapping(data.get("agent", {}), "agent")
|
|
264
294
|
agent_settings = self._agent_settings(agent)
|
|
265
295
|
|
|
@@ -290,6 +320,17 @@ class ConfigManager:
|
|
|
290
320
|
|
|
291
321
|
technologies = self._technologies(data.get("technologies", {}))
|
|
292
322
|
|
|
323
|
+
language_value = documentation.get(
|
|
324
|
+
"language",
|
|
325
|
+
DEFAULT_DOCUMENTATION_LANGUAGE,
|
|
326
|
+
)
|
|
327
|
+
if not isinstance(language_value, str) or not language_value.strip():
|
|
328
|
+
msg = "documentation.language must be a non-empty string."
|
|
329
|
+
raise ConfigError(msg)
|
|
330
|
+
documentation_language = canonical_documentation_language(
|
|
331
|
+
language_value,
|
|
332
|
+
)
|
|
333
|
+
|
|
293
334
|
name = project.get("name", self.root.name)
|
|
294
335
|
project_type = project.get("type", "unknown")
|
|
295
336
|
project_mode = canonical_project_mode(
|
|
@@ -336,6 +377,7 @@ class ConfigManager:
|
|
|
336
377
|
specifications_path=specifications_path,
|
|
337
378
|
plans_path=plans_path,
|
|
338
379
|
templates_path=templates_path,
|
|
380
|
+
documentation_language=documentation_language,
|
|
339
381
|
agent=agent_settings,
|
|
340
382
|
)
|
|
341
383
|
|
|
@@ -349,6 +391,7 @@ class ConfigManager:
|
|
|
349
391
|
agent_harness: str = "auto",
|
|
350
392
|
execution_mode: str = "interactive",
|
|
351
393
|
permissions: AgentPermissions | None = None,
|
|
394
|
+
documentation_language: str = DEFAULT_DOCUMENTATION_LANGUAGE,
|
|
352
395
|
) -> DevFlowConfig:
|
|
353
396
|
"""Create and persist a configuration for a project."""
|
|
354
397
|
normalized_project_mode = canonical_project_mode(project_mode)
|
|
@@ -373,6 +416,10 @@ class ConfigManager:
|
|
|
373
416
|
)
|
|
374
417
|
raise ConfigError(msg)
|
|
375
418
|
agent_permissions = permissions or AgentPermissions()
|
|
419
|
+
language = canonical_documentation_language(documentation_language)
|
|
420
|
+
if not language:
|
|
421
|
+
msg = "documentation language must be a non-empty string."
|
|
422
|
+
raise ConfigError(msg)
|
|
376
423
|
validated_files = [
|
|
377
424
|
validate_document_name(filename, "constitution_files")
|
|
378
425
|
for filename in constitution_files
|
|
@@ -405,6 +452,9 @@ class ConfigManager:
|
|
|
405
452
|
"templates": {
|
|
406
453
|
"path": DEFAULT_TEMPLATES_PATH.as_posix(),
|
|
407
454
|
},
|
|
455
|
+
"documentation": {
|
|
456
|
+
"language": language,
|
|
457
|
+
},
|
|
408
458
|
"agent": {
|
|
409
459
|
"harness": harness,
|
|
410
460
|
"execution": {
|
|
@@ -482,6 +532,22 @@ class ConfigManager:
|
|
|
482
532
|
execution_mode=execution_mode,
|
|
483
533
|
)
|
|
484
534
|
|
|
535
|
+
def set_documentation_language(self, language: str) -> DevFlowConfig:
|
|
536
|
+
"""Persist the language used for specification prose."""
|
|
537
|
+
normalized = canonical_documentation_language(language)
|
|
538
|
+
if not normalized:
|
|
539
|
+
msg = "documentation language must be a non-empty string."
|
|
540
|
+
raise ConfigError(msg)
|
|
541
|
+
|
|
542
|
+
data = self._read_document()
|
|
543
|
+
documentation = data.get("documentation")
|
|
544
|
+
if not isinstance(documentation, dict):
|
|
545
|
+
documentation = {}
|
|
546
|
+
data["documentation"] = documentation
|
|
547
|
+
documentation["language"] = normalized
|
|
548
|
+
self._write_document(data)
|
|
549
|
+
return self.load()
|
|
550
|
+
|
|
485
551
|
def set_project_mode(self, project_mode: str) -> DevFlowConfig:
|
|
486
552
|
"""Persist the default project mode used by the next spec runs."""
|
|
487
553
|
normalized = canonical_project_mode(project_mode)
|
devflow/core/discovery.py
CHANGED
|
@@ -208,6 +208,30 @@ _DATA_WORDS = {
|
|
|
208
208
|
"tabla",
|
|
209
209
|
"table",
|
|
210
210
|
}
|
|
211
|
+
_COMMENT_WORDS = {
|
|
212
|
+
"comment",
|
|
213
|
+
"comments",
|
|
214
|
+
"comentario",
|
|
215
|
+
"comentarios",
|
|
216
|
+
}
|
|
217
|
+
_COMMENT_DECISION_WORDS = {
|
|
218
|
+
"anonymous",
|
|
219
|
+
"anonimo",
|
|
220
|
+
"auth",
|
|
221
|
+
"authenticated",
|
|
222
|
+
"autenticacion",
|
|
223
|
+
"authentication",
|
|
224
|
+
"authorization",
|
|
225
|
+
"autorizacion",
|
|
226
|
+
"login",
|
|
227
|
+
"moderacion",
|
|
228
|
+
"moderation",
|
|
229
|
+
"moderator",
|
|
230
|
+
"permission",
|
|
231
|
+
"permiso",
|
|
232
|
+
"usuario",
|
|
233
|
+
"user",
|
|
234
|
+
}
|
|
211
235
|
_PERSISTENCE_DECISIONS = {
|
|
212
236
|
"archivo",
|
|
213
237
|
"database",
|
|
@@ -1079,6 +1103,25 @@ class DiscoveryPlanner:
|
|
|
1079
1103
|
)
|
|
1080
1104
|
)
|
|
1081
1105
|
|
|
1106
|
+
if (
|
|
1107
|
+
words & _COMMENT_WORDS
|
|
1108
|
+
and not (words & _COMMENT_DECISION_WORDS)
|
|
1109
|
+
):
|
|
1110
|
+
add_question(
|
|
1111
|
+
"security_authentication",
|
|
1112
|
+
"Who may create, edit or delete comments, and how are they "
|
|
1113
|
+
"identified?",
|
|
1114
|
+
"Comment ownership, authentication and moderation change "
|
|
1115
|
+
"permissions, data fields and API behavior.",
|
|
1116
|
+
(
|
|
1117
|
+
"Any visitor may comment without authentication.",
|
|
1118
|
+
"Only authenticated users may comment.",
|
|
1119
|
+
"Only authenticated users may comment, edit or delete their "
|
|
1120
|
+
"own comments.",
|
|
1121
|
+
"Comments require review before publication.",
|
|
1122
|
+
),
|
|
1123
|
+
)
|
|
1124
|
+
|
|
1082
1125
|
if (
|
|
1083
1126
|
words & _DATA_WORDS
|
|
1084
1127
|
and not project.databases
|
devflow/core/recovery.py
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"""Inspect and recover changes written without workflow state."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
from devflow.core.architecture import (
|
|
8
|
+
ArchitectureError,
|
|
9
|
+
ArchitectureManifest,
|
|
10
|
+
ArchitectureManifestLoader,
|
|
11
|
+
)
|
|
12
|
+
from devflow.core.artifacts.errors import ArtifactError
|
|
13
|
+
from devflow.core.artifacts.store import ArtifactStore
|
|
14
|
+
from devflow.core.config import DevFlowConfig
|
|
15
|
+
from devflow.core.discovery import DiscoveryError, DiscoveryManager
|
|
16
|
+
from devflow.core.specification import SpecificationManager
|
|
17
|
+
from devflow.core.state import (
|
|
18
|
+
ChangeLocation,
|
|
19
|
+
StateError,
|
|
20
|
+
WorkflowLocator,
|
|
21
|
+
WorkflowStateManager,
|
|
22
|
+
)
|
|
23
|
+
from devflow.core.state.models import WorkflowState
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(frozen=True)
|
|
27
|
+
class ChangeInspection:
|
|
28
|
+
"""Read-only diagnostic view of one change directory."""
|
|
29
|
+
|
|
30
|
+
location: ChangeLocation
|
|
31
|
+
events_present: bool
|
|
32
|
+
workflow_present: bool
|
|
33
|
+
workflow_status: str
|
|
34
|
+
discovery_present: bool
|
|
35
|
+
discovery_complete: bool
|
|
36
|
+
discovery_status: str
|
|
37
|
+
discovery_digest: str
|
|
38
|
+
discovery_error: str
|
|
39
|
+
spec_present: bool
|
|
40
|
+
spec_valid: bool
|
|
41
|
+
spec_digest: str
|
|
42
|
+
spec_error: str
|
|
43
|
+
architecture_digest: str
|
|
44
|
+
warnings: tuple[str, ...] = ()
|
|
45
|
+
orphans: tuple[str, ...] = ()
|
|
46
|
+
can_recover: bool = False
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def healthy(self) -> bool:
|
|
50
|
+
"""Return whether the change has a complete, current workflow."""
|
|
51
|
+
return (
|
|
52
|
+
self.events_present
|
|
53
|
+
and self.workflow_present
|
|
54
|
+
and not self.warnings
|
|
55
|
+
and not self.orphans
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@dataclass(frozen=True)
|
|
60
|
+
class RecoveryResult:
|
|
61
|
+
"""Outcome of registering orphaned artifacts."""
|
|
62
|
+
|
|
63
|
+
inspection: ChangeInspection
|
|
64
|
+
state: WorkflowState
|
|
65
|
+
recovered: bool = True
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def inspect_change(
|
|
69
|
+
config: DevFlowConfig,
|
|
70
|
+
location: ChangeLocation,
|
|
71
|
+
) -> ChangeInspection:
|
|
72
|
+
"""Inspect workflow, Discovery and specification without repairing."""
|
|
73
|
+
store = ArtifactStore(config.root)
|
|
74
|
+
manager = WorkflowStateManager(
|
|
75
|
+
config.specifications_path,
|
|
76
|
+
project_root=config.root,
|
|
77
|
+
)
|
|
78
|
+
events_present = location.events_path.is_file()
|
|
79
|
+
workflow_present = location.workflow_path.is_file()
|
|
80
|
+
warnings: list[str] = []
|
|
81
|
+
orphans: tuple[str, ...] = ()
|
|
82
|
+
workflow_status = ""
|
|
83
|
+
|
|
84
|
+
if events_present:
|
|
85
|
+
try:
|
|
86
|
+
current = manager.status(location)
|
|
87
|
+
except StateError as error:
|
|
88
|
+
warnings.append(str(error))
|
|
89
|
+
else:
|
|
90
|
+
workflow_status = current.state.status
|
|
91
|
+
warnings.extend(current.warnings)
|
|
92
|
+
orphans = current.orphans
|
|
93
|
+
elif workflow_present:
|
|
94
|
+
warnings.append(
|
|
95
|
+
"workflow.yaml exists without events.jsonl; the projection cannot "
|
|
96
|
+
"be trusted. Restore the event log or remove the orphan projection."
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
discovery_path = location.directory / "discovery.yaml"
|
|
100
|
+
discovery_present = discovery_path.is_file()
|
|
101
|
+
discovery_complete = False
|
|
102
|
+
discovery_status = ""
|
|
103
|
+
discovery_digest = ""
|
|
104
|
+
discovery_error = ""
|
|
105
|
+
if discovery_present:
|
|
106
|
+
try:
|
|
107
|
+
discovery = DiscoveryManager(config.root).load(
|
|
108
|
+
location.directory,
|
|
109
|
+
required=True,
|
|
110
|
+
)
|
|
111
|
+
except DiscoveryError as error:
|
|
112
|
+
discovery_error = str(error)
|
|
113
|
+
else:
|
|
114
|
+
if discovery is not None:
|
|
115
|
+
discovery_complete = discovery.is_complete
|
|
116
|
+
discovery_status = discovery.status
|
|
117
|
+
if not discovery_error:
|
|
118
|
+
try:
|
|
119
|
+
discovery_digest = store.digest_file(discovery_path)
|
|
120
|
+
except ArtifactError as error:
|
|
121
|
+
discovery_error = str(error)
|
|
122
|
+
|
|
123
|
+
architecture: ArchitectureManifest | None = None
|
|
124
|
+
architecture_digest = ""
|
|
125
|
+
try:
|
|
126
|
+
architecture = ArchitectureManifestLoader().load(
|
|
127
|
+
config.root,
|
|
128
|
+
required=config.project_mode == "greenfield",
|
|
129
|
+
)
|
|
130
|
+
except ArchitectureError as error:
|
|
131
|
+
warnings.append(f"Architecture manifest: {error}")
|
|
132
|
+
else:
|
|
133
|
+
if architecture is not None:
|
|
134
|
+
architecture_digest = architecture.digest
|
|
135
|
+
|
|
136
|
+
spec_path = location.directory / "spec.md"
|
|
137
|
+
spec_present = spec_path.is_file()
|
|
138
|
+
spec_valid = False
|
|
139
|
+
spec_digest = ""
|
|
140
|
+
spec_error = ""
|
|
141
|
+
if spec_present:
|
|
142
|
+
try:
|
|
143
|
+
spec_digest = store.digest_file(spec_path)
|
|
144
|
+
spec_text = spec_path.read_text(encoding="utf-8")
|
|
145
|
+
spec_valid, spec_error = SpecificationManager().validate(
|
|
146
|
+
spec_text,
|
|
147
|
+
project_mode=config.project_mode,
|
|
148
|
+
architecture=architecture,
|
|
149
|
+
discovery_digest=discovery_digest or None,
|
|
150
|
+
)
|
|
151
|
+
except (ArtifactError, OSError) as error:
|
|
152
|
+
spec_error = str(error)
|
|
153
|
+
else:
|
|
154
|
+
spec_error = "spec.md is missing"
|
|
155
|
+
|
|
156
|
+
can_recover = (
|
|
157
|
+
not events_present
|
|
158
|
+
and not workflow_present
|
|
159
|
+
and discovery_complete
|
|
160
|
+
and spec_valid
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
return ChangeInspection(
|
|
164
|
+
location=location,
|
|
165
|
+
events_present=events_present,
|
|
166
|
+
workflow_present=workflow_present,
|
|
167
|
+
workflow_status=workflow_status,
|
|
168
|
+
discovery_present=discovery_present,
|
|
169
|
+
discovery_complete=discovery_complete,
|
|
170
|
+
discovery_status=discovery_status,
|
|
171
|
+
discovery_digest=discovery_digest,
|
|
172
|
+
discovery_error=discovery_error,
|
|
173
|
+
spec_present=spec_present,
|
|
174
|
+
spec_valid=spec_valid,
|
|
175
|
+
spec_digest=spec_digest,
|
|
176
|
+
spec_error=spec_error,
|
|
177
|
+
architecture_digest=architecture_digest,
|
|
178
|
+
warnings=tuple(warnings),
|
|
179
|
+
orphans=orphans,
|
|
180
|
+
can_recover=can_recover,
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def recover_change(
|
|
185
|
+
config: DevFlowConfig,
|
|
186
|
+
location: ChangeLocation,
|
|
187
|
+
) -> RecoveryResult:
|
|
188
|
+
"""Register existing valid artifacts in a missing workflow state.
|
|
189
|
+
|
|
190
|
+
Running this function again once a workflow exists is safe: it returns
|
|
191
|
+
the current state without changing it.
|
|
192
|
+
"""
|
|
193
|
+
inspection = inspect_change(config, location)
|
|
194
|
+
manager = WorkflowStateManager(
|
|
195
|
+
config.specifications_path,
|
|
196
|
+
project_root=config.root,
|
|
197
|
+
)
|
|
198
|
+
if inspection.events_present:
|
|
199
|
+
return RecoveryResult(
|
|
200
|
+
inspection=inspection,
|
|
201
|
+
state=manager.status(location).state,
|
|
202
|
+
recovered=False,
|
|
203
|
+
)
|
|
204
|
+
if inspection.workflow_present:
|
|
205
|
+
raise StateError(
|
|
206
|
+
f"Cannot recover {location.change}: workflow.yaml exists without "
|
|
207
|
+
"events.jsonl. Restore the event log or remove the orphan "
|
|
208
|
+
"projection, then run 'devflow doctor' again."
|
|
209
|
+
)
|
|
210
|
+
if not inspection.discovery_present:
|
|
211
|
+
raise StateError(
|
|
212
|
+
f"Cannot recover {location.change}: discovery.yaml is missing. "
|
|
213
|
+
"Run 'devflow spec' first."
|
|
214
|
+
)
|
|
215
|
+
if not inspection.discovery_complete:
|
|
216
|
+
detail = inspection.discovery_error or (
|
|
217
|
+
f"Discovery status is '{inspection.discovery_status}'."
|
|
218
|
+
)
|
|
219
|
+
raise StateError(
|
|
220
|
+
f"Cannot recover {location.change}: Discovery is not complete. "
|
|
221
|
+
f"{detail} Resolve it with 'devflow spec --continue "
|
|
222
|
+
f"{location.spec_id}'."
|
|
223
|
+
)
|
|
224
|
+
if not inspection.spec_present:
|
|
225
|
+
raise StateError(
|
|
226
|
+
f"Cannot recover {location.change}: spec.md is missing. "
|
|
227
|
+
f"Run 'devflow spec --continue {location.spec_id}' first."
|
|
228
|
+
)
|
|
229
|
+
if not inspection.spec_valid:
|
|
230
|
+
raise StateError(
|
|
231
|
+
f"Cannot recover {location.change}: spec.md is invalid. "
|
|
232
|
+
f"{inspection.spec_error}"
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
manager.initialize_change(location.directory)
|
|
236
|
+
location = WorkflowLocator(config.specifications_path).from_directory(
|
|
237
|
+
location.directory
|
|
238
|
+
)
|
|
239
|
+
manager.record_artifact(
|
|
240
|
+
location,
|
|
241
|
+
stage="discovery",
|
|
242
|
+
path=location.directory / "discovery.yaml",
|
|
243
|
+
validated=True,
|
|
244
|
+
source="existing",
|
|
245
|
+
)
|
|
246
|
+
metadata: dict[str, str] = {
|
|
247
|
+
"discovery_digest": inspection.discovery_digest,
|
|
248
|
+
}
|
|
249
|
+
if inspection.architecture_digest:
|
|
250
|
+
metadata["architecture_digest"] = inspection.architecture_digest
|
|
251
|
+
state = manager.record_artifact(
|
|
252
|
+
location,
|
|
253
|
+
stage="spec",
|
|
254
|
+
path=location.directory / "spec.md",
|
|
255
|
+
validated=True,
|
|
256
|
+
source="existing",
|
|
257
|
+
metadata=metadata,
|
|
258
|
+
)
|
|
259
|
+
return RecoveryResult(inspection=inspection, state=state)
|
devflow/core/spec_workflow.py
CHANGED
|
@@ -64,6 +64,7 @@ class SpecWorkflowRequest:
|
|
|
64
64
|
warnings: tuple[str, ...] = ()
|
|
65
65
|
project_mode: str = "existing"
|
|
66
66
|
continue_spec_id: str | None = None
|
|
67
|
+
language: str = ""
|
|
67
68
|
|
|
68
69
|
|
|
69
70
|
@dataclass(frozen=True)
|
|
@@ -467,6 +468,7 @@ class SpecWorkflow:
|
|
|
467
468
|
execution_mode=request.execution_mode,
|
|
468
469
|
permissions=config.permissions,
|
|
469
470
|
project_mode=project_mode,
|
|
471
|
+
language=request.language or config.documentation_language,
|
|
470
472
|
architecture_path=(
|
|
471
473
|
architecture.relative_path(config.root)
|
|
472
474
|
if architecture is not None
|
devflow/core/state/manager.py
CHANGED
|
@@ -842,7 +842,9 @@ class WorkflowStateManager:
|
|
|
842
842
|
raise InvalidStateError(msg)
|
|
843
843
|
msg = (
|
|
844
844
|
f"No workflow state found for {location.change}. "
|
|
845
|
-
"Run 'devflow spec' first
|
|
845
|
+
"Run 'devflow spec' first, or run 'devflow doctor "
|
|
846
|
+
f"{location.spec_id}' if the change already has context.md, "
|
|
847
|
+
"discovery.yaml and spec.md."
|
|
846
848
|
)
|
|
847
849
|
raise ChangeNotFoundError(msg)
|
|
848
850
|
|
devflow/prompts/__init__.py
CHANGED
|
@@ -40,6 +40,7 @@ def build_spec_prompt(
|
|
|
40
40
|
discovery_path: str = "",
|
|
41
41
|
discovery_digest: str = "",
|
|
42
42
|
discovery_decisions: list[str] | None = None,
|
|
43
|
+
language: str = "en",
|
|
43
44
|
) -> str:
|
|
44
45
|
"""Render the shared specification prompt for any harness."""
|
|
45
46
|
template_name = (
|
|
@@ -80,6 +81,7 @@ def build_spec_prompt(
|
|
|
80
81
|
"harness_name": harness_name,
|
|
81
82
|
"execution_mode": execution_mode,
|
|
82
83
|
"project_mode": project_mode,
|
|
84
|
+
"language_note": _language_note(language),
|
|
83
85
|
"architecture_note": architecture_note,
|
|
84
86
|
"discovery_note": discovery_note,
|
|
85
87
|
"mode_instructions": mode_instructions,
|
|
@@ -123,6 +125,20 @@ def build_discovery_prompt(
|
|
|
123
125
|
return rendered
|
|
124
126
|
|
|
125
127
|
|
|
128
|
+
def _language_note(language: str) -> str:
|
|
129
|
+
"""Return the prompt instruction that selects the prose language."""
|
|
130
|
+
target = (language or "en").strip() or "en"
|
|
131
|
+
return (
|
|
132
|
+
f"Write all specification prose in the language identified as "
|
|
133
|
+
f"`{target}`. If that identifier is ambiguous, treat it as the "
|
|
134
|
+
"target language name.\n\n"
|
|
135
|
+
"Keep every required heading line, section number, `FR-XXX` and "
|
|
136
|
+
"`AC-XXX` identifier, field name, path, command, code block and "
|
|
137
|
+
"digest exactly as shown in this prompt. Do not translate or "
|
|
138
|
+
"reformat those tokens."
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
|
|
126
142
|
def _discovery_mode_instructions(
|
|
127
143
|
discovery_path: str,
|
|
128
144
|
execution_mode: str,
|
|
@@ -18,6 +18,10 @@ before writing. The declared architecture manifest is the primary
|
|
|
18
18
|
source of design decisions. The project constitution takes precedence
|
|
19
19
|
over generic preferences.
|
|
20
20
|
|
|
21
|
+
## Documentation Language
|
|
22
|
+
|
|
23
|
+
{{language_note}}
|
|
24
|
+
|
|
21
25
|
## Non-Negotiable Boundaries
|
|
22
26
|
|
|
23
27
|
- There is no existing implementation. Do not invent source files,
|
devflow/prompts/spec.md
CHANGED
|
@@ -18,6 +18,10 @@ documents before writing. The project constitution takes precedence
|
|
|
18
18
|
over generic preferences. Existing code evidence takes precedence over
|
|
19
19
|
assumptions.
|
|
20
20
|
|
|
21
|
+
## Documentation Language
|
|
22
|
+
|
|
23
|
+
{{language_note}}
|
|
24
|
+
|
|
21
25
|
## Non-Negotiable Boundaries
|
|
22
26
|
|
|
23
27
|
- Do not modify application source code, tests, configuration or
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: devflow-toolkit
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: Specification workflow toolkit for AI-assisted software changes
|
|
5
5
|
Author: DevFlow contributors
|
|
6
6
|
License-Expression: MIT
|
|
@@ -42,7 +42,7 @@ anyone starts implementing it. DevFlow owns the workflow state; the
|
|
|
42
42
|
selected agent harness is only the execution backend that drafts the
|
|
43
43
|
specification.
|
|
44
44
|
|
|
45
|
-
This is the `0.3.
|
|
45
|
+
This is the `0.3.2` MVP. It implements the **discovery and
|
|
46
46
|
specification stages only**. It supports two specification contexts:
|
|
47
47
|
**Existing Project** (the default) and **Greenfield**. It is not a
|
|
48
48
|
complete SDD platform and does not include planning, implementation or
|
|
@@ -114,7 +114,7 @@ pip install devflow-toolkit
|
|
|
114
114
|
To install a specific built artifact instead:
|
|
115
115
|
|
|
116
116
|
```bash
|
|
117
|
-
pip install devflow_toolkit-0.3.
|
|
117
|
+
pip install devflow_toolkit-0.3.2-py3-none-any.whl
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
Verify the installation:
|
|
@@ -144,10 +144,18 @@ Common options:
|
|
|
144
144
|
devflow init --harness opencode --mode non-interactive
|
|
145
145
|
devflow init --profile django-backend --name my-service
|
|
146
146
|
devflow init --project-mode greenfield
|
|
147
|
+
devflow init --language es
|
|
147
148
|
devflow init --no-agent
|
|
148
149
|
devflow init --yes
|
|
149
150
|
```
|
|
150
151
|
|
|
152
|
+
`init --language <code>` sets the language used for specification
|
|
153
|
+
prose. The value is stored as `documentation.language` in
|
|
154
|
+
`.devflow/config.yaml` and defaults to `en`. Common language names such
|
|
155
|
+
as `Spanish` are normalized to their code (`es`). Required headings,
|
|
156
|
+
section numbers, `FR-XXX`/`AC-XXX` identifiers, paths, commands and
|
|
157
|
+
digests remain unchanged so structural validation still works.
|
|
158
|
+
|
|
151
159
|
`init --project-mode greenfield` creates `.devflow/architecture.yaml`
|
|
152
160
|
from a template when it does not exist. It never overwrites an existing
|
|
153
161
|
manifest. Edit the manifest before running a Greenfield specification;
|
|
@@ -270,7 +278,7 @@ as an architectural constraint when it is present.
|
|
|
270
278
|
|
|
271
279
|
### Harnesses
|
|
272
280
|
|
|
273
|
-
| Harness | Status in 0.3.
|
|
281
|
+
| Harness | Status in 0.3.2 |
|
|
274
282
|
| --- | --- |
|
|
275
283
|
| OpenCode | Verified end-to-end in non-interactive mode |
|
|
276
284
|
| Codex | Integration files are generated, but not verified for this release |
|
|
@@ -401,8 +409,10 @@ require Discovery.
|
|
|
401
409
|
5. Review `spec.md` and resolve any remaining non-blocking questions.
|
|
402
410
|
6. Record the approval.
|
|
403
411
|
7. Inspect the state, artifacts and approval digests.
|
|
412
|
+
8. If artifacts exist without workflow state, diagnose with
|
|
413
|
+
`devflow doctor <id>` and repair with `devflow recover <id>`.
|
|
404
414
|
|
|
405
|
-
Available commands in `0.3.
|
|
415
|
+
Available commands in `0.3.2`:
|
|
406
416
|
|
|
407
417
|
| Command | Status |
|
|
408
418
|
| --- | --- |
|
|
@@ -410,6 +420,8 @@ Available commands in `0.3.0`:
|
|
|
410
420
|
| `devflow spec` | Implemented: Discovery, specification, and `--continue` |
|
|
411
421
|
| `devflow approve <id> --stage spec` | Implemented |
|
|
412
422
|
| `devflow status <id>` | Implemented |
|
|
423
|
+
| `devflow doctor <id>` | Implemented: read-only diagnostics |
|
|
424
|
+
| `devflow recover <id>` | Implemented: register existing artifacts |
|
|
413
425
|
| `devflow version` | Implemented |
|
|
414
426
|
| `devflow plan` | Not implemented |
|
|
415
427
|
| `devflow approve <id> --stage plan` | Rejected |
|
|
@@ -468,11 +480,17 @@ Useful options:
|
|
|
468
480
|
```bash
|
|
469
481
|
devflow spec "Description" --harness opencode --mode non-interactive
|
|
470
482
|
devflow spec "Description" --no-agent
|
|
483
|
+
devflow spec "Description" --language es
|
|
471
484
|
devflow spec "Change in a real project" --project-mode existing
|
|
472
485
|
devflow spec "Create a new service" --project-mode greenfield
|
|
473
486
|
devflow spec --continue 006
|
|
474
487
|
```
|
|
475
488
|
|
|
489
|
+
`spec --language <code>` overrides the configured language for that run
|
|
490
|
+
without changing `.devflow/config.yaml`. The deterministic `--no-agent`
|
|
491
|
+
draft remains in English; the language setting applies to specifications
|
|
492
|
+
written by an agent.
|
|
493
|
+
|
|
476
494
|
If the harness is unavailable, fails, or returns an invalid document,
|
|
477
495
|
DevFlow writes a deterministic draft and reports the reason. The command
|
|
478
496
|
remains usable in CI and on machines without an AI harness, but the draft
|
|
@@ -490,6 +508,45 @@ devflow status 001-add-a-get-patients-endpoint
|
|
|
490
508
|
approvals, stale artifacts and orphan files. It reconciles
|
|
491
509
|
`workflow.yaml` from `events.jsonl` before reporting.
|
|
492
510
|
|
|
511
|
+
### Diagnose and recover a change
|
|
512
|
+
|
|
513
|
+
If `context.md`, `discovery.yaml` or `spec.md` were written outside
|
|
514
|
+
`devflow spec`, the change can exist on disk without `workflow.yaml`,
|
|
515
|
+
`events.jsonl` or `runs/`. In that case `status` reports that no workflow
|
|
516
|
+
state was found.
|
|
517
|
+
|
|
518
|
+
Diagnose the change without changing anything:
|
|
519
|
+
|
|
520
|
+
```bash
|
|
521
|
+
devflow doctor 001
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
`doctor` checks the workflow, Discovery and specification, reports
|
|
525
|
+
orphan artifacts, and exits non-zero when the change is unhealthy.
|
|
526
|
+
|
|
527
|
+
If `discovery.yaml` is complete and `spec.md` is structurally valid,
|
|
528
|
+
register the existing artifacts without regenerating them:
|
|
529
|
+
|
|
530
|
+
```bash
|
|
531
|
+
devflow recover 001
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
`recover` creates the missing workflow state and registers Discovery and
|
|
535
|
+
the specification with `source: existing`. It preserves the artifact
|
|
536
|
+
bytes and their digests, does not modify `spec.md`, and does not approve
|
|
537
|
+
the change. Running it again after recovery is a no-op.
|
|
538
|
+
|
|
539
|
+
Recovery does not bypass review. After recovering, inspect
|
|
540
|
+
`devflow status 001`, then approve explicitly:
|
|
541
|
+
|
|
542
|
+
```bash
|
|
543
|
+
devflow approve 001 --stage spec
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
If Discovery is incomplete or `spec.md` is invalid, `recover` refuses to
|
|
547
|
+
register the artifacts and names the problem. Resolve it with
|
|
548
|
+
`devflow spec --continue 001` first.
|
|
549
|
+
|
|
493
550
|
### Approve the specification
|
|
494
551
|
|
|
495
552
|
```bash
|
|
@@ -497,7 +554,7 @@ devflow approve 001 --stage spec
|
|
|
497
554
|
```
|
|
498
555
|
|
|
499
556
|
Approval is explicit and binds the decision to the current artifact
|
|
500
|
-
digests. For a `0.3.
|
|
557
|
+
digests. For a `0.3.2` change it binds `spec.md`, `discovery.yaml` and,
|
|
501
558
|
when a manifest applies, the architecture manifest digest. Repeating the
|
|
502
559
|
same approval is a no-op. If an artifact changes after validation,
|
|
503
560
|
DevFlow marks it stale and refuses approval until it is regenerated and
|
|
@@ -507,7 +564,7 @@ Discovery must be complete before approval. If it is not, approval fails
|
|
|
507
564
|
and names the pending questions and assumptions. Legacy `0.2.0` changes
|
|
508
565
|
without `discovery.yaml` remain approvable with a warning.
|
|
509
566
|
|
|
510
|
-
Only the `spec` stage is available in `0.3.
|
|
567
|
+
Only the `spec` stage is available in `0.3.2`. `--stage plan` and
|
|
511
568
|
`--stage review` are rejected. There are no `plan`, `implement` or
|
|
512
569
|
`review` commands in this release.
|
|
513
570
|
|
|
@@ -531,6 +588,7 @@ my-project/
|
|
|
531
588
|
│ ├── spec.md # only when Discovery is complete
|
|
532
589
|
│ ├── workflow.yaml # projection of events.jsonl
|
|
533
590
|
│ ├── events.jsonl # append-only source of truth
|
|
591
|
+
│ ├── runs/ # agent run metadata
|
|
534
592
|
│ └── .lock # per-change advisory lock
|
|
535
593
|
├── AGENTS.md
|
|
536
594
|
├── opencode.json # when OpenCode is selected
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
devflow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
devflow/cli.py,sha256=
|
|
2
|
+
devflow/cli.py,sha256=V1G0D8yMDYeEtLoU7E0W_mbpw0CkqeVBmT61Ftt-kt0,1168
|
|
3
3
|
devflow/adapters/__init__.py,sha256=WcsjXQTKzHNzMAHx82-sdJQeR3ceHRVqLWTUtRlaraE,867
|
|
4
4
|
devflow/adapters/agents.py,sha256=4d54hDfBgnIP4zOKcZqAG-Qa-jfuuxzFL-akZS2qYtw,1309
|
|
5
5
|
devflow/adapters/base.py,sha256=YggY_IwHExdybl5S9NjwZSlmmcw9Y6z7DhQsl3JLvXs,2055
|
|
@@ -11,21 +11,24 @@ devflow/adapters/kiro.py,sha256=8l5y7ZYffg_T9eciM28NKGHil_zgdT96mAdYK4oBZ0U,6111
|
|
|
11
11
|
devflow/adapters/opencode.py,sha256=DonmvAKyWK2v5-X2XrL0n2iptFp7qLgOlh-X8n_8I-w,6492
|
|
12
12
|
devflow/adapters/registry.py,sha256=NLd_tf7dAiZUa6gbQFcwPogurZyjbMNbzjjXozAD4xs,1177
|
|
13
13
|
devflow/commands/__init__.py,sha256=yOLtd_4R4xdlMgAzihzIT35oyV_qcz0br-aoLebRj1c,157
|
|
14
|
-
devflow/commands/approve.py,sha256=
|
|
14
|
+
devflow/commands/approve.py,sha256=h9X6noFrjxWFIQfJ7lVvLfIb0jaxDduFm1xwL5VaREQ,2740
|
|
15
|
+
devflow/commands/doctor.py,sha256=7LQMl26arw-ofoET8BL18_AcBpIniapYDrVPhCb_Mik,3791
|
|
15
16
|
devflow/commands/harness.py,sha256=r_RSAi7gXK8QNucC6eV-RzXHJycmmR03dzihqLVgdiU,2791
|
|
16
|
-
devflow/commands/init.py,sha256=
|
|
17
|
-
devflow/commands/
|
|
17
|
+
devflow/commands/init.py,sha256=B-rW-etZ-Rptt9YW43YZ5mN_l3gfGczuXW9kpmHDOWQ,15420
|
|
18
|
+
devflow/commands/recover.py,sha256=sV9x5-30E_3XRBe7JItDiSG-pqrowRzjqOkC_eyrhFQ,2165
|
|
19
|
+
devflow/commands/spec.py,sha256=_h2-QIXxVME2iPPD9mIk6uabPnkQTdXwK9dfqp_cDZ0,14558
|
|
18
20
|
devflow/commands/status.py,sha256=HtBCIF8U0bmkyS6wS7IEvggo89FzGRGBCsFfPrKzLpU,4369
|
|
19
21
|
devflow/core/__init__.py,sha256=hN7i4-PDaZ7y4P8qRpZl_lJvIiPyQaN1TDGnw2BecYU,427
|
|
20
22
|
devflow/core/architecture.py,sha256=qllllsUVqA76LiSU6z_s4U8dxMcs6ClKXU16HxI3yOI,13692
|
|
21
23
|
devflow/core/clock.py,sha256=KZROv6o51Ln1EzK00ySCxfc7WPZqPlaQhFfjfdc_TMY,1651
|
|
22
|
-
devflow/core/config.py,sha256=
|
|
24
|
+
devflow/core/config.py,sha256=Ft37K1r6zm3QsU6YtuqBjq2Yr9sDscC5QiqAUrsHpUw,22108
|
|
23
25
|
devflow/core/constitution.py,sha256=nPHyy7BuIyyqkn4y85UyWn2E7f5AWHbg4iZ0frF9SfE,4581
|
|
24
|
-
devflow/core/discovery.py,sha256=
|
|
26
|
+
devflow/core/discovery.py,sha256=xFlY9aLLs8NgJGe13PmjYIB8dibUgOv1i6e8i5QG650,35259
|
|
25
27
|
devflow/core/ports.py,sha256=R6ybjAdJEdtTKFc4FMFTX0TVwRfDwPoWCsu-BHrhI5A,4071
|
|
26
28
|
devflow/core/profile_manager.py,sha256=QnnJka2KIKD2tCSWJkGTOUEFMgmQT0Z9Qv173JKWKHw,8937
|
|
27
29
|
devflow/core/project.py,sha256=SINU6KSRIpX5rPlPy8nWMfQuHas_VF1bAIVafhbcgCg,13330
|
|
28
|
-
devflow/core/
|
|
30
|
+
devflow/core/recovery.py,sha256=n_-sOc7SAwzMajlXBIJiJ9MX8xx56yd88g3bl300BSA,7535
|
|
31
|
+
devflow/core/spec_workflow.py,sha256=uCpvImVIL7kVyVjUsiePccSy3RNw9jX6Pj06r47gCao,28534
|
|
29
32
|
devflow/core/specification.py,sha256=aHAL_U8Tl0YBokUJKneqUyCPenY6xtcPlZUgKmUsEMw,65719
|
|
30
33
|
devflow/core/artifacts/__init__.py,sha256=gt9xahPynoxv75FMq1ZJx91ILTIv4ExuvX1Ymrxwr2c,627
|
|
31
34
|
devflow/core/artifacts/errors.py,sha256=hwZxnLFcUTtEjDWtN6rUCkM69EN19LGVlc6HD-pNZyk,493
|
|
@@ -36,7 +39,7 @@ devflow/core/state/errors.py,sha256=dgF-x4TCxQTXc1OifyT8UZSU-0PBhATjO1x6OTMagac,
|
|
|
36
39
|
devflow/core/state/events.py,sha256=IfwFCC0jbrQsH1tzADyqwm8HtWo5fR7QDD85M6JH8N0,20698
|
|
37
40
|
devflow/core/state/locator.py,sha256=J6ZnVzcY_KzwKqBXbAOnfG9FrRzSCaYMqFeMQ7ptjIc,3256
|
|
38
41
|
devflow/core/state/lock.py,sha256=94llvwHtCc5WOw-Uq8kDCu4iOBpRM4ccp6Q6fLZpYZ0,2089
|
|
39
|
-
devflow/core/state/manager.py,sha256=
|
|
42
|
+
devflow/core/state/manager.py,sha256=L7Ksn91rI4rlr7bZbIENUS2_ntS0CmRKEdO2dTAWA3I,27982
|
|
40
43
|
devflow/core/state/models.py,sha256=4GTrS34ymbJIyBeZkcCi0z0e1bsq67vdxRSnSQ9O3gc,4654
|
|
41
44
|
devflow/core/state/transitions.py,sha256=Go0zLhxcujWhaZEGg7JMqcC_UJU_nEFEBbpKIqrCtrs,3581
|
|
42
45
|
devflow/models/__init__.py,sha256=hXX3IDZbHgklmuzVVlpiRs5SSPnrkO5kN1-k2hIEk7E,156
|
|
@@ -52,12 +55,12 @@ devflow/profiles/django-backend/profile.yaml,sha256=SNj7a3yamdJx-P69GvIJmLkC2svO
|
|
|
52
55
|
devflow/profiles/django-backend/constitution/django-standards.md,sha256=0M-XmxOpEmgIadcaVdf6OVmll8Oec0jEjcJ4C8MfwhQ,2052
|
|
53
56
|
devflow/profiles/fastapi-backend/profile.yaml,sha256=5_b-zWSX0HV-tw_2ntRCSa4DyP3NUqYWmxOh55pXYmc,321
|
|
54
57
|
devflow/profiles/fastapi-backend/constitution/fastapi-standards.md,sha256=iFKib4i_9z4wBQ9thl-uftg5g-CHwvmFWzMtLgA7CBk,1949
|
|
55
|
-
devflow/prompts/__init__.py,sha256=
|
|
58
|
+
devflow/prompts/__init__.py,sha256=j30n28MIIGJtTV-9jAutke0icTj5WXJbfUBYbQUA_QI,7234
|
|
56
59
|
devflow/prompts/discovery.md,sha256=rwuCgD70yhFCw3MbygPr5jOxGof2_naKcKUVOlvmRRc,3716
|
|
57
|
-
devflow/prompts/spec.greenfield.md,sha256=
|
|
58
|
-
devflow/prompts/spec.md,sha256=
|
|
59
|
-
devflow_toolkit-0.3.
|
|
60
|
-
devflow_toolkit-0.3.
|
|
61
|
-
devflow_toolkit-0.3.
|
|
62
|
-
devflow_toolkit-0.3.
|
|
63
|
-
devflow_toolkit-0.3.
|
|
60
|
+
devflow/prompts/spec.greenfield.md,sha256=HEq2_rC-Aom9XFzYyyHdtedSECJe0aK8jz5WbNLL5MY,4724
|
|
61
|
+
devflow/prompts/spec.md,sha256=b1cVZNlOG197JxhMZlL5xA1sThDPsCDcAuLTrmkXzBk,3392
|
|
62
|
+
devflow_toolkit-0.3.2.dist-info/METADATA,sha256=sGdZiE4WRYSyz5FXtBmjl1_14mdBxMz5-69T1A6Psz4,24573
|
|
63
|
+
devflow_toolkit-0.3.2.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
64
|
+
devflow_toolkit-0.3.2.dist-info/entry_points.txt,sha256=wPmqE1081vi8s3xf-Wfzfvpl-44IKgwx7OGoLEK3u7o,44
|
|
65
|
+
devflow_toolkit-0.3.2.dist-info/licenses/LICENSE,sha256=Wa04lstC8Goe4b9IYfEYWB2k7nokYBejZl6NdyAl8rA,1077
|
|
66
|
+
devflow_toolkit-0.3.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|