@theokit/sdk-tools 0.7.0 → 0.8.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 +6 -0
- package/dist/index.cjs +38 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -4
- package/dist/index.d.ts +46 -4
- package/dist/index.js +38 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ac3f77d: @theokit/sdk: resolveModelCapabilities catalog gains cheap OpenRouter slugs (qwen3-coder, deepseek v4-flash/v3.2, glm-4.7-flash, gemini-2.5-flash-lite/pro) so they resolve real context windows instead of the 4096 default. @theokit/sdk-tools: new createGenericHttpSearchAdapter (env-keyed generic HTTP WebSearchCallback alongside Brave); buildEnvContext gains git-branch detection + an injectable clock. @theokit/sdk-cache: ships createLexicalEmbedder (zero-dependency token-hash lexical embedder built-in).
|
|
8
|
+
|
|
3
9
|
## 0.7.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -887,15 +887,26 @@ function safeReadHead(p, n) {
|
|
|
887
887
|
return "";
|
|
888
888
|
}
|
|
889
889
|
}
|
|
890
|
-
function
|
|
890
|
+
function gitBranch(headPath) {
|
|
891
|
+
try {
|
|
892
|
+
const head = fs.readFileSync(headPath, "utf-8").trim();
|
|
893
|
+
const match = head.match(/^ref:\s*refs\/heads\/(.+)$/);
|
|
894
|
+
return match ? match[1] : void 0;
|
|
895
|
+
} catch {
|
|
896
|
+
return void 0;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
function buildEnvContext(cwd, opts = {}) {
|
|
891
900
|
const lines = [
|
|
892
901
|
"<env>",
|
|
893
902
|
` Working directory: ${cwd}`,
|
|
894
903
|
` Platform: ${process.platform} (${process.arch})`,
|
|
895
904
|
` Node: ${process.version}`,
|
|
896
|
-
` Is git repo: ${safeExists(path.join(cwd, ".git")) ? "yes" : "no"}
|
|
897
|
-
` Today's date: ${(/* @__PURE__ */ new Date()).toDateString()}`
|
|
905
|
+
` Is git repo: ${safeExists(path.join(cwd, ".git")) ? "yes" : "no"}`
|
|
898
906
|
];
|
|
907
|
+
const branch = gitBranch(opts.gitHeadPath ?? path.join(cwd, ".git", "HEAD"));
|
|
908
|
+
if (branch) lines.push(` Branch: ${branch}`);
|
|
909
|
+
lines.push(` Today's date: ${(opts.now ?? /* @__PURE__ */ new Date()).toDateString()}`);
|
|
899
910
|
const docs = PROJECT_DOCS.filter((d) => safeExists(path.join(cwd, d)));
|
|
900
911
|
if (docs.length > 0) {
|
|
901
912
|
lines.push(` Project docs: ${docs.join(", ")}`);
|
|
@@ -1934,6 +1945,29 @@ function createBraveWebSearchAdapter(opts = {}) {
|
|
|
1934
1945
|
}));
|
|
1935
1946
|
};
|
|
1936
1947
|
}
|
|
1948
|
+
|
|
1949
|
+
// src/web-search-http.ts
|
|
1950
|
+
function createGenericHttpSearchAdapter(opts = {}) {
|
|
1951
|
+
const apiKey = opts.apiKey ?? process.env.THEOKIT_SEARCH_API_KEY;
|
|
1952
|
+
const endpoint = opts.endpoint ?? process.env.THEOKIT_SEARCH_API_URL;
|
|
1953
|
+
const fetchImpl = opts.fetchImpl ?? globalThis.fetch;
|
|
1954
|
+
return async (query, maxResults) => {
|
|
1955
|
+
if (!apiKey || !endpoint) return [];
|
|
1956
|
+
try {
|
|
1957
|
+
const url = `${endpoint}?q=${encodeURIComponent(query)}&n=${maxResults}`;
|
|
1958
|
+
const res = await fetchImpl(url, { headers: { Authorization: `Bearer ${apiKey}` } });
|
|
1959
|
+
if (!res.ok) return [];
|
|
1960
|
+
const data = await res.json();
|
|
1961
|
+
return (data?.results ?? []).slice(0, maxResults).map((r) => ({
|
|
1962
|
+
title: String(r?.title ?? ""),
|
|
1963
|
+
url: String(r?.url ?? ""),
|
|
1964
|
+
snippet: String(r?.snippet ?? "")
|
|
1965
|
+
}));
|
|
1966
|
+
} catch {
|
|
1967
|
+
return [];
|
|
1968
|
+
}
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1937
1971
|
var BINARY_PROBE_BYTES3 = 8 * 1024;
|
|
1938
1972
|
function createWriteFileTool(opts) {
|
|
1939
1973
|
const { projectRoot } = opts;
|
|
@@ -2001,6 +2035,7 @@ exports.commandDenialReason = commandDenialReason;
|
|
|
2001
2035
|
exports.createApplyPatchTool = createApplyPatchTool;
|
|
2002
2036
|
exports.createBraveWebSearchAdapter = createBraveWebSearchAdapter;
|
|
2003
2037
|
exports.createEditFileTool = createEditFileTool;
|
|
2038
|
+
exports.createGenericHttpSearchAdapter = createGenericHttpSearchAdapter;
|
|
2004
2039
|
exports.createGitDiffTool = createGitDiffTool;
|
|
2005
2040
|
exports.createGlobTool = createGlobTool;
|
|
2006
2041
|
exports.createListDirTool = createListDirTool;
|