@theokit/sdk-tools 0.3.0 → 0.4.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/CHANGELOG.md +8 -0
- package/dist/index.cjs +12 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -266,7 +266,7 @@ function createEditFileTool(opts) {
|
|
|
266
266
|
const { projectRoot } = opts;
|
|
267
267
|
return defineTool({
|
|
268
268
|
name: "edit_file",
|
|
269
|
-
description: "
|
|
269
|
+
description: "Make an exact string replacement in a project-relative file. Replaces the FIRST occurrence of old_string with new_string (a whitespace-normalized fallback is attempted if the exact match fails) and writes a .bak backup first. Read the file first so old_string matches the on-disk text exactly; include enough surrounding context to make it unique \u2014 only the first match is replaced, so a too-short old_string can edit the wrong location. old_string must be non-empty and differ from new_string; to change every occurrence, call edit_file repeatedly. Returns { ok, replacements } or { ok: false, error }.",
|
|
270
270
|
inputSchema: z.object({
|
|
271
271
|
path: z.string().min(1).describe("Project-relative file path."),
|
|
272
272
|
old_string: z.string().min(1).describe("String to find in the file."),
|
|
@@ -274,6 +274,9 @@ function createEditFileTool(opts) {
|
|
|
274
274
|
}),
|
|
275
275
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: unified diff parsing is inherently complex
|
|
276
276
|
handler: async ({ path, old_string, new_string }) => {
|
|
277
|
+
if (old_string === new_string) {
|
|
278
|
+
return JSON.stringify({ ok: false, error: "no_change", path });
|
|
279
|
+
}
|
|
277
280
|
if (isForbiddenPath(path)) {
|
|
278
281
|
return JSON.stringify({ ok: false, error: "forbidden_path", path });
|
|
279
282
|
}
|
|
@@ -522,7 +525,7 @@ function createGlobTool(opts) {
|
|
|
522
525
|
const { projectRoot } = opts;
|
|
523
526
|
return defineTool({
|
|
524
527
|
name: "glob_files",
|
|
525
|
-
description: "
|
|
528
|
+
description: "Find files by glob pattern across the project \u2014 fast at any repo size. Use glob_files when you know the filename SHAPE; use search_text when you know the file CONTENT; use read_file when you know the exact path. The pattern supports * and ** wildcards (e.g. '**/*.ts', 'src/**/*.json'); node_modules/.git/dist/.theo are excluded and results are relative paths. Returns { ok, files } or { ok: false, error }.",
|
|
526
529
|
inputSchema: z.object({
|
|
527
530
|
pattern: z.string().min(1).describe("Glob pattern (e.g. '**/*.ts', 'src/**/*.json')."),
|
|
528
531
|
cwd: z.string().optional().describe("Project-relative subdirectory to search from.")
|
|
@@ -1209,7 +1212,7 @@ function createReadFileTool(opts) {
|
|
|
1209
1212
|
const { projectRoot } = opts;
|
|
1210
1213
|
return defineTool({
|
|
1211
1214
|
name: "read_file",
|
|
1212
|
-
description: "Read a
|
|
1215
|
+
description: "Read a project-relative text file as UTF-8. ALWAYS read a file before you edit it (edit_file) or overwrite it (write_file), so your old_string / new content matches the real bytes exactly. Returns the WHOLE file (there is no offset or line-range parameter); to locate a symbol inside a large file, use search_text instead of re-reading. Refuses paths that escape the project root, sensitive files (.env, .git/, node_modules/, .theo/, lock files), and binary files (null byte in the first 8 KB); caps at 5 MB. Returns { ok, content, size } or { ok: false, error }.",
|
|
1213
1216
|
inputSchema: z.object({
|
|
1214
1217
|
path: z.string().min(1).describe("Project-relative file path.")
|
|
1215
1218
|
}),
|
|
@@ -1399,7 +1402,7 @@ function createSearchTextTool(opts) {
|
|
|
1399
1402
|
} = opts;
|
|
1400
1403
|
return defineTool({
|
|
1401
1404
|
name: "search_text",
|
|
1402
|
-
description: `Search the project tree
|
|
1405
|
+
description: `Search file CONTENTS for a LITERAL, CASE-SENSITIVE query across the project tree (the query is matched as a substring, not a regex). Use search_text when you know the content; use glob_files when you know the filename shape; use read_file when you know the exact path. Skips sensitive dirs (.env/.git/node_modules/.theo), binary files, and files over 1 MB; 'path' scopes the search to a subdirectory. Returns up to ${String(maxMatches)} matches as { file, line, preview } \u2014 cite locations to the user as file:line. Returns { ok, matches } or { ok: false, error }.`,
|
|
1403
1406
|
inputSchema: z.object({
|
|
1404
1407
|
query: z.string().min(1).describe("Literal text to search for. Case-sensitive."),
|
|
1405
1408
|
path: z.string().optional().describe("Optional project-relative directory to scope the search.")
|
|
@@ -1510,7 +1513,7 @@ function createShellTool(opts) {
|
|
|
1510
1513
|
const { projectRoot, defaultTimeoutMs = DEFAULT_TIMEOUT_MS3, allowCatastrophic = false } = opts;
|
|
1511
1514
|
return defineTool({
|
|
1512
1515
|
name: "shell_exec",
|
|
1513
|
-
description: "Execute a shell command in the project directory.
|
|
1516
|
+
description: "Execute a shell command in the project directory. Use this for terminal operations \u2014 running tests, git, package managers, build tools. Do NOT use it for file operations (reading, writing, editing, finding files): prefer the specialized read_file/write_file/edit_file/glob_files/search_text tools, which are path-checked and safer. Only commit, push, or change git state when the user explicitly asks. timeout_ms defaults to 30000 (max 300000); stdout/stderr are capped (~5 MB). Returns { ok, stdout, stderr, exit_code } or { ok: false, error }.",
|
|
1514
1517
|
inputSchema: z.object({
|
|
1515
1518
|
command: z.string().min(1).describe("Shell command to execute."),
|
|
1516
1519
|
timeout_ms: z.number().int().positive().optional().describe("Timeout in milliseconds (default 30000, max 300000).")
|
|
@@ -1688,7 +1691,7 @@ ${done}/${items.length} done | ${inProg} in progress | ${pending} pending`);
|
|
|
1688
1691
|
};
|
|
1689
1692
|
return {
|
|
1690
1693
|
name: "todolist",
|
|
1691
|
-
description: "
|
|
1694
|
+
description: "Create and maintain a structured task list for the current session \u2014 tracks progress and keeps a multi-step plan visible across turns. Use it proactively when the work has 3+ steps or the user gave multiple tasks; skip it for a single trivial step. Keep exactly ONE item 'in_progress' at a time, and mark 'complete' only after the work is actually done. Actions: 'add' (create with title), 'in_progress' (mark started by id), 'complete' (mark done by id), 'remove' (delete by id), 'list' (show all), 'clear_completed' (remove done items). Returns { ok, items, items_summary } (items = structured array; items_summary = formatted text).",
|
|
1692
1695
|
inputSchema: {
|
|
1693
1696
|
type: "object",
|
|
1694
1697
|
properties: {
|
|
@@ -1744,7 +1747,7 @@ function createWebFetchTool(opts) {
|
|
|
1744
1747
|
const allowPrivateHosts = opts?.allowPrivateHosts ?? false;
|
|
1745
1748
|
return defineTool({
|
|
1746
1749
|
name: "web_fetch",
|
|
1747
|
-
description: "Fetch
|
|
1750
|
+
description: "Fetch the contents of a URL via HTTP/HTTPS. Use only for URLs the user provided or that you are confident help with the task; never invent or guess URLs. Rejects non-http(s) URLs and is SSRF-guarded by default (private/loopback/link-local/cloud-metadata hosts are refused with an ssrf_blocked error). The response body is capped at 1 MB. Returns { ok, content, status_code, content_type } or { ok: false, error }.",
|
|
1748
1751
|
inputSchema: z.object({
|
|
1749
1752
|
url: z.string().min(1).describe("URL to fetch (http or https only)."),
|
|
1750
1753
|
timeout_ms: z.number().int().positive().optional().describe("Timeout in milliseconds (default 30000).")
|
|
@@ -1825,7 +1828,7 @@ function createWebSearchTool(opts) {
|
|
|
1825
1828
|
const { search, defaultMaxResults = 5 } = opts;
|
|
1826
1829
|
return defineTool({
|
|
1827
1830
|
name: "web_search",
|
|
1828
|
-
description: "Search the web for a query. Returns a list of results with title, URL, and snippet. The search provider is injected by the consumer. Returns { ok, results } or { ok: false, error }.",
|
|
1831
|
+
description: "Search the web for a query \u2014 use when you need current information beyond the repo or your training cutoff (library docs, an error message, an API). Returns a list of results with title, URL, and snippet; follow up with web_fetch on a promising result to read it in full. The search provider is injected by the consumer. Returns { ok, results } or { ok: false, error }.",
|
|
1829
1832
|
inputSchema: z.object({
|
|
1830
1833
|
query: z.string().min(1).describe("Search query."),
|
|
1831
1834
|
max_results: z.number().int().positive().max(20).optional().describe("Maximum results to return (default 5, max 20).")
|
|
@@ -1883,7 +1886,7 @@ function createWriteFileTool(opts) {
|
|
|
1883
1886
|
const { projectRoot } = opts;
|
|
1884
1887
|
return defineTool({
|
|
1885
1888
|
name: "write_file",
|
|
1886
|
-
description: "Write UTF-8 content to a project-relative file
|
|
1889
|
+
description: "Write UTF-8 content to a project-relative file, creating parent directories as needed. OVERWRITES any existing file at the path. Prefer editing an existing file with edit_file over rewriting it; use write_file to create a NEW file or fully replace a small one. If the file already exists, read_file it first so you do not discard content you have not seen. Refuses paths that escape the project root, sensitive files (.env, .git/, node_modules/, .theo/, lock files), and binary-file overwrites. Returns { ok, path, bytes } or { ok: false, error }.",
|
|
1887
1890
|
inputSchema: z.object({
|
|
1888
1891
|
path: z.string().min(1).describe("Project-relative file path."),
|
|
1889
1892
|
content: z.string().describe("UTF-8 content to write.")
|