devflow-cli 11.0.0__py3-none-any.whl → 11.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- devflow_cli/__init__.py +1 -1
- devflow_cli/adapters/agents.py +127 -21
- devflow_cli/commands/adaptive.py +18 -0
- devflow_cli/core/run_progress.py +113 -3
- devflow_cli/core/worktree_snapshot.py +67 -14
- devflow_cli/resources/commands/devflow.md +37 -1
- {devflow_cli-11.0.0.dist-info → devflow_cli-11.1.0.dist-info}/METADATA +1 -1
- {devflow_cli-11.0.0.dist-info → devflow_cli-11.1.0.dist-info}/RECORD +11 -11
- {devflow_cli-11.0.0.dist-info → devflow_cli-11.1.0.dist-info}/WHEEL +0 -0
- {devflow_cli-11.0.0.dist-info → devflow_cli-11.1.0.dist-info}/entry_points.txt +0 -0
- {devflow_cli-11.0.0.dist-info → devflow_cli-11.1.0.dist-info}/licenses/LICENSE +0 -0
devflow_cli/__init__.py
CHANGED
devflow_cli/adapters/agents.py
CHANGED
|
@@ -5,8 +5,10 @@ from __future__ import annotations
|
|
|
5
5
|
import json
|
|
6
6
|
import subprocess
|
|
7
7
|
import re
|
|
8
|
+
import threading
|
|
8
9
|
import time
|
|
9
10
|
from abc import ABC, abstractmethod
|
|
11
|
+
from collections.abc import Callable
|
|
10
12
|
from dataclasses import dataclass, replace
|
|
11
13
|
from pathlib import Path
|
|
12
14
|
from typing import Literal
|
|
@@ -19,6 +21,8 @@ from devflow_cli.adapters.linear import environment_without_linear_key
|
|
|
19
21
|
|
|
20
22
|
PermissionMode = Literal["auto", "acceptEdits", "manual"]
|
|
21
23
|
SandboxMode = Literal["read-only", "workspace-write"]
|
|
24
|
+
# Recoit chaque evenement JSON du flux de l'agent pendant qu'il tourne.
|
|
25
|
+
EventObserver = Callable[[dict], None]
|
|
22
26
|
|
|
23
27
|
# L'agent a termine sans erreur (code 0) mais sa sortie structuree manque ou n'est
|
|
24
28
|
# pas le JSON attendu. Claude porte le diagnostic dedie ; les autres valeurs restent
|
|
@@ -38,6 +42,8 @@ STRUCTURED_OUTPUT_MISSING_MESSAGE = (
|
|
|
38
42
|
# Impose le premier plan aux sous-agents de l'agent Claude d'une activite ; desactive
|
|
39
43
|
# aussi ses commandes shell en arriere-plan.
|
|
40
44
|
CLAUDE_FOREGROUND_ENV = "CLAUDE_CODE_DISABLE_BACKGROUND_TASKS"
|
|
45
|
+
# Attente des lecteurs de sortie apres l'arret du processus a l'expiration du delai.
|
|
46
|
+
READER_GRACE_SECONDS = 5
|
|
41
47
|
|
|
42
48
|
@dataclass(frozen=True)
|
|
43
49
|
class QuotaWindow:
|
|
@@ -98,6 +104,8 @@ class AgentAdapter(ABC):
|
|
|
98
104
|
|
|
99
105
|
name: str
|
|
100
106
|
executable: str
|
|
107
|
+
# Sortie standard structuree lue comme un flux d'evenements JSON, un par ligne.
|
|
108
|
+
streams_events = False
|
|
101
109
|
|
|
102
110
|
@abstractmethod
|
|
103
111
|
def build_command(self, prompt: str, permission_mode: PermissionMode) -> list[str]:
|
|
@@ -158,25 +166,25 @@ class AgentAdapter(ABC):
|
|
|
158
166
|
output_file: Path,
|
|
159
167
|
permission_mode: PermissionMode = "auto",
|
|
160
168
|
sandbox_mode: SandboxMode = "workspace-write",
|
|
169
|
+
*,
|
|
170
|
+
observer: EventObserver | None = None,
|
|
161
171
|
) -> AgentExecution:
|
|
162
172
|
command = self.build_structured_command(
|
|
163
173
|
prompt, permission_mode, schema_file, output_file, sandbox_mode
|
|
164
174
|
)
|
|
175
|
+
collector = _StdoutCollector(self.streams_events, observer)
|
|
165
176
|
started = time.monotonic()
|
|
166
177
|
try:
|
|
167
|
-
result =
|
|
178
|
+
result = _run_streaming(
|
|
168
179
|
command,
|
|
169
180
|
cwd=cwd,
|
|
170
181
|
timeout=timeout,
|
|
171
|
-
text=True,
|
|
172
|
-
capture_output=True,
|
|
173
|
-
stdin=subprocess.DEVNULL,
|
|
174
|
-
shell=False,
|
|
175
182
|
env=self.structured_environment(),
|
|
183
|
+
on_line=collector.feed,
|
|
176
184
|
)
|
|
177
185
|
execution = AgentExecution(
|
|
178
186
|
result.returncode,
|
|
179
|
-
|
|
187
|
+
collector.stdout(),
|
|
180
188
|
result.stderr or "",
|
|
181
189
|
duration_seconds=time.monotonic() - started,
|
|
182
190
|
final_output_status=_output_status(output_file),
|
|
@@ -242,7 +250,7 @@ class AgentAdapter(ABC):
|
|
|
242
250
|
usage=execution.usage,
|
|
243
251
|
)
|
|
244
252
|
except subprocess.TimeoutExpired as exc:
|
|
245
|
-
stdout, stderr =
|
|
253
|
+
stdout, stderr = collector.stdout(), _text(exc.stderr)
|
|
246
254
|
session_id = self.session_id(stdout, stderr)
|
|
247
255
|
return AgentExecution(
|
|
248
256
|
124,
|
|
@@ -307,6 +315,7 @@ class AgentAdapter(ABC):
|
|
|
307
315
|
class ClaudeCodeAdapter(AgentAdapter):
|
|
308
316
|
name = "claude-code"
|
|
309
317
|
executable = "claude"
|
|
318
|
+
streams_events = True
|
|
310
319
|
|
|
311
320
|
def build_command(self, prompt: str, permission_mode: PermissionMode) -> list[str]:
|
|
312
321
|
return [
|
|
@@ -334,7 +343,8 @@ class ClaudeCodeAdapter(AgentAdapter):
|
|
|
334
343
|
"--permission-mode",
|
|
335
344
|
effective_mode,
|
|
336
345
|
"--output-format",
|
|
337
|
-
"json",
|
|
346
|
+
"stream-json",
|
|
347
|
+
"--verbose",
|
|
338
348
|
"--json-schema",
|
|
339
349
|
schema,
|
|
340
350
|
prompt,
|
|
@@ -370,7 +380,7 @@ class ClaudeCodeAdapter(AgentAdapter):
|
|
|
370
380
|
return _count(stats.get("spawned")), _count(stats.get("started_in_background"))
|
|
371
381
|
|
|
372
382
|
def usage(self, stdout: str, session_id: str | None) -> AgentUsage | None:
|
|
373
|
-
"""Lit l'
|
|
383
|
+
"""Lit l'evenement result du flux : usage cumule de tous les tours."""
|
|
374
384
|
envelope = json.loads(stdout)
|
|
375
385
|
if not isinstance(envelope, dict) or not isinstance(envelope.get("usage"), dict):
|
|
376
386
|
return None
|
|
@@ -435,6 +445,112 @@ def _claude_compatible_schema(schema_file: Path) -> str:
|
|
|
435
445
|
return json.dumps(schema, ensure_ascii=False)
|
|
436
446
|
|
|
437
447
|
|
|
448
|
+
class _StdoutCollector:
|
|
449
|
+
"""Sortie standard d'une execution structuree, recue ligne a ligne.
|
|
450
|
+
|
|
451
|
+
En flux d'evenements, seul l'evenement ``type: result`` est garde, cherche par son
|
|
452
|
+
type et non par sa position ; les autres lignes ne sont ni gardees ni ecrites.
|
|
453
|
+
"""
|
|
454
|
+
|
|
455
|
+
def __init__(self, events: bool, observer: EventObserver | None) -> None:
|
|
456
|
+
self._events = events
|
|
457
|
+
self._observer = observer
|
|
458
|
+
self._lines: list[str] = []
|
|
459
|
+
self._result = ""
|
|
460
|
+
|
|
461
|
+
def feed(self, line: str) -> None:
|
|
462
|
+
if not self._events:
|
|
463
|
+
self._lines.append(line)
|
|
464
|
+
return
|
|
465
|
+
event = _json_object(line)
|
|
466
|
+
if event is None:
|
|
467
|
+
return
|
|
468
|
+
if event.get("type") == "result":
|
|
469
|
+
self._result = line.strip()
|
|
470
|
+
if self._observer is not None:
|
|
471
|
+
try:
|
|
472
|
+
self._observer(event)
|
|
473
|
+
except Exception: # noqa: BLE001 - l'avancement ne fait jamais echouer
|
|
474
|
+
pass
|
|
475
|
+
|
|
476
|
+
def stdout(self) -> str:
|
|
477
|
+
return self._result if self._events else "".join(self._lines)
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
def _run_streaming(
|
|
481
|
+
command: list[str],
|
|
482
|
+
*,
|
|
483
|
+
cwd: Path,
|
|
484
|
+
timeout: int,
|
|
485
|
+
env: dict[str, str],
|
|
486
|
+
on_line: Callable[[str], None],
|
|
487
|
+
) -> subprocess.CompletedProcess:
|
|
488
|
+
"""Lance l'agent et remet chaque ligne de sa sortie standard pendant qu'il tourne.
|
|
489
|
+
|
|
490
|
+
La sortie d'erreur est lue par un fil a part : aucun interblocage entre les deux
|
|
491
|
+
tuyaux. A l'expiration du delai, le processus est arrete et TimeoutExpired levee,
|
|
492
|
+
avec la sortie d'erreur lue jusque-la.
|
|
493
|
+
"""
|
|
494
|
+
deadline = time.monotonic() + timeout
|
|
495
|
+
process = subprocess.Popen(
|
|
496
|
+
command,
|
|
497
|
+
cwd=cwd,
|
|
498
|
+
text=True,
|
|
499
|
+
errors="replace",
|
|
500
|
+
stdout=subprocess.PIPE,
|
|
501
|
+
stderr=subprocess.PIPE,
|
|
502
|
+
stdin=subprocess.DEVNULL,
|
|
503
|
+
shell=False,
|
|
504
|
+
env=env,
|
|
505
|
+
)
|
|
506
|
+
errors: list[str] = []
|
|
507
|
+
|
|
508
|
+
def read_stdout() -> None:
|
|
509
|
+
with process.stdout:
|
|
510
|
+
for line in process.stdout:
|
|
511
|
+
on_line(line)
|
|
512
|
+
|
|
513
|
+
def read_stderr() -> None:
|
|
514
|
+
with process.stderr:
|
|
515
|
+
errors.append(process.stderr.read())
|
|
516
|
+
|
|
517
|
+
readers = [
|
|
518
|
+
threading.Thread(target=read_stdout, daemon=True),
|
|
519
|
+
threading.Thread(target=read_stderr, daemon=True),
|
|
520
|
+
]
|
|
521
|
+
for reader in readers:
|
|
522
|
+
reader.start()
|
|
523
|
+
try:
|
|
524
|
+
process.wait(timeout=max(0.0, deadline - time.monotonic()))
|
|
525
|
+
for reader in readers:
|
|
526
|
+
reader.join(max(0.0, deadline - time.monotonic()))
|
|
527
|
+
if any(reader.is_alive() for reader in readers):
|
|
528
|
+
raise subprocess.TimeoutExpired(command, timeout)
|
|
529
|
+
except subprocess.TimeoutExpired:
|
|
530
|
+
process.kill()
|
|
531
|
+
process.wait()
|
|
532
|
+
for reader in readers:
|
|
533
|
+
reader.join(READER_GRACE_SECONDS)
|
|
534
|
+
raise subprocess.TimeoutExpired(command, timeout, stderr="".join(errors))
|
|
535
|
+
except BaseException:
|
|
536
|
+
# Interruption (KeyboardInterrupt, etc.) : l'agent ne doit pas survivre.
|
|
537
|
+
process.kill()
|
|
538
|
+
process.wait()
|
|
539
|
+
raise
|
|
540
|
+
return subprocess.CompletedProcess(command, process.returncode, "", "".join(errors))
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
def _json_object(line: str) -> dict | None:
|
|
544
|
+
line = line.strip()
|
|
545
|
+
if not line.startswith("{"):
|
|
546
|
+
return None
|
|
547
|
+
try:
|
|
548
|
+
event = json.loads(line)
|
|
549
|
+
except json.JSONDecodeError:
|
|
550
|
+
return None
|
|
551
|
+
return event if isinstance(event, dict) else None
|
|
552
|
+
|
|
553
|
+
|
|
438
554
|
def _text(value: str | bytes | None) -> str:
|
|
439
555
|
if value is None:
|
|
440
556
|
return ""
|
|
@@ -462,18 +578,8 @@ def _session_id(stdout: str, stderr: str) -> str | None:
|
|
|
462
578
|
|
|
463
579
|
def json_line_events(stdout: str) -> list[dict]:
|
|
464
580
|
"""Decode un flux JSONL d'agent en ignorant les lignes non JSON ou non objet."""
|
|
465
|
-
events
|
|
466
|
-
for
|
|
467
|
-
line = line.strip()
|
|
468
|
-
if not line.startswith("{"):
|
|
469
|
-
continue
|
|
470
|
-
try:
|
|
471
|
-
event = json.loads(line)
|
|
472
|
-
except json.JSONDecodeError:
|
|
473
|
-
continue
|
|
474
|
-
if isinstance(event, dict):
|
|
475
|
-
events.append(event)
|
|
476
|
-
return events
|
|
581
|
+
events = (_json_object(line) for line in stdout.splitlines())
|
|
582
|
+
return [event for event in events if event is not None]
|
|
477
583
|
|
|
478
584
|
|
|
479
585
|
def _strip_json_fence(value: str) -> str:
|
devflow_cli/commands/adaptive.py
CHANGED
|
@@ -385,11 +385,23 @@ def _run_activity(
|
|
|
385
385
|
sync_activity_status(
|
|
386
386
|
current_state.issueId, activity_contract.activity, stream
|
|
387
387
|
)
|
|
388
|
+
actions = run_progress.AgentActions(
|
|
389
|
+
project_root,
|
|
390
|
+
lambda: len(
|
|
391
|
+
changed_paths(
|
|
392
|
+
before,
|
|
393
|
+
snapshot_worktree(
|
|
394
|
+
project_root, feature_dir, optional_locks=False
|
|
395
|
+
),
|
|
396
|
+
)
|
|
397
|
+
),
|
|
398
|
+
)
|
|
388
399
|
with run_progress.heartbeat(
|
|
389
400
|
activity_contract.activity,
|
|
390
401
|
agent,
|
|
391
402
|
stream,
|
|
392
403
|
run_progress.PROGRESS_INTERVAL_SECONDS,
|
|
404
|
+
actions,
|
|
393
405
|
):
|
|
394
406
|
execution = adapter.execute_structured(
|
|
395
407
|
prompt_text,
|
|
@@ -401,6 +413,7 @@ def _run_activity(
|
|
|
401
413
|
"workspace-write"
|
|
402
414
|
if "execute" in activity_contract.allowedActions
|
|
403
415
|
else "read-only",
|
|
416
|
+
observer=actions.observe,
|
|
404
417
|
)
|
|
405
418
|
attempt["execution"] = execution
|
|
406
419
|
output = (
|
|
@@ -458,6 +471,11 @@ def _run_activity(
|
|
|
458
471
|
f"Activite '{outcome.activity}' validee. "
|
|
459
472
|
f"Prochaine : {outcome.nextActivity}"
|
|
460
473
|
)
|
|
474
|
+
if outcome.result is not None:
|
|
475
|
+
# Texte de l'agent affiche tel quel : un crochet reste un crochet (D6).
|
|
476
|
+
console.print(
|
|
477
|
+
f" Resume : {outcome.result.summary}", markup=False, soft_wrap=True
|
|
478
|
+
)
|
|
461
479
|
_print_warnings(outcome.warnings)
|
|
462
480
|
_print_pending_approvals(feature_dir, current_state.issueId, outcome.activity)
|
|
463
481
|
return
|
devflow_cli/core/run_progress.py
CHANGED
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
"""Avancement d'une activite : lignes horodatees
|
|
1
|
+
"""Avancement d'une activite : lignes horodatees.
|
|
2
|
+
|
|
3
|
+
Seuls des faits sont exposes (KKS-776, D4) : nombre d'actions, nombre de fichiers
|
|
4
|
+
du depot dont le contenu a change depuis le debut de l'activite (lu par git, sans
|
|
5
|
+
verrou optionnel), nom de la derniere action avec son chemin ou, pour `Bash`, la
|
|
6
|
+
description ecrite par l'agent (repli : la commande masquee) ; jamais un contenu de
|
|
7
|
+
fichier, un prompt ni une sortie d'outil.
|
|
8
|
+
"""
|
|
2
9
|
|
|
3
10
|
from __future__ import annotations
|
|
4
11
|
|
|
12
|
+
import shlex
|
|
5
13
|
import sys
|
|
6
14
|
import threading
|
|
7
15
|
import time
|
|
8
16
|
from contextlib import contextmanager
|
|
9
17
|
from datetime import datetime, timezone
|
|
10
|
-
from
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
from typing import Callable, Iterator, TextIO
|
|
20
|
+
|
|
21
|
+
from devflow_cli.core.redaction import redact_command
|
|
11
22
|
|
|
12
23
|
PROGRESS_INTERVAL_SECONDS = 60
|
|
24
|
+
COMMAND_LABEL_LIMIT = 80
|
|
13
25
|
|
|
14
26
|
|
|
15
27
|
def emit_progress(message: str, stream: TextIO | None = None) -> None:
|
|
@@ -32,12 +44,108 @@ def format_elapsed(seconds: float) -> str:
|
|
|
32
44
|
return f"{minutes} min {secs:02d} s"
|
|
33
45
|
|
|
34
46
|
|
|
47
|
+
def action_label(name: str, tool_input: object, project_root: Path) -> str:
|
|
48
|
+
"""Libelle d'une action : outil, description de l'agent, commande masquee ou chemin (D4)."""
|
|
49
|
+
fields = tool_input if isinstance(tool_input, dict) else {}
|
|
50
|
+
if name == "Bash":
|
|
51
|
+
description = fields.get("description")
|
|
52
|
+
if isinstance(description, str):
|
|
53
|
+
first = next(iter(description.strip().splitlines()), "").strip()
|
|
54
|
+
if first:
|
|
55
|
+
return _printable(f"Bash : {first[:COMMAND_LABEL_LIMIT]}")
|
|
56
|
+
command = fields.get("command")
|
|
57
|
+
lines = command.splitlines() if isinstance(command, str) else []
|
|
58
|
+
try:
|
|
59
|
+
args = shlex.split(lines[0]) if lines else []
|
|
60
|
+
except ValueError:
|
|
61
|
+
args = []
|
|
62
|
+
label = " ".join(redact_command(args))[:COMMAND_LABEL_LIMIT]
|
|
63
|
+
return _printable(f"Bash : {label}" if label else "Bash")
|
|
64
|
+
path = _tool_path(fields)
|
|
65
|
+
if path is None:
|
|
66
|
+
return _printable(name)
|
|
67
|
+
try:
|
|
68
|
+
shown = Path(path).relative_to(project_root).as_posix()
|
|
69
|
+
except ValueError:
|
|
70
|
+
shown = path
|
|
71
|
+
return _printable(f"{name} : {shown}")
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class AgentActions:
|
|
75
|
+
"""Faits retenus du flux de l'agent et de ses sous-agents (D3), sans contenu."""
|
|
76
|
+
|
|
77
|
+
def __init__(
|
|
78
|
+
self, project_root: Path, changed_files: Callable[[], int] | None = None
|
|
79
|
+
) -> None:
|
|
80
|
+
self._project_root = project_root
|
|
81
|
+
self._changed_files = changed_files
|
|
82
|
+
self._lock = threading.Lock()
|
|
83
|
+
self._count = 0
|
|
84
|
+
self._last = ""
|
|
85
|
+
|
|
86
|
+
def observe(self, event: dict) -> None:
|
|
87
|
+
"""Compte chaque bloc tool_use d'un evenement assistant ; ignore le reste."""
|
|
88
|
+
message = event.get("message") if event.get("type") == "assistant" else None
|
|
89
|
+
content = message.get("content") if isinstance(message, dict) else None
|
|
90
|
+
if not isinstance(content, list):
|
|
91
|
+
return
|
|
92
|
+
for block in content:
|
|
93
|
+
if not isinstance(block, dict) or block.get("type") != "tool_use":
|
|
94
|
+
continue
|
|
95
|
+
name = block.get("name")
|
|
96
|
+
if not isinstance(name, str) or not name:
|
|
97
|
+
continue
|
|
98
|
+
fields = block.get("input")
|
|
99
|
+
label = action_label(name, fields, self._project_root)
|
|
100
|
+
with self._lock:
|
|
101
|
+
self._count += 1
|
|
102
|
+
self._last = label
|
|
103
|
+
|
|
104
|
+
def describe(self) -> str | None:
|
|
105
|
+
"""Suffixe de la ligne de la minute ; None tant qu'aucune action n'est vue."""
|
|
106
|
+
with self._lock:
|
|
107
|
+
count, last = self._count, self._last
|
|
108
|
+
if count == 0:
|
|
109
|
+
return None
|
|
110
|
+
files = self._count_changed_files()
|
|
111
|
+
part = f", {files} fichiers modifies" if files is not None else ""
|
|
112
|
+
return f"{count} actions{part}, derniere : {last}"
|
|
113
|
+
|
|
114
|
+
def _count_changed_files(self) -> int | None:
|
|
115
|
+
"""Appelee hors verrou ; toute erreur est avalee (jamais d'echec d'activite)."""
|
|
116
|
+
if self._changed_files is None:
|
|
117
|
+
return None
|
|
118
|
+
try:
|
|
119
|
+
value = self._changed_files()
|
|
120
|
+
except Exception:
|
|
121
|
+
return None
|
|
122
|
+
if isinstance(value, bool) or not isinstance(value, int):
|
|
123
|
+
return None
|
|
124
|
+
return value
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _tool_path(fields: object) -> str | None:
|
|
128
|
+
if not isinstance(fields, dict):
|
|
129
|
+
return None
|
|
130
|
+
for key in ("file_path", "notebook_path"):
|
|
131
|
+
value = fields.get(key)
|
|
132
|
+
if isinstance(value, str) and value:
|
|
133
|
+
return value
|
|
134
|
+
return None
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def _printable(text: str) -> str:
|
|
138
|
+
"""Une ligne complete : aucune sequence de controle venue du flux."""
|
|
139
|
+
return "".join(char for char in text if char.isprintable())
|
|
140
|
+
|
|
141
|
+
|
|
35
142
|
@contextmanager
|
|
36
143
|
def heartbeat(
|
|
37
144
|
activity: str,
|
|
38
145
|
agent: str,
|
|
39
146
|
stream: TextIO,
|
|
40
147
|
interval: float = PROGRESS_INTERVAL_SECONDS,
|
|
148
|
+
actions: AgentActions | None = None,
|
|
41
149
|
) -> Iterator[None]:
|
|
42
150
|
"""Emet une ligne toutes les `interval` secondes tant que le bloc s'execute."""
|
|
43
151
|
if interval <= 0:
|
|
@@ -48,8 +156,10 @@ def heartbeat(
|
|
|
48
156
|
def beat() -> None:
|
|
49
157
|
while not stop.wait(interval):
|
|
50
158
|
elapsed = format_elapsed(time.monotonic() - started)
|
|
159
|
+
facts = actions.describe() if actions is not None else None
|
|
51
160
|
emit_progress(
|
|
52
|
-
f"Activite '{activity}' en cours depuis {elapsed} (agent {agent})"
|
|
161
|
+
f"Activite '{activity}' en cours depuis {elapsed} (agent {agent})"
|
|
162
|
+
+ (f" : {facts}" if facts else ""),
|
|
53
163
|
stream,
|
|
54
164
|
)
|
|
55
165
|
|
|
@@ -23,24 +23,43 @@ TRACE_SUFFIX = ".raw.txt"
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def snapshot_worktree(
|
|
26
|
-
project_root: Path, feature_dir: Path | None = None
|
|
26
|
+
project_root: Path, feature_dir: Path | None = None, *, optional_locks: bool = True
|
|
27
27
|
) -> WorktreeSnapshot:
|
|
28
28
|
"""Capture HEAD, branche et contenu des fichiers modifies/non suivis.
|
|
29
29
|
|
|
30
30
|
Avec ``feature_dir``, les fichiers ignores par git dans ce seul dossier
|
|
31
31
|
sont aussi captures, hors traces brutes : un projet qui ignore ``.specify``
|
|
32
32
|
doit tout de meme voir les artefacts de sa feature.
|
|
33
|
+
|
|
34
|
+
Avec ``optional_locks=False``, git ne prend aucun verrou optionnel (index) :
|
|
35
|
+
la capture peut avoir lieu pendant qu'un agent travaille.
|
|
33
36
|
"""
|
|
34
|
-
head = _git_text(
|
|
35
|
-
|
|
37
|
+
head = _git_text(
|
|
38
|
+
project_root,
|
|
39
|
+
["rev-parse", "--verify", "HEAD"],
|
|
40
|
+
allow_failure=True,
|
|
41
|
+
optional_locks=optional_locks,
|
|
42
|
+
)
|
|
43
|
+
branch = _git_text(
|
|
44
|
+
project_root,
|
|
45
|
+
["branch", "--show-current"],
|
|
46
|
+
allow_failure=True,
|
|
47
|
+
optional_locks=optional_locks,
|
|
48
|
+
)
|
|
36
49
|
# Sans detection de renommage : un git mv indexe compte sa source et sa destination.
|
|
37
50
|
if head:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
51
|
+
if optional_locks:
|
|
52
|
+
tracked = _git_paths(
|
|
53
|
+
project_root,
|
|
54
|
+
["diff", "--no-renames", "--name-only", "-z", "HEAD", "--"],
|
|
55
|
+
)
|
|
56
|
+
else:
|
|
57
|
+
# git status respecte GIT_OPTIONAL_LOCKS : l'index n'est pas reecrit.
|
|
58
|
+
tracked = _status_paths(project_root)
|
|
41
59
|
else:
|
|
42
|
-
tracked = _git_paths(project_root, ["ls-files", "-z"])
|
|
43
|
-
|
|
60
|
+
tracked = _git_paths(project_root, ["ls-files", "-z"], optional_locks=optional_locks)
|
|
61
|
+
others = untracked_paths(project_root, feature_dir, optional_locks=optional_locks)
|
|
62
|
+
paths = sorted(set(tracked) | set(others))
|
|
44
63
|
return WorktreeSnapshot(
|
|
45
64
|
head=head,
|
|
46
65
|
branch=branch,
|
|
@@ -48,19 +67,26 @@ def snapshot_worktree(
|
|
|
48
67
|
)
|
|
49
68
|
|
|
50
69
|
|
|
51
|
-
def untracked_paths(
|
|
70
|
+
def untracked_paths(
|
|
71
|
+
project_root: Path, feature_dir: Path | None = None, *, optional_locks: bool = True
|
|
72
|
+
) -> list[str]:
|
|
52
73
|
"""Fichiers non suivis non ignores, plus les ignores du dossier de la feature.
|
|
53
74
|
|
|
54
75
|
Les traces brutes de la feature restent exclues.
|
|
55
76
|
"""
|
|
56
77
|
paths = set(
|
|
57
|
-
_git_paths(
|
|
78
|
+
_git_paths(
|
|
79
|
+
project_root,
|
|
80
|
+
["ls-files", "--others", "--exclude-standard", "-z"],
|
|
81
|
+
optional_locks=optional_locks,
|
|
82
|
+
)
|
|
58
83
|
)
|
|
59
84
|
subtree = _subtree(project_root, feature_dir)
|
|
60
85
|
if subtree is not None:
|
|
61
86
|
ignored = _git_paths(
|
|
62
87
|
project_root,
|
|
63
88
|
["ls-files", "--others", "--ignored", "--exclude-standard", "-z", "--", subtree],
|
|
89
|
+
optional_locks=optional_locks,
|
|
64
90
|
)
|
|
65
91
|
paths |= {path for path in ignored if not path.endswith(TRACE_SUFFIX)}
|
|
66
92
|
return sorted(paths)
|
|
@@ -76,6 +102,16 @@ def changed_paths(before: WorktreeSnapshot, after: WorktreeSnapshot) -> list[str
|
|
|
76
102
|
return sorted(path for path in paths if before.files.get(path) != after.files.get(path))
|
|
77
103
|
|
|
78
104
|
|
|
105
|
+
def _status_paths(project_root: Path) -> list[str]:
|
|
106
|
+
"""Fichiers suivis qui different de HEAD, lus par git status sans ecrire l'index."""
|
|
107
|
+
entries = _git_paths(
|
|
108
|
+
project_root,
|
|
109
|
+
["status", "--porcelain", "-z", "--no-renames", "--untracked-files=no"],
|
|
110
|
+
optional_locks=False,
|
|
111
|
+
)
|
|
112
|
+
return [entry[3:] for entry in entries if entry[:2] not in ("??", "!!")]
|
|
113
|
+
|
|
114
|
+
|
|
79
115
|
def _subtree(project_root: Path, feature_dir: Path | None) -> str | None:
|
|
80
116
|
if feature_dir is None:
|
|
81
117
|
return None
|
|
@@ -85,14 +121,27 @@ def _subtree(project_root: Path, feature_dir: Path | None) -> str | None:
|
|
|
85
121
|
return None
|
|
86
122
|
|
|
87
123
|
|
|
88
|
-
def
|
|
124
|
+
def _git_environment(optional_locks: bool) -> dict[str, str]:
|
|
125
|
+
environment = environment_without_linear_key()
|
|
126
|
+
if not optional_locks:
|
|
127
|
+
environment["GIT_OPTIONAL_LOCKS"] = "0"
|
|
128
|
+
return environment
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def _git_text(
|
|
132
|
+
project_root: Path,
|
|
133
|
+
args: list[str],
|
|
134
|
+
*,
|
|
135
|
+
allow_failure: bool = False,
|
|
136
|
+
optional_locks: bool = True,
|
|
137
|
+
) -> str:
|
|
89
138
|
result = subprocess.run(
|
|
90
139
|
["git", *args],
|
|
91
140
|
cwd=project_root,
|
|
92
141
|
capture_output=True,
|
|
93
142
|
text=True,
|
|
94
143
|
timeout=30,
|
|
95
|
-
env=
|
|
144
|
+
env=_git_environment(optional_locks),
|
|
96
145
|
)
|
|
97
146
|
if result.returncode != 0:
|
|
98
147
|
if allow_failure:
|
|
@@ -102,14 +151,18 @@ def _git_text(project_root: Path, args: list[str], *, allow_failure: bool = Fals
|
|
|
102
151
|
|
|
103
152
|
|
|
104
153
|
def _git_paths(
|
|
105
|
-
project_root: Path,
|
|
154
|
+
project_root: Path,
|
|
155
|
+
args: list[str],
|
|
156
|
+
*,
|
|
157
|
+
allow_failure: bool = False,
|
|
158
|
+
optional_locks: bool = True,
|
|
106
159
|
) -> list[str]:
|
|
107
160
|
result = subprocess.run(
|
|
108
161
|
["git", *args],
|
|
109
162
|
cwd=project_root,
|
|
110
163
|
capture_output=True,
|
|
111
164
|
timeout=30,
|
|
112
|
-
env=
|
|
165
|
+
env=_git_environment(optional_locks),
|
|
113
166
|
)
|
|
114
167
|
if result.returncode != 0:
|
|
115
168
|
if allow_failure:
|
|
@@ -32,7 +32,8 @@ Devflow : le dire, avec la cause, et traiter la demande hors Devflow.
|
|
|
32
32
|
6. Si elle est évaluée mais non démarrée, lancer
|
|
33
33
|
`devflow adaptive start ISSUE_ID`.
|
|
34
34
|
7. Enchaîner les activités avec
|
|
35
|
-
`devflow adaptive run ISSUE_ID --until CIBLE
|
|
35
|
+
`devflow adaptive run ISSUE_ID --until CIBLE`, en suivant la section
|
|
36
|
+
« Rendre compte pendant le parcours ».
|
|
36
37
|
`--until` inclut l'activité ciblée.
|
|
37
38
|
La CLI s'arrête au premier refus. Distinguer alors deux cas :
|
|
38
39
|
- refus justifié (gate non satisfaite par le travail de l'agent) :
|
|
@@ -46,6 +47,41 @@ Devflow : le dire, avec la cause, et traiter la demande hors Devflow.
|
|
|
46
47
|
l'abandon et sa cause, et indiquer cette cause dans le compte rendu.
|
|
47
48
|
8. Afficher ensuite `devflow adaptive status ISSUE_ID`.
|
|
48
49
|
|
|
50
|
+
## Rendre compte pendant le parcours
|
|
51
|
+
|
|
52
|
+
Un parcours dure de quelques minutes à plus d'une heure, et la personne ne
|
|
53
|
+
voit pas la sortie de la CLI : c'est à toi de dire ce qui se passe. Devflow
|
|
54
|
+
fournit les faits, tu les dis.
|
|
55
|
+
|
|
56
|
+
1. Avant de lancer `adaptive run`, annoncer en trois lignes au plus : le
|
|
57
|
+
profil, les activités qui restent, et que tu reprendras la parole à chaque
|
|
58
|
+
fin d'activité.
|
|
59
|
+
2. Lancer `devflow adaptive run ISSUE_ID --until CIBLE` en arrière-plan, sa
|
|
60
|
+
sortie redirigée vers un fichier journal (`> JOURNAL 2>&1`) placé dans le
|
|
61
|
+
dossier temporaire du poste, jamais dans le dépôt : un fichier créé dans
|
|
62
|
+
le dépôt pendant une activité est imputé à l'agent.
|
|
63
|
+
3. Suivre ce journal avec l'outil Monitor, à sa durée maximale :
|
|
64
|
+
`tail -n +1 -f JOURNAL | awk '/en cours depuis/ { if (++n % 10) next } { print; fflush() }'`.
|
|
65
|
+
Ce filtre laisse passer toutes les lignes de la CLI, et une ligne « en
|
|
66
|
+
cours depuis » sur dix. Tant que la commande tourne, réarmer le suivi à
|
|
67
|
+
chaque expiration avec `tail -n 0 -f`, après avoir relu la fin du journal.
|
|
68
|
+
Sans outil Monitor : lancer une activité à la fois, sans `--until`, et
|
|
69
|
+
rendre compte à chaque retour.
|
|
70
|
+
4. À chaque événement, dire en une à trois lignes, en clair et sans recopier
|
|
71
|
+
la ligne brute :
|
|
72
|
+
- activité validée : ce qu'elle a produit, d'après le résumé affiché par
|
|
73
|
+
la CLI, et l'activité qui démarre ;
|
|
74
|
+
- point d'étape : la durée, le nombre d'actions et de fichiers modifiés,
|
|
75
|
+
l'action en cours ;
|
|
76
|
+
- refus : le motif et ce que tu fais ensuite.
|
|
77
|
+
5. Tant que la commande tourne, finir chaque message par l'état : « Devflow
|
|
78
|
+
travaille encore : ACTIVITE depuis HEURE ». Ne jamais laisser entendre que
|
|
79
|
+
le parcours est fini avant le retour de la commande.
|
|
80
|
+
6. Au retour de la commande, dire d'abord si le parcours est terminé ou
|
|
81
|
+
arrêté.
|
|
82
|
+
7. Si la session affiche une liste de tâches, y porter les activités de la
|
|
83
|
+
route et garder l'activité courante « en cours ».
|
|
84
|
+
|
|
49
85
|
## Retours d'usage
|
|
50
86
|
|
|
51
87
|
Consigner les retours au fil du parcours avec `devflow feedback add`, sans
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: devflow-cli
|
|
3
|
-
Version: 11.
|
|
3
|
+
Version: 11.1.0
|
|
4
4
|
Summary: Workflow adaptatif pour Claude Code : profils, preuves et contrats d'activité
|
|
5
5
|
Project-URL: Homepage, https://github.com/sopequenoteck/devflow
|
|
6
6
|
Project-URL: Repository, https://github.com/sopequenoteck/devflow
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
devflow_cli/__init__.py,sha256=
|
|
1
|
+
devflow_cli/__init__.py,sha256=qdh9L2SU2oDA50GTSrZfMdHW8GgmKGp9Y1IkUNHEas0,871
|
|
2
2
|
devflow_cli/cli.py,sha256=QQktLkHK1cEAj0ZlEuGKYumm3xJUHM-aeC-E2RgfcEY,2136
|
|
3
3
|
devflow_cli/adapters/__init__.py,sha256=z1J7_YJHcgak2a6dTZpOUKKwf-K7UwRqGzS8XY9duC0,299
|
|
4
|
-
devflow_cli/adapters/agents.py,sha256
|
|
4
|
+
devflow_cli/adapters/agents.py,sha256=gVvxZnYxPQqDq_BQi0WP-mlOZ3-_fjVa8UI7i-JkMIo,22153
|
|
5
5
|
devflow_cli/adapters/linear.py,sha256=xHKjMuL3fFJEDBF65pPJ-yWHpXom999UAU2A0C7_QeI,8362
|
|
6
6
|
devflow_cli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
devflow_cli/commands/adaptive.py,sha256=
|
|
7
|
+
devflow_cli/commands/adaptive.py,sha256=BFO0XYhG8T2ACrB1KOMLPKmVU8gt7dTtRut0FWn7WAw,67893
|
|
8
8
|
devflow_cli/commands/assess.py,sha256=V-E3ft41ljCrqp2WLjR1Dqw-JtswcqsK2nD1-euNbNE,5655
|
|
9
9
|
devflow_cli/commands/check.py,sha256=nJOHVFvgT3Nq70g-4QGrSDZVwCSetu6g7snZcfLFf9I,4421
|
|
10
10
|
devflow_cli/commands/docs_sync.py,sha256=Xc0mulpNTjDyeUDumKL7VNG0eumAf3016wEM_dqXpSU,1021
|
|
@@ -34,7 +34,7 @@ devflow_cli/core/operational.py,sha256=11iLTbyZF0ZjYTQ5HDmVCaw4bpbXpLtH2v9f1WQOr
|
|
|
34
34
|
devflow_cli/core/redaction.py,sha256=o_1MDtCyvRLrk_dWlV6_7E6_mPVB1B5a0cCfTBj9j0Q,1973
|
|
35
35
|
devflow_cli/core/remediation.py,sha256=ywOOJUyT6SYbK79NnsIZcpn90HBZhavFxl4JSB9Vz3s,12254
|
|
36
36
|
devflow_cli/core/result_template.py,sha256=XfrjUlSUDYJxE2nN8EJjHCXq1l06hn-wW1gDn1c1rBA,2493
|
|
37
|
-
devflow_cli/core/run_progress.py,sha256=
|
|
37
|
+
devflow_cli/core/run_progress.py,sha256=pCHdJVl5HjmFlsFYKd5ayy2tXuN0ZlW0QJgIHkLUv-0,6126
|
|
38
38
|
devflow_cli/core/runtime_backup.py,sha256=dowz6a1vcJsqkl-m9wGhS4F6XGfsU2rwSNJvIZMJjhI,4345
|
|
39
39
|
devflow_cli/core/staleness.py,sha256=0JH_i1b8dYJmjDmQZuVToPnLOoNCN8ZZFgiSNrrBWOY,4283
|
|
40
40
|
devflow_cli/core/telemetry.py,sha256=FVR4iU9ywXIPo_5wrqWufpsp3GmHVLYiWaReaZ_DebM,2760
|
|
@@ -44,7 +44,7 @@ devflow_cli/core/validators.py,sha256=HKGG1-td5T8cFx3rbE0iWPtddolk73qsqYreVWVT07
|
|
|
44
44
|
devflow_cli/core/verification.py,sha256=3_iGhsXNFCs5cpBUyBCRTsmRsfuBAVa38lRgy-LXXww,20349
|
|
45
45
|
devflow_cli/core/waivers.py,sha256=0w38Osjr69mDT6Lsn0ljkaq6bbggVejuhqiOnYHabs4,5586
|
|
46
46
|
devflow_cli/core/worklog.py,sha256=7sNdvvzvEzO4MKAs3tBeGGCdl2K2kyLlu9y756j9SNo,17124
|
|
47
|
-
devflow_cli/core/worktree_snapshot.py,sha256=
|
|
47
|
+
devflow_cli/core/worktree_snapshot.py,sha256=ESNWFJN8fZ7NKeDdEKHZq9f9V_2wv-3Z6dlWusu9oH4,6034
|
|
48
48
|
devflow_cli/schemas/activity-contract-v4.schema.json,sha256=IeduWDiJ5IV6EL7FDZWnHBjzyUt1uwig2rB-SMbcpOU,2006
|
|
49
49
|
devflow_cli/schemas/activity-result-v2.schema.json,sha256=2yDf6S--mlNWMxE8h8ruwTsM3Tnaa96SJDjluc4ePbI,2772
|
|
50
50
|
devflow_cli/schemas/assessment-v4.schema.json,sha256=byFBaoG_Vu-qS7vERREKThtpQa3dzNtPiFCMyEpWFVQ,2254
|
|
@@ -55,11 +55,11 @@ devflow_cli/utils/console.py,sha256=t7cpyeEluWj4v_O_KFSI59iqXK4GiSXPuxlsr8q5zoQ,
|
|
|
55
55
|
devflow_cli/utils/logging.py,sha256=ZL7DYB7rQn_94KKG7A6_IqONddR-XubJ4MhG3bGPKRI,1840
|
|
56
56
|
devflow_cli/utils/paths.py,sha256=CH81dZZTI2vjgl8mck6QcAChxoBpujmKZ0vVKhKmXEY,8176
|
|
57
57
|
devflow_cli/utils/strings.py,sha256=bfFXCwBDnFxshgZOYfy6mtysnjiaWO1wFnqBf7HLg4o,351
|
|
58
|
-
devflow_cli/resources/commands/devflow.md,sha256=
|
|
58
|
+
devflow_cli/resources/commands/devflow.md,sha256=__hcU7uy7CrKODk-Tsvd8XlTnGsrsgLkgP4OzEMZk3k,5541
|
|
59
59
|
devflow_cli/resources/commands/devflow.status.md,sha256=tqjQ1IboU99ztG6C4nunBHGJCvMn3qDqx3AoF4SPjCk,338
|
|
60
60
|
devflow_cli/resources/templates/constitution-template.md,sha256=uSzNuwF-xIRx8cHt9gloynRjNgDGmnN5z2Xck6fCOsI,2102
|
|
61
|
-
devflow_cli-11.
|
|
62
|
-
devflow_cli-11.
|
|
63
|
-
devflow_cli-11.
|
|
64
|
-
devflow_cli-11.
|
|
65
|
-
devflow_cli-11.
|
|
61
|
+
devflow_cli-11.1.0.dist-info/METADATA,sha256=B3Yh4MqSuhNMmZDPhfEGC2RaXTuwGvYKl3FM_3Wcx9g,6674
|
|
62
|
+
devflow_cli-11.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
63
|
+
devflow_cli-11.1.0.dist-info/entry_points.txt,sha256=GVJ6bMvFpqyO5589iC4nFKeGTpGIW8aKn_QPPpSZ6kU,48
|
|
64
|
+
devflow_cli-11.1.0.dist-info/licenses/LICENSE,sha256=v79PvnmqOdKhQiOa_QcWxng4q8GuGscLOwi7ygUpwpo,1070
|
|
65
|
+
devflow_cli-11.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|