@moreih29/nexus-core 0.1.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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -0
  3. package/agents/architect/body.md +160 -0
  4. package/agents/architect/meta.yml +13 -0
  5. package/agents/designer/body.md +109 -0
  6. package/agents/designer/meta.yml +13 -0
  7. package/agents/engineer/body.md +92 -0
  8. package/agents/engineer/meta.yml +11 -0
  9. package/agents/postdoc/body.md +106 -0
  10. package/agents/postdoc/meta.yml +13 -0
  11. package/agents/researcher/body.md +122 -0
  12. package/agents/researcher/meta.yml +12 -0
  13. package/agents/reviewer/body.md +123 -0
  14. package/agents/reviewer/meta.yml +12 -0
  15. package/agents/strategist/body.md +100 -0
  16. package/agents/strategist/meta.yml +13 -0
  17. package/agents/tester/body.md +180 -0
  18. package/agents/tester/meta.yml +12 -0
  19. package/agents/writer/body.md +108 -0
  20. package/agents/writer/meta.yml +11 -0
  21. package/manifest.json +317 -0
  22. package/package.json +50 -0
  23. package/schema/README.md +69 -0
  24. package/schema/agent.schema.json +23 -0
  25. package/schema/common.schema.json +21 -0
  26. package/schema/manifest.schema.json +61 -0
  27. package/schema/skill.schema.json +39 -0
  28. package/schema/vocabulary.schema.json +92 -0
  29. package/skills/nx-init/body.md +199 -0
  30. package/skills/nx-init/meta.yml +4 -0
  31. package/skills/nx-plan/body.md +336 -0
  32. package/skills/nx-plan/meta.yml +7 -0
  33. package/skills/nx-run/body.md +149 -0
  34. package/skills/nx-run/meta.yml +5 -0
  35. package/skills/nx-setup/body.md +196 -0
  36. package/skills/nx-setup/meta.yml +4 -0
  37. package/skills/nx-sync/body.md +81 -0
  38. package/skills/nx-sync/meta.yml +6 -0
  39. package/vocabulary/capabilities.yml +32 -0
  40. package/vocabulary/categories.yml +11 -0
  41. package/vocabulary/resume-tiers.yml +11 -0
  42. package/vocabulary/tags.yml +51 -0
@@ -0,0 +1,39 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "skill.schema.json",
4
+ "title": "Nexus Skill meta.yml",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["id", "name", "description"],
8
+ "properties": {
9
+ "id": { "$ref": "common.schema.json#/$defs/id" },
10
+ "name": { "type": "string", "minLength": 1 },
11
+ "description": { "$ref": "common.schema.json#/$defs/description" },
12
+ "triggers": {
13
+ "type": "array",
14
+ "minItems": 1,
15
+ "items": { "$ref": "common.schema.json#/$defs/id" }
16
+ },
17
+ "alias_ko": { "type": "string" },
18
+ "manual_only": { "type": "boolean", "default": false }
19
+ },
20
+ "allOf": [
21
+ {
22
+ "if": {
23
+ "properties": { "manual_only": { "const": true } },
24
+ "required": ["manual_only"]
25
+ },
26
+ "then": {},
27
+ "else": {
28
+ "properties": {
29
+ "triggers": {
30
+ "type": "array",
31
+ "minItems": 1,
32
+ "items": { "$ref": "common.schema.json#/$defs/id" }
33
+ }
34
+ },
35
+ "required": ["triggers"]
36
+ }
37
+ }
38
+ ]
39
+ }
@@ -0,0 +1,92 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "vocabulary.schema.json",
4
+ "title": "Nexus Vocabulary files",
5
+ "$defs": {
6
+ "capabilityEntry": {
7
+ "type": "object",
8
+ "additionalProperties": false,
9
+ "required": ["id", "description", "harness_mapping"],
10
+ "properties": {
11
+ "id": { "$ref": "common.schema.json#/$defs/id" },
12
+ "description": { "$ref": "common.schema.json#/$defs/description" },
13
+ "harness_mapping": {
14
+ "type": "object",
15
+ "additionalProperties": false,
16
+ "required": ["claude_code", "opencode"],
17
+ "properties": {
18
+ "claude_code": { "type": "array", "items": { "type": "string", "minLength": 1 } },
19
+ "opencode": { "type": "array", "items": { "type": "string", "minLength": 1 } }
20
+ }
21
+ }
22
+ }
23
+ },
24
+ "capabilityFile": {
25
+ "type": "object",
26
+ "additionalProperties": false,
27
+ "required": ["capabilities"],
28
+ "properties": {
29
+ "capabilities": { "type": "array", "items": { "$ref": "#/$defs/capabilityEntry" } }
30
+ }
31
+ },
32
+ "simpleEntry": {
33
+ "type": "object",
34
+ "additionalProperties": false,
35
+ "required": ["id", "description"],
36
+ "properties": {
37
+ "id": { "$ref": "common.schema.json#/$defs/id" },
38
+ "description": { "$ref": "common.schema.json#/$defs/description" }
39
+ }
40
+ },
41
+ "categoryFile": {
42
+ "type": "object",
43
+ "additionalProperties": false,
44
+ "required": ["categories"],
45
+ "properties": {
46
+ "categories": { "type": "array", "items": { "$ref": "#/$defs/simpleEntry" } }
47
+ }
48
+ },
49
+ "resumeTierFile": {
50
+ "type": "object",
51
+ "additionalProperties": false,
52
+ "required": ["resume_tiers"],
53
+ "properties": {
54
+ "resume_tiers": { "type": "array", "items": { "$ref": "#/$defs/simpleEntry" } }
55
+ }
56
+ },
57
+ "tagEntry": {
58
+ "type": "object",
59
+ "additionalProperties": false,
60
+ "required": ["id", "trigger", "type", "description"],
61
+ "properties": {
62
+ "id": { "$ref": "common.schema.json#/$defs/id" },
63
+ "trigger": { "type": "string", "minLength": 1 },
64
+ "type": { "type": "string", "enum": ["skill", "inline_action"] },
65
+ "description": { "$ref": "common.schema.json#/$defs/description" },
66
+ "skill": { "$ref": "common.schema.json#/$defs/id" },
67
+ "handler": { "type": "string", "minLength": 1 },
68
+ "variants": { "type": "array", "items": { "type": "string", "minLength": 1 } }
69
+ },
70
+ "if": {
71
+ "properties": { "type": { "const": "skill" } },
72
+ "required": ["type"]
73
+ },
74
+ "then": {
75
+ "properties": { "skill": {} },
76
+ "required": ["skill"]
77
+ },
78
+ "else": {
79
+ "properties": { "handler": {} },
80
+ "required": ["handler"]
81
+ }
82
+ },
83
+ "tagFile": {
84
+ "type": "object",
85
+ "additionalProperties": false,
86
+ "required": ["tags"],
87
+ "properties": {
88
+ "tags": { "type": "array", "items": { "$ref": "#/$defs/tagEntry" } }
89
+ }
90
+ }
91
+ }
92
+ }
@@ -0,0 +1,199 @@
1
+ ## Role
2
+
3
+ Scans the project and builds Nexus knowledge in the flat .nexus/ structure. On first run, performs a 5-step full onboarding sequence.
4
+
5
+ ## Constraints
6
+
7
+ - NEVER modify source code. Slimming down CLAUDE.md beyond the project section is not this skill's responsibility.
8
+ - NEVER infer or guess information that cannot be confirmed from code — do not write it to context/.
9
+ - NEVER store secrets (API keys, credentials, etc.) in knowledge files.
10
+ - NEVER overwrite existing files without `--reset`. On resume, preserve existing files.
11
+ - Project section in CLAUDE.md MUST go through user confirmation before writing.
12
+ - NEVER reference or create identity/, codebase/, reference/, or core/ paths.
13
+ - Essentials section MUST NOT exceed 10 lines. If more items are needed, move lower-priority ones to .nexus/context/.
14
+
15
+ ## Guidelines
16
+
17
+ ## Trigger
18
+
19
+ - `/claude-nexus:nx-init` — full onboarding (or resume)
20
+ - `/claude-nexus:nx-init --reset` — back up existing `.nexus/` knowledge and re-onboard
21
+ - `/claude-nexus:nx-init --reset --cleanup` — show backup list + selective deletion
22
+
23
+ ---
24
+
25
+ ## Modes
26
+
27
+ ### First Run (no `.nexus/` flat structure)
28
+
29
+ Automatically runs the 5-step full onboarding.
30
+
31
+ Detection: `.nexus/context/`, `.nexus/memory/`, `.nexus/state/`, `.nexus/rules/` do not exist.
32
+
33
+ ### Resume (`.nexus/` partially exists)
34
+
35
+ Check existing state and resume from the first incomplete step.
36
+
37
+ ### Reset (`--reset`)
38
+
39
+ Back up existing `.nexus/` knowledge directories to `.nexus/bak.{timestamp}/`, then enter First Run.
40
+
41
+ ### Cleanup (`--reset --cleanup`)
42
+
43
+ Show backup directory list, let user select backups to delete.
44
+
45
+ ---
46
+
47
+ ## Process
48
+
49
+ ### Phase 0: Mode Detection
50
+
51
+ ```
52
+ IF --reset --cleanup flag:
53
+ Show list of .nexus/bak.*/ directories
54
+ AskUserQuestion({
55
+ questions: [{
56
+ question: "Select a backup to delete (or cancel)",
57
+ options: [...backup list..., { label: "Cancel", description: "Exit without changes" }]
58
+ }]
59
+ })
60
+ Delete selected backup and exit
61
+
62
+ ELSE IF --reset flag:
63
+ Move .nexus/{memory,context,state,rules}/ → .nexus/bak.{timestamp}/
64
+ Inform: "Existing knowledge has been backed up to .nexus/bak.{timestamp}/. Starting re-onboarding."
65
+ → Enter First Run
66
+
67
+ ELSE IF .nexus/context/ exists:
68
+ → Enter Resume (check existing steps and resume)
69
+
70
+ ELSE:
71
+ → Enter First Run (from Step 1)
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Steps
77
+
78
+ ### Step 1: Project Scan
79
+
80
+ Auto-detect code structure and tech stack. Create the flat `.nexus/` directory structure if it does not exist.
81
+
82
+ Create directories (using Bash mkdir):
83
+ - `.nexus/memory/`
84
+ - `.nexus/context/`
85
+ - `.nexus/state/`
86
+ - `.nexus/rules/`
87
+
88
+ Collected items:
89
+ - **Directory structure**: top-level layout, major modules/packages
90
+ - **Tech stack**: language, framework, runtime (package.json, Cargo.toml, pyproject.toml, go.mod, build.gradle, etc.)
91
+ - **Build/test system**: scripts, CI configuration
92
+ - **Existing docs**: CLAUDE.md, README.md, docs/, .cursorrules, etc.
93
+ - **git context**: recent commits, branch structure, contributors
94
+
95
+ Output: scan summary (language, framework, structure overview)
96
+
97
+ For large projects (10+ top-level directories or 100+ files), consider spawning an Explore subagent for parallel scanning to reduce Lead context usage.
98
+
99
+ ### Step 2: Mission + Essentials (Interactive)
100
+
101
+ Using the Step 1 scan results, draft a Mission statement (1–2 lines) and an Essentials list, then present both to the user for confirmation in a single pass.
102
+
103
+ #### Essentials Guidelines
104
+
105
+ Essentials are agent-critical facts — things an agent would get wrong if it didn't know them. Apply this judgment criterion: **"Would an agent produce wrong results without knowing this?"** Yes → Essentials. No → .nexus/context/.
106
+
107
+ Draft from these five categories (include only what applies to this project):
108
+
109
+ - **Tech stack** — runtime, language, package manager, core framework. Flag non-default tools (e.g. bun instead of npm, deno instead of node).
110
+ - **Workflow** — build, test, deploy commands. Must-follow procedures such as required lint or type-check steps before committing.
111
+ - **Constraints** — forbidden tools, patterns, or approaches. Directories or files that must not be modified.
112
+ - **Domain** — target audience, required terminology or tone, compliance or regulatory constraints, methodology for research projects.
113
+ - **Conventions** — naming, structure, or style that deviate from general defaults. Project-specific patterns an agent would not infer.
114
+
115
+ Do not include items that are standard defaults for the detected tech stack. Do not exceed 10 lines total in the Essentials section.
116
+
117
+ #### Draft Presentation
118
+
119
+ Present the full draft to the user in this format:
120
+
121
+ ```
122
+ The following will be added to CLAUDE.md (existing content will not be changed):
123
+
124
+ <!-- PROJECT:START -->
125
+ ## {project-name}
126
+
127
+ {mission 1-2 lines}
128
+
129
+ ### Essentials
130
+ - {auto-detected item}
131
+ - {auto-detected item}
132
+ <!-- PROJECT:END -->
133
+
134
+ Any changes?
135
+ ```
136
+
137
+ Wait for the user to confirm or provide edits. Apply all changes in one pass — do not ask about Mission and Essentials separately.
138
+
139
+ After confirmation, write the section into CLAUDE.md inside markers using the Edit tool. If CLAUDE.md already contains `<!-- PROJECT:START -->` markers, replace the content between them. If CLAUDE.md does not exist, create it with the markers.
140
+
141
+ ### Step 3: Context Knowledge Auto-Generation
142
+
143
+ Analyze Step 1 scan results to generate context knowledge documents in `.nexus/context/`.
144
+
145
+ Principles:
146
+ - File names and content are decided freely based on project characteristics. No fixed templates.
147
+ - Existing docs are information sources only — do not replicate their structure verbatim.
148
+ - Do not guess content that cannot be confirmed from code.
149
+ - Typically 1-3 files are sufficient. More files are not better.
150
+ - **Generate abstract-level content only** — design patterns, architecture direction, module relationships, conventions. Do NOT include code-level details such as file listings, function signatures, or import maps. Those can be read directly from code.
151
+
152
+ Generation targets (select and name based on what the project actually needs):
153
+ - Development stack (languages, frameworks, runtimes, key dependencies, build/test/deploy workflow)
154
+ - Design and architecture (module relationships, data flow, core entry points, conventions)
155
+ - Implementation specifics (pipeline details, configuration patterns, file structure conventions, tool restrictions — anything too specific for CLAUDE.md but not readable from code alone)
156
+
157
+ Use the Write tool to create files at `.nexus/context/{chosen-name}.md`.
158
+
159
+ For large projects, spawn Writer subagents per topic to generate context knowledge in parallel. Lead coordinates and reviews outputs.
160
+
161
+ On completion: "context knowledge N files generated"
162
+
163
+ ### Step 4: Rules Initial Setup (Optional)
164
+
165
+ Check whether team custom rules are needed.
166
+
167
+ ```
168
+ AskUserQuestion({
169
+ questions: [{
170
+ question: "Do you want to set up development rules now?",
171
+ options: [
172
+ { label: "Set up", description: "Coding conventions, test policy, commit rules, etc." },
173
+ { label: "Skip", description: "Can be added later via [rule] tag" }
174
+ ]
175
+ }]
176
+ })
177
+ ```
178
+
179
+ If "Set up": present a draft based on scan results → user confirms → save via Write tool to `.nexus/rules/{topic}.md`.
180
+
181
+ If "Skip": inform and proceed to Step 5.
182
+
183
+ ### Step 5: Completion Summary
184
+
185
+ Output a summary of the onboarding results.
186
+
187
+ ```
188
+ ## Nexus Initialization Complete
189
+
190
+ ### Generated Files
191
+ - CLAUDE.md: project section — mission and essentials (<!-- PROJECT:START/END -->)
192
+ - .nexus/context/: {list of generated files}
193
+ - .nexus/rules/: {generated files or "none (skipped)"}
194
+
195
+ ### Next Steps
196
+ - [plan] — research, analyze, and plan before execution
197
+ - [run] — execute from a plan
198
+ - /claude-nexus:nx-init --reset — re-run onboarding (existing knowledge will be backed up)
199
+ ```
@@ -0,0 +1,4 @@
1
+ name: nx-init
2
+ description: Project onboarding — scan, mission, essentials, context generation
3
+ manual_only: true
4
+ id: nx-init
@@ -0,0 +1,336 @@
1
+ ## Role
2
+
3
+ Facilitate structured multi-perspective analysis using subagents to decompose issues, deliberate on options, and align on decisions. Lead acts as synthesizer AND active participant — orchestrates subagent research/analysis AND contributes its own position. Does not execute — planning only. Transition to execution is the user's decision.
4
+
5
+ ## Constraints
6
+
7
+ - NEVER execute — this skill is planning only; transition to execution is the user's decision
8
+ - NEVER call `nx_plan_start` before research is complete (research_summary is required)
9
+ - NEVER present multiple issues at once — one issue at a time only
10
+ - NEVER ask groundless questions — always research code/knowledge/decisions first
11
+ - NEVER use TeamCreate. SendMessage is permitted ONLY for resuming completed subagents whose `resume_tier` is `persistent` or `bounded`, and ONLY within the constraints of the Resume Policy section below. SendMessage to a `name` (running teammate communication) remains forbidden in plan sessions.
12
+ - MUST record all decisions with `[d]` tag so they are not scattered across turns
13
+ - MUST call `nx_plan_decide` when recording `[d]`
14
+ - MUST check for existing plan.json before starting a new session
15
+ - `[d]` without an active plan.json is BLOCKED — "[d]는 plan 세션 안에서만 유효합니다."
16
+ - MUST present a comparison table before asking for a decision — never present options as prose only. Format:
17
+
18
+ ```
19
+ | | A: {title} | B: {title} |
20
+ |---|---|---|
21
+ | Pros | ... | ... |
22
+ | Cons | ... | ... |
23
+ | Pick | | **(Recommended)** |
24
+ ```
25
+
26
+ ## Guidelines
27
+
28
+ ## Trigger
29
+
30
+ - Explicit tag: `[plan]` — continue existing session if plan.json exists, otherwise start new
31
+ - Additional analysis needed mid-session: spawn HOW subagents independently via Agent tool
32
+ - Continuing conversation without a tag → continue existing session
33
+
34
+ ---
35
+
36
+ ## Auto Mode (`[plan:auto]`)
37
+
38
+ When triggered with `[plan:auto]` or invoked via `Skill({ args: "auto" })`, run the full planning process **without user interaction**:
39
+
40
+ 1. **Research** — spawn researcher+Explore subagents (same as interactive)
41
+ 2. **Issue derivation** — Lead identifies issues from research
42
+ 3. **Auto-decide** — for each issue, Lead selects the recommended option without presenting choices. Each `nx_plan_decide(summary)` MUST include: selected approach + reason, AND rejected alternatives + why they were dismissed. No comparison table needed, but internal deliberation is mandatory.
43
+ 4. **Decision briefing** — output a concise summary of all decisions before generating tasks:
44
+ ```
45
+ [auto-plan complete] N issues, N decisions:
46
+ - #1: {selected} ({rejected alternative} — reason)
47
+ - #2: ...
48
+ ```
49
+ Do not wait for user response — proceed immediately to task generation.
50
+ 5. **Plan document** — generate tasks.json following Step 7 rules (including HOW-assisted decomposition if `how_agents` present in plan.json issues). Apply owner table and verification auto-pairing.
51
+
52
+ Key differences from interactive mode:
53
+ - No `AskUserQuestion` or comparison tables — Lead decides autonomously
54
+ - No dynamic agenda proposals — Lead handles all derived issues internally
55
+ - Output: tasks.json ready for `[run]` execution
56
+
57
+ **Scope by invocation context:**
58
+ - `[plan:auto]` standalone → auto-plan + briefing + tasks.json generation. Stops here.
59
+ - Invoked by `[run]` (tasks.json absent) → auto-plan + briefing + tasks.json generation + seamless execution transition. No pause between plan and run.
60
+
61
+ This mode is invoked internally by `[run]` when no tasks.json exists, or explicitly by the user with `[plan:auto]`.
62
+
63
+ ---
64
+
65
+ ## Procedure (Interactive Mode)
66
+
67
+ ### Step 1: Intent Discovery
68
+
69
+ Determine planning depth and identify which HOW subagents to delegate analysis to, based on Progressive Depth.
70
+
71
+ | Level | Signal | Exploration Scope |
72
+ |-------|--------|-------------------|
73
+ | **Specific** | File path, function name, error message, or concrete target named | Focused on the relevant file/module |
74
+ | **Direction-setting** | Open-ended question, "it would be nice if ~", choice needed among approaches | Related area + external case research |
75
+ | **Abstract** | "I don't know how to approach this", goal itself unclear, fundamental direction | Full codebase + external research + comparable project comparison |
76
+
77
+ - Specific request → confirm intent with 1–2 questions, derive issues immediately
78
+ - Direction-setting → use hypothesis-based questions to understand intent
79
+ - Abstract/fundamental → actively interview to uncover root goals the user hasn't clarified
80
+
81
+ **HOW subagent selection rule:**
82
+ - User explicitly names agents → use as-is, propose additions if gaps detected
83
+ - User does not name agents → Lead proposes based on issue scope, confirm with user
84
+ - Additional HOW subagents can be spawned at any time during analysis (Lead's or user's discretion)
85
+
86
+ ### Step 2: Research
87
+
88
+ Understand code, core knowledge, and prior decisions before forming a planning agenda.
89
+
90
+ **Start by checking existing knowledge**: before spawning any subagent, use Glob/Read to scan `.nexus/memory/` and `.nexus/context/` for relevant memos and context files, and use `nx_history_search` to check for prior decisions on this topic. If the needed information is already there, use it directly and skip or narrow the subagent spawn. Only spawn subagents to fill gaps not covered by existing knowledge.
91
+
92
+ **Approach selection:**
93
+
94
+ | Scenario | Approach |
95
+ |----------|----------|
96
+ | Codebase orientation | Spawn Explore agent (`subagent_type: "Explore"`) for file/code search |
97
+ | External research needed | Spawn Researcher agent (`subagent_type: "claude-nexus:researcher"`) for web search |
98
+ | Both codebase and external | Spawn Explore + Researcher in parallel |
99
+
100
+ - NEVER call `nx_plan_start` before research is complete.
101
+ - `research_summary` parameter in `nx_plan_start` is required — forces research completion before session creation.
102
+ - Researcher subagents are spawned via the Agent tool and return findings to Lead. They do not join the plan session.
103
+
104
+ **Existing session (plan.json present):**
105
+ - Check current state with `nx_plan_status`.
106
+ - If new topic or additional research needed → spawn researcher subagent accordingly.
107
+ - Do not proceed to next issue before research is complete.
108
+
109
+ ### Step 3: Session Setup
110
+
111
+ Register the planning session.
112
+
113
+ 1. **`nx_plan_start(topic, issues, research_summary)`** — register plan in plan.json; auto-archives any existing plan.json.
114
+ 2. Show the issue list to the user and confirm before proceeding.
115
+
116
+ ### Step 4: Analysis
117
+
118
+ **Always proceed one issue at a time.** Never present multiple issues simultaneously.
119
+
120
+ For each issue:
121
+
122
+ 1. **Current State Analysis** — Lead summarizes the current state and problems, drawing on research.
123
+ 2. **Subagent Analysis** — for complex issues, spawn HOW subagents (architect, strategist, etc.) in parallel via Agent tool. Each subagent independently analyzes the issue and returns findings.
124
+ - **Domain-Agent mapping** — match issue keywords to recommended HOW subagents:
125
+
126
+ | Domain keywords | Recommended HOW |
127
+ |----------------|-----------------|
128
+ | UI, UX, 디자인, 인터페이스, 사용자 경험, 레이아웃 | Designer |
129
+ | 아키텍처, 시스템 설계, 성능, 구조 변경, API, 스키마 | Architect |
130
+ | 비즈니스, 시장, 전략, 포지셔닝, 경쟁, 수익 | Strategist |
131
+ | 연구 방법론, 근거 평가, 문헌, 실험 설계 | Postdoc |
132
+
133
+ - **Opt-out default**: if the issue matches a domain in the mapping, spawning is the default. Multiple matches → multiple spawns. To skip, state "{Agent} not needed — reason: ..." in the analysis text.
134
+ - **No mapping match**: if no domain matches, Lead analyzes directly. When uncertain, spawn — the cost of an unnecessary spawn is lower than the cost of a shallow analysis.
135
+ - **Record HOW findings**: after HOW subagents return, include their agent names and key findings when recording the decision via `nx_plan_decide(how_agents=[...], how_summary={...})`. This data is stored in plan.json for Step 7 task generation.
136
+ 3. **Present Options** — after synthesis, Lead presents a comparison:
137
+
138
+ ```
139
+ | Item | A: {title} | B: {title} | C: {title} |
140
+ |------|-----------|-----------|-----------|
141
+ | Pros | ... | ... | ... |
142
+ | Cons | ... | ... | ... |
143
+ | Trade-offs | ... | ... | ... |
144
+ | Best for | ... | ... | ... |
145
+
146
+ **Recommendation: {X} ({title})**
147
+
148
+ - Option A falls short because {reason}
149
+ - Option B falls short because {reason}
150
+ - Option X overcomes {A/B limitations} → {core benefit}
151
+ ```
152
+
153
+ 4. **Await user response** — receive free-form responses. Users may combine options, push back, or ask follow-up questions.
154
+
155
+ ## Resume Policy
156
+
157
+ When `.nexus/state/runtime.json` shows `teams_enabled: false`, ALL resume paths are disabled — force fresh spawn. Otherwise:
158
+
159
+ | resume_tier | Same-issue default | Cross-issue | Disqualifiers |
160
+ |---|---|---|---|
161
+ | persistent | resume by default | Lead opt-in only | counter-evidence / reversal / re-review issue → fresh |
162
+ | bounded | conditional (same artifact only) | forbidden | loop 3x / feedback cycle (REVISION_REQUIRED) → fresh |
163
+ | ephemeral | forbidden | forbidden | N/A (always fresh) |
164
+
165
+ Before resuming a `bounded` agent: include a "re-read target files before any modification" instruction in the prompt. Bounded resume without re-read is BLOCKED.
166
+
167
+ `resume_tier` is read from each agent's frontmatter (`agents/*.md`). If absent, treat as `ephemeral` (most conservative).
168
+
169
+ ### Step 5: Record Decision
170
+
171
+ When the user decides, record with the `[d]` tag.
172
+
173
+ - gate.ts detects `[d]` and routes to `nx_plan_decide`.
174
+ - `nx_plan_decide(issue_id, summary)` — marks issue as `decided`, writes `decision` inline in plan.json.
175
+ - Decisions are NOT written to decisions.json — plan.json is the single source of truth.
176
+ - `[d]` without plan.json is blocked.
177
+ - **Progress anchoring**: immediately after recording, output one line: "Issue #N decided (M of K complete). Next: #X — {title}." This keeps the user oriented in multi-issue sessions.
178
+
179
+ **Immediately after each decision**, Lead checks: "Does this decision create follow-up questions or new issues?" If yes, propose adding via `nx_plan_update(action='add')` before moving to the next issue.
180
+
181
+ **Decision reversal**: if the user wants to reconsider a prior decision ("아까 결정 다시 생각해보자", "issue #N 번복"), Lead calls `nx_plan_update(action='reopen', issue_id=N)` to reopen the issue and returns to Step 4 analysis for that issue.
182
+
183
+ ### Step 6: Dynamic Agenda + Wrap-up
184
+
185
+ After each decision, Lead automatically checks for derived issues.
186
+
187
+ - **Dynamic agenda proposal**: after a decision is recorded, Lead examines whether the decision implies follow-on questions or unresolved sub-issues. If found, propose adding them with `nx_plan_update(action='add', ...)` and confirm with the user before adding.
188
+ - Pending issues remain → naturally transition to the next issue.
189
+ - All issues decided → **Gap check**: compare original question/topic against the issue list.
190
+ - Gap found → register additional issues with `nx_plan_update(action='add', ...)`, return to Step 4.
191
+ - No gap → signal planning complete.
192
+ - Wrap-up: confirm all analysis threads have reported conclusions to Lead.
193
+ - Proceed to Step 7 automatically — do not ask whether to generate the plan document.
194
+
195
+ ### Step 7: Plan Document Generation
196
+
197
+ All issues decided → generate the plan document (tasks.json) immediately:
198
+
199
+ 1. **Collect decisions** — gather all `decided` issues from plan.json
200
+ 2. **Derive tasks** — decompose decisions into concrete, actionable tasks
201
+
202
+ **HOW-assisted task decomposition**: check plan.json issues for `how_agents` field.
203
+ - If HOW agents participated in analysis → re-spawn those HOWs with the decided approach + their prior `how_summary` as context. Ask them to propose task decomposition and owner assignment for their domain.
204
+ - If no HOW agents participated → Lead decomposes alone using the owner table and auto-pairing rules above.
205
+ - This ensures task generation depth is proportional to plan analysis depth.
206
+
207
+ 3. **Enrich each task** with:
208
+ - `approach` — implementation strategy derived from the decision rationale
209
+ - `acceptance` — definition of done, verifiable criteria
210
+ - `risk` — known risks or caveats from the analysis
211
+ - `deps` — task dependencies based on execution order
212
+ - `owner` — assign based on delegation analysis:
213
+
214
+ | Task type | owner | Criteria |
215
+ |-----------|-------|----------|
216
+ | Single file, small change | **lead** | Subagent overhead > task effort |
217
+ | Code implementation (.ts, .js, .py, etc.) | **engineer** | Source code creation/modification |
218
+ | Documentation/content (.md, non-code) | **writer** | .md files, README, docs, non-code content |
219
+ | Web research / external investigation | **researcher** | External information gathering needed |
220
+ | Design analysis / review | **architect** etc. HOW | Technical trade-off judgment |
221
+ | Sequential edits to same file | **lead** | Parallel subagents risk conflict |
222
+
223
+ **Verification task auto-pairing** — create separate verification tasks:
224
+ - Task with `owner: "engineer"` + `acceptance` field → pair a **tester** task (verify acceptance criteria)
225
+ - Task with `owner: "writer"` → pair a **reviewer** task (verify deliverable)
226
+ - Paired verification tasks are linked via `deps` to the original task
227
+ 4. **Write tasks.json** via `nx_task_add`:
228
+ - Set `goal` from the plan topic
229
+ - Set `decisions` from plan.json decided summaries
230
+ - Call `nx_task_add(plan_issue=N, approach, acceptance, risk, owner)` for each task
231
+ - If any decisions involve design or architecture changes, include a task (owner: `writer` or `lead`) to update the relevant files in `.nexus/context/` to reflect those decisions
232
+ 5. **Present plan document** — show the user the generated tasks.json summary for review
233
+ 6. **Present transition**: "Proceed with `[run]` to execute."
234
+
235
+ **Incremental mode**: if tasks.json already exists (e.g., after adding follow-up issues), only add tasks for new decisions. Check `plan_issue` field to avoid duplicating tasks for already-covered issues.
236
+
237
+ ---
238
+
239
+ ## plan → run Transition
240
+
241
+ tasks.json is already generated in Step 7. Plan's role ends here.
242
+ Proceed with `[run]` to execute.
243
+
244
+ ---
245
+
246
+ ## Principles
247
+
248
+ 1. **Active intent discovery** — actively uncover what the user hasn't clarified. Use interviewing to surface the root goal behind the words.
249
+ 2. **Lead as synthesizer AND participant** — Lead does not merely relay subagent findings. Lead forms its own position, makes recommendations, and pushes back with evidence. Not a yes-man.
250
+ 3. **Exploration first + proactive expansion** — research code/knowledge/external sources before planning starts. Never ask groundless questions.
251
+ 4. **Hypothesis-based questions** — instead of empty questions, form hypotheses grounded in research and confirm with the user.
252
+ 5. **Progressive Depth** — automatically adjust planning depth and HOW subagent composition based on request complexity.
253
+ 6. **One at a time** — never present multiple issues at once. Reduce the user's cognitive load.
254
+ 7. **Options must include pros/cons/trade-offs/recommendation** — when recommending, explain why other options fall short.
255
+ 8. **Objective pushback** — even when the user arrives with strong conviction, Lead MUST independently analyze all viable options and present trade-offs the user may not have considered. The comparison table exists to surface what the user doesn't know, not to confirm what they already believe. Counter with evidence when better alternatives exist.
256
+ 9. **Prose conversation by default** — free-form user responses (combinations, pushback, follow-up questions) are the core of planning quality.
257
+ 10. **Dynamic agenda** — decisions create new questions. Lead proactively surfaces derived issues rather than waiting for the user to notice gaps.
258
+
259
+ ---
260
+
261
+ ## State Management
262
+
263
+ ### plan.json
264
+
265
+ `.nexus/state/plan.json` — managed via MCP tools.
266
+
267
+ ```json
268
+ {
269
+ "id": 1,
270
+ "topic": "topic name",
271
+ "issues": [
272
+ {
273
+ "id": 1,
274
+ "title": "issue title",
275
+ "status": "pending"
276
+ },
277
+ {
278
+ "id": 2,
279
+ "title": "issue title",
280
+ "status": "decided",
281
+ "decision": "decision summary",
282
+ "how_agents": ["architect", "designer"],
283
+ "how_summary": {
284
+ "architect": "key findings...",
285
+ "designer": "key findings..."
286
+ }
287
+ }
288
+ ],
289
+ "research_summary": "...",
290
+ "created_at": "2026-01-01T00:00:00Z"
291
+ }
292
+ ```
293
+
294
+ - **Create**: `nx_plan_start(topic, issues, research_summary)` — called in Step 3; auto-archives any existing plan.json
295
+ - **Read**: `nx_plan_status()` — check current issue state + decisions
296
+ - **Update**: `nx_plan_update(action, ...)` — add/remove/edit/reopen issues
297
+ - **Decide**: `nx_plan_decide(issue_id, summary)` — marks issue as `decided`, writes decision inline
298
+ - **File presence = session in progress**
299
+
300
+ ### Topic Switching
301
+
302
+ - `[plan]` → continue existing plan.json if present; start new session if not
303
+ - Continue conversation without tag → continue existing session
304
+ - New `nx_plan_start` call → auto-archives current plan.json before creating new one
305
+
306
+ ### Session Abort
307
+
308
+ To abort a session, archive current state via `nx_task_close`. Incomplete issues/tasks are recorded in history.json for future reference.
309
+
310
+ ---
311
+
312
+ ## Self-Reinforcing Loop
313
+
314
+ ```
315
+ [plan] start → check/continue existing plan.json (start new if none)
316
+
317
+ Intent discovery → research (parallel subagents) → nx_plan_start (register issues)
318
+
319
+ Per-issue: HOW subagent analysis (parallel, independent) → Lead synthesis
320
+ → options comparison → [d] → nx_plan_decide
321
+ → dynamic agenda check → propose derived issues if found
322
+
323
+ Next issue → ... → gap check → planning complete
324
+
325
+ Proceed with `[run]` to execute.
326
+
327
+ [run]: execution skill handles the full pipeline
328
+
329
+ All done → nx_task_close (handled by run skill)
330
+ ```
331
+
332
+ gate.ts detects `[d]` and routes to `nx_plan_decide` if plan.json exists; blocks otherwise.
333
+
334
+ ## Deactivation
335
+
336
+ When transitioning to `[run]`, Plan's role ends. Execution is handled by the run skill.