context-mode 2.2.2 → 2.2.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.zcode-plugin/plugin.json +1 -1
- package/README.md +72 -72
- package/SHA256SUMS +16 -16
- package/cli.mjs +35 -16
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +106 -99
- package/opencode/plugin.js +311 -69
- package/package.json +1 -1
- package/pi/index.js +373 -69
- package/qwen-extension.json +1 -1
- package/run.mjs +14 -12
- package/search.mjs +14 -12
- package/server.mjs +270 -42
package/qwen-extension.json
CHANGED
package/run.mjs
CHANGED
|
@@ -14,14 +14,6 @@ function prefixToolNames(text, prefix) {
|
|
|
14
14
|
}
|
|
15
15
|
var OUTPUT_CAP = 16384;
|
|
16
16
|
var INDEX_WRITE_CHUNK = 1048576;
|
|
17
|
-
var REPLACE_TRIGGER_BYTES_DEFAULT = 4096;
|
|
18
|
-
var REPLACE_TRIGGER_ENV = "CTX_REPLACE_TRIGGER_BYTES";
|
|
19
|
-
function readReplaceTrigger(raw) {
|
|
20
|
-
if (raw === void 0 || raw.trim() === "") return REPLACE_TRIGGER_BYTES_DEFAULT;
|
|
21
|
-
const n = Number(raw);
|
|
22
|
-
return Number.isSafeInteger(n) && n > 0 ? n : REPLACE_TRIGGER_BYTES_DEFAULT;
|
|
23
|
-
}
|
|
24
|
-
var REPLACE_TRIGGER_BYTES = readReplaceTrigger(process.env[REPLACE_TRIGGER_ENV]);
|
|
25
17
|
var RANGE_READ_TOOLS = Object.freeze(["Read", "view"]);
|
|
26
18
|
var READ_RANGE_KEYS = Object.freeze(["offset", "limit", "view_range"]);
|
|
27
19
|
var SKILL_LOAD_TOOLS = Object.freeze(["Skill"]);
|
|
@@ -179,7 +171,7 @@ var SQLITE_NOTADB_CODE = 26;
|
|
|
179
171
|
var HOOK_TIMEOUT_MS = 5e3;
|
|
180
172
|
var IN_PROCESS_TIMEOUT_MS = 0;
|
|
181
173
|
var PROJECT_KEY_HEX_LEN = 16;
|
|
182
|
-
var SCHEMA_VERSION =
|
|
174
|
+
var SCHEMA_VERSION = 7;
|
|
183
175
|
var PROJECTS_DIR_NAME = "projects";
|
|
184
176
|
var DB_FILE_NAME = "context.db";
|
|
185
177
|
var GIT_DIR_NAME = ".git";
|
|
@@ -1756,7 +1748,8 @@ var ERROR_TEXT = Object.freeze({
|
|
|
1756
1748
|
NO_RUNTIME: "No <lang> runtime on PATH. Fix: install it or pick another language.",
|
|
1757
1749
|
FETCH_FAILED: "Fetch failed: <code>. Fix: check the URL or proxy.",
|
|
1758
1750
|
SSRF: "Blocked private address <host>. Fix: use a public URL.",
|
|
1759
|
-
OUTSIDE_ROOT: "Path <p> is outside the project. Fix: use a path inside <root
|
|
1751
|
+
OUTSIDE_ROOT: "Path <p> is outside the project and the folders added to this session. Fix: use a path inside <root>, or add its folder to the session (Claude Code /add-dir, Codex --add-dir).",
|
|
1752
|
+
// #1398 D-1398-HOST-ROOTS-1
|
|
1760
1753
|
INVALID_ARGS: "Invalid argument <field>. Fix: <action>.",
|
|
1761
1754
|
ONE_OF_INPUT: "Pass exactly one of <names>. Fix: drop the extra field.",
|
|
1762
1755
|
SPAWN_FAILED: "Failed to start the process: <detail>. Fix: check the command and PATH.",
|
|
@@ -1915,13 +1908,22 @@ CREATE VIRTUAL TABLE line_units USING fts5(
|
|
|
1915
1908
|
var DDL_V6 = `
|
|
1916
1909
|
UPDATE sources SET label = replace(label, char(92), '/') WHERE kind = 'path' AND instr(label, char(92)) > 0;
|
|
1917
1910
|
`;
|
|
1911
|
+
var DDL_V7 = `
|
|
1912
|
+
ALTER TABLE sources ADD COLUMN unit_lo INTEGER;
|
|
1913
|
+
ALTER TABLE sources ADD COLUMN unit_hi INTEGER;
|
|
1914
|
+
CREATE INDEX IF NOT EXISTS idx_sources_session ON sources(session_id, id);
|
|
1915
|
+
UPDATE sources SET unit_lo = g.lo, unit_hi = g.hi
|
|
1916
|
+
FROM (SELECT source_id, MIN(rowid) AS lo, MAX(rowid) AS hi FROM line_units GROUP BY source_id) AS g
|
|
1917
|
+
WHERE g.source_id = sources.id;
|
|
1918
|
+
`;
|
|
1918
1919
|
var MIGRATIONS = [
|
|
1919
1920
|
{ version: 1, sql: DDL },
|
|
1920
1921
|
{ version: 2, sql: DDL_V2 },
|
|
1921
1922
|
{ version: 3, sql: DDL_V3 },
|
|
1922
1923
|
{ version: 4, sql: DDL_V4 },
|
|
1923
1924
|
{ version: 5, sql: DDL_V5 },
|
|
1924
|
-
{ version: 6, sql: DDL_V6 }
|
|
1925
|
+
{ version: 6, sql: DDL_V6 },
|
|
1926
|
+
{ version: 7, sql: DDL_V7 }
|
|
1925
1927
|
];
|
|
1926
1928
|
function applyMigrations(db, fromVersion) {
|
|
1927
1929
|
if (fromVersion === SCHEMA_VERSION2) return;
|
|
@@ -5540,7 +5542,7 @@ var TOOL_DESCRIPTIONS = Object.freeze({
|
|
|
5540
5542
|
ctx_execute: 'Example: `ctx_execute({language:"shell",code:"git log --oneline -5"})`. Required: language, code.\nWrite code that prints only the answer, not the raw data. Runs code in a sandboxed subprocess in the project directory (shell, powershell, javascript, typescript, python, or another runtime on PATH); only what the code prints comes back. For a large file, set `file` to its local path: the code gets it in the CTX_FILE environment variable. Set `intent` when output may be large: the matching sections come back and the full output is indexed for ctx_search. `timeoutMs` defaults to and caps at 600000; then the whole process tree is killed.',
|
|
5541
5543
|
ctx_batch: 'Example: `ctx_batch({commands:["git log --oneline -5"],queries:["recent changes"]})`. Required: commands, queries.\nRuns several shell commands, then answers several search queries over their combined output, in one call. Use it to collect facts from more than one command at once, for example test results plus recent commits, when you need specific answers rather than the full text. Returns the matching sections and a one-line footer.',
|
|
5542
5544
|
ctx_index: 'Example: `ctx_index({path:"docs/api.md"})`. Required: one of path, content, url.\nStores content so it can be searched later: a local file or folder (nested .gitignore files are respected), raw text, or a URL, which is fetched and converted to Markdown. Use it for documentation or large files you will query more than once, then use ctx_search instead of reading the content again. Returns the source label and how many chunks were stored.',
|
|
5543
|
-
ctx_search: 'Example: `ctx_search({queries:["auth middleware"]})`. Required: queries.\nSearches content stored with ctx_index and earlier sandbox output in this project. Memory files such as AGENTS.md are searched too. Pass several queries in one call. By default it searches the current worktree; set `scope` to `project` for all worktrees or `session` for this session only. Results from the current session rank first, then by relevance, ranked with measurably better recall than plain keyword search. Set `sort` to `timeline` for oldest-first order across this session, prior sessions and memory, paged with `after`; `offset` is for relevance order only. Set `source` to `decision` to search only rows where the user answered a question. Every hit names its source. When nothing matches, the reply states the scope and how many sources are indexed.',
|
|
5545
|
+
ctx_search: 'Example: `ctx_search({queries:["auth middleware"]})`. Required: queries.\nSearches content stored with ctx_index and earlier sandbox output in this project. Memory files such as AGENTS.md are searched too. Pass several queries in one call. By default it searches the current worktree; set `scope` to `project` for all worktrees or `session` for this session only. Results from the current session rank first, then by relevance, ranked with measurably better recall than plain keyword search. Set `sort` to `timeline` for oldest-first order across this session, prior sessions and memory, paged with `after`; `offset` is for relevance order only. Set `source` to `decision` to search only rows where the user answered a question. Every hit names its source. Set `source` with queries `[""]` to read that source whole, in order, a full page per call; `More:` gives the next `offset`. When nothing matches, the reply states the scope and how many sources are indexed.',
|
|
5544
5546
|
ctx_resume: "Example: `ctx_resume({})`. Required: none.\nReturns a summary of up to 2 KB for this session: the last task and user request, files changed, open errors, and search terms for ctx_search. A large row is shown as a pointer line instead of its full text; call `ctx_resume(seq: N)` with that line's number to read the full row. Call it with no `seq` to get the state block on demand. Use it after the conversation was compacted or resumed, before you repeat earlier work.",
|
|
5545
5547
|
ctx_stats: "Example: `ctx_stats({})`. Required: none.\nReports the bytes context-mode kept out of the chat: a text report (bars, per tool, per agent) and a Markdown table. Show the text block to the user unchanged, in a code block. Use it when the user asks what it saved.",
|
|
5546
5548
|
ctx_doctor: "Example: `ctx_doctor({})`. Required: none.\nChecks this context-mode install and reports a table with one row per check: version, Node and node:sqlite, host config and hooks for this agent, MCP connection, project and worktree, database health, index contents, and hook timing. Each failed row names its cause, the fix and a docs link. Use it when the user asks whether context-mode works, or after a context-mode error. Run each Fix first, then call ctx_doctor again. If a FAIL stays, show the user the report file it names (it holds paths and environment details) and ask before you run the printed gh issue command.\n",
|
package/search.mjs
CHANGED
|
@@ -14,14 +14,6 @@ function prefixToolNames(text, prefix) {
|
|
|
14
14
|
}
|
|
15
15
|
var OUTPUT_CAP = 16384;
|
|
16
16
|
var INDEX_WRITE_CHUNK = 1048576;
|
|
17
|
-
var REPLACE_TRIGGER_BYTES_DEFAULT = 4096;
|
|
18
|
-
var REPLACE_TRIGGER_ENV = "CTX_REPLACE_TRIGGER_BYTES";
|
|
19
|
-
function readReplaceTrigger(raw) {
|
|
20
|
-
if (raw === void 0 || raw.trim() === "") return REPLACE_TRIGGER_BYTES_DEFAULT;
|
|
21
|
-
const n = Number(raw);
|
|
22
|
-
return Number.isSafeInteger(n) && n > 0 ? n : REPLACE_TRIGGER_BYTES_DEFAULT;
|
|
23
|
-
}
|
|
24
|
-
var REPLACE_TRIGGER_BYTES = readReplaceTrigger(process.env[REPLACE_TRIGGER_ENV]);
|
|
25
17
|
var RANGE_READ_TOOLS = Object.freeze(["Read", "view"]);
|
|
26
18
|
var READ_RANGE_KEYS = Object.freeze(["offset", "limit", "view_range"]);
|
|
27
19
|
var SKILL_LOAD_TOOLS = Object.freeze(["Skill"]);
|
|
@@ -179,7 +171,7 @@ var SQLITE_NOTADB_CODE = 26;
|
|
|
179
171
|
var HOOK_TIMEOUT_MS = 5e3;
|
|
180
172
|
var IN_PROCESS_TIMEOUT_MS = 0;
|
|
181
173
|
var PROJECT_KEY_HEX_LEN = 16;
|
|
182
|
-
var SCHEMA_VERSION =
|
|
174
|
+
var SCHEMA_VERSION = 7;
|
|
183
175
|
var PROJECTS_DIR_NAME = "projects";
|
|
184
176
|
var DB_FILE_NAME = "context.db";
|
|
185
177
|
var GIT_DIR_NAME = ".git";
|
|
@@ -1756,7 +1748,8 @@ var ERROR_TEXT = Object.freeze({
|
|
|
1756
1748
|
NO_RUNTIME: "No <lang> runtime on PATH. Fix: install it or pick another language.",
|
|
1757
1749
|
FETCH_FAILED: "Fetch failed: <code>. Fix: check the URL or proxy.",
|
|
1758
1750
|
SSRF: "Blocked private address <host>. Fix: use a public URL.",
|
|
1759
|
-
OUTSIDE_ROOT: "Path <p> is outside the project. Fix: use a path inside <root
|
|
1751
|
+
OUTSIDE_ROOT: "Path <p> is outside the project and the folders added to this session. Fix: use a path inside <root>, or add its folder to the session (Claude Code /add-dir, Codex --add-dir).",
|
|
1752
|
+
// #1398 D-1398-HOST-ROOTS-1
|
|
1760
1753
|
INVALID_ARGS: "Invalid argument <field>. Fix: <action>.",
|
|
1761
1754
|
ONE_OF_INPUT: "Pass exactly one of <names>. Fix: drop the extra field.",
|
|
1762
1755
|
SPAWN_FAILED: "Failed to start the process: <detail>. Fix: check the command and PATH.",
|
|
@@ -1915,13 +1908,22 @@ CREATE VIRTUAL TABLE line_units USING fts5(
|
|
|
1915
1908
|
var DDL_V6 = `
|
|
1916
1909
|
UPDATE sources SET label = replace(label, char(92), '/') WHERE kind = 'path' AND instr(label, char(92)) > 0;
|
|
1917
1910
|
`;
|
|
1911
|
+
var DDL_V7 = `
|
|
1912
|
+
ALTER TABLE sources ADD COLUMN unit_lo INTEGER;
|
|
1913
|
+
ALTER TABLE sources ADD COLUMN unit_hi INTEGER;
|
|
1914
|
+
CREATE INDEX IF NOT EXISTS idx_sources_session ON sources(session_id, id);
|
|
1915
|
+
UPDATE sources SET unit_lo = g.lo, unit_hi = g.hi
|
|
1916
|
+
FROM (SELECT source_id, MIN(rowid) AS lo, MAX(rowid) AS hi FROM line_units GROUP BY source_id) AS g
|
|
1917
|
+
WHERE g.source_id = sources.id;
|
|
1918
|
+
`;
|
|
1918
1919
|
var MIGRATIONS = [
|
|
1919
1920
|
{ version: 1, sql: DDL },
|
|
1920
1921
|
{ version: 2, sql: DDL_V2 },
|
|
1921
1922
|
{ version: 3, sql: DDL_V3 },
|
|
1922
1923
|
{ version: 4, sql: DDL_V4 },
|
|
1923
1924
|
{ version: 5, sql: DDL_V5 },
|
|
1924
|
-
{ version: 6, sql: DDL_V6 }
|
|
1925
|
+
{ version: 6, sql: DDL_V6 },
|
|
1926
|
+
{ version: 7, sql: DDL_V7 }
|
|
1925
1927
|
];
|
|
1926
1928
|
function applyMigrations(db, fromVersion) {
|
|
1927
1929
|
if (fromVersion === SCHEMA_VERSION2) return;
|
|
@@ -5540,7 +5542,7 @@ var TOOL_DESCRIPTIONS = Object.freeze({
|
|
|
5540
5542
|
ctx_execute: 'Example: `ctx_execute({language:"shell",code:"git log --oneline -5"})`. Required: language, code.\nWrite code that prints only the answer, not the raw data. Runs code in a sandboxed subprocess in the project directory (shell, powershell, javascript, typescript, python, or another runtime on PATH); only what the code prints comes back. For a large file, set `file` to its local path: the code gets it in the CTX_FILE environment variable. Set `intent` when output may be large: the matching sections come back and the full output is indexed for ctx_search. `timeoutMs` defaults to and caps at 600000; then the whole process tree is killed.',
|
|
5541
5543
|
ctx_batch: 'Example: `ctx_batch({commands:["git log --oneline -5"],queries:["recent changes"]})`. Required: commands, queries.\nRuns several shell commands, then answers several search queries over their combined output, in one call. Use it to collect facts from more than one command at once, for example test results plus recent commits, when you need specific answers rather than the full text. Returns the matching sections and a one-line footer.',
|
|
5542
5544
|
ctx_index: 'Example: `ctx_index({path:"docs/api.md"})`. Required: one of path, content, url.\nStores content so it can be searched later: a local file or folder (nested .gitignore files are respected), raw text, or a URL, which is fetched and converted to Markdown. Use it for documentation or large files you will query more than once, then use ctx_search instead of reading the content again. Returns the source label and how many chunks were stored.',
|
|
5543
|
-
ctx_search: 'Example: `ctx_search({queries:["auth middleware"]})`. Required: queries.\nSearches content stored with ctx_index and earlier sandbox output in this project. Memory files such as AGENTS.md are searched too. Pass several queries in one call. By default it searches the current worktree; set `scope` to `project` for all worktrees or `session` for this session only. Results from the current session rank first, then by relevance, ranked with measurably better recall than plain keyword search. Set `sort` to `timeline` for oldest-first order across this session, prior sessions and memory, paged with `after`; `offset` is for relevance order only. Set `source` to `decision` to search only rows where the user answered a question. Every hit names its source. When nothing matches, the reply states the scope and how many sources are indexed.',
|
|
5545
|
+
ctx_search: 'Example: `ctx_search({queries:["auth middleware"]})`. Required: queries.\nSearches content stored with ctx_index and earlier sandbox output in this project. Memory files such as AGENTS.md are searched too. Pass several queries in one call. By default it searches the current worktree; set `scope` to `project` for all worktrees or `session` for this session only. Results from the current session rank first, then by relevance, ranked with measurably better recall than plain keyword search. Set `sort` to `timeline` for oldest-first order across this session, prior sessions and memory, paged with `after`; `offset` is for relevance order only. Set `source` to `decision` to search only rows where the user answered a question. Every hit names its source. Set `source` with queries `[""]` to read that source whole, in order, a full page per call; `More:` gives the next `offset`. When nothing matches, the reply states the scope and how many sources are indexed.',
|
|
5544
5546
|
ctx_resume: "Example: `ctx_resume({})`. Required: none.\nReturns a summary of up to 2 KB for this session: the last task and user request, files changed, open errors, and search terms for ctx_search. A large row is shown as a pointer line instead of its full text; call `ctx_resume(seq: N)` with that line's number to read the full row. Call it with no `seq` to get the state block on demand. Use it after the conversation was compacted or resumed, before you repeat earlier work.",
|
|
5545
5547
|
ctx_stats: "Example: `ctx_stats({})`. Required: none.\nReports the bytes context-mode kept out of the chat: a text report (bars, per tool, per agent) and a Markdown table. Show the text block to the user unchanged, in a code block. Use it when the user asks what it saved.",
|
|
5546
5548
|
ctx_doctor: "Example: `ctx_doctor({})`. Required: none.\nChecks this context-mode install and reports a table with one row per check: version, Node and node:sqlite, host config and hooks for this agent, MCP connection, project and worktree, database health, index contents, and hook timing. Each failed row names its cause, the fix and a docs link. Use it when the user asks whether context-mode works, or after a context-mode error. Run each Fix first, then call ctx_doctor again. If a FAIL stays, show the user the report file it names (it holds paths and environment details) and ask before you run the printed gh issue command.\n",
|