@tesselate-digital/notion-agent-hive 0.0.7 → 0.0.9
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 +24 -194
- package/dist/agents/shared.d.ts +44 -0
- package/dist/index.js +191 -126
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/logo.png" alt="Notion Agent Hive" width="400">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
1
5
|
# notion-agent-hive
|
|
2
6
|
|
|
3
7
|
**Persistent memory for AI coding sessions using Notion.**
|
|
4
8
|
|
|
5
9
|
## Why this exists
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
Like many, I've been using LLMs extensively, in every flavour, and with all sorts of harnesses (Claude code, Codex, Copilot, etc.)
|
|
12
|
+
|
|
13
|
+
While they can be wildly effective, I found some limitations in my workflow:
|
|
8
14
|
|
|
9
|
-
**
|
|
15
|
+
**Form factor** CLIs can be a bit clunky to collect one's thoughts. I love to write, edit, revisit, add structure through headers and richer markup ... Command line doesn't feel like the best place for that.
|
|
10
16
|
|
|
11
17
|
**You lose track of what actually happened.** When working on larger features that take time, you often switch between your agent and other tasks. Coming back later, it's hard to trace what happened and what the agent was working on. You get a "done!" checklist but lose the 200k tokens of reasoning behind it, leaving you wondering what was actually discussed and implemented.
|
|
12
18
|
|
|
13
|
-
**
|
|
19
|
+
**Sessions die at the worst time.** Especially when Anthropic cuts your plan allowance. The plan and logs live somewhere in some temp folder, you could do some digging, fire opencode, and let it handle the context all over again, but this is a bit awkward and wasteful.
|
|
20
|
+
|
|
21
|
+
**Limited task horizon.** Models' performance tend to degrade far below their max context size. I found it hard to reliably tackle more ambitious features because of it. Harnesses _may_ compact, or _may_ use subagents, which can help, but feels like a roll of dice. Being diligent, going through plan -> execute loops helps too, but then you're still facing issues 1-3 in this list.
|
|
14
22
|
|
|
15
23
|
## What this does
|
|
16
24
|
|
|
17
|
-
|
|
25
|
+
This uses Notion as a persistent memory layer and source of truth. Every feature gets:
|
|
18
26
|
|
|
19
27
|
- A dedicated Notion page with the full plan, decisions, and reasoning
|
|
20
28
|
- An inline kanban board with detailed task tickets
|
|
21
29
|
- Context that persists across sessions and tools
|
|
22
30
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- **You might already be using it at work** - You can easily link the wider context, specs, or designs to the notion agent
|
|
26
|
-
- **Pick up where you left off instantly** - Any agent can read tickets and continue, no chat history needed
|
|
27
|
-
- **Review what actually happened** - See plans, decisions, and reasoning without digging through conversation logs
|
|
28
|
-
|
|
29
|
-
## How It Works
|
|
30
|
-
|
|
31
|
-
A coordinator manages three specialized subagents through a shared Notion board:
|
|
31
|
+
Under the hood, the tool will synchronise a few specialised subagents:
|
|
32
32
|
|
|
33
33
|
| Agent | Role |
|
|
34
34
|
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
@@ -37,29 +37,17 @@ A coordinator manages three specialized subagents through a shared Notion board:
|
|
|
37
37
|
| **Executor** | Implements code for the specific ticket assigned by the Coordinator. Writes findings/work summaries on that ticket, then reports back; does not route itself to other tasks. |
|
|
38
38
|
| **Reviewer** | Verifies implementations against acceptance criteria. Gates tasks for human review before they can be marked done. |
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
InTest -->|"Reviewer approves"| HumanReview["Human Review"]
|
|
48
|
-
InTest -->|"Reviewer rejects"| ToDo
|
|
49
|
-
HumanReview -->|"Human approves"| Done
|
|
50
|
-
HumanReview -->|"Human requests changes"| ToDo
|
|
51
|
-
|
|
52
|
-
style Done fill:#2ecc71,color:#fff
|
|
53
|
-
style HumanReview fill:#9b59b6,color:#fff
|
|
54
|
-
style InTest fill:#e67e22,color:#fff
|
|
55
|
-
style InProgress fill:#f1c40f,color:#000
|
|
56
|
-
style ToDo fill:#3498db,color:#fff
|
|
57
|
-
style Backlog fill:#95a5a6,color:#fff
|
|
58
|
-
```
|
|
40
|
+
It's quite flexible. Fire it with a rough idea, either inline or in a Notion page, and it will interactively create a plan. Give it an existing plan in Notion, and it will resume the work. Just like that, you get:
|
|
41
|
+
|
|
42
|
+
- **A proper space to think.** Notion pages with headers, tables, and structure. Each step becomes a ticket on a board with rich context, not a checklist item in a terminal.
|
|
43
|
+
- **A proper space to review.** Leave comments on specific parts of the plan. Add notes. Give feedback where it matters, not in a chat thread that scrolls away.
|
|
44
|
+
- **A proper space to supervise.** The board shows you exactly where everything stands at a glance.
|
|
45
|
+
|
|
46
|
+
Each task runs with a fresh context, so you stay in the sweet spot where models perform best. When you want to review what an agent did, just look at the ticket: the work summary and QA report are right there.
|
|
59
47
|
|
|
60
|
-
|
|
48
|
+
It also saves money. You can assign a strong model for planning, a fast one for coordination, and a cheaper one for execution, since the thinking has already been done.
|
|
61
49
|
|
|
62
|
-
|
|
50
|
+
I'm still toying with different configurations, but had some good results using chatGPT 5.4 mini as the fast coordinator, chatGPT 5.4 (With high effort) or opus 4.6 as the thinker/reviewer, and at this point anything "Not considered SOTA but still good" like KIMI K2.5, GLM-5, or Devstral as the executor, where most of the tokens are spent.
|
|
63
51
|
|
|
64
52
|
## Installation
|
|
65
53
|
|
|
@@ -80,92 +68,6 @@ This command:
|
|
|
80
68
|
- A Notion workspace with an [integration/API token](https://www.notion.so/my-integrations)
|
|
81
69
|
- The [Notion MCP server](https://github.com/makenotion/notion-mcp-server) configured in OpenCode
|
|
82
70
|
|
|
83
|
-
### Local Development
|
|
84
|
-
|
|
85
|
-
If you're developing from this repo instead of installing a published npm package, use a local plugin file.
|
|
86
|
-
|
|
87
|
-
OpenCode auto-loads `.ts` plugin files from `~/.config/opencode/plugins/` (or `$OPENCODE_CONFIG_DIR/plugins` / `$XDG_CONFIG_HOME/opencode/plugins` if you use those).
|
|
88
|
-
|
|
89
|
-
1. Build the plugin bundle:
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
bun install
|
|
93
|
-
bun build src/index.ts --outdir dist --target bun --format esm
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
2. Create `~/.config/opencode/plugins/notion-agent-hive.ts`:
|
|
97
|
-
|
|
98
|
-
```ts
|
|
99
|
-
import { NotionAgentHivePlugin } from "/absolute/path/to/notion-agent-hive/dist/index.js";
|
|
100
|
-
|
|
101
|
-
export { NotionAgentHivePlugin };
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
3. Create `~/.config/opencode/notion-agent-hive.json` to choose models for each internal agent:
|
|
105
|
-
|
|
106
|
-
```json
|
|
107
|
-
{
|
|
108
|
-
"agents": {
|
|
109
|
-
"coordinator": { "model": "openai/gpt-5.2" },
|
|
110
|
-
"thinker": { "model": "openai/gpt-5.4", "variant": "xhigh" },
|
|
111
|
-
"executor": { "model": "kimi-for-coding/k2p5" },
|
|
112
|
-
"reviewer": { "model": "openai/gpt-5.4", "variant": "xhigh" }
|
|
113
|
-
},
|
|
114
|
-
"fallback": {
|
|
115
|
-
"enabled": true,
|
|
116
|
-
"chains": {}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
4. Configure your Notion MCP server in `~/.config/opencode/opencode.json` if you haven't already:
|
|
122
|
-
|
|
123
|
-
```json
|
|
124
|
-
{
|
|
125
|
-
"mcp": {
|
|
126
|
-
"notion": {
|
|
127
|
-
"type": "remote",
|
|
128
|
-
"url": "https://mcp.notion.com/mcp"
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
5. Restart OpenCode.
|
|
135
|
-
6. Start a session with the `notion agent hive` agent.
|
|
136
|
-
|
|
137
|
-
When you change plugin source, rebuild `dist/index.js` so OpenCode picks up the new code.
|
|
138
|
-
|
|
139
|
-
### Published Package
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
bunx @tesselate-digital/notion-agent-hive install
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
This command:
|
|
146
|
-
|
|
147
|
-
1. Adds `@tesselate-digital/notion-agent-hive` to the `plugin` array in `~/.config/opencode/opencode.json` (or `$OPENCODE_CONFIG_DIR/opencode.json` / `$XDG_CONFIG_HOME/opencode/opencode.json`)
|
|
148
|
-
2. Creates a `~/.config/opencode/notion-agent-hive.json` starter config (or the matching `$OPENCODE_CONFIG_DIR` / `$XGD_CONFIG_HOME` location)
|
|
149
|
-
|
|
150
|
-
If you want per-project overrides, create `notion-agent-hive.json` in the project root manually.
|
|
151
|
-
|
|
152
|
-
Then configure your Notion MCP server in `~/.config/opencode/opencode.json` if you haven't already:
|
|
153
|
-
|
|
154
|
-
```json
|
|
155
|
-
{
|
|
156
|
-
"mcp": {
|
|
157
|
-
"notion": {
|
|
158
|
-
"type": "npx",
|
|
159
|
-
"command": "npx",
|
|
160
|
-
"args": ["-y", "@notionhq/notion-mcp-server"],
|
|
161
|
-
"env": {
|
|
162
|
-
"OPENAPI_MCP_HEADERS": "{\"Authorization\": \"Bearer YOUR_NOTION_TOKEN\"}"
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
```
|
|
168
|
-
|
|
169
71
|
### Configuring Models
|
|
170
72
|
|
|
171
73
|
There are two places to configure models, merged at startup:
|
|
@@ -177,15 +79,7 @@ There are two places to configure models, merged at startup:
|
|
|
177
79
|
|
|
178
80
|
Project config takes precedence. Agent keys are merged individually — setting `thinker` in the project config does not wipe out `executor` from your global config.
|
|
179
81
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
Model IDs use the `provider/model-name` format that OpenCode uses — any provider configured in your OpenCode setup works here.
|
|
185
|
-
|
|
186
|
-
The public agent name is `notion agent hive`, but the model config key is still `coordinator`.
|
|
187
|
-
|
|
188
|
-
The `$schema` path depends on how you installed the plugin. For local development or global config, it's simplest to omit `$schema`.
|
|
82
|
+
Example config:
|
|
189
83
|
|
|
190
84
|
```json
|
|
191
85
|
{
|
|
@@ -198,27 +92,7 @@ The `$schema` path depends on how you installed the plugin. For local developmen
|
|
|
198
92
|
}
|
|
199
93
|
```
|
|
200
94
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
| Agent | Role | Suggested model profile |
|
|
204
|
-
| --------------- | ------------------------------------ | ----------------------------------------------------------- |
|
|
205
|
-
| **coordinator** | Dispatches agents, moves tickets | Fast and cheap — it mostly routes, not thinks |
|
|
206
|
-
| **thinker** | Deep research, feature decomposition | Most capable model you have — this is where quality matters |
|
|
207
|
-
| **executor** | Code implementation | Balanced — good at coding tasks |
|
|
208
|
-
| **reviewer** | QA verification, criteria checking | Same tier as executor |
|
|
209
|
-
|
|
210
|
-
#### Variants
|
|
211
|
-
|
|
212
|
-
Some providers support model-specific variants such as `"xhigh"` or `"max"`:
|
|
213
|
-
|
|
214
|
-
```json
|
|
215
|
-
{
|
|
216
|
-
"agents": {
|
|
217
|
-
"thinker": { "model": "openai/gpt-5.4", "variant": "xhigh" },
|
|
218
|
-
"reviewer": { "model": "anthropic/claude-opus-4", "variant": "max" }
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
```
|
|
95
|
+
Restart OpenCode for changes to take effect.
|
|
222
96
|
|
|
223
97
|
#### Fallback chains
|
|
224
98
|
|
|
@@ -253,47 +127,3 @@ You can also pass the full chain directly as the `model` value — the first ent
|
|
|
253
127
|
}
|
|
254
128
|
}
|
|
255
129
|
```
|
|
256
|
-
|
|
257
|
-
### Usage
|
|
258
|
-
|
|
259
|
-
1. Open OpenCode and start a session with the **notion agent hive** agent
|
|
260
|
-
2. Describe the feature you want to build
|
|
261
|
-
3. The Coordinator dispatches the Thinker, who interrogates you, explores your codebase, and creates the Notion feature page + task board
|
|
262
|
-
4. Say **"execute"** and the Coordinator dispatches tasks to the Executor, runs them through the Reviewer, and surfaces completed work for your review
|
|
263
|
-
5. Review tasks in the **Human Review** column and move them to **Done**, or send them back with comments
|
|
264
|
-
|
|
265
|
-
You can close your session at any point. When you come back, point the Coordinator at the same Notion board and pick up where you left off.
|
|
266
|
-
|
|
267
|
-
---
|
|
268
|
-
|
|
269
|
-
<details>
|
|
270
|
-
<summary><strong>Technical Details</strong></summary>
|
|
271
|
-
|
|
272
|
-
### Repository Structure
|
|
273
|
-
|
|
274
|
-
```
|
|
275
|
-
notion-agent-hive/
|
|
276
|
-
├── src/
|
|
277
|
-
│ ├── agents/
|
|
278
|
-
│ │ ├── types.ts # AgentDefinition + AgentConfig interfaces
|
|
279
|
-
│ │ ├── coordinator.ts # notion agent hive agent factory
|
|
280
|
-
│ │ ├── thinker.ts # notion-thinker agent factory
|
|
281
|
-
│ │ ├── executor.ts # notion-executor agent factory
|
|
282
|
-
│ │ └── reviewer.ts # notion-reviewer agent factory
|
|
283
|
-
│ ├── cli/
|
|
284
|
-
│ │ ├── index.ts # CLI entry point
|
|
285
|
-
│ │ └── install.ts # install command
|
|
286
|
-
│ ├── config.ts # Config loading + Zod validation
|
|
287
|
-
│ ├── fallback.ts # Runtime model fallback manager
|
|
288
|
-
│ └── index.ts # Plugin entry point + public API
|
|
289
|
-
├── schema.json # JSON Schema for notion-agent-hive.json
|
|
290
|
-
├── biome.json
|
|
291
|
-
├── tsconfig.json
|
|
292
|
-
└── package.json
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
### MCP Requirements
|
|
296
|
-
|
|
297
|
-
Only the **Notion MCP server** is required. No other MCP servers are mandatory for core functionality.
|
|
298
|
-
|
|
299
|
-
</details>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kanban database schema for feature boards.
|
|
3
|
+
* Used by coordinator when creating new boards.
|
|
4
|
+
*/
|
|
5
|
+
export declare const KANBAN_SCHEMA = "```sql\nCREATE TABLE (\n \"Task\" TITLE,\n \"Status\" SELECT('Backlog':default, 'To Do':blue, 'In Progress':yellow, 'Needs Human Input':red, 'In Test':orange, 'Human Review':purple, 'Done':green),\n \"Priority\" SELECT('Critical':red, 'High':orange, 'Medium':yellow, 'Low':green),\n \"Depends On\" RICH_TEXT,\n \"Complexity\" SELECT('Small':green, 'Medium':yellow, 'Large':red),\n \"Notes\" RICH_TEXT\n)\n```";
|
|
6
|
+
/**
|
|
7
|
+
* Status transition rules. Coordinator is the sole agent responsible for all transitions.
|
|
8
|
+
*/
|
|
9
|
+
export declare const STATUS_TRANSITIONS = "| Transition | Condition |\n|---|---|\n| Backlog \u2192 To Do | Thinker sets during plan creation, or coordinator adjusts |\n| To Do \u2192 In Progress | When dispatching executor |\n| In Progress \u2192 In Test | Executor reports `READY_FOR_TEST` |\n| In Test \u2192 Human Review | Reviewer reports `PASS` |\n| In Test \u2192 To Do | Reviewer reports `FAIL` |\n| Any \u2192 Needs Human Input | Ambiguity escalation |\n| Human Review \u2192 Done | **Human only**, final sign-off |\n| Human Review \u2192 To Do | Human requests changes |";
|
|
10
|
+
/**
|
|
11
|
+
* Board permissions by agent role.
|
|
12
|
+
* Single source of truth referenced by all agents.
|
|
13
|
+
*/
|
|
14
|
+
export declare const BOARD_PERMISSIONS: {
|
|
15
|
+
coordinator: {
|
|
16
|
+
summary: string;
|
|
17
|
+
allowed: string[];
|
|
18
|
+
forbidden: string[];
|
|
19
|
+
};
|
|
20
|
+
executor: {
|
|
21
|
+
summary: string;
|
|
22
|
+
allowed: string[];
|
|
23
|
+
forbidden: string[];
|
|
24
|
+
};
|
|
25
|
+
reviewer: {
|
|
26
|
+
summary: string;
|
|
27
|
+
allowed: string[];
|
|
28
|
+
forbidden: string[];
|
|
29
|
+
};
|
|
30
|
+
thinker: {
|
|
31
|
+
summary: string;
|
|
32
|
+
allowed: string[];
|
|
33
|
+
forbidden: string[];
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Generates a thinker dispatch instruction block.
|
|
38
|
+
* Consolidates boilerplate across PLAN_FEATURE, PLAN_FROM_DRAFT, INVESTIGATE, REFINE_TASK.
|
|
39
|
+
*/
|
|
40
|
+
export declare function formatThinkerDispatch(type: "PLAN_FEATURE" | "PLAN_FROM_DRAFT" | "INVESTIGATE" | "REFINE_TASK"): string;
|
|
41
|
+
/**
|
|
42
|
+
* Board permissions summary for subagent prompts.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getBoardPermissionsBlock(role: keyof typeof BOARD_PERMISSIONS): string;
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,129 @@ var __export = (target, all) => {
|
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
// src/agents/shared.ts
|
|
18
|
+
var KANBAN_SCHEMA = `\`\`\`sql
|
|
19
|
+
CREATE TABLE (
|
|
20
|
+
"Task" TITLE,
|
|
21
|
+
"Status" SELECT('Backlog':default, 'To Do':blue, 'In Progress':yellow, 'Needs Human Input':red, 'In Test':orange, 'Human Review':purple, 'Done':green),
|
|
22
|
+
"Priority" SELECT('Critical':red, 'High':orange, 'Medium':yellow, 'Low':green),
|
|
23
|
+
"Depends On" RICH_TEXT,
|
|
24
|
+
"Complexity" SELECT('Small':green, 'Medium':yellow, 'Large':red),
|
|
25
|
+
"Notes" RICH_TEXT
|
|
26
|
+
)
|
|
27
|
+
\`\`\``;
|
|
28
|
+
var STATUS_TRANSITIONS = `| Transition | Condition |
|
|
29
|
+
|---|---|
|
|
30
|
+
| Backlog \u2192 To Do | Thinker sets during plan creation, or coordinator adjusts |
|
|
31
|
+
| To Do \u2192 In Progress | When dispatching executor |
|
|
32
|
+
| In Progress \u2192 In Test | Executor reports \`READY_FOR_TEST\` |
|
|
33
|
+
| In Test \u2192 Human Review | Reviewer reports \`PASS\` |
|
|
34
|
+
| In Test \u2192 To Do | Reviewer reports \`FAIL\` |
|
|
35
|
+
| Any \u2192 Needs Human Input | Ambiguity escalation |
|
|
36
|
+
| Human Review \u2192 Done | **Human only**, final sign-off |
|
|
37
|
+
| Human Review \u2192 To Do | Human requests changes |`;
|
|
38
|
+
var BOARD_PERMISSIONS = {
|
|
39
|
+
coordinator: {
|
|
40
|
+
summary: "Full board control. Creates pages, databases, tickets. Handles ALL status transitions.",
|
|
41
|
+
allowed: ["create pages/databases/tickets", "all status transitions", "update ticket properties"],
|
|
42
|
+
forbidden: ["implementing code", "deep research"]
|
|
43
|
+
},
|
|
44
|
+
executor: {
|
|
45
|
+
summary: "Limited board access. Read context, write findings on assigned ticket only.",
|
|
46
|
+
allowed: ["read board/ticket context", "write implementation notes on assigned ticket page"],
|
|
47
|
+
forbidden: ["moving tasks between statuses", "creating/deleting tickets", "scanning board for next task"]
|
|
48
|
+
},
|
|
49
|
+
reviewer: {
|
|
50
|
+
summary: "Read-only for source code. Can move In Test \u2192 Human Review on PASS verdict.",
|
|
51
|
+
allowed: ["read board/ticket context", "write QA findings on ticket page"],
|
|
52
|
+
forbidden: ["moving to Done (human only)", "moving to To Do/In Progress", "creating/deleting tickets"]
|
|
53
|
+
},
|
|
54
|
+
thinker: {
|
|
55
|
+
summary: "Read-only Notion access. Returns reports; coordinator handles all writes.",
|
|
56
|
+
allowed: ["read Notion pages for context"],
|
|
57
|
+
forbidden: ["create/update/delete anything in Notion", "move tickets", "dispatch subagents"]
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
function formatThinkerDispatch(type) {
|
|
61
|
+
const headers = {
|
|
62
|
+
PLAN_FEATURE: "You are being dispatched to research and plan a feature.",
|
|
63
|
+
PLAN_FROM_DRAFT: "You are being dispatched to convert a user's draft into a structured feature plan.",
|
|
64
|
+
INVESTIGATE: "You are being dispatched to investigate an issue.",
|
|
65
|
+
REFINE_TASK: "You are being dispatched to refine a task specification."
|
|
66
|
+
};
|
|
67
|
+
const contexts = {
|
|
68
|
+
PLAN_FEATURE: `BOARD_CONTEXT:
|
|
69
|
+
thinking_board_id: <page ID>
|
|
70
|
+
existing_context: <any relevant board state, or "new board">
|
|
71
|
+
|
|
72
|
+
USER_REQUEST:
|
|
73
|
+
<verbatim user request>`,
|
|
74
|
+
PLAN_FROM_DRAFT: `BOARD_CONTEXT:
|
|
75
|
+
thinking_board_id: <page ID>
|
|
76
|
+
draft_page_id: <same page ID, or child page if draft is nested>
|
|
77
|
+
|
|
78
|
+
USER_DRAFT_CONTENT:
|
|
79
|
+
<full content extracted from the Notion page>
|
|
80
|
+
|
|
81
|
+
USER_REQUEST:
|
|
82
|
+
<any additional instructions from the user, or "Convert this draft into a thinking board">`,
|
|
83
|
+
INVESTIGATE: `BOARD_CONTEXT:
|
|
84
|
+
thinking_board_id: <page ID>
|
|
85
|
+
task_page_id: <page ID of the affected task>
|
|
86
|
+
|
|
87
|
+
QUESTION:
|
|
88
|
+
<specific question or problem to investigate>
|
|
89
|
+
|
|
90
|
+
CONTEXT:
|
|
91
|
+
<execution report, reviewer findings, human comments, or other relevant context>`,
|
|
92
|
+
REFINE_TASK: `BOARD_CONTEXT:
|
|
93
|
+
thinking_board_id: <page ID>
|
|
94
|
+
task_page_id: <page ID of the task to refine>
|
|
95
|
+
|
|
96
|
+
FEEDBACK:
|
|
97
|
+
<execution report, reviewer findings, or human comments>
|
|
98
|
+
|
|
99
|
+
CURRENT_SPECIFICATION:
|
|
100
|
+
<full current task page content>`
|
|
101
|
+
};
|
|
102
|
+
const instructions = {
|
|
103
|
+
PLAN_FEATURE: `Interrogate the user, explore the codebase, decompose into tasks.
|
|
104
|
+
Return a PLANNING_REPORT with the complete feature context and task specifications.
|
|
105
|
+
Do NOT create anything in Notion - just return the report.`,
|
|
106
|
+
PLAN_FROM_DRAFT: `The user has already done preliminary thinking. Your job is to:
|
|
107
|
+
1. Understand their intent, ideas, and any structure they've established
|
|
108
|
+
2. Ask clarifying questions if critical details are missing
|
|
109
|
+
3. Preserve their terminology and framing where sensible
|
|
110
|
+
4. Decompose into concrete, actionable tasks
|
|
111
|
+
5. Return a PLANNING_REPORT as usual
|
|
112
|
+
|
|
113
|
+
Do NOT discard or override the user's ideas. Build on them.
|
|
114
|
+
Do NOT create anything in Notion - just return the report.`,
|
|
115
|
+
INVESTIGATE: `Research the issue, explore the codebase, and return an INVESTIGATION_REPORT.
|
|
116
|
+
Do NOT modify Notion - just return the report.`,
|
|
117
|
+
REFINE_TASK: `Research the issue and return a REFINEMENT_REPORT with the updated specification.
|
|
118
|
+
Do NOT modify Notion - just return the report.`
|
|
119
|
+
};
|
|
120
|
+
return `\`\`\`
|
|
121
|
+
${headers[type]}
|
|
122
|
+
|
|
123
|
+
DISPATCH_TYPE: ${type}
|
|
124
|
+
|
|
125
|
+
${contexts[type]}
|
|
126
|
+
|
|
127
|
+
${instructions[type]}
|
|
128
|
+
\`\`\``;
|
|
129
|
+
}
|
|
130
|
+
function getBoardPermissionsBlock(role) {
|
|
131
|
+
const perms = BOARD_PERMISSIONS[role];
|
|
132
|
+
return `## Board Permissions
|
|
133
|
+
|
|
134
|
+
${perms.summary}
|
|
135
|
+
|
|
136
|
+
- **Allowed:** ${perms.allowed.join("; ")}
|
|
137
|
+
- **Forbidden:** ${perms.forbidden.join("; ")}`;
|
|
138
|
+
}
|
|
139
|
+
|
|
17
140
|
// src/agents/coordinator.ts
|
|
18
141
|
var COORDINATOR_PROMPT = `# Notion Agent Hive (Coordinator)
|
|
19
142
|
|
|
@@ -32,43 +155,55 @@ The coordinator is orchestration-only and must never implement code directly. It
|
|
|
32
155
|
|
|
33
156
|
## Communication Style
|
|
34
157
|
|
|
35
|
-
|
|
158
|
+
**TUI output (what the user sees in terminal):** Terse. Action + result only. No background, no reasoning, no "here's what I'm thinking". Examples:
|
|
159
|
+
- "Executor done, moving T-003 to In Test. Dispatching reviewer."
|
|
160
|
+
- "Thinker returned 4 tasks. Creating board."
|
|
161
|
+
- "T-001 blocked: missing API credentials. Moving to Needs Human Input."
|
|
36
162
|
|
|
37
|
-
|
|
38
|
-
- **Subagent dispatches**: Do not narrate. Just dispatch and report the verdict when it returns.
|
|
39
|
-
- **Board state**: Bullet list of tasks with status. No commentary unless something needs user attention.
|
|
40
|
-
- **Decisions**: State what you are doing, not why (unless the user asks or it is non-obvious).
|
|
41
|
-
- **Errors/escalations**: Be direct. "Task X blocked: missing API credentials. Need your input."
|
|
163
|
+
Do NOT say: "The executor has completed its work and reported that the implementation is ready. Based on this, I will now transition the ticket status and proceed to dispatch the review agent to verify the changes."
|
|
42
164
|
|
|
43
|
-
|
|
165
|
+
**Notion content (board, feature pages, tickets):** Exhaustive. The board is the source of truth for both humans and agents. A human should open the board after a week away and understand the feature. Agents load only the ticket content as context, so tickets must be self-contained with full specifications, acceptance criteria, and relevant background.
|
|
44
166
|
|
|
45
167
|
---
|
|
46
168
|
|
|
47
169
|
## Board Discovery
|
|
48
170
|
|
|
49
|
-
At the start of every conversation, determine the Thinking Board page ID and
|
|
171
|
+
At the start of every conversation, determine the Thinking Board page ID and classify the board state:
|
|
50
172
|
|
|
51
173
|
1. **Check the user's message first.** If the user included a Notion URL or page ID anywhere in their prompt (e.g., "create a board at https://notion.so/...", "restart the plan at abc123def", "continue from https://notion.so/..."), extract and use it directly. Notion URLs contain the page ID as the last segment (after the final \`-\` or as the trailing hex string). Do NOT ask the user to confirm a link they already gave you. A provided URL/ID is only an identifier for loading context/records; it is never permission to bypass the Thinker -> Executor -> Reviewer flow.
|
|
52
174
|
2. **Only if no URL or page ID is present** in the user's message, ask using AskHuman tool: *"What is the Notion page ID (or URL) of the Thinking Board where I should create feature pages?"*
|
|
53
175
|
|
|
54
176
|
Store the result as the **Thinking Board page ID** for the rest of the session. All feature sub-pages are created as children of this page.
|
|
55
177
|
|
|
178
|
+
### Board State Classification
|
|
179
|
+
|
|
180
|
+
After obtaining the page ID, fetch the page content via Notion MCP and classify it into one of three states:
|
|
181
|
+
|
|
182
|
+
| State | Detection | Action |
|
|
183
|
+
|-------|-----------|--------|
|
|
184
|
+
| **Empty Board** | Page has no content or only a title | Proceed to Plan Phase with user's request as new feature |
|
|
185
|
+
| **Existing Thinking Board** | Page contains a kanban database with Status column matching schema | Proceed to Session Resumption |
|
|
186
|
+
| **Draft Page** | Page contains content (text, lists, notes) but NO kanban database | Ask user: overwrite or create sibling? Then proceed to Draft Conversion |
|
|
187
|
+
|
|
188
|
+
### Draft Conversion
|
|
189
|
+
|
|
190
|
+
When the user points to a page containing their own draft ideas, notes, or planning content (but no kanban database):
|
|
191
|
+
|
|
192
|
+
1. **Ask the user** via AskHuman: *"This page has existing content. Should I: (A) Convert this page into the feature board (your draft becomes background context), or (B) Create a separate sibling page for the board and link back to your draft?"*
|
|
193
|
+
2. **Read the draft content** from the Notion page via MCP.
|
|
194
|
+
3. **Dispatch the thinker** with PLAN_FROM_DRAFT (see Plan Phase for dispatch template).
|
|
195
|
+
4. **Process the PLANNING_REPORT** as usual (create feature page, kanban database, task tickets).
|
|
196
|
+
5. **Create the board based on user's choice:**
|
|
197
|
+
- **(A) Convert this page**: Restructure it by moving draft content into a "Background" section, then add the kanban database.
|
|
198
|
+
- **(B) Create sibling**: Create a new feature page as a sibling, link to it from the draft page, preserve draft as-is.
|
|
199
|
+
|
|
56
200
|
---
|
|
57
201
|
|
|
58
202
|
## Kanban Database Schema
|
|
59
203
|
|
|
60
204
|
When creating a kanban database for a feature, create it as a separate database (child of the Thinking Board, sibling to the feature page). Link to it from the feature page. Use this schema:
|
|
61
205
|
|
|
62
|
-
|
|
63
|
-
CREATE TABLE (
|
|
64
|
-
"Task" TITLE,
|
|
65
|
-
"Status" SELECT('Backlog':default, 'To Do':blue, 'In Progress':yellow, 'Needs Human Input':red, 'In Test':orange, 'Human Review':purple, 'Done':green),
|
|
66
|
-
"Priority" SELECT('Critical':red, 'High':orange, 'Medium':yellow, 'Low':green),
|
|
67
|
-
"Depends On" RICH_TEXT,
|
|
68
|
-
"Complexity" SELECT('Small':green, 'Medium':yellow, 'Large':red),
|
|
69
|
-
"Notes" RICH_TEXT
|
|
70
|
-
)
|
|
71
|
-
\`\`\`
|
|
206
|
+
${KANBAN_SCHEMA}
|
|
72
207
|
|
|
73
208
|
After creating the database, **always create a Board view** grouped by \`"Status"\` so the kanban is immediately usable.
|
|
74
209
|
|
|
@@ -78,20 +213,9 @@ After creating the database, **always create a Board view** grouped by \`"Status
|
|
|
78
213
|
|
|
79
214
|
You are the sole agent responsible for all status transitions:
|
|
80
215
|
|
|
81
|
-
|
|
82
|
-
|---|---|
|
|
83
|
-
| Backlog \u2192 To Do | Thinker sets during plan creation, or coordinator adjusts |
|
|
84
|
-
| To Do \u2192 In Progress | When dispatching executor |
|
|
85
|
-
| In Progress \u2192 In Test | Executor reports \`READY_FOR_TEST\` |
|
|
86
|
-
| In Test \u2192 Human Review | Reviewer reports \`PASS\` |
|
|
87
|
-
| In Test \u2192 To Do | Reviewer reports \`FAIL\` |
|
|
88
|
-
| Any \u2192 Needs Human Input | Ambiguity escalation |
|
|
89
|
-
| Human Review \u2192 Done | **Human only**, final sign-off |
|
|
90
|
-
| Human Review \u2192 To Do | Human requests changes |
|
|
216
|
+
${STATUS_TRANSITIONS}
|
|
91
217
|
|
|
92
|
-
No subagent moves tickets. You do ALL status transitions.
|
|
93
|
-
|
|
94
|
-
No agent may ever move a ticket to \`Done\`. Only the human user can.
|
|
218
|
+
No subagent moves tickets. You do ALL status transitions. No agent may ever move a ticket to \`Done\`. Only the human user can.
|
|
95
219
|
|
|
96
220
|
---
|
|
97
221
|
|
|
@@ -108,74 +232,23 @@ Default to dispatching the thinker. Only skip the thinker for genuinely trivial
|
|
|
108
232
|
|
|
109
233
|
### Dispatching the Thinker
|
|
110
234
|
|
|
111
|
-
The thinker researches and returns structured reports. You handle all Notion operations.
|
|
112
|
-
|
|
113
|
-
#### For Feature Planning (PLAN_FEATURE)
|
|
114
|
-
|
|
115
|
-
Spawn a \`notion-thinker\` subagent via the Task tool with this prefix:
|
|
116
|
-
|
|
117
|
-
\`\`\`
|
|
118
|
-
You are being dispatched to research and plan a feature.
|
|
119
|
-
|
|
120
|
-
DISPATCH_TYPE: PLAN_FEATURE
|
|
121
|
-
|
|
122
|
-
BOARD_CONTEXT:
|
|
123
|
-
thinking_board_id: <page ID>
|
|
124
|
-
existing_context: <any relevant board state, or "new board">
|
|
125
|
-
|
|
126
|
-
USER_REQUEST:
|
|
127
|
-
<verbatim user request>
|
|
128
|
-
|
|
129
|
-
Interrogate the user, explore the codebase, decompose into tasks.
|
|
130
|
-
Return a PLANNING_REPORT with the complete feature context and task specifications.
|
|
131
|
-
Do NOT create anything in Notion - just return the report.
|
|
132
|
-
\`\`\`
|
|
133
|
-
|
|
134
|
-
#### For Investigation (INVESTIGATE)
|
|
135
|
-
|
|
136
|
-
Used during execution when a task is blocked, partially complete, or failed review due to a design problem. Spawn a \`notion-thinker\` subagent with:
|
|
137
|
-
|
|
138
|
-
\`\`\`
|
|
139
|
-
You are being dispatched to investigate an issue.
|
|
140
|
-
|
|
141
|
-
DISPATCH_TYPE: INVESTIGATE
|
|
142
|
-
|
|
143
|
-
BOARD_CONTEXT:
|
|
144
|
-
thinking_board_id: <page ID>
|
|
145
|
-
task_page_id: <page ID of the affected task>
|
|
146
|
-
|
|
147
|
-
QUESTION:
|
|
148
|
-
<specific question or problem to investigate>
|
|
149
|
-
|
|
150
|
-
CONTEXT:
|
|
151
|
-
<execution report, reviewer findings, human comments, or other relevant context>
|
|
235
|
+
The thinker researches and returns structured reports. You handle all Notion operations. Spawn a \`notion-thinker\` subagent via the Task tool with the appropriate dispatch type:
|
|
152
236
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
237
|
+
#### PLAN_FEATURE
|
|
238
|
+
New feature research and decomposition.
|
|
239
|
+
${formatThinkerDispatch("PLAN_FEATURE")}
|
|
156
240
|
|
|
157
|
-
####
|
|
241
|
+
#### PLAN_FROM_DRAFT
|
|
242
|
+
Convert user's draft notes into a structured plan. Thinker builds on existing work.
|
|
243
|
+
${formatThinkerDispatch("PLAN_FROM_DRAFT")}
|
|
158
244
|
|
|
159
|
-
|
|
245
|
+
#### INVESTIGATE
|
|
246
|
+
Research a blocker, failure, or design problem during execution.
|
|
247
|
+
${formatThinkerDispatch("INVESTIGATE")}
|
|
160
248
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
DISPATCH_TYPE: REFINE_TASK
|
|
165
|
-
|
|
166
|
-
BOARD_CONTEXT:
|
|
167
|
-
thinking_board_id: <page ID>
|
|
168
|
-
task_page_id: <page ID of the task to refine>
|
|
169
|
-
|
|
170
|
-
FEEDBACK:
|
|
171
|
-
<execution report, reviewer findings, or human comments>
|
|
172
|
-
|
|
173
|
-
CURRENT_SPECIFICATION:
|
|
174
|
-
<full current task page content>
|
|
175
|
-
|
|
176
|
-
Research the issue and return a REFINEMENT_REPORT with the updated specification.
|
|
177
|
-
Do NOT modify Notion - just return the report.
|
|
178
|
-
\`\`\`
|
|
249
|
+
#### REFINE_TASK
|
|
250
|
+
Update a task specification based on feedback.
|
|
251
|
+
${formatThinkerDispatch("REFINE_TASK")}
|
|
179
252
|
|
|
180
253
|
### Processing the Thinker's Planning Report
|
|
181
254
|
|
|
@@ -187,20 +260,7 @@ Create a sub-page under the Thinking Board with the feature title. Write the \`f
|
|
|
187
260
|
|
|
188
261
|
#### Step 2 \u2014 Create the Kanban Database
|
|
189
262
|
|
|
190
|
-
Create a separate database as a child of the Thinking Board (sibling to the feature page, not inline). Use
|
|
191
|
-
|
|
192
|
-
\`\`\`sql
|
|
193
|
-
CREATE TABLE (
|
|
194
|
-
"Task" TITLE,
|
|
195
|
-
"Status" SELECT('Backlog':default, 'To Do':blue, 'In Progress':yellow, 'Needs Human Input':red, 'In Test':orange, 'Human Review':purple, 'Done':green),
|
|
196
|
-
"Priority" SELECT('Critical':red, 'High':orange, 'Medium':yellow, 'Low':green),
|
|
197
|
-
"Depends On" RICH_TEXT,
|
|
198
|
-
"Complexity" SELECT('Small':green, 'Medium':yellow, 'Large':red),
|
|
199
|
-
"Notes" RICH_TEXT
|
|
200
|
-
)
|
|
201
|
-
\`\`\`
|
|
202
|
-
|
|
203
|
-
Create a **Board view** grouped by \`"Status"\`. Add a link to the database on the feature page so they are connected.
|
|
263
|
+
Create a separate database as a child of the Thinking Board (sibling to the feature page, not inline). Use the schema from the Kanban Database Schema section above. Create a **Board view** grouped by \`"Status"\`. Add a link to the database on the feature page.
|
|
204
264
|
|
|
205
265
|
#### Step 3 \u2014 Populate Task Tickets
|
|
206
266
|
|
|
@@ -455,14 +515,7 @@ You will be invoked with task context from the orchestrator. The payload may inc
|
|
|
455
515
|
- Parent task intent overrides sibling assumptions.
|
|
456
516
|
- If unresolved, report ambiguity clearly.
|
|
457
517
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
You have **limited** board access:
|
|
461
|
-
- **Allowed:** Read board/ticket context needed for implementation.
|
|
462
|
-
- **Allowed:** Write implementation notes on the assigned ticket page (findings, progress notes, execution summary, blocker notes).
|
|
463
|
-
- **Forbidden:** Moving tasks between statuses. Only the orchestrator (\`notion-agent-hive\`) handles status transitions.
|
|
464
|
-
- **Forbidden:** Creating or deleting tickets.
|
|
465
|
-
- **Forbidden:** Scanning the board to decide what to do next. Task routing belongs to the orchestrator.
|
|
518
|
+
${getBoardPermissionsBlock("executor")}
|
|
466
519
|
|
|
467
520
|
## Execution Workflow
|
|
468
521
|
|
|
@@ -527,13 +580,7 @@ You are not checking boxes. You are evaluating:
|
|
|
527
580
|
|
|
528
581
|
You are the last line of defense before code reaches human review. Take that responsibility seriously.
|
|
529
582
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
You have **limited** board access:
|
|
533
|
-
- **Allowed:** Move a task from \`In Test\` \u2192 \`Human Review\` when all checks pass.
|
|
534
|
-
- **Forbidden:** Moving tasks to \`Done\`. Only the human user may do this.
|
|
535
|
-
- **Forbidden:** Moving tasks to \`To Do\` or \`In Progress\`. Report failures back to the Thinker and it will handle rework transitions.
|
|
536
|
-
- **Forbidden:** Creating or deleting tickets. Only the Thinker may do this.
|
|
583
|
+
${getBoardPermissionsBlock("reviewer")}
|
|
537
584
|
|
|
538
585
|
## Inputs
|
|
539
586
|
|
|
@@ -815,13 +862,31 @@ Before producing any task breakdown, explore the codebase to gather concrete con
|
|
|
815
862
|
|
|
816
863
|
Break the feature into tasks following these principles:
|
|
817
864
|
|
|
818
|
-
1. **Independence first**:
|
|
865
|
+
1. **Independence first**: Design tasks that can run in parallel by default.
|
|
866
|
+
- Slice by module/file rather than by workflow step (e.g., "implement auth service" not "implement login, then implement logout")
|
|
867
|
+
- Prefer "implement X in isolation" over "implement X, then wire it up"
|
|
868
|
+
- Extract shared concerns (types, schemas, configs) into dedicated foundation tasks that others depend on
|
|
869
|
+
- If two tasks would touch the same file, question whether they are truly independent or should be merged/resequenced
|
|
819
870
|
2. **One concern per task**: A task should do one thing well. Do not bundle unrelated changes.
|
|
820
871
|
3. **Testable**: Each task should have verifiable acceptance criteria.
|
|
821
872
|
4. **Ordered by dependency**: Tasks that others depend on should be higher priority.
|
|
822
|
-
5. **
|
|
873
|
+
5. **Small by default**: Prefer many small tasks over few large ones.
|
|
874
|
+
- If a task has more than 5 subtasks, it is too big \u2014 decompose further
|
|
875
|
+
- "Large" complexity is a smell: always ask "can this be two tasks instead?"
|
|
876
|
+
- When in doubt, split. Merging tasks later is easier than debugging a monolithic one.
|
|
823
877
|
6. **Contract-first handoff**: Every task must be closed at the contract level (what/where/constraints/acceptance), while allowing normal implementation-level leeway.
|
|
824
878
|
|
|
879
|
+
#### Dependency Minimization Checklist
|
|
880
|
+
|
|
881
|
+
Before finalizing tasks, verify:
|
|
882
|
+
|
|
883
|
+
- [ ] Each dependency is truly necessary \u2014 would the dependent task fail without it, or is it just convenient ordering?
|
|
884
|
+
- [ ] No chain dependencies that could be broken (A\u2192B\u2192C\u2192D often hides parallelizable work)
|
|
885
|
+
- [ ] Shared concerns (types, schemas, configs) are extracted to foundation tasks rather than duplicated or assumed
|
|
886
|
+
- [ ] No two tasks modify the same file unless absolutely necessary
|
|
887
|
+
|
|
888
|
+
If the checklist fails, refactor the task breakdown before proceeding.
|
|
889
|
+
|
|
825
890
|
#### Ticket Strictness Rules (Non-Negotiable)
|
|
826
891
|
|
|
827
892
|
Before including a task in your report, enforce these rules:
|