@bacnh85/pi-serena 0.3.0 → 0.3.1
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/lib/detect.ts +56 -0
- package/package.json +3 -2
package/lib/detect.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure detection logic for code-vs-non-code and semantic-search-vs-text-search decisions.
|
|
3
|
+
* Extracted from index.ts so it can be tested without importing pi-coding-agent.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const CODE_FILE_EXTENSIONS = new Set([
|
|
7
|
+
".c",
|
|
8
|
+
".cc",
|
|
9
|
+
".cpp",
|
|
10
|
+
".cs",
|
|
11
|
+
".css",
|
|
12
|
+
".go",
|
|
13
|
+
".java",
|
|
14
|
+
".js",
|
|
15
|
+
".jsx",
|
|
16
|
+
".kt",
|
|
17
|
+
".lua",
|
|
18
|
+
".mjs",
|
|
19
|
+
".php",
|
|
20
|
+
".py",
|
|
21
|
+
".rb",
|
|
22
|
+
".rs",
|
|
23
|
+
".scala",
|
|
24
|
+
".sh",
|
|
25
|
+
".swift",
|
|
26
|
+
".ts",
|
|
27
|
+
".tsx",
|
|
28
|
+
".vue",
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
const NON_SEMANTIC_FILE_EXTENSIONS = new Set([".json", ".jsonl", ".lock", ".md", ".txt", ".yaml", ".yml"]);
|
|
32
|
+
|
|
33
|
+
export const SEMANTIC_MISS_THRESHOLD = 2;
|
|
34
|
+
|
|
35
|
+
export function pathLooksLikeCode(value: unknown): boolean {
|
|
36
|
+
if (typeof value !== "string" || value.trim() === "") return false;
|
|
37
|
+
const cleanPath = value.split(/[?#]/, 1)[0].toLowerCase();
|
|
38
|
+
const dotIndex = cleanPath.lastIndexOf(".");
|
|
39
|
+
if (dotIndex < 0) return false;
|
|
40
|
+
return CODE_FILE_EXTENSIONS.has(cleanPath.slice(dotIndex));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function pathLooksNonSemantic(value: unknown): boolean {
|
|
44
|
+
if (typeof value !== "string" || value.trim() === "") return false;
|
|
45
|
+
const cleanPath = value.split(/[?#]/, 1)[0].toLowerCase();
|
|
46
|
+
const dotIndex = cleanPath.lastIndexOf(".");
|
|
47
|
+
if (dotIndex < 0) return false;
|
|
48
|
+
return NON_SEMANTIC_FILE_EXTENSIONS.has(cleanPath.slice(dotIndex));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function commandLooksLikeSemanticCodeSearch(command: string): boolean {
|
|
52
|
+
if (!/\b(rg|grep|fd|find)\b/.test(command)) return false;
|
|
53
|
+
if (/\b(SKILL\.md|README\.md|AGENTS\.md|package\.json|skill-registry\.json|skill-history\.jsonl)\b/i.test(command)) return false;
|
|
54
|
+
if (/\b(symbol|class|method|function|def|interface|references?|implementation|declaration|rename|refactor)\b/i.test(command)) return true;
|
|
55
|
+
return /\.(c|cc|cpp|cs|go|java|js|jsx|kt|lua|mjs|php|py|rb|rs|scala|sh|swift|ts|tsx|vue)\b/i.test(command);
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bacnh85/pi-serena",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Pi extension that provides Serena semantic code tools through a persistent worker.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"files": [
|
|
25
25
|
"README.md",
|
|
26
26
|
"index.ts",
|
|
27
|
-
"worker.ts"
|
|
27
|
+
"worker.ts",
|
|
28
|
+
"lib/"
|
|
28
29
|
],
|
|
29
30
|
"pi": {
|
|
30
31
|
"extensions": [
|