devflow-toolkit 0.3.17__py3-none-any.whl → 0.3.18__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/adapters/antigravity.py +31 -0
- devflow/adapters/claude_code.py +3 -0
- devflow/adapters/codex.py +3 -0
- devflow/adapters/kiro.py +30 -0
- devflow/adapters/opencode.py +28 -0
- devflow/cli.py +4 -0
- devflow/commands/config.py +53 -0
- devflow/commands/harness.py +227 -2
- devflow/commands/init.py +54 -1
- devflow/commands/spec.py +17 -1
- devflow/core/config.py +30 -8
- devflow/core/discovery.py +14 -20
- devflow/core/file_types.py +33 -0
- devflow/core/ports.py +13 -0
- devflow/core/project.py +1 -16
- devflow/core/spec_workflow.py +201 -30
- devflow/core/specification.py +1 -25
- devflow/core/state/locator.py +0 -4
- devflow/models/project.py +0 -11
- devflow/prompts/__init__.py +23 -2
- devflow/prompts/discovery-repair.md +36 -0
- devflow/prompts/discovery.md +17 -0
- {devflow_toolkit-0.3.17.dist-info → devflow_toolkit-0.3.18.dist-info}/METADATA +1 -1
- {devflow_toolkit-0.3.17.dist-info → devflow_toolkit-0.3.18.dist-info}/RECORD +27 -24
- {devflow_toolkit-0.3.17.dist-info → devflow_toolkit-0.3.18.dist-info}/WHEEL +0 -0
- {devflow_toolkit-0.3.17.dist-info → devflow_toolkit-0.3.18.dist-info}/entry_points.txt +0 -0
- {devflow_toolkit-0.3.17.dist-info → devflow_toolkit-0.3.18.dist-info}/licenses/LICENSE +0 -0
devflow/adapters/antigravity.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import json
|
|
6
|
+
import subprocess
|
|
6
7
|
from pathlib import Path
|
|
7
8
|
from typing import Any
|
|
8
9
|
|
|
@@ -16,6 +17,7 @@ from devflow.adapters.base import (
|
|
|
16
17
|
SetupContext,
|
|
17
18
|
SetupResult,
|
|
18
19
|
)
|
|
20
|
+
from devflow.core.ports import ModelOption
|
|
19
21
|
from devflow.adapters.instructions import (
|
|
20
22
|
MANAGED_MARKER,
|
|
21
23
|
render_agent_instructions,
|
|
@@ -125,11 +127,13 @@ class AntigravityAdapter(HarnessAdapter):
|
|
|
125
127
|
self._settings(context),
|
|
126
128
|
separators=(",", ":"),
|
|
127
129
|
)
|
|
130
|
+
model = ("--model", context.model) if context.model else ()
|
|
128
131
|
if context.mode == "interactive":
|
|
129
132
|
argv = (
|
|
130
133
|
self.executable,
|
|
131
134
|
"--settings",
|
|
132
135
|
settings,
|
|
136
|
+
*model,
|
|
133
137
|
"--agent",
|
|
134
138
|
INTERACTIVE_AGENT,
|
|
135
139
|
"--prompt-interactive",
|
|
@@ -141,6 +145,7 @@ class AntigravityAdapter(HarnessAdapter):
|
|
|
141
145
|
self.executable,
|
|
142
146
|
"--settings",
|
|
143
147
|
settings,
|
|
148
|
+
*model,
|
|
144
149
|
"--agent",
|
|
145
150
|
READONLY_AGENT,
|
|
146
151
|
"--output-format",
|
|
@@ -150,6 +155,32 @@ class AntigravityAdapter(HarnessAdapter):
|
|
|
150
155
|
)
|
|
151
156
|
return Invocation(argv=argv, cwd=root, interactive=False)
|
|
152
157
|
|
|
158
|
+
def list_models(self) -> tuple[ModelOption, ...]:
|
|
159
|
+
"""Return models reported by ``agy models``."""
|
|
160
|
+
try:
|
|
161
|
+
result = subprocess.run( # noqa: S603
|
|
162
|
+
[self.executable, "models"],
|
|
163
|
+
capture_output=True,
|
|
164
|
+
text=True,
|
|
165
|
+
timeout=30,
|
|
166
|
+
check=False,
|
|
167
|
+
)
|
|
168
|
+
except (OSError, subprocess.SubprocessError):
|
|
169
|
+
return ()
|
|
170
|
+
if result.returncode != 0:
|
|
171
|
+
return ()
|
|
172
|
+
options: list[ModelOption] = []
|
|
173
|
+
for line in result.stdout.splitlines():
|
|
174
|
+
line = line.strip()
|
|
175
|
+
if not line or line.lower().startswith("fetching"):
|
|
176
|
+
continue
|
|
177
|
+
parts = line.split("\t", maxsplit=1)
|
|
178
|
+
model_id = parts[0].strip()
|
|
179
|
+
label = parts[1].strip() if len(parts) > 1 else ""
|
|
180
|
+
if model_id:
|
|
181
|
+
options.append(ModelOption(model_id, label or model_id))
|
|
182
|
+
return tuple(options)
|
|
183
|
+
|
|
153
184
|
def permission_warnings(
|
|
154
185
|
self,
|
|
155
186
|
context: RunContext,
|
devflow/adapters/claude_code.py
CHANGED
|
@@ -59,10 +59,12 @@ class ClaudeCodeAdapter(HarnessAdapter):
|
|
|
59
59
|
permission_mode = (
|
|
60
60
|
"manual" if context.mode == "interactive" else "dontAsk"
|
|
61
61
|
)
|
|
62
|
+
model = ("--model", context.model) if context.model else ()
|
|
62
63
|
|
|
63
64
|
if context.mode == "interactive":
|
|
64
65
|
argv = (
|
|
65
66
|
self.executable,
|
|
67
|
+
*model,
|
|
66
68
|
"--permission-mode",
|
|
67
69
|
permission_mode,
|
|
68
70
|
"--settings",
|
|
@@ -77,6 +79,7 @@ class ClaudeCodeAdapter(HarnessAdapter):
|
|
|
77
79
|
argv = (
|
|
78
80
|
self.executable,
|
|
79
81
|
"-p",
|
|
82
|
+
*model,
|
|
80
83
|
"--output-format",
|
|
81
84
|
"text",
|
|
82
85
|
"--permission-mode",
|
devflow/adapters/codex.py
CHANGED
|
@@ -51,6 +51,7 @@ class CodexAdapter(HarnessAdapter):
|
|
|
51
51
|
|
|
52
52
|
def build_run(self, context: RunContext) -> Invocation:
|
|
53
53
|
root = context.root
|
|
54
|
+
model = ("-m", context.model) if context.model else ()
|
|
54
55
|
if context.mode == "interactive":
|
|
55
56
|
sandbox = (
|
|
56
57
|
"workspace-write"
|
|
@@ -60,6 +61,7 @@ class CodexAdapter(HarnessAdapter):
|
|
|
60
61
|
)
|
|
61
62
|
argv = (
|
|
62
63
|
self.executable,
|
|
64
|
+
*model,
|
|
63
65
|
"--sandbox",
|
|
64
66
|
sandbox,
|
|
65
67
|
"--ask-for-approval",
|
|
@@ -82,6 +84,7 @@ class CodexAdapter(HarnessAdapter):
|
|
|
82
84
|
argv = [
|
|
83
85
|
self.executable,
|
|
84
86
|
"exec",
|
|
87
|
+
*model,
|
|
85
88
|
"--sandbox",
|
|
86
89
|
sandbox,
|
|
87
90
|
"--skip-git-repo-check",
|
devflow/adapters/kiro.py
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import subprocess
|
|
6
|
+
|
|
5
7
|
from devflow.adapters.base import (
|
|
6
8
|
FileChange,
|
|
7
9
|
HarnessAdapter,
|
|
@@ -10,6 +12,7 @@ from devflow.adapters.base import (
|
|
|
10
12
|
SetupContext,
|
|
11
13
|
SetupResult,
|
|
12
14
|
)
|
|
15
|
+
from devflow.core.ports import ModelOption
|
|
13
16
|
from devflow.adapters.instructions import (
|
|
14
17
|
MANAGED_MARKER,
|
|
15
18
|
render_agent_instructions,
|
|
@@ -114,6 +117,7 @@ class KiroAdapter(HarnessAdapter):
|
|
|
114
117
|
|
|
115
118
|
def build_run(self, context: RunContext) -> Invocation:
|
|
116
119
|
root = context.root
|
|
120
|
+
model = ("--model", context.model) if context.model else ()
|
|
117
121
|
if context.mode == "interactive":
|
|
118
122
|
writable = (
|
|
119
123
|
context.permissions.allow_spec_write
|
|
@@ -126,6 +130,7 @@ class KiroAdapter(HarnessAdapter):
|
|
|
126
130
|
argv = (
|
|
127
131
|
self.executable,
|
|
128
132
|
"chat",
|
|
133
|
+
*model,
|
|
129
134
|
"--agent",
|
|
130
135
|
agent,
|
|
131
136
|
f"--trust-tools={trusted}",
|
|
@@ -137,6 +142,7 @@ class KiroAdapter(HarnessAdapter):
|
|
|
137
142
|
self.executable,
|
|
138
143
|
"chat",
|
|
139
144
|
"--no-interactive",
|
|
145
|
+
*model,
|
|
140
146
|
"--agent",
|
|
141
147
|
READONLY_AGENT,
|
|
142
148
|
"--trust-tools=fs_read",
|
|
@@ -146,6 +152,30 @@ class KiroAdapter(HarnessAdapter):
|
|
|
146
152
|
)
|
|
147
153
|
return Invocation(argv=argv, cwd=root, interactive=False)
|
|
148
154
|
|
|
155
|
+
def list_models(self) -> tuple[ModelOption, ...]:
|
|
156
|
+
"""Return models reported by ``kiro-cli chat --list-models``."""
|
|
157
|
+
try:
|
|
158
|
+
result = subprocess.run( # noqa: S603
|
|
159
|
+
[self.executable, "chat", "--list-models"],
|
|
160
|
+
capture_output=True,
|
|
161
|
+
text=True,
|
|
162
|
+
timeout=30,
|
|
163
|
+
check=False,
|
|
164
|
+
)
|
|
165
|
+
except (OSError, subprocess.SubprocessError):
|
|
166
|
+
return ()
|
|
167
|
+
if result.returncode != 0:
|
|
168
|
+
return ()
|
|
169
|
+
options: list[ModelOption] = []
|
|
170
|
+
for line in result.stdout.splitlines():
|
|
171
|
+
stripped = line.strip()
|
|
172
|
+
if not stripped or stripped.lower().startswith("available models"):
|
|
173
|
+
continue
|
|
174
|
+
model_id = stripped.split(maxsplit=1)[0].lstrip("*")
|
|
175
|
+
if model_id:
|
|
176
|
+
options.append(ModelOption(model_id, stripped))
|
|
177
|
+
return tuple(options)
|
|
178
|
+
|
|
149
179
|
def permission_warnings(
|
|
150
180
|
self,
|
|
151
181
|
context: RunContext,
|
devflow/adapters/opencode.py
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import subprocess
|
|
6
|
+
|
|
5
7
|
import yaml
|
|
6
8
|
|
|
7
9
|
from devflow.adapters.base import (
|
|
@@ -12,6 +14,7 @@ from devflow.adapters.base import (
|
|
|
12
14
|
SetupContext,
|
|
13
15
|
SetupResult,
|
|
14
16
|
)
|
|
17
|
+
from devflow.core.ports import ModelOption
|
|
15
18
|
from devflow.adapters.instructions import (
|
|
16
19
|
MANAGED_MARKER,
|
|
17
20
|
render_agent_instructions,
|
|
@@ -115,10 +118,12 @@ class OpenCodeAdapter(HarnessAdapter):
|
|
|
115
118
|
|
|
116
119
|
def build_run(self, context: RunContext) -> Invocation:
|
|
117
120
|
root = context.root
|
|
121
|
+
model = ("--model", context.model) if context.model else ()
|
|
118
122
|
if context.mode == "interactive":
|
|
119
123
|
argv = (
|
|
120
124
|
self.executable,
|
|
121
125
|
"mini",
|
|
126
|
+
*model,
|
|
122
127
|
"--agent",
|
|
123
128
|
INTERACTIVE_AGENT,
|
|
124
129
|
"--prompt",
|
|
@@ -134,12 +139,35 @@ class OpenCodeAdapter(HarnessAdapter):
|
|
|
134
139
|
argv = (
|
|
135
140
|
self.executable,
|
|
136
141
|
"run",
|
|
142
|
+
*model,
|
|
137
143
|
"--agent",
|
|
138
144
|
agent,
|
|
139
145
|
context.prompt,
|
|
140
146
|
)
|
|
141
147
|
return Invocation(argv=argv, cwd=root, interactive=False)
|
|
142
148
|
|
|
149
|
+
def list_models(self) -> tuple[ModelOption, ...]:
|
|
150
|
+
"""Return models reported by ``opencode models``."""
|
|
151
|
+
try:
|
|
152
|
+
result = subprocess.run( # noqa: S603
|
|
153
|
+
[self.executable, "models"],
|
|
154
|
+
capture_output=True,
|
|
155
|
+
text=True,
|
|
156
|
+
timeout=30,
|
|
157
|
+
check=False,
|
|
158
|
+
)
|
|
159
|
+
except (OSError, subprocess.SubprocessError):
|
|
160
|
+
return ()
|
|
161
|
+
if result.returncode != 0:
|
|
162
|
+
return ()
|
|
163
|
+
options: list[ModelOption] = []
|
|
164
|
+
for line in result.stdout.splitlines():
|
|
165
|
+
model_id = line.strip()
|
|
166
|
+
if not model_id or model_id.startswith("Fetching"):
|
|
167
|
+
continue
|
|
168
|
+
options.append(ModelOption(model_id, model_id))
|
|
169
|
+
return tuple(options)
|
|
170
|
+
|
|
143
171
|
def permission_warnings(
|
|
144
172
|
self,
|
|
145
173
|
context: RunContext,
|
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.config import config_app
|
|
9
10
|
from devflow.commands.doctor import doctor as doctor_command
|
|
11
|
+
from devflow.commands.harness import harness_app
|
|
10
12
|
from devflow.commands.init import init as init_command
|
|
11
13
|
from devflow.commands.recover import recover as recover_command
|
|
12
14
|
from devflow.commands.spec import spec as spec_command
|
|
@@ -27,6 +29,8 @@ app.command("approve")(approve_command)
|
|
|
27
29
|
app.command("status")(status_command)
|
|
28
30
|
app.command("doctor")(doctor_command)
|
|
29
31
|
app.command("recover")(recover_command)
|
|
32
|
+
app.add_typer(config_app, name="config")
|
|
33
|
+
app.add_typer(harness_app, name="harness")
|
|
30
34
|
|
|
31
35
|
|
|
32
36
|
@app.command()
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""Implementation of DevFlow configuration commands."""
|
|
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.config import ConfigError, ConfigManager
|
|
11
|
+
from devflow.core.project import ProjectDetector
|
|
12
|
+
|
|
13
|
+
config_app = typer.Typer(
|
|
14
|
+
help="Inspect or update DevFlow configuration.",
|
|
15
|
+
no_args_is_help=True,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
console = Console()
|
|
19
|
+
error_console = Console(stderr=True)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@config_app.command("language")
|
|
23
|
+
def language(
|
|
24
|
+
value: str = typer.Argument(
|
|
25
|
+
...,
|
|
26
|
+
help="Documentation language, for example en, es or es-MX.",
|
|
27
|
+
),
|
|
28
|
+
path: Path = typer.Argument(
|
|
29
|
+
Path("."),
|
|
30
|
+
help="Project root or a path inside it.",
|
|
31
|
+
),
|
|
32
|
+
) -> None:
|
|
33
|
+
"""Set the language used for discovery and specification prose."""
|
|
34
|
+
try:
|
|
35
|
+
root = ProjectDetector().find_root(path)
|
|
36
|
+
config = ConfigManager(root).set_documentation_language(value)
|
|
37
|
+
except (
|
|
38
|
+
ConfigError,
|
|
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
|
+
console.print(
|
|
47
|
+
"[bold]Documentation language:[/bold] "
|
|
48
|
+
f"{config.documentation_language}"
|
|
49
|
+
)
|
|
50
|
+
console.print(
|
|
51
|
+
"[dim]The next discovery or specification run will use this "
|
|
52
|
+
"language.[/dim]"
|
|
53
|
+
)
|
devflow/commands/harness.py
CHANGED
|
@@ -12,13 +12,69 @@ from devflow.adapters.detector import (
|
|
|
12
12
|
detect_harnesses,
|
|
13
13
|
select_harness,
|
|
14
14
|
)
|
|
15
|
-
from devflow.adapters.registry import get_adapter
|
|
15
|
+
from devflow.adapters.registry import adapter_names, get_adapter
|
|
16
16
|
from devflow.core.config import (
|
|
17
17
|
SUPPORTED_HARNESSES,
|
|
18
18
|
ConfigError,
|
|
19
|
+
ConfigManager,
|
|
20
|
+
DevFlowConfig,
|
|
19
21
|
canonical_harness_name,
|
|
20
22
|
)
|
|
21
|
-
from devflow.core.
|
|
23
|
+
from devflow.core.constitution import (
|
|
24
|
+
ConstitutionError,
|
|
25
|
+
ConstitutionLoader,
|
|
26
|
+
)
|
|
27
|
+
from devflow.core.ports import (
|
|
28
|
+
HarnessPort,
|
|
29
|
+
SetupResult,
|
|
30
|
+
build_setup_context,
|
|
31
|
+
)
|
|
32
|
+
from devflow.core.profile_manager import ProfileError, ProfileManager
|
|
33
|
+
from devflow.core.project import ProjectDetector
|
|
34
|
+
|
|
35
|
+
console = Console()
|
|
36
|
+
error_console = Console(stderr=True)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
harness_app = typer.Typer(
|
|
40
|
+
help="Inspect or change the agent harness and model.",
|
|
41
|
+
no_args_is_help=True,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def prompt_for_model(adapter: HarnessPort) -> str | None:
|
|
46
|
+
"""Ask for a harness model in an interactive terminal."""
|
|
47
|
+
if not sys.stdin.isatty():
|
|
48
|
+
return None
|
|
49
|
+
models = adapter.list_models()
|
|
50
|
+
if not models:
|
|
51
|
+
answer = typer.prompt(
|
|
52
|
+
f"Model for {adapter.display_name} "
|
|
53
|
+
"(leave empty for the harness default)",
|
|
54
|
+
default="",
|
|
55
|
+
show_default=False,
|
|
56
|
+
)
|
|
57
|
+
return answer.strip() or None
|
|
58
|
+
|
|
59
|
+
typer.echo(f"Models available for {adapter.display_name}:")
|
|
60
|
+
typer.echo(" 0. Use the harness default")
|
|
61
|
+
for index, model in enumerate(models, start=1):
|
|
62
|
+
label = ""
|
|
63
|
+
if model.label and model.label != model.id:
|
|
64
|
+
label = f" — {model.label}"
|
|
65
|
+
typer.echo(f" {index}. {model.id}{label}")
|
|
66
|
+
while True:
|
|
67
|
+
answer = typer.prompt("Model number or id", default="0")
|
|
68
|
+
value = answer.strip()
|
|
69
|
+
if value in {"", "0"}:
|
|
70
|
+
return None
|
|
71
|
+
if value.isdigit():
|
|
72
|
+
index = int(value)
|
|
73
|
+
if 1 <= index <= len(models):
|
|
74
|
+
return models[index - 1].id
|
|
75
|
+
if value:
|
|
76
|
+
return value
|
|
77
|
+
typer.echo("Choose a listed number or type a model id.")
|
|
22
78
|
|
|
23
79
|
|
|
24
80
|
def validate_harness_name(value: str) -> str:
|
|
@@ -133,3 +189,172 @@ def _prompt_for_harness(
|
|
|
133
189
|
if canonical in choices:
|
|
134
190
|
return canonical
|
|
135
191
|
typer.echo(f"Choose one of: {', '.join(choices)}")
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def _load_harness_config(path: Path) -> tuple[Path, DevFlowConfig]:
|
|
195
|
+
root = ProjectDetector().find_root(path)
|
|
196
|
+
return root, ConfigManager(root).load()
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def _harness_error(error: Exception) -> None:
|
|
200
|
+
error_console.print(f"[red]Error:[/red] {error}")
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
@harness_app.command("current")
|
|
204
|
+
def current(
|
|
205
|
+
path: Path = typer.Argument(
|
|
206
|
+
Path("."),
|
|
207
|
+
help="Project root or a path inside it.",
|
|
208
|
+
),
|
|
209
|
+
) -> None:
|
|
210
|
+
"""Show the configured harness, model and execution mode."""
|
|
211
|
+
try:
|
|
212
|
+
_root, config = _load_harness_config(path)
|
|
213
|
+
except (ConfigError, FileNotFoundError, NotADirectoryError, OSError) as error:
|
|
214
|
+
_harness_error(error)
|
|
215
|
+
raise typer.Exit(code=1) from error
|
|
216
|
+
console.print(f"[bold]Harness:[/bold] {config.agent_harness}")
|
|
217
|
+
console.print(
|
|
218
|
+
f"[bold]Model:[/bold] {config.model or 'harness default'}"
|
|
219
|
+
)
|
|
220
|
+
console.print(
|
|
221
|
+
f"[bold]Execution mode:[/bold] {config.execution_mode}"
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
@harness_app.command("list")
|
|
226
|
+
def list_harnesses(
|
|
227
|
+
path: Path = typer.Argument(
|
|
228
|
+
Path("."),
|
|
229
|
+
help="Project root or a path inside it.",
|
|
230
|
+
),
|
|
231
|
+
) -> None:
|
|
232
|
+
"""List the configured harness and the installed harnesses."""
|
|
233
|
+
try:
|
|
234
|
+
_root, config = _load_harness_config(path)
|
|
235
|
+
except (ConfigError, FileNotFoundError, NotADirectoryError, OSError) as error:
|
|
236
|
+
_harness_error(error)
|
|
237
|
+
raise typer.Exit(code=1) from error
|
|
238
|
+
installed = {item.name for item in detect_harnesses()}
|
|
239
|
+
console.print(
|
|
240
|
+
f"[bold]Configured:[/bold] {config.agent_harness} "
|
|
241
|
+
f"(model: {config.model or 'default'})"
|
|
242
|
+
)
|
|
243
|
+
for name in adapter_names():
|
|
244
|
+
marker = "*" if name == config.agent_harness else " "
|
|
245
|
+
status = "installed" if name in installed else "not installed"
|
|
246
|
+
console.print(f"{marker} {name} ({status})")
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
@harness_app.command("models")
|
|
250
|
+
def models(
|
|
251
|
+
name: str | None = typer.Argument(
|
|
252
|
+
None,
|
|
253
|
+
help="Harness name. Defaults to the configured harness.",
|
|
254
|
+
),
|
|
255
|
+
path: Path = typer.Argument(
|
|
256
|
+
Path("."),
|
|
257
|
+
help="Project root or a path inside it.",
|
|
258
|
+
),
|
|
259
|
+
) -> None:
|
|
260
|
+
"""List the models advertised by a harness."""
|
|
261
|
+
try:
|
|
262
|
+
_root, config = _load_harness_config(path)
|
|
263
|
+
target = validate_harness_name(name or config.agent_harness)
|
|
264
|
+
if target in {"auto", "none"}:
|
|
265
|
+
msg = "Choose a concrete harness to list models."
|
|
266
|
+
raise ConfigError(msg)
|
|
267
|
+
adapter = adapter_for(target)
|
|
268
|
+
options = adapter.list_models()
|
|
269
|
+
except (ConfigError, FileNotFoundError, NotADirectoryError, OSError) as error:
|
|
270
|
+
_harness_error(error)
|
|
271
|
+
raise typer.Exit(code=1) from error
|
|
272
|
+
if not options:
|
|
273
|
+
console.print(
|
|
274
|
+
f"[yellow]{adapter.display_name} does not expose a model list.[/yellow]"
|
|
275
|
+
)
|
|
276
|
+
console.print(
|
|
277
|
+
"Use --model with a model id supported by the harness."
|
|
278
|
+
)
|
|
279
|
+
return
|
|
280
|
+
for option in options:
|
|
281
|
+
label = f" — {option.label}" if option.label else ""
|
|
282
|
+
console.print(f"- {option.id}{label}")
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
@harness_app.command("use")
|
|
286
|
+
def use(
|
|
287
|
+
name: str = typer.Argument(
|
|
288
|
+
...,
|
|
289
|
+
help="Harness to configure: codex, opencode, claude-code, kiro, antigravity or none.",
|
|
290
|
+
),
|
|
291
|
+
path: Path = typer.Argument(
|
|
292
|
+
Path("."),
|
|
293
|
+
help="Project root or a path inside it.",
|
|
294
|
+
),
|
|
295
|
+
model: str | None = typer.Option(
|
|
296
|
+
None,
|
|
297
|
+
"--model",
|
|
298
|
+
help="Model to persist for the selected harness.",
|
|
299
|
+
),
|
|
300
|
+
) -> None:
|
|
301
|
+
"""Change the harness and generate its integration files."""
|
|
302
|
+
try:
|
|
303
|
+
root, config = _load_harness_config(path)
|
|
304
|
+
canonical = validate_harness_name(name)
|
|
305
|
+
if canonical == "auto":
|
|
306
|
+
msg = (
|
|
307
|
+
"Choose a concrete harness with 'devflow harness use'. "
|
|
308
|
+
"The 'auto' value is resolved at runtime."
|
|
309
|
+
)
|
|
310
|
+
raise ConfigError(msg)
|
|
311
|
+
adapter = None
|
|
312
|
+
if canonical != "none":
|
|
313
|
+
adapter = adapter_for(canonical)
|
|
314
|
+
if not adapter.is_available():
|
|
315
|
+
executable = getattr(adapter, "executable", canonical)
|
|
316
|
+
msg = (
|
|
317
|
+
f"Agent harness '{canonical}' is not installed or not on "
|
|
318
|
+
f"PATH ({executable})."
|
|
319
|
+
)
|
|
320
|
+
raise ConfigError(msg)
|
|
321
|
+
selected_model = model
|
|
322
|
+
if selected_model is None and sys.stdin.isatty():
|
|
323
|
+
selected_model = prompt_for_model(adapter)
|
|
324
|
+
else:
|
|
325
|
+
selected_model = ""
|
|
326
|
+
config = ConfigManager(root).set_agent_harness(
|
|
327
|
+
canonical,
|
|
328
|
+
model=selected_model,
|
|
329
|
+
)
|
|
330
|
+
if adapter is not None:
|
|
331
|
+
profile_manager = ProfileManager()
|
|
332
|
+
profiles = profile_manager.resolve(list(config.profiles))
|
|
333
|
+
constitution = ConstitutionLoader(profile_manager).load(
|
|
334
|
+
config,
|
|
335
|
+
profiles,
|
|
336
|
+
)
|
|
337
|
+
project = ProjectDetector().detect(root)
|
|
338
|
+
result = adapter.setup(
|
|
339
|
+
build_setup_context(
|
|
340
|
+
config=config,
|
|
341
|
+
project=project,
|
|
342
|
+
profiles=profiles,
|
|
343
|
+
constitution=constitution,
|
|
344
|
+
)
|
|
345
|
+
)
|
|
346
|
+
print_setup_result(result, root, console)
|
|
347
|
+
except (
|
|
348
|
+
ConfigError,
|
|
349
|
+
ConstitutionError,
|
|
350
|
+
ProfileError,
|
|
351
|
+
FileNotFoundError,
|
|
352
|
+
NotADirectoryError,
|
|
353
|
+
OSError,
|
|
354
|
+
) as error:
|
|
355
|
+
_harness_error(error)
|
|
356
|
+
raise typer.Exit(code=1) from error
|
|
357
|
+
console.print(f"[bold]Harness:[/bold] {config.agent_harness}")
|
|
358
|
+
console.print(
|
|
359
|
+
f"[bold]Model:[/bold] {config.model or 'harness default'}"
|
|
360
|
+
)
|
devflow/commands/init.py
CHANGED
|
@@ -13,6 +13,7 @@ from devflow.adapters.agents import AgentsFileWriter
|
|
|
13
13
|
from devflow.commands.harness import (
|
|
14
14
|
adapter_for,
|
|
15
15
|
print_setup_result,
|
|
16
|
+
prompt_for_model,
|
|
16
17
|
resolve_harness,
|
|
17
18
|
validate_harness_name,
|
|
18
19
|
)
|
|
@@ -104,6 +105,14 @@ def init(
|
|
|
104
105
|
"Language for specification prose, for example en, es or es-MX."
|
|
105
106
|
),
|
|
106
107
|
),
|
|
108
|
+
model: Optional[str] = typer.Option(
|
|
109
|
+
None,
|
|
110
|
+
"--model",
|
|
111
|
+
help=(
|
|
112
|
+
"Harness model to persist. When omitted, DevFlow asks for one "
|
|
113
|
+
"during an interactive init."
|
|
114
|
+
),
|
|
115
|
+
),
|
|
107
116
|
) -> None:
|
|
108
117
|
"""Initialize DevFlow in a project."""
|
|
109
118
|
try:
|
|
@@ -117,6 +126,7 @@ def init(
|
|
|
117
126
|
no_agent,
|
|
118
127
|
project_mode,
|
|
119
128
|
language,
|
|
129
|
+
model,
|
|
120
130
|
)
|
|
121
131
|
except (
|
|
122
132
|
ArchitectureError,
|
|
@@ -140,8 +150,10 @@ def _initialize(
|
|
|
140
150
|
no_agent: bool,
|
|
141
151
|
project_mode: Optional[str],
|
|
142
152
|
language: Optional[str],
|
|
153
|
+
model: Optional[str],
|
|
143
154
|
) -> None:
|
|
144
155
|
requested_harness = _requested_harness(harness, no_agent)
|
|
156
|
+
requested_model = (model or "").strip()
|
|
145
157
|
execution_mode = _requested_mode(mode)
|
|
146
158
|
requested_project_mode = _requested_project_mode(project_mode)
|
|
147
159
|
requested_language = (
|
|
@@ -149,6 +161,8 @@ def _initialize(
|
|
|
149
161
|
if language is not None
|
|
150
162
|
else DEFAULT_DOCUMENTATION_LANGUAGE
|
|
151
163
|
)
|
|
164
|
+
if language is None and not yes and sys.stdin.isatty():
|
|
165
|
+
requested_language = _prompt_for_language()
|
|
152
166
|
if not requested_language:
|
|
153
167
|
msg = "The documentation language cannot be empty."
|
|
154
168
|
raise ConfigError(msg)
|
|
@@ -198,6 +212,8 @@ def _initialize(
|
|
|
198
212
|
project_mode_override=project_mode is not None,
|
|
199
213
|
language=requested_language,
|
|
200
214
|
language_override=language is not None,
|
|
215
|
+
model=requested_model,
|
|
216
|
+
model_override=model is not None,
|
|
201
217
|
allow_prompt=not yes and sys.stdin.isatty(),
|
|
202
218
|
)
|
|
203
219
|
return
|
|
@@ -231,6 +247,7 @@ def _initialize(
|
|
|
231
247
|
project_mode=requested_project_mode,
|
|
232
248
|
agent_harness=requested_harness,
|
|
233
249
|
execution_mode=execution_mode,
|
|
250
|
+
model=requested_model,
|
|
234
251
|
documentation_language=requested_language,
|
|
235
252
|
)
|
|
236
253
|
config_manager.ensure_directories(config)
|
|
@@ -248,6 +265,13 @@ def _initialize(
|
|
|
248
265
|
requested_harness=requested_harness,
|
|
249
266
|
allow_prompt=not yes and sys.stdin.isatty(),
|
|
250
267
|
)
|
|
268
|
+
if selected_harness is not None:
|
|
269
|
+
if requested_model:
|
|
270
|
+
config = config_manager.set_agent_model(requested_model)
|
|
271
|
+
elif not yes and sys.stdin.isatty():
|
|
272
|
+
chosen_model = prompt_for_model(adapter_for(selected_harness))
|
|
273
|
+
if chosen_model is not None:
|
|
274
|
+
config = config_manager.set_agent_model(chosen_model)
|
|
251
275
|
|
|
252
276
|
console.print(f"[bold]Project:[/bold] {project.name}")
|
|
253
277
|
console.print(f"[bold]Root:[/bold] {config.root}")
|
|
@@ -304,6 +328,23 @@ def _initialize(
|
|
|
304
328
|
)
|
|
305
329
|
|
|
306
330
|
|
|
331
|
+
def _prompt_for_language() -> str:
|
|
332
|
+
"""Ask for the documentation language during interactive initialization."""
|
|
333
|
+
console.print(
|
|
334
|
+
"[bold]Documentation language:[/bold] en, es, pt, fr, de, it, "
|
|
335
|
+
"or a BCP-47 tag such as es-MX."
|
|
336
|
+
)
|
|
337
|
+
value = typer.prompt(
|
|
338
|
+
"Documentation language",
|
|
339
|
+
default=DEFAULT_DOCUMENTATION_LANGUAGE,
|
|
340
|
+
)
|
|
341
|
+
normalized = canonical_documentation_language(value)
|
|
342
|
+
if not normalized:
|
|
343
|
+
msg = "The documentation language cannot be empty."
|
|
344
|
+
raise ConfigError(msg)
|
|
345
|
+
return normalized
|
|
346
|
+
|
|
347
|
+
|
|
307
348
|
def _refresh_existing(
|
|
308
349
|
config: DevFlowConfig,
|
|
309
350
|
config_manager: ConfigManager,
|
|
@@ -319,6 +360,8 @@ def _refresh_existing(
|
|
|
319
360
|
project_mode_override: bool,
|
|
320
361
|
language: str,
|
|
321
362
|
language_override: bool,
|
|
363
|
+
model: str,
|
|
364
|
+
model_override: bool,
|
|
322
365
|
allow_prompt: bool,
|
|
323
366
|
) -> None:
|
|
324
367
|
if explicit_profiles:
|
|
@@ -338,11 +381,21 @@ def _refresh_existing(
|
|
|
338
381
|
)
|
|
339
382
|
raise ProfileError(msg)
|
|
340
383
|
|
|
341
|
-
if harness_override or mode_override:
|
|
384
|
+
if harness_override or mode_override or model_override:
|
|
342
385
|
config = config_manager.set_agent_harness(
|
|
343
386
|
requested_harness if harness_override else config.agent_harness,
|
|
344
387
|
execution_mode if mode_override else None,
|
|
388
|
+
model=model if model_override else None,
|
|
345
389
|
)
|
|
390
|
+
if (
|
|
391
|
+
allow_prompt
|
|
392
|
+
and not model_override
|
|
393
|
+
and not config.model
|
|
394
|
+
and config.agent_harness not in {"auto", "none"}
|
|
395
|
+
):
|
|
396
|
+
chosen_model = prompt_for_model(adapter_for(config.agent_harness))
|
|
397
|
+
if chosen_model is not None:
|
|
398
|
+
config = config_manager.set_agent_model(chosen_model)
|
|
346
399
|
if project_mode_override:
|
|
347
400
|
config = config_manager.set_project_mode(project_mode)
|
|
348
401
|
if language_override:
|