@tesselate-digital/notion-agent-hive 0.0.1

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 ADDED
@@ -0,0 +1,301 @@
1
+ # notion-agent-hive
2
+
3
+ **Persistent memory for AI coding sessions using Notion.**
4
+
5
+ ## Why this exists
6
+
7
+ Two, ahem, persistent problems with AI coding agents:
8
+
9
+ **Sessions die at the worst time.** You're mid-feature when rate limits hit or sessions expire. There's no clean way to continue on another platform. You learn to ask agents to write plans in markdown first, but it's easy to forget - and then the context is gone.
10
+
11
+ **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
+
13
+ **Limited task horizon.** Most AI coding sessions work best for small, contained tasks. When you want to tackle more ambitious, long-running features that span multiple sessions or days, you're left managing context manually - if you can at all.
14
+
15
+ ## What this does
16
+
17
+ Uses **Notion kanban boards as persistent memory** for your entire workflow. Every feature gets:
18
+
19
+ - A dedicated Notion page with the full plan, decisions, and reasoning
20
+ - An inline kanban board with detailed task tickets
21
+ - Context that persists across sessions and tools
22
+
23
+ Why Notion specifically:
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:
32
+
33
+ | Agent | Role |
34
+ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
35
+ | **Coordinator** | Entry point. Manages the Notion board, creates feature pages and task tickets, dispatches subagents, and handles status transitions. |
36
+ | **Thinker** | Deep research and investigation. Interrogates users, explores the codebase, decomposes features into tasks. Returns structured reports to the coordinator. Never modifies the board. |
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
+ | **Reviewer** | Verifies implementations against acceptance criteria. Gates tasks for human review before they can be marked done. |
39
+
40
+ ### Ticket Lifecycle
41
+
42
+ ```mermaid
43
+ flowchart LR
44
+ Backlog --> ToDo["To Do"]
45
+ ToDo -->|"Executor picks up"| InProgress["In Progress"]
46
+ InProgress -->|"Executor reports done"| InTest["In Test"]
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
+ ```
59
+
60
+ **Key rule:** No agent can mark a task as Done. Only you can. The human always has final say.
61
+
62
+ A task can also be moved to **Needs Human Input** at any point when a decision requires your judgment. The agent won't guess.
63
+
64
+ ## Installation
65
+
66
+ ### Quick Start
67
+
68
+ ```bash
69
+ bunx @tesselate-digital/notion-agent-hive@latest install
70
+ ```
71
+
72
+ This command:
73
+
74
+ 1. Adds `@tesselate-digital/notion-agent-hive` to the `plugin` array in `~/.config/opencode/opencode.json`
75
+ 2. Creates a `~/.config/opencode/notion-agent-hive.json` starter config
76
+
77
+ ### Prerequisites
78
+
79
+ - [OpenCode](https://opencode.ai) installed
80
+ - A Notion workspace with an [integration/API token](https://www.notion.so/my-integrations)
81
+ - The [Notion MCP server](https://github.com/makenotion/notion-mcp-server) configured in OpenCode
82
+
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
+ Once the package is published, the intended install command is:
142
+
143
+ ```bash
144
+ bunx @tesselate-digital/notion-agent-hive@latest install
145
+ ```
146
+
147
+ This command:
148
+
149
+ 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`)
150
+ 2. Creates a `~/.config/opencode/notion-agent-hive.json` starter config (or the matching `$OPENCODE_CONFIG_DIR` / `$XDG_CONFIG_HOME` location)
151
+
152
+ If you want per-project overrides, create `notion-agent-hive.json` in the project root manually.
153
+
154
+ Then configure your Notion MCP server in `~/.config/opencode/opencode.json` if you haven't already:
155
+
156
+ ```json
157
+ {
158
+ "mcp": {
159
+ "notion": {
160
+ "type": "npx",
161
+ "command": "npx",
162
+ "args": ["-y", "@notionhq/notion-mcp-server"],
163
+ "env": {
164
+ "OPENAPI_MCP_HEADERS": "{\"Authorization\": \"Bearer YOUR_NOTION_TOKEN\"}"
165
+ }
166
+ }
167
+ }
168
+ }
169
+ ```
170
+
171
+ ### Configuring Models
172
+
173
+ There are two places to configure models, merged at startup:
174
+
175
+ | Location | Scope | Use for |
176
+ | ------------------------------------------- | --------------------- | ----------------------------- |
177
+ | `~/.config/opencode/notion-agent-hive.json` | Global (all projects) | Your personal default models |
178
+ | `notion-agent-hive.json` in project root | Per-project | Overrides for a specific repo |
179
+
180
+ Project config takes precedence. Agent keys are merged individually — setting `thinker` in the project config does not wipe out `executor` from your global config.
181
+
182
+ Restart OpenCode for changes to take effect.
183
+
184
+ ---
185
+
186
+ Model IDs use the `provider/model-name` format that OpenCode uses — any provider configured in your OpenCode setup works here.
187
+
188
+ The public agent name is `notion agent hive`, but the model config key is still `coordinator`.
189
+
190
+ The `$schema` path depends on how you installed the plugin. For local development or global config, it's simplest to omit `$schema`.
191
+
192
+ ```json
193
+ {
194
+ "agents": {
195
+ "coordinator": { "model": "openai/gpt-5.2" },
196
+ "thinker": { "model": "openai/gpt-5.4", "variant": "xhigh" },
197
+ "executor": { "model": "kimi-for-coding/k2p5" },
198
+ "reviewer": { "model": "openai/gpt-5.4", "variant": "xhigh" }
199
+ }
200
+ }
201
+ ```
202
+
203
+ Each agent has a distinct role, so you can tune them independently:
204
+
205
+ | Agent | Role | Suggested model profile |
206
+ | --------------- | ------------------------------------ | ----------------------------------------------------------- |
207
+ | **coordinator** | Dispatches agents, moves tickets | Fast and cheap — it mostly routes, not thinks |
208
+ | **thinker** | Deep research, feature decomposition | Most capable model you have — this is where quality matters |
209
+ | **executor** | Code implementation | Balanced — good at coding tasks |
210
+ | **reviewer** | QA verification, criteria checking | Same tier as executor |
211
+
212
+ #### Variants
213
+
214
+ Some providers support model-specific variants such as `"xhigh"` or `"max"`:
215
+
216
+ ```json
217
+ {
218
+ "agents": {
219
+ "thinker": { "model": "openai/gpt-5.4", "variant": "xhigh" },
220
+ "reviewer": { "model": "anthropic/claude-opus-4", "variant": "max" }
221
+ }
222
+ }
223
+ ```
224
+
225
+ #### Fallback chains
226
+
227
+ Define ordered fallback models per agent. If the primary model hits a rate limit mid-session, the plugin automatically switches to the next in the chain:
228
+
229
+ ```json
230
+ {
231
+ "agents": {
232
+ "thinker": { "model": "openai/gpt-5.4" }
233
+ },
234
+ "fallback": {
235
+ "enabled": true,
236
+ "chains": {
237
+ "thinker": ["google/gemini-2.5-pro", "anthropic/claude-opus-4"]
238
+ }
239
+ }
240
+ }
241
+ ```
242
+
243
+ You can also pass the full chain directly as the `model` value — the first entry is used at startup, the rest are fallbacks:
244
+
245
+ ```json
246
+ {
247
+ "agents": {
248
+ "thinker": {
249
+ "model": [
250
+ "openai/gpt-5.4",
251
+ "google/gemini-2.5-pro",
252
+ "anthropic/claude-opus-4"
253
+ ]
254
+ }
255
+ }
256
+ }
257
+ ```
258
+
259
+ ### Usage
260
+
261
+ 1. Open OpenCode and start a session with the **notion agent hive** agent
262
+ 2. Describe the feature you want to build
263
+ 3. The Coordinator dispatches the Thinker, who interrogates you, explores your codebase, and creates the Notion feature page + task board
264
+ 4. Say **"execute"** and the Coordinator dispatches tasks to the Executor, runs them through the Reviewer, and surfaces completed work for your review
265
+ 5. Review tasks in the **Human Review** column and move them to **Done**, or send them back with comments
266
+
267
+ 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.
268
+
269
+ ---
270
+
271
+ <details>
272
+ <summary><strong>Technical Details</strong></summary>
273
+
274
+ ### Repository Structure
275
+
276
+ ```
277
+ notion-agent-hive/
278
+ ├── src/
279
+ │ ├── agents/
280
+ │ │ ├── types.ts # AgentDefinition + AgentConfig interfaces
281
+ │ │ ├── coordinator.ts # notion agent hive agent factory
282
+ │ │ ├── thinker.ts # notion-thinker agent factory
283
+ │ │ ├── executor.ts # notion-executor agent factory
284
+ │ │ └── reviewer.ts # notion-reviewer agent factory
285
+ │ ├── cli/
286
+ │ │ ├── index.ts # CLI entry point
287
+ │ │ └── install.ts # install command
288
+ │ ├── config.ts # Config loading + Zod validation
289
+ │ ├── fallback.ts # Runtime model fallback manager
290
+ │ └── index.ts # Plugin entry point + public API
291
+ ├── schema.json # JSON Schema for notion-agent-hive.json
292
+ ├── biome.json
293
+ ├── tsconfig.json
294
+ └── package.json
295
+ ```
296
+
297
+ ### MCP Requirements
298
+
299
+ Only the **Notion MCP server** is required. No other MCP servers are mandatory for core functionality.
300
+
301
+ </details>
@@ -0,0 +1,5 @@
1
+ import type { AgentDefinition } from "./types";
2
+ export declare function createCoordinatorAgent(model?: string | Array<string | {
3
+ id: string;
4
+ variant?: string;
5
+ }>, variant?: string): AgentDefinition;
@@ -0,0 +1,5 @@
1
+ import type { AgentDefinition } from "./types";
2
+ export declare function createExecutorAgent(model?: string | Array<string | {
3
+ id: string;
4
+ variant?: string;
5
+ }>, variant?: string): AgentDefinition;
@@ -0,0 +1,5 @@
1
+ import type { AgentDefinition } from "./types";
2
+ export declare function createReviewerAgent(model?: string | Array<string | {
3
+ id: string;
4
+ variant?: string;
5
+ }>, variant?: string): AgentDefinition;
@@ -0,0 +1,5 @@
1
+ import type { AgentDefinition } from "./types";
2
+ export declare function createThinkerAgent(model?: string | Array<string | {
3
+ id: string;
4
+ variant?: string;
5
+ }>, variant?: string): AgentDefinition;
@@ -0,0 +1,16 @@
1
+ import type { AgentConfig } from "@opencode-ai/sdk/v2";
2
+ export type { AgentConfig };
3
+ /**
4
+ * Extended agent definition with metadata for plugin registration.
5
+ */
6
+ export interface AgentDefinition {
7
+ /** Unique agent name (e.g., "notion agent hive") */
8
+ name: string;
9
+ /** Agent configuration (matches OpenCode's AgentConfig shape) */
10
+ config: AgentConfig;
11
+ /** Priority-ordered model entries for runtime fallback resolution */
12
+ _modelArray?: Array<{
13
+ id: string;
14
+ variant?: string;
15
+ }>;
16
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bun
2
+ export {};