ww-agentic-workflows 1.0.0.dev8__py3-none-any.whl → 1.0.0.dev9__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.
- ww/_bundled_extensions/ww/git/extension.py +27 -11
- ww/action_execution.py +24 -0
- ww/actions/contracts.py +16 -0
- ww/actions/extension.py +11 -0
- ww/assets/docs/features.md +79 -28
- ww/assets/docs/specification.md +5 -4
- ww/assets/ww-rule_skill.md +13 -8
- ww/cli/main.py +3 -6
- ww/cli/parser.py +10 -1
- ww/completion_inputs.py +7 -2
- ww/config_writes.py +123 -31
- ww/execution_models/plan_codec.py +1 -0
- ww/execution_models/records.py +1 -0
- ww/extensions/api.py +9 -0
- ww/instructions/builder.py +47 -9
- ww/instructions/handoff.py +22 -1
- ww/instructions/models.py +12 -3
- ww/output_adapters/markdown.py +40 -10
- ww/output_adapters/rule_pages.py +24 -1
- ww/plan/actions.py +6 -1
- ww/plan/compiler.py +3 -12
- ww/rule_views.py +100 -4
- ww/rule_writes.py +132 -57
- ww/service.py +27 -5
- ww/transitions.py +9 -2
- ww/workflow_config.py +31 -2
- ww/workflow_validation.py +5 -22
- {ww_agentic_workflows-1.0.0.dev8.dist-info → ww_agentic_workflows-1.0.0.dev9.dist-info}/METADATA +1 -1
- {ww_agentic_workflows-1.0.0.dev8.dist-info → ww_agentic_workflows-1.0.0.dev9.dist-info}/RECORD +32 -32
- {ww_agentic_workflows-1.0.0.dev8.dist-info → ww_agentic_workflows-1.0.0.dev9.dist-info}/WHEEL +0 -0
- {ww_agentic_workflows-1.0.0.dev8.dist-info → ww_agentic_workflows-1.0.0.dev9.dist-info}/entry_points.txt +0 -0
- {ww_agentic_workflows-1.0.0.dev8.dist-info → ww_agentic_workflows-1.0.0.dev9.dist-info}/licenses/LICENSE +0 -0
|
@@ -400,18 +400,31 @@ def _status_paths(output: str) -> tuple[str, ...]:
|
|
|
400
400
|
return tuple(paths)
|
|
401
401
|
|
|
402
402
|
|
|
403
|
-
def
|
|
403
|
+
def _workspace_status(
|
|
404
|
+
context: ExtensionContext,
|
|
405
|
+
) -> tuple[tuple[str, ...], str | None]:
|
|
406
|
+
"""The paths Git reports changed in the task workspace, or why it cannot."""
|
|
404
407
|
root, error = _workspace_root(context)
|
|
405
408
|
if error:
|
|
406
|
-
return error
|
|
409
|
+
return (), error
|
|
407
410
|
assert root is not None
|
|
408
411
|
status = _git(context, "status", "--porcelain=v1", "-z", "--untracked-files=all")
|
|
409
412
|
if status.returncode:
|
|
410
|
-
return _failed(status, "git status failed")
|
|
413
|
+
return (), _failed(status, "git status failed")
|
|
411
414
|
paths = _status_paths(status.stdout)
|
|
412
415
|
if status.stdout and not paths:
|
|
413
|
-
return "Git reported malformed status output"
|
|
414
|
-
return _paths_inside(root, paths)
|
|
416
|
+
return (), "Git reported malformed status output"
|
|
417
|
+
return paths, _paths_inside(root, paths)
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
def _validate_commit_workspace(context: ExtensionContext) -> str | None:
|
|
421
|
+
return _workspace_status(context)[1]
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
def _needs_commit_message(context: ExtensionContext) -> bool:
|
|
425
|
+
"""Whether the workspace has anything to commit; Git trouble asks as usual."""
|
|
426
|
+
paths, error = _workspace_status(context)
|
|
427
|
+
return bool(paths) or error is not None
|
|
415
428
|
|
|
416
429
|
|
|
417
430
|
def _validate_staged_paths(context: ExtensionContext) -> str | None:
|
|
@@ -799,12 +812,6 @@ def _commit_message_error(values: Mapping[str, str]) -> str | None:
|
|
|
799
812
|
|
|
800
813
|
def _commit(context: ExtensionContext) -> ExtensionResult:
|
|
801
814
|
settings = _task_settings(context)
|
|
802
|
-
error = _commit_message_error(context.values)
|
|
803
|
-
if error is not None:
|
|
804
|
-
return ExtensionResult(False, error=error)
|
|
805
|
-
subject = _subject(context, settings, context.values["commit_message"])
|
|
806
|
-
if not subject:
|
|
807
|
-
return ExtensionResult(False, error="commit_format rendered an empty message")
|
|
808
815
|
# A retry may arrive after git committed but before ww recorded the
|
|
809
816
|
# result. The operation trailer gives the checker a durable identity.
|
|
810
817
|
if context.operation_id:
|
|
@@ -840,6 +847,14 @@ def _commit(context: ExtensionContext) -> ExtensionResult:
|
|
|
840
847
|
False,
|
|
841
848
|
error=_failed(has_staged_changes, "could not inspect staged changes"),
|
|
842
849
|
)
|
|
850
|
+
# Only a commit needs its message: the precondition lets ww run this
|
|
851
|
+
# without asking for one when the workspace is clean.
|
|
852
|
+
error = _commit_message_error(context.values)
|
|
853
|
+
if error is not None:
|
|
854
|
+
return ExtensionResult(False, error=error)
|
|
855
|
+
subject = _subject(context, settings, context.values["commit_message"])
|
|
856
|
+
if not subject:
|
|
857
|
+
return ExtensionResult(False, error="commit_format rendered an empty message")
|
|
843
858
|
commit_args = ["commit", "-m", subject]
|
|
844
859
|
if context.operation_id:
|
|
845
860
|
commit_args.extend(["-m", _operation_marker(context)])
|
|
@@ -1692,6 +1707,7 @@ EXTENSION = Extension(
|
|
|
1692
1707
|
),
|
|
1693
1708
|
check=_check_commit,
|
|
1694
1709
|
validate=_commit_message_error,
|
|
1710
|
+
needs_input=_needs_commit_message,
|
|
1695
1711
|
),
|
|
1696
1712
|
ExtensionHandler(
|
|
1697
1713
|
"merge-branch",
|
ww/action_execution.py
CHANGED
|
@@ -339,6 +339,13 @@ class _InputValidationContext:
|
|
|
339
339
|
extensions: _HandlerLookup
|
|
340
340
|
|
|
341
341
|
|
|
342
|
+
@dataclass(frozen=True)
|
|
343
|
+
class _PreconditionContext:
|
|
344
|
+
"""Handler access and the handler's own context; nothing is recorded."""
|
|
345
|
+
|
|
346
|
+
extensions: _ExtensionService
|
|
347
|
+
|
|
348
|
+
|
|
342
349
|
class _PreflightExtensions:
|
|
343
350
|
def __init__(self, executor: ActionExecutor) -> None:
|
|
344
351
|
self._executor = executor
|
|
@@ -722,6 +729,23 @@ class ActionExecutor:
|
|
|
722
729
|
_InputValidationContext(_HandlerLookup(self)),
|
|
723
730
|
)
|
|
724
731
|
|
|
732
|
+
def needs_input(
|
|
733
|
+
self, state: ExecutionState, snapshot: PlanSnapshot, item: PlanItem
|
|
734
|
+
) -> bool:
|
|
735
|
+
"""Whether the current automatic item must get its inputs before it runs.
|
|
736
|
+
|
|
737
|
+
Asked while they are missing and before anything is recorded; an
|
|
738
|
+
action without a precondition always needs them.
|
|
739
|
+
"""
|
|
740
|
+
implementation = actions.get(item.kind)
|
|
741
|
+
if not isinstance(implementation, AutomaticAction):
|
|
742
|
+
return True
|
|
743
|
+
dispatch = _Dispatch(self, state, snapshot, item)
|
|
744
|
+
return implementation.needs_input(
|
|
745
|
+
item.payload_as(implementation.planned_type),
|
|
746
|
+
_PreconditionContext(_ExtensionService(dispatch)),
|
|
747
|
+
)
|
|
748
|
+
|
|
725
749
|
def check_recovery(
|
|
726
750
|
self, state: ExecutionState, plan: WorkflowPlan, item: PlanItem
|
|
727
751
|
) -> RecoveryCheckResult | None:
|
ww/actions/contracts.py
CHANGED
|
@@ -529,6 +529,13 @@ class InputValidationContext(Protocol):
|
|
|
529
529
|
def extensions(self) -> ExtensionHandlerService: ...
|
|
530
530
|
|
|
531
531
|
|
|
532
|
+
class PreconditionContext(Protocol):
|
|
533
|
+
"""What an action may consult to tell whether it needs its inputs."""
|
|
534
|
+
|
|
535
|
+
@property
|
|
536
|
+
def extensions(self) -> ExtensionService: ...
|
|
537
|
+
|
|
538
|
+
|
|
532
539
|
class ExecutionContext(Protocol):
|
|
533
540
|
"""Read-only invocation information plus deliberately narrow effects."""
|
|
534
541
|
|
|
@@ -634,6 +641,15 @@ class AutomaticAction(Action[DefinitionT, PlannedT]):
|
|
|
634
641
|
del planned, values, context
|
|
635
642
|
return None
|
|
636
643
|
|
|
644
|
+
def needs_input(self, planned: PlannedT, context: PreconditionContext) -> bool:
|
|
645
|
+
"""Whether the action needs its declared inputs this run.
|
|
646
|
+
|
|
647
|
+
Core asks while they are missing and nothing is recorded; ``False``
|
|
648
|
+
runs the action without requesting them.
|
|
649
|
+
"""
|
|
650
|
+
del planned, context
|
|
651
|
+
return True
|
|
652
|
+
|
|
637
653
|
def check_recovery(
|
|
638
654
|
self, planned: PlannedT, context: RecoveryContext
|
|
639
655
|
) -> RecoveryCheckResult | None:
|
ww/actions/extension.py
CHANGED
|
@@ -31,6 +31,7 @@ from .contracts import (
|
|
|
31
31
|
InputValidationContext,
|
|
32
32
|
InstructionContent,
|
|
33
33
|
InstructionContext,
|
|
34
|
+
PreconditionContext,
|
|
34
35
|
PreflightContext,
|
|
35
36
|
RecoveryCheckResult,
|
|
36
37
|
RecoveryContext,
|
|
@@ -70,6 +71,16 @@ class ExtensionAction(AutomaticAction[Extension, Extension]):
|
|
|
70
71
|
return "extension validator returned an invalid result"
|
|
71
72
|
return verdict.strip()
|
|
72
73
|
|
|
74
|
+
def needs_input(self, planned: Extension, context: PreconditionContext) -> bool:
|
|
75
|
+
"""Ask the handler's precondition; one that fails needs the inputs."""
|
|
76
|
+
handler = context.extensions.handler(planned.reference)
|
|
77
|
+
if handler.needs_input is None:
|
|
78
|
+
return True
|
|
79
|
+
try:
|
|
80
|
+
return handler.needs_input(context.extensions.context(planned)) is not False
|
|
81
|
+
except Exception: # noqa: BLE001 - a failing precondition asks as usual
|
|
82
|
+
return True
|
|
83
|
+
|
|
73
84
|
def execute(self, planned: Extension, context: ExecutionContext) -> ActionResult:
|
|
74
85
|
handler = context.extensions.handler(planned.reference)
|
|
75
86
|
try:
|
ww/assets/docs/features.md
CHANGED
|
@@ -1366,13 +1366,16 @@ Direct branches and `outcomes` cannot be combined; use `outcomes` for custom
|
|
|
1366
1366
|
labels.
|
|
1367
1367
|
|
|
1368
1368
|
The agent sees the choice before it answers: the assessment's page lists each
|
|
1369
|
-
outcome and what it does, for example "`negative` — ends the workflow here"
|
|
1369
|
+
outcome and what it does, for example "`negative` — ends the workflow here",
|
|
1370
|
+
and says that once the step is complete the manager records the outcome with
|
|
1371
|
+
`next --outcome <label>`.
|
|
1370
1372
|
Once the assessment is complete, the next page asks for the outcome and shows
|
|
1371
|
-
one `next --outcome <label>` command per outcome
|
|
1372
|
-
|
|
1373
|
-
outcome is chosen; ww pauses at a pending assessment rather than
|
|
1374
|
-
branch. A delegating manager chooses it itself; no worker preview
|
|
1375
|
-
shown until the outcome decides which work comes next
|
|
1373
|
+
one `next --outcome <label>` command per outcome; a plain `next` runs nothing
|
|
1374
|
+
and shows that choice again. An outcome made of an automatic command runs only
|
|
1375
|
+
after its outcome is chosen; ww pauses at a pending assessment rather than
|
|
1376
|
+
running any branch. A delegating manager chooses it itself; no worker preview
|
|
1377
|
+
is shown until the outcome decides which work comes next, and the worker's
|
|
1378
|
+
handoff block ends with the same one command per outcome.
|
|
1376
1379
|
|
|
1377
1380
|
`profile` may be a name or a mapping containing `name` and/or `description`.
|
|
1378
1381
|
The mapping form supplies an inline description. ww resolves a named profile by
|
|
@@ -1537,14 +1540,16 @@ manager continues. `awaiting_operator` means a human must decide; see
|
|
|
1537
1540
|
At handoff only the manager runs the displayed `next --role manager` command.
|
|
1538
1541
|
In the `auto` runtime the manager's delegate page and the requested worker
|
|
1539
1542
|
describe the step that drives selection, not whichever hook the cursor is on,
|
|
1540
|
-
and both the manager and the worker are told every item the assignment covers
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1543
|
+
and both the manager and the worker are told every item the assignment covers,
|
|
1544
|
+
in plan order, the ones ww runs itself marked: `This assignment covers, in
|
|
1545
|
+
order: `develop`, `git-push` (run by `ww`), `update-workflow-summary`.` while
|
|
1546
|
+
nothing is done, then, once some of them are completed, `Already completed in
|
|
1547
|
+
this assignment: ... Remaining, in order: ...`, derived from the items'
|
|
1548
|
+
execution status rather than from the assignment's first item. The line is
|
|
1549
|
+
omitted when one item or none remains; while it is shown and ww is running an
|
|
1550
|
+
automatic item of the assignment, a commit hook or a push, it names it: `` `ww`
|
|
1551
|
+
is now running `git-push`. `` The previous manager page's "Upcoming
|
|
1552
|
+
assignment" preview lists the same items.
|
|
1548
1553
|
A worker moving to a later item of the same assignment is told so explicitly,
|
|
1549
1554
|
and the end of an assignment says to stop and return to the manager.
|
|
1550
1555
|
|
|
@@ -1555,9 +1560,11 @@ the `awaiting_input` instruction is addressed to the manager, its command
|
|
|
1555
1560
|
carries `--role manager`, and the preview before it says that no worker is
|
|
1556
1561
|
selected. Every pending-input page also lists, under "Work these values
|
|
1557
1562
|
describe", the handovers of the steps completed since that handler last ran
|
|
1558
|
-
in the run, so a commit message names this
|
|
1559
|
-
|
|
1560
|
-
|
|
1563
|
+
in the run, through any of its placements, so a commit message names this
|
|
1564
|
+
round's work rather than repeating an earlier one; a run that found nothing to
|
|
1565
|
+
commit does not count as one. The first page of each session shows the
|
|
1566
|
+
requirements saved by `init` in full under "Task requirements", so the user's
|
|
1567
|
+
wording reaches the worker
|
|
1561
1568
|
without the manager adding commentary: the manager's first page that asks for
|
|
1562
1569
|
work, the first page of every delegated worker assignment (each is a fresh
|
|
1563
1570
|
session; `pages.worker_requirements` in `ww.json` set to `pointer` swaps it for
|
|
@@ -1699,7 +1706,9 @@ Manager: continue with `./ww next TASK-7 --role manager`
|
|
|
1699
1706
|
When the block ends a child task's run (the task ID has a `/` and no run of it
|
|
1700
1707
|
is open any more), the last line names the parent instead: "Manager: continue
|
|
1701
1708
|
with the parent task: `./ww next TASK-7 --role manager`". A child that is only
|
|
1702
|
-
partway through its run keeps its own command.
|
|
1709
|
+
partway through its run keeps its own command. When the assignment ended with
|
|
1710
|
+
an assessment, the last line instead asks the manager to choose its outcome
|
|
1711
|
+
and lists one `next --outcome <label>` command per outcome.
|
|
1703
1712
|
|
|
1704
1713
|
It lists every agent item the worker performed in the assignment with its
|
|
1705
1714
|
outcome (`completed`, `loop break`, `loop continue`, `held for verification`,
|
|
@@ -2389,8 +2398,13 @@ the missing file.
|
|
|
2389
2398
|
froze it: its full text, globs, rule file, command, and the steps that carry
|
|
2390
2399
|
it, and for a rule without a command what the store knows about its wording.
|
|
2391
2400
|
`ww rules` lists the project's declared groups, with their filters and each
|
|
2392
|
-
rule's ID and first sentence,
|
|
2393
|
-
|
|
2401
|
+
rule's ID and first sentence, each step's own rules, and then every
|
|
2402
|
+
workflow's steps as a `steps` filter can name them: one line per step with
|
|
2403
|
+
its path, which reaches exactly that step where a leaf name would match it
|
|
2404
|
+
everywhere (loop bodies and per-item stages included), the groups reaching
|
|
2405
|
+
it, or that it is not an agent step and takes no rules. `--json` gives the
|
|
2406
|
+
same for a program, the steps as `targets` with `workflow`, `step`, `path`,
|
|
2407
|
+
`agent_owned` and `groups`. `ww rules prune` deletes store entries no declared rule
|
|
2394
2408
|
needs any more, after listing them and asking; `--yes` skips the question.
|
|
2395
2409
|
`ww rules revoke <check>` rejects a converted or proposed check and its rules
|
|
2396
2410
|
the same way.
|
|
@@ -2399,8 +2413,8 @@ the same way.
|
|
|
2399
2413
|
|
|
2400
2414
|
Rules are easiest to add in conversation. Invoked as `/ww-rule`, or when you
|
|
2401
2415
|
ask an agent to add or change a rule, the `ww-rule` skill carries the
|
|
2402
|
-
judgment: it reads the groups
|
|
2403
|
-
|
|
2416
|
+
judgment: it reads the groups and the real workflow and step names from
|
|
2417
|
+
`ww rules --json`, splits what you said into atomic obligations,
|
|
2404
2418
|
tells a new rule from an amendment of an existing one or a change of where a
|
|
2405
2419
|
group applies, gives a rule globs only when it names a kind of file and
|
|
2406
2420
|
counts what each matches, places it in a group whose filters fit, and
|
|
@@ -2437,6 +2451,13 @@ Reaches these steps (an agent step's page shows it):
|
|
|
2437
2451
|
sentence unless `--id` names it, with `--paths` globs, `--contains` strings
|
|
2438
2452
|
(it reports how many files hold each) and a check from `--check-shell` or
|
|
2439
2453
|
`--check-argv` and `--assert empty|eq:<value>`. It never overwrites a file.
|
|
2454
|
+
A group that lists its rule files one by one instead of a directory gets
|
|
2455
|
+
the file beside its last one, or in `--dir <path>`, and the file's path
|
|
2456
|
+
appended to its `rules` list: `ww-rules.yaml` is rewritten whole; `ww.yaml`
|
|
2457
|
+
or another file of yours gains that one line, checked to change nothing
|
|
2458
|
+
else, and the command refuses with the line to add by hand when the list is
|
|
2459
|
+
written in a way it cannot extend (flow style, an anchor). A group that
|
|
2460
|
+
names only other groups needs `--dir`.
|
|
2440
2461
|
- `rules add --group <name> --dir <path>` adds a root group, with optional
|
|
2441
2462
|
`--workflows` and `--steps` filters. ww never rewrites
|
|
2442
2463
|
`ww.yaml`: the group goes into `ww-rules.yaml` next to
|
|
@@ -2448,7 +2469,9 @@ Reaches these steps (an agent step's page shows it):
|
|
|
2448
2469
|
and, when the old wording had an approved check, that `rules promote` keeps
|
|
2449
2470
|
it.
|
|
2450
2471
|
- `rules move <id> <group>` moves the file, unchanged, into another group's
|
|
2451
|
-
directory
|
|
2472
|
+
directory, or beside the last file of a group that lists files and into its
|
|
2473
|
+
`rules` list as `rules add` does; its wording, and so what the store knows
|
|
2474
|
+
about it, stays.
|
|
2452
2475
|
- `rules filter <group> --workflows ... --steps ...` changes where a group of
|
|
2453
2476
|
`ww-rules.yaml` applies (`--workflows '*'` writes `"*"`; `--all-workflows` and
|
|
2454
2477
|
`--all-steps` remove a filter, which also means all); a group declared
|
|
@@ -2551,7 +2574,11 @@ review loop or one that is a step of its own, therefore requests it afresh
|
|
|
2551
2574
|
(`awaiting_input`) instead of running silently with the message an earlier
|
|
2552
2575
|
step supplied. A failed handler releases its values the same way when it is
|
|
2553
2576
|
retried, keeping them on its record so the request can show what it was given
|
|
2554
|
-
last time.
|
|
2577
|
+
last time. A handler with a precondition asks only when it needs the value:
|
|
2578
|
+
`git-commit` needs no message while the task workspace has nothing to commit,
|
|
2579
|
+
so such a value is optional on the step's completion (the page says so), and
|
|
2580
|
+
when it is left out ww asks for it only if the workspace changed; a clean one
|
|
2581
|
+
commits nothing without a question.
|
|
2555
2582
|
|
|
2556
2583
|
When several automatic completion hooks request the same variable with the
|
|
2557
2584
|
same description, ww asks for it once and gives that value to each hook.
|
|
@@ -2787,7 +2814,12 @@ holds the conversation, the manager in the `auto` runtime: it is a
|
|
|
2787
2814
|
`role: manager` step, and the step's profile, agent, model, and reasoning
|
|
2788
2815
|
are ignored. For a manual-testing workflow, put `interactive: true` on the
|
|
2789
2816
|
per-item stage: the manager presents each test case, waits for the operator's
|
|
2790
|
-
result, records it, ends the interaction, and completes the item.
|
|
2817
|
+
result, records it, ends the interaction, and completes the item. Running
|
|
2818
|
+
`next` again while such a step is open shows its page again, as it does for
|
|
2819
|
+
any open step in the `single` runtime; `complete` is not the way to leave an
|
|
2820
|
+
interactive step before the conversation ended. Only a worker's open item is
|
|
2821
|
+
refused, and the refusal names the ways out: `instruction` to see its page,
|
|
2822
|
+
`complete` to finish it, `next --reassign` to dispatch it again.
|
|
2791
2823
|
|
|
2792
2824
|
A conversation is recorded once, when it ends. A session that ends in the
|
|
2793
2825
|
middle of one has not recorded it, and ww does not recover it from the
|
|
@@ -3674,8 +3706,10 @@ An extension handler runs inside ww rather than as a shell command, so it can
|
|
|
3674
3706
|
remember what it did. `ww/git`'s `git-commit` commits and then records the
|
|
3675
3707
|
commit, and `commits` reads that back. It stages the task workspace first; when
|
|
3676
3708
|
nothing is staged, for example after a review round that needed no fix, it
|
|
3677
|
-
succeeds without a commit
|
|
3678
|
-
Husky or lint-staged
|
|
3709
|
+
succeeds without a commit, without a `commit_message`, and without invoking
|
|
3710
|
+
project pre-commit hooks such as Husky or lint-staged. Its precondition tells
|
|
3711
|
+
ww whether the workspace has anything to commit, so a clean one is committed
|
|
3712
|
+
without asking for a message at all:
|
|
3679
3713
|
|
|
3680
3714
|
```console
|
|
3681
3715
|
ww-agentic-workflows extensions # what is installed, and what it provides
|
|
@@ -3989,6 +4023,16 @@ workspace, and no effects, and it does not replace the check the handler makes
|
|
|
3989
4023
|
when it runs: `ww/git` declares one for `commit_message` and still checks the
|
|
3990
4024
|
same rule in `git-commit`.
|
|
3991
4025
|
|
|
4026
|
+
Such a handler may also declare `needs_input`, a precondition: whether the
|
|
4027
|
+
handler needs its declared inputs this run; `False` lets ww run it without
|
|
4028
|
+
asking. ww consults it, with the handler's ordinary context, when the inputs
|
|
4029
|
+
are missing: the values of a handler with a precondition are optional on the
|
|
4030
|
+
agent's completion, and when they are left out ww asks for them only if the
|
|
4031
|
+
precondition says they are needed (a precondition that raises counts as
|
|
4032
|
+
needing them). The handler must then accept running without them: `ww/git`'s
|
|
4033
|
+
`git-commit` needs its message only while the task workspace has something
|
|
4034
|
+
to commit, and commits nothing without one otherwise.
|
|
4035
|
+
|
|
3992
4036
|
```python
|
|
3993
4037
|
def _subject_error(values):
|
|
3994
4038
|
if "\n" in values.get("commit_message", ""):
|
|
@@ -3996,11 +4040,16 @@ def _subject_error(values):
|
|
|
3996
4040
|
return None
|
|
3997
4041
|
|
|
3998
4042
|
|
|
4043
|
+
def _needs_commit_message(context):
|
|
4044
|
+
return bool(_git(context, "status", "--porcelain").stdout)
|
|
4045
|
+
|
|
4046
|
+
|
|
3999
4047
|
ExtensionHandler(
|
|
4000
4048
|
"git-commit",
|
|
4001
4049
|
_commit,
|
|
4002
4050
|
provide=(ProvidedVariable("commit_message"),),
|
|
4003
4051
|
validate=_subject_error,
|
|
4052
|
+
needs_input=_needs_commit_message,
|
|
4004
4053
|
)
|
|
4005
4054
|
```
|
|
4006
4055
|
|
|
@@ -4177,7 +4226,9 @@ anything is saved, ww hands each value to the handler that will consume it:
|
|
|
4177
4226
|
a handler that declares a validator, such as `ww/git`'s `git-commit` for
|
|
4178
4227
|
`commit_message`, refuses a value it would fail on, and the completion fails
|
|
4179
4228
|
with the handler's own message and records nothing, so the agent corrects the
|
|
4180
|
-
value and completes again.
|
|
4229
|
+
value and completes again. A value whose handler has a precondition is
|
|
4230
|
+
optional, and the screen says so: left out, it is requested later only when
|
|
4231
|
+
the handler needs it, as `git-commit` does only with something to commit. `ww` then
|
|
4181
4232
|
executes those handlers itself before it activates the next worker item or
|
|
4182
4233
|
returns control to the manager. If an automatic command fails, the worker stops
|
|
4183
4234
|
and reports the failure to the manager. The response reports
|
ww/assets/docs/specification.md
CHANGED
|
@@ -1907,15 +1907,15 @@ or `schema_version` is an error.
|
|
|
1907
1907
|
| `check <task> [--json]` | Runs the checks of the step in progress against its change set so far, exactly as `complete` would, and prints the failures in the fix page's shape, or `All checks pass`, plus the rules a verifier judges at completion. Records nothing: no attempt counts and no output is kept. Exits 1 when a check fails. Not written to the audit log. |
|
|
1908
1908
|
| `dispute <task> --rule <id> --reason "<why>"` | Only while the step is in progress, and only for an ID a rejected completion of it failed: a rule, a `fix` hook, a derived check, or a judged rule. Stops the task with `operator_reason: check_disputed`; the page shows the check's text, command, and last output, and the worker's reason. |
|
|
1909
1909
|
| `rule <task> <id> [--json]` | One rule or check of the task as its plan froze it: full text, globs, rule file (or the step's own list), command and assertion, `max_fixes`, the steps of the task that carry it, and for a rule without a command what the rule-automation store knows about its wording. |
|
|
1910
|
-
| `rules [--json]` | The declared root groups with their filters, verifier hints, and rules (ID, summary, globs, whether it has a check, file, times disputed), then each step's own rules and the groups it names. |
|
|
1910
|
+
| `rules [--json]` | The declared root groups with their filters, verifier hints, and rules (ID, summary, globs, whether it has a check, file, times disputed), then each step's own rules and the groups it names, then the `targets`: every workflow's steps in tree order, `init` left out, each with its leaf `step` name, its logical `path` (the precise `steps` selector; loop bodies, nested steps, per-item and per-child stages take their parent's path as a prefix), whether it is `agent_owned` (a loop or nested sequence only holds its steps; an extension or ww-owned action takes no rules), and the `groups` reaching it now, by filter or by name, empty for a step that is not an agent's. |
|
|
1911
1911
|
| `rules revoke <check> [--reason "<why>"] [--yes] [--json]` | Shows a `converted` or `proposed` store check, asks, and rejects it, recording the reason, together with the rules whose entries name it, which a verifier judges from then on. Never touches YAML, rule files, or the check's config files; the output says they stay for the operator. `--yes` skips the question; without it and without a terminal, it refuses. |
|
|
1912
1912
|
| `rules convert <check> --covers <rule-id>... [--assert empty\|equals:<value>]... [--config <path>...] [--proven] [--dry-run] [--yes] [--json] (--check-shell "<sh>" \| --check-argv <arg>... \| --check-argv -- <arg>...)` | `--check-argv -- <arg>...` goes last and takes every argument after `--` as the argv, options starting with `-` included. Shows the check, its command in full, its config files, the rules it covers with each one's current store state, and every other change, asks, and records it in the store as `converted`, approved by the operator. A new name creates the check; an existing one has its command, config, proof and coverage replaced and any pending revision dropped. A covered rule another check covered moves to this one, and that check loses any pending revision and is removed once it covers nothing more. A rule this check covered before and no longer does returns to unscriptized (its entry is removed); a rejection or decline naming the check stays. `--config` paths are relative to the project and refused when absolute or with a `..` part. Refuses an unknown or repeated rule ID and a rule with a command of its own. `--dry-run` prints the preview and records nothing. `--json` gives the check, its rules, and the `unscriptized`, `moved`, `dropped_checks` and `dropped_revisions` changes. |
|
|
1913
1913
|
| `rules decline <rule-id>... --reason "<why>" [--dry-run] [--yes] [--json]` | Shows the rules with each one's current store state and every other change, asks, and records them as `not_convertible` with the reason, removing them from any check's coverage (a check left covering nothing is removed): a verifier judges them, and `ww-scriptize-rules` leaves them out. `--json` gives the rules and the same changes as `rules convert`. |
|
|
1914
1914
|
| `rules prune [--yes] [--json]` | Lists the store's orphans, rule entries whose wording no declared rule has and checks that cover only such rules and that no remaining rule names, asks, and deletes them. `--yes` skips the question. |
|
|
1915
|
-
| `rules add <group> --text "<text>" [--paths <glob>...] [--contains <text>...] [--assert empty\|equals:<value>]... [--id <stem>] [--check-shell "<sh>" \| --check-argv <arg>... \| --check-argv -- <arg>...]` | `--check-argv -- <arg>...` goes last, as for `rules convert`. Creates `<stem>.md` in the group's first directory item; the stem is the first five words of the first sentence in kebab-case unless `--id` gives one. Refuses an existing file, a group
|
|
1915
|
+
| `rules add <group> --text "<text>" [--paths <glob>...] [--contains <text>...] [--assert empty\|equals:<value>]... [--id <stem>] [--check-shell "<sh>" \| --check-argv <arg>... \| --check-argv -- <arg>...]` | `--check-argv -- <arg>...` goes last, as for `rules convert`. Creates `<stem>.md` in `--dir <path>`, else in the group's first directory item, else beside the group's last file item; the stem is the first five words of the first sentence in kebab-case unless `--id` gives one. A file no listed directory holds is appended to the group's `rules` list, relative to the declaring file as its other entries are: in `ww-rules.yaml` by rewriting the file whole, in any other file as one added line, checked to change nothing else and refused, naming the line to add by hand, when the list cannot be extended that way (a flow list, an anchor, a tag). Refuses an existing file, a group that lists neither a directory nor a file when `--dir` is absent, and a group an extension ships. Reports each glob's match count, and the number of project files containing each `--contains` string, and warns about one found nowhere. `--assert` is repeatable, one condition each. |
|
|
1916
1916
|
| `rules add --group <name> --dir <path> [--workflows <name>...] [--steps <name>...]` | `<path>` is relative to the project root and inside it. Adds the group `{rules: [<path>/], workflows, steps}` to `ww-rules.yaml` and, the first time, `ww-rules.yaml` to the repo file's `imports`; creates the directory. A filter option without a name writes `[]`; `'*'` alone writes `"*"`. |
|
|
1917
1917
|
| `rules edit <id> [--text "<text>"] [--paths <glob>...] [--contains <text>...]` | Replaces a rule file's body, its `paths`, its `contains`, or any of them, keeping every other byte, and reports matches as `rules add` does; warns when the wording's hash changes and names the store entry and approved check that stop matching. Refuses a rule written in a step's `rules` list. |
|
|
1918
|
-
| `rules move <id> <group>` | Moves the rule file unchanged into the group's first directory; the rule's ID becomes `<group>/<stem>`. |
|
|
1918
|
+
| `rules move <id> <group>` | Moves the rule file unchanged into the group's first directory, or beside the group's last file item and into its `rules` list as `rules add` lists a file; the rule's ID becomes `<group>/<stem>`. |
|
|
1919
1919
|
| `rules filter <group> [--workflows <name>...] [--steps <name>...] [--all-workflows] [--all-steps]` | Sets a `ww-rules.yaml` group's filters; `--workflows '*'` / `--steps '*'` writes `"*"`, and `--all-*` removes one, which also admits all. Refuses a group declared in another file. |
|
|
1920
1920
|
| `rules promote <check>` | Copies a `converted` store check without a pending revision into the `check` of every rule file whose wording it covers, then deletes the check and those rules' entries from the store. Refuses when a covered rule is written in a step's `rules` list or already has a check. |
|
|
1921
1921
|
|
|
@@ -1941,7 +1941,8 @@ absolute or has a `..` part, which only a hand-edited store holds, counts as
|
|
|
1941
1941
|
absent.
|
|
1942
1942
|
|
|
1943
1943
|
`ww-rules.yaml`, next to `ww.yaml`, holds only a `rules`
|
|
1944
|
-
mapping written by `rules add --group` and `rules filter
|
|
1944
|
+
mapping written by `rules add --group` and `rules filter`, and by `rules add`
|
|
1945
|
+
and `rules move` listing a file in one of its groups; ww rewrites it
|
|
1945
1946
|
whole and it is composed like any import. While it exists without being
|
|
1946
1947
|
imported, the write commands refuse to use it.
|
|
1947
1948
|
|
ww/assets/ww-rule_skill.md
CHANGED
|
@@ -12,11 +12,13 @@ optional frontmatter scopes it to files (`paths`) or gives it a command
|
|
|
12
12
|
group, `ww-rules.yaml`, `ww.yaml` or
|
|
13
13
|
`ww-rule-automation.json` yourself.
|
|
14
14
|
|
|
15
|
-
1. **Learn what exists.** Run `./ww rules --json
|
|
16
|
-
directories' rules with IDs, summaries, globs,
|
|
17
|
-
`check_guidance` setting
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
1. **Learn what exists.** Run `./ww rules --json`: groups, their filters and
|
|
16
|
+
directories' rules with IDs, summaries, globs, the project's
|
|
17
|
+
`check_guidance` setting, and `targets`, every workflow's steps with the
|
|
18
|
+
`path` a `steps` filter names to reach exactly that step (loop bodies and
|
|
19
|
+
per-item stages included) and whether the step is `agent_owned`; only
|
|
20
|
+
such a step takes rules. Use only workflow names and step names or paths
|
|
21
|
+
it shows; never invent one.
|
|
20
22
|
2. **Split into atomic obligations.** One rule is one thing an agent can do
|
|
21
23
|
or fail to do. Break the input into such obligations and merge the ones
|
|
22
24
|
that say the same thing twice. For each, search the existing rules by ID
|
|
@@ -29,9 +31,12 @@ group, `ww-rules.yaml`, `ww.yaml` or
|
|
|
29
31
|
or `--dry-run`, which reports the count). A glob that matches nothing is
|
|
30
32
|
dropped, and you say so.
|
|
31
33
|
4. **Decide placement from the real filters.** An existing group whose
|
|
32
|
-
`workflows`/`steps` fit the rule
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
`workflows`/`steps` fit the rule, whether it lists a directory or its
|
|
35
|
+
files one by one (`rules add` then writes the file beside the group's
|
|
36
|
+
last one, or in `--dir`, and lists it; a group naming only other groups
|
|
37
|
+
needs `--dir`); else propose a new group with its directory and filters;
|
|
38
|
+
else, for a one-off, the step's own `rules:` list, which the operator
|
|
39
|
+
edits in the YAML by hand (say exactly what to add).
|
|
35
40
|
5. **Rewrite each rule** as one imperative sentence with concrete nouns and
|
|
36
41
|
no hedging; the rationale and an example go in the body below it, since
|
|
37
42
|
the step page shows only the first sentence. Propose a `check` only when
|
ww/cli/main.py
CHANGED
|
@@ -609,12 +609,8 @@ def _rule_write(context: _Context, configuration: WorkflowConfiguration) -> _Out
|
|
|
609
609
|
raise StateError(
|
|
610
610
|
"rules add takes GROUP with --text, or --group NAME with --dir"
|
|
611
611
|
)
|
|
612
|
-
if
|
|
613
|
-
|
|
614
|
-
or args.workflows is not None
|
|
615
|
-
or (args.steps is not None)
|
|
616
|
-
):
|
|
617
|
-
raise StateError("--dir, --workflows and --steps go with --group")
|
|
612
|
+
if args.workflows is not None or args.steps is not None:
|
|
613
|
+
raise StateError("--workflows and --steps go with --group")
|
|
618
614
|
write = rule_writes.plan_add_rule(
|
|
619
615
|
project,
|
|
620
616
|
args.group_name,
|
|
@@ -627,6 +623,7 @@ def _rule_write(context: _Context, configuration: WorkflowConfiguration) -> _Out
|
|
|
627
623
|
tuple(args.assertion) if args.assertion else None,
|
|
628
624
|
),
|
|
629
625
|
stem=args.stem,
|
|
626
|
+
directory=args.directory,
|
|
630
627
|
)
|
|
631
628
|
elif action == "edit":
|
|
632
629
|
write = rule_writes.plan_edit(
|
ww/cli/parser.py
CHANGED
|
@@ -1195,7 +1195,16 @@ def _rules_parser(
|
|
|
1195
1195
|
)
|
|
1196
1196
|
add.add_argument("--id", dest="stem", metavar="STEM", default=None)
|
|
1197
1197
|
add.add_argument("--group", dest="new_group", metavar="NAME", default=None)
|
|
1198
|
-
add.add_argument(
|
|
1198
|
+
add.add_argument(
|
|
1199
|
+
"--dir",
|
|
1200
|
+
dest="directory",
|
|
1201
|
+
type=Path,
|
|
1202
|
+
default=None,
|
|
1203
|
+
help=(
|
|
1204
|
+
"A new group's directory; with GROUP, where the rule file goes "
|
|
1205
|
+
"instead of the group's directory or beside its last file."
|
|
1206
|
+
),
|
|
1207
|
+
)
|
|
1199
1208
|
_filter_options(add)
|
|
1200
1209
|
edit = actions.add_parser(
|
|
1201
1210
|
"edit",
|
ww/completion_inputs.py
CHANGED
|
@@ -28,9 +28,14 @@ def group_metadata_values(
|
|
|
28
28
|
def validate_requested_values(
|
|
29
29
|
values: dict[str, str], requested: tuple[ProvidedVariable, ...]
|
|
30
30
|
) -> None:
|
|
31
|
-
"""Require
|
|
31
|
+
"""Require the variables requested by a plan item and accept no other.
|
|
32
|
+
|
|
33
|
+
A conditional one may be left out: ww asks for it later only when the
|
|
34
|
+
handler that declared it needs it.
|
|
35
|
+
"""
|
|
32
36
|
expected = {item.name for item in requested}
|
|
33
|
-
|
|
37
|
+
needed = {item.name for item in requested if not item.conditional}
|
|
38
|
+
unknown, missing = set(values) - expected, needed - set(values)
|
|
34
39
|
if unknown:
|
|
35
40
|
raise StateError(
|
|
36
41
|
"unexpected completion variable(s): " + ", ".join(sorted(unknown))
|