opencode-context 1.0.3 → 1.0.5
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/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -31
- package/dist/install.js +6 -4
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +15 -1
- package/dist/search.d.ts.map +1 -1
- package/package.json +2 -3
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA4M1C,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7961,6 +7961,17 @@ var DOC_PATTERNS = [
|
|
|
7961
7961
|
|
|
7962
7962
|
// src/search.ts
|
|
7963
7963
|
function parseQuery(query) {
|
|
7964
|
+
if (!query || typeof query !== "string") {
|
|
7965
|
+
return {
|
|
7966
|
+
original: query || "",
|
|
7967
|
+
terms: [],
|
|
7968
|
+
exactTerms: [],
|
|
7969
|
+
fileTypes: [],
|
|
7970
|
+
wantTests: false,
|
|
7971
|
+
wantConfigs: false,
|
|
7972
|
+
wantDocs: false
|
|
7973
|
+
};
|
|
7974
|
+
}
|
|
7964
7975
|
const lowerQuery = query.toLowerCase();
|
|
7965
7976
|
const terms = [];
|
|
7966
7977
|
const exactTerms = [];
|
|
@@ -8346,7 +8357,6 @@ async function searchFiles(options) {
|
|
|
8346
8357
|
}
|
|
8347
8358
|
|
|
8348
8359
|
// src/index.ts
|
|
8349
|
-
var program2 = new Command;
|
|
8350
8360
|
function formatScore(score) {
|
|
8351
8361
|
if (score >= 80)
|
|
8352
8362
|
return import_picocolors3.default.green(score.toString().padStart(3));
|
|
@@ -8456,36 +8466,43 @@ async function interactiveMode() {
|
|
|
8456
8466
|
process.exit(1);
|
|
8457
8467
|
}
|
|
8458
8468
|
}
|
|
8459
|
-
|
|
8460
|
-
program2
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8469
|
+
function runCLI() {
|
|
8470
|
+
const program2 = new Command;
|
|
8471
|
+
program2.name("opencode-context").description("Smart file finder for codebases - semantic search with confidence scoring").version("1.0.3");
|
|
8472
|
+
program2.option("-q, --query <query>", "Search query").option("-n, --max-files <number>", "Maximum number of results", "5").option("--min-score <score>", "Minimum relevance score (0-100)", "15").option("-p, --path <path>", "Root path to search from", process.cwd()).option("--include-tests", "Include test files", false).option("--include-configs", "Include configuration files", false).option("--include-docs", "Include documentation files", false).option("--no-content", "Skip content search (faster)").option("--max-size <bytes>", "Maximum file size to read", "1048576").option("-j, --json", "Output as JSON", false).option("-d, --detailed", "Show detailed match reasons", false).option("-i, --interactive", "Interactive mode", false).action(async (options) => {
|
|
8473
|
+
try {
|
|
8474
|
+
if (options.interactive || !options.query) {
|
|
8475
|
+
await interactiveMode();
|
|
8476
|
+
return;
|
|
8477
|
+
}
|
|
8478
|
+
const searchOptions = {
|
|
8479
|
+
query: options.query,
|
|
8480
|
+
maxFiles: parseInt(options.maxFiles, 10),
|
|
8481
|
+
minScore: parseInt(options.minScore, 10),
|
|
8482
|
+
rootPath: options.path,
|
|
8483
|
+
includeTests: options.includeTests,
|
|
8484
|
+
includeConfigs: options.includeConfigs,
|
|
8485
|
+
includeDocs: options.includeDocs,
|
|
8486
|
+
searchContent: options.content !== false,
|
|
8487
|
+
maxFileSize: parseInt(options.maxSize, 10)
|
|
8488
|
+
};
|
|
8489
|
+
const result = await searchFiles(searchOptions);
|
|
8490
|
+
if (options.json) {
|
|
8491
|
+
console.log(JSON.stringify(result, null, 2));
|
|
8492
|
+
} else {
|
|
8493
|
+
formatResults(result, options.detailed);
|
|
8494
|
+
}
|
|
8495
|
+
} catch (error) {
|
|
8496
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
8497
|
+
console.error(import_picocolors3.default.red(`Error: ${message}`));
|
|
8498
|
+
process.exit(1);
|
|
8482
8499
|
}
|
|
8483
|
-
}
|
|
8484
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
8485
|
-
console.error(import_picocolors3.default.red(`Error: ${message}`));
|
|
8486
|
-
process.exit(1);
|
|
8487
|
-
}
|
|
8488
|
-
});
|
|
8489
|
-
if (__require.main == __require.module) {
|
|
8500
|
+
});
|
|
8490
8501
|
program2.parse();
|
|
8491
8502
|
}
|
|
8503
|
+
if (__require.main == __require.module) {
|
|
8504
|
+
runCLI();
|
|
8505
|
+
}
|
|
8506
|
+
export {
|
|
8507
|
+
searchFiles
|
|
8508
|
+
};
|
package/dist/install.js
CHANGED
|
@@ -26,7 +26,7 @@ async function writeConfig(config) {
|
|
|
26
26
|
`);
|
|
27
27
|
}
|
|
28
28
|
async function install() {
|
|
29
|
-
console.log(`Installing
|
|
29
|
+
console.log(`Installing opencode-context plugin...
|
|
30
30
|
`);
|
|
31
31
|
await ensureConfigDir();
|
|
32
32
|
const config = await readConfig();
|
|
@@ -35,10 +35,10 @@ async function install() {
|
|
|
35
35
|
}
|
|
36
36
|
const pluginName = "opencode-context@latest";
|
|
37
37
|
if (config.plugin.includes(pluginName)) {
|
|
38
|
-
console.log("\u2713
|
|
38
|
+
console.log("\u2713 opencode-context already in plugins");
|
|
39
39
|
} else {
|
|
40
40
|
config.plugin.push(pluginName);
|
|
41
|
-
console.log("\u2713 Added
|
|
41
|
+
console.log("\u2713 Added opencode-context@latest to plugins");
|
|
42
42
|
}
|
|
43
43
|
await writeConfig(config);
|
|
44
44
|
console.log(`
|
|
@@ -50,4 +50,6 @@ To use:`);
|
|
|
50
50
|
console.log(` 3. The agent will use find_files tool
|
|
51
51
|
`);
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
if (__require.main == __require.module) {
|
|
54
|
+
install().catch(console.error);
|
|
55
|
+
}
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,qBAAqB,CAAC;AAaxD,QAAA,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,qBAAqB,CAAC;AAaxD,QAAA,MAAM,iBAAiB,EAAE,MA8CxB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
package/dist/plugin.js
CHANGED
|
@@ -17707,6 +17707,17 @@ var DOC_PATTERNS = [
|
|
|
17707
17707
|
|
|
17708
17708
|
// src/search.ts
|
|
17709
17709
|
function parseQuery(query) {
|
|
17710
|
+
if (!query || typeof query !== "string") {
|
|
17711
|
+
return {
|
|
17712
|
+
original: query || "",
|
|
17713
|
+
terms: [],
|
|
17714
|
+
exactTerms: [],
|
|
17715
|
+
fileTypes: [],
|
|
17716
|
+
wantTests: false,
|
|
17717
|
+
wantConfigs: false,
|
|
17718
|
+
wantDocs: false
|
|
17719
|
+
};
|
|
17720
|
+
}
|
|
17710
17721
|
const lowerQuery = query.toLowerCase();
|
|
17711
17722
|
const terms = [];
|
|
17712
17723
|
const exactTerms = [];
|
|
@@ -18092,7 +18103,7 @@ async function searchFiles(options) {
|
|
|
18092
18103
|
}
|
|
18093
18104
|
|
|
18094
18105
|
// src/plugin.ts
|
|
18095
|
-
var OpenContextPlugin = async (
|
|
18106
|
+
var OpenContextPlugin = async () => {
|
|
18096
18107
|
return {
|
|
18097
18108
|
tool: {
|
|
18098
18109
|
find_files: tool({
|
|
@@ -18107,6 +18118,9 @@ var OpenContextPlugin = async (ctx) => {
|
|
|
18107
18118
|
},
|
|
18108
18119
|
async execute(args, context) {
|
|
18109
18120
|
const { directory } = context;
|
|
18121
|
+
if (!args.query || typeof args.query !== "string") {
|
|
18122
|
+
return "Error: query parameter is required. Usage: find_files query='search term'";
|
|
18123
|
+
}
|
|
18110
18124
|
const options = {
|
|
18111
18125
|
query: args.query,
|
|
18112
18126
|
maxFiles: args.maxFiles || 5,
|
package/dist/search.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,SAAS,EAET,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,WAAW,EAOZ,MAAM,YAAY,CAAC;AAEpB,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,SAAS,EAET,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,WAAW,EAOZ,MAAM,YAAY,CAAC;AAEpB,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CA+DrD;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAMpD;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAMtD;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAMnD;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQnE;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAiB7E;AAgQD,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,OAAO,GACrB,OAAO,CAAC,SAAS,CAAC,CAmCpB;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAiE/E"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-context",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Smart file finder for codebases - semantic search with confidence scoring. Also available as an OpenCode plugin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"bin": {
|
|
9
|
-
"opencode-context": "dist/index.js"
|
|
10
|
-
"opencode-context-install": "dist/install.js"
|
|
9
|
+
"opencode-context": "dist/index.js"
|
|
11
10
|
},
|
|
12
11
|
"files": [
|
|
13
12
|
"dist/",
|