mpt-workflow 0.0.0-stage → 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/CHANGELOG.md +144 -0
- package/LICENSE +21 -0
- package/README.md +323 -2
- package/README.zh-CN.md +272 -0
- package/dist/cli.js +479 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/acl.js +120 -0
- package/dist/core/acl.js.map +1 -0
- package/dist/core/config.js +100 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/demo.js +50 -0
- package/dist/core/demo.js.map +1 -0
- package/dist/core/docs.js +291 -0
- package/dist/core/docs.js.map +1 -0
- package/dist/core/fsutil.js +89 -0
- package/dist/core/fsutil.js.map +1 -0
- package/dist/core/git.js +126 -0
- package/dist/core/git.js.map +1 -0
- package/dist/core/glob.js +36 -0
- package/dist/core/glob.js.map +1 -0
- package/dist/core/hooks.js +277 -0
- package/dist/core/hooks.js.map +1 -0
- package/dist/core/init.js +382 -0
- package/dist/core/init.js.map +1 -0
- package/dist/core/markdown.js +109 -0
- package/dist/core/markdown.js.map +1 -0
- package/dist/core/messages.js +365 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/questions.js +240 -0
- package/dist/core/questions.js.map +1 -0
- package/dist/core/state.js +139 -0
- package/dist/core/state.js.map +1 -0
- package/dist/core/types.js +8 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/workflow.js +1050 -0
- package/dist/core/workflow.js.map +1 -0
- package/dist/mcp/server.js +852 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/web/public/index.html +1094 -0
- package/dist/web/server.js +249 -0
- package/dist/web/server.js.map +1 -0
- package/package.json +63 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.5.0] - 2026-11-25
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Dashboard: review the file list, stat and unified diff before approving a
|
|
15
|
+
commit; message filters (未读 / blocking / 全部); copyable
|
|
16
|
+
`WF_ROLE=… WF_REPO=… claude` session command for each next action; visible
|
|
17
|
+
version and last-updated time; error banner with retry; onboarding empty
|
|
18
|
+
states.
|
|
19
|
+
- Auto-refresh now pauses while you type or review a milestone, preserves
|
|
20
|
+
question drafts and the open milestone detail, and skips hidden tabs.
|
|
21
|
+
- `mpt-workflow demo` creates a disposable workspace under `$TMPDIR`;
|
|
22
|
+
`mpt-workflow --version` prints the package version.
|
|
23
|
+
- `init` writes `npx`-stable MCP/hook commands when it runs from the npx cache,
|
|
24
|
+
instead of baking an evictable cache path into `.mcp.json` or git hooks.
|
|
25
|
+
|
|
26
|
+
## [0.4.0] - 2026-11-25
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- **Package identity.** The npm package is now `mpt-workflow`; the previous
|
|
31
|
+
name `workflow-mcp` is taken by an unrelated package. Binaries are
|
|
32
|
+
`mpt-workflow` and `mpt` (the generic `wf` alias was dropped). The package is
|
|
33
|
+
no longer `private` and ships a `files` allowlist plus `prepublishOnly`.
|
|
34
|
+
- `committed` is now derived from git instead of being an unmaintained status:
|
|
35
|
+
an accepted milestone whose TODO record is clean counts as committed.
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- **Data safety.** Mutating reads now use `readTextRequired`; a permission or
|
|
40
|
+
I/O error throws instead of silently returning an empty string that would
|
|
41
|
+
overwrite the user's TODO or questions file.
|
|
42
|
+
- **Commit scope.** `commit_request` and `commit` now refuse changes outside the
|
|
43
|
+
current TODO's declared file list, not just ACL violations.
|
|
44
|
+
- **Evidence placement.** New evidence is inserted into `## 证据记录` rather
|
|
45
|
+
than appended to EOF, so evidence recorded after an acceptance (a rework loop)
|
|
46
|
+
is still parsed.
|
|
47
|
+
- **Dashboard.** Loopback `Host` and same-origin checks close cross-site writes;
|
|
48
|
+
path containment uses `within()`; `/api/files` is limited to workflow
|
|
49
|
+
documents.
|
|
50
|
+
- **Evidence timeout.** Commands run in their own process group, so a timeout
|
|
51
|
+
kills the whole tree instead of leaving orphaned test processes.
|
|
52
|
+
- **Locks.** `withLock` retries briefly instead of failing immediately when
|
|
53
|
+
another session holds the lock.
|
|
54
|
+
- **Pre-commit hook.** Workflow-managed files (`TODO-*.md`,
|
|
55
|
+
`docs/agent-questions.md`, `.mcp.json`, `.claude/**`) are exempt from the
|
|
56
|
+
backstop, so a todo session can commit the milestone it just completed while
|
|
57
|
+
out-of-scope source files are still rejected.
|
|
58
|
+
- **Dev-mode init.** `init` warns (and skips hook installation) when
|
|
59
|
+
`dist/cli.js` does not exist, instead of writing hooks that point at a
|
|
60
|
+
missing file.
|
|
61
|
+
|
|
62
|
+
### Added
|
|
63
|
+
|
|
64
|
+
- Coverage gate (`npm run test:coverage`, 70% lines/functions/statements, 60%
|
|
65
|
+
branches) and a CI artifact.
|
|
66
|
+
- CodeQL analysis and a tag-driven release workflow with npm provenance.
|
|
67
|
+
- [docs/platform-support.md](docs/platform-support.md) (macOS / Linux / WSL2)
|
|
68
|
+
and [docs/releasing.md](docs/releasing.md).
|
|
69
|
+
|
|
70
|
+
## [0.3.0] - 2026-11-25
|
|
71
|
+
|
|
72
|
+
### Added
|
|
73
|
+
|
|
74
|
+
- Protocol-level test that spawns the real MCP server over stdio, lists tools,
|
|
75
|
+
calls `status` and checks role gating on the wire.
|
|
76
|
+
|
|
77
|
+
### Changed
|
|
78
|
+
|
|
79
|
+
- Require Node.js 22+ (Node 20 reached end-of-life in April 2026). CI now runs
|
|
80
|
+
Node 22 and 24.
|
|
81
|
+
- Upgrade `zod` to v4. The MCP SDK supports both v3 and v4; the full suite,
|
|
82
|
+
including the stdio protocol test, passes on v4.
|
|
83
|
+
|
|
84
|
+
## [0.2.0] - 2026-11-25
|
|
85
|
+
|
|
86
|
+
### Added
|
|
87
|
+
|
|
88
|
+
- **Agent messaging.** Persistent, addressed messages between `main`,
|
|
89
|
+
`plan@repo`, `todo@repo`, `user` and `system`, stored as one JSON file per
|
|
90
|
+
message plus an append-only audit log under `.workflow/runtime/messages/`.
|
|
91
|
+
- Message lifecycle `queued → unread → read → acked`, with `expired` and
|
|
92
|
+
`escalated` outcomes. Offline recipients see `queued` until their next
|
|
93
|
+
`bootstrap`/`inbox`.
|
|
94
|
+
- **Automatic notifications** for `ask`/`answer`/`close`,
|
|
95
|
+
`milestone_claim/complete/accept/reject`, `commit_request`, `commit` and
|
|
96
|
+
`phase_activate`.
|
|
97
|
+
- **Blocking messages** gate `milestone_claim/complete/accept/reject` until
|
|
98
|
+
acknowledged; answering a question acks the blocker for its addressee.
|
|
99
|
+
Stale blockers expire after 45 minutes and escalate to `user` and `main`.
|
|
100
|
+
- New MCP tools: `send_message`, `inbox`, `read_message`, `ack_message`,
|
|
101
|
+
`wait_message`, `broadcast`, `presence`, `escalate`.
|
|
102
|
+
- New CLI commands: `inbox`, `read`, `ack`, `send`, `wait`, `watch`, `escalate`,
|
|
103
|
+
`presence`.
|
|
104
|
+
- SessionStart hook now injects unread and blocking messages.
|
|
105
|
+
- Dashboard: unread-messages tile and a message panel with read/ack; question
|
|
106
|
+
answering now notifies the asker.
|
|
107
|
+
- `docs/architecture.md` and `docs/requirements-messaging.md`.
|
|
108
|
+
|
|
109
|
+
### Changed
|
|
110
|
+
|
|
111
|
+
- `status` and `next` surface unread/blocking messages and prioritise blockers.
|
|
112
|
+
- `bootstrap` registers presence and returns an unread summary.
|
|
113
|
+
- The dashboard web test now starts its own server on an ephemeral port, so it
|
|
114
|
+
runs in CI without a pre-started process.
|
|
115
|
+
|
|
116
|
+
### Fixed
|
|
117
|
+
|
|
118
|
+
- Empty repositories are reported as "no milestones" instead of "all done".
|
|
119
|
+
- Scope checks ignore workflow-managed files (`TODO-*.md`,
|
|
120
|
+
`docs/agent-questions.md`, `.mcp.json`, `.claude/**`).
|
|
121
|
+
|
|
122
|
+
## [0.1.0] - 2026-11-24
|
|
123
|
+
|
|
124
|
+
### Added
|
|
125
|
+
|
|
126
|
+
- Initial release: MCP server, CLI and local dashboard for a multi-agent,
|
|
127
|
+
multi-repo PLAN → TODO → accept → commit workflow.
|
|
128
|
+
- Markdown-derived state for `PLAN.md`, `TODO-Mn.md` and
|
|
129
|
+
`docs/agent-questions.md`; `init --adopt` for existing workspaces.
|
|
130
|
+
- Role model (`main`, `plan`, `todo`, `user`) with path ACLs enforced by
|
|
131
|
+
`PreToolUse` hooks and a git `pre-commit` scope check.
|
|
132
|
+
- 17 MCP tools covering status, questions, milestone transitions, server-side
|
|
133
|
+
evidence (`evidence_run`), scope checks and commit approvals.
|
|
134
|
+
- One-shot commit approvals bound to the working-tree hash; agents cannot push.
|
|
135
|
+
- Dashboard with milestone tracks, question inbox, approvals, doctor and
|
|
136
|
+
timeline.
|
|
137
|
+
- 16 tests.
|
|
138
|
+
|
|
139
|
+
[Unreleased]: https://github.com/Ye-Yu-Mo/mpt-workflow/compare/v0.5.0...HEAD
|
|
140
|
+
[0.5.0]: https://github.com/Ye-Yu-Mo/mpt-workflow/compare/v0.4.0...v0.5.0
|
|
141
|
+
[0.4.0]: https://github.com/Ye-Yu-Mo/mpt-workflow/compare/v0.3.0...v0.4.0
|
|
142
|
+
[0.3.0]: https://github.com/Ye-Yu-Mo/mpt-workflow/compare/v0.2.0...v0.3.0
|
|
143
|
+
[0.2.0]: https://github.com/Ye-Yu-Mo/mpt-workflow/compare/v0.1.0...v0.2.0
|
|
144
|
+
[0.1.0]: https://github.com/Ye-Yu-Mo/mpt-workflow/releases/tag/v0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ye-Yu-Mo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,324 @@
|
|
|
1
|
-
#
|
|
1
|
+
# mpt-workflow
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**A local MCP server, CLI and dashboard that turn a multi-agent, multi-repo
|
|
4
|
+
PLAN → TODO → implement → accept → commit workflow into an enforceable state machine.**
|
|
5
|
+
|
|
6
|
+
[中文](README.zh-CN.md)
|
|
7
|
+
|
|
8
|
+
[](https://github.com/Ye-Yu-Mo/mpt-workflow/actions/workflows/ci.yml)
|
|
9
|
+
[](https://www.npmjs.com/package/mpt-workflow)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
[](package.json)
|
|
12
|
+
|
|
13
|
+
> Status: pre-1.0. See [ROADMAP.md](ROADMAP.md) for the current release and
|
|
14
|
+
> next steps.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Why
|
|
19
|
+
|
|
20
|
+
Running several Claude Code sessions against several git repos looks fine until
|
|
21
|
+
it doesn't:
|
|
22
|
+
|
|
23
|
+
- **Nobody knows where the work stands.** A new session has to be told "you are
|
|
24
|
+
the PLAN agent for `my-service`, M3 is accepted, M4 has no TODO yet".
|
|
25
|
+
- **Roles are advisory.** The PLAN agent is told not to edit source. Nothing
|
|
26
|
+
stops it.
|
|
27
|
+
- **The human is the message bus.** You copy a question from the TODO session
|
|
28
|
+
into the PLAN session, then copy the answer back.
|
|
29
|
+
- **"It passes" is unverifiable.** Evidence is typed into a document by the same
|
|
30
|
+
agent that wrote the code.
|
|
31
|
+
- **Commits happen mid-thought.** You wanted to review the diff first.
|
|
32
|
+
|
|
33
|
+
This tool keeps the workflow in Markdown (so it stays reviewable), and adds a
|
|
34
|
+
state layer on top: derived status, role-scoped writes, server-executed
|
|
35
|
+
evidence, one-shot commit approvals, and persistent messaging between agents.
|
|
36
|
+
|
|
37
|
+
## How it works
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
┌─────────────────────────────────────────┐
|
|
41
|
+
PLAN.md / TODO-Mn.md │ mpt-workflow │
|
|
42
|
+
docs/agent-questions │ parse → derive state → gate → notify │
|
|
43
|
+
.workflow/program.yaml │ │ │
|
|
44
|
+
└────────┼────────────┼───────────┼────────┘
|
|
45
|
+
│ │ │
|
|
46
|
+
MCP tools PreToolUse pre-commit
|
|
47
|
+
(Claude) hooks hooks
|
|
48
|
+
│ │ │
|
|
49
|
+
┌────▼────────────▼───────────▼────┐
|
|
50
|
+
│ Claude Code sessions by role │
|
|
51
|
+
│ main · plan@repo · todo@repo │
|
|
52
|
+
└───────────────┬──────────────────┘
|
|
53
|
+
│
|
|
54
|
+
┌────────▼─────────┐
|
|
55
|
+
│ localhost:7788 │
|
|
56
|
+
│ dashboard (user) │
|
|
57
|
+
└──────────────────┘
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Three principles:
|
|
61
|
+
|
|
62
|
+
1. **Markdown is the source of truth.** `PLAN.md`, `TODO-Mn.md`,
|
|
63
|
+
`docs/agent-questions.md`, `.workflow/program.yaml` are human-readable and
|
|
64
|
+
git-reviewable. The tool derives state from them; it never invents a second
|
|
65
|
+
database of record.
|
|
66
|
+
2. **The MCP server is not the enforcement boundary.** Agents edit files with
|
|
67
|
+
`Edit`/`Write`, which never touches MCP. Real enforcement is a
|
|
68
|
+
`PreToolUse` hook (blocks out-of-role writes and `git push`) plus a
|
|
69
|
+
`pre-commit` hook (scope check).
|
|
70
|
+
3. **The human approves, the machine remembers.** Commits use a one-shot
|
|
71
|
+
approval bound to the exact working-tree hash; messages and status survive
|
|
72
|
+
restarts and new sessions.
|
|
73
|
+
|
|
74
|
+
## Requirements
|
|
75
|
+
|
|
76
|
+
- Node.js **22+** (Node 20 reached end-of-life in April 2026)
|
|
77
|
+
- git
|
|
78
|
+
- macOS, Linux, or WSL2. Native Windows is not supported yet — see
|
|
79
|
+
[docs/platform-support.md](docs/platform-support.md).
|
|
80
|
+
- [Claude Code](https://claude.com/claude-code) (for the MCP server and hooks;
|
|
81
|
+
the CLI and dashboard work without it)
|
|
82
|
+
|
|
83
|
+
## Install
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npm install -g mpt-workflow
|
|
87
|
+
mpt-workflow --help
|
|
88
|
+
|
|
89
|
+
# or run it without a global install
|
|
90
|
+
npx mpt-workflow --help
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The npm package name is **`mpt-workflow`**. `workflow-mcp` is already taken by
|
|
94
|
+
an unrelated package, so do not install or run that name.
|
|
95
|
+
|
|
96
|
+
Source install (for development):
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
git clone git@github.com:Ye-Yu-Mo/mpt-workflow.git
|
|
100
|
+
cd mpt-workflow
|
|
101
|
+
npm install
|
|
102
|
+
npm run build
|
|
103
|
+
node dist/cli.js --help
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`npm link` puts the `mpt-workflow` and `mpt` binaries on your `PATH`.
|
|
107
|
+
|
|
108
|
+
## Quick start
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Try it in a throwaway workspace (nothing outside $TMPDIR is touched)
|
|
112
|
+
mpt-workflow demo
|
|
113
|
+
|
|
114
|
+
# Adopt an existing multi-repo workspace (idempotent; never overwrites files)
|
|
115
|
+
mpt-workflow init --root /path/to/workspace
|
|
116
|
+
|
|
117
|
+
# Add the enforcement hooks (recommended)
|
|
118
|
+
mpt-workflow init --root /path/to/workspace --install-hooks
|
|
119
|
+
|
|
120
|
+
# See where things stand
|
|
121
|
+
mpt-workflow status --root /path/to/workspace
|
|
122
|
+
mpt-workflow next
|
|
123
|
+
|
|
124
|
+
# Open the dashboard
|
|
125
|
+
mpt-workflow web --root /path/to/workspace --port 7788
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Every command also works as `npx mpt-workflow <command>`.
|
|
129
|
+
|
|
130
|
+
Want to see it work first? `mpt-workflow demo` builds a throwaway workspace,
|
|
131
|
+
adopts it, prints status and sends a message. Nothing outside `$TMPDIR` is
|
|
132
|
+
touched. From a source checkout, `./scripts/demo.sh` does the same.
|
|
133
|
+
|
|
134
|
+
`init` writes:
|
|
135
|
+
|
|
136
|
+
| Path | Purpose |
|
|
137
|
+
|---|---|
|
|
138
|
+
| `.workflow/program.yaml` | program, repos, phases, active repo, contracts — **tracked in git** |
|
|
139
|
+
| `.workflow/.gitignore` | keeps `runtime/` out of git |
|
|
140
|
+
| `<root>/.mcp.json`, `<repo>/.mcp.json` | registers the MCP server (excluded via `.git/info/exclude`) |
|
|
141
|
+
| `<repo>/docs/agent-questions.md` | created only if missing |
|
|
142
|
+
| `.claude/settings.json` | only with `--install-hooks` |
|
|
143
|
+
| `.git/hooks/pre-commit` | only with `--install-hooks` |
|
|
144
|
+
|
|
145
|
+
## Roles
|
|
146
|
+
|
|
147
|
+
| Role | Address | May write | Must not write |
|
|
148
|
+
|---|---|---|---|
|
|
149
|
+
| `main` | `main` | umbrella docs, decisions, `PLAN.md`/`TODO-*.md` | source code, tests, manifests |
|
|
150
|
+
| `plan` | `plan@repo` | repo `PLAN.md`, `TODO-*.md`, `docs/**`, `MS-*/**` | source, manifests, other repos |
|
|
151
|
+
| `todo` | `todo@repo` | anything in the bound repo | `PLAN.md`, `TODO-*.md`, umbrella |
|
|
152
|
+
| `user` | `user` | everything (final authority) | — |
|
|
153
|
+
|
|
154
|
+
Declare the role per session. **Use environment variables when sessions run
|
|
155
|
+
concurrently** — the on-disk lease is machine-wide:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
WF_ROLE=plan WF_REPO=my-service claude
|
|
159
|
+
WF_ROLE=todo WF_REPO=my-service claude
|
|
160
|
+
WF_ROLE=main claude
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Or call `bootstrap(role="plan", repo="my-service")` as the first tool in the
|
|
164
|
+
session.
|
|
165
|
+
|
|
166
|
+
## The daily loop
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
plan writes TODO-M3.md (plain Write)
|
|
170
|
+
todo milestone_claim(M3)
|
|
171
|
+
todo ... code ...
|
|
172
|
+
todo evidence_run("cargo test --workspace --locked")
|
|
173
|
+
todo milestone_complete(M3) → plan gets a message
|
|
174
|
+
plan milestone_accept(M3) → main and user get a message
|
|
175
|
+
user reviews the diff in the dashboard, clicks Approve
|
|
176
|
+
agent commit_request → commit (local only, never pushes)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Every transition is idempotent and recorded. `next` tells each role what to do
|
|
180
|
+
based on derived state.
|
|
181
|
+
|
|
182
|
+
## Commit safety
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
agent: commit_request(message="feat: ...")
|
|
186
|
+
→ scope check, returns a one-shot approval id
|
|
187
|
+
user: approve in the dashboard, or `mpt-workflow approve ap-xxx`
|
|
188
|
+
agent: commit(approval="ap-xxx")
|
|
189
|
+
→ refuses if the working tree changed since approval
|
|
190
|
+
→ local git commit only; push is always manual
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The approval is a **guardrail against mistakes**, not an authorization system:
|
|
194
|
+
the server runs as your OS user. It exists so a human sees the diff before it
|
|
195
|
+
lands. `git push` is blocked for agents by the hook.
|
|
196
|
+
|
|
197
|
+
## Messaging and notifications
|
|
198
|
+
|
|
199
|
+
Agents don't need a human relay anymore. Events and messages are persisted,
|
|
200
|
+
queryable and acknowledged:
|
|
201
|
+
|
|
202
|
+
| Event | From → To |
|
|
203
|
+
|---|---|
|
|
204
|
+
| `ask` / `answer` / `close` | question participants |
|
|
205
|
+
| `milestone_claim` / `complete` | `todo@repo → plan@repo` |
|
|
206
|
+
| `milestone_accept` | `plan@repo → main, user` |
|
|
207
|
+
| `milestone_reject` | `plan@repo → todo@repo` |
|
|
208
|
+
| `commit_request` | any → `user` |
|
|
209
|
+
| `commit` | any → `main, user` |
|
|
210
|
+
| `phase_activate` | `main → all plan/todo` |
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
mpt-workflow inbox --role plan --repo my-service --unread
|
|
214
|
+
mpt-workflow read msg-...
|
|
215
|
+
mpt-workflow ack msg-... --note "handled"
|
|
216
|
+
mpt-workflow wait --role plan --repo my-service --timeout 60000
|
|
217
|
+
mpt-workflow watch --role main
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
- **At-least-once.** A message is a file on disk; a failed wake-up never loses it.
|
|
221
|
+
Offline recipients see `queued`, promoted to `unread` on their next
|
|
222
|
+
`bootstrap`/`inbox`.
|
|
223
|
+
- **Blocking** messages prevent `milestone_claim/complete/accept/reject` until
|
|
224
|
+
acknowledged, and are surfaced first by `next` and by the SessionStart hook.
|
|
225
|
+
- **Expiry.** Blocking messages expire after 45 minutes by default and escalate
|
|
226
|
+
to `user` and `main`.
|
|
227
|
+
- **Send ACL.** `todo@repo → plan@same-repo`; `todo → main` only for `alert`;
|
|
228
|
+
`plan → main`; `plan → todo@same-repo`; `plan → user` only for `alert`;
|
|
229
|
+
`main`, `user` and `system` are unrestricted. Cross-repo traffic goes through
|
|
230
|
+
`main`.
|
|
231
|
+
|
|
232
|
+
## Dashboard
|
|
233
|
+
|
|
234
|
+
`mpt-workflow web` serves a single-page, local-only dashboard:
|
|
235
|
+
|
|
236
|
+
- program progress, blocking issues, unread messages, in-flight milestones
|
|
237
|
+
- repo cards with a milestone track, evidence and current state
|
|
238
|
+
- question inbox — answer inline (writes back to Markdown, notifies the asker),
|
|
239
|
+
adopt the recommendation, or copy a relay message
|
|
240
|
+
- message panel with read/ack and **未读 / blocking / 全部** filters
|
|
241
|
+
- pending commit approvals with a **diff review** (file list, stat, unified
|
|
242
|
+
diff) before you approve
|
|
243
|
+
- copyable agent session command (`WF_ROLE=… WF_REPO=… claude`) for each next
|
|
244
|
+
action
|
|
245
|
+
- environment checks and an event timeline
|
|
246
|
+
|
|
247
|
+
The dashboard auto-refreshes every 15 seconds, but **pauses while you are
|
|
248
|
+
typing or reviewing a milestone**, preserves drafts and the open milestone
|
|
249
|
+
detail, and shows a retry banner if the API fails.
|
|
250
|
+
|
|
251
|
+
The only write actions are: answer/close a question, approve a commit, ack a
|
|
252
|
+
message, switch the active repo.
|
|
253
|
+
|
|
254
|
+
## MCP tools
|
|
255
|
+
|
|
256
|
+
| Tool | Roles | Purpose |
|
|
257
|
+
|---|---|---|
|
|
258
|
+
| `bootstrap` | all | declare role, get ACL + unread summary |
|
|
259
|
+
| `status` / `next` / `doctor` | all | state, recommended action, environment checks |
|
|
260
|
+
| `questions` | all | list questions |
|
|
261
|
+
| `ask` / `answer` / `close` | by addressee | question lifecycle |
|
|
262
|
+
| `milestone_claim` / `milestone_complete` | todo, main | start / finish implementation |
|
|
263
|
+
| `evidence_run` | todo, plan, main | execute a command, record exit code + tree oid + output |
|
|
264
|
+
| `milestone_accept` / `milestone_reject` | plan, main | accept with evidence / reject with reason |
|
|
265
|
+
| `scope_check` | all | diff vs declared files and role ACL |
|
|
266
|
+
| `commit_request` / `commit` | all | request approval, commit with it |
|
|
267
|
+
| `phase_activate` | main, user | serial repo lock |
|
|
268
|
+
| `send_message` / `inbox` / `read_message` / `ack_message` | all (ACL) | targeted messages |
|
|
269
|
+
| `wait_message` | all | long-poll for the next message |
|
|
270
|
+
| `broadcast` / `presence` / `escalate` | main / all / all | broadcast, presence, escalation |
|
|
271
|
+
|
|
272
|
+
## What it reads
|
|
273
|
+
|
|
274
|
+
The parser is deliberately forgiving so existing repos can be adopted without a
|
|
275
|
+
rewrite:
|
|
276
|
+
|
|
277
|
+
- **Milestones** from a `PLAN.md` table (`| M1 | name | ... |`) or headings
|
|
278
|
+
(`### M1 — name`), unioned with `TODO-M*.md` files.
|
|
279
|
+
- **Status** from YAML front matter (`status: implementing`) or a Chinese/English
|
|
280
|
+
marker (`状态:已验收`, `**已验收(...)**`).
|
|
281
|
+
- **Allowed files** from the `**影响文件**` list in each TODO.
|
|
282
|
+
- **Questions** from `## Q-001 [open] to: main` blocks.
|
|
283
|
+
- **Evidence** from a `## 证据记录` section.
|
|
284
|
+
|
|
285
|
+
Empty or missing files degrade gracefully: a repo without a `PLAN.md` shows up
|
|
286
|
+
as "no milestones", not an error.
|
|
287
|
+
|
|
288
|
+
## Safety model
|
|
289
|
+
|
|
290
|
+
Read [SECURITY.md](SECURITY.md) before running this on a shared machine.
|
|
291
|
+
|
|
292
|
+
- `evidence_run` executes arbitrary shell commands **as your user**, by design.
|
|
293
|
+
It has the same trust level as your terminal.
|
|
294
|
+
- The dashboard binds `127.0.0.1` only and has no authentication.
|
|
295
|
+
- Hooks are guardrails, not a sandbox; `git commit --no-verify` and
|
|
296
|
+
`WF_ALLOW_COMMIT=1` bypass the scope check.
|
|
297
|
+
- Bash-path ACLs only inspect obvious redirects. Use the pre-commit hook as the
|
|
298
|
+
backstop.
|
|
299
|
+
|
|
300
|
+
## Repository layout
|
|
301
|
+
|
|
302
|
+
```
|
|
303
|
+
src/core/ parsing, state machine, ACL, git, evidence, approvals, messages
|
|
304
|
+
src/mcp/ MCP server (25 tools)
|
|
305
|
+
src/web/ HTTP API + single-page dashboard
|
|
306
|
+
src/cli.ts init / status / doctor / web / mcp / hook / inbox / send ...
|
|
307
|
+
tests/ node:test suites (40 tests, incl. a real MCP stdio round-trip)
|
|
308
|
+
docs/ architecture and requirement notes
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Development
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
npm run typecheck # tsc --noEmit
|
|
315
|
+
npm test # runs the 40 tests via tsx
|
|
316
|
+
npm run build # tsc + copies the dashboard assets into dist/
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the full workflow, and
|
|
320
|
+
[docs/architecture.md](docs/architecture.md) for the design rationale.
|
|
321
|
+
|
|
322
|
+
## License
|
|
323
|
+
|
|
324
|
+
[MIT](LICENSE)
|