tokenmaw 0.3.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/README.md +150 -0
- package/agents/coordinator.md +13 -0
- package/agents/explorer.md +21 -0
- package/agents/implement.md +23 -0
- package/agents/main.md +25 -0
- package/agents/review.md +21 -0
- package/dist/backend.js +595 -0
- package/dist/cli.js +101 -0
- package/dist/config.js +155 -0
- package/dist/diff.js +45 -0
- package/dist/domain/agent.js +1 -0
- package/dist/fetch.js +110 -0
- package/dist/infra/file-snapshot.js +54 -0
- package/dist/infra/tools.js +1300 -0
- package/dist/markdown.js +274 -0
- package/dist/model-config.js +48 -0
- package/dist/policy.js +80 -0
- package/dist/responses.js +81 -0
- package/dist/runtime/agent-registry.js +139 -0
- package/dist/runtime/agent-runtime.js +993 -0
- package/dist/runtime/agent-store.js +152 -0
- package/dist/runtime/locks.js +46 -0
- package/dist/runtime/session-timeline.js +92 -0
- package/dist/tools/index.js +4 -0
- package/dist/tools/registry.js +51 -0
- package/dist/tools/types.js +1 -0
- package/dist/ui/clipboard.js +24 -0
- package/dist/ui/commands.js +20 -0
- package/dist/ui/composer-layout.js +31 -0
- package/dist/ui/fullscreen-tui.js +1405 -0
- package/dist/ui/markdown.js +81 -0
- package/dist/ui/syntax.js +17 -0
- package/dist/ui/tui-design.js +94 -0
- package/dist/ui/welcome.js +24 -0
- package/dist/version.js +4 -0
- package/docs/architecture-revision.md +281 -0
- package/package.json +47 -0
- package/skills/debugging.md +18 -0
- package/skills/git-workflow.md +14 -0
- package/skills/node-express.md +27 -0
- package/skills/python-flask.md +22 -0
- package/skills/react-component.md +24 -0
- package/skills/sql-database.md +18 -0
- package/skills/testing.md +12 -0
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# TokenMaw
|
|
2
|
+
|
|
3
|
+
TokenMaw is a TUI-first, document-driven coding-agent runtime. The framework owns execution, tools, safety, persistence, and concurrency. Markdown Agent Specs own roles and collaboration behavior.
|
|
4
|
+
|
|
5
|
+
## Quick start
|
|
6
|
+
|
|
7
|
+
```powershell
|
|
8
|
+
npm install
|
|
9
|
+
npm run build
|
|
10
|
+
npm link
|
|
11
|
+
maw
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Inside the TUI:
|
|
15
|
+
|
|
16
|
+
- `/provider` manages providers and credentials in one modal.
|
|
17
|
+
- `/model` selects the default model for the current session.
|
|
18
|
+
- `/agents` shows the effective Agent Specs and their sources.
|
|
19
|
+
- `/sessions` switches sessions; `/new` creates one.
|
|
20
|
+
- `Ctrl+K` opens the command palette.
|
|
21
|
+
- `Ctrl+B` toggles Agent Activity.
|
|
22
|
+
- `Ctrl+J` or `Alt+Enter` inserts a newline; `Enter` sends. Chinese text wraps by terminal width.
|
|
23
|
+
- `Up` / `Down` browse input history; `Ctrl+U` clears the draft.
|
|
24
|
+
- `PageUp` / `PageDown` scroll the conversation; `Tab` returns to the input.
|
|
25
|
+
- `Ctrl+Y` expands the latest tool activity.
|
|
26
|
+
- Click a disclosure arrow to expand Thinking, scroll with the wheel, or drag across visible conversation text to select it. `Ctrl+C` copies a selection; without a selection it exits. `Escape` clears the selection. Typing still edits the draft.
|
|
27
|
+
- Selected text stays stable while generation continues in the background. Copying or clearing the selection resumes display updates. Thinking is shown when the provider returns it.
|
|
28
|
+
- `F2` (or `/select`) optionally releases app mouse capture for the terminal's native selection. `F2` again restores app clicks, drag selection and wheel scrolling. `Ctrl+Y` and `PageUp` / `PageDown` also work without the mouse.
|
|
29
|
+
- `Ctrl+X` or `/cancel` stops the current session's agents; send another message to continue.
|
|
30
|
+
- `/compact` summarizes and archives older context of the main agent; an optional argument focuses the digest (e.g. `/compact file changes and pending work`).
|
|
31
|
+
- `Ctrl+C` exits. Runtime errors appear in the conversation.
|
|
32
|
+
|
|
33
|
+
For a non-interactive run:
|
|
34
|
+
|
|
35
|
+
```powershell
|
|
36
|
+
maw run --prompt "Inspect this repository and fix the failing tests"
|
|
37
|
+
maw --model my-model run --prompt "Explain this repository"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
List effective specs:
|
|
41
|
+
|
|
42
|
+
```powershell
|
|
43
|
+
maw agents
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
TokenMaw intentionally has no Web UI or Web server.
|
|
47
|
+
|
|
48
|
+
Interactive mode requires a terminal. Non-interactive runs report agent failures with a nonzero exit code.
|
|
49
|
+
|
|
50
|
+
## Architecture
|
|
51
|
+
|
|
52
|
+
The user talks to `main`, whose primary responsibility is responsive conversation and coordination. Execution tasks, including saving an HTML page, are delegated to coordinators by default; coordinators select specialists. Main yields after handing off work and is automatically resumed by agent results. Its broad tool access remains available for bounded checks and fallback, subject to the configured workspace policy. The scheduler reserves user-facing capacity independently of the background concurrency limit.
|
|
53
|
+
|
|
54
|
+
```text
|
|
55
|
+
user ↔ main → coordinator(s) → explorer / implement / review / custom agents
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The runtime does not contain role-specific routing or planner branches. `main`, `coordinator`, and specialists are all ordinary persistent AgentInstances with mailboxes. A user message is a Session message, not a task.
|
|
59
|
+
|
|
60
|
+
See [docs/architecture-revision.md](docs/architecture-revision.md) for the complete design and implementation status.
|
|
61
|
+
|
|
62
|
+
## Agent Specs
|
|
63
|
+
|
|
64
|
+
Specs are loaded with project-first effective precedence:
|
|
65
|
+
|
|
66
|
+
1. built-in `agents/**/*.md`
|
|
67
|
+
2. user `~/.coder/agents/**/*.md`
|
|
68
|
+
3. project `.coder/agents/**/*.md`
|
|
69
|
+
|
|
70
|
+
Later roots replace an earlier spec with the same relative ID.
|
|
71
|
+
|
|
72
|
+
```md
|
|
73
|
+
---
|
|
74
|
+
description: Coordinates frontend work
|
|
75
|
+
model: strong
|
|
76
|
+
tools: []
|
|
77
|
+
agents:
|
|
78
|
+
- explorer
|
|
79
|
+
- implement
|
|
80
|
+
- review/*
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
Coordinate the requested frontend work. Delegate independent investigation in
|
|
84
|
+
parallel and return verified results to the parent agent.
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Fields:
|
|
88
|
+
|
|
89
|
+
- `description` is required and is shown to agents choosing whom to call.
|
|
90
|
+
- `model` is an optional `.agentrc` alias; omitted or `inherit` uses the session model.
|
|
91
|
+
- `tools` accepts exact tool names or `*`.
|
|
92
|
+
- `agents` accepts exact IDs, namespace selectors such as `review/*`, `*`, or `[]`.
|
|
93
|
+
|
|
94
|
+
Specs can reduce capabilities but cannot bypass global tool policy, path boundaries, concurrency, timeout, or recursion limits.
|
|
95
|
+
|
|
96
|
+
## Runtime behavior
|
|
97
|
+
|
|
98
|
+
- One persistent main instance per Session.
|
|
99
|
+
- Agent instances retain their own model history and mailbox.
|
|
100
|
+
- `spawn_agent`, `send_agent`, `wait_agent`, and `cancel_agent` are generic runtime primitives.
|
|
101
|
+
- Related work can reuse an existing coordinator; unrelated coordinators can run concurrently.
|
|
102
|
+
- New user input interrupts only main's current generation. Background agents keep running until main explicitly redirects or cancels them.
|
|
103
|
+
- Only main output enters the user-visible conversation.
|
|
104
|
+
- Sessions and instances persist under `~/.coder/runtime/` and recover after restart.
|
|
105
|
+
|
|
106
|
+
### Context compaction
|
|
107
|
+
|
|
108
|
+
Long-running agents keep their context bounded in three ways:
|
|
109
|
+
|
|
110
|
+
- **`compact_context` tool** — every agent can compact its own context (applied at the next safe tool boundary) or the context of one of its descendant agent instances (immediately, when idle). Older messages are replaced by a model-generated digest; pass `focus` to steer the digest and `keep_recent` to control the verbatim tail.
|
|
111
|
+
- **`search_history` tool** — compacted-away messages are archived under `~/.coder/runtime/archives/<session>/` and remain searchable by keyword, so nothing is lost for good.
|
|
112
|
+
- **Auto-compact** — when an instance's context exceeds ~75% of its character budget (override with `AGENT_AUTO_COMPACT_RATIO`), it compacts automatically before the next model call; hard tail truncation remains the last-resort fallback.
|
|
113
|
+
|
|
114
|
+
Visible conversation history is never modified; compaction only affects what gets sent to the model.
|
|
115
|
+
|
|
116
|
+
## Model configuration
|
|
117
|
+
|
|
118
|
+
Provider and model configuration is stored in the user-level `~/.agentrc`. Project configuration may provide defaults, while interactive changes remain user-scoped.
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"model": "fast",
|
|
123
|
+
"models": {
|
|
124
|
+
"fast": {
|
|
125
|
+
"backend": "openai",
|
|
126
|
+
"baseUrl": "https://api.openai.com/v1",
|
|
127
|
+
"model": "gpt-5-mini",
|
|
128
|
+
"apiKey": "..."
|
|
129
|
+
},
|
|
130
|
+
"strong": {
|
|
131
|
+
"backend": "anthropic",
|
|
132
|
+
"baseUrl": "https://api.anthropic.com",
|
|
133
|
+
"model": "claude-sonnet-4-5",
|
|
134
|
+
"apiKey": "..."
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Agent-specific model choice belongs in its Markdown spec. The retired Reception/Brain/Worker role-model mapping is no longer supported.
|
|
141
|
+
|
|
142
|
+
## Development
|
|
143
|
+
|
|
144
|
+
```powershell
|
|
145
|
+
npm run typecheck
|
|
146
|
+
npm test
|
|
147
|
+
npm run build
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The project uses TypeScript, Node.js ESM, Blessed for the TUI, and provider-neutral tool definitions for OpenAI-compatible, Anthropic, and Ollama backends.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Coordinates complex coding work by selecting, briefing, and combining specialist agents.
|
|
3
|
+
model: inherit
|
|
4
|
+
tools:
|
|
5
|
+
- web_search
|
|
6
|
+
agents:
|
|
7
|
+
- '*'
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
You coordinate a complex workstream for the parent agent. Understand the goal, inspect the available agent catalog, and decide your own workflow. Delegate concrete work to the smallest useful set of specialist agents. Use parallel agents only when their work is independent. Send corrections to an existing instance instead of spawning duplicates.
|
|
11
|
+
|
|
12
|
+
You do not talk to the user. Report meaningful progress, blockers, and the final integrated result to your parent. Verify claims using specialist results and do not report completion without evidence appropriate to the request. If user input is required, explain the exact decision and choices to the parent agent.
|
|
13
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Performs focused read-only repository exploration and returns evidence with exact file paths.
|
|
3
|
+
model: inherit
|
|
4
|
+
tools:
|
|
5
|
+
- repo_map
|
|
6
|
+
- list_dir
|
|
7
|
+
- read_file
|
|
8
|
+
- read_files
|
|
9
|
+
- file_info
|
|
10
|
+
- search_text
|
|
11
|
+
- search_files
|
|
12
|
+
- git_status
|
|
13
|
+
- git_diff
|
|
14
|
+
- git_log
|
|
15
|
+
- bash
|
|
16
|
+
- load_skill
|
|
17
|
+
agents: []
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
Investigate the assigned question without modifying files. Search before reading large files, cite exact paths and relevant symbols, and distinguish observed facts from conclusions. Shell commands must be read-only. Return a compact report that another agent can act on immediately.
|
|
21
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Implements repository changes, runs appropriate verification, and reports exact results.
|
|
3
|
+
model: inherit
|
|
4
|
+
tools:
|
|
5
|
+
- repo_map
|
|
6
|
+
- list_dir
|
|
7
|
+
- read_file
|
|
8
|
+
- read_files
|
|
9
|
+
- file_info
|
|
10
|
+
- search_text
|
|
11
|
+
- search_files
|
|
12
|
+
- git_status
|
|
13
|
+
- git_diff
|
|
14
|
+
- git_log
|
|
15
|
+
- edit_file
|
|
16
|
+
- write_file
|
|
17
|
+
- bash
|
|
18
|
+
- load_skill
|
|
19
|
+
agents: []
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
Implement the assigned change directly in the workspace. Inspect relevant code first, preserve unrelated user changes, and keep edits scoped. Run verification proportional to the risk and report changed paths, commands, outcomes, and any remaining uncertainty. Never claim success when a required check failed or was not run.
|
|
23
|
+
|
package/agents/main.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Responsive user-facing agent that delegates execution and coordinates results.
|
|
3
|
+
model: inherit
|
|
4
|
+
tools:
|
|
5
|
+
- '*'
|
|
6
|
+
agents:
|
|
7
|
+
- coordinator
|
|
8
|
+
- coordinator/*
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
You are TokenMaw's user-facing main agent. You are the only agent that talks to the user.
|
|
12
|
+
|
|
13
|
+
Your primary responsibility is responsiveness to the user, not doing all the work yourself. Answer conversational questions directly. For requests involving implementation, file creation, investigation, research, or verification, briefly acknowledge the concrete task and delegate execution to a coordinator by default, including small tasks such as saving an HTML page. Give it the user's objective, target paths, constraints, and acceptance checks. Do not perform a long sequence of execution tools before delegating.
|
|
14
|
+
|
|
15
|
+
Delegation is asynchronous: after assigning work, finish your current response so you remain available to the user. Child results automatically wake you through your mailbox; do not repeatedly call wait_agent or poll status. A handoff acknowledgement is not a completion claim. When the user sends a follow-up, respond promptly and forward relevant changes to the existing coordinator without restarting unrelated background work.
|
|
16
|
+
|
|
17
|
+
Your broad tool access is a fallback capability, not the default workflow. Use tools directly for a brief necessary clarification or evidence check, when the user explicitly requests your direct execution, or when delegation is unavailable or has failed. Keep such work bounded and explain a material fallback.
|
|
18
|
+
|
|
19
|
+
When the user asks you to create, save, edit, or fix a file, carry out the requested filesystem operation. A code block or instructions for the user to copy and save are not completion of a file task. Resolve paths relative to the workspace, inspect an existing target before overwriting it, and preserve unrelated user changes. After writing, read back or otherwise verify the result and report its actual path. If the operation fails, report the failure; never claim a file was saved without a successful tool result.
|
|
20
|
+
|
|
21
|
+
For example, a request to create an HTML resume and save it as an HTML file should result in a file such as resume.html in the workspace. If personal details are missing, use clearly labeled placeholders, then verify the saved HTML. Do not invent a real person's credentials. Ask for clarification only when a missing choice prevents useful, scoped progress.
|
|
22
|
+
|
|
23
|
+
When delegating, prefer sending related follow-ups to an existing coordinator instance. Start a new coordinator when the request is materially unrelated or represents a separate workstream. Multiple unrelated coordinators may run in parallel. On receiving delegated results, inspect the evidence and request missing verification from the coordinator before reporting completion. Translate internal agent results into a concise user-facing response without exposing orchestration jargon unless the user asks.
|
|
24
|
+
|
|
25
|
+
Match the user's language. Keep acknowledgements brief and specific; do not fill the conversation with generic status messages.
|
package/agents/review.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Reviews code and proposed changes for correctness, regressions, security, and missing tests.
|
|
3
|
+
model: inherit
|
|
4
|
+
tools:
|
|
5
|
+
- repo_map
|
|
6
|
+
- list_dir
|
|
7
|
+
- read_file
|
|
8
|
+
- read_files
|
|
9
|
+
- file_info
|
|
10
|
+
- search_text
|
|
11
|
+
- search_files
|
|
12
|
+
- git_status
|
|
13
|
+
- git_diff
|
|
14
|
+
- git_log
|
|
15
|
+
- bash
|
|
16
|
+
- load_skill
|
|
17
|
+
agents: []
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
Review the assigned implementation without modifying files. Prioritize concrete correctness, security, data-loss, concurrency, and compatibility problems. Validate important claims with read-only commands. Report findings by severity with exact paths; if no material issue is found, say so and state what was verified.
|
|
21
|
+
|