@niroai/niro 0.3.5 → 0.3.6

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/mcp/setup.js +51 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@niroai/niro",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Niro — one package: the niro CLI plus the Niro MCP server (code intelligence for AI coding assistants).",
5
5
  "keywords": [
6
6
  "niro",
package/src/mcp/setup.js CHANGED
@@ -41,17 +41,27 @@ const NIRO_MD_MARKER = "<!-- niro-mcp -->";
41
41
  * own notes added below the block survive uninstall — see teardown.js removeMarkerSection).
42
42
  * Each begins with a leading "\n" because install does `existing + section`.
43
43
  */
44
+ /**
45
+ * Explore-first rule, shared by every client's markdown section. Prose alone is weak, but this is the
46
+ * one lever some clients (Codex, Copilot CLI, Factory, OpenCode, Windsurf) have — they support no hooks,
47
+ * so their ONLY always-on nudge is this file. For Claude Code it reinforces the PreToolUse Grep|Glob|Read
48
+ * hook (NIRO_EXPLORE_COMMAND), which fires once per session/repo/branch; this stays in force for the rest
49
+ * of the session. Wording is imperative and names concrete tools so the agent knows what to call instead
50
+ * of native search.
51
+ */
52
+ const NIRO_EXPLORE_FIRST_SENTENCE = "MUST FOLLOW: before you run grep, find, glob, or open a file to hunt for something, first check whether a Niro tool answers it (code_grep for content search, resolve_fqn and get_source_code for a known symbol, find_handler and find_api_endpoints for entry points). Use the connection tools (get_call_chain, get_reverse_call_chain, get_blast_radius, get_impact_analysis, get_service_topology) to understand how code connects BEFORE deciding which file to read or search next, rather than reading files to rebuild that picture by hand. Native search is the fallback for what Niro does not cover (config files, docs, logs, generated output, non-code text) or when the tools are unavailable.";
53
+
44
54
  const NIRO_MULTI_REPO_SENTENCE = "The temporary project answer is per (repo, BRANCH): after you create/switch a branch in a repo — and before your first edit on that branch — call should_create_temp_project with the repo's git url, its CURRENT branch, and its `.niro-project` id if present, then run `niro new-temp-project` in its folder if needs_temp_project is true. Re-check after every branch change (a `false` from another branch does NOT carry over); this applies to every repo you touch, including when the session started in a parent folder that is not itself a git repo.";
45
- const NIRO_CLAUDE_MD_SECTION = `\n${NIRO_MD_MARKER}\n## Niro MCP\nNiro MCP tools are available for code intelligence. Use them (call chains, blast radius, impact analysis, source lookup) before falling back to native grep/read for code questions.\nBefore adding/writing any new code, you MUST use the find_reusable_code tool from niro to figure out if there is anything reusable.\n${NIRO_MULTI_REPO_SENTENCE}\n`;
46
- const NIRO_CODEX_MD_SECTION = `\n${NIRO_MD_MARKER}\n## Niro MCP\nNiro MCP code-intelligence tools and the \`niro-skill\` are available (call chains, blast radius, impact analysis, source lookup). Prefer them over grep/read for questions about this codebase; the niro-skill has the full tool-routing playbook. Before adding or writing any new code, use find_reusable_code to check for reusable code. If the niro tools are not present or the repo is not indexed, use native tools.\n${NIRO_MULTI_REPO_SENTENCE}\n`;
47
- const NIRO_WINDSURF_MD_SECTION = `\n${NIRO_MD_MARKER}\n## Niro MCP\nNiro MCP code-intelligence tools and the niro-skill are available. Prefer them over grep/read for questions about this codebase (structure, call chains, blast radius, impact, data flows, reuse); the niro-skill has the full routing playbook. Before writing any new code, use find_reusable_code. If the niro tools are not present or the repo is not indexed, use native tools.\n${NIRO_MULTI_REPO_SENTENCE}\n`;
55
+ const NIRO_CLAUDE_MD_SECTION = `\n${NIRO_MD_MARKER}\n## Niro MCP\nNiro MCP tools are available for code intelligence. Use them (call chains, blast radius, impact analysis, source lookup) before falling back to native grep/read for code questions.\nBefore adding/writing any new code, you MUST use the find_reusable_code tool from niro to figure out if there is anything reusable.\n${NIRO_EXPLORE_FIRST_SENTENCE}\n${NIRO_MULTI_REPO_SENTENCE}\n`;
56
+ const NIRO_CODEX_MD_SECTION = `\n${NIRO_MD_MARKER}\n## Niro MCP\nNiro MCP code-intelligence tools and the \`niro-skill\` are available (call chains, blast radius, impact analysis, source lookup). Prefer them over grep/read for questions about this codebase; the niro-skill has the full tool-routing playbook. Before adding or writing any new code, use find_reusable_code to check for reusable code. If the niro tools are not present or the repo is not indexed, use native tools.\n${NIRO_EXPLORE_FIRST_SENTENCE}\n${NIRO_MULTI_REPO_SENTENCE}\n`;
57
+ const NIRO_WINDSURF_MD_SECTION = `\n${NIRO_MD_MARKER}\n## Niro MCP\nNiro MCP code-intelligence tools and the niro-skill are available. Prefer them over grep/read for questions about this codebase (structure, call chains, blast radius, impact, data flows, reuse); the niro-skill has the full routing playbook. Before writing any new code, use find_reusable_code. If the niro tools are not present or the repo is not indexed, use native tools.\n${NIRO_EXPLORE_FIRST_SENTENCE}\n${NIRO_MULTI_REPO_SENTENCE}\n`;
48
58
  /**
49
59
  * Shared generic section for clients whose "always-on instructions" file has no companion
50
60
  * skill mechanism we've verified (Gemini CLI's GEMINI.md, GitHub Copilot CLI's
51
61
  * copilot-instructions.md, Factory's AGENTS.md, OpenCode's AGENTS.md) — one wording, reused
52
62
  * across those destination files (teardown matches it per-file, so reuse is safe).
53
63
  */
54
- const NIRO_GENERIC_MD_SECTION = `\n${NIRO_MD_MARKER}\n## Niro MCP\nNiro MCP code-intelligence tools are available (call chains, blast radius, impact analysis, source lookup). Prefer them over grep/read for questions about this codebase. Before adding or writing any new code, use find_reusable_code to check for reusable code. If the niro tools are not present or the repo is not indexed, use native tools.\n${NIRO_MULTI_REPO_SENTENCE}\n`;
64
+ const NIRO_GENERIC_MD_SECTION = `\n${NIRO_MD_MARKER}\n## Niro MCP\nNiro MCP code-intelligence tools are available (call chains, blast radius, impact analysis, source lookup). Prefer them over grep/read for questions about this codebase. Before adding or writing any new code, use find_reusable_code to check for reusable code. If the niro tools are not present or the repo is not indexed, use native tools.\n${NIRO_EXPLORE_FIRST_SENTENCE}\n${NIRO_MULTI_REPO_SENTENCE}\n`;
55
65
 
56
66
  /** All niro markdown sections — the uninstaller tries each for an exact removal. */
57
67
  const NIRO_MD_SECTIONS = [NIRO_CLAUDE_MD_SECTION, NIRO_CODEX_MD_SECTION, NIRO_WINDSURF_MD_SECTION, NIRO_GENERIC_MD_SECTION];
@@ -886,6 +896,16 @@ code — structure, behavior, impact, data/event flows, semantics — prefer the
886
896
  native grep/read. For anything outside the indexed code (config files, docs, runtime state),
887
897
  use your native tools.
888
898
 
899
+ ## Explore first — MUST FOLLOW
900
+
901
+ Before you run grep, find, glob, or open a file to hunt for something, check whether a Niro
902
+ tool answers it: \`code_grep\` for content search, \`resolve_fqn\` + \`get_source_code\` for a known
903
+ symbol, \`find_handler\` / \`find_api_endpoints\` for entry points. Use the connection tools
904
+ (\`get_call_chain\`, \`get_reverse_call_chain\`, \`get_blast_radius\`, \`get_impact_analysis\`,
905
+ \`get_service_topology\`) to understand how the code connects BEFORE you decide which file to
906
+ read or search next, instead of reading files to rebuild that picture by hand. Native search
907
+ stays the fallback for what Niro does not cover, and when the tools are unavailable.
908
+
889
909
  \`project_id\` auto-resolves from a \`.niro-project\` file at the repo root — omit it. If there
890
910
  is no such file, call \`list_projects\` and pass the chosen \`project_id\`.
891
911
 
@@ -1287,6 +1307,13 @@ alwaysApply: false
1287
1307
  The niro MCP server exposes code-intelligence tools for this codebase. Prefer them over
1288
1308
  grep/read for any question answerable from the indexed code.
1289
1309
 
1310
+ MUST FOLLOW — explore first: before you run grep, find, glob, or open a file to hunt for
1311
+ something, check whether a niro tool answers it (code_grep, resolve_fqn + get_source_code,
1312
+ find_handler, find_api_endpoints). Use the connection tools (get_call_chain,
1313
+ get_reverse_call_chain, get_blast_radius, get_impact_analysis, get_service_topology) to see
1314
+ how the code connects BEFORE deciding which file to read or search next. Native search is the
1315
+ fallback for what niro does not cover, and when the tools are unavailable.
1316
+
1290
1317
  Availability self-check FIRST — if the niro tools are not present in this session, or the
1291
1318
  repo is not indexed (no project resolves / a tool reports "not indexed"), fall back to
1292
1319
  native tools silently and do not mention Niro.
@@ -1574,6 +1601,13 @@ Niro code-intelligence MCP tools are available for the current codebase. Prefer
1574
1601
  grep/read for questions about structure, call chains, blast radius, impact, data flows, and
1575
1602
  reuse. Before writing or adding any new code, use \`find_reusable_code\` first.
1576
1603
 
1604
+ MUST FOLLOW — explore first: before you run grep, find, glob, or open a file to hunt for
1605
+ something, check whether a niro tool answers it (\`code_grep\`, \`resolve_fqn\` +
1606
+ \`get_source_code\`, \`find_handler\`, \`find_api_endpoints\`). Use the connection tools
1607
+ (\`get_call_chain\`, \`get_reverse_call_chain\`, \`get_blast_radius\`, \`get_impact_analysis\`,
1608
+ \`get_service_topology\`) to see how the code connects BEFORE deciding which file to read or
1609
+ search next. Native search is the fallback for what niro does not cover.
1610
+
1577
1611
  If the niro tools are not present in this session, or the repo is not indexed (no project
1578
1612
  resolves), fall back to native tools silently — do not mention Niro's absence.
1579
1613
  `;
@@ -1612,6 +1646,13 @@ Niro code-intelligence MCP tools are available for the current codebase. Prefer
1612
1646
  grep/read for questions about structure, call chains, blast radius, impact, data flows, and
1613
1647
  reuse. Before writing or adding any new code, use \`find_reusable_code\` first.
1614
1648
 
1649
+ MUST FOLLOW — explore first: before you run grep, find, glob, or open a file to hunt for
1650
+ something, check whether a niro tool answers it (\`code_grep\`, \`resolve_fqn\` +
1651
+ \`get_source_code\`, \`find_handler\`, \`find_api_endpoints\`). Use the connection tools
1652
+ (\`get_call_chain\`, \`get_reverse_call_chain\`, \`get_blast_radius\`, \`get_impact_analysis\`,
1653
+ \`get_service_topology\`) to see how the code connects BEFORE deciding which file to read or
1654
+ search next. Native search is the fallback for what niro does not cover.
1655
+
1615
1656
  If the niro tools are not present in this session, or the repo is not indexed (no project
1616
1657
  resolves), fall back to native tools silently — do not mention Niro's absence.
1617
1658
  `;
@@ -2058,6 +2099,12 @@ module.exports = {
2058
2099
  // Exposed for content regression tests (e.g. the cross-project routing guidance).
2059
2100
  NIRO_SKILL,
2060
2101
  NIRO_CLI_SKILL,
2102
+ // Exposed for tests: the explore-first rule must reach EVERY client's always-on instruction surface.
2103
+ NIRO_EXPLORE_FIRST_SENTENCE,
2104
+ NIRO_CURSOR_RULE,
2105
+ NIRO_CLINE_RULE,
2106
+ NIRO_KIRO_STEERING,
2107
+ upsertNiroMarkerSection,
2061
2108
  // Exposed for tests: URL resolution replaced the install-time prompt.
2062
2109
  resolveMcpServerUrl,
2063
2110
  SAAS_URL,