@moreih29/nexus-core 0.15.2 → 0.16.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.
Files changed (107) hide show
  1. package/assets/hooks/prompt-router/handler.ts +11 -0
  2. package/dist/assets/hooks/prompt-router/handler.d.ts.map +1 -1
  3. package/dist/assets/hooks/prompt-router/handler.js +10 -0
  4. package/dist/assets/hooks/prompt-router/handler.js.map +1 -1
  5. package/dist/claude/.claude-plugin/marketplace.json +75 -0
  6. package/dist/claude/.claude-plugin/plugin.json +67 -0
  7. package/dist/claude/agents/architect.md +172 -0
  8. package/dist/claude/agents/designer.md +120 -0
  9. package/dist/claude/agents/engineer.md +98 -0
  10. package/dist/claude/agents/lead.md +59 -0
  11. package/dist/claude/agents/postdoc.md +117 -0
  12. package/dist/claude/agents/researcher.md +132 -0
  13. package/dist/claude/agents/reviewer.md +133 -0
  14. package/dist/claude/agents/strategist.md +111 -0
  15. package/dist/claude/agents/tester.md +190 -0
  16. package/dist/claude/agents/writer.md +114 -0
  17. package/dist/claude/dist/hooks/agent-bootstrap.js +121 -0
  18. package/dist/claude/dist/hooks/agent-finalize.js +180 -0
  19. package/dist/claude/dist/hooks/prompt-router.js +7336 -0
  20. package/dist/claude/dist/hooks/session-init.js +37 -0
  21. package/dist/claude/hooks/hooks.json +52 -0
  22. package/dist/claude/settings.json +3 -0
  23. package/dist/claude/skills/nx-init/SKILL.md +189 -0
  24. package/dist/claude/skills/nx-plan/SKILL.md +353 -0
  25. package/dist/claude/skills/nx-run/SKILL.md +154 -0
  26. package/dist/claude/skills/nx-sync/SKILL.md +87 -0
  27. package/dist/codex/agents/architect.toml +172 -0
  28. package/dist/codex/agents/designer.toml +120 -0
  29. package/dist/codex/agents/engineer.toml +102 -0
  30. package/dist/codex/agents/lead.toml +64 -0
  31. package/dist/codex/agents/postdoc.toml +117 -0
  32. package/dist/codex/agents/researcher.toml +133 -0
  33. package/dist/codex/agents/reviewer.toml +134 -0
  34. package/dist/codex/agents/strategist.toml +111 -0
  35. package/dist/codex/agents/tester.toml +191 -0
  36. package/dist/codex/agents/writer.toml +118 -0
  37. package/dist/codex/dist/hooks/agent-bootstrap.js +121 -0
  38. package/dist/codex/dist/hooks/agent-finalize.js +180 -0
  39. package/dist/codex/dist/hooks/prompt-router.js +7336 -0
  40. package/dist/codex/dist/hooks/session-init.js +37 -0
  41. package/dist/codex/hooks/hooks.json +28 -0
  42. package/dist/codex/install/AGENTS.fragment.md +60 -0
  43. package/dist/codex/install/config.fragment.toml +5 -0
  44. package/dist/codex/install/install.sh +60 -0
  45. package/dist/codex/package.json +20 -0
  46. package/dist/codex/plugin/.codex-plugin/plugin.json +57 -0
  47. package/dist/codex/plugin/skills/nx-init/SKILL.md +189 -0
  48. package/dist/codex/plugin/skills/nx-plan/SKILL.md +353 -0
  49. package/dist/codex/plugin/skills/nx-run/SKILL.md +154 -0
  50. package/dist/codex/plugin/skills/nx-sync/SKILL.md +87 -0
  51. package/dist/codex/prompts/architect.md +166 -0
  52. package/dist/codex/prompts/designer.md +114 -0
  53. package/dist/codex/prompts/engineer.md +97 -0
  54. package/dist/codex/prompts/lead.md +60 -0
  55. package/dist/codex/prompts/postdoc.md +111 -0
  56. package/dist/codex/prompts/researcher.md +127 -0
  57. package/dist/codex/prompts/reviewer.md +128 -0
  58. package/dist/codex/prompts/strategist.md +105 -0
  59. package/dist/codex/prompts/tester.md +185 -0
  60. package/dist/codex/prompts/writer.md +113 -0
  61. package/dist/hooks/agent-bootstrap.js +1 -1
  62. package/dist/hooks/agent-finalize.js +1 -1
  63. package/dist/hooks/prompt-router.js +21 -1
  64. package/dist/hooks/session-init.js +1 -1
  65. package/dist/manifests/opencode-manifest.json +4 -4
  66. package/dist/opencode/.opencode/skills/nx-init/SKILL.md +189 -0
  67. package/dist/opencode/.opencode/skills/nx-plan/SKILL.md +353 -0
  68. package/dist/opencode/.opencode/skills/nx-run/SKILL.md +154 -0
  69. package/dist/opencode/.opencode/skills/nx-sync/SKILL.md +87 -0
  70. package/dist/opencode/package.json +23 -0
  71. package/dist/opencode/src/agents/architect.ts +176 -0
  72. package/dist/opencode/src/agents/designer.ts +124 -0
  73. package/dist/opencode/src/agents/engineer.ts +105 -0
  74. package/dist/opencode/src/agents/lead.ts +66 -0
  75. package/dist/opencode/src/agents/postdoc.ts +121 -0
  76. package/dist/opencode/src/agents/researcher.ts +136 -0
  77. package/dist/opencode/src/agents/reviewer.ts +137 -0
  78. package/dist/opencode/src/agents/strategist.ts +115 -0
  79. package/dist/opencode/src/agents/tester.ts +194 -0
  80. package/dist/opencode/src/agents/writer.ts +121 -0
  81. package/dist/opencode/src/index.ts +25 -0
  82. package/dist/opencode/src/plugin.ts +6 -0
  83. package/dist/scripts/build-agents.d.ts +0 -1
  84. package/dist/scripts/build-agents.d.ts.map +1 -1
  85. package/dist/scripts/build-agents.js +3 -15
  86. package/dist/scripts/build-agents.js.map +1 -1
  87. package/dist/scripts/build-hooks.d.ts.map +1 -1
  88. package/dist/scripts/build-hooks.js +27 -18
  89. package/dist/scripts/build-hooks.js.map +1 -1
  90. package/dist/scripts/smoke/smoke-claude.d.ts +2 -0
  91. package/dist/scripts/smoke/smoke-claude.d.ts.map +1 -0
  92. package/dist/scripts/smoke/smoke-claude.js +58 -0
  93. package/dist/scripts/smoke/smoke-claude.js.map +1 -0
  94. package/dist/scripts/smoke/smoke-codex.d.ts +2 -0
  95. package/dist/scripts/smoke/smoke-codex.d.ts.map +1 -0
  96. package/dist/scripts/smoke/smoke-codex.js +50 -0
  97. package/dist/scripts/smoke/smoke-codex.js.map +1 -0
  98. package/dist/scripts/smoke/smoke-consumer.d.ts +2 -0
  99. package/dist/scripts/smoke/smoke-consumer.d.ts.map +1 -0
  100. package/dist/scripts/smoke/smoke-consumer.js +80 -0
  101. package/dist/scripts/smoke/smoke-consumer.js.map +1 -0
  102. package/dist/scripts/smoke/smoke-opencode.d.ts +2 -0
  103. package/dist/scripts/smoke/smoke-opencode.d.ts.map +1 -0
  104. package/dist/scripts/smoke/smoke-opencode.js +99 -0
  105. package/dist/scripts/smoke/smoke-opencode.js.map +1 -0
  106. package/docs/contract/harness-io.md +51 -6
  107. package/package.json +8 -3
@@ -0,0 +1,37 @@
1
+ // assets/hooks/session-init/handler.ts
2
+ import { mkdirSync, writeFileSync } from "node:fs";
3
+ import { join, basename } from "node:path";
4
+ var handler = async (input) => {
5
+ if (input.hook_event_name !== "SessionStart")
6
+ return;
7
+ const safeSid = basename(input.session_id);
8
+ if (!safeSid || safeSid.startsWith(".") || safeSid.includes("/")) {
9
+ process.stderr.write(`[session-init] invalid session_id: ${input.session_id}
10
+ `);
11
+ return;
12
+ }
13
+ const sessionDir = join(input.cwd, ".nexus/state", safeSid);
14
+ mkdirSync(sessionDir, { recursive: true });
15
+ writeFileSync(join(sessionDir, "agent-tracker.json"), "[]");
16
+ writeFileSync(join(sessionDir, "tool-log.jsonl"), "");
17
+ };
18
+ var handler_default = handler;
19
+
20
+ // ../../../../../tmp/nexus-hook-entry-session-init-1776672660208/session-init-entry.ts
21
+ import { readFileSync } from "node:fs";
22
+ async function main() {
23
+ let raw = "";
24
+ try {
25
+ raw = readFileSync(0, "utf-8");
26
+ } catch {}
27
+ const input = raw ? JSON.parse(raw) : {};
28
+ const result = await handler_default(input);
29
+ if (result != null && result !== undefined) {
30
+ process.stdout.write(JSON.stringify(result));
31
+ }
32
+ }
33
+ main().then(() => process.exit(0), (err) => {
34
+ process.stderr.write(String(err?.stack ?? err) + `
35
+ `);
36
+ process.exit(1);
37
+ });
@@ -0,0 +1,28 @@
1
+ {
2
+ "hooks": {
3
+ "SessionStart": [
4
+ {
5
+ "command": "node ${CLAUDE_PLUGIN_ROOT}/dist/hooks/session-init.js",
6
+ "timeout": 10
7
+ }
8
+ ],
9
+ "UserPromptSubmit": [
10
+ {
11
+ "command": "node ${CLAUDE_PLUGIN_ROOT}/dist/hooks/prompt-router.js",
12
+ "timeout": 10
13
+ }
14
+ ],
15
+ "SubagentStop": [
16
+ {
17
+ "command": "node ${CLAUDE_PLUGIN_ROOT}/dist/hooks/agent-finalize.js",
18
+ "timeout": 10
19
+ }
20
+ ],
21
+ "SubagentStart": [
22
+ {
23
+ "command": "node ${CLAUDE_PLUGIN_ROOT}/dist/hooks/agent-bootstrap.js",
24
+ "timeout": 10
25
+ }
26
+ ]
27
+ }
28
+ }
@@ -0,0 +1,60 @@
1
+ <!-- nexus-core:lead:start -->
2
+ # lead
3
+
4
+ ## Identity
5
+
6
+ You are Lead — the sole agent who converses directly with users.
7
+ You orchestrate 9 subagents (architect, designer, postdoc, strategist, engineer, researcher, writer, reviewer, tester) to fulfill user requests.
8
+ Final responsibility for decision recording, scope judgment, and user-facing reporting rests with you.
9
+
10
+ ## Constraints
11
+
12
+ - **Task ownership**: You are the only agent authorized to call `nx_task_add` / `nx_task_update` / `nx_task_close`. Subagents do not create or update tasks.
13
+ - **Scope authority**: You consult HOW agents for advice, but final scope decisions are yours alone.
14
+ - **Skill delegation**: Delegate execution flows to skills. Use nx-plan for `[plan]`, nx-run for `[run]`, nx-sync for `[sync]`, and nx-init for initial onboarding. Detailed execution steps live inside each skill and are not duplicated in this body.
15
+ - **File editing**: No `no_file_edit` restriction — handle simple tasks directly.
16
+ - **Absolute prohibitions**:
17
+ - Spawning multiple subagents in parallel for the same task (risk of target file conflicts)
18
+ - Destructive git operations without explicit user instruction (`reset --hard`, `push --force`, etc.)
19
+ - Injecting hook messages in any language other than English
20
+
21
+ ## Collaboration
22
+
23
+ ### HOW agents (architect / designer / postdoc / strategist)
24
+ They advise on technical, UX, research methodology, and business judgment. They do not hold decision authority. You review their advice and make the final call.
25
+
26
+ ### DO agents (engineer / researcher / writer)
27
+ They handle execution, implementation, investigation, and writing. You provide task context, approach, and acceptance criteria, then review their deliverables.
28
+
29
+ ### CHECK agents (reviewer / tester)
30
+ They verify the accuracy and quality of deliverables.
31
+ - writer → reviewer: mandatory pairing
32
+ - engineer → tester: conditional pairing (when acceptance criteria include runtime requirements)
33
+
34
+ ### Direct handling vs. spawn decision
35
+ - Single file or small-scale edits: handle directly as Lead
36
+ - Three or more files, complex judgment, or specialist analysis: spawn a subagent
37
+
38
+ ### Resume Dispatch
39
+ Decide whether to reuse a completed subagent based on the `resume_tier` field (persistent / bounded / ephemeral) in the agent's frontmatter. See the nx-run skill for detailed rules.
40
+
41
+ ## Output Format
42
+
43
+ When responding to users, maintain the following structure:
44
+
45
+ - **Changes**: Paths and summaries of modified, created, or deleted files
46
+ - **Key Decisions**: Judgments made during this work (scope, approach, trade-offs)
47
+ - **Next Steps**: Follow-on actions the user can take (review, commit, further investigation, etc.)
48
+
49
+ For long responses, lead with the summary. For short questions, answer directly without structure.
50
+
51
+ ## References
52
+
53
+ | Skill | Purpose |
54
+ |-------|---------|
55
+ | nx-plan | Structured multi-perspective analysis and decision recording |
56
+ | nx-run | Task execution orchestration |
57
+ | nx-sync | `.nexus/context/` knowledge synchronization |
58
+ | nx-init | Project onboarding |
59
+
60
+ <!-- nexus-core:lead:end -->
@@ -0,0 +1,5 @@
1
+ # Auto-generated by build-agents.ts — do not edit
2
+ # Merge this fragment into your codex config.toml
3
+
4
+ [mcp_servers.nx]
5
+ command = "nexus-mcp"
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env bash
2
+ # Codex plugin installer — block-marker merge pattern.
3
+ # nexus-core Model 2: wrapper owns integration seams.
4
+ # Merges config.fragment.toml into ~/.codex/config.toml,
5
+ # copies native agent TOMLs to ~/.codex/agents/,
6
+ # and merges AGENTS.fragment.md into ~/.codex/AGENTS.md.
7
+ set -euo pipefail
8
+
9
+ PLUGIN_NAME="${PLUGIN_NAME:-codex-nexus}"
10
+ CODEX_HOME="${CODEX_HOME:-$HOME/.codex}"
11
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12
+ REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
13
+
14
+ mkdir -p "$CODEX_HOME" "$CODEX_HOME/agents" "$CODEX_HOME/plugins"
15
+
16
+ # 1. config.toml — block-marker merge
17
+ MARKER_BEGIN="# BEGIN ${PLUGIN_NAME}"
18
+ MARKER_END="# END ${PLUGIN_NAME}"
19
+ CONFIG="$CODEX_HOME/config.toml"
20
+ CONFIG_FRAGMENT="$SCRIPT_DIR/config.fragment.toml"
21
+
22
+ touch "$CONFIG"
23
+ if grep -q "${MARKER_BEGIN}" "$CONFIG" 2>/dev/null; then
24
+ sed -i.bak "/${MARKER_BEGIN}/,/${MARKER_END}/d" "$CONFIG"
25
+ fi
26
+ {
27
+ echo ""
28
+ echo "${MARKER_BEGIN}"
29
+ cat "$CONFIG_FRAGMENT"
30
+ echo "${MARKER_END}"
31
+ } >> "$CONFIG"
32
+
33
+ # 2. native agent TOMLs
34
+ cp "$REPO_ROOT"/agents/*.toml "$CODEX_HOME/agents/" 2>/dev/null || true
35
+
36
+ # 3. plugin body → ~/.codex/plugins/<name>/
37
+ PLUGIN_DEST="$CODEX_HOME/plugins/${PLUGIN_NAME}"
38
+ rm -rf "$PLUGIN_DEST"
39
+ mkdir -p "$PLUGIN_DEST"
40
+ cp -R "$REPO_ROOT"/plugin/. "$PLUGIN_DEST/"
41
+
42
+ # 4. AGENTS.md — block-marker merge
43
+ AGENTS_TARGET="$CODEX_HOME/AGENTS.md"
44
+ AGENTS_FRAGMENT="$SCRIPT_DIR/AGENTS.fragment.md"
45
+ FRAG_BEGIN="<!-- nexus-core:lead:start -->"
46
+ FRAG_END="<!-- nexus-core:lead:end -->"
47
+
48
+ if [ -f "$AGENTS_FRAGMENT" ]; then
49
+ touch "$AGENTS_TARGET"
50
+ if grep -q "${FRAG_BEGIN}" "$AGENTS_TARGET" 2>/dev/null; then
51
+ awk -v begin="${FRAG_BEGIN}" -v end="${FRAG_END}" '
52
+ $0 ~ begin { skip=1; next }
53
+ $0 ~ end { skip=0; next }
54
+ !skip { print }
55
+ ' "$AGENTS_TARGET" > "$AGENTS_TARGET.tmp" && mv "$AGENTS_TARGET.tmp" "$AGENTS_TARGET"
56
+ fi
57
+ cat "$AGENTS_FRAGMENT" >> "$AGENTS_TARGET"
58
+ fi
59
+
60
+ echo "Installed ${PLUGIN_NAME} → $CODEX_HOME"
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "codex-nexus",
3
+ "version": "0.13.0",
4
+ "description": "Nexus agent suite for Codex CLI",
5
+ "private": true,
6
+ "scripts": {
7
+ "sync": "bunx @moreih29/nexus-core sync --harness=codex --target=./",
8
+ "sync:dry": "bunx @moreih29/nexus-core sync --harness=codex --target=./ --dry-run",
9
+ "build": "bun run sync",
10
+ "validate": "bunx @moreih29/nexus-core validate",
11
+ "list": "bunx @moreih29/nexus-core list",
12
+ "install-plugin": "bash install/install.sh"
13
+ },
14
+ "devDependencies": {
15
+ "@moreih29/nexus-core": "^0.14.0"
16
+ },
17
+ "engines": {
18
+ "node": ">=22"
19
+ }
20
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "codex-nexus",
3
+ "version": "0.13.0",
4
+ "description": "Nexus agent suite for Codex",
5
+ "agents": [
6
+ {
7
+ "id": "architect",
8
+ "config": "agents/architect.toml",
9
+ "prompt": "prompts/architect.md"
10
+ },
11
+ {
12
+ "id": "designer",
13
+ "config": "agents/designer.toml",
14
+ "prompt": "prompts/designer.md"
15
+ },
16
+ {
17
+ "id": "engineer",
18
+ "config": "agents/engineer.toml",
19
+ "prompt": "prompts/engineer.md"
20
+ },
21
+ {
22
+ "id": "lead",
23
+ "config": "agents/lead.toml",
24
+ "prompt": "prompts/lead.md"
25
+ },
26
+ {
27
+ "id": "postdoc",
28
+ "config": "agents/postdoc.toml",
29
+ "prompt": "prompts/postdoc.md"
30
+ },
31
+ {
32
+ "id": "researcher",
33
+ "config": "agents/researcher.toml",
34
+ "prompt": "prompts/researcher.md"
35
+ },
36
+ {
37
+ "id": "reviewer",
38
+ "config": "agents/reviewer.toml",
39
+ "prompt": "prompts/reviewer.md"
40
+ },
41
+ {
42
+ "id": "strategist",
43
+ "config": "agents/strategist.toml",
44
+ "prompt": "prompts/strategist.md"
45
+ },
46
+ {
47
+ "id": "tester",
48
+ "config": "agents/tester.toml",
49
+ "prompt": "prompts/tester.md"
50
+ },
51
+ {
52
+ "id": "writer",
53
+ "config": "agents/writer.toml",
54
+ "prompt": "prompts/writer.md"
55
+ }
56
+ ]
57
+ }
@@ -0,0 +1,189 @@
1
+ ---
2
+ description: "Project onboarding — scan, mission, essentials, context generation"
3
+ ---
4
+ ## Role
5
+
6
+ Scans the project and builds Nexus knowledge in the flat .nexus/ structure. On first run, performs a 5-step full onboarding sequence.
7
+
8
+ ## Constraints
9
+
10
+ - NEVER modify source code. Slimming down the instruction file beyond the project section is not this skill's responsibility.
11
+ - NEVER infer or guess information that cannot be confirmed from code — do not write it to context/.
12
+ - NEVER store secrets (API keys, credentials, etc.) in knowledge files.
13
+ - NEVER overwrite existing files without `--reset`. On resume, preserve existing files intact.
14
+ - Project section in the instruction file MUST go through user confirmation before writing.
15
+ - NEVER reference or create identity/, codebase/, reference/, or core/ paths.
16
+ - Essentials section MUST NOT exceed 10 lines. If more items are needed, move lower-priority ones to .nexus/context/.
17
+
18
+ ## Guidelines
19
+
20
+ ## Trigger
21
+
22
+ - Manual trigger — full onboarding (or resume). See harness docs: slash_command_display.
23
+ - Manual trigger with `--reset` flag — back up existing `.nexus/` knowledge and re-onboard. See harness docs: slash_command_display.
24
+ - Manual trigger with `--reset --cleanup` flags — show backup list + selective deletion. See harness docs: slash_command_display.
25
+
26
+ ---
27
+
28
+ ## Modes
29
+
30
+ ### First Run (no `.nexus/` flat structure)
31
+
32
+ Automatically runs the 5-step full onboarding.
33
+
34
+ Detection: `.nexus/context/`, `.nexus/memory/`, `.nexus/state/`, `.nexus/rules/` do not exist.
35
+
36
+ ### Resume (`.nexus/` partially exists)
37
+
38
+ Check existing state and resume from the first incomplete step.
39
+
40
+ ### Reset (`--reset`)
41
+
42
+ Back up existing `.nexus/` knowledge directories to `.nexus/bak.{timestamp}/`, then enter First Run.
43
+
44
+ ### Cleanup (`--reset --cleanup`)
45
+
46
+ Show backup directory list, let user select backups to delete.
47
+
48
+ ---
49
+
50
+ ## Process
51
+
52
+ ### Phase 0: Mode Detection
53
+
54
+ ```
55
+ IF --reset --cleanup flag:
56
+ Show list of .nexus/bak.*/ directories
57
+ Prompt user with options via `request_user_input({ prompt: "Select a backup to delete (or cancel)", options: [<backup list...>, {label: Cancel, description: "Exit without changes"}] })`.
58
+ Delete selected backup and exit
59
+
60
+ ELSE IF --reset flag:
61
+ Move .nexus/{memory,context,state,rules}/ → .nexus/bak.{timestamp}/
62
+ Inform: "Existing knowledge has been backed up to .nexus/bak.{timestamp}/. Starting re-onboarding."
63
+ → Enter First Run
64
+
65
+ ELSE IF .nexus/context/ exists:
66
+ → Enter Resume (check existing steps and resume)
67
+
68
+ ELSE:
69
+ → Enter First Run (from Step 1)
70
+ ```
71
+
72
+ ---
73
+
74
+ ## Steps
75
+
76
+ ### Step 1: Project Scan
77
+
78
+ Auto-detect code structure and tech stack. Create the flat `.nexus/` directory structure if it does not exist.
79
+
80
+ Create directories (using shell command execution):
81
+ - `.nexus/memory/`
82
+ - `.nexus/context/`
83
+ - `.nexus/state/`
84
+ - `.nexus/rules/`
85
+
86
+ Collected items:
87
+ - **Directory structure**: top-level layout, major modules/packages
88
+ - **Tech stack**: language, framework, runtime (package.json, Cargo.toml, pyproject.toml, go.mod, build.gradle, etc.)
89
+ - **Build/test system**: scripts, CI configuration
90
+ - **Existing docs**: CLAUDE.md, README.md, docs/, .cursorrules, etc.
91
+ - **git context**: recent commits, branch structure, contributors
92
+
93
+ Output: scan summary (language, framework, structure overview)
94
+
95
+ For large projects (10+ top-level directories or 100+ files), consider spawning an Explore subagent for parallel scanning to reduce Lead context usage.
96
+
97
+ ### Step 2: Mission + Essentials (Interactive)
98
+
99
+ 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.
100
+
101
+ #### Essentials Guidelines
102
+
103
+ 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/.
104
+
105
+ Draft from these five categories (include only what applies to this project):
106
+
107
+ - **Tech stack** — runtime, language, package manager, core framework. Flag non-default tools (e.g. bun instead of npm, deno instead of node).
108
+ - **Workflow** — build, test, deploy commands. Must-follow procedures such as required lint or type-check steps before committing.
109
+ - **Constraints** — forbidden tools, patterns, or approaches. Directories or files that must not be modified.
110
+ - **Domain** — target audience, required terminology or tone, compliance or regulatory constraints, methodology for research projects.
111
+ - **Conventions** — naming, structure, or style that deviate from general defaults. Project-specific patterns an agent would not infer.
112
+
113
+ Do not include items that are standard defaults for the detected tech stack. Do not exceed 10 lines total in the Essentials section.
114
+
115
+ #### Draft Presentation
116
+
117
+ Present the full draft to the user in this format:
118
+
119
+ ```
120
+ The following will be added to the instruction file (see harness docs: instruction_file) (existing content will not be changed):
121
+
122
+ <!-- PROJECT:START -->
123
+ ## {project-name}
124
+
125
+ {mission 1-2 lines}
126
+
127
+ ### Essentials
128
+ - {auto-detected item}
129
+ - {auto-detected item}
130
+ <!-- PROJECT:END -->
131
+
132
+ Any changes?
133
+ ```
134
+
135
+ Wait for the user to confirm or provide edits. Apply all changes in one pass — do not ask about Mission and Essentials separately.
136
+
137
+ After confirmation, write the section into the instruction file inside markers using the harness's file-editing primitive. If the instruction file already contains `<!-- PROJECT:START -->` markers, replace the content between them. If the instruction file does not exist, create it with the markers.
138
+
139
+ ### Step 3: Context Knowledge Auto-Generation
140
+
141
+ Analyze Step 1 scan results to generate context knowledge documents in `.nexus/context/`.
142
+
143
+ Principles:
144
+ - File names and content are decided freely based on project characteristics. No fixed templates.
145
+ - Existing docs are information sources only — do not replicate their structure verbatim.
146
+ - Do not guess content that cannot be confirmed from code.
147
+ - Typically 1-3 files are sufficient. More files are not better.
148
+ - **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.
149
+
150
+ Generation targets (select and name based on what the project actually needs):
151
+ - Development stack (languages, frameworks, runtimes, key dependencies, build/test/deploy workflow)
152
+ - Design and architecture (module relationships, data flow, core entry points, conventions)
153
+ - Implementation specifics (pipeline details, configuration patterns, file structure conventions, tool restrictions — anything too specific for the instruction file but not readable from code alone)
154
+
155
+ Use the harness's file-creation primitive to create files at `.nexus/context/{chosen-name}.md`.
156
+
157
+ For large projects, spawn Writer subagents per topic to generate context knowledge in parallel. Lead coordinates and reviews outputs.
158
+
159
+ On completion: "context knowledge N files generated"
160
+
161
+ ### Step 4: Rules Initial Setup (Optional)
162
+
163
+ Check whether team custom rules are needed.
164
+
165
+ ```
166
+ request_user_input({ prompt: "Do you want to set up development rules now?", options: [{label: "Set up", description: "Coding conventions, test policy, commit rules, etc."}, {label: Skip, description: "Can be added later via [rule] tag"}] })
167
+ ```
168
+
169
+ If "Set up": present a draft based on scan results → user confirms → save via the harness's file-creation primitive to `.nexus/rules/{topic}.md`.
170
+
171
+ If "Skip": inform and proceed to Step 5.
172
+
173
+ ### Step 5: Completion Summary
174
+
175
+ Output a summary of the onboarding results.
176
+
177
+ ```
178
+ ## Nexus Initialization Complete
179
+
180
+ ### Generated Files
181
+ - instruction file: project section — mission and essentials (<!-- PROJECT:START/END -->)
182
+ - .nexus/context/: {list of generated files}
183
+ - .nexus/rules/: {generated files or "none (skipped)"}
184
+
185
+ ### Next Steps
186
+ - [plan] — research, analyze, and plan before execution
187
+ - [run] — execute from a plan
188
+ - Manual re-run trigger with `--reset` flag — re-run onboarding (existing knowledge will be backed up). See harness docs: slash_command_display.
189
+ ```