@wanbicoi/next-steps 0.1.0 → 0.1.2
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/README.md +124 -50
- package/dist/cli.js +444 -621
- package/docs/AGENTS.sample.md +120 -0
- package/package.json +2 -1
- package/viz/template.html +106 -165
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# next-steps
|
|
2
2
|
|
|
3
|
-
A small CLI that keeps an agent on a predefined workflow. The graph
|
|
4
|
-
|
|
5
|
-
same question: **what can I do next?**
|
|
3
|
+
A small CLI that keeps an agent on a predefined workflow. The graph is one file,
|
|
4
|
+
`.next-steps/workflow.json`; the tool records one session per task and always
|
|
5
|
+
answers the same question: **what can I do next?**
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
$ next-steps create
|
|
8
|
+
$ next-steps create
|
|
9
9
|
session: 4f1c9b3e-9a02-4d1c-8e11-7c6b1f0a2d33
|
|
10
10
|
workflow: feature-work Implement a feature end to end
|
|
11
11
|
status: running
|
|
@@ -16,16 +16,18 @@ next:
|
|
|
16
16
|
|
|
17
17
|
$ next-steps log --key 4f1c... --node read-issue
|
|
18
18
|
logged: #1 read-issue (entry)
|
|
19
|
-
|
|
19
|
+
status: running
|
|
20
20
|
|
|
21
21
|
next:
|
|
22
|
-
1.
|
|
22
|
+
1. implement Implement [review]
|
|
23
23
|
Criteria are understood.
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
The point is not to constrain what the agent can think — it is to make the path
|
|
27
27
|
it took readable afterwards, and to stop it from skipping work or losing its
|
|
28
|
-
place.
|
|
28
|
+
place. A node marked `[review]` means the agent shows the plan and waits for an
|
|
29
|
+
explicit yes before doing the work; the flag is advisory, so nothing blocks a
|
|
30
|
+
scripted run.
|
|
29
31
|
|
|
30
32
|
## Run it
|
|
31
33
|
|
|
@@ -57,44 +59,44 @@ bun src/cli.ts help
|
|
|
57
59
|
You can also use the package script: `bun run next-steps -- help`.
|
|
58
60
|
|
|
59
61
|
State is created on first use at `./.next-steps/state.db` (SQLite, gitignored).
|
|
60
|
-
|
|
61
|
-
from the project root.
|
|
62
|
+
The graph is read from `./.next-steps/workflow.json`; commit that file, and run
|
|
63
|
+
the tool from the project root. There are no path flags.
|
|
62
64
|
|
|
63
|
-
This repo keeps
|
|
65
|
+
This repo keeps sample graphs under `test/fixtures/<id>/.next-steps/`. To try the
|
|
64
66
|
commands from the repo root:
|
|
65
67
|
|
|
66
68
|
```sh
|
|
67
|
-
mkdir -p
|
|
69
|
+
mkdir -p .next-steps && cp test/fixtures/feature-work/.next-steps/workflow.json .next-steps/
|
|
68
70
|
```
|
|
69
71
|
|
|
70
|
-
## Visualize
|
|
72
|
+
## Visualize the graph
|
|
71
73
|
|
|
72
|
-
`next-steps viz` serves an interactive Cytoscape viewer for
|
|
73
|
-
|
|
74
|
+
`next-steps viz` serves an interactive Cytoscape viewer for
|
|
75
|
+
`.next-steps/workflow.json`:
|
|
74
76
|
|
|
75
77
|
```sh
|
|
76
78
|
next-steps viz # http://127.0.0.1:3000
|
|
77
79
|
next-steps viz --port 8080
|
|
78
80
|
```
|
|
79
81
|
|
|
80
|
-
From this repo, `bun src/cli.ts viz`. Press Ctrl+C to stop.
|
|
81
|
-
|
|
82
|
-
`viz/template.html` to change the styles.
|
|
82
|
+
From this repo, `bun src/cli.ts viz`. Press Ctrl+C to stop. Groups are drawn as
|
|
83
|
+
labelled boxes, review nodes are marked, and every move shows its description and
|
|
84
|
+
condition. Edit `viz/template.html` to change the styles.
|
|
83
85
|
|
|
84
86
|
## Commands
|
|
85
87
|
|
|
86
88
|
```
|
|
87
|
-
next-steps create
|
|
89
|
+
next-steps create [--key <key>] [--json]
|
|
88
90
|
next-steps log --key <key> --node <node> [--json]
|
|
89
91
|
next-steps next --key <key> [--json]
|
|
90
92
|
next-steps steps --key <key> [--limit <n>] [--after <seq>] [--json]
|
|
91
|
-
next-steps keys [--
|
|
93
|
+
next-steps keys [--json]
|
|
92
94
|
next-steps reset --key <key> [--json]
|
|
95
|
+
next-steps agents [--json]
|
|
93
96
|
|
|
94
|
-
next-steps workflow new
|
|
95
|
-
next-steps workflow
|
|
96
|
-
next-steps workflow
|
|
97
|
-
next-steps workflow check [id] [--json]
|
|
97
|
+
next-steps workflow new [--json]
|
|
98
|
+
next-steps workflow show [--json]
|
|
99
|
+
next-steps workflow check [--json]
|
|
98
100
|
|
|
99
101
|
next-steps viz [--port <n>] [--json]
|
|
100
102
|
```
|
|
@@ -103,7 +105,69 @@ Pretty output is the default; `--json` is the stable, machine-readable form
|
|
|
103
105
|
documented in `docs/AGENTS.sample.md`.
|
|
104
106
|
|
|
105
107
|
`create` only opens a session (the key is the task id; a UUID is generated when
|
|
106
|
-
omitted). It does not author
|
|
108
|
+
omitted). It does not author the graph — use `workflow new` for that.
|
|
109
|
+
|
|
110
|
+
`agents` prints `docs/AGENTS.sample.md`, the playbook an agent reads to drive
|
|
111
|
+
this CLI from another repo. Copy the output into that repo's `AGENTS.md`:
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
next-steps agents > /tmp/agents.md
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Hooks
|
|
118
|
+
|
|
119
|
+
If `.next-steps/hook` exists and is executable (`chmod +x`), every successful
|
|
120
|
+
`log` runs it after the state is written. Use it to mirror progress into a
|
|
121
|
+
status bar, window title, or agent sidebar. Any language works; a Python hook:
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
#!/usr/bin/env python3
|
|
125
|
+
# .next-steps/hook — mirror the state into a status file
|
|
126
|
+
import json
|
|
127
|
+
import sys
|
|
128
|
+
|
|
129
|
+
payload = json.load(sys.stdin)
|
|
130
|
+
|
|
131
|
+
if payload["status"] == "done":
|
|
132
|
+
label = "done"
|
|
133
|
+
elif payload["status"] == "review":
|
|
134
|
+
label = ", ".join(n["title"] for n in payload["next"] if n["reviewRequired"])
|
|
135
|
+
else:
|
|
136
|
+
label = " | ".join(n["title"] for n in payload["next"]) or payload["last"]["title"]
|
|
137
|
+
|
|
138
|
+
with open("/tmp/next-steps-status", "w") as out:
|
|
139
|
+
out.write(f'{payload["key"]} {payload["status"]} {label}\n')
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Replace the file write with a call to your status tool (a tmux status line, a
|
|
143
|
+
Herdr sidebar, a file watcher). The hook runs from the project root and inherits
|
|
144
|
+
the normal environment; its stdout and stderr are discarded, so report through
|
|
145
|
+
the tool it drives.
|
|
146
|
+
|
|
147
|
+
The payload on stdin is a status snapshot, not the full event:
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"event": "log",
|
|
152
|
+
"key": "4f1c...",
|
|
153
|
+
"status": "review",
|
|
154
|
+
"last": { "id": "read-issue", "title": "Read the issue" },
|
|
155
|
+
"next": [{ "id": "implement", "title": "Implement", "reviewRequired": true }]
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`status` is derived: `done` when the run finished, `review` when any legal next
|
|
160
|
+
node has `reviewRequired`, otherwise `running`. `last` is the node just logged;
|
|
161
|
+
`next` is what the agent may do now. For anything richer (edges, descriptions,
|
|
162
|
+
conditions, history), call `next-steps next --key <key> --json` — the payload
|
|
163
|
+
carries the `key`.
|
|
164
|
+
|
|
165
|
+
Hooks run synchronously with a five-second timeout. A missing hook is silent; a
|
|
166
|
+
hook that fails, times out, or lacks the execute bit prints a warning to stderr
|
|
167
|
+
and never changes the log's exit code. Only `log` triggers the hook, so a fresh
|
|
168
|
+
session stays quiet until its first node is finished. Commit `.next-steps/hook`
|
|
169
|
+
when the whole team should share the behaviour; leave it untracked for a local
|
|
170
|
+
adapter.
|
|
107
171
|
|
|
108
172
|
## Workflow format
|
|
109
173
|
|
|
@@ -113,36 +177,44 @@ omitted). It does not author a workflow — use `workflow new` for that.
|
|
|
113
177
|
"title": "Deploy a change",
|
|
114
178
|
"start": "build",
|
|
115
179
|
"nodes": [
|
|
116
|
-
{
|
|
180
|
+
{
|
|
181
|
+
"id": "build",
|
|
182
|
+
"title": "Build",
|
|
183
|
+
"description": "Run the build.",
|
|
184
|
+
"group": "Prepare",
|
|
185
|
+
"next": [{ "to": "review", "description": "The build is green." }]
|
|
186
|
+
},
|
|
117
187
|
{
|
|
118
188
|
"id": "review",
|
|
119
|
-
"type": "subgraph",
|
|
120
|
-
"workflow": "code-review",
|
|
121
189
|
"title": "Review",
|
|
122
|
-
"description": "
|
|
190
|
+
"description": "Read the change before it ships.",
|
|
191
|
+
"group": "Prepare",
|
|
192
|
+
"reviewRequired": true,
|
|
193
|
+
"next": [
|
|
194
|
+
{ "to": "build", "description": "Fix the review notes." },
|
|
195
|
+
{ "to": "END", "description": "Approved." }
|
|
196
|
+
]
|
|
123
197
|
}
|
|
124
|
-
],
|
|
125
|
-
"edges": [
|
|
126
|
-
{ "id": "e1", "from": "build", "to": "review", "description": "Build is green." },
|
|
127
|
-
{ "id": "e2", "from": "review", "to": "END", "description": "Review done." }
|
|
128
198
|
]
|
|
129
199
|
}
|
|
130
200
|
```
|
|
131
201
|
|
|
132
|
-
- `start` names the first step.
|
|
133
|
-
- `
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
-
|
|
141
|
-
|
|
142
|
-
- Duplicate
|
|
202
|
+
- `start` names the first step. Every node needs at least one move.
|
|
203
|
+
- `next` holds the ways out of the node. `to` is a node id or `END`; a
|
|
204
|
+
`condition` adds prose the agent reads but nothing evaluates. The move the
|
|
205
|
+
agent actually logs is the audit trail, recorded as `from->to`.
|
|
206
|
+
- `END` is a reserved target, not a node. A node whose only move is `END`
|
|
207
|
+
finishes the run as soon as it is logged, with no extra step.
|
|
208
|
+
- `group` labels a region of the graph. It is rendering metadata: the viewer
|
|
209
|
+
draws it as a box, and the rest of the tool ignores it.
|
|
210
|
+
- `reviewRequired` marks a node that needs an explicit yes before the work
|
|
211
|
+
starts. It is reported in `next` and `workflow show`, and never enforced.
|
|
212
|
+
- Duplicate moves out of one node are rejected so the log is unambiguous, and at
|
|
213
|
+
least one move to `END` is required.
|
|
214
|
+
- The graph is flat: there are no subgraphs and no cross-file references.
|
|
143
215
|
|
|
144
216
|
Run `next-steps workflow check` after editing. It fails with exit 5 on structural
|
|
145
|
-
problems and warns about unreachable nodes
|
|
217
|
+
problems and warns about unreachable nodes or nodes that cannot reach `END`.
|
|
146
218
|
|
|
147
219
|
## Exit codes
|
|
148
220
|
|
|
@@ -151,7 +223,7 @@ problems and warns about unreachable nodes.
|
|
|
151
223
|
|
|
152
224
|
Errors go to stderr. With `--json` they are
|
|
153
225
|
`{ "error": { "code", "message", "details" } }`, and `details.legal` lists the
|
|
154
|
-
|
|
226
|
+
moves the graph allows.
|
|
155
227
|
|
|
156
228
|
## Publish
|
|
157
229
|
|
|
@@ -193,12 +265,14 @@ src/commands/ one function per command
|
|
|
193
265
|
src/workflow/ load, validate, pure graph logic
|
|
194
266
|
src/runs/ session service, store, Bun/Node SQLite driver
|
|
195
267
|
scripts/build.ts Node bundle + shebang for dist/cli.js
|
|
196
|
-
test/fixtures
|
|
268
|
+
test/fixtures/<id>/ sample graphs, each in its own .next-steps/ directory
|
|
197
269
|
test/ pure, validation, end-to-end
|
|
198
270
|
```
|
|
199
271
|
|
|
200
|
-
`src/workflow/graph.ts` is pure: no I/O, no database, so the
|
|
201
|
-
|
|
202
|
-
which loads `bun:sqlite` under Bun and `node:sqlite` under Node.
|
|
272
|
+
`src/workflow/graph.ts` is pure: no I/O, no database, so the next computation is
|
|
273
|
+
testable in milliseconds. `RunStore` is an interface over `src/runs/driver.ts`,
|
|
274
|
+
which loads `bun:sqlite` under Bun and `node:sqlite` under Node. A state file from
|
|
275
|
+
0.1.0 or earlier is replaced on first use, since those sessions name graphs that
|
|
276
|
+
no longer exist.
|
|
203
277
|
|
|
204
|
-
`docs/initial-plan.md` records the design and the decisions behind it.
|
|
278
|
+
`docs/initial-plan.md` records the original design and the decisions behind it.
|