@inkobytes/nexus 1.0.7 → 1.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.
@@ -0,0 +1,196 @@
1
+ export const MONTH_NAMES = [
2
+ 'January',
3
+ 'February',
4
+ 'March',
5
+ 'April',
6
+ 'May',
7
+ 'June',
8
+ 'July',
9
+ 'August',
10
+ 'September',
11
+ 'October',
12
+ 'November',
13
+ 'December',
14
+ ];
15
+
16
+ export const START_MARKER = '<!-- NEXUS-AGENT-PROTOCOL:START -->';
17
+ export const END_MARKER = '<!-- NEXUS-AGENT-PROTOCOL:END -->';
18
+ export const REQUIRED_CONTEXT_READ = 'Read continuity and latest memory at session start, `nexus start`, or resume.';
19
+ export const CONTINUITY_LEDGER_LINE = 'Compaction-safe session ledger. Read this first after context loss, restart, or fresh entry.';
20
+ export const SKILL_CONTEXT_GUARDRAIL = 'Continuity is the compaction-safe session ledger; latest memory is required startup/resume context.';
21
+ export const MEMORY_INDEX_GUARDRAIL = 'Memory indexes use monthly folders and newest-first Markdown links with one-line outcomes.';
22
+
23
+ export const CONTINUITY_TEMPLATE = `# CONTINUITY
24
+
25
+ ${CONTINUITY_LEDGER_LINE}
26
+
27
+ Goal: Project setup
28
+ State: Planning
29
+
30
+ Now: Initial Nexus setup
31
+ Next: Confirm first task
32
+ Blockers: None
33
+ Decisions:
34
+ - Nexus manages swarm coordination
35
+ - Continuity and memories are agent-local
36
+ Files:
37
+ - _NEXUS_QUEUE.md
38
+ - _NEXUS_STANDUP.md
39
+ `;
40
+
41
+ export const MEMORY_INDEX_TEMPLATE = `# Memory Index
42
+
43
+ Newest first, max 10 visible entries.
44
+
45
+ Format:
46
+
47
+ - [YYYY-MM-DD-HHMM-topic](YYYY-Month/YYYY-MM-DD-HHMM-topic.md) - one-line outcome
48
+
49
+ Entries live in month folders from the start, for example:
50
+
51
+ - [2026-01-15-1030-project-setup](2026-January/2026-01-15-1030-project-setup.md) - initialized Nexus scaffolds
52
+ - [2026-02-01-0900-debug-session](2026-February/2026-02-01-0900-debug-session.md) - isolated the failing hook path
53
+
54
+ This keeps monthly review simple: ask an agent to read one month folder and summarize the Markdown files.
55
+
56
+ `;
57
+
58
+ export function currentMemoryMonthFolder(now = new Date()) {
59
+ return `${now.getFullYear()}-${MONTH_NAMES[now.getMonth()]}`;
60
+ }
61
+
62
+ export function protocolBlock(agent) {
63
+ return `${START_MARKER}
64
+
65
+ ## Nexus Project Protocol
66
+
67
+ This project uses Nexus for multi-agent coordination.
68
+
69
+ ### Start Here
70
+
71
+ 1. Read \`_NEXUS_CONSTITUTION.md\`.
72
+ 2. Read \`_NEXUS_QUEUE.md\` for executable priorities.
73
+ 3. Read \`_NEXUS_STANDUP.md\` for comms, decisions, and completion notes.
74
+ 4. Read \`USER.md\` if present for local human preferences.
75
+ 5. Read \`${agent.continuity}\` for current session state.
76
+ 6. Read \`${agent.memoryIndex}\` and the latest memory entry at session start, \`nexus start\`, or resume.
77
+
78
+ ### Nexus Rules
79
+
80
+ - On compaction, resume, or a fresh turn, treat this file and the Nexus protocol as active requirements, not optional guidance.
81
+ - Claim before touching shared project files: \`nexus claim <path> @Agent "intent"\`.
82
+ - If a hook blocks reading, editing, committing, or releasing because a path is unclaimed, stop and claim the exact path. Do not bypass the hook with another tool, shell trick, cached content, or manual git command.
83
+ - Claim first, then read/edit. No exceptions, no "I'll claim after."
84
+ - Nexus is agent-native and file-native, not human-native: optimize for concurrency and rollback, not feature-commit aesthetics.
85
+ - Release each claimed file as soon as it reaches a coherent checkpoint.
86
+ - Never hold claims just to bundle a prettier feature commit; that blocks other agents.
87
+ - Release finished work through Nexus: \`nexus release <path> "commit message"\`.
88
+ - Use \`nexus next @Agent\` for the next safe queue task.
89
+ - Do not free-roam into unassigned or \`Auto-flow: no\` work without user approval.
90
+ - Direct user instruction can override queue order, but not claim/release, data, security, or approval gates.
91
+ - If no safe task remains, announce \`Standby\` with what you are waiting for, then stop until user input, queue change, or explicit assignment.
92
+
93
+ ### Current File State
94
+
95
+ - Treat previous chat context, cached model memory, and earlier reads as stale when file contents matter.
96
+ - Unclaimed orientation reads are limited to Nexus protocol, queue, standup, human preference, continuity, and memory files named in Start Here.
97
+ - Claim before reading implementation files, tests, docs, generated artifacts, or agent instruction files outside that orientation set.
98
+ - Before claiming what a file says, making edits, or judging current state, read the file from disk with a fresh command.
99
+ - Treat \`nexus claim\` as the atomic lock-and-read boundary and its output as fresh file state for the claimed path.
100
+ - If you read a shared file before claiming it, treat that read as stale after claim succeeds.
101
+ - If another agent or tool may have touched the file since your last read, re-read it before editing.
102
+ - If a claim appears stale, do not edit through it; run \`nexus status\` or \`nexus doctor\`, then clean only when ownership is clearly abandoned.
103
+
104
+ ### Drills
105
+
106
+ Drill guidance is defined in \`_NEXUS_CONSTITUTION.md\`.
107
+ If the situation resembles a drill, use that drill before acting.
108
+
109
+ ### Delegated Work
110
+
111
+ - Lead agents own the repo effects of their subagents, tools, and parallel workers.
112
+ - Claim the full path scope before delegating shared-file work.
113
+ - Give subagents the claimed path, intent, non-goals, and boundaries.
114
+ - Re-read affected files after subagent work before final edits, release, or current-state claims.
115
+ - Mention delegated work in release or \`nexus standup\` notes when it affected files, tests, or risk.
116
+
117
+ ### Git Write Safety
118
+
119
+ - Before git writes, verify \`pwd\`, repo root, branch/status, and remotes.
120
+ - Stop if they do not match the requested project.
121
+ - Never infer from similar folder names or cached context.
122
+ - Require explicit confirmation before push/force-push, main/master, remote changes, or deletes.
123
+ - To remove private agent files from git, untrack them; do not delete local folders.
124
+ - Agent instruction files are shared protocol files; normal edits require claim/release, while \`nexus doctor --fix\` may update managed protocol blocks after user approval.
125
+ - Agents work inside assigned work zones. If a change crosses work-zone boundaries or alters a shared contract another zone may depend on, announce it in \`_NEXUS_STANDUP.md\` before release and ask if coordination is needed.
126
+
127
+ ### Supply-Chain Safety
128
+
129
+ - Do not install third-party packages that have existed for less than 14 days.
130
+ - Before adding a new dependency, verify the package creation date and the specific version publish date.
131
+ - If the package or version is younger than 14 days, or either date cannot be verified, stop and ask the user.
132
+ - Run \`nexus doctor\` before installs; review any Security findings before running package scripts.
133
+ - \`nexus doctor\` is cheap, local, and idempotent.
134
+ - If \`nexus doctor\` reports Security, Package Privacy, Git Privacy, or supply-chain findings, stop and report before fixing or installing.
135
+ - Treat install hooks and scripts with network commands, webhooks, raw sockets, SSH, or secret-looking variables as human-review only.
136
+ - Prefer built-in runtime APIs and existing project dependencies when they fit.
137
+
138
+ ### Agent-Local Files
139
+
140
+ \`${agent.continuity}\` and \`${agent.memoryIndex}\` are agent-local handoff files.
141
+ They are exempt from Nexus claim/release unless the user says otherwise.
142
+
143
+ ### Continuity Flow
144
+
145
+ - Continuity is the compaction-safe session ledger.
146
+ - On session start, read \`${agent.continuity}\` once and treat it as current state unless the user contradicts it.
147
+ - Write continuity only on task switch, blocker, checkpoint request, or session end.
148
+ - Replace the ledger instead of appending to it.
149
+ - In task replies, use a one-line status summary instead of echoing the full ledger.
150
+ - If the ledger is missing, stale, or lacks referenced context, ask once instead of guessing.
151
+
152
+ ### Memory Flow
153
+
154
+ - On session start, \`nexus start\`, or resume, read \`${agent.memoryIndex}\`, then read the newest linked entry.
155
+ - Memory entries are session handoffs, not permanent system truth.
156
+ - Durable architecture and protocol decisions belong in \`DECISIONS.md\`; mention them in \`_NEXUS_STANDUP.md\` only when active agents need to coordinate around them.
157
+ - Write memory once per session, only when the user asks, or on session end, pause, or checkpoint request.
158
+ - When writing your own memory entry, create the current month folder under \`${agent.memoryDir}\` if it is missing.
159
+ - Do not create or repair other agents' memory folders manually; use \`nexus doctor --fix\` for broad scaffold repair.
160
+ - On session end, pause, or checkpoint request:
161
+ 1. Run \`nexus checkout @${agent.aliases[0]}\` to clear your presence heartbeat.
162
+ 2. Create one new memory file: \`${agent.memoryDir}/YYYY-Month/YYYY-MM-DD-HHMM-topic.md\`.
163
+ - Add the newest file to the top of \`${agent.memoryIndex}\` as a Markdown link plus one-line outcome.
164
+ - Keep the index to the 10 newest visible entries.
165
+ - For monthly review, read one month folder such as \`${agent.memoryDir}/2026-January/\` and summarize the Markdown files.
166
+
167
+ Memory entry format:
168
+
169
+ \`\`\`markdown
170
+ # YYYY-MM-DD - HH:MM - <topic>
171
+
172
+ ## Session Summary
173
+ - What we worked on: [<=50 words]
174
+ - What got done: [bullet list, max 5]
175
+ - Where we stopped: [exact state, <=30 words]
176
+
177
+ ## Next Session Needs
178
+ - Immediate next task: [<=20 words]
179
+ - Blockers: [None, or list]
180
+ - Open questions: [if any]
181
+
182
+ ## Context to Carry
183
+ - Key decisions made: [max 3 bullets]
184
+ - Files touched: [max 5 paths]
185
+ - Gotchas/warnings: [anything next session should watch for]
186
+ \`\`\`
187
+
188
+ ${END_MARKER}
189
+ `;
190
+ }
191
+
192
+ export function fullEntrypoint(agent) {
193
+ return `# ${agent.label} Agent Guide
194
+
195
+ ${protocolBlock(agent)}`;
196
+ }