devflow-cli 11.0.1__py3-none-any.whl → 11.2.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/activity_contracts.py +5 -1
- devflow_cli/core/automatic_evidence.py +191 -21
- devflow_cli/core/run_progress.py +113 -3
- devflow_cli/core/worklog.py +10 -0
- devflow_cli/core/worktree_snapshot.py +67 -14
- devflow_cli/resources/commands/devflow.md +37 -1
- {devflow_cli-11.0.1.dist-info → devflow_cli-11.2.0.dist-info}/METADATA +1 -1
- {devflow_cli-11.0.1.dist-info → devflow_cli-11.2.0.dist-info}/RECORD +14 -14
- {devflow_cli-11.0.1.dist-info → devflow_cli-11.2.0.dist-info}/WHEEL +0 -0
- {devflow_cli-11.0.1.dist-info → devflow_cli-11.2.0.dist-info}/entry_points.txt +0 -0
- {devflow_cli-11.0.1.dist-info → devflow_cli-11.2.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
|
|
@@ -66,7 +66,11 @@ VALIDATION_PLAN_ROLE_CONSTRAINT = (
|
|
|
66
66
|
"validationPlan est la liste que verify executera apres implement pour produire "
|
|
67
67
|
"la preuve : y lancer les tests du lot (suite du projet et tests cibles), ne pas "
|
|
68
68
|
"y controler le document produit par cette activite, et n'y mettre aucune "
|
|
69
|
-
"commande vouee a echouer apres implement (par exemple git diff --exit-code)."
|
|
69
|
+
"commande vouee a echouer apres implement (par exemple git diff --exit-code). "
|
|
70
|
+
"verify lance deja, pour chaque module touche, la suite de regression de la CLI "
|
|
71
|
+
"(mvn verify, et le build ou la verification Node) : ne pas repeter ces commandes "
|
|
72
|
+
"dans validationPlan ; une commande repetee quand meme est couverte par la "
|
|
73
|
+
"commande equivalente gardee, sans refus."
|
|
70
74
|
)
|
|
71
75
|
# KKS-554 (D3) : verify refuse un diff que git diff --check signale.
|
|
72
76
|
FILE_ENDING_CONSTRAINT = (
|
|
@@ -11,7 +11,7 @@ import shutil
|
|
|
11
11
|
import tempfile
|
|
12
12
|
from dataclasses import dataclass, replace
|
|
13
13
|
from datetime import datetime, timezone
|
|
14
|
-
from pathlib import Path
|
|
14
|
+
from pathlib import Path, PurePosixPath
|
|
15
15
|
|
|
16
16
|
from devflow_cli.core.adaptive_workflow import (
|
|
17
17
|
AdaptiveWorkflowState,
|
|
@@ -40,6 +40,7 @@ from devflow_cli.core.assessment import read_assessment
|
|
|
40
40
|
from devflow_cli.core.verification import (
|
|
41
41
|
ValidationCommand,
|
|
42
42
|
VerificationResult,
|
|
43
|
+
redact_command,
|
|
43
44
|
run_verifications,
|
|
44
45
|
validate_command_policy,
|
|
45
46
|
)
|
|
@@ -588,15 +589,7 @@ def run_automatic_verification(
|
|
|
588
589
|
return AutomaticVerificationOutcome(
|
|
589
590
|
False, "invalid-preparation-result", str(exc)
|
|
590
591
|
)
|
|
591
|
-
|
|
592
|
-
(tuple(command.args), command.working_directory)
|
|
593
|
-
for command in regression_commands
|
|
594
|
-
}
|
|
595
|
-
regression_commands.extend(
|
|
596
|
-
command
|
|
597
|
-
for command in planned_commands
|
|
598
|
-
if (tuple(command.args), command.working_directory) not in known_commands
|
|
599
|
-
)
|
|
592
|
+
regression_commands.extend(planned_commands)
|
|
600
593
|
if state.profile in {"standard", "deep"} and not regression_commands:
|
|
601
594
|
return AutomaticVerificationOutcome(
|
|
602
595
|
False,
|
|
@@ -694,6 +687,21 @@ def run_automatic_verification(
|
|
|
694
687
|
False, "validation-policy-refused", "; ".join(refusals)
|
|
695
688
|
)
|
|
696
689
|
|
|
690
|
+
# Les gates et la politique ont vu toutes les commandes : seules les gardees s'executent.
|
|
691
|
+
if reuse_targeted_as_regression:
|
|
692
|
+
(regression_commands, security_commands), (
|
|
693
|
+
covered_regression, covered_security
|
|
694
|
+
) = deduplicate_commands(
|
|
695
|
+
[regression_commands, security_commands], planned_prefix
|
|
696
|
+
)
|
|
697
|
+
commands, covered_targeted = regression_commands, []
|
|
698
|
+
else:
|
|
699
|
+
(commands, regression_commands, security_commands), (
|
|
700
|
+
covered_targeted, covered_regression, covered_security
|
|
701
|
+
) = deduplicate_commands(
|
|
702
|
+
[commands, regression_commands, security_commands], planned_prefix
|
|
703
|
+
)
|
|
704
|
+
|
|
697
705
|
before = snapshot_worktree(project_root)
|
|
698
706
|
started_at = _now_iso()
|
|
699
707
|
try:
|
|
@@ -721,16 +729,27 @@ def run_automatic_verification(
|
|
|
721
729
|
break
|
|
722
730
|
return AutomaticVerificationOutcome(False, "validation-policy-refused", detail)
|
|
723
731
|
completed_at = _now_iso()
|
|
724
|
-
|
|
725
|
-
result.
|
|
732
|
+
results_by_id = {
|
|
733
|
+
result.id: result
|
|
734
|
+
for result in [*results, *regression_results, *security_results]
|
|
735
|
+
}
|
|
736
|
+
targeted_keepers = _keeper_results(covered_targeted, results_by_id)
|
|
737
|
+
regression_keepers = _keeper_results(covered_regression, results_by_id)
|
|
738
|
+
security_keepers = _keeper_results(covered_security, results_by_id)
|
|
739
|
+
checks_passed = (
|
|
740
|
+
bool(results) or bool(covered_targeted) or document_batch is not None
|
|
741
|
+
) and all(
|
|
742
|
+
result.succeeded or not result.blocking
|
|
743
|
+
for result in [*results, *targeted_keepers]
|
|
726
744
|
)
|
|
727
745
|
regression_passed = all(
|
|
728
|
-
result.succeeded or not result.blocking
|
|
746
|
+
result.succeeded or not result.blocking
|
|
747
|
+
for result in [*regression_results, *regression_keepers]
|
|
729
748
|
)
|
|
730
749
|
security_findings = _sensitive_execution_findings(security_results)
|
|
731
750
|
security_passed = (
|
|
732
|
-
bool(security_results)
|
|
733
|
-
and all(result.succeeded for result in security_results)
|
|
751
|
+
(bool(security_results) or bool(covered_security))
|
|
752
|
+
and all(result.succeeded for result in [*security_results, *security_keepers])
|
|
734
753
|
and not security_findings
|
|
735
754
|
)
|
|
736
755
|
try:
|
|
@@ -755,6 +774,12 @@ def run_automatic_verification(
|
|
|
755
774
|
if reuse_targeted_as_regression or state.profile != "deep"
|
|
756
775
|
else [*results, *regression_results]
|
|
757
776
|
)
|
|
777
|
+
check_covered = (
|
|
778
|
+
covered_targeted
|
|
779
|
+
if reuse_targeted_as_regression or state.profile != "deep"
|
|
780
|
+
else [*covered_targeted, *covered_regression]
|
|
781
|
+
)
|
|
782
|
+
check_keepers = _keeper_results(check_covered, results_by_id)
|
|
758
783
|
check_passed = (
|
|
759
784
|
checks_passed and regression_passed
|
|
760
785
|
if state.profile == "deep"
|
|
@@ -767,6 +792,7 @@ def run_automatic_verification(
|
|
|
767
792
|
"startedAt": started_at,
|
|
768
793
|
"completedAt": completed_at,
|
|
769
794
|
"commands": [result.to_dict() for result in check_results],
|
|
795
|
+
"coveredCommands": [item.to_dict() for item in check_covered],
|
|
770
796
|
"worktreeMutations": test_mutations,
|
|
771
797
|
"waiversApplied": applied_waivers,
|
|
772
798
|
}
|
|
@@ -784,6 +810,7 @@ def run_automatic_verification(
|
|
|
784
810
|
"startedAt": started_at,
|
|
785
811
|
"completedAt": completed_at,
|
|
786
812
|
"commands": [result.to_dict() for result in regression_results],
|
|
813
|
+
"coveredCommands": [item.to_dict() for item in covered_regression],
|
|
787
814
|
"worktreeMutations": test_mutations,
|
|
788
815
|
"waiversApplied": applied_waivers,
|
|
789
816
|
}
|
|
@@ -802,6 +829,7 @@ def run_automatic_verification(
|
|
|
802
829
|
"startedAt": started_at,
|
|
803
830
|
"completedAt": completed_at,
|
|
804
831
|
"commands": [result.to_dict() for result in security_results],
|
|
832
|
+
"coveredCommands": [item.to_dict() for item in covered_security],
|
|
805
833
|
"executionFindings": security_findings,
|
|
806
834
|
"worktreeMutations": test_mutations,
|
|
807
835
|
"waiversApplied": [],
|
|
@@ -833,22 +861,24 @@ def run_automatic_verification(
|
|
|
833
861
|
|
|
834
862
|
if check_payload["outcome"] != "passed":
|
|
835
863
|
safe_refresh_worklog(feature_dir)
|
|
864
|
+
reported = _with_keepers(check_results, check_keepers)
|
|
836
865
|
failed = [
|
|
837
866
|
result.id
|
|
838
|
-
for result in
|
|
867
|
+
for result in reported
|
|
839
868
|
if result.blocking and not result.succeeded
|
|
840
869
|
]
|
|
841
870
|
detail = ", ".join(failed) or "les tests ont modifie le working tree"
|
|
842
871
|
return AutomaticVerificationOutcome(
|
|
843
872
|
False, f"{targeted_id}-failed", detail,
|
|
844
|
-
failures=_failures(
|
|
873
|
+
failures=_failures(reported),
|
|
845
874
|
)
|
|
846
875
|
if state.profile == "standard" and not regression_passed:
|
|
847
876
|
safe_refresh_worklog(feature_dir)
|
|
848
|
-
|
|
877
|
+
reported = _with_keepers(regression_results, regression_keepers)
|
|
878
|
+
failed = [result.id for result in reported if not result.succeeded]
|
|
849
879
|
return AutomaticVerificationOutcome(
|
|
850
880
|
False, "regression-check-failed", ", ".join(failed),
|
|
851
|
-
failures=_failures(
|
|
881
|
+
failures=_failures(reported),
|
|
852
882
|
)
|
|
853
883
|
if diff_payload["outcome"] != "passed":
|
|
854
884
|
safe_refresh_worklog(feature_dir)
|
|
@@ -864,8 +894,9 @@ def run_automatic_verification(
|
|
|
864
894
|
)
|
|
865
895
|
if security_payload is not None and security_payload["outcome"] != "passed":
|
|
866
896
|
safe_refresh_worklog(feature_dir)
|
|
897
|
+
reported = _with_keepers(security_results, security_keepers)
|
|
867
898
|
failed = [
|
|
868
|
-
result.id for result in
|
|
899
|
+
result.id for result in reported if not result.succeeded
|
|
869
900
|
]
|
|
870
901
|
failed.extend(
|
|
871
902
|
f"{item['commandId']}: {item['finding']}"
|
|
@@ -874,7 +905,7 @@ def run_automatic_verification(
|
|
|
874
905
|
return AutomaticVerificationOutcome(
|
|
875
906
|
False, "security-or-data-check-failed", ", ".join(failed),
|
|
876
907
|
failures=(
|
|
877
|
-
*_failures(
|
|
908
|
+
*_failures(reported),
|
|
878
909
|
*(
|
|
879
910
|
VerificationFailure(item["commandId"], None)
|
|
880
911
|
for item in security_findings
|
|
@@ -962,6 +993,145 @@ def run_automatic_verification(
|
|
|
962
993
|
)
|
|
963
994
|
|
|
964
995
|
|
|
996
|
+
MAVEN_EXECUTABLES = frozenset({"mvn", "./mvnw"})
|
|
997
|
+
|
|
998
|
+
|
|
999
|
+
def normalized_command(command: ValidationCommand) -> tuple[str, tuple[str, ...], str]:
|
|
1000
|
+
"""Forme normalisee (executable, arguments, dossier) qui decide de l'equivalence."""
|
|
1001
|
+
directory = PurePosixPath(command.working_directory or ".")
|
|
1002
|
+
executable, *args = command.args or [""]
|
|
1003
|
+
if executable in MAVEN_EXECUTABLES:
|
|
1004
|
+
kept: list[str] = []
|
|
1005
|
+
project_dir = directory
|
|
1006
|
+
index = 0
|
|
1007
|
+
while index < len(args):
|
|
1008
|
+
arg = args[index]
|
|
1009
|
+
if arg in {"-B", "--batch-mode"}:
|
|
1010
|
+
index += 1
|
|
1011
|
+
continue
|
|
1012
|
+
if arg in {"-f", "--file"} and index + 1 < len(args):
|
|
1013
|
+
pom = PurePosixPath(args[index + 1])
|
|
1014
|
+
if pom.name != "pom.xml":
|
|
1015
|
+
# Un -f vers un autre fichier laisse la commande telle quelle.
|
|
1016
|
+
kept, project_dir = list(args), directory
|
|
1017
|
+
break
|
|
1018
|
+
project_dir = directory / pom.parent
|
|
1019
|
+
index += 2
|
|
1020
|
+
continue
|
|
1021
|
+
kept.append(arg)
|
|
1022
|
+
index += 1
|
|
1023
|
+
args, directory = kept, project_dir
|
|
1024
|
+
elif executable == "npm":
|
|
1025
|
+
kept = []
|
|
1026
|
+
index = 0
|
|
1027
|
+
while index < len(args):
|
|
1028
|
+
if args[index] == "--prefix" and index + 1 < len(args):
|
|
1029
|
+
directory = directory / args[index + 1]
|
|
1030
|
+
index += 2
|
|
1031
|
+
continue
|
|
1032
|
+
kept.append(args[index])
|
|
1033
|
+
index += 1
|
|
1034
|
+
args = kept
|
|
1035
|
+
return executable, tuple(args), PurePosixPath(directory.as_posix()).as_posix()
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
@dataclass(frozen=True)
|
|
1039
|
+
class CoveredCommand:
|
|
1040
|
+
"""Commande ecartee parce qu'une commande equivalente gardee la couvre."""
|
|
1041
|
+
|
|
1042
|
+
command: ValidationCommand
|
|
1043
|
+
coveredBy: str
|
|
1044
|
+
|
|
1045
|
+
@property
|
|
1046
|
+
def blocking(self) -> bool:
|
|
1047
|
+
return self.command.blocking
|
|
1048
|
+
|
|
1049
|
+
def to_dict(self) -> dict:
|
|
1050
|
+
return {
|
|
1051
|
+
"id": self.command.id,
|
|
1052
|
+
"command": redact_command(self.command.args),
|
|
1053
|
+
"workingDirectory": self.command.working_directory,
|
|
1054
|
+
"coveredBy": self.coveredBy,
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
|
|
1058
|
+
def deduplicate_commands(
|
|
1059
|
+
lists: list[list[ValidationCommand]], planned_prefix: str
|
|
1060
|
+
) -> tuple[list[list[ValidationCommand]], list[list[CoveredCommand]]]:
|
|
1061
|
+
"""Garde une commande par forme normalisee sur l'ensemble des listes.
|
|
1062
|
+
|
|
1063
|
+
La derniere liste est celle des controles proteges. Ordre de garde : controle
|
|
1064
|
+
protege, puis commande du plan, puis commande automatique ; a rang egal, la
|
|
1065
|
+
premiere rencontree. Une commande non bloquante ne couvre jamais une bloquante.
|
|
1066
|
+
La commande gardee recoit le delai le plus long des commandes qu'elle couvre.
|
|
1067
|
+
"""
|
|
1068
|
+
protected = len(lists) - 1
|
|
1069
|
+
entries = [
|
|
1070
|
+
(list_index, position, command)
|
|
1071
|
+
for list_index, items in enumerate(lists)
|
|
1072
|
+
for position, command in enumerate(items)
|
|
1073
|
+
]
|
|
1074
|
+
|
|
1075
|
+
def rank(entry: tuple[int, int, ValidationCommand]) -> int:
|
|
1076
|
+
if entry[0] == protected:
|
|
1077
|
+
return 0
|
|
1078
|
+
return 1 if entry[2].id.startswith(f"{planned_prefix}-") else 2
|
|
1079
|
+
|
|
1080
|
+
groups: dict[tuple[str, tuple[str, ...], str], list] = {}
|
|
1081
|
+
for entry in entries:
|
|
1082
|
+
groups.setdefault(normalized_command(entry[2]), []).append(entry)
|
|
1083
|
+
kept: dict[tuple[int, int], ValidationCommand] = {}
|
|
1084
|
+
covered: list[list[CoveredCommand]] = [[] for _ in lists]
|
|
1085
|
+
for members in groups.values():
|
|
1086
|
+
remaining = list(members)
|
|
1087
|
+
while remaining:
|
|
1088
|
+
keeper = min(remaining, key=rank)
|
|
1089
|
+
covers = [
|
|
1090
|
+
entry
|
|
1091
|
+
for entry in remaining
|
|
1092
|
+
if entry is not keeper and (keeper[2].blocking or not entry[2].blocking)
|
|
1093
|
+
]
|
|
1094
|
+
timeout = max(entry[2].timeout for entry in [keeper, *covers])
|
|
1095
|
+
kept[keeper[:2]] = replace(keeper[2], timeout=timeout)
|
|
1096
|
+
for entry in covers:
|
|
1097
|
+
covered[entry[0]].append(CoveredCommand(entry[2], keeper[2].id))
|
|
1098
|
+
remaining = [
|
|
1099
|
+
entry for entry in remaining if entry is not keeper and entry not in covers
|
|
1100
|
+
]
|
|
1101
|
+
kept_lists = [
|
|
1102
|
+
[
|
|
1103
|
+
kept[(list_index, position)]
|
|
1104
|
+
for position in range(len(items))
|
|
1105
|
+
if (list_index, position) in kept
|
|
1106
|
+
]
|
|
1107
|
+
for list_index, items in enumerate(lists)
|
|
1108
|
+
]
|
|
1109
|
+
return kept_lists, covered
|
|
1110
|
+
|
|
1111
|
+
|
|
1112
|
+
def _keeper_results(
|
|
1113
|
+
covered: list[CoveredCommand], results_by_id: dict[str, VerificationResult]
|
|
1114
|
+
) -> list[VerificationResult]:
|
|
1115
|
+
"""Resultat de la commande gardee, porte au caractere bloquant de la commande couverte."""
|
|
1116
|
+
return [
|
|
1117
|
+
replace(results_by_id[item.coveredBy], blocking=item.blocking)
|
|
1118
|
+
for item in covered
|
|
1119
|
+
]
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
def _with_keepers(
|
|
1123
|
+
results: list[VerificationResult], keepers: list[VerificationResult]
|
|
1124
|
+
) -> list[VerificationResult]:
|
|
1125
|
+
"""Resultats d'une liste completes des commandes gardees qui couvrent ses commandes."""
|
|
1126
|
+
seen = {result.id for result in results}
|
|
1127
|
+
merged = list(results)
|
|
1128
|
+
for result in keepers:
|
|
1129
|
+
if result.id not in seen:
|
|
1130
|
+
seen.add(result.id)
|
|
1131
|
+
merged.append(result)
|
|
1132
|
+
return merged
|
|
1133
|
+
|
|
1134
|
+
|
|
965
1135
|
def _failures(results: list[VerificationResult]) -> tuple[VerificationFailure, ...]:
|
|
966
1136
|
return tuple(
|
|
967
1137
|
VerificationFailure(result.id, result.returncode, result.timed_out)
|
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
|
|
devflow_cli/core/worklog.py
CHANGED
|
@@ -335,6 +335,16 @@ def _verification_lines(
|
|
|
335
335
|
lines.append(
|
|
336
336
|
f" - `{rendered}` → code `{command.get('returncode', 'inconnu')}`{qualifier}"
|
|
337
337
|
)
|
|
338
|
+
covered = targeted.get("coveredCommands", []) if targeted else []
|
|
339
|
+
if isinstance(covered, list):
|
|
340
|
+
for item in covered:
|
|
341
|
+
if not isinstance(item, dict):
|
|
342
|
+
continue
|
|
343
|
+
args = item.get("command", [])
|
|
344
|
+
rendered = " ".join(args) if isinstance(args, list) else str(args)
|
|
345
|
+
lines.append(
|
|
346
|
+
f" - `{rendered}` → couverte par `{item.get('coveredBy', 'inconnu')}`"
|
|
347
|
+
)
|
|
338
348
|
findings = inspection.get("findings", []) if inspection else []
|
|
339
349
|
if isinstance(findings, list):
|
|
340
350
|
lines.extend(f" - Constat : {item}" for item in findings if isinstance(item, str))
|
|
@@ -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.0
|
|
3
|
+
Version: 11.2.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=vmkwJEwELUxVwxHeL3_1yFRXX8EvZRhDIH3e4hq60C0,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
|
|
@@ -16,13 +16,13 @@ devflow_cli/commands/status.py,sha256=Votdh_sZkRuC_iui1krrdXE9cZ5dpY2OO2au4PVa7I
|
|
|
16
16
|
devflow_cli/commands/upgrade_cmd.py,sha256=7GYe1T7SWzkDSYW9x1G-Dznw9qwKT2uI1gJUcWr9_2M,6093
|
|
17
17
|
devflow_cli/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
18
|
devflow_cli/core/activity_base.py,sha256=eEC_YIr5O7WhCglA7xAEPypVzhcdC6f2h9d-SDDecVA,20475
|
|
19
|
-
devflow_cli/core/activity_contracts.py,sha256=
|
|
19
|
+
devflow_cli/core/activity_contracts.py,sha256=M1heF8J_oQl7e8zlws_lUEL-nIN0ub4GJQKWoN9XaTk,40581
|
|
20
20
|
devflow_cli/core/adaptive_runner.py,sha256=PuixfWdqpdfIkfUAE10r4S2d1qUZqb5WpA_0P2psvrM,50355
|
|
21
21
|
devflow_cli/core/adaptive_workflow.py,sha256=dCtzURfOSsk_DpdLMwVlGNO4hUXeLH0lUOz29kP64G8,14416
|
|
22
22
|
devflow_cli/core/agent_failure.py,sha256=iX4q249lAHeVdD_ZF1aObmU-FX6sjfYP9dfLSnWGAD0,3771
|
|
23
23
|
devflow_cli/core/agent_run_marker.py,sha256=QW3ScA2ZpqfQdUo5ANTbenDVyY2iHpB_wTaN6VUKlzc,3451
|
|
24
24
|
devflow_cli/core/assessment.py,sha256=ACtJbXq1qZjVfeERjy8Qg6-ioLfSMUBVQm2l-mtGwgI,11522
|
|
25
|
-
devflow_cli/core/automatic_evidence.py,sha256=
|
|
25
|
+
devflow_cli/core/automatic_evidence.py,sha256=u2vpRm072fIkWkSdrlcaz_3GAW7dfr0IXVkCUEHYnAs,50747
|
|
26
26
|
devflow_cli/core/contract_schemas.py,sha256=CWzaDbJEbe9KjqJG2r-u3KNsAlHnI5NxdA0yf05FRyU,9670
|
|
27
27
|
devflow_cli/core/decisions.py,sha256=tFYKNDaztMvnhLfVGJKIux5zaSjEPx2nwXs5nb2qv4U,6308
|
|
28
28
|
devflow_cli/core/docgen.py,sha256=47JoVDWetkcctgHwJZC67AVebOKgl10VB9hZ3Xr63mo,3908
|
|
@@ -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
|
|
@@ -43,8 +43,8 @@ devflow_cli/core/validation_approvals.py,sha256=3AHOpnW3BtY3BQrRZr38K7VNYRvbxGNh
|
|
|
43
43
|
devflow_cli/core/validators.py,sha256=HKGG1-td5T8cFx3rbE0iWPtddolk73qsqYreVWVT07g,7081
|
|
44
44
|
devflow_cli/core/verification.py,sha256=3_iGhsXNFCs5cpBUyBCRTsmRsfuBAVa38lRgy-LXXww,20349
|
|
45
45
|
devflow_cli/core/waivers.py,sha256=0w38Osjr69mDT6Lsn0ljkaq6bbggVejuhqiOnYHabs4,5586
|
|
46
|
-
devflow_cli/core/worklog.py,sha256=
|
|
47
|
-
devflow_cli/core/worktree_snapshot.py,sha256=
|
|
46
|
+
devflow_cli/core/worklog.py,sha256=WPvK0D8b0DBOmnjEoKVum8_EtYR3DjTz7e2p9bulFzk,17577
|
|
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.0.
|
|
62
|
-
devflow_cli-11.0.
|
|
63
|
-
devflow_cli-11.0.
|
|
64
|
-
devflow_cli-11.0.
|
|
65
|
-
devflow_cli-11.0.
|
|
61
|
+
devflow_cli-11.2.0.dist-info/METADATA,sha256=njgOU2tWroX-ADG5LZPjM-iEhS2TY5ON65aQJ0tfFLQ,6674
|
|
62
|
+
devflow_cli-11.2.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
63
|
+
devflow_cli-11.2.0.dist-info/entry_points.txt,sha256=GVJ6bMvFpqyO5589iC4nFKeGTpGIW8aKn_QPPpSZ6kU,48
|
|
64
|
+
devflow_cli-11.2.0.dist-info/licenses/LICENSE,sha256=v79PvnmqOdKhQiOa_QcWxng4q8GuGscLOwi7ygUpwpo,1070
|
|
65
|
+
devflow_cli-11.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|