realontext 0.20.0 → 0.21.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "realontext",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Code search for coding agents, over the directory you are in. Needs `npm install -g realontext`.",
5
5
  "author": {
6
6
  "name": "FlowerRealm",
package/bin/realontext.js CHANGED
@@ -16,8 +16,10 @@ const terminal = process.stdin.isTTY && process.stdout.isTTY;
16
16
  if (command !== "mcp" && command !== "hook") require("../lib/update.js").start();
17
17
 
18
18
  function exit(status) {
19
- if (typeof status === "string") process.kill(process.pid, status);
20
- process.exit(status);
19
+ if (typeof status !== "string") process.exit(status);
20
+ process.kill(process.pid, status);
21
+ // Still here: a signal Node ignores, SIGPIPE. The status a shell gives it.
22
+ process.exit(128 + require("os").constants.signals[status]);
21
23
  }
22
24
 
23
25
  if (terminal && (command === undefined || (command === "setup" && rest.length === 0))) {
@@ -1,3 +1,3 @@
1
1
  <realontext>
2
- That was grep. Code search goes through codebase-retrieval, not grep: call it now for the code you were looking for - it returns whole functions, ranked by what you asked, with line numbers. If it is not loaded yet, load it once with `search_tools` (query "codebase-retrieval") and call it. `pattern` is the regex you would grep for; add `query`, an English description of the code - with it, a model on the realontext Relay ranks the results. Text outside code (docs, configs, logs, a command's output) is `realontext query --pattern RE [--path PATH]...` in the shell.
2
+ That was grep. Code search goes through codebase-retrieval, not grep: call it now for the code you were looking for - it returns whole functions, ranked by what you asked, with line numbers. If it is not loaded yet, load it once with `search_tools` (query "codebase-retrieval") and call it. `pattern` is the regex you would grep for; give `query`, an English description of the code, on every call - leave it out only when the pattern is one exact name you know; with it, a model on the realontext Relay ranks the results. Text outside code (docs, configs, logs, a command's output) is `realontext query --pattern RE [--path PATH]...` in the shell.
3
3
  </realontext>
package/hooks/hint.md CHANGED
@@ -1,3 +1,3 @@
1
1
  <realontext>
2
- To search source code, call codebase-retrieval yourself instead of grep or rg: it returns whole functions ranked by what you asked, with line numbers. Search yourself, at every step of the task: do not hand a code search to a subagent, which may not have this tool and greps instead. If your client defers tools and lists it by name only, load it once with your tool search before the first call. `pattern` is the regex you would grep for; add `query`, an English description of the code, unless you already know the exact name - with it, a model on the realontext Relay ranks the results. For docs, configs, logs and a command's output, use `realontext query --pattern RE [--path PATH]...` in the shell, or pipe into it: `git log | realontext query --pattern fix`. Do not run grep or rg at all.
2
+ To search source code, call codebase-retrieval yourself instead of grep or rg: it returns whole functions ranked by what you asked, with line numbers. Search yourself, at every step of the task: do not hand a code search to a subagent, which may not have this tool and greps instead. If your client defers tools and lists it by name only, load it once with your tool search before the first call. `pattern` is the regex you would grep for; give `query`, an English description of the code, on every call - leave it out only when the pattern is one exact name you know; with it, a model on the realontext Relay ranks the results. For docs, configs, logs and a command's output, use `realontext query --pattern RE [--path PATH]...` in the shell, or pipe into it: `git log | realontext query --pattern fix`. Do not run grep or rg at all.
3
3
  </realontext>
package/lib/hook.js CHANGED
@@ -4,14 +4,17 @@
4
4
  // would, and any failure here is silent. Which events it answers, and in what
5
5
  // shape, is the agent's `hook` in `agents.js` - one event or a list of them; an
6
6
  // entry naming a `hint` reads `hooks/hint-<hint>.md` in place of `hooks/hint.md`.
7
+ // An entry with no `hint` whose event fired for a grep tool reads `hint-grep.md`
8
+ // instead: the reminder rides the grep itself, which is where the model reaches
9
+ // for it, not the session's first turn.
7
10
  "use strict";
8
11
 
9
12
  const fs = require("fs");
10
13
  const os = require("os");
11
14
  const path = require("path");
12
15
 
13
- // True the first time it is asked for one session and event, false after: a
14
- // marker file per session, made atomically, since every hook call is its own
16
+ // True the first time it is asked for one session, event and text, false after:
17
+ // a marker file per session, made atomically, since every hook call is its own
15
18
  // process.
16
19
  function firstTime(marker) {
17
20
  const id = marker.replace(/[^\w-]/g, "");
@@ -35,8 +38,13 @@ module.exports = function hook(key) {
35
38
  const fired = typeof input.hook_event_name === "string" ? input.hook_event_name : "";
36
39
  const { event, flat, hint } = events.find((e) => e.event === fired) ?? events[0];
37
40
  const session = String((input.session_id ?? input.sessionId ?? input.conversation_id) || process.ppid);
38
- if (!firstTime(`${key}-${event}-${session}`)) return;
39
- const file = hint ? `hint-${hint}.md` : "hint.md";
41
+ // The tool the event is about, as the agent names it: a grep tool gets the
42
+ // sharp reminder, anything else the plain one. Command Code's grep is
43
+ // SEARCH, which no `/grep/i` catches: its own entry says `hint: "grep"`.
44
+ const tool = String(input.tool_name ?? input.toolName ?? input.tool ?? "");
45
+ const which = hint ?? (/grep/i.test(tool) ? "grep" : "");
46
+ if (!firstTime(`${key}-${event}-${which || "hint"}-${session}`)) return;
47
+ const file = which ? `hint-${which}.md` : "hint.md";
40
48
  const text = fs.readFileSync(path.join(__dirname, "..", "hooks", file), "utf8").trimEnd();
41
49
  const out = flat ? { additionalContext: text } : { hookSpecificOutput: { hookEventName: event, additionalContext: text } };
42
50
  process.stdout.write(JSON.stringify(out));
package/lib/rules.md CHANGED
@@ -1,3 +1,3 @@
1
1
  ## Code search
2
2
 
3
- This repository is searched with realontext, which replaces grep. Its MCP tool `codebase-retrieval` searches the code: every time you need to know where something is in the source (where or how something is done, where a name you know is defined, what calls it, where it is used, which line of a file it is on), call `codebase-retrieval` yourself, at every step of the task (if your tools are deferred, load it first). For text in docs, configs and logs, and for a command's output, run `realontext query --pattern RE [--path PATH]...` in the shell, or pipe into it: `git log | realontext query --pattern fix`. Do not run grep, rg, git grep or any other text search, as a tool or in the shell, alone or inside a longer command. Listing files by name stays with your own tools. Every call needs a `pattern`: the grep you would have run, in ripgrep's syntax: a name exactly (`truncate_name\(` for every call of it), or for a description the keywords the code must contain, broad and case-insensitive (`(?i)retry|backoff`); only code with a matching line is searched. Add a `query`, an English description of the behavior with words likely to appear in the code, when you are describing behavior: the Relay then orders the results. Leave it out for a name you know: the pattern's words answer at once. If nothing comes back, loosen the pattern; if 20 results are not enough, narrow it.
3
+ This repository is searched with realontext, which replaces grep. Its MCP tool `codebase-retrieval` searches the code: every time you need to know where something is in the source (where or how something is done, where a name you know is defined, what calls it, where it is used, which line of a file it is on), call `codebase-retrieval` yourself, at every step of the task (if your tools are deferred, load it first). For text in docs, configs and logs, and for a command's output, run `realontext query --pattern RE [--path PATH]...` in the shell, or pipe into it: `git log | realontext query --pattern fix`. Do not run grep, rg, git grep or any other text search, as a tool or in the shell, alone or inside a longer command. Listing files by name stays with your own tools. Every call needs a `pattern`: the grep you would have run, in ripgrep's syntax: a name exactly (`truncate_name\(` for every call of it), or for a description the keywords the code must contain, broad and case-insensitive (`(?i)retry|backoff`); only code with a matching line is searched. Give a `query` on every call, an English description of the behavior with words likely to appear in the code: the Relay then orders the results. Leave it out only when the pattern is one exact name you already know and you want just its own line: the pattern's words answer at once. If nothing comes back, loosen the pattern; if 20 results are not enough, narrow it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "realontext",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Code search for coding agents, over the directory you are in. CLI and MCP server.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -34,8 +34,8 @@
34
34
  "react": "^18.3.1"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@realontext/darwin-arm64": "0.20.0",
38
- "@realontext/linux-x64": "0.20.0",
39
- "@realontext/win32-x64": "0.20.0"
37
+ "@realontext/darwin-arm64": "0.21.0",
38
+ "@realontext/linux-x64": "0.21.0",
39
+ "@realontext/win32-x64": "0.21.0"
40
40
  }
41
41
  }