pi-supernova 0.4.0 → 0.6.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.
- package/README.md +86 -24
- package/docs/CHANGELOG.md +70 -0
- package/docs/TOKEN_COSTS.md +64 -28
- package/index.js +64 -25
- package/package.json +2 -2
- package/src/bridge/catalog.js +14 -10
- package/src/bridge/host-bridge.js +919 -158
- package/src/bridge/native-tools.js +16 -6
- package/src/context/evidence.js +13 -5
- package/src/context/fuzzy.js +34 -13
- package/src/context/outline.js +11 -2
- package/src/context/repo-index.js +190 -19
- package/src/context/search.js +70 -17
- package/src/context/snap.js +128 -40
- package/src/context/spans.js +39 -0
- package/src/context/surface.js +23 -15
- package/src/fs/check.js +10 -2
- package/src/fs/json-read.js +5 -1
- package/src/fs/patch.js +4 -2
- package/src/fs/vfs.js +133 -33
- package/src/fs/workspace.js +34 -4
- package/src/output/bottleneck.js +53 -15
- package/src/output/format.js +63 -29
- package/src/runtime/guest-worker.js +172 -61
- package/src/runtime/parallel.js +4 -1
- package/src/runtime/program-batch.js +17 -6
- package/src/runtime/program-file.js +6 -3
- package/src/runtime/reference.js +15 -22
- package/src/runtime/runtime.js +17 -8
- package/src/shared/decode.js +26 -3
- package/src/ui/omp-frame.js +11 -4
- package/src/ui/render.js +2 -2
package/src/bridge/catalog.js
CHANGED
|
@@ -4,22 +4,24 @@ import { isString, isObject } from "../shared/decode.js";
|
|
|
4
4
|
const NATIVE_TOOL_DEFINITIONS = [
|
|
5
5
|
{
|
|
6
6
|
name: "read",
|
|
7
|
-
description: "Read files, images or directories. JSON selectors project full documents within output budgets. Source questions locate and open source directly; resolve returns structured source/status without guessing.",
|
|
7
|
+
description: "Read files, images or directories (directory reads return entries). JSON selectors project full documents within output budgets. Source questions locate and open source directly; resolve returns structured source/status without guessing.",
|
|
8
8
|
parameters: { type: "object", properties: {
|
|
9
|
-
path: { anyOf: [{ type: "string" }, { type: "array", items: { type: "string" } }], description: "Workspace-relative file or directory, source question, or
|
|
9
|
+
path: { anyOf: [{ type: "string" }, { type: "array", items: { type: "string" }, maxItems: 64 }], description: "Workspace-relative file or directory, source question, or up to 64 paths" },
|
|
10
10
|
target: { anyOf: [{ type: "string" }, { type: "array" }], description: "File path/query or array of paths" },
|
|
11
11
|
offset: { type: "number", description: "One-based starting line" },
|
|
12
12
|
limit: { type: "number", description: "Maximum lines to return" },
|
|
13
|
-
about: { type: "string", description: "Question or symbol: expand file bodies, or locate
|
|
14
|
-
query: { type: "string", description: "Source question; optional path scopes the search directory" },
|
|
13
|
+
about: { type: "string", description: "Question or symbol (at most 16 keywords): expand file bodies, or locate/open source inside a directory" },
|
|
14
|
+
query: { type: "string", description: "Source question (at most 16 keywords); optional path scopes the search directory" },
|
|
15
|
+
outline: { type: "boolean", description: "Return a compact structural outline for the target file" },
|
|
16
|
+
evidence: { type: "boolean", description: "Rank source spans answering the target/path question" },
|
|
15
17
|
resolve: { type: "boolean", description: "Return structured source/status for a direct resolve-to-edit handoff" },
|
|
16
18
|
complete: { type: "boolean", description: "Fail unless the entire requested file fits without clipping" },
|
|
17
|
-
json: { anyOf: [{ type: "boolean" }, { type: "string" }, { type: "array", items: { type: "string" } }], description: "Parse
|
|
19
|
+
json: { anyOf: [{ type: "boolean" }, { type: "string" }, { type: "array", items: { type: "string" }, minItems: 1, maxItems: 64 }], description: "Parse complete JSON input up to 16 MiB, then select .field, .items[0:3], quoted keys, true, or 1-64 selectors. Oversized selections fail, never clip." },
|
|
18
20
|
} },
|
|
19
21
|
},
|
|
20
22
|
{
|
|
21
23
|
name: "write", description: "Write UTF-8 content to a workspace file.",
|
|
22
|
-
parameters: { type: "object", properties: { path: { type: "string" }, content: { type: "string" }, allowReadArtifacts: { type: "boolean", description: "Explicit opt-in for intentionally writing literal truncation-marker text" } }, required: ["path", "content"] },
|
|
24
|
+
parameters: { type: "object", properties: { path: { type: "string" }, content: { type: "string" }, append: { type: "boolean", description: "Append to an existing file instead of replacing it" }, allowReadArtifacts: { type: "boolean", description: "Explicit opt-in for intentionally writing literal truncation-marker text" } }, required: ["path", "content"] },
|
|
23
25
|
},
|
|
24
26
|
{
|
|
25
27
|
name: "edit", description: "Apply unique text replacements to a workspace file; returns the post-edit lines, a structural check, and references to changed declarations.",
|
|
@@ -53,7 +55,7 @@ const NATIVE_TOOL_DEFINITIONS = [
|
|
|
53
55
|
},
|
|
54
56
|
{
|
|
55
57
|
name: "bash", description: "Run a shell command inside the workspace and capture bounded output.",
|
|
56
|
-
parameters: { type: "object", properties: { command: { type: "string" }, cwd: { type: "string" }, timeoutMs: { type: "number" } }, required: ["command"] },
|
|
58
|
+
parameters: { type: "object", properties: { command: { type: "string" }, args: { type: "array", items: { type: "string" }, description: "Literal argv without shell interpretation (POSIX)" }, cwd: { type: "string" }, timeoutMs: { type: "number" } }, required: ["command"] },
|
|
57
59
|
},
|
|
58
60
|
{
|
|
59
61
|
name: "grep", description: "Search file contents. Smart-case regex; definition lines first (marked *); fuzzy fallback when nothing matches literally.",
|
|
@@ -178,7 +180,9 @@ export function searchCatalog(catalog, query, limit = 12) {
|
|
|
178
180
|
|
|
179
181
|
scored.sort((a, b) => b.score - a.score || a.name.localeCompare(b.name));
|
|
180
182
|
|
|
181
|
-
|
|
183
|
+
const capped = Math.min(64, Math.max(1, Math.floor(Number(limit)) || 1));
|
|
184
|
+
|
|
185
|
+
return scored.slice(0, capped).map(({ score: _s, ...hit }) => hit);
|
|
182
186
|
}
|
|
183
187
|
|
|
184
188
|
/** Optimal string alignment distance: insert/delete/substitute/adjacent-transpose cost 1. */
|
|
@@ -202,7 +206,7 @@ function editDistance(a, b) {
|
|
|
202
206
|
|
|
203
207
|
/** Closest tool names for a mistyped name: substring hits first, then a length-scaled edit distance. */
|
|
204
208
|
function suggestNames(name, candidates, limit = 3) {
|
|
205
|
-
const needle = String(name || "").toLowerCase();
|
|
209
|
+
const needle = String(name || "").toLowerCase().slice(0, 128);
|
|
206
210
|
|
|
207
211
|
if (!needle) return [];
|
|
208
212
|
const maxDistance = Math.max(1, Math.floor(needle.length / 3));
|
|
@@ -228,7 +232,7 @@ function suggestNames(name, candidates, limit = 3) {
|
|
|
228
232
|
}
|
|
229
233
|
|
|
230
234
|
export function unknownToolMessage(name, candidates) {
|
|
231
|
-
const close = suggestNames(name, candidates);
|
|
235
|
+
const close = suggestNames(name, candidates.filter(isString));
|
|
232
236
|
const hint = close.length ? ` Did you mean ${close.map((c) => JSON.stringify(c)).join(", ")}?` : "";
|
|
233
237
|
|
|
234
238
|
return `unknown tool "${name}".${hint} Check the command name and configured tool exclusions.`;
|