@selesai/code 0.3.10 → 0.5.0
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.
- package/dist/core/agent-session-auto-handoff.test.d.ts +2 -0
- package/dist/core/agent-session-auto-handoff.test.d.ts.map +1 -0
- package/dist/core/agent-session-auto-handoff.test.js +161 -0
- package/dist/core/agent-session-auto-handoff.test.js.map +1 -0
- package/dist/core/agent-session.d.ts +4 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +43 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/settings-manager-auto-handoff.test.d.ts +2 -0
- package/dist/core/settings-manager-auto-handoff.test.d.ts.map +1 -0
- package/dist/core/settings-manager-auto-handoff.test.js +29 -0
- package/dist/core/settings-manager-auto-handoff.test.js.map +1 -0
- package/dist/core/settings-manager.d.ts +9 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +22 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/defaults/models.json +2 -3
- package/dist/extensions/caveman/index.js +16 -1
- package/dist/extensions/caveman/test/extension.test.js +7 -4
- package/dist/extensions/caveman/test/helpers.test.js +12 -1
- package/dist/extensions/context-compaction-reminder.test.ts +82 -0
- package/dist/extensions/context-compaction-reminder.ts +28 -0
- package/dist/extensions/handoff-new.test.ts +2 -13
- package/dist/extensions/handoff-new.ts +16 -25
- package/dist/extensions/package.json +1 -0
- package/dist/extensions/pi-powerline-footer/index.ts +43 -2
- package/dist/extensions/pi-powerline-footer/session-usage.ts +44 -0
- package/dist/extensions/pi-powerline-footer/tests/session-usage.test.ts +47 -0
- package/dist/extensions/pi-subagents/README.md +1 -1
- package/dist/extensions/pi-subagents/agents/architect.md +9 -29
- package/dist/extensions/pi-subagents/agents/builder.md +17 -106
- package/dist/extensions/pi-subagents/agents/commentator.md +20 -117
- package/dist/extensions/pi-subagents/agents/explorer.md +14 -35
- package/dist/extensions/pi-subagents/agents/recapper.md +20 -12
- package/dist/extensions/pi-subagents/agents/researcher.md +11 -34
- package/dist/extensions/pi-subagents/src/agents/agents.ts +46 -0
- package/dist/extensions/pi-subagents/src/extension/index.ts +2 -1
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +2 -0
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +24 -0
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +25 -1
- package/dist/extensions/question/constants.ts +0 -7
- package/dist/extensions/question/index.ts +11 -108
- package/dist/extensions/question/schemas.ts +1 -26
- package/dist/extensions/question/shortcuts.ts +5 -14
- package/dist/extensions/question/tests/question-list.test.ts +8 -0
- package/dist/extensions/question/tests/ui-protocol.test.ts +1 -7
- package/dist/extensions/question/tui-adapter.ts +3 -20
- package/dist/extensions/question/types.ts +0 -6
- package/dist/extensions/question/ui-protocol.ts +2 -17
- package/dist/extensions/workflow/adapter.ts +395 -275
- package/dist/extensions/workflow/extension.ts +2 -1
- package/dist/extensions/workflow/modes/prototype.ts +17 -19
- package/dist/extensions/workflow/modes/quick.ts +17 -19
- package/dist/extensions/workflow/modes/task.ts +82 -0
- package/dist/extensions/workflow/run-state.ts +124 -0
- package/dist/extensions/workflow/state-machine.ts +7 -8
- package/dist/extensions/workflow/task-validators.ts +69 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +20 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +8 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +8 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +12 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +14 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +20 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/skills/workflow-creation/SKILL.md +72 -0
- package/docs/workflows.md +46 -7
- package/package.json +1 -1
package/docs/workflows.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Workflows
|
|
2
2
|
|
|
3
|
-
Selesai ships a workflow engine under `src/extensions/workflow/`. It powers the built-in `prototype` and `
|
|
3
|
+
Selesai ships a workflow engine under `src/extensions/workflow/`. It powers the built-in `prototype`, `quick`, and `task` workflows and is designed so you can add a new workflow mode as a thin config file — no engine changes.
|
|
4
4
|
|
|
5
5
|
## How it fits together
|
|
6
6
|
|
|
@@ -8,15 +8,18 @@ Selesai ships a workflow engine under `src/extensions/workflow/`. It powers the
|
|
|
8
8
|
src/extensions/workflow/
|
|
9
9
|
package.json pi package manifest; loads ./extension.ts as the single entry
|
|
10
10
|
state-machine.ts pure phase state machine (no fs, no pi API)
|
|
11
|
-
adapter.ts pi wiring: tools, commands, events, fs,
|
|
11
|
+
adapter.ts pi wiring: tools, commands, events, fs, durable-state lifecycle
|
|
12
|
+
run-state.ts versioned atomic workflow.json load/save/discovery
|
|
12
13
|
extension.ts single pi extension that mounts every workflow mode
|
|
13
14
|
modes/
|
|
14
15
|
prototype.ts mode config + registration object (exported as `prototypeMode`)
|
|
15
16
|
quick.ts mode config + registration object (exported as `quickMode`)
|
|
17
|
+
task.ts mode config + registration object (exported as `taskMode`)
|
|
16
18
|
```
|
|
17
19
|
|
|
18
20
|
- **`state-machine.ts`** is the deep module. It owns the phase graph, artifact gating, skip rules, the terminal close gate, and the reentrancy guard. It imports nothing external — no `node:fs`, no pi API, no `pi-tui`, no `typebox`. Every method returns a `WorkflowEffect` (a discriminated union in domain vocabulary) that the adapter pattern-matches on.
|
|
19
|
-
- **`adapter.ts`** is the thin glue.
|
|
21
|
+
- **`adapter.ts`** is the thin glue. It owns Pi/fs wiring, durable state, explicit resume, loop review persistence, and the git-based `reuse` skip predicate. Parent-written artifacts advance durable phase state. `prototype` and `quick` stop at user-controlled boundaries; `task` queues its build loop as soon as its plan is ready.
|
|
22
|
+
- **`workflow.json`** in each artifact directory is the canonical, versioned run record. It is atomically replaced after state changes; session custom entries are only pointers for UI/history and never reconstruct an active run.
|
|
20
23
|
- **`extension.ts`** imports each mode's registration object and calls `createWorkflowExtension(config, options)(pi)` for each, so one extension load resolves a single shared writer tool + one start/end tool pair per mode.
|
|
21
24
|
- **A mode file** is pure data: the phase list, the per-phase artifact filenames, the per-phase prompt generators, the terminal close artifacts, and identity strings (tool names, command name, status key, entry type). Prompts are functions that receive `{ artifactDir, userPrompt }` and return a string. Each mode exports a `WorkflowModeRegistration` object (e.g. `prototypeMode`, `quickMode`); it does not call `createWorkflowExtension` itself.
|
|
22
25
|
|
|
@@ -90,10 +93,12 @@ export const rigorousMode: WorkflowModeRegistration = {
|
|
|
90
93
|
"Run the rigorous workflow (grill → spec → research → plan → reuse → handoff → loop → audit → sign-off)",
|
|
91
94
|
toolNames: {
|
|
92
95
|
start: "start_rigorous_workflow",
|
|
96
|
+
resume: "resume_rigorous_workflow",
|
|
93
97
|
end: "end_rigorous_workflow",
|
|
94
98
|
},
|
|
95
99
|
toolLabels: {
|
|
96
100
|
start: "Start Rigorous Workflow",
|
|
101
|
+
resume: "Resume Rigorous Workflow",
|
|
97
102
|
end: "End Rigorous Workflow",
|
|
98
103
|
},
|
|
99
104
|
};
|
|
@@ -111,7 +116,21 @@ import { rigorousMode } from "./modes/rigorous.ts";
|
|
|
111
116
|
const MODES = [prototypeMode, quickMode, rigorousMode] as const;
|
|
112
117
|
```
|
|
113
118
|
|
|
114
|
-
That's it. The loader picks it up at boot (`package.json` loads only `./extension.ts`);
|
|
119
|
+
That's it. The loader picks it up at boot (`package.json` loads only `./extension.ts`); start/resume/end tools and the `/rigorous` command are registered automatically. There is no `next` tool — phases auto-advance as artifacts land and only the `end` tool completes the terminal phase.
|
|
120
|
+
|
|
121
|
+
## Built-in modes
|
|
122
|
+
|
|
123
|
+
### `task` — rapid plan + build/review loop
|
|
124
|
+
|
|
125
|
+
The simplest workflow: an architect subagent produces a validated `plan.md`, then a builder↔commentator review loop runs (max 3 blocking rounds). A clean review makes the workflow terminal-ready; `end_task_workflow` completes it.
|
|
126
|
+
|
|
127
|
+
Lifecycle: `plan → loop (build ↔ review) → terminal-ready → end_task_workflow`
|
|
128
|
+
|
|
129
|
+
- `/workflow-task <goal>` — start a new run
|
|
130
|
+
- `/workflow-task resume` — list and resume active runs
|
|
131
|
+
- `/workflow-task help` — show the lifecycle
|
|
132
|
+
- Its ready plan automatically queues the builder↔review loop
|
|
133
|
+
- No grilling, research, reuse, or handoff phases
|
|
115
134
|
|
|
116
135
|
## Config reference
|
|
117
136
|
|
|
@@ -124,8 +143,9 @@ That's it. The loader picks it up at boot (`package.json` loads only `./extensio
|
|
|
124
143
|
| `closeArtifacts` | `string[]` | Files that must exist before `end()` succeeds. Config-owned, no built-in default. |
|
|
125
144
|
| `skipRules?` | `{ phase, shouldSkip }[]` | Optional per-phase skip rules. `shouldSkip` is a boolean predicate; when true the engine skips to the next phase. Omit to use the adapter's default (skip `reuse` on empty projects). |
|
|
126
145
|
| `statusKey` | `string` | Footer status key. |
|
|
127
|
-
| `entryType` | `string` |
|
|
146
|
+
| `entryType` | `string` | Session-history custom-type. It stores a pointer only; `workflow.json` is canonical. |
|
|
128
147
|
| `footerLabel` | `string` | Label shown in the footer (`● label · step/total phase`). |
|
|
148
|
+
| `continueAfterArtifact?` | `boolean` | Queue the next phase prompt after the parent writes a valid artifact. `task` enables this for plan → build. |
|
|
129
149
|
|
|
130
150
|
### Adapter options
|
|
131
151
|
|
|
@@ -133,12 +153,31 @@ The second argument to `createWorkflowExtension`:
|
|
|
133
153
|
|
|
134
154
|
| Field | Description |
|
|
135
155
|
|---|---|
|
|
136
|
-
| `toolNames` | `{ start, end }` —
|
|
156
|
+
| `toolNames` | `{ start, resume, end }` — registered tool names. Artifacts advance phase state; the user explicitly continues the attached run. |
|
|
137
157
|
| `toolLabels` | Human-readable labels for the tools. |
|
|
138
158
|
| `commandName` | The `/<command>` name users type to kick off the workflow. |
|
|
139
159
|
| `commandDescription` | Description shown in the command list. |
|
|
140
160
|
|
|
141
|
-
##
|
|
161
|
+
## Durable runs and explicit resume
|
|
162
|
+
|
|
163
|
+
Each started workflow receives a UUID artifact directory under `.selesai/artifacts/` and an adjacent `workflow.json`. It stores the mode, phase, armed state, loop round/review path, and timestamps. Writes use a temporary sibling file plus rename, so a crash cannot partially overwrite the canonical record.
|
|
164
|
+
|
|
165
|
+
Runs are **never** auto-resumed on session start. At most one run can be attached to a Pi instance, but older active runs remain resumable:
|
|
166
|
+
|
|
167
|
+
- `resume_workflow({ run: "<id-or-path>" })` / `resume_quick_workflow(...)` / `resume_task_workflow(...)`
|
|
168
|
+
- `/workflow-prototype resume <id-or-artifact-dir-or-workflow.json>` / `/workflow-quick resume ...` / `/workflow-task resume ...`
|
|
169
|
+
- `/workflow-prototype resume`, `/workflow-quick resume`, or `/workflow-task resume` lists active runs (and offers a UI picker when available).
|
|
170
|
+
- `/workflow-prototype help`, `/workflow-quick help`, or `/workflow-task help` shows the start, resume, continue, and explicit-completion lifecycle.
|
|
171
|
+
|
|
172
|
+
Resume validates the selected file is under the artifacts base, belongs to that mode, is active, and matches its containing directory. It reconciles the current expected artifact once before emitting the current prompt, covering a crash after `write_workflow_artifact` writes the file but before the phase-state write. Artifact writes do not inject the next phase prompt or launch the next subagent; they terminate the parent turn and wait for the user to continue. A mode can opt out of that pause after a parent artifact write; `task` does so after `plan.md` so the build loop starts immediately. Corrupt records are skipped during discovery.
|
|
173
|
+
|
|
174
|
+
A valid terminal artifact makes a workflow **terminal-ready**; it does not complete the run. Call the mode-specific `end_*_workflow` tool to write `status: "completed"`, append the done entry, and terminate. This is the only completion path.
|
|
175
|
+
|
|
176
|
+
## Artifact ownership
|
|
177
|
+
|
|
178
|
+
Workflow artifacts have one writer: the parent session's `write_workflow_artifact` tool. Every workflow child call uses `output: false` and returns inline. In artifact phases (`plan`, `reuse`, `handoff`, and `audit`), the parent inspects that result, validates any required marker, and immediately passes it to `write_workflow_artifact`. Child output paths and fallback persistence are deliberately disabled; a child result alone cannot create an artifact or advance a phase.
|
|
179
|
+
|
|
180
|
+
The implement/review loop is the explicit exception to parent persistence, not inline return: the engine persists `loop-review-<round>.md` and `loop-complete.md` from commentator results so it can manage review rounds. Builders only change workspace code.
|
|
142
181
|
|
|
143
182
|
Every state-machine method returns a `WorkflowEffect` — a discriminated union the adapter switches on:
|
|
144
183
|
|