devflow-toolkit 0.4.3__py3-none-any.whl → 0.4.5__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 +21 -7
- devflow/adapters/claude_code.py +27 -6
- devflow/adapters/instructions.py +3 -1
- devflow/adapters/kiro.py +21 -7
- devflow/adapters/opencode.py +55 -34
- devflow/commands/approve.py +3 -2
- devflow/commands/config.py +2 -1
- devflow/commands/doctor.py +2 -1
- devflow/commands/harness.py +3 -2
- devflow/commands/init.py +4 -3
- devflow/commands/recover.py +2 -1
- devflow/commands/reopen.py +63 -25
- devflow/commands/security.py +2 -1
- devflow/commands/spec.py +77 -4
- devflow/commands/status.py +30 -17
- devflow/core/artifacts/store.py +29 -3
- devflow/core/config.py +27 -1
- devflow/core/ports.py +9 -1
- devflow/core/safe_files.py +36 -0
- devflow/core/security_tools.py +24 -7
- devflow/core/spec_workflow.py +211 -5
- devflow/core/specification.py +20 -3
- devflow/core/state/events.py +56 -7
- devflow/core/state/lock.py +5 -1
- devflow/core/state/manager.py +131 -32
- devflow/core/state/signing.py +107 -0
- devflow/hooks/claude_guard.py +10 -1
- devflow/prompts/__init__.py +6 -2
- {devflow_toolkit-0.4.3.dist-info → devflow_toolkit-0.4.5.dist-info}/METADATA +88 -23
- {devflow_toolkit-0.4.3.dist-info → devflow_toolkit-0.4.5.dist-info}/RECORD +33 -31
- {devflow_toolkit-0.4.3.dist-info → devflow_toolkit-0.4.5.dist-info}/WHEEL +0 -0
- {devflow_toolkit-0.4.3.dist-info → devflow_toolkit-0.4.5.dist-info}/entry_points.txt +0 -0
- {devflow_toolkit-0.4.3.dist-info → devflow_toolkit-0.4.5.dist-info}/licenses/LICENSE +0 -0
devflow/adapters/antigravity.py
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import json
|
|
6
|
+
import os
|
|
6
7
|
import subprocess
|
|
8
|
+
import tempfile
|
|
7
9
|
from pathlib import Path
|
|
8
10
|
from typing import Any
|
|
9
11
|
|
|
@@ -39,6 +41,10 @@ class AntigravityAdapter(HarnessAdapter):
|
|
|
39
41
|
name = "antigravity"
|
|
40
42
|
display_name = "Antigravity"
|
|
41
43
|
executable = "agy"
|
|
44
|
+
agent_definition_files = (
|
|
45
|
+
f".agents/agents/{INTERACTIVE_AGENT}.md",
|
|
46
|
+
f".agents/agents/{READONLY_AGENT}.md",
|
|
47
|
+
)
|
|
42
48
|
|
|
43
49
|
def setup(self, context: SetupContext) -> SetupResult:
|
|
44
50
|
changes: list[FileChange] = []
|
|
@@ -157,14 +163,22 @@ class AntigravityAdapter(HarnessAdapter):
|
|
|
157
163
|
|
|
158
164
|
def list_models(self) -> tuple[ModelOption, ...]:
|
|
159
165
|
"""Return models reported by ``agy models``."""
|
|
166
|
+
if not self.is_available():
|
|
167
|
+
return ()
|
|
160
168
|
try:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
169
|
+
# Run outside the project so the harness does not load the
|
|
170
|
+
# repository's own configuration, plugins or MCP servers.
|
|
171
|
+
with tempfile.TemporaryDirectory() as neutral:
|
|
172
|
+
result = subprocess.run( # noqa: S603
|
|
173
|
+
[self.executable, "models"],
|
|
174
|
+
capture_output=True,
|
|
175
|
+
text=True,
|
|
176
|
+
timeout=30,
|
|
177
|
+
check=False,
|
|
178
|
+
cwd=neutral,
|
|
179
|
+
# OpenCode resolves the project from PWD, not the cwd.
|
|
180
|
+
env={**os.environ, "PWD": neutral},
|
|
181
|
+
)
|
|
168
182
|
except (OSError, subprocess.SubprocessError):
|
|
169
183
|
return ()
|
|
170
184
|
if result.returncode != 0:
|
devflow/adapters/claude_code.py
CHANGED
|
@@ -19,6 +19,7 @@ from devflow.adapters.instructions import (
|
|
|
19
19
|
write_gitignore_entries,
|
|
20
20
|
write_text_managed,
|
|
21
21
|
)
|
|
22
|
+
from devflow.core.safe_files import WORKFLOW_STATE_FILES
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
class ClaudeCodeAdapter(HarnessAdapter):
|
|
@@ -65,11 +66,16 @@ class ClaudeCodeAdapter(HarnessAdapter):
|
|
|
65
66
|
"manual" if context.mode == "interactive" else "dontAsk"
|
|
66
67
|
)
|
|
67
68
|
model = ("--model", context.model) if context.model else ()
|
|
69
|
+
# Load only the user's own settings and no MCP servers: hooks,
|
|
70
|
+
# permissions and MCP servers committed in the project's .claude/ or
|
|
71
|
+
# .mcp.json must not run with DevFlow's agent session.
|
|
72
|
+
isolation = ("--setting-sources", "user", "--strict-mcp-config")
|
|
68
73
|
|
|
69
74
|
if context.mode == "interactive":
|
|
70
75
|
argv = (
|
|
71
76
|
self.executable,
|
|
72
77
|
*model,
|
|
78
|
+
*isolation,
|
|
73
79
|
"--permission-mode",
|
|
74
80
|
permission_mode,
|
|
75
81
|
"--settings",
|
|
@@ -85,6 +91,7 @@ class ClaudeCodeAdapter(HarnessAdapter):
|
|
|
85
91
|
self.executable,
|
|
86
92
|
"-p",
|
|
87
93
|
*model,
|
|
94
|
+
*isolation,
|
|
88
95
|
"--output-format",
|
|
89
96
|
"text",
|
|
90
97
|
"--permission-mode",
|
|
@@ -125,9 +132,12 @@ class ClaudeCodeAdapter(HarnessAdapter):
|
|
|
125
132
|
):
|
|
126
133
|
return {}
|
|
127
134
|
allowed = context.spec_directory.parent
|
|
135
|
+
# Claude Code runs the hook from the project directory; `-P` keeps a
|
|
136
|
+
# `devflow/` package in an untrusted project from replacing the guard.
|
|
128
137
|
command = " ".join(
|
|
129
138
|
[
|
|
130
139
|
shlex.quote(sys.executable),
|
|
140
|
+
"-P",
|
|
131
141
|
"-m",
|
|
132
142
|
"devflow.hooks.claude_guard",
|
|
133
143
|
shlex.quote(str(allowed)),
|
|
@@ -145,12 +155,11 @@ class ClaudeCodeAdapter(HarnessAdapter):
|
|
|
145
155
|
def _permission_rules(
|
|
146
156
|
self,
|
|
147
157
|
context: RunContext,
|
|
148
|
-
) -> dict[str,
|
|
158
|
+
) -> dict[str, object]:
|
|
159
|
+
# Reads inside the project need no rule. A bare "Read" allow would
|
|
160
|
+
# also pre-approve reads anywhere on disk, so none is added.
|
|
149
161
|
allow: list[str] = []
|
|
150
|
-
deny: list[str] = []
|
|
151
|
-
|
|
152
|
-
if context.permissions.allow_project_read:
|
|
153
|
-
allow.extend(["Read", "Grep", "Glob"])
|
|
162
|
+
deny: list[str] = ["mcp__*", "Read(./**/.env)", "Read(./**/.env.*)"]
|
|
154
163
|
|
|
155
164
|
if context.permissions.allow_source_code_changes:
|
|
156
165
|
allow.extend(["Edit", "Write", "Bash"])
|
|
@@ -163,7 +172,19 @@ class ClaudeCodeAdapter(HarnessAdapter):
|
|
|
163
172
|
)
|
|
164
173
|
|
|
165
174
|
deny.extend(["WebFetch", "WebSearch", "Task"])
|
|
175
|
+
for name in WORKFLOW_STATE_FILES:
|
|
176
|
+
deny.extend(
|
|
177
|
+
[
|
|
178
|
+
f"Edit(.devflow/specs/**/{name})",
|
|
179
|
+
f"Write(.devflow/specs/**/{name})",
|
|
180
|
+
]
|
|
181
|
+
)
|
|
166
182
|
if not context.permissions.allow_source_code_changes:
|
|
167
183
|
deny.extend(["Bash", "NotebookEdit"])
|
|
168
184
|
|
|
169
|
-
return {
|
|
185
|
+
return {
|
|
186
|
+
"allow": allow,
|
|
187
|
+
"deny": deny,
|
|
188
|
+
"blockReadsOutsideWorkingDirectories": True,
|
|
189
|
+
"blockWritesOutsideWorkingDirectories": True,
|
|
190
|
+
}
|
devflow/adapters/instructions.py
CHANGED
|
@@ -76,7 +76,9 @@ def _write_atomic(path: Path, content: str) -> None:
|
|
|
76
76
|
|
|
77
77
|
mode = 0o644
|
|
78
78
|
try:
|
|
79
|
-
|
|
79
|
+
# Keep the owner's read/write choice, but never carry over special,
|
|
80
|
+
# executable or world-writable bits from the file being replaced.
|
|
81
|
+
mode = stat.S_IMODE(path.stat().st_mode) & 0o664
|
|
80
82
|
except OSError:
|
|
81
83
|
pass
|
|
82
84
|
os.chmod(temporary, mode)
|
devflow/adapters/kiro.py
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import os
|
|
5
6
|
import subprocess
|
|
7
|
+
import tempfile
|
|
6
8
|
|
|
7
9
|
from devflow.adapters.base import (
|
|
8
10
|
FileChange,
|
|
@@ -31,6 +33,10 @@ class KiroAdapter(HarnessAdapter):
|
|
|
31
33
|
name = "kiro"
|
|
32
34
|
display_name = "Kiro"
|
|
33
35
|
executable = "kiro-cli"
|
|
36
|
+
agent_definition_files = (
|
|
37
|
+
f".kiro/agents/{INTERACTIVE_AGENT}.json",
|
|
38
|
+
f".kiro/agents/{READONLY_AGENT}.json",
|
|
39
|
+
)
|
|
34
40
|
|
|
35
41
|
def setup(self, context: SetupContext) -> SetupResult:
|
|
36
42
|
changes: list[FileChange] = []
|
|
@@ -154,14 +160,22 @@ class KiroAdapter(HarnessAdapter):
|
|
|
154
160
|
|
|
155
161
|
def list_models(self) -> tuple[ModelOption, ...]:
|
|
156
162
|
"""Return models reported by ``kiro-cli chat --list-models``."""
|
|
163
|
+
if not self.is_available():
|
|
164
|
+
return ()
|
|
157
165
|
try:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
166
|
+
# Run outside the project so the harness does not load the
|
|
167
|
+
# repository's own configuration, plugins or MCP servers.
|
|
168
|
+
with tempfile.TemporaryDirectory() as neutral:
|
|
169
|
+
result = subprocess.run( # noqa: S603
|
|
170
|
+
[self.executable, "chat", "--list-models"],
|
|
171
|
+
capture_output=True,
|
|
172
|
+
text=True,
|
|
173
|
+
timeout=30,
|
|
174
|
+
check=False,
|
|
175
|
+
cwd=neutral,
|
|
176
|
+
# OpenCode resolves the project from PWD, not the cwd.
|
|
177
|
+
env={**os.environ, "PWD": neutral},
|
|
178
|
+
)
|
|
165
179
|
except (OSError, subprocess.SubprocessError):
|
|
166
180
|
return ()
|
|
167
181
|
if result.returncode != 0:
|
devflow/adapters/opencode.py
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import os
|
|
5
6
|
import subprocess
|
|
7
|
+
import tempfile
|
|
6
8
|
|
|
7
9
|
import yaml
|
|
8
10
|
|
|
@@ -15,6 +17,7 @@ from devflow.adapters.base import (
|
|
|
15
17
|
SetupResult,
|
|
16
18
|
)
|
|
17
19
|
from devflow.core.ports import ModelOption
|
|
20
|
+
from devflow.core.safe_files import WORKFLOW_STATE_FILES
|
|
18
21
|
from devflow.adapters.instructions import (
|
|
19
22
|
MANAGED_MARKER,
|
|
20
23
|
render_agent_instructions,
|
|
@@ -33,6 +36,10 @@ class OpenCodeAdapter(HarnessAdapter):
|
|
|
33
36
|
name = "opencode"
|
|
34
37
|
display_name = "OpenCode"
|
|
35
38
|
executable = "opencode"
|
|
39
|
+
agent_definition_files = (
|
|
40
|
+
f".opencode/agents/{INTERACTIVE_AGENT}.md",
|
|
41
|
+
f".opencode/agents/{READONLY_AGENT}.md",
|
|
42
|
+
)
|
|
36
43
|
|
|
37
44
|
def setup(self, context: SetupContext) -> SetupResult:
|
|
38
45
|
changes: list[FileChange] = []
|
|
@@ -148,14 +155,22 @@ class OpenCodeAdapter(HarnessAdapter):
|
|
|
148
155
|
|
|
149
156
|
def list_models(self) -> tuple[ModelOption, ...]:
|
|
150
157
|
"""Return models reported by ``opencode models``."""
|
|
158
|
+
if not self.is_available():
|
|
159
|
+
return ()
|
|
151
160
|
try:
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
161
|
+
# Run outside the project so the harness does not load the
|
|
162
|
+
# repository's own configuration, plugins or MCP servers.
|
|
163
|
+
with tempfile.TemporaryDirectory() as neutral:
|
|
164
|
+
result = subprocess.run( # noqa: S603
|
|
165
|
+
[self.executable, "models"],
|
|
166
|
+
capture_output=True,
|
|
167
|
+
text=True,
|
|
168
|
+
timeout=30,
|
|
169
|
+
check=False,
|
|
170
|
+
cwd=neutral,
|
|
171
|
+
# OpenCode resolves the project from PWD, not the cwd.
|
|
172
|
+
env={**os.environ, "PWD": neutral},
|
|
173
|
+
)
|
|
159
174
|
except (OSError, subprocess.SubprocessError):
|
|
160
175
|
return ()
|
|
161
176
|
if result.returncode != 0:
|
|
@@ -247,52 +262,58 @@ class OpenCodeAdapter(HarnessAdapter):
|
|
|
247
262
|
*,
|
|
248
263
|
interactive: bool,
|
|
249
264
|
) -> list[dict[str, str]]:
|
|
250
|
-
|
|
265
|
+
"""Build OpenCode V2 rules; the last matching rule wins.
|
|
266
|
+
|
|
267
|
+
OpenCode starts every agent from an allow-all policy, so the list
|
|
268
|
+
opens with a deny-all rule. Anything not granted below, such as MCP
|
|
269
|
+
tools, skills or image generation, stays denied.
|
|
270
|
+
"""
|
|
271
|
+
specs = context.config.specifications_path.relative_to(
|
|
272
|
+
context.config.root
|
|
273
|
+
).as_posix()
|
|
274
|
+
permissions: list[dict[str, str]] = [
|
|
275
|
+
{"action": "*", "resource": "*", "effect": "deny"},
|
|
276
|
+
]
|
|
251
277
|
if context.permissions.allow_project_read:
|
|
252
278
|
for action in ("read", "glob", "grep"):
|
|
253
279
|
permissions.append(
|
|
254
280
|
{"action": action, "resource": "*", "effect": "allow"}
|
|
255
281
|
)
|
|
282
|
+
for pattern, effect in (
|
|
283
|
+
("*.env", "deny"),
|
|
284
|
+
("*.env.*", "deny"),
|
|
285
|
+
("*.env.example", "allow"),
|
|
286
|
+
):
|
|
287
|
+
permissions.append(
|
|
288
|
+
{"action": "read", "resource": pattern, "effect": effect}
|
|
289
|
+
)
|
|
256
290
|
|
|
257
291
|
if context.permissions.allow_source_code_changes:
|
|
258
292
|
permissions.append(
|
|
259
293
|
{"action": "edit", "resource": "*", "effect": "allow"}
|
|
260
294
|
)
|
|
295
|
+
permissions.append(
|
|
296
|
+
{"action": "shell", "resource": "*", "effect": "allow"}
|
|
297
|
+
)
|
|
261
298
|
elif context.permissions.allow_spec_write:
|
|
262
299
|
permissions.append(
|
|
263
|
-
{"action": "edit", "resource": "
|
|
300
|
+
{"action": "edit", "resource": f"{specs}/*", "effect": "allow"}
|
|
264
301
|
)
|
|
302
|
+
for name in WORKFLOW_STATE_FILES:
|
|
265
303
|
permissions.append(
|
|
266
304
|
{
|
|
267
305
|
"action": "edit",
|
|
268
|
-
"resource": "
|
|
269
|
-
"effect": "
|
|
306
|
+
"resource": f"{specs}/*/{name}",
|
|
307
|
+
"effect": "deny",
|
|
270
308
|
}
|
|
271
309
|
)
|
|
272
|
-
|
|
310
|
+
if interactive:
|
|
273
311
|
permissions.append(
|
|
274
|
-
{"action": "
|
|
312
|
+
{"action": "question", "resource": "*", "effect": "allow"}
|
|
275
313
|
)
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
"action": "shell",
|
|
281
|
-
"resource": "*",
|
|
282
|
-
"effect": (
|
|
283
|
-
"allow"
|
|
284
|
-
if context.permissions.allow_source_code_changes
|
|
285
|
-
else "deny"
|
|
286
|
-
),
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
"action": "question",
|
|
290
|
-
"resource": "*",
|
|
291
|
-
"effect": "allow" if interactive else "deny",
|
|
292
|
-
},
|
|
293
|
-
{"action": "webfetch", "resource": "*", "effect": "deny"},
|
|
294
|
-
{"action": "websearch", "resource": "*", "effect": "deny"},
|
|
295
|
-
{"action": "subagent", "resource": "*", "effect": "deny"},
|
|
296
|
-
]
|
|
314
|
+
# Paths outside the project are checked against external_directory
|
|
315
|
+
# before read or edit rules.
|
|
316
|
+
permissions.append(
|
|
317
|
+
{"action": "external_directory", "resource": "*", "effect": "deny"}
|
|
297
318
|
)
|
|
298
319
|
return permissions
|
devflow/commands/approve.py
CHANGED
|
@@ -7,6 +7,7 @@ from pathlib import Path
|
|
|
7
7
|
|
|
8
8
|
import typer
|
|
9
9
|
from rich.console import Console
|
|
10
|
+
from rich.markup import escape
|
|
10
11
|
|
|
11
12
|
from devflow.commands.security import offer_security_tools
|
|
12
13
|
from devflow.core.artifacts.errors import ArtifactError
|
|
@@ -54,7 +55,7 @@ def approve(
|
|
|
54
55
|
NotADirectoryError,
|
|
55
56
|
OSError,
|
|
56
57
|
) as error:
|
|
57
|
-
error_console.print(f"[red]Error:[/red] {error}")
|
|
58
|
+
error_console.print(f"[red]Error:[/red] {escape(str(error))}")
|
|
58
59
|
raise typer.Exit(code=1) from error
|
|
59
60
|
|
|
60
61
|
|
|
@@ -76,7 +77,7 @@ def _approve(spec_id: str, path: Path, stage: str) -> None:
|
|
|
76
77
|
location = WorkflowLocator(config.specifications_path).find(spec_id)
|
|
77
78
|
result = manager.approve(location, normalized)
|
|
78
79
|
for warning in result.warnings:
|
|
79
|
-
console.print(f"[yellow]Warning:[/yellow] {warning}")
|
|
80
|
+
console.print(f"[yellow]Warning:[/yellow] {escape(warning)}")
|
|
80
81
|
|
|
81
82
|
if not result.changed:
|
|
82
83
|
console.print(
|
devflow/commands/config.py
CHANGED
|
@@ -6,6 +6,7 @@ from pathlib import Path
|
|
|
6
6
|
|
|
7
7
|
import typer
|
|
8
8
|
from rich.console import Console
|
|
9
|
+
from rich.markup import escape
|
|
9
10
|
|
|
10
11
|
from devflow.core.config import ConfigError, ConfigManager
|
|
11
12
|
from devflow.core.project import ProjectDetector
|
|
@@ -40,7 +41,7 @@ def language(
|
|
|
40
41
|
NotADirectoryError,
|
|
41
42
|
OSError,
|
|
42
43
|
) as error:
|
|
43
|
-
error_console.print(f"[red]Error:[/red] {error}")
|
|
44
|
+
error_console.print(f"[red]Error:[/red] {escape(str(error))}")
|
|
44
45
|
raise typer.Exit(code=1) from error
|
|
45
46
|
|
|
46
47
|
console.print(
|
devflow/commands/doctor.py
CHANGED
|
@@ -6,6 +6,7 @@ from pathlib import Path
|
|
|
6
6
|
|
|
7
7
|
import typer
|
|
8
8
|
from rich.console import Console
|
|
9
|
+
from rich.markup import escape
|
|
9
10
|
|
|
10
11
|
from devflow.core.artifacts.errors import ArtifactError
|
|
11
12
|
from devflow.core.config import ConfigError, ConfigManager
|
|
@@ -40,7 +41,7 @@ def doctor(
|
|
|
40
41
|
NotADirectoryError,
|
|
41
42
|
OSError,
|
|
42
43
|
) as error:
|
|
43
|
-
error_console.print(f"[red]Error:[/red] {error}")
|
|
44
|
+
error_console.print(f"[red]Error:[/red] {escape(str(error))}")
|
|
44
45
|
raise typer.Exit(code=1) from error
|
|
45
46
|
if not healthy:
|
|
46
47
|
raise typer.Exit(code=1)
|
devflow/commands/harness.py
CHANGED
|
@@ -7,6 +7,7 @@ from pathlib import Path
|
|
|
7
7
|
|
|
8
8
|
import typer
|
|
9
9
|
from rich.console import Console
|
|
10
|
+
from rich.markup import escape
|
|
10
11
|
|
|
11
12
|
from devflow.adapters.detector import (
|
|
12
13
|
detect_harnesses,
|
|
@@ -160,7 +161,7 @@ def print_setup_result(
|
|
|
160
161
|
relative = change.path.relative_to(root)
|
|
161
162
|
console.print(f"[{color}]Agent integration {label}:[/{color}] {relative}")
|
|
162
163
|
for warning in result.warnings:
|
|
163
|
-
console.print(f"[yellow]Warning:[/yellow] {warning}")
|
|
164
|
+
console.print(f"[yellow]Warning:[/yellow] {escape(warning)}")
|
|
164
165
|
|
|
165
166
|
|
|
166
167
|
def _prompt_for_harness(
|
|
@@ -197,7 +198,7 @@ def _load_harness_config(path: Path) -> tuple[Path, DevFlowConfig]:
|
|
|
197
198
|
|
|
198
199
|
|
|
199
200
|
def _harness_error(error: Exception) -> None:
|
|
200
|
-
error_console.print(f"[red]Error:[/red] {error}")
|
|
201
|
+
error_console.print(f"[red]Error:[/red] {escape(str(error))}")
|
|
201
202
|
|
|
202
203
|
|
|
203
204
|
@harness_app.command("current")
|
devflow/commands/init.py
CHANGED
|
@@ -8,6 +8,7 @@ from typing import Optional
|
|
|
8
8
|
|
|
9
9
|
import typer
|
|
10
10
|
from rich.console import Console
|
|
11
|
+
from rich.markup import escape
|
|
11
12
|
|
|
12
13
|
from devflow.adapters.agents import AgentsFileWriter
|
|
13
14
|
from devflow.commands.harness import (
|
|
@@ -150,7 +151,7 @@ def init(
|
|
|
150
151
|
NotADirectoryError,
|
|
151
152
|
OSError,
|
|
152
153
|
) as error:
|
|
153
|
-
error_console.print(f"[red]Error:[/red] {error}")
|
|
154
|
+
error_console.print(f"[red]Error:[/red] {escape(str(error))}")
|
|
154
155
|
raise typer.Exit(code=1) from error
|
|
155
156
|
|
|
156
157
|
|
|
@@ -475,7 +476,7 @@ def _refresh_existing(
|
|
|
475
476
|
)
|
|
476
477
|
|
|
477
478
|
for warning in constitution.warnings:
|
|
478
|
-
console.print(f"[yellow]Warning:[/yellow] {warning}")
|
|
479
|
+
console.print(f"[yellow]Warning:[/yellow] {escape(warning)}")
|
|
479
480
|
|
|
480
481
|
_report_harness(
|
|
481
482
|
config.agent_harness,
|
|
@@ -622,7 +623,7 @@ def _report_harness(
|
|
|
622
623
|
f"[bold]Execution mode:[/bold] {config.execution_mode}"
|
|
623
624
|
)
|
|
624
625
|
for warning in warnings:
|
|
625
|
-
console.print(f"[yellow]Warning:[/yellow] {warning}")
|
|
626
|
+
console.print(f"[yellow]Warning:[/yellow] {escape(warning)}")
|
|
626
627
|
if setup_result is not None:
|
|
627
628
|
print_setup_result(setup_result, config.root, console)
|
|
628
629
|
|
devflow/commands/recover.py
CHANGED
|
@@ -6,6 +6,7 @@ from pathlib import Path
|
|
|
6
6
|
|
|
7
7
|
import typer
|
|
8
8
|
from rich.console import Console
|
|
9
|
+
from rich.markup import escape
|
|
9
10
|
|
|
10
11
|
from devflow.core.artifacts.errors import ArtifactError
|
|
11
12
|
from devflow.core.config import ConfigError, ConfigManager
|
|
@@ -40,7 +41,7 @@ def recover(
|
|
|
40
41
|
NotADirectoryError,
|
|
41
42
|
OSError,
|
|
42
43
|
) as error:
|
|
43
|
-
error_console.print(f"[red]Error:[/red] {error}")
|
|
44
|
+
error_console.print(f"[red]Error:[/red] {escape(str(error))}")
|
|
44
45
|
raise typer.Exit(code=1) from error
|
|
45
46
|
|
|
46
47
|
|
devflow/commands/reopen.py
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from pathlib import Path
|
|
6
|
+
from typing import Optional
|
|
6
7
|
|
|
7
8
|
import typer
|
|
8
9
|
from rich.console import Console
|
|
10
|
+
from rich.markup import escape
|
|
9
11
|
|
|
10
12
|
from devflow.core.artifacts.errors import ArtifactError
|
|
11
13
|
from devflow.core.config import ConfigError, ConfigManager
|
|
@@ -33,7 +35,18 @@ def reopen(
|
|
|
33
35
|
discovery: bool = typer.Option(
|
|
34
36
|
False,
|
|
35
37
|
"--discovery",
|
|
36
|
-
help=
|
|
38
|
+
help=(
|
|
39
|
+
"Reopen Discovery so the agent asks about new or changed "
|
|
40
|
+
"decisions. Works on approved and not-yet-approved changes."
|
|
41
|
+
),
|
|
42
|
+
),
|
|
43
|
+
add: Optional[str] = typer.Option(
|
|
44
|
+
None,
|
|
45
|
+
"--add",
|
|
46
|
+
help=(
|
|
47
|
+
"What to add or change, for example \"password recovery by "
|
|
48
|
+
"email\". Implies --discovery."
|
|
49
|
+
),
|
|
37
50
|
),
|
|
38
51
|
yes: bool = typer.Option(
|
|
39
52
|
False,
|
|
@@ -42,9 +55,9 @@ def reopen(
|
|
|
42
55
|
help="Do not ask for confirmation.",
|
|
43
56
|
),
|
|
44
57
|
) -> None:
|
|
45
|
-
"""Reopen
|
|
58
|
+
"""Reopen a specification to change or extend it."""
|
|
46
59
|
try:
|
|
47
|
-
_reopen(spec_id, path, discovery=discovery, yes=yes)
|
|
60
|
+
_reopen(spec_id, path, discovery=discovery, add=add or "", yes=yes)
|
|
48
61
|
except (
|
|
49
62
|
ArtifactError,
|
|
50
63
|
ConfigError,
|
|
@@ -54,52 +67,77 @@ def reopen(
|
|
|
54
67
|
NotADirectoryError,
|
|
55
68
|
OSError,
|
|
56
69
|
) as error:
|
|
57
|
-
error_console.print(f"[red]Error:[/red] {error}")
|
|
70
|
+
error_console.print(f"[red]Error:[/red] {escape(str(error))}")
|
|
58
71
|
raise typer.Exit(code=1) from error
|
|
59
72
|
|
|
60
73
|
|
|
61
|
-
def _reopen(
|
|
74
|
+
def _reopen(
|
|
75
|
+
spec_id: str,
|
|
76
|
+
path: Path,
|
|
77
|
+
*,
|
|
78
|
+
discovery: bool,
|
|
79
|
+
add: str,
|
|
80
|
+
yes: bool,
|
|
81
|
+
) -> None:
|
|
62
82
|
root = ProjectDetector().find_root(path)
|
|
63
83
|
config = ConfigManager(root).load()
|
|
64
84
|
location = WorkflowLocator(config.specifications_path).find(spec_id)
|
|
65
|
-
|
|
66
|
-
if not yes and not typer.confirm(
|
|
67
|
-
f"Reopen the approved specification {location.change}?",
|
|
68
|
-
default=False,
|
|
69
|
-
):
|
|
70
|
-
console.print("Cancelled. Nothing was changed.")
|
|
71
|
-
raise typer.Exit(code=1)
|
|
72
|
-
|
|
73
85
|
manager = WorkflowStateManager(
|
|
74
86
|
config.specifications_path,
|
|
75
87
|
project_root=config.root,
|
|
76
88
|
)
|
|
77
|
-
|
|
89
|
+
discovery = discovery or bool(add.strip())
|
|
90
|
+
approved = "spec" in manager.load(location).approvals
|
|
78
91
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
92
|
+
if approved:
|
|
93
|
+
question = (
|
|
94
|
+
f"Withdraw the approval of {location.change} so it can be changed?"
|
|
95
|
+
)
|
|
96
|
+
elif discovery:
|
|
97
|
+
question = (
|
|
98
|
+
f"Reopen Discovery of {location.change} to add or change decisions?"
|
|
99
|
+
)
|
|
100
|
+
else:
|
|
101
|
+
question = ""
|
|
102
|
+
if question and not yes and not typer.confirm(question, default=False):
|
|
103
|
+
console.print("Cancelled. Nothing was changed.")
|
|
104
|
+
raise typer.Exit(code=1)
|
|
105
|
+
|
|
106
|
+
result = manager.reopen(location, discovery=discovery, addition=add)
|
|
107
|
+
|
|
108
|
+
if result.approval_withdrawn:
|
|
109
|
+
console.print(
|
|
110
|
+
f"[bold green]Reopened {location.change}.[/bold green] "
|
|
111
|
+
"The spec approval was withdrawn."
|
|
112
|
+
)
|
|
113
|
+
else:
|
|
114
|
+
console.print(
|
|
115
|
+
f"[bold green]Reopened Discovery of {location.change}."
|
|
116
|
+
"[/bold green]"
|
|
117
|
+
)
|
|
83
118
|
if result.archived is not None:
|
|
84
119
|
console.print(
|
|
85
120
|
"Approved spec archived: "
|
|
86
121
|
f"{manager.store.display_path(result.archived)}"
|
|
87
122
|
)
|
|
123
|
+
if add.strip():
|
|
124
|
+
console.print(f"Recorded what to add: {escape(add.strip())}")
|
|
88
125
|
console.print(f"Workflow status: {result.state.status}")
|
|
89
126
|
|
|
90
127
|
continue_command = f"devflow spec --continue {location.spec_id}"
|
|
91
128
|
if discovery:
|
|
92
129
|
console.print(
|
|
93
130
|
f"\n[bold]Next:[/bold] {continue_command}\n"
|
|
94
|
-
"[dim]
|
|
95
|
-
"command again to write the
|
|
96
|
-
f"devflow approve {location.spec_id}.[/dim]"
|
|
131
|
+
"[dim]The agent asks you about the new decisions (interactive "
|
|
132
|
+
"mode). Run the same command again to write the extended spec, "
|
|
133
|
+
f"then approve it with devflow approve {location.spec_id}.[/dim]"
|
|
97
134
|
)
|
|
98
135
|
else:
|
|
99
136
|
console.print(
|
|
100
|
-
"\n[bold]Next:[/bold] edit spec.md, then "
|
|
137
|
+
"\n[bold]Next:[/bold] edit spec.md yourself, then "
|
|
101
138
|
f"{continue_command}\n"
|
|
102
|
-
"[dim]DevFlow validates and registers your edited spec
|
|
103
|
-
f"
|
|
104
|
-
"
|
|
139
|
+
"[dim]DevFlow validates and registers your edited spec; approve it "
|
|
140
|
+
f"again with devflow approve {location.spec_id}. To have the agent "
|
|
141
|
+
f"extend it instead, run devflow reopen {location.spec_id} --add "
|
|
142
|
+
'"what to add".[/dim]'
|
|
105
143
|
)
|
devflow/commands/security.py
CHANGED
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import typer
|
|
6
6
|
from rich.console import Console
|
|
7
|
+
from rich.markup import escape
|
|
7
8
|
|
|
8
9
|
from devflow.core import security_tools
|
|
9
10
|
from devflow.core.config import ConfigManager, DevFlowConfig
|
|
@@ -27,7 +28,7 @@ def install_security_tools(
|
|
|
27
28
|
for message in result.messages:
|
|
28
29
|
console.print(f"[green]{message}[/green]")
|
|
29
30
|
for warning in result.warnings:
|
|
30
|
-
console.print(f"[yellow]Warning:[/yellow] {warning}")
|
|
31
|
+
console.print(f"[yellow]Warning:[/yellow] {escape(warning)}")
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
def decline_security_tools(config: DevFlowConfig) -> None:
|