devflow-toolkit 0.3.22__py3-none-any.whl → 0.3.24__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/commands/status.py +27 -8
- devflow/core/discovery.py +153 -25
- devflow/core/spec_workflow.py +123 -8
- devflow/core/specification.py +80 -6
- devflow/prompts/__init__.py +40 -6
- devflow/prompts/discovery.md +61 -3
- devflow/prompts/spec.md +9 -4
- {devflow_toolkit-0.3.22.dist-info → devflow_toolkit-0.3.24.dist-info}/METADATA +79 -7
- {devflow_toolkit-0.3.22.dist-info → devflow_toolkit-0.3.24.dist-info}/RECORD +12 -12
- {devflow_toolkit-0.3.22.dist-info → devflow_toolkit-0.3.24.dist-info}/WHEEL +0 -0
- {devflow_toolkit-0.3.22.dist-info → devflow_toolkit-0.3.24.dist-info}/entry_points.txt +0 -0
- {devflow_toolkit-0.3.22.dist-info → devflow_toolkit-0.3.24.dist-info}/licenses/LICENSE +0 -0
devflow/commands/status.py
CHANGED
|
@@ -14,7 +14,11 @@ from devflow.core.config import (
|
|
|
14
14
|
ConfigManager,
|
|
15
15
|
DevFlowConfig,
|
|
16
16
|
)
|
|
17
|
-
from devflow.core.discovery import
|
|
17
|
+
from devflow.core.discovery import (
|
|
18
|
+
DiscoveryDocument,
|
|
19
|
+
DiscoveryError,
|
|
20
|
+
DiscoveryManager,
|
|
21
|
+
)
|
|
18
22
|
from devflow.core.project import ProjectDetector
|
|
19
23
|
from devflow.core.state import (
|
|
20
24
|
ChangeLocation,
|
|
@@ -99,7 +103,7 @@ def _status(spec_id: str, path: Path) -> None:
|
|
|
99
103
|
else:
|
|
100
104
|
console.print("\n[yellow]No artifacts are registered.[/yellow]")
|
|
101
105
|
|
|
102
|
-
_print_discovery(config=config, location=location)
|
|
106
|
+
discovery = _print_discovery(config=config, location=location)
|
|
103
107
|
|
|
104
108
|
if state.approvals:
|
|
105
109
|
console.print("\n[bold]Approvals[/bold]")
|
|
@@ -123,7 +127,7 @@ def _status(spec_id: str, path: Path) -> None:
|
|
|
123
127
|
"They are not approved and do not advance the change.[/dim]"
|
|
124
128
|
)
|
|
125
129
|
|
|
126
|
-
next_step = _next_step(current, location)
|
|
130
|
+
next_step = _next_step(current, location, discovery)
|
|
127
131
|
if next_step:
|
|
128
132
|
console.print(f"\n[bold]Next:[/bold] {next_step}")
|
|
129
133
|
|
|
@@ -131,6 +135,7 @@ def _status(spec_id: str, path: Path) -> None:
|
|
|
131
135
|
def _next_step(
|
|
132
136
|
current: ChangeStatus,
|
|
133
137
|
location: ChangeLocation,
|
|
138
|
+
discovery: DiscoveryDocument | None = None,
|
|
134
139
|
) -> str:
|
|
135
140
|
"""Suggest the next action for the current workflow state."""
|
|
136
141
|
state = current.state
|
|
@@ -152,7 +157,14 @@ def _next_step(
|
|
|
152
157
|
if spec is not None
|
|
153
158
|
else f"{location.change}/spec.md"
|
|
154
159
|
)
|
|
155
|
-
|
|
160
|
+
step = f"ask your coding agent to implement `{spec_path}`"
|
|
161
|
+
suggestions = (
|
|
162
|
+
discovery.suggested_next_specs() if discovery is not None else ()
|
|
163
|
+
)
|
|
164
|
+
if suggestions:
|
|
165
|
+
title = suggestions[0].title.replace('"', "'")
|
|
166
|
+
step += f'. Next level: devflow spec "{title}"'
|
|
167
|
+
return step
|
|
156
168
|
if (
|
|
157
169
|
state.status == WorkflowStatus.DRAFT.value
|
|
158
170
|
and spec is not None
|
|
@@ -171,18 +183,18 @@ def _print_discovery(
|
|
|
171
183
|
*,
|
|
172
184
|
config: DevFlowConfig,
|
|
173
185
|
location: ChangeLocation,
|
|
174
|
-
) -> None:
|
|
186
|
+
) -> DiscoveryDocument | None:
|
|
175
187
|
manager = DiscoveryManager(config.root)
|
|
176
188
|
if not manager.exists(location.directory):
|
|
177
|
-
return
|
|
189
|
+
return None
|
|
178
190
|
console.print("\n[bold]Discovery[/bold]")
|
|
179
191
|
try:
|
|
180
192
|
discovery = manager.load(location.directory, required=True)
|
|
181
193
|
except DiscoveryError as error:
|
|
182
194
|
console.print(f"[yellow]- invalid discovery: {error}[/yellow]")
|
|
183
|
-
return
|
|
195
|
+
return None
|
|
184
196
|
if discovery is None:
|
|
185
|
-
return
|
|
197
|
+
return None
|
|
186
198
|
console.print(
|
|
187
199
|
f" status: {discovery.status} · "
|
|
188
200
|
f"{len(discovery.pending_questions)} pending · "
|
|
@@ -214,3 +226,10 @@ def _print_discovery(
|
|
|
214
226
|
f"{assumption.value}",
|
|
215
227
|
soft_wrap=True,
|
|
216
228
|
)
|
|
229
|
+
|
|
230
|
+
suggestions = discovery.suggested_next_specs()
|
|
231
|
+
if suggestions:
|
|
232
|
+
console.print("\n[bold]Suggested next specifications[/bold]")
|
|
233
|
+
for index, item in enumerate(suggestions, start=1):
|
|
234
|
+
console.print(f" {index}. {item.title}: {item.why}", soft_wrap=True)
|
|
235
|
+
return discovery
|
devflow/core/discovery.py
CHANGED
|
@@ -29,6 +29,7 @@ MAX_QUESTIONS = 100
|
|
|
29
29
|
MAX_ASSUMPTIONS = 100
|
|
30
30
|
MAX_TEXT_LENGTH = 4_000
|
|
31
31
|
MAX_OPTIONS = 10
|
|
32
|
+
MAX_DEFERRED = 30
|
|
32
33
|
|
|
33
34
|
DISCOVERY_PENDING = "pending"
|
|
34
35
|
DISCOVERY_AWAITING = "awaiting_clarification"
|
|
@@ -52,6 +53,9 @@ QUESTION_STATUSES = (
|
|
|
52
53
|
QUESTION_ASSUMED,
|
|
53
54
|
QUESTION_ANSWERED,
|
|
54
55
|
)
|
|
56
|
+
# Agents sometimes write the record status on a question. Both mean the
|
|
57
|
+
# decision is still open.
|
|
58
|
+
QUESTION_PENDING_ALIASES = frozenset({"awaiting_clarification", "open"})
|
|
55
59
|
QUESTION_WRITTEN_STATUSES = (
|
|
56
60
|
QUESTION_PENDING,
|
|
57
61
|
QUESTION_RESOLVED,
|
|
@@ -107,6 +111,7 @@ ASSUMPTION_STATUSES = (ASSUMPTION_PENDING, ASSUMPTION_ACCEPTED)
|
|
|
107
111
|
ASSUMPTION_SOURCES = ("agent_default", "human", "existing_convention")
|
|
108
112
|
|
|
109
113
|
_QUESTION_ID = re.compile(r"^Q\d{1,3}$")
|
|
114
|
+
_RECOMMENDED = re.compile(r"recom+end", re.IGNORECASE)
|
|
110
115
|
_ASSUMPTION_ID = re.compile(r"^A\d{1,3}$")
|
|
111
116
|
|
|
112
117
|
_STOPWORDS = {
|
|
@@ -479,6 +484,45 @@ class DiscoveryIncompleteError(DiscoveryError):
|
|
|
479
484
|
"""Raised when a workflow requires a complete discovery."""
|
|
480
485
|
|
|
481
486
|
|
|
487
|
+
@dataclass(frozen=True)
|
|
488
|
+
class NextLevel:
|
|
489
|
+
"""The option that would take a decision one level further."""
|
|
490
|
+
|
|
491
|
+
option: str
|
|
492
|
+
why: str
|
|
493
|
+
|
|
494
|
+
def to_dict(self) -> dict[str, Any]:
|
|
495
|
+
return {"option": self.option, "why": self.why}
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
@dataclass(frozen=True)
|
|
499
|
+
class DeferredItem:
|
|
500
|
+
"""A next-level improvement suggested for a later specification."""
|
|
501
|
+
|
|
502
|
+
title: str
|
|
503
|
+
why: str
|
|
504
|
+
question_id: str | None = None
|
|
505
|
+
|
|
506
|
+
def to_dict(self) -> dict[str, Any]:
|
|
507
|
+
data: dict[str, Any] = {"title": self.title, "why": self.why}
|
|
508
|
+
if self.question_id:
|
|
509
|
+
data["question_id"] = self.question_id
|
|
510
|
+
return data
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
def _same_choice(answer: str | None, option: str) -> bool:
|
|
514
|
+
"""Return whether an answer selects the given option."""
|
|
515
|
+
if not answer:
|
|
516
|
+
return False
|
|
517
|
+
|
|
518
|
+
def normalized(value: str) -> str:
|
|
519
|
+
return " ".join(value.split()).casefold().rstrip(" .")
|
|
520
|
+
|
|
521
|
+
chosen = normalized(answer)
|
|
522
|
+
expected = normalized(option)
|
|
523
|
+
return bool(expected) and chosen.startswith(expected)
|
|
524
|
+
|
|
525
|
+
|
|
482
526
|
@dataclass(frozen=True)
|
|
483
527
|
class DiscoveryQuestion:
|
|
484
528
|
"""One decision that may block specification generation."""
|
|
@@ -496,6 +540,16 @@ class DiscoveryQuestion:
|
|
|
496
540
|
materiality: str = ""
|
|
497
541
|
resolution_source: str | None = None
|
|
498
542
|
evidence: tuple[str, ...] = ()
|
|
543
|
+
next_level: NextLevel | None = None
|
|
544
|
+
|
|
545
|
+
@property
|
|
546
|
+
def chose_next_level(self) -> bool:
|
|
547
|
+
"""Return whether the user selected the next-level option."""
|
|
548
|
+
return (
|
|
549
|
+
self.next_level is not None
|
|
550
|
+
and self.is_resolved
|
|
551
|
+
and _same_choice(self.answer, self.next_level.option)
|
|
552
|
+
)
|
|
499
553
|
|
|
500
554
|
@property
|
|
501
555
|
def effective_materiality(self) -> str:
|
|
@@ -563,9 +617,11 @@ class DiscoveryQuestion:
|
|
|
563
617
|
data["resolution_source"] = self.resolution_source
|
|
564
618
|
if self.evidence:
|
|
565
619
|
data["evidence"] = list(self.evidence)
|
|
620
|
+
data["options"] = list(self.options)
|
|
621
|
+
if self.next_level is not None:
|
|
622
|
+
data["next_level"] = self.next_level.to_dict()
|
|
566
623
|
data.update(
|
|
567
624
|
{
|
|
568
|
-
"options": list(self.options),
|
|
569
625
|
"answer": self.answer,
|
|
570
626
|
"answered_by": self.answered_by,
|
|
571
627
|
"answered_at": self.answered_at,
|
|
@@ -618,6 +674,39 @@ class DiscoveryDocument:
|
|
|
618
674
|
updated_at: str
|
|
619
675
|
questions: tuple[DiscoveryQuestion, ...] = ()
|
|
620
676
|
assumptions: tuple[DiscoveryAssumption, ...] = ()
|
|
677
|
+
deferred: tuple[DeferredItem, ...] = ()
|
|
678
|
+
|
|
679
|
+
def suggested_next_specs(self) -> tuple[DeferredItem, ...]:
|
|
680
|
+
"""Return next-level improvements to propose as later specs.
|
|
681
|
+
|
|
682
|
+
Explicitly deferred items come first. A decided question whose
|
|
683
|
+
next-level option was not selected adds that option.
|
|
684
|
+
"""
|
|
685
|
+
items: list[DeferredItem] = []
|
|
686
|
+
seen: set[str] = set()
|
|
687
|
+
|
|
688
|
+
def add(item: DeferredItem) -> None:
|
|
689
|
+
key = " ".join(item.title.split()).casefold()
|
|
690
|
+
if key in seen:
|
|
691
|
+
return
|
|
692
|
+
seen.add(key)
|
|
693
|
+
items.append(item)
|
|
694
|
+
|
|
695
|
+
for item in self.deferred:
|
|
696
|
+
add(item)
|
|
697
|
+
for question in self.questions:
|
|
698
|
+
if question.next_level is None or question.is_pending:
|
|
699
|
+
continue
|
|
700
|
+
if question.chose_next_level:
|
|
701
|
+
continue
|
|
702
|
+
add(
|
|
703
|
+
DeferredItem(
|
|
704
|
+
title=question.next_level.option,
|
|
705
|
+
why=question.next_level.why,
|
|
706
|
+
question_id=question.id,
|
|
707
|
+
)
|
|
708
|
+
)
|
|
709
|
+
return tuple(items)
|
|
621
710
|
|
|
622
711
|
@property
|
|
623
712
|
def pending_blocking(self) -> tuple[DiscoveryQuestion, ...]:
|
|
@@ -747,6 +836,11 @@ class DiscoveryDocument:
|
|
|
747
836
|
"assumptions": [
|
|
748
837
|
assumption.to_dict() for assumption in self.assumptions
|
|
749
838
|
],
|
|
839
|
+
**(
|
|
840
|
+
{"deferred": [item.to_dict() for item in self.deferred]}
|
|
841
|
+
if self.deferred
|
|
842
|
+
else {}
|
|
843
|
+
),
|
|
750
844
|
}
|
|
751
845
|
|
|
752
846
|
|
|
@@ -814,18 +908,8 @@ class DiscoveryManager:
|
|
|
814
908
|
msg = f"Invalid YAML in discovery file: {path}: {detail}"
|
|
815
909
|
raise DiscoveryError(msg) from error
|
|
816
910
|
document = self._parse(data, directory)
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
and (
|
|
820
|
-
document.pending_questions
|
|
821
|
-
or document.pending_assumptions
|
|
822
|
-
)
|
|
823
|
-
):
|
|
824
|
-
msg = (
|
|
825
|
-
"Discovery is marked complete but still has pending "
|
|
826
|
-
"questions or assumptions."
|
|
827
|
-
)
|
|
828
|
-
raise DiscoveryError(msg)
|
|
911
|
+
# Completeness is derived from the decisions, never from the
|
|
912
|
+
# status an agent wrote.
|
|
829
913
|
return replace(document, status=document.derived_status)
|
|
830
914
|
|
|
831
915
|
def write(
|
|
@@ -1129,6 +1213,15 @@ class DiscoveryManager:
|
|
|
1129
1213
|
)
|
|
1130
1214
|
raise DiscoveryError(msg)
|
|
1131
1215
|
|
|
1216
|
+
deferred_data = _list(mapping.get("deferred"), "deferred")
|
|
1217
|
+
if len(deferred_data) > MAX_DEFERRED:
|
|
1218
|
+
msg = f"At most {MAX_DEFERRED} deferred items are allowed."
|
|
1219
|
+
raise DiscoveryError(msg)
|
|
1220
|
+
deferred = tuple(
|
|
1221
|
+
self._deferred(item, index, question_ids)
|
|
1222
|
+
for index, item in enumerate(deferred_data, start=1)
|
|
1223
|
+
)
|
|
1224
|
+
|
|
1132
1225
|
document = DiscoveryDocument(
|
|
1133
1226
|
version=version,
|
|
1134
1227
|
spec_id=spec_id,
|
|
@@ -1140,19 +1233,8 @@ class DiscoveryManager:
|
|
|
1140
1233
|
updated_at=updated_at,
|
|
1141
1234
|
questions=questions,
|
|
1142
1235
|
assumptions=assumptions,
|
|
1236
|
+
deferred=deferred,
|
|
1143
1237
|
)
|
|
1144
|
-
if (
|
|
1145
|
-
document.status == DISCOVERY_COMPLETE
|
|
1146
|
-
and (
|
|
1147
|
-
document.pending_questions
|
|
1148
|
-
or document.pending_assumptions
|
|
1149
|
-
)
|
|
1150
|
-
):
|
|
1151
|
-
msg = (
|
|
1152
|
-
"Discovery is marked complete but still has pending "
|
|
1153
|
-
"questions or assumptions."
|
|
1154
|
-
)
|
|
1155
|
-
raise DiscoveryError(msg)
|
|
1156
1238
|
return document
|
|
1157
1239
|
|
|
1158
1240
|
def _question(
|
|
@@ -1191,6 +1273,8 @@ class DiscoveryManager:
|
|
|
1191
1273
|
)
|
|
1192
1274
|
raise DiscoveryError(msg)
|
|
1193
1275
|
status = _text(mapping.get("status"), f"{identifier}.status")
|
|
1276
|
+
if status in QUESTION_PENDING_ALIASES:
|
|
1277
|
+
status = QUESTION_PENDING
|
|
1194
1278
|
if status not in QUESTION_STATUSES:
|
|
1195
1279
|
msg = (
|
|
1196
1280
|
f"Invalid status for {identifier}: {status!r}. "
|
|
@@ -1210,6 +1294,26 @@ class DiscoveryManager:
|
|
|
1210
1294
|
if len(options) > MAX_OPTIONS:
|
|
1211
1295
|
msg = f"{identifier} has too many options."
|
|
1212
1296
|
raise DiscoveryError(msg)
|
|
1297
|
+
next_level = None
|
|
1298
|
+
next_level_data = mapping.get("next_level")
|
|
1299
|
+
if next_level_data is not None:
|
|
1300
|
+
next_level_mapping = _mapping(
|
|
1301
|
+
next_level_data,
|
|
1302
|
+
f"{identifier}.next_level",
|
|
1303
|
+
)
|
|
1304
|
+
next_level = NextLevel(
|
|
1305
|
+
option=_limited_text(
|
|
1306
|
+
next_level_mapping.get("option"),
|
|
1307
|
+
f"{identifier}.next_level.option",
|
|
1308
|
+
),
|
|
1309
|
+
why=_limited_text(
|
|
1310
|
+
next_level_mapping.get("why"),
|
|
1311
|
+
f"{identifier}.next_level.why",
|
|
1312
|
+
),
|
|
1313
|
+
)
|
|
1314
|
+
# The recommended option is level 1, never the next level.
|
|
1315
|
+
if _RECOMMENDED.search(next_level.option):
|
|
1316
|
+
next_level = None
|
|
1213
1317
|
resolution_source = _optional_text(
|
|
1214
1318
|
mapping.get("resolution_source"),
|
|
1215
1319
|
f"{identifier}.resolution_source",
|
|
@@ -1316,6 +1420,30 @@ class DiscoveryManager:
|
|
|
1316
1420
|
materiality=materiality,
|
|
1317
1421
|
resolution_source=resolution_source,
|
|
1318
1422
|
evidence=evidence,
|
|
1423
|
+
next_level=next_level,
|
|
1424
|
+
)
|
|
1425
|
+
|
|
1426
|
+
def _deferred(
|
|
1427
|
+
self,
|
|
1428
|
+
data: object,
|
|
1429
|
+
index: int,
|
|
1430
|
+
question_ids: set[str],
|
|
1431
|
+
) -> DeferredItem:
|
|
1432
|
+
mapping = _mapping(data, f"deferred[{index}]")
|
|
1433
|
+
question_id = _optional_text(
|
|
1434
|
+
mapping.get("question_id"),
|
|
1435
|
+
f"deferred[{index}].question_id",
|
|
1436
|
+
)
|
|
1437
|
+
if question_id is not None and question_id not in question_ids:
|
|
1438
|
+
msg = (
|
|
1439
|
+
f"deferred[{index}] references unknown question "
|
|
1440
|
+
f"{question_id!r}."
|
|
1441
|
+
)
|
|
1442
|
+
raise DiscoveryError(msg)
|
|
1443
|
+
return DeferredItem(
|
|
1444
|
+
title=_limited_text(mapping.get("title"), f"deferred[{index}].title"),
|
|
1445
|
+
why=_limited_text(mapping.get("why"), f"deferred[{index}].why"),
|
|
1446
|
+
question_id=question_id,
|
|
1319
1447
|
)
|
|
1320
1448
|
|
|
1321
1449
|
def _assumption(
|
devflow/core/spec_workflow.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from dataclasses import dataclass
|
|
5
|
+
from dataclasses import dataclass, replace
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
8
|
from devflow.core.architecture import (
|
|
@@ -61,6 +61,15 @@ from devflow.prompts import (
|
|
|
61
61
|
)
|
|
62
62
|
|
|
63
63
|
|
|
64
|
+
class SpecDiscoveryInvalidError(Exception):
|
|
65
|
+
"""Raised when the specification agent leaves discovery.yaml invalid."""
|
|
66
|
+
|
|
67
|
+
def __init__(self, reason: str, warnings: tuple[str, ...] = ()) -> None:
|
|
68
|
+
self.reason = reason
|
|
69
|
+
self.warnings = warnings
|
|
70
|
+
super().__init__(reason)
|
|
71
|
+
|
|
72
|
+
|
|
64
73
|
class SpecOpenQuestionsError(Exception):
|
|
65
74
|
"""Raised when the specification agent leaves decisions unresolved."""
|
|
66
75
|
|
|
@@ -633,18 +642,50 @@ class SpecWorkflow:
|
|
|
633
642
|
discovery_digest=discovery_digest,
|
|
634
643
|
archive=archive_existing,
|
|
635
644
|
)
|
|
636
|
-
except
|
|
645
|
+
except SpecDiscoveryInvalidError as error:
|
|
637
646
|
if prepared.path.is_file():
|
|
638
647
|
ArtifactStore(prepared.root).archive(prepared.path)
|
|
639
648
|
prepared.path.unlink(missing_ok=True)
|
|
640
|
-
|
|
641
|
-
discovery
|
|
642
|
-
error.
|
|
649
|
+
warnings.append(
|
|
650
|
+
"the specification agent left discovery.yaml invalid: "
|
|
651
|
+
f"{error.reason}. No specification was written. Run 'devflow "
|
|
652
|
+
f"spec --continue {prepared.spec_id}' to repair it."
|
|
643
653
|
)
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
654
|
+
return self._build_result(
|
|
655
|
+
spec=None,
|
|
656
|
+
harness_name=adapter.display_name,
|
|
657
|
+
execution_mode=request.execution_mode,
|
|
658
|
+
warnings=warnings,
|
|
659
|
+
run_warnings=list(error.warnings),
|
|
660
|
+
setup_result=setup_result,
|
|
661
|
+
constitution=constitution,
|
|
662
|
+
project_mode=project_mode,
|
|
663
|
+
architecture=architecture,
|
|
664
|
+
discovery=discovery,
|
|
665
|
+
discovery_digest=discovery_digest,
|
|
666
|
+
discovery_path=discovery_path,
|
|
667
|
+
discovery_source=discovery_source,
|
|
668
|
+
discovery_created=discovery_created,
|
|
669
|
+
blocked=True,
|
|
670
|
+
spec_written=False,
|
|
671
|
+
spec_reused=False,
|
|
672
|
+
continuation=continuation,
|
|
673
|
+
directory=prepared.directory,
|
|
674
|
+
discovery_valid=False,
|
|
647
675
|
)
|
|
676
|
+
except SpecOpenQuestionsError as error:
|
|
677
|
+
if prepared.path.is_file():
|
|
678
|
+
ArtifactStore(prepared.root).archive(prepared.path)
|
|
679
|
+
prepared.path.unlink(missing_ok=True)
|
|
680
|
+
if error.questions:
|
|
681
|
+
discovery = discovery_manager.add_questions(
|
|
682
|
+
discovery,
|
|
683
|
+
error.questions,
|
|
684
|
+
)
|
|
685
|
+
discovery_path, discovery_digest = discovery_manager.write(
|
|
686
|
+
prepared.directory,
|
|
687
|
+
discovery,
|
|
688
|
+
)
|
|
648
689
|
discovery = discovery_manager.load(
|
|
649
690
|
prepared.directory,
|
|
650
691
|
required=True,
|
|
@@ -693,6 +734,31 @@ class SpecWorkflow:
|
|
|
693
734
|
continuation=continuation,
|
|
694
735
|
directory=prepared.directory,
|
|
695
736
|
)
|
|
737
|
+
current_digest = self._discovery_digest(
|
|
738
|
+
discovery_manager,
|
|
739
|
+
prepared.directory,
|
|
740
|
+
)
|
|
741
|
+
if current_digest and current_digest != discovery_digest:
|
|
742
|
+
discovery = discovery_manager.load(
|
|
743
|
+
prepared.directory,
|
|
744
|
+
required=True,
|
|
745
|
+
)
|
|
746
|
+
discovery_digest = current_digest
|
|
747
|
+
discovery_source = "agent"
|
|
748
|
+
prepared = self.manager.prepare(
|
|
749
|
+
description=description,
|
|
750
|
+
config=config,
|
|
751
|
+
project=project,
|
|
752
|
+
constitution=constitution,
|
|
753
|
+
profiles=profiles,
|
|
754
|
+
project_mode=project_mode,
|
|
755
|
+
architecture=architecture,
|
|
756
|
+
discovery=discovery,
|
|
757
|
+
discovery_digest=discovery_digest,
|
|
758
|
+
directory=prepared.directory,
|
|
759
|
+
spec_id=prepared.spec_id,
|
|
760
|
+
)
|
|
761
|
+
self.manager.materialize_context(prepared)
|
|
696
762
|
return self._build_result(
|
|
697
763
|
spec=spec,
|
|
698
764
|
harness_name=adapter.display_name,
|
|
@@ -1058,7 +1124,35 @@ class SpecWorkflow:
|
|
|
1058
1124
|
run_warnings,
|
|
1059
1125
|
)
|
|
1060
1126
|
if prepared.path.is_file():
|
|
1127
|
+
current = self._raise_if_returned_to_discovery(
|
|
1128
|
+
prepared,
|
|
1129
|
+
run_warnings,
|
|
1130
|
+
)
|
|
1061
1131
|
content = prepared.path.read_text(encoding="utf-8")
|
|
1132
|
+
current_digest = self._discovery_digest(
|
|
1133
|
+
DiscoveryManager(prepared.root),
|
|
1134
|
+
prepared.directory,
|
|
1135
|
+
)
|
|
1136
|
+
if (
|
|
1137
|
+
current is not None
|
|
1138
|
+
and discovery_digest
|
|
1139
|
+
and current_digest
|
|
1140
|
+
and current_digest != discovery_digest
|
|
1141
|
+
):
|
|
1142
|
+
# Decisions answered by the user during this session are
|
|
1143
|
+
# part of Discovery. DevFlow binds the spec to the new
|
|
1144
|
+
# record, because the agent cannot compute the digest.
|
|
1145
|
+
prepared = replace(
|
|
1146
|
+
prepared,
|
|
1147
|
+
discovery=current,
|
|
1148
|
+
discovery_digest=current_digest,
|
|
1149
|
+
)
|
|
1150
|
+
discovery_digest = current_digest
|
|
1151
|
+
if discovery_digest:
|
|
1152
|
+
content = self.manager.stamp_discovery_digest(
|
|
1153
|
+
content,
|
|
1154
|
+
discovery_digest,
|
|
1155
|
+
)
|
|
1062
1156
|
self._raise_if_open_questions(
|
|
1063
1157
|
content,
|
|
1064
1158
|
discovery_digest,
|
|
@@ -1089,6 +1183,7 @@ class SpecWorkflow:
|
|
|
1089
1183
|
run_warnings,
|
|
1090
1184
|
)
|
|
1091
1185
|
|
|
1186
|
+
self._raise_if_returned_to_discovery(prepared, run_warnings)
|
|
1092
1187
|
run_warnings.append(
|
|
1093
1188
|
"the interactive agent did not write the specification. "
|
|
1094
1189
|
"Using deterministic DevFlow output."
|
|
@@ -1149,6 +1244,26 @@ class SpecWorkflow:
|
|
|
1149
1244
|
if output_path is not None:
|
|
1150
1245
|
output_path.unlink(missing_ok=True)
|
|
1151
1246
|
|
|
1247
|
+
def _raise_if_returned_to_discovery(
|
|
1248
|
+
self,
|
|
1249
|
+
prepared: PreparedSpec,
|
|
1250
|
+
run_warnings: list[str],
|
|
1251
|
+
) -> DiscoveryDocument | None:
|
|
1252
|
+
"""Stop when the agent recorded new decisions instead of a spec."""
|
|
1253
|
+
try:
|
|
1254
|
+
current = DiscoveryManager(prepared.root).load(
|
|
1255
|
+
prepared.directory,
|
|
1256
|
+
required=True,
|
|
1257
|
+
)
|
|
1258
|
+
except DiscoveryError as error:
|
|
1259
|
+
raise SpecDiscoveryInvalidError(
|
|
1260
|
+
str(error),
|
|
1261
|
+
tuple(run_warnings),
|
|
1262
|
+
) from error
|
|
1263
|
+
if current is not None and not current.is_complete:
|
|
1264
|
+
raise SpecOpenQuestionsError((), tuple(run_warnings))
|
|
1265
|
+
return current
|
|
1266
|
+
|
|
1152
1267
|
def _raise_if_open_questions(
|
|
1153
1268
|
self,
|
|
1154
1269
|
content: str,
|
devflow/core/specification.py
CHANGED
|
@@ -48,6 +48,7 @@ IGNORED_FILENAMES = {
|
|
|
48
48
|
MAX_FILE_BYTES = 256_000
|
|
49
49
|
MAX_ANALYSIS_FILES = 3000
|
|
50
50
|
MAX_REFERENCES = 25
|
|
51
|
+
NEXT_SPECS_HEADING = "### 10.1 Suggested next specifications"
|
|
51
52
|
|
|
52
53
|
STOPWORDS = {
|
|
53
54
|
"a",
|
|
@@ -889,6 +890,7 @@ class SpecificationManager:
|
|
|
889
890
|
if not cleaned.strip():
|
|
890
891
|
cleaned = prepared.fallback_content
|
|
891
892
|
source = "static"
|
|
893
|
+
cleaned = self.with_next_specs(cleaned, prepared.discovery)
|
|
892
894
|
|
|
893
895
|
prepared.directory.mkdir(parents=True, exist_ok=True)
|
|
894
896
|
ArtifactStore(prepared.root).write(
|
|
@@ -1085,6 +1087,60 @@ class SpecificationManager:
|
|
|
1085
1087
|
cleaned = cleaned[start:]
|
|
1086
1088
|
return cleaned.strip()
|
|
1087
1089
|
|
|
1090
|
+
def stamp_discovery_digest(self, content: str, digest: str) -> str:
|
|
1091
|
+
"""Write the authoritative Discovery digest into the header row."""
|
|
1092
|
+
return re.sub(
|
|
1093
|
+
r"^(\|\s*Discovery digest\s*\|).*$",
|
|
1094
|
+
lambda match: f"{match.group(1)} `{digest}` |",
|
|
1095
|
+
content,
|
|
1096
|
+
count=1,
|
|
1097
|
+
flags=re.MULTILINE,
|
|
1098
|
+
)
|
|
1099
|
+
|
|
1100
|
+
def with_next_specs(
|
|
1101
|
+
self,
|
|
1102
|
+
content: str,
|
|
1103
|
+
discovery: DiscoveryDocument | None,
|
|
1104
|
+
) -> str:
|
|
1105
|
+
"""Write section 10.1 from the Discovery suggestions.
|
|
1106
|
+
|
|
1107
|
+
DevFlow owns this subsection so the agent does not spend tokens on
|
|
1108
|
+
it and the suggestions always match the recorded decisions.
|
|
1109
|
+
"""
|
|
1110
|
+
section = re.search(
|
|
1111
|
+
r"^##\s+10\.[^\n]*\n(?P<body>.*?)(?=^##\s+11\.|\Z)",
|
|
1112
|
+
content,
|
|
1113
|
+
re.MULTILINE | re.DOTALL,
|
|
1114
|
+
)
|
|
1115
|
+
if section is None:
|
|
1116
|
+
return content
|
|
1117
|
+
|
|
1118
|
+
suggestions = (
|
|
1119
|
+
discovery.suggested_next_specs() if discovery is not None else ()
|
|
1120
|
+
)
|
|
1121
|
+
lines = [NEXT_SPECS_HEADING, ""]
|
|
1122
|
+
if suggestions:
|
|
1123
|
+
for index, item in enumerate(suggestions, start=1):
|
|
1124
|
+
command = item.title.replace('"', "'")
|
|
1125
|
+
lines.append(f"{index}. **{item.title}**: {item.why}")
|
|
1126
|
+
lines.append(f' `devflow spec "{command}"`')
|
|
1127
|
+
else:
|
|
1128
|
+
lines.append("None.")
|
|
1129
|
+
block = "\n".join(lines)
|
|
1130
|
+
|
|
1131
|
+
body = re.sub(
|
|
1132
|
+
r"^###\s+10\.1\b.*",
|
|
1133
|
+
"",
|
|
1134
|
+
section.group("body"),
|
|
1135
|
+
flags=re.MULTILINE | re.DOTALL,
|
|
1136
|
+
).rstrip()
|
|
1137
|
+
new_body = f"{body}\n\n{block}\n\n" if body else f"\n{block}\n\n"
|
|
1138
|
+
return (
|
|
1139
|
+
content[: section.start("body")]
|
|
1140
|
+
+ new_body
|
|
1141
|
+
+ content[section.end("body"):]
|
|
1142
|
+
)
|
|
1143
|
+
|
|
1088
1144
|
def extract_open_questions(self, content: str) -> tuple[str, ...]:
|
|
1089
1145
|
"""Read the open questions listed by an agent specification."""
|
|
1090
1146
|
match = re.search(
|
|
@@ -1099,13 +1155,31 @@ class SpecificationManager:
|
|
|
1099
1155
|
if not body or "no open questions" in body.lower():
|
|
1100
1156
|
return ()
|
|
1101
1157
|
|
|
1158
|
+
lines = body.splitlines()
|
|
1159
|
+
marker = r"(?:\d+[.)]|[-*])\s+(.*)"
|
|
1160
|
+
if not any(re.match(rf"^{marker}", line) for line in lines):
|
|
1161
|
+
# Every item is indented: treat each one as a question.
|
|
1162
|
+
return tuple(
|
|
1163
|
+
item.group(1).strip()
|
|
1164
|
+
for line in lines
|
|
1165
|
+
if (item := re.match(rf"^\s*{marker}", line))
|
|
1166
|
+
and item.group(1).strip()
|
|
1167
|
+
)
|
|
1168
|
+
|
|
1169
|
+
# Nested bullets and continuation lines belong to the item above,
|
|
1170
|
+
# so one question keeps all of its context.
|
|
1102
1171
|
questions: list[str] = []
|
|
1103
|
-
for line in
|
|
1104
|
-
|
|
1105
|
-
if
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1172
|
+
for line in lines:
|
|
1173
|
+
top = re.match(rf"^{marker}", line)
|
|
1174
|
+
if top:
|
|
1175
|
+
if top.group(1).strip():
|
|
1176
|
+
questions.append(top.group(1).strip())
|
|
1177
|
+
continue
|
|
1178
|
+
text = line.strip()
|
|
1179
|
+
if not text or not questions:
|
|
1180
|
+
continue
|
|
1181
|
+
nested = re.match(rf"^\s*{marker}", line)
|
|
1182
|
+
questions[-1] += " " + (nested.group(1).strip() if nested else text)
|
|
1109
1183
|
return tuple(questions)
|
|
1110
1184
|
|
|
1111
1185
|
def _next_spec_directory(
|
devflow/prompts/__init__.py
CHANGED
|
@@ -17,6 +17,10 @@ PROMPTS_ROOT = Path(__file__).resolve().parent
|
|
|
17
17
|
# normal English/Spanish text uses roughly four characters per token.
|
|
18
18
|
MAX_DECISION_CONTEXT_CHARS = 8_000
|
|
19
19
|
|
|
20
|
+
# Missing decisions the specification agent may ask in its own session
|
|
21
|
+
# before the change has to return to a separate Discovery session.
|
|
22
|
+
MAX_IN_SESSION_DECISIONS = 3
|
|
23
|
+
|
|
20
24
|
|
|
21
25
|
class PromptError(Exception):
|
|
22
26
|
"""Raised when a bundled prompt cannot be loaded."""
|
|
@@ -307,6 +311,20 @@ def build_decision_context(
|
|
|
307
311
|
lines.append("- None.")
|
|
308
312
|
lines.append("")
|
|
309
313
|
|
|
314
|
+
lines.extend(["### Suggested next specifications", ""])
|
|
315
|
+
suggestions = (
|
|
316
|
+
discovery.suggested_next_specs() if discovery is not None else ()
|
|
317
|
+
)
|
|
318
|
+
if suggestions:
|
|
319
|
+
for item in suggestions:
|
|
320
|
+
source = f" ({item.question_id})" if item.question_id else ""
|
|
321
|
+
lines.append(
|
|
322
|
+
f"- {_clip(item.title, 160)}{source}: {_clip(item.why, 200)}"
|
|
323
|
+
)
|
|
324
|
+
else:
|
|
325
|
+
lines.append("- None.")
|
|
326
|
+
lines.append("")
|
|
327
|
+
|
|
310
328
|
rendered = "\n".join(lines)
|
|
311
329
|
if len(rendered) <= max_chars:
|
|
312
330
|
return rendered
|
|
@@ -358,7 +376,9 @@ def _language_note(language: str) -> str:
|
|
|
358
376
|
"`AC-XXX` identifier, field name, path, command, code block and "
|
|
359
377
|
"digest exactly as shown in this prompt. Do not translate or "
|
|
360
378
|
"reformat those tokens. Do not write the specification in English "
|
|
361
|
-
"unless the target language is `en
|
|
379
|
+
"unless the target language is `en`.\n\n"
|
|
380
|
+
"Speak to the user, and write every question you add to the "
|
|
381
|
+
"discovery record, in the same target language."
|
|
362
382
|
)
|
|
363
383
|
|
|
364
384
|
|
|
@@ -453,11 +473,25 @@ def _mode_instructions(
|
|
|
453
473
|
return (
|
|
454
474
|
"You are running interactively. Discovery is complete; use its "
|
|
455
475
|
"recorded answers and accepted assumptions as settled decisions. "
|
|
456
|
-
"
|
|
457
|
-
|
|
458
|
-
"
|
|
459
|
-
"
|
|
460
|
-
"
|
|
476
|
+
"Before writing, check that every decision the specification "
|
|
477
|
+
"needs is recorded. If up to "
|
|
478
|
+
f"{MAX_IN_SESSION_DECISIONS} decisions are missing, ask the user "
|
|
479
|
+
"now in one batch, with the structured question tool when "
|
|
480
|
+
"available: put the recommended level-1 option first, add one "
|
|
481
|
+
"more advanced next-level option with a one-sentence reason, and "
|
|
482
|
+
"never assume a security decision. Record each answer in the "
|
|
483
|
+
"discovery record as a new question with the next `Qn` id, "
|
|
484
|
+
"`status: resolved`, `resolution_source: user`, the chosen option "
|
|
485
|
+
"text as `answer`, `answered_by: user`, `answered_at`, `options` "
|
|
486
|
+
"and `next_level`; DevFlow updates the Discovery digest in the "
|
|
487
|
+
"specification header. If more decisions are missing or the user "
|
|
488
|
+
"does not answer, append them as questions with `status: "
|
|
489
|
+
"pending`, set the root `status` of the record to "
|
|
490
|
+
"`awaiting_clarification`, do not write the specification and "
|
|
491
|
+
"tell the user to exit this session so DevFlow returns to "
|
|
492
|
+
"Discovery. Otherwise write the complete specification to "
|
|
493
|
+
f"`{spec_path}` using the available file tools. Do not finish "
|
|
494
|
+
"until the file exists and contains the "
|
|
461
495
|
"complete document. Then tell the user that the specification is "
|
|
462
496
|
"written and that they must exit this session so DevFlow can "
|
|
463
497
|
"validate it. Exiting earlier makes DevFlow replace it with a "
|
devflow/prompts/discovery.md
CHANGED
|
@@ -36,6 +36,48 @@ persists, enforces invariants and decides completeness.
|
|
|
36
36
|
Ask only what materially changes the implementation. Prefer explicit,
|
|
37
37
|
reversible defaults for everything else.
|
|
38
38
|
|
|
39
|
+
## Level-Based Discovery
|
|
40
|
+
|
|
41
|
+
Build the solution level by level. Assume a user with technical
|
|
42
|
+
knowledge who wants to learn and improve along the way; Discovery
|
|
43
|
+
traces that path instead of solving everything at once.
|
|
44
|
+
|
|
45
|
+
1. **Level 1 first.** Scope this specification to the essential
|
|
46
|
+
behavior of the request, built with the tools the project already
|
|
47
|
+
has, plus basic and obvious security.
|
|
48
|
+
2. **Security is never assumed or hidden.** Ask every basic security
|
|
49
|
+
decision explicitly, recommend the basic option and explain in one
|
|
50
|
+
sentence why it matters. Answering it is how the user learns it.
|
|
51
|
+
3. **Every question offers a next level.** Add one option that takes
|
|
52
|
+
the decision one level further and record it in `next_level`:
|
|
53
|
+
`option` is the exact option text (also listed in `options`) and
|
|
54
|
+
`why` explains in one sentence what it improves and when it is worth
|
|
55
|
+
it. It is never the recommended level-1 option; DevFlow ignores a
|
|
56
|
+
`next_level` marked as recommended. If the user picks it, record the answer with that exact text. If
|
|
57
|
+
not, DevFlow proposes it as a next specification. Do not ask
|
|
58
|
+
follow-up questions about the next level in this specification.
|
|
59
|
+
4. **Do not go deeper than this level.** When an answer opens a more
|
|
60
|
+
advanced decision (limits, expiration policies, multiple devices,
|
|
61
|
+
scaling), record it in `deferred` with a short `title` and `why`
|
|
62
|
+
instead of asking it now.
|
|
63
|
+
5. **Split large requests.** When the request bundles several
|
|
64
|
+
independent features, ask in the first round which part this
|
|
65
|
+
specification covers, proposing a level-1 scope. Record the rest in
|
|
66
|
+
`deferred`.
|
|
67
|
+
6. **Nothing is decided silently.** Every suggestion of yours reaches
|
|
68
|
+
the user with its explanation, as a question option or as a
|
|
69
|
+
`deferred` item; never as an unstated requirement.
|
|
70
|
+
|
|
71
|
+
## Readiness Check
|
|
72
|
+
|
|
73
|
+
Before reporting Discovery as complete, walk through what the
|
|
74
|
+
specification will need and confirm a decision exists for each item:
|
|
75
|
+
every user-facing flow and the interfaces it uses (API, HTML pages,
|
|
76
|
+
CLI), the data stored and where, error and unauthenticated behavior,
|
|
77
|
+
how each level-1 security measure works, and what is out of scope. Ask
|
|
78
|
+
every missing decision in the same round. The specification writer
|
|
79
|
+
must not find new decisions.
|
|
80
|
+
|
|
39
81
|
## Decision Outcomes
|
|
40
82
|
|
|
41
83
|
Every decision has exactly one outcome:
|
|
@@ -169,7 +211,12 @@ questions:
|
|
|
169
211
|
reason: "..."
|
|
170
212
|
blocking: true
|
|
171
213
|
status: pending
|
|
172
|
-
options:
|
|
214
|
+
options:
|
|
215
|
+
- "Basic option (recommended for level 1)"
|
|
216
|
+
- "Next-level option"
|
|
217
|
+
next_level:
|
|
218
|
+
option: "Next-level option"
|
|
219
|
+
why: "What it improves and when it is worth it."
|
|
173
220
|
- id: Q2
|
|
174
221
|
category: architecture_boundary
|
|
175
222
|
materiality: technical
|
|
@@ -198,8 +245,15 @@ assumptions:
|
|
|
198
245
|
reason: "..."
|
|
199
246
|
source: agent_default
|
|
200
247
|
status: pending_acceptance
|
|
248
|
+
deferred:
|
|
249
|
+
- title: "Limit failed login attempts"
|
|
250
|
+
why: "Protects accounts from password guessing once login works."
|
|
251
|
+
question_id: Q1
|
|
201
252
|
```
|
|
202
253
|
|
|
254
|
+
`next_level` and `deferred` are optional, but every material question
|
|
255
|
+
should have a `next_level` unless no meaningful next level exists.
|
|
256
|
+
|
|
203
257
|
### YAML Safety Rules
|
|
204
258
|
|
|
205
259
|
- Quote every free-text scalar with single quotes when it contains
|
|
@@ -226,6 +280,8 @@ Valid materialities are `critical`, `functional`, `technical` and
|
|
|
226
280
|
`cosmetic`.
|
|
227
281
|
|
|
228
282
|
Valid question statuses are `pending`, `resolved` and `assumed`.
|
|
283
|
+
`awaiting_clarification` and `complete` belong only to the root
|
|
284
|
+
`status` of the record.
|
|
229
285
|
`answered` is a legacy alias that DevFlow reads as `resolved`; write
|
|
230
286
|
`resolved` in new records. Valid assumption statuses are
|
|
231
287
|
`pending_acceptance` and `accepted`.
|
|
@@ -281,8 +337,10 @@ assumption is unaccepted, and to `complete` only when nothing remains.
|
|
|
281
337
|
- Stop asking only when no decision is pending and every assumption is
|
|
282
338
|
accepted. A decision is not optional because it is marked
|
|
283
339
|
non-blocking; resolve it or record an assumption instead.
|
|
284
|
-
- If
|
|
285
|
-
question
|
|
340
|
+
- If an answer raises a new decision needed at this level, append a
|
|
341
|
+
new question and ask it in the same round when it is independent. If
|
|
342
|
+
the new decision belongs to the next level, record it in `deferred`
|
|
343
|
+
instead.
|
|
286
344
|
|
|
287
345
|
{{reopened_note}}## Execution Instructions
|
|
288
346
|
|
devflow/prompts/spec.md
CHANGED
|
@@ -52,8 +52,9 @@ implemented code.
|
|
|
52
52
|
- Write only the DevFlow specification. Never create implementation
|
|
53
53
|
files.
|
|
54
54
|
- Do not invent requirements. Every decision must already be recorded in
|
|
55
|
-
Discovery
|
|
56
|
-
|
|
55
|
+
Discovery, however small. Check this before writing anything: if a
|
|
56
|
+
decision is missing, return it to Discovery instead of writing the
|
|
57
|
+
specification.
|
|
57
58
|
- Do not duplicate or replace the project constitution. Reference the
|
|
58
59
|
documents that apply.
|
|
59
60
|
- Specs must remain portable between agent harnesses. Do not include
|
|
@@ -180,7 +181,9 @@ renumber the document.
|
|
|
180
181
|
not add assumptions. If a decision is genuinely missing, leave the
|
|
181
182
|
specification invalid by listing the unresolved question as a
|
|
182
183
|
numbered item in section 7; DevFlow will return it to Discovery for a
|
|
183
|
-
human answer.
|
|
184
|
+
human answer. Each missing decision is one top-level numbered item
|
|
185
|
+
with the complete question; do not use nested bullets. When a
|
|
186
|
+
Discovery digest is provided, include that exact
|
|
184
187
|
digest in the header table, state that Discovery is complete, and
|
|
185
188
|
reference the recorded answers and accepted assumptions without
|
|
186
189
|
contradicting them.
|
|
@@ -189,7 +192,9 @@ renumber the document.
|
|
|
189
192
|
- Section 9 lists the constitution documents that apply and their
|
|
190
193
|
profile scope. Reference paths, do not copy their contents.
|
|
191
194
|
- Section 10 states what is explicitly excluded from this change. In
|
|
192
|
-
Greenfield, include code generation and planning in this stage.
|
|
195
|
+
Greenfield, include code generation and planning in this stage. Do not
|
|
196
|
+
write subsection 10.1: DevFlow writes the suggested next
|
|
197
|
+
specifications from Discovery.
|
|
193
198
|
- Section 11 contains the review and approval checklist.
|
|
194
199
|
<!-- devflow:mode existing -->
|
|
195
200
|
- Section 3 cites real files from the context. Explain their relevance.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: devflow-toolkit
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.24
|
|
4
4
|
Summary: Specification workflow toolkit for AI-assisted software changes
|
|
5
5
|
Author: DevFlow contributors
|
|
6
6
|
License-Expression: MIT
|
|
@@ -32,7 +32,7 @@ Description-Content-Type: text/markdown
|
|
|
32
32
|
|
|
33
33
|
# DevFlow Toolkit
|
|
34
34
|
|
|
35
|
-
**Current version: `0.3.
|
|
35
|
+
**Current version: `0.3.24`.**
|
|
36
36
|
|
|
37
37
|
DevFlow is a command-line toolkit for leading AI models and coding
|
|
38
38
|
agents through specification-driven changes in real software projects.
|
|
@@ -152,7 +152,7 @@ pip install devflow-toolkit
|
|
|
152
152
|
To install a specific built artifact instead:
|
|
153
153
|
|
|
154
154
|
```bash
|
|
155
|
-
pip install devflow_toolkit-0.3.
|
|
155
|
+
pip install devflow_toolkit-0.3.24-py3-none-any.whl
|
|
156
156
|
```
|
|
157
157
|
|
|
158
158
|
Verify the installation:
|
|
@@ -428,7 +428,7 @@ as an architectural constraint when it is present.
|
|
|
428
428
|
|
|
429
429
|
### Harnesses
|
|
430
430
|
|
|
431
|
-
| Harness | Status in 0.3.
|
|
431
|
+
| Harness | Status in 0.3.24 |
|
|
432
432
|
| --- | --- |
|
|
433
433
|
| OpenCode | Verified end-to-end; interactive Discovery uses the `question` tool |
|
|
434
434
|
| Antigravity | Custom agents and scoped permissions generated; `agy` loading and print mode verified |
|
|
@@ -683,6 +683,78 @@ appends the question to `discovery.yaml`, and returns the change to
|
|
|
683
683
|
specification is generated. `devflow approve` rejects a
|
|
684
684
|
specification that still lists open questions.
|
|
685
685
|
|
|
686
|
+
In an interactive run the specification agent checks for missing
|
|
687
|
+
decisions **before** writing:
|
|
688
|
+
|
|
689
|
+
- **Up to 3 missing decisions:** it asks you in the same session, with
|
|
690
|
+
the same rules as Discovery (recommended level-1 option first, a
|
|
691
|
+
next-level option with its reason, security never assumed). Your
|
|
692
|
+
answers are recorded in `discovery.yaml` as decisions resolved by you,
|
|
693
|
+
and then it writes the spec. DevFlow writes the new Discovery digest
|
|
694
|
+
into the spec header, because the agent cannot compute it.
|
|
695
|
+
- **More than 3, or no answer:** it records them as `pending`, sets the
|
|
696
|
+
record to `awaiting_clarification` and stops without writing
|
|
697
|
+
`spec.md`, so no tokens are spent on a document that would be
|
|
698
|
+
discarded.
|
|
699
|
+
|
|
700
|
+
If the agent leaves `discovery.yaml` invalid, DevFlow writes no
|
|
701
|
+
specification and asks you to run `devflow spec --continue`, which
|
|
702
|
+
repairs the file first. When an agent lists questions in section 7,
|
|
703
|
+
nested bullets stay part of the same question.
|
|
704
|
+
|
|
705
|
+
DevFlow derives completeness from the decisions themselves: a record
|
|
706
|
+
marked `complete` with pending questions is treated as
|
|
707
|
+
`awaiting_clarification`, and a question written with
|
|
708
|
+
`status: awaiting_clarification` is read as `pending`.
|
|
709
|
+
|
|
710
|
+
### Level-based Discovery
|
|
711
|
+
|
|
712
|
+
Discovery builds the solution level by level instead of solving
|
|
713
|
+
everything at once:
|
|
714
|
+
|
|
715
|
+
1. **Level 1 first.** The spec covers the essential behavior, built with
|
|
716
|
+
the tools the project already has, plus basic and obvious security.
|
|
717
|
+
2. **Security is always asked, never assumed.** Basic security decisions
|
|
718
|
+
are explicit questions with a recommended option and a short
|
|
719
|
+
explanation, so the user learns them by answering.
|
|
720
|
+
3. **Every question offers a next level.** One option takes the decision
|
|
721
|
+
one level further. It is recorded in `next_level`:
|
|
722
|
+
|
|
723
|
+
```yaml
|
|
724
|
+
options:
|
|
725
|
+
- "Token valid until logout (basic)"
|
|
726
|
+
- "Token that expires after 24 hours"
|
|
727
|
+
next_level:
|
|
728
|
+
option: "Token that expires after 24 hours"
|
|
729
|
+
why: "Limits the damage if a token leaks."
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
If the user chooses it, the answer uses that exact text. If not,
|
|
733
|
+
DevFlow treats it as a suggestion for a later specification. The
|
|
734
|
+
recommended option is level 1, so a `next_level` marked as
|
|
735
|
+
recommended is ignored.
|
|
736
|
+
4. **No deeper than this level.** More advanced decisions found along
|
|
737
|
+
the way, and parts of a large request left for later, are recorded in
|
|
738
|
+
`deferred`:
|
|
739
|
+
|
|
740
|
+
```yaml
|
|
741
|
+
deferred:
|
|
742
|
+
- title: "Limit failed login attempts"
|
|
743
|
+
why: "Protects accounts from password guessing."
|
|
744
|
+
question_id: Q2
|
|
745
|
+
```
|
|
746
|
+
|
|
747
|
+
5. **Readiness check.** Before closing, the agent confirms a decision
|
|
748
|
+
exists for every flow, interface, stored data, error case and level-1
|
|
749
|
+
security measure, and asks what is missing in the same round.
|
|
750
|
+
|
|
751
|
+
DevFlow collects `deferred` items and every unchosen `next_level` into
|
|
752
|
+
**suggested next specifications**. They appear in the Decision Context,
|
|
753
|
+
in `devflow status`, after approval in the `Next:` line, and in
|
|
754
|
+
`spec.md` section `10.1 Suggested next specifications`. DevFlow writes
|
|
755
|
+
that subsection itself, with a ready-to-run `devflow spec "..."` command
|
|
756
|
+
for each item; the agent does not write it.
|
|
757
|
+
|
|
686
758
|
## Workflow
|
|
687
759
|
|
|
688
760
|
1. Initialize the project with `devflow init`.
|
|
@@ -696,7 +768,7 @@ specification that still lists open questions.
|
|
|
696
768
|
8. If artifacts exist without workflow state, diagnose with
|
|
697
769
|
`devflow doctor <id>` and repair with `devflow recover <id>`.
|
|
698
770
|
|
|
699
|
-
Available commands in `0.3.
|
|
771
|
+
Available commands in `0.3.24`:
|
|
700
772
|
|
|
701
773
|
| Command | Status |
|
|
702
774
|
| --- | --- |
|
|
@@ -929,7 +1001,7 @@ devflow approve 001
|
|
|
929
1001
|
```
|
|
930
1002
|
|
|
931
1003
|
Approval is explicit and binds the decision to the current artifact
|
|
932
|
-
digests. For a `0.3.
|
|
1004
|
+
digests. For a `0.3.24` change it binds `spec.md`, `discovery.yaml` and,
|
|
933
1005
|
when a manifest applies, the architecture manifest digest. Repeating the
|
|
934
1006
|
same approval is a no-op. If an artifact changes after validation,
|
|
935
1007
|
DevFlow marks it stale and refuses approval until it is regenerated and
|
|
@@ -940,7 +1012,7 @@ and names the pending questions and assumptions. Approval also rejects a
|
|
|
940
1012
|
specification whose section 7 still lists open questions. Legacy `0.2.0`
|
|
941
1013
|
changes without `discovery.yaml` remain approvable with a warning.
|
|
942
1014
|
|
|
943
|
-
Only the `spec` stage is available in `0.3.
|
|
1015
|
+
Only the `spec` stage is available in `0.3.24`, so `--stage` is optional
|
|
944
1016
|
and defaults to `spec`. `--stage plan` and `--stage review` are
|
|
945
1017
|
rejected. There are no `plan`, `implement` or
|
|
946
1018
|
`review` commands in this release.
|
|
@@ -20,20 +20,20 @@ devflow/commands/init.py,sha256=G2LDYDElWDSDPk3-1DfRtv8sW_z-9ITJH1Co6C5jiyw,1718
|
|
|
20
20
|
devflow/commands/recover.py,sha256=sV9x5-30E_3XRBe7JItDiSG-pqrowRzjqOkC_eyrhFQ,2165
|
|
21
21
|
devflow/commands/reopen.py,sha256=bZiX-dyKgmtdKdV4FHwEwRCFvuuX5jezBCI7wIpkHYU,2971
|
|
22
22
|
devflow/commands/spec.py,sha256=7glxFHKuJd33mL6YayrxRJ6TViUmmQk5rijbNepsbig,16353
|
|
23
|
-
devflow/commands/status.py,sha256=
|
|
23
|
+
devflow/commands/status.py,sha256=Lazqr7I8heJHCK-0q3NQxsIORwRzopDwkRgAnbcdnA4,6742
|
|
24
24
|
devflow/core/__init__.py,sha256=hN7i4-PDaZ7y4P8qRpZl_lJvIiPyQaN1TDGnw2BecYU,427
|
|
25
25
|
devflow/core/architecture.py,sha256=qllllsUVqA76LiSU6z_s4U8dxMcs6ClKXU16HxI3yOI,13692
|
|
26
26
|
devflow/core/clock.py,sha256=KZROv6o51Ln1EzK00ySCxfc7WPZqPlaQhFfjfdc_TMY,1651
|
|
27
27
|
devflow/core/config.py,sha256=VsR2ezH1toydLVyniy-BXtC843vDIstxI2-8vh4VmnU,26455
|
|
28
28
|
devflow/core/constitution.py,sha256=rPLc8Puv9nUMC_GZwzOqvr1B-4urdxAISr655od2IPM,5333
|
|
29
|
-
devflow/core/discovery.py,sha256=
|
|
29
|
+
devflow/core/discovery.py,sha256=EIffENMOrmF3SmdJJAPVJDVAo0kG0SMw8RSW-LWnC10,59943
|
|
30
30
|
devflow/core/file_types.py,sha256=5S5YywOaTESDiln4kP7qyJFEjxHoiF6tSBbwuXNpDDc,566
|
|
31
31
|
devflow/core/ports.py,sha256=6jlqeR40MNaz-IuZIAPimXpRKew-wMUab3KzelcTXsU,4541
|
|
32
32
|
devflow/core/profile_manager.py,sha256=QnnJka2KIKD2tCSWJkGTOUEFMgmQT0Z9Qv173JKWKHw,8937
|
|
33
33
|
devflow/core/project.py,sha256=4OnudghY5N5rCOmafWO5Hk68M7T3-mOV0j0k0dh2luE,16891
|
|
34
34
|
devflow/core/recovery.py,sha256=W2If6Ymb3ISwMN8IVQYCwptDUzhxejlF-P2NvMYyZP0,8818
|
|
35
|
-
devflow/core/spec_workflow.py,sha256=
|
|
36
|
-
devflow/core/specification.py,sha256=
|
|
35
|
+
devflow/core/spec_workflow.py,sha256=Ngma_-7MLsp96gNd2avVC81_SjWTAk4jscsQinmCml4,43961
|
|
36
|
+
devflow/core/specification.py,sha256=JSd-OHuoMWi4yuNblulFEGJ0HYmBNh8R_8MF6tMx-lo,67214
|
|
37
37
|
devflow/core/artifacts/__init__.py,sha256=gt9xahPynoxv75FMq1ZJx91ILTIv4ExuvX1Ymrxwr2c,627
|
|
38
38
|
devflow/core/artifacts/errors.py,sha256=hwZxnLFcUTtEjDWtN6rUCkM69EN19LGVlc6HD-pNZyk,493
|
|
39
39
|
devflow/core/artifacts/models.py,sha256=xJjmY8jUAHxqYN9u1JEu8CbJB-IJg1xb9P-LDaP5_Hw,2049
|
|
@@ -59,12 +59,12 @@ devflow/profiles/django-backend/profile.yaml,sha256=SNj7a3yamdJx-P69GvIJmLkC2svO
|
|
|
59
59
|
devflow/profiles/django-backend/constitution/django-standards.md,sha256=0M-XmxOpEmgIadcaVdf6OVmll8Oec0jEjcJ4C8MfwhQ,2052
|
|
60
60
|
devflow/profiles/fastapi-backend/profile.yaml,sha256=5_b-zWSX0HV-tw_2ntRCSa4DyP3NUqYWmxOh55pXYmc,321
|
|
61
61
|
devflow/profiles/fastapi-backend/constitution/fastapi-standards.md,sha256=iFKib4i_9z4wBQ9thl-uftg5g-CHwvmFWzMtLgA7CBk,1949
|
|
62
|
-
devflow/prompts/__init__.py,sha256=
|
|
62
|
+
devflow/prompts/__init__.py,sha256=DttfMavd0nfmhKkVE46VhpIHkGS-4amYfufABEM20xI,19120
|
|
63
63
|
devflow/prompts/discovery-repair.md,sha256=YfTfrrw5uUZvC_x6X2lrYEDkMNhanhoe0ER3Yc2-rgI,1135
|
|
64
|
-
devflow/prompts/discovery.md,sha256=
|
|
65
|
-
devflow/prompts/spec.md,sha256=
|
|
66
|
-
devflow_toolkit-0.3.
|
|
67
|
-
devflow_toolkit-0.3.
|
|
68
|
-
devflow_toolkit-0.3.
|
|
69
|
-
devflow_toolkit-0.3.
|
|
70
|
-
devflow_toolkit-0.3.
|
|
64
|
+
devflow/prompts/discovery.md,sha256=AqHl0jz_uZZSlupQnxoRYzPhAzvkNCxIv34yGV5uBt8,14470
|
|
65
|
+
devflow/prompts/spec.md,sha256=90NI6atLfvCcLKAojcxgEfCJDSt-kbb70KGctu_1tXA,7375
|
|
66
|
+
devflow_toolkit-0.3.24.dist-info/METADATA,sha256=abbM1nIO4KP2e8_XfmSPr7xq0XJsrRXxXxvpwj8H6hM,49731
|
|
67
|
+
devflow_toolkit-0.3.24.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
68
|
+
devflow_toolkit-0.3.24.dist-info/entry_points.txt,sha256=wPmqE1081vi8s3xf-Wfzfvpl-44IKgwx7OGoLEK3u7o,44
|
|
69
|
+
devflow_toolkit-0.3.24.dist-info/licenses/LICENSE,sha256=Wa04lstC8Goe4b9IYfEYWB2k7nokYBejZl6NdyAl8rA,1077
|
|
70
|
+
devflow_toolkit-0.3.24.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|