@moreih29/nexus-core 0.1.2 → 0.2.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 +3 -3
- package/agents/architect/body.md +7 -6
- package/agents/designer/body.md +3 -3
- package/agents/engineer/body.md +8 -8
- package/agents/postdoc/body.md +4 -4
- package/agents/researcher/body.md +4 -4
- package/agents/reviewer/body.md +2 -2
- package/agents/strategist/body.md +4 -4
- package/agents/tester/body.md +2 -2
- package/agents/writer/body.md +1 -1
- package/conformance/README.md +125 -0
- package/conformance/scenarios/full-plan-cycle.json +132 -0
- package/conformance/scenarios/task-deps-ordering.json +83 -0
- package/conformance/schema/fixture.schema.json +224 -0
- package/conformance/state-schemas/agent-tracker.schema.json +58 -0
- package/conformance/state-schemas/history.schema.json +124 -0
- package/conformance/state-schemas/plan.schema.json +72 -0
- package/conformance/state-schemas/runtime.schema.json +25 -0
- package/conformance/state-schemas/tasks.schema.json +93 -0
- package/conformance/tools/plan-decide.json +70 -0
- package/conformance/tools/plan-start.json +67 -0
- package/conformance/tools/task-add.json +73 -0
- package/conformance/tools/task-close.json +98 -0
- package/docs/behavioral-contracts.md +145 -0
- package/docs/consumer-implementation-guide.md +844 -0
- package/docs/nexus-layout.md +234 -0
- package/docs/nexus-state-overview.md +185 -0
- package/docs/nexus-tools-contract.md +427 -0
- package/manifest.json +126 -113
- package/package.json +5 -1
- package/schema/common.schema.json +0 -4
- package/schema/skill.schema.json +16 -1
- package/schema/vocabulary.schema.json +14 -9
- package/skills/nx-init/body.md +6 -9
- package/skills/nx-init/meta.yml +1 -0
- package/skills/nx-plan/body.md +14 -11
- package/skills/nx-plan/meta.yml +3 -0
- package/skills/nx-run/body.md +4 -4
- package/skills/nx-run/meta.yml +3 -0
- package/skills/nx-setup/body.md +9 -9
- package/skills/nx-setup/meta.yml +1 -0
- package/skills/nx-sync/meta.yml +1 -0
- package/vocabulary/capabilities.yml +58 -25
|
@@ -0,0 +1,844 @@
|
|
|
1
|
+
# Nexus Consumer Implementation Guide
|
|
2
|
+
|
|
3
|
+
**Version:** nexus-core 0.2.0
|
|
4
|
+
**Audience:** Developers building a Nexus consumer harness from scratch.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
1. [Overview](#1-overview)
|
|
11
|
+
2. [Prerequisites](#2-prerequisites)
|
|
12
|
+
3. [Component Map and Build Order](#3-component-map-and-build-order)
|
|
13
|
+
4. [State File Management](#4-state-file-management)
|
|
14
|
+
5. [MCP Tool Implementation](#5-mcp-tool-implementation)
|
|
15
|
+
6. [Capability Handling](#6-capability-handling)
|
|
16
|
+
7. [Agent Catalog Construction](#7-agent-catalog-construction)
|
|
17
|
+
8. [Skill Activation Architecture](#8-skill-activation-architecture)
|
|
18
|
+
9. [Hook Event Lifecycle](#9-hook-event-lifecycle)
|
|
19
|
+
10. [Subagent Orchestration Model](#10-subagent-orchestration-model)
|
|
20
|
+
11. [Conformance Verification](#11-conformance-verification)
|
|
21
|
+
12. [Minimum Viable Consumer](#12-minimum-viable-consumer)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 1. Overview
|
|
26
|
+
|
|
27
|
+
A **Nexus consumer** is an execution-layer harness that reads nexus-core and orchestrates agents on behalf of the user. nexus-core is the authoring layer: it defines prompts, metadata, vocabulary, schemas, conformance fixtures, and documentation. The consumer is the runtime layer: it implements tool execution, spawns agents, enforces capability gates, and manages session state.
|
|
28
|
+
|
|
29
|
+
### What nexus-core provides
|
|
30
|
+
|
|
31
|
+
- **Agent prompts** — `agents/{id}/body.md`, harness-neutral behavioral specifications for each agent role
|
|
32
|
+
- **Skill prompts** — `skills/{id}/body.md`, full behavioral specifications for each skill
|
|
33
|
+
- **Metadata** — `agents/{id}/meta.yml` and `skills/{id}/meta.yml`, structured descriptions of each agent and skill
|
|
34
|
+
- **Manifest** — `manifest.json`, a single-file snapshot of all agents, skills, and vocabulary for the current version
|
|
35
|
+
- **Vocabulary** — `vocabulary/capabilities.yml`, `tags.yml`, `resume-tiers.yml`, `categories.yml`, abstract definitions of the Nexus semantic model
|
|
36
|
+
- **Schemas** — `schema/*.json`, JSON Schema definitions for all data structures
|
|
37
|
+
- **Conformance fixtures** — `conformance/tools/*.json` and `conformance/scenarios/*.json`, declarative behavioral tests
|
|
38
|
+
- **Documentation** — `docs/`, normative specifications for tools, state files, layout, and behavioral contracts
|
|
39
|
+
|
|
40
|
+
### What the consumer builds
|
|
41
|
+
|
|
42
|
+
- **Runtime orchestration** — session start/end logic, cycle management, state file creation and cleanup
|
|
43
|
+
- **Tool implementation** — concrete implementations of the 11 abstract Nexus tools
|
|
44
|
+
- **Hook system** — lifecycle event handlers that fire at well-defined points in the session
|
|
45
|
+
- **Capability mapping** — a local file that translates abstract capability IDs to concrete disallowed tools in your harness
|
|
46
|
+
- **Agent catalog** — your harness's agent registration, populated from nexus-core agent definitions
|
|
47
|
+
- **Skill dispatcher** — tag detection and skill body injection
|
|
48
|
+
- **Subagent orchestration** — spawn, context injection, resume evaluation, result collection
|
|
49
|
+
- **UI integration** — your harness's plugin registration, command system, and inter-process communication
|
|
50
|
+
|
|
51
|
+
### How to use this guide
|
|
52
|
+
|
|
53
|
+
Read this guide cover to cover before writing any code. The sections are ordered by build dependency: later sections assume the structures established by earlier ones. Jumping ahead and implementing subagent orchestration before state file management or tool implementation is defined will produce integration failures that are difficult to diagnose.
|
|
54
|
+
|
|
55
|
+
Cross-reference the normative specifications linked throughout. This guide describes what to build and in what order; the linked documents define the precise contracts your implementation must satisfy.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 2. Prerequisites
|
|
60
|
+
|
|
61
|
+
### Package installation
|
|
62
|
+
|
|
63
|
+
Install nexus-core as a development dependency. It is not shipped to end users — it is consumed at build time by your harness.
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
npm install --save-dev @moreih29/nexus-core
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
After installation, the package is available at `node_modules/@moreih29/nexus-core/`. All paths in this guide referencing nexus-core files resolve from that root.
|
|
70
|
+
|
|
71
|
+
### Knowledge prerequisites
|
|
72
|
+
|
|
73
|
+
Before building a consumer, you must be familiar with:
|
|
74
|
+
|
|
75
|
+
1. **Your harness's plugin system** — how to register tools that the LLM can call, how hooks are declared and fire, and how to inject content into the LLM's context (system prompt, tool response, or user message prefix).
|
|
76
|
+
2. **Your harness's agent/subprocess model** — how to spawn an isolated LLM session, how to pass initial context, and how to receive the result.
|
|
77
|
+
3. **JSON and YAML** — all nexus-core metadata files are YAML or JSON; all state files are JSON.
|
|
78
|
+
|
|
79
|
+
### Primary entry points
|
|
80
|
+
|
|
81
|
+
Begin your implementation by reading these files in order:
|
|
82
|
+
|
|
83
|
+
1. `manifest.json` — the complete catalog of agents, skills, and vocabulary for the installed version. This is your primary lookup source; most implementation tasks start here.
|
|
84
|
+
2. `docs/nexus-tools-contract.md` — normative specifications for all 11 tools: parameters, return values, side effects, and error conditions. Read this before implementing any tool.
|
|
85
|
+
3. `docs/nexus-state-overview.md` — lifecycle and tool access table for every state file.
|
|
86
|
+
4. `docs/nexus-layout.md` — the canonical `.nexus/` directory structure your harness must create.
|
|
87
|
+
5. `docs/behavioral-contracts.md` — state machines, permission model, resume tier semantics, and the `manual_only` contract.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 3. Component Map and Build Order
|
|
92
|
+
|
|
93
|
+
A complete Nexus consumer comprises nine components. They have hard dependencies: some components cannot be implemented until others are in place. Build them in the order shown.
|
|
94
|
+
|
|
95
|
+
### Components
|
|
96
|
+
|
|
97
|
+
| # | Component | Description |
|
|
98
|
+
|---|-----------|-------------|
|
|
99
|
+
| 1 | `.nexus/` Directory Initialization | Create the required directory tree and `.gitignore` at session start |
|
|
100
|
+
| 2 | State File Management | Read/write plan.json, tasks.json, history.json, runtime.json, agent-tracker.json |
|
|
101
|
+
| 3 | MCP Tool Implementation | Concrete implementations of the 11 abstract Nexus tools |
|
|
102
|
+
| 4 | Capability Mapping | Local file translating abstract capability IDs to concrete disallowed tools |
|
|
103
|
+
| 5 | Agent Catalog | Load nexus-core agents, apply capability-map, register with harness |
|
|
104
|
+
| 6 | Skill Dispatcher | Detect bracket tags, load skill body.md, inject into LLM context |
|
|
105
|
+
| 7 | Hook/Gate System | Lifecycle event handlers: session_start, user_message, pre_tool_use, etc. |
|
|
106
|
+
| 8 | Subagent Orchestration | Spawn isolated LLM sessions, pass context, collect results, evaluate resume |
|
|
107
|
+
| 9 | Conformance Verification | Run fixtures against your tool implementations to verify interoperability |
|
|
108
|
+
|
|
109
|
+
### Dependency graph
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
Directory Init → State File Mgmt → MCP Tools → Capability Mapping
|
|
113
|
+
→ Agent Catalog → Skill Dispatcher
|
|
114
|
+
→ Hook/Gate System → Subagent Orchestration
|
|
115
|
+
→ Conformance Verification
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Directory Init** must precede everything: state files cannot be written if the directory does not exist.
|
|
119
|
+
|
|
120
|
+
**State File Management** must precede tool implementation: tools read and write specific files at specific paths. Without knowing the file layout, tool implementation cannot be completed.
|
|
121
|
+
|
|
122
|
+
**MCP Tools** must precede Capability Mapping, Agent Catalog, and Hook/Gate: the capability-map is only useful once the tools it restricts are implemented; the agent catalog is validated against the tool set; hooks reference both.
|
|
123
|
+
|
|
124
|
+
**Capability Mapping** must precede Agent Catalog: effective capabilities are computed by merging canonical capabilities with consumer additions, and that merge requires the capability-map to be defined.
|
|
125
|
+
|
|
126
|
+
**Agent Catalog** must precede Skill Dispatcher: the dispatcher injects skill body alongside agent context; the agent registration format must exist first.
|
|
127
|
+
|
|
128
|
+
**Hook/Gate System** must precede Subagent Orchestration: hooks fire during agent spawn and completion; the hook contracts must be defined before the orchestration logic can reference them.
|
|
129
|
+
|
|
130
|
+
**Subagent Orchestration** must precede Conformance Verification: end-to-end scenario fixtures test the full lifecycle, including agent spawning.
|
|
131
|
+
|
|
132
|
+
### Build order within components
|
|
133
|
+
|
|
134
|
+
Within MCP Tools, implement in this recommended order:
|
|
135
|
+
|
|
136
|
+
1. `plan_start`, `plan_decide` — the core planning pair; all planning workflows depend on them
|
|
137
|
+
2. `plan_status`, `plan_update` — planning query and mutation
|
|
138
|
+
3. `task_add`, `task_list`, `task_update`, `task_close` — execution lifecycle
|
|
139
|
+
4. `history_search`, `context`, `artifact_write` — support and reporting
|
|
140
|
+
|
|
141
|
+
This order matches the dependency chain within the planning/execution lifecycle. Implement and test each tool against its conformance fixtures before moving to the next.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 4. State File Management
|
|
146
|
+
|
|
147
|
+
Nexus state is split into two categories with different scopes, persistence, and git-tracking rules. Your implementation must respect these boundaries exactly.
|
|
148
|
+
|
|
149
|
+
### Two-category model
|
|
150
|
+
|
|
151
|
+
**Session-scoped state** lives in `.nexus/state/`. It is created at session start, updated throughout the session, and deleted at session end or cycle close. It must never be git-tracked. Your `.nexus/.gitignore` must contain `state/` to enforce this.
|
|
152
|
+
|
|
153
|
+
**Project-scoped content** lives directly under `.nexus/` (outside `state/`). It persists across sessions and git branches. It is git-tracked and committed to the repository.
|
|
154
|
+
|
|
155
|
+
### Directory tree
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
.nexus/
|
|
159
|
+
├── state/ ← session-scoped (not git-tracked)
|
|
160
|
+
│ ├── plan.json
|
|
161
|
+
│ ├── tasks.json
|
|
162
|
+
│ ├── runtime.json
|
|
163
|
+
│ ├── agent-tracker.json
|
|
164
|
+
│ ├── tool-log.jsonl
|
|
165
|
+
│ ├── edit-tracker.json
|
|
166
|
+
│ ├── reopen-tracker.json
|
|
167
|
+
│ └── artifacts/
|
|
168
|
+
├── history.json ← project-scoped (git-tracked, append-only)
|
|
169
|
+
├── memory/ ← project-scoped (git-tracked)
|
|
170
|
+
│ └── *.md
|
|
171
|
+
├── context/ ← project-scoped (git-tracked, nx-sync managed)
|
|
172
|
+
│ └── *.md
|
|
173
|
+
├── rules/ ← project-scoped (git-tracked, user-defined)
|
|
174
|
+
│ └── *.md
|
|
175
|
+
└── .gitignore
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Initialization sequence
|
|
179
|
+
|
|
180
|
+
At session start, your harness must:
|
|
181
|
+
|
|
182
|
+
1. Create `.nexus/` if it does not exist.
|
|
183
|
+
2. Create `.nexus/state/` if it does not exist.
|
|
184
|
+
3. Write `.nexus/.gitignore` with content `state/` if the file does not exist.
|
|
185
|
+
4. Write `.nexus/state/runtime.json` with session metadata (session ID, harness version, start timestamp).
|
|
186
|
+
5. Initialize `.nexus/state/agent-tracker.json` as an empty array `[]`.
|
|
187
|
+
6. Check for stale state files from a prior crashed session. If `plan.json` or `tasks.json` exist without a running session, warn the user that a previous session may not have closed cleanly.
|
|
188
|
+
|
|
189
|
+
### Key state files
|
|
190
|
+
|
|
191
|
+
| File | Scope | Git-tracked | Created by | Deleted by |
|
|
192
|
+
|------|-------|------------|------------|------------|
|
|
193
|
+
| `state/plan.json` | Session | No | `plan_start` tool | `task_close` tool |
|
|
194
|
+
| `state/tasks.json` | Session | No | `task_add` tool (first call) | `task_close` tool |
|
|
195
|
+
| `state/runtime.json` | Session | No | session_start hook | session_end hook |
|
|
196
|
+
| `state/agent-tracker.json` | Session | No | session_start hook | session_end hook |
|
|
197
|
+
| `state/tool-log.jsonl` | Session | No | post_tool_use hook | session_end hook |
|
|
198
|
+
| `state/edit-tracker.json` | Session | No | post_tool_use hook (first edit) | task_close / session_end |
|
|
199
|
+
| `history.json` | Project | Yes | `plan_start` or `task_close` (first archive) | Never |
|
|
200
|
+
|
|
201
|
+
### Schema validation
|
|
202
|
+
|
|
203
|
+
JSON Schema definitions for all state files are available in `conformance/state-schemas/`. The schemas cover `plan.json`, `tasks.json`, `history.json`, `runtime.json`, and `agent-tracker.json`. Validate state files against these schemas in your test suite.
|
|
204
|
+
|
|
205
|
+
For full lifecycle and tool access details, see [nexus-state-overview.md](./nexus-state-overview.md) and [nexus-layout.md](./nexus-layout.md).
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## 5. MCP Tool Implementation
|
|
210
|
+
|
|
211
|
+
The 11 Nexus abstract tools are the interface between the LLM and Nexus state. Your harness implements each one concretely. nexus-core specifies behavior; you choose the registration name, prefix, and implementation mechanism.
|
|
212
|
+
|
|
213
|
+
### The 11 abstract tool names
|
|
214
|
+
|
|
215
|
+
| Abstract name | Function |
|
|
216
|
+
|---------------|----------|
|
|
217
|
+
| `plan_start` | Create a new planning session |
|
|
218
|
+
| `plan_status` | Query the current plan state |
|
|
219
|
+
| `plan_update` | Add, remove, edit, or reopen plan issues |
|
|
220
|
+
| `plan_decide` | Record a decision on a plan issue |
|
|
221
|
+
| `task_add` | Add a task to the active task list |
|
|
222
|
+
| `task_list` | List tasks with dependency-aware ready set |
|
|
223
|
+
| `task_update` | Update a task's status |
|
|
224
|
+
| `task_close` | Archive the current cycle to history.json and delete session state files |
|
|
225
|
+
| `history_search` | Search past cycles in history.json |
|
|
226
|
+
| `context` | Read active session context (branch, task summary, decisions) |
|
|
227
|
+
| `artifact_write` | Write a named artifact file to the session artifact directory |
|
|
228
|
+
|
|
229
|
+
### Tool naming
|
|
230
|
+
|
|
231
|
+
nexus-core uses abstract names only. Your harness chooses its own registration names. For example, a harness might register `plan_start` as `nx_plan_start`, or a plugin system might prefix it as `mcp__plugin_name_nx__plan_start`. The name you use internally is your decision. The behavioral contract — parameters, return values, side effects, error conditions — is fixed by nexus-core and must not vary.
|
|
232
|
+
|
|
233
|
+
### Implementation contract
|
|
234
|
+
|
|
235
|
+
For every tool, implement exactly the parameter schema, return shape, and side effects documented in [nexus-tools-contract.md](./nexus-tools-contract.md). Do not add undocumented parameters or return fields that callers may depend on. Do not omit required return fields.
|
|
236
|
+
|
|
237
|
+
Specific requirements to enforce:
|
|
238
|
+
|
|
239
|
+
- `plan_start`: when a prior `plan.json` exists, archive it to `history.json` before creating the new session. Failure to archive on replace will cause data loss.
|
|
240
|
+
- `task_close`: delete `plan.json`, `tasks.json`, `edit-tracker.json`, and `reopen-tracker.json` after archiving. Leaving these files causes stale state on next session.
|
|
241
|
+
- `artifact_write`: create `.nexus/state/artifacts/` on demand if it does not exist. Do not require the directory to pre-exist.
|
|
242
|
+
- `context`: return `{ active: false }` (for plan_status) or `{ exists: false }` (for task_list) when the relevant state file is absent. Do not return an error.
|
|
243
|
+
|
|
244
|
+
### Implementation order
|
|
245
|
+
|
|
246
|
+
Implement in this sequence:
|
|
247
|
+
|
|
248
|
+
1. `plan_start`, `plan_decide` — validates state file management; these are the most frequently tested tools
|
|
249
|
+
2. `plan_status`, `plan_update` — complete the planning surface
|
|
250
|
+
3. `task_add`, `task_list`, `task_update`, `task_close` — execution lifecycle; `task_close` is the cleanup path
|
|
251
|
+
4. `history_search`, `context`, `artifact_write` — support tools; implement after the core tools are passing conformance
|
|
252
|
+
|
|
253
|
+
After each tool pair, run the relevant fixtures from `conformance/tools/` before continuing.
|
|
254
|
+
|
|
255
|
+
For full parameter schemas, return value shapes, and error conditions, see [nexus-tools-contract.md](./nexus-tools-contract.md).
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## 6. Capability Handling
|
|
260
|
+
|
|
261
|
+
Capabilities restrict which tools a subagent may call. nexus-core defines capabilities in abstract semantic terms. Your harness translates them into concrete tool blocklists.
|
|
262
|
+
|
|
263
|
+
### Canonical capability definitions
|
|
264
|
+
|
|
265
|
+
Read `vocabulary/capabilities.yml`. Each capability has:
|
|
266
|
+
|
|
267
|
+
- `id` — the canonical identifier (e.g., `no_file_edit`)
|
|
268
|
+
- `intent` — a machine-readable semantic class (e.g., `workspace_write_denial`)
|
|
269
|
+
- `blocks_semantic_classes` — the list of semantic operation classes this capability forbids
|
|
270
|
+
- `prose_guidance` — a human-readable description of exactly which tool behaviors are blocked and which are not
|
|
271
|
+
|
|
272
|
+
The four canonical capabilities in nexus-core 0.2.0:
|
|
273
|
+
|
|
274
|
+
| ID | Intent | Blocks |
|
|
275
|
+
|----|--------|--------|
|
|
276
|
+
| `no_file_edit` | `workspace_write_denial` | `file_creation`, `file_modification`, `file_deletion`, `partial_file_edit`, `structured_document_edit` |
|
|
277
|
+
| `no_task_create` | `task_pipeline_append_denial` | `nexus_task_creation` |
|
|
278
|
+
| `no_task_update` | `task_pipeline_mutate_denial` | `nexus_task_state_transition`, `nexus_task_metadata_modification` |
|
|
279
|
+
| `no_shell_exec` | `shell_execution_denial` | `shell_command_exec`, `subprocess_spawn`, `interactive_shell_session` |
|
|
280
|
+
|
|
281
|
+
### Local capability-map
|
|
282
|
+
|
|
283
|
+
Create a consumer-owned capability-map file that translates each capability ID and semantic class to the concrete tool names in your harness. The format is your choice; the following YAML structure is a workable pattern:
|
|
284
|
+
|
|
285
|
+
```yaml
|
|
286
|
+
# capability-map.yml (consumer-owned, not part of nexus-core)
|
|
287
|
+
no_file_edit:
|
|
288
|
+
disallowed_tools:
|
|
289
|
+
- YourEditTool
|
|
290
|
+
- YourWriteTool
|
|
291
|
+
- YourDeleteTool
|
|
292
|
+
- YourPatchTool
|
|
293
|
+
- YourNotebookCellEditTool
|
|
294
|
+
mapped_classes:
|
|
295
|
+
- file_creation
|
|
296
|
+
- file_modification
|
|
297
|
+
- file_deletion
|
|
298
|
+
- partial_file_edit
|
|
299
|
+
- structured_document_edit
|
|
300
|
+
|
|
301
|
+
no_task_create:
|
|
302
|
+
disallowed_tools:
|
|
303
|
+
- YourTaskAddTool # your harness's concrete registration name for task_add
|
|
304
|
+
mapped_classes:
|
|
305
|
+
- nexus_task_creation
|
|
306
|
+
|
|
307
|
+
no_task_update:
|
|
308
|
+
disallowed_tools:
|
|
309
|
+
- YourTaskUpdateTool # your harness's concrete registration name for task_update
|
|
310
|
+
- YourTaskCloseTool # your harness's concrete registration name for task_close
|
|
311
|
+
mapped_classes:
|
|
312
|
+
- nexus_task_state_transition
|
|
313
|
+
- nexus_task_metadata_modification
|
|
314
|
+
|
|
315
|
+
no_shell_exec:
|
|
316
|
+
disallowed_tools:
|
|
317
|
+
- YourShellTool
|
|
318
|
+
- YourSubprocessTool
|
|
319
|
+
mapped_classes:
|
|
320
|
+
- shell_command_exec
|
|
321
|
+
- subprocess_spawn
|
|
322
|
+
- interactive_shell_session
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Effective capability computation
|
|
326
|
+
|
|
327
|
+
When building an agent's effective restriction set, apply the additive-only merge rule defined in [behavioral-contracts.md §4](./behavioral-contracts.md):
|
|
328
|
+
|
|
329
|
+
```
|
|
330
|
+
effective_capabilities(agent) = canonical_capabilities(agent) ∪ consumer_additions(agent)
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
- `canonical_capabilities` is the `capabilities` array in `agents/{id}/meta.yml` (the nexus-core definition).
|
|
334
|
+
- `consumer_additions` is a harness-local set you define for agents where you want stricter restrictions.
|
|
335
|
+
|
|
336
|
+
**You may add capabilities. You must not remove canonical capabilities.** Removing `no_file_edit` from an agent that carries it canonically violates the nexus-core design intent. If nexus-core later adds a capability that your consumer already applies locally, the overlap is harmless — the union is idempotent.
|
|
337
|
+
|
|
338
|
+
### Applying the capability-map
|
|
339
|
+
|
|
340
|
+
When registering an agent for a subagent session:
|
|
341
|
+
|
|
342
|
+
1. Read the agent's `capabilities` array from `manifest.json` or `agents/{id}/meta.yml`.
|
|
343
|
+
2. Merge with any consumer additions for that agent ID.
|
|
344
|
+
3. For each capability in the merged set, look up `disallowed_tools` in your capability-map.
|
|
345
|
+
4. Build the union of all disallowed tools across all capabilities.
|
|
346
|
+
5. Pass this union to your harness's agent-registration mechanism as the set of tools the agent may not call.
|
|
347
|
+
|
|
348
|
+
### CI coverage assertion
|
|
349
|
+
|
|
350
|
+
In your test suite, verify that every `blocks_semantic_classes` value across all entries in `vocabulary/capabilities.yml` has at least one mapped tool in your capability-map. This catches omissions when nexus-core adds new semantic classes in a future version.
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## 7. Agent Catalog Construction
|
|
355
|
+
|
|
356
|
+
The agent catalog is your harness's internal registry of all Nexus agent roles, populated from nexus-core agent definitions and augmented with harness-specific context.
|
|
357
|
+
|
|
358
|
+
### Reading agent definitions
|
|
359
|
+
|
|
360
|
+
Start with `manifest.json`. The `agents` array contains one entry per agent role with these fields:
|
|
361
|
+
|
|
362
|
+
| Field | Type | Description |
|
|
363
|
+
|-------|------|-------------|
|
|
364
|
+
| `id` | string | Canonical agent identifier (e.g., `engineer`) |
|
|
365
|
+
| `name` | string | Display name |
|
|
366
|
+
| `description` | string | One-line role description |
|
|
367
|
+
| `category` | `"how" \| "do" \| "check"` | Role category |
|
|
368
|
+
| `resume_tier` | `"persistent" \| "bounded" \| "ephemeral"` | Session persistence behavior |
|
|
369
|
+
| `model_tier` | `"high" \| "standard"` | Abstract model selection signal |
|
|
370
|
+
| `capabilities` | `string[]` | Canonical capability IDs |
|
|
371
|
+
| `body_hash` | string | SHA-256 hash of body.md for integrity verification |
|
|
372
|
+
|
|
373
|
+
For full metadata, read `agents/{id}/meta.yml`. For the agent's prompt content, read `agents/{id}/body.md`.
|
|
374
|
+
|
|
375
|
+
### Transformation pipeline
|
|
376
|
+
|
|
377
|
+
For each agent in `manifest.json`:
|
|
378
|
+
|
|
379
|
+
1. **Read body.md** from `agents/{id}/body.md`. This is the prompt you will inject into the agent's LLM context.
|
|
380
|
+
2. **Compute effective_capabilities** by merging canonical capabilities with your consumer additions (see §6).
|
|
381
|
+
3. **Resolve disallowed tools** by applying your capability-map to `effective_capabilities`.
|
|
382
|
+
4. **Map model_tier** to a concrete model identifier: `high` → your harness's high-capability model, `standard` → your harness's standard model. This mapping is consumer-owned.
|
|
383
|
+
5. **Register** the agent in your harness's agent system with the resolved prompt, model, and tool restrictions.
|
|
384
|
+
|
|
385
|
+
### Neutral body + harness context synthesis
|
|
386
|
+
|
|
387
|
+
`body.md` is deliberately harness-neutral. It says things like "report to Lead" without specifying the concrete mechanism. This is intentional: the same body works across claude-nexus, opencode-nexus, and nexus-code because each harness injects the mechanism alongside the body.
|
|
388
|
+
|
|
389
|
+
Your harness must inject harness-specific tool awareness when activating an agent. Concretely:
|
|
390
|
+
|
|
391
|
+
- body.md says: "report to Lead"
|
|
392
|
+
- Your harness injects alongside it: "To report to Lead, use [your harness's inter-agent communication tool]."
|
|
393
|
+
|
|
394
|
+
- body.md says: "save your output using the artifact tool"
|
|
395
|
+
- Your harness injects alongside it: "The artifact tool in this harness is registered as [your concrete tool name]."
|
|
396
|
+
|
|
397
|
+
The `harness_docs_refs` field in `skills/{id}/meta.yml` signals which harness-specific topics should be surfaced when injecting context for that skill. For example, `nx-plan` and `nx-run` both declare `harness_docs_refs: [resume_invocation]` — meaning your harness should inject documentation about how agent resume works in your specific system when those skills are active.
|
|
398
|
+
|
|
399
|
+
### Nine agent roles
|
|
400
|
+
|
|
401
|
+
nexus-core 0.2.0 defines these nine agents:
|
|
402
|
+
|
|
403
|
+
| ID | Category | Resume tier | Canonical capabilities |
|
|
404
|
+
|----|----------|-------------|------------------------|
|
|
405
|
+
| `architect` | how | persistent | no_file_edit, no_task_create, no_task_update |
|
|
406
|
+
| `designer` | how | persistent | no_file_edit, no_task_create, no_task_update |
|
|
407
|
+
| `postdoc` | how | persistent | no_file_edit, no_task_create, no_task_update |
|
|
408
|
+
| `strategist` | how | persistent | no_file_edit, no_task_create, no_task_update |
|
|
409
|
+
| `engineer` | do | bounded | no_task_create |
|
|
410
|
+
| `writer` | do | bounded | no_task_create |
|
|
411
|
+
| `researcher` | do | persistent | no_file_edit, no_task_create |
|
|
412
|
+
| `tester` | check | ephemeral | no_file_edit, no_task_create |
|
|
413
|
+
| `reviewer` | check | ephemeral | no_file_edit, no_task_create |
|
|
414
|
+
|
|
415
|
+
All nine roles must be registered in your catalog. A consumer that omits an agent prevents Lead from using that role in plans and run cycles.
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## 8. Skill Activation Architecture
|
|
420
|
+
|
|
421
|
+
Skills are behavioral specifications that change how Lead operates. Skill activation transforms the LLM's operating mode by injecting a new body.md as its primary instruction set. The activation flow has six stages.
|
|
422
|
+
|
|
423
|
+
### Full activation flow
|
|
424
|
+
|
|
425
|
+
```
|
|
426
|
+
User types "[plan] analyze the architecture"
|
|
427
|
+
|
|
|
428
|
+
v
|
|
429
|
+
1. Tag Detection
|
|
430
|
+
- The consumer's user_message hook (or equivalent) intercepts the message
|
|
431
|
+
- Scan the message text for bracket tag patterns defined in vocabulary/tags.yml
|
|
432
|
+
- "[plan]" matches: id=plan, type=skill, skill=nx-plan
|
|
433
|
+
|
|
|
434
|
+
v
|
|
435
|
+
2. Routing by type
|
|
436
|
+
- type=skill → proceed to skill body loading (step 3)
|
|
437
|
+
- type=inline_action → call the handler tool directly; do not load a skill body
|
|
438
|
+
Example: "[d]" → call plan_decide tool immediately
|
|
439
|
+
|
|
|
440
|
+
v
|
|
441
|
+
3. Skill Body Loading
|
|
442
|
+
- Read skills/{skill_id}/body.md from the nexus-core package
|
|
443
|
+
- This file is the skill's complete behavioral specification
|
|
444
|
+
- Also read skills/{skill_id}/meta.yml to check for harness_docs_refs
|
|
445
|
+
|
|
|
446
|
+
v
|
|
447
|
+
4. LLM Context Injection
|
|
448
|
+
- Inject the body.md content into the LLM's operating context
|
|
449
|
+
- HOW to inject is consumer's decision:
|
|
450
|
+
a. System prompt injection — most common; replaces or appends to the system prompt
|
|
451
|
+
b. Tool-response injection — return body.md as a tool response the LLM reads
|
|
452
|
+
c. User-message prefix — prepend body.md to the next user message
|
|
453
|
+
- Also inject harness-specific context for any harness_docs_refs declared in meta.yml
|
|
454
|
+
- The body.md content BECOMES the LLM's operating instructions for this skill
|
|
455
|
+
|
|
|
456
|
+
v
|
|
457
|
+
5. Skill Active State
|
|
458
|
+
- Skill remains active until one of:
|
|
459
|
+
a. Session ends — all skills deactivate
|
|
460
|
+
b. Another skill is activated — replacement (e.g., [plan] → [run] transition)
|
|
461
|
+
c. The skill's own deactivation condition is met
|
|
462
|
+
Example: nx-plan completes (all issues decided) → user types [run] to transition
|
|
463
|
+
- While active, the skill's body governs Lead's behavior
|
|
464
|
+
|
|
|
465
|
+
v
|
|
466
|
+
6. manual_only Handling
|
|
467
|
+
- Before exposing skills to LLM natural-language detection, check meta.yml
|
|
468
|
+
- If manual_only=true: NEVER include in auto-detection candidate list
|
|
469
|
+
- Only activate on explicit user trigger: slash command or bracket tag typed by user
|
|
470
|
+
- Applies to: nx-init, nx-setup in nexus-core 0.2.0
|
|
471
|
+
- See: behavioral-contracts.md §6
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
### Tag variants
|
|
475
|
+
|
|
476
|
+
Tags may include variant suffixes. The `variants` field in `vocabulary/tags.yml` lists valid variant tokens for each tag.
|
|
477
|
+
|
|
478
|
+
Example: `plan` has `variants: ["auto"]`. This means `[plan:auto]` is a valid trigger that activates the same `nx-plan` skill but passes `auto` as a mode flag. Your consumer must:
|
|
479
|
+
|
|
480
|
+
1. Detect `[plan:auto]` as a variant of the `plan` tag.
|
|
481
|
+
2. Activate the same `nx-plan` skill body.
|
|
482
|
+
3. Pass the variant string (`auto`) to the skill activation logic as an argument or injected parameter.
|
|
483
|
+
|
|
484
|
+
The `rule` tag has `variants: ["*"]`, meaning any suffix is valid: `[rule:frontend]`, `[rule:testing]`, etc. Capture the suffix and pass it to the `rule_store` handler.
|
|
485
|
+
|
|
486
|
+
### Inline actions
|
|
487
|
+
|
|
488
|
+
Tags with `type=inline_action` do not load a skill body. They trigger a direct tool call.
|
|
489
|
+
|
|
490
|
+
| Tag | Handler | Effect |
|
|
491
|
+
|-----|---------|--------|
|
|
492
|
+
| `[d]` | `nx_plan_decide` | Immediately calls plan_decide with the user's decision text |
|
|
493
|
+
| `[m]` | `memory_store` | Stores the current lesson to `.nexus/memory/` |
|
|
494
|
+
| `[m:gc]` | `memory_gc` | Garbage-collects `.nexus/memory/` |
|
|
495
|
+
| `[rule]` | `rule_store` | Stores a rule to `.nexus/rules/` |
|
|
496
|
+
|
|
497
|
+
For inline actions, extract the relevant content from the user's message (the text following the tag) and pass it as the tool parameter. No skill body is loaded; no LLM mode change occurs.
|
|
498
|
+
|
|
499
|
+
### Natural-language trigger detection
|
|
500
|
+
|
|
501
|
+
Natural-language trigger detection — recognizing that a user's message implies a skill activation even without a bracket tag — is **consumer-owned**. nexus-core does not define, distribute, or maintain natural-language pattern lists.
|
|
502
|
+
|
|
503
|
+
The canonical trigger for every tag is the explicit bracket form in `vocabulary/tags.yml`. Any other activation form (recognizing "let's plan this" as equivalent to `[plan]`) is a consumer extension. Different consumers may implement different patterns. This divergence is explicitly acceptable per [behavioral-contracts.md §7](./behavioral-contracts.md).
|
|
504
|
+
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
## 9. Hook Event Lifecycle
|
|
508
|
+
|
|
509
|
+
Hooks are the consumer's mechanism for responding to lifecycle events. nexus-core defines 8 abstract events. The names are harness-neutral; each harness maps them to its own event API.
|
|
510
|
+
|
|
511
|
+
### Event mapping examples
|
|
512
|
+
|
|
513
|
+
Different harnesses expose these events under different names:
|
|
514
|
+
|
|
515
|
+
- **Claude Code**: `SessionStart`, `UserPromptSubmit`, `SubagentStart`, `SubagentStop`, `PreToolUse`, `PostToolUse`, `Stop`, `PostCompact`
|
|
516
|
+
- **OpenCode**: its own hook API names — map accordingly when building an OpenCode consumer
|
|
517
|
+
|
|
518
|
+
Identify the equivalent events in your harness's plugin system and implement the expected behaviors below.
|
|
519
|
+
|
|
520
|
+
### 8 lifecycle events
|
|
521
|
+
|
|
522
|
+
#### `session_start`
|
|
523
|
+
|
|
524
|
+
**When it fires:** The harness launches or the user begins a new session.
|
|
525
|
+
|
|
526
|
+
**Expected consumer behavior:**
|
|
527
|
+
- Create `.nexus/` and `.nexus/state/` directories if they do not exist.
|
|
528
|
+
- Write `.nexus/.gitignore` with `state/` if it does not exist.
|
|
529
|
+
- Write `.nexus/state/runtime.json` with session metadata: session ID, harness version, start timestamp, and any environment properties your harness tracks.
|
|
530
|
+
- Initialize `.nexus/state/agent-tracker.json` as `[]`.
|
|
531
|
+
- Check for stale state from a prior crashed session: if `plan.json` or `tasks.json` exist, warn the user that these may be leftover from an unclean shutdown.
|
|
532
|
+
- Load the knowledge index: list files in `.nexus/memory/`, `.nexus/context/`, and `.nexus/rules/` to build the reference index that will be injected into subagent spawns.
|
|
533
|
+
|
|
534
|
+
---
|
|
535
|
+
|
|
536
|
+
#### `user_message`
|
|
537
|
+
|
|
538
|
+
**When it fires:** The user submits a message to Lead.
|
|
539
|
+
|
|
540
|
+
**Expected consumer behavior:**
|
|
541
|
+
- Scan the message text for bracket tags. Match against all triggers defined in `vocabulary/tags.yml`.
|
|
542
|
+
- For each matched tag:
|
|
543
|
+
- If `type=skill`: activate the skill (see §8, steps 3–5). Do not proceed with normal message handling for that tag.
|
|
544
|
+
- If `type=inline_action`: call the handler tool immediately. The user's message following the tag is the input.
|
|
545
|
+
- After tag routing, inject contextual guidance into Lead's available context before LLM inference begins:
|
|
546
|
+
- Current plan status: if `plan.json` exists, summarize pending vs. decided issues.
|
|
547
|
+
- Task progress: if `tasks.json` exists, summarize total/completed/pending counts and the ready-task set.
|
|
548
|
+
- Knowledge file counts: number of files in `.nexus/memory/`, `.nexus/context/`, `.nexus/rules/`.
|
|
549
|
+
- If no tags are matched, pass the message to Lead without modification.
|
|
550
|
+
|
|
551
|
+
---
|
|
552
|
+
|
|
553
|
+
#### `subagent_spawn`
|
|
554
|
+
|
|
555
|
+
**When it fires:** Lead spawns a subagent to execute a task.
|
|
556
|
+
|
|
557
|
+
**Expected consumer behavior:**
|
|
558
|
+
- Record the new agent entry in `agent-tracker.json`: `{ agent_type, agent_id, task_id, started_at }`.
|
|
559
|
+
- Inject the knowledge index into the subagent's initial context: the list of files in `.nexus/memory/`, `.nexus/context/`, and `.nexus/rules/` so the agent knows what project knowledge is available.
|
|
560
|
+
- Apply capability restrictions: resolve `effective_capabilities` for this agent type and configure the subagent's tool access accordingly (see §6).
|
|
561
|
+
- Apply the resume evaluation: check `owner_reuse_policy` on the task and the agent's `resume_tier` to determine whether to spawn fresh or resume a prior session (see §10).
|
|
562
|
+
- Pass the structured task context to the agent: title, context, approach, and acceptance criteria (see §10, Context Passing).
|
|
563
|
+
|
|
564
|
+
---
|
|
565
|
+
|
|
566
|
+
#### `subagent_complete`
|
|
567
|
+
|
|
568
|
+
**When it fires:** A subagent finishes its assigned work and returns control to Lead.
|
|
569
|
+
|
|
570
|
+
**Expected consumer behavior:**
|
|
571
|
+
- Update `agent-tracker.json`: set `status=completed`, record `stopped_at` timestamp.
|
|
572
|
+
- Compute `files_touched` from your tool-log or the subagent's tool usage record. Record which files were created or modified.
|
|
573
|
+
- Update `edit-tracker.json` with the files touched by this agent. This data feeds the bounded-tier resume evaluation on subsequent spawns.
|
|
574
|
+
- Check if the completed task has pending acceptance criteria that were not verified. If the task has `acceptance` defined and no `tester` or `reviewer` subagent has been scheduled, surface a reminder to Lead.
|
|
575
|
+
- Update the task status in `tasks.json` via the `task_update` tool: set to `completed`.
|
|
576
|
+
|
|
577
|
+
---
|
|
578
|
+
|
|
579
|
+
#### `pre_tool_use`
|
|
580
|
+
|
|
581
|
+
**When it fires:** A tool is about to execute.
|
|
582
|
+
|
|
583
|
+
**Expected consumer behavior:**
|
|
584
|
+
- Gate enforcement for unplanned file edits: if `tasks.json` does not exist and the tool is a file-editing tool, block the call and return an error explaining that edits outside of a planned task cycle are disallowed. This prevents unplanned workspace changes.
|
|
585
|
+
- Capability gate: check whether the current agent (Lead or a subagent) has the requested tool in its disallowed set. If so, block the call and return an appropriate error.
|
|
586
|
+
- Any other pre-condition checks your harness requires (rate limits, sandbox policies, etc.).
|
|
587
|
+
|
|
588
|
+
Read-only tools (query tools, status reads) are never blocked by capability gates. Only tools with primary write effects are subject to capability restrictions.
|
|
589
|
+
|
|
590
|
+
---
|
|
591
|
+
|
|
592
|
+
#### `post_tool_use`
|
|
593
|
+
|
|
594
|
+
**When it fires:** A tool has executed and returned a result.
|
|
595
|
+
|
|
596
|
+
**Expected consumer behavior:**
|
|
597
|
+
- Append a log entry to `.nexus/state/tool-log.jsonl`: timestamp, agent_id, tool name, file path (if a file was touched), result status.
|
|
598
|
+
- If the tool was a file-editing tool, update `edit-tracker.json`: record the file path and the agent_id that modified it. This is the data source for bounded-tier resume evaluation.
|
|
599
|
+
- If the tool result indicates an error, record the error in the log for diagnostic purposes. Do not suppress error results.
|
|
600
|
+
|
|
601
|
+
---
|
|
602
|
+
|
|
603
|
+
#### `session_end`
|
|
604
|
+
|
|
605
|
+
**When it fires:** The user closes the harness or the session terminates.
|
|
606
|
+
|
|
607
|
+
**Expected consumer behavior:**
|
|
608
|
+
- Check for pending tasks: if `tasks.json` exists and contains incomplete tasks (status `pending` or `in_progress`), warn the user that the session is ending with unfinished work and suggest calling `task_close` to archive before exiting.
|
|
609
|
+
- Check for an active plan: if `plan.json` exists, warn that the plan session will be lost if not archived.
|
|
610
|
+
- Delete `runtime.json` and `agent-tracker.json` (session-scoped files that have no value beyond the session).
|
|
611
|
+
- Optionally rotate or archive `tool-log.jsonl` if your harness supports log retention.
|
|
612
|
+
- Do not delete `history.json`, `memory/`, `context/`, or `rules/` — these are project-scoped and must persist.
|
|
613
|
+
|
|
614
|
+
---
|
|
615
|
+
|
|
616
|
+
#### `context_compact`
|
|
617
|
+
|
|
618
|
+
**When it fires:** The LLM's context window is compressed (older messages are truncated to make room for new content).
|
|
619
|
+
|
|
620
|
+
**Expected consumer behavior:**
|
|
621
|
+
- Re-inject the critical session snapshot that was lost in compression:
|
|
622
|
+
- Active skill/mode: which skill is currently active (plan, run, sync, or none).
|
|
623
|
+
- Plan status: if `plan.json` exists, re-inject the issue list with pending/decided status.
|
|
624
|
+
- Task progress: if `tasks.json` exists, re-inject the task list with status and ready-task set.
|
|
625
|
+
- Knowledge file index: re-inject the list of files in `.nexus/memory/`, `.nexus/context/`, `.nexus/rules/`.
|
|
626
|
+
- Active agent list: re-inject which subagents are currently tracked in `agent-tracker.json`.
|
|
627
|
+
- Context compaction is a context loss event. The LLM cannot reconstruct session state from its compressed context alone. Your consumer must restore state from the state files on disk.
|
|
628
|
+
- Read state files fresh from disk — do not rely on in-memory caches that may also have been cleared.
|
|
629
|
+
|
|
630
|
+
---
|
|
631
|
+
|
|
632
|
+
## 10. Subagent Orchestration Model
|
|
633
|
+
|
|
634
|
+
Subagent orchestration is the mechanism by which Lead delegates work to specialized agents. nexus-core specifies the behavioral contracts; the implementation mechanism is consumer-decided.
|
|
635
|
+
|
|
636
|
+
### Spawn model
|
|
637
|
+
|
|
638
|
+
When Lead assigns a task to an agent, the consumer:
|
|
639
|
+
|
|
640
|
+
1. Creates an isolated LLM session for the agent. The isolation mechanism is implementation-specific: a subprocess, an API call to a sandboxed session, a parallel conversation thread, or any other approach your harness supports.
|
|
641
|
+
2. Injects the agent's `body.md` as the agent's system prompt or initial context. This is the agent's identity and behavioral specification.
|
|
642
|
+
3. Applies tool restrictions derived from `effective_capabilities` (see §6). The agent session must not have access to tools in its disallowed set.
|
|
643
|
+
4. Passes the task's structured context as the agent's working prompt.
|
|
644
|
+
5. Waits for the agent to complete and collects the result.
|
|
645
|
+
|
|
646
|
+
### Context passing
|
|
647
|
+
|
|
648
|
+
Pass task context to the agent in this structured format:
|
|
649
|
+
|
|
650
|
+
```
|
|
651
|
+
TASK: {task.title}
|
|
652
|
+
|
|
653
|
+
CONTEXT:
|
|
654
|
+
{task.context}
|
|
655
|
+
|
|
656
|
+
APPROACH:
|
|
657
|
+
{task.approach}
|
|
658
|
+
|
|
659
|
+
ACCEPTANCE:
|
|
660
|
+
{task.acceptance}
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
Omit sections whose fields are absent (not all tasks have `approach` or `acceptance` defined). The `task_list` tool returns the full task structure including all optional fields.
|
|
664
|
+
|
|
665
|
+
Also inject:
|
|
666
|
+
- The knowledge index: file paths in `.nexus/memory/`, `.nexus/context/`, `.nexus/rules/`
|
|
667
|
+
- Harness-specific tool name mapping: which of your harness's concrete tool names correspond to the abstract nexus operations the agent's body.md may reference
|
|
668
|
+
- Any `harness_docs_refs` from the active skill's meta.yml
|
|
669
|
+
|
|
670
|
+
### Result collection
|
|
671
|
+
|
|
672
|
+
The agent produces output: file changes, artifact files, reports, or analysis. How the result is returned to Lead is consumer-decided. Common patterns:
|
|
673
|
+
|
|
674
|
+
- **Return value** — the subagent session's final message is returned as a string; Lead reads it directly.
|
|
675
|
+
- **Shared filesystem** — the agent writes to `.nexus/state/artifacts/` via the `artifact_write` tool; Lead reads the file.
|
|
676
|
+
- **Message passing** — the agent sends a structured message to Lead via your harness's inter-agent communication mechanism; Lead receives and acts on it.
|
|
677
|
+
|
|
678
|
+
The body.md of each agent specifies that it should "report to Lead" — whatever concrete mechanism you implement, ensure that the agent's output reaches Lead before the subagent session closes.
|
|
679
|
+
|
|
680
|
+
Lead is the only coordinator. Subagents do not communicate directly with each other. All inter-agent communication flows through Lead.
|
|
681
|
+
|
|
682
|
+
### Resume model
|
|
683
|
+
|
|
684
|
+
Before spawning an agent, evaluate whether to spawn fresh or resume a prior session. The evaluation follows three inputs:
|
|
685
|
+
|
|
686
|
+
**1. `owner_reuse_policy` from `tasks.json`** (per-task override, highest priority):
|
|
687
|
+
|
|
688
|
+
| Value | Effect |
|
|
689
|
+
|-------|--------|
|
|
690
|
+
| `fresh` | Always spawn fresh; ignore resume_tier |
|
|
691
|
+
| `resume_if_same_artifact` | Resume only if same agent, same target files, no intervening edits |
|
|
692
|
+
| `resume` | Always resume if a prior session is available |
|
|
693
|
+
| absent | Fall back to the agent's default resume_tier |
|
|
694
|
+
|
|
695
|
+
**2. Agent `resume_tier` from `manifest.json`** (default behavior):
|
|
696
|
+
|
|
697
|
+
| Tier | Behavior |
|
|
698
|
+
|------|----------|
|
|
699
|
+
| `ephemeral` | Always spawn fresh. Independent verification requires no prior context. Applies to: tester, reviewer. |
|
|
700
|
+
| `bounded` | Resume only when: same owner identity, same target files, no intervening edits by others. Re-read target files at session start. Applies to: engineer, writer. |
|
|
701
|
+
| `persistent` | Resume by default within the same run session. Cross-task reuse allowed. Applies to: architect, designer, postdoc, strategist, researcher. |
|
|
702
|
+
|
|
703
|
+
**3. Resume gating**:
|
|
704
|
+
|
|
705
|
+
Before attempting to resume, verify that your harness supports the resume mechanism for the current context. If the mechanism is unavailable (the harness cannot reopen a prior session, or no session ID was recorded for this agent), fall back to a fresh spawn silently. Do not surface a resume failure as an error to the user.
|
|
706
|
+
|
|
707
|
+
For `bounded` agents evaluating resume eligibility:
|
|
708
|
+
- Check `agent-tracker.json` for the prior agent ID assigned to this task.
|
|
709
|
+
- Check `edit-tracker.json` to determine if any other agent has modified the target files since the last session.
|
|
710
|
+
- If any intervening edit is found, use a fresh spawn regardless of `owner_reuse_policy`.
|
|
711
|
+
|
|
712
|
+
Full resume tier definitions are in [behavioral-contracts.md §3](./behavioral-contracts.md).
|
|
713
|
+
|
|
714
|
+
### Inter-agent communication boundary
|
|
715
|
+
|
|
716
|
+
Subagents communicate results to Lead. Lead is responsible for all coordination. No direct subagent-to-subagent communication is defined or permitted by the nexus-core model.
|
|
717
|
+
|
|
718
|
+
If your harness exposes an inter-agent communication tool, it must be available to Lead and may be made available to subagents for the purpose of reporting back to Lead. Subagents must not use it to route work to other subagents — that is Lead's responsibility.
|
|
719
|
+
|
|
720
|
+
---
|
|
721
|
+
|
|
722
|
+
## 11. Conformance Verification
|
|
723
|
+
|
|
724
|
+
Conformance fixtures verify that your tool implementations behave identically to the nexus-core specification. Passing all fixtures guarantees interoperability with any other nexus-core consumer and ensures your harness will remain compatible as nexus-core evolves.
|
|
725
|
+
|
|
726
|
+
### Fixture types
|
|
727
|
+
|
|
728
|
+
**Tool fixtures** (`conformance/tools/*.json`) — single-action tests for individual tools. Each fixture specifies:
|
|
729
|
+
- `precondition` — which state files must exist or must not exist before the test
|
|
730
|
+
- `action` — the tool name and parameters to call
|
|
731
|
+
- `postcondition` — assertions on the return value and state file contents after the call
|
|
732
|
+
|
|
733
|
+
**Scenario fixtures** (`conformance/scenarios/*.json`) — multi-step tests for end-to-end lifecycle flows. Each fixture specifies a sequence of steps, each with an action and assertions. Scenarios cover flows such as a full plan cycle and dependency-ordered task execution.
|
|
734
|
+
|
|
735
|
+
Available fixture files in nexus-core 0.2.0:
|
|
736
|
+
|
|
737
|
+
| File | Coverage |
|
|
738
|
+
|------|----------|
|
|
739
|
+
| `conformance/tools/plan-start.json` | `plan_start` happy path and edge cases |
|
|
740
|
+
| `conformance/tools/plan-decide.json` | `plan_decide` decision recording |
|
|
741
|
+
| `conformance/tools/task-add.json` | `task_add` creation and first-time initialization |
|
|
742
|
+
| `conformance/tools/task-close.json` | `task_close` archiving and state file deletion |
|
|
743
|
+
| `conformance/scenarios/full-plan-cycle.json` | Complete plan → decide → task → close lifecycle |
|
|
744
|
+
| `conformance/scenarios/task-deps-ordering.json` | Dependency-ordered task readiness computation |
|
|
745
|
+
|
|
746
|
+
### Writing a test runner
|
|
747
|
+
|
|
748
|
+
A conformance test runner:
|
|
749
|
+
|
|
750
|
+
1. Loads a fixture JSON file.
|
|
751
|
+
2. Establishes the precondition: writes or deletes state files as specified.
|
|
752
|
+
3. Calls your harness's implementation of the named tool with the fixture's parameters.
|
|
753
|
+
4. Evaluates postconditions using JSONPath assertions against the return value and state files.
|
|
754
|
+
5. Reports pass/fail per `test_id`.
|
|
755
|
+
|
|
756
|
+
Assertion keys in postconditions are JSONPath expressions. A `null` value at a file path key means the file must not exist. A `null` value at a JSONPath key means that field must be `null`.
|
|
757
|
+
|
|
758
|
+
The fixture format schema is at `conformance/schema/fixture.schema.json`.
|
|
759
|
+
|
|
760
|
+
For runner implementation patterns and a TypeScript sketch, see [conformance/README.md](../conformance/README.md).
|
|
761
|
+
|
|
762
|
+
### CI integration
|
|
763
|
+
|
|
764
|
+
Add the conformance test runner to your CI pipeline. Conformance failures on a version bump indicate a breaking behavioral change in your tool implementation. Do not merge harness changes that break conformance unless you have intentionally diverged from the spec (which is not recommended and is not supported).
|
|
765
|
+
|
|
766
|
+
Conformance verification is distinct from your harness's own unit tests. Run both.
|
|
767
|
+
|
|
768
|
+
---
|
|
769
|
+
|
|
770
|
+
## 12. Minimum Viable Consumer
|
|
771
|
+
|
|
772
|
+
The smallest working Nexus session requires exactly these components. Build this first, verify it works end to end, then expand incrementally.
|
|
773
|
+
|
|
774
|
+
### Tools (4 minimum)
|
|
775
|
+
|
|
776
|
+
| Abstract name | Purpose |
|
|
777
|
+
|---------------|---------|
|
|
778
|
+
| `plan_start` | Create a planning session |
|
|
779
|
+
| `plan_decide` | Record decisions on plan issues |
|
|
780
|
+
| `task_add` | Add tasks to the execution list |
|
|
781
|
+
| `task_close` | Archive the cycle and clean up session state |
|
|
782
|
+
|
|
783
|
+
This set covers the complete plan → decide → add tasks → close cycle. Implement these four tools first, run their conformance fixtures, and verify the full cycle before adding more tools.
|
|
784
|
+
|
|
785
|
+
### Agent (1 minimum)
|
|
786
|
+
|
|
787
|
+
Register the `engineer` agent:
|
|
788
|
+
|
|
789
|
+
- **body.md**: `agents/engineer/body.md`
|
|
790
|
+
- **resume_tier**: `bounded`
|
|
791
|
+
- **capabilities**: `no_task_create`
|
|
792
|
+
- **model_tier**: `standard`
|
|
793
|
+
|
|
794
|
+
Engineer is the execution agent. With engineer alone, Lead can delegate implementation tasks and collect results.
|
|
795
|
+
|
|
796
|
+
### Skill (1 minimum)
|
|
797
|
+
|
|
798
|
+
Activate `nx-plan` when the user types `[plan]`:
|
|
799
|
+
|
|
800
|
+
- **body.md**: `skills/nx-plan/body.md`
|
|
801
|
+
- **trigger**: `[plan]` (from `vocabulary/tags.yml`)
|
|
802
|
+
- **type**: `skill`
|
|
803
|
+
|
|
804
|
+
Implement tag detection in your `user_message` hook. When `[plan]` is detected, load `skills/nx-plan/body.md` and inject it into Lead's context.
|
|
805
|
+
|
|
806
|
+
### Hook events (3 minimum)
|
|
807
|
+
|
|
808
|
+
| Event | Minimum required behavior |
|
|
809
|
+
|-------|--------------------------|
|
|
810
|
+
| `session_start` | Create `.nexus/state/` directory; write `runtime.json`; initialize `agent-tracker.json` as `[]` |
|
|
811
|
+
| `user_message` | Detect `[plan]` tag; load `skills/nx-plan/body.md`; inject into Lead's context |
|
|
812
|
+
| `session_end` | Check for `tasks.json`; if present with incomplete tasks, warn the user |
|
|
813
|
+
|
|
814
|
+
### State files (3 minimum)
|
|
815
|
+
|
|
816
|
+
| File | Why it is required |
|
|
817
|
+
|------|--------------------|
|
|
818
|
+
| `plan.json` | Written by `plan_start`; read by `plan_decide` |
|
|
819
|
+
| `tasks.json` | Written by `task_add`; archived by `task_close` |
|
|
820
|
+
| `history.json` | Written by `task_close`; the permanent project record |
|
|
821
|
+
|
|
822
|
+
### What this gives you
|
|
823
|
+
|
|
824
|
+
A minimum viable consumer supports this complete cycle:
|
|
825
|
+
|
|
826
|
+
1. User types `[plan] let's plan the feature` → `nx-plan` skill activates
|
|
827
|
+
2. Lead runs a planning session, calls `plan_start`, calls `plan_decide` for each issue
|
|
828
|
+
3. Lead calls `task_add` to create implementation tasks
|
|
829
|
+
4. Lead spawns engineer subagent with task context
|
|
830
|
+
5. Engineer completes the work
|
|
831
|
+
6. Lead calls `task_close` to archive the cycle
|
|
832
|
+
|
|
833
|
+
### Incremental expansion path
|
|
834
|
+
|
|
835
|
+
Add components in this order after verifying the MVC:
|
|
836
|
+
|
|
837
|
+
1. **`[run]` skill + `nx-run` body** — adds structured execution orchestration; Lead gets the full delegation protocol for parallel task assignment
|
|
838
|
+
2. **Remaining 7 agents** — researcher, architect, postdoc, strategist, designer, writer, tester, reviewer; adds parallel analysis and verification roles
|
|
839
|
+
3. **Remaining 7 tools** — `plan_status`, `plan_update`, `task_list`, `task_update`, `history_search`, `context`, `artifact_write`; completes the full tool surface
|
|
840
|
+
4. **All 8 hook events** — adds `subagent_spawn`, `subagent_complete`, `pre_tool_use`, `post_tool_use`, `context_compact` for full lifecycle management
|
|
841
|
+
5. **Conformance suite** — run all fixtures in `conformance/tools/` and `conformance/scenarios/` before marking the harness production-ready
|
|
842
|
+
6. **`[sync]` skill** — adds `nx-sync` for keeping `.nexus/context/` synchronized with project state
|
|
843
|
+
|
|
844
|
+
Do not add the `[sync]`, `nx-init`, or `nx-setup` skills until the core planning and execution lifecycle is verified. These skills depend on the project state infrastructure built by the earlier components.
|