oioxo-mcp 0.1.2 → 0.1.3

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.
@@ -1,3 +1,5 @@
1
+ /** The instruction files for the agents that read them at session start. */
2
+ export declare function writeAgentInstructions(root: string): Promise<string[]>;
1
3
  export interface InitOptions {
2
4
  /** Force-write the per-PROJECT files even when not detected. */
3
5
  all?: boolean;
@@ -123,6 +123,46 @@ async function appendToml(file, entry) {
123
123
  await fs.writeFile(file, existing + block, 'utf8');
124
124
  return true;
125
125
  }
126
+ // ---- agent INSTRUCTION files — why OIOXO fires BEFORE the session starts ----
127
+ // MCP registration alone leaves it to the model's judgement whether to call the
128
+ // tool. Instructions files are read by the agent at session start, so the very
129
+ // first prompt already routes through OIOXO. Marked block, idempotent.
130
+ const OIOXO_START = '<!-- oioxo:start -->';
131
+ const OIOXO_END = '<!-- oioxo:end -->';
132
+ const OIOXO_INSTRUCTIONS = `${OIOXO_START}
133
+ ## OIOXO context engine (use it FIRST)
134
+ This project is wired to the OIOXO MCP server. BEFORE reading, searching or listing files yourself, ALWAYS call the \`get_context\` tool from the \`oioxo\` MCP server with the task as the query — it returns the minimal relevant code slice (10-20x fewer tokens than reading files). Use \`get_impact\` before refactors, \`get_skeleton\` to learn an API cheaply, and \`remember\` to persist durable project facts.
135
+ ${OIOXO_END}`;
136
+ /** Append/refresh the marked OIOXO block in an instructions file. */
137
+ async function writeInstructionBlock(file) {
138
+ let existing = '';
139
+ try {
140
+ existing = await fs.readFile(file, 'utf8');
141
+ }
142
+ catch { /* fresh file */ }
143
+ const start = existing.indexOf(OIOXO_START);
144
+ const end = existing.indexOf(OIOXO_END);
145
+ let next;
146
+ if (start >= 0 && end > start) {
147
+ next = existing.slice(0, start) + OIOXO_INSTRUCTIONS + existing.slice(end + OIOXO_END.length);
148
+ }
149
+ else {
150
+ next = existing ? existing.trimEnd() + '\n\n' + OIOXO_INSTRUCTIONS + '\n' : OIOXO_INSTRUCTIONS + '\n';
151
+ }
152
+ await fs.mkdir(path.dirname(file), { recursive: true });
153
+ await fs.writeFile(file, next, 'utf8');
154
+ }
155
+ /** The instruction files for the agents that read them at session start. */
156
+ export async function writeAgentInstructions(root) {
157
+ const targets = [
158
+ path.join(root, '.github', 'copilot-instructions.md'), // Copilot reads automatically
159
+ path.join(root, 'CLAUDE.md'), // Claude Code reads at start
160
+ path.join(root, '.cursor', 'rules', 'oioxo.mdc'), // Cursor project rules
161
+ ];
162
+ for (const t of targets)
163
+ await writeInstructionBlock(t);
164
+ return targets;
165
+ }
126
166
  export async function initAgents(root, opts = {}) {
127
167
  const home = opts.home ?? os.homedir();
128
168
  const entry = serverEntry(opts.command);
@@ -150,6 +190,9 @@ export async function initAgents(root, opts = {}) {
150
190
  console.log(' No agents detected. Run with --all to write the project configs anyway.');
151
191
  return;
152
192
  }
193
+ // Instruction files make agents call OIOXO from the FIRST prompt of a session.
194
+ await writeAgentInstructions(root);
195
+ console.log(' ✓ Agent instructions: .github/copilot-instructions.md, CLAUDE.md, .cursor/rules/oioxo.mdc');
153
196
  console.log('\nRestart your agent (or reload the window) and it will call OIOXO before reading files.');
154
197
  console.log('Not connected yet? Run `oioxo-mcp login`.');
155
198
  }
@@ -91,6 +91,11 @@ test('init writes + merges agent configs (project + global)', async () => {
91
91
  const codex = await fs.readFile(path.join(home, '.codex', 'config.toml'), 'utf8');
92
92
  assert.ok(codex.startsWith('model = "o4"'), 'existing TOML preserved');
93
93
  assert.ok(codex.includes('[mcp_servers.oioxo]'));
94
+ // Instruction files (the "fires first" mechanism) — written and idempotent.
95
+ const copilotIns = await fs.readFile(path.join(root, '.github', 'copilot-instructions.md'), 'utf8');
96
+ assert.ok(copilotIns.includes('get_context'), 'copilot instructions mention the tool');
97
+ const claudeMd = await fs.readFile(path.join(root, 'CLAUDE.md'), 'utf8');
98
+ assert.ok(claudeMd.includes('oioxo:start'));
94
99
  // Idempotent: second run must not duplicate the TOML section.
95
100
  await initAgents(root, { all: true, command: 'oioxo-mcp', home });
96
101
  const codex2 = await fs.readFile(path.join(home, '.codex', 'config.toml'), 'utf8');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oioxo-mcp",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "OIOXO context engine for AI coding agents — feeds Claude Code, Copilot, Cursor and any MCP-capable agent the minimal relevant slice of your codebase, on-device, so your tokens go further.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "type": "module",