Skip to content

refactor: one copy of the workflow tool, check run() args, show aborted - #90

Merged
Vzlentin merged 3 commits into
mainfrom
refactor/cut-the-workflows-engine-into-concept-groups
Nov 1, 2026
Merged

Vzlentin merged 3 commits into
mainfrom
refactor/cut-the-workflows-engine-into-concept-groups

Conversation

@Vzlentin

@Vzlentin Vzlentin commented Nov 1, 2026

Copy link
Copy Markdown
Owner

On top of #89.

One copy of the workflow tool. It was in src/entry.ts and pi/index.ts, and the copies had drifted. src/tool.ts now holds the parameters, the CLI args, the outcome schema (also the output schema), the summaries, the description and the guidelines. It imports only typebox. pi/index.ts loads dist/tool.js from the package it already resolves, the same way it loads harness's entries.

  • The Pi tool now gives the report lines of a finished run, and its description has the input() sentence, as the host tool did.
  • A test checks that the two tools have the same description and parameters.

run() args are checked against the child's meta. One check in launch/args.ts for argv and for run(). A declared arg must have its type and a required arg must be there, before the child task exists:

run ship: rounds must be a positive integer
run ship: item is missing

Undeclared args (memory, patches, plan, reply, start) still pass. repo, base and branch are checked as strings instead of converted.

list and show print aborted for a stopped run. A script result stopped, such as a thermoloop out of rounds, still shows stopped. Before, both showed stopped, but resume treats them differently.

Base automatically changed from refactor/engine-concept-groups to main November 1, 2026 13:55
The workflow tool had two copies, in src/entry.ts for the host
and in pi/index.ts for Pi, and they differed. src/tool.ts is now
the one definition, and imports only typebox.

- src/tool.ts holds the parameters, `cliArgs`, `OUTCOME` and
  `WorkflowOutcome` (from src/run/task.ts), `JSON_VALUE` (from
  src/run/calls.ts), `outcomeOf`, `savedOutcome`, `summary`,
  `outcomeText`, the description and the guidelines.
- src/entry.ts uses it. Its output schema is `OUTCOME`, not a
  hand-written copy.
- pi/index.ts loads dist/tool.js of the workflows package it
  resolves. The tests give it src/tool.ts with the command.
  Rendering, the widget, the watcher and /workflows stay in pi/.

Differences resolved as the union of both copies:

- The Pi description gets the `input(question)` sentence of the
  host description.
- The Pi result text and the workflow-result message use
  `outcomeText`, as the host does: the summary, then the report
  lines of a finished run that does not wait.
- The Pi output schema is `OUTCOME`, one object per status.

A test checks that the host tool and the Pi tool have the same
description, parameters and output schema. A test checks that
the installed extension registers the tool of dist/tool.js.
AGENTS.md, docs/spec.md and README.md describe the tool module.
TASK.version does not change.
A run() call gave its args to the child with no check, so a
wrong type or a missing required arg failed late, inside the
child, or not at all.

- src/launch/args.ts has one check of args against meta.args,
  `argProblem`, used by the argv of `workflows <wf>` and by
  `runArgs` and `checkArgs` for a run() call. A declared arg must
  have its type (number as a positive integer), and a required
  arg must be present. Undeclared args pass.
- For argv, the usage errors and exit codes do not change.
- A run() call that fails the check throws
  `run <name>: <arg> is missing` or `run <name>: <arg> must be
  <type>`, before a worktree or a child task exists.
- The placement args `repo`, `base`, `branch` and `start` of a
  meta.worktree child go through the same check. A value that is
  not a string fails with `<key> must be a string`, in place of
  the `String()` conversions and `start is not a string`.
- `ARG_VALUES` in src/workflow/meta.ts names the schema and the
  wording of each arg type, for the meta defaults and the check.
- docs/spec.md and script.d.ts describe the check.

Tests show a wrong type and a missing required arg fail the call
with no child task and no child run directory. TASK.version does
not change.
list and show printed `stopped` for a run whose task ended
aborted, so it looked like a script result `stopped`, such as a
thermoloop out of rounds.

- `runStatus` in src/cli/saved.ts gives the task outcome as it
  is, so an aborted task is `aborted` in list and show, in text
  and with --json.
- A script result `stopped` still gives `stopped`.
- The lines of stop, resume and a followed run at the stop, and
  the `stopped` outcome of the tool and of --json, do not change.
- markOf gives `·` for `aborted`, as it did for `stopped`. The Pi
  /workflows command shows the status word as it is.
- docs/spec.md gives `aborted` in the list statuses and in show.

Tests show that a stopped run is `aborted` in list, list --json
and show --json, and that a run with the script result `stopped`
is `stopped`. TASK.version does not change.
@Vzlentin
Vzlentin force-pushed the refactor/cut-the-workflows-engine-into-concept-groups branch from 2f3ff07 to 124f913 Compare November 1, 2026 13:55
@Vzlentin
Vzlentin merged commit 9c657ed into main Nov 1, 2026
3 checks passed
@Vzlentin
Vzlentin deleted the refactor/cut-the-workflows-engine-into-concept-groups branch November 1, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant