@dreki-gg/pi-doc-search 0.2.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/.github/workflows/release.yml +46 -0
- package/.release-please-manifest.json +3 -0
- package/CHANGELOG.md +82 -0
- package/LICENSE +21 -0
- package/README.md +50 -0
- package/bun.lock +382 -0
- package/extensions/doc-search/README.md +50 -0
- package/extensions/doc-search/api.ts +143 -0
- package/extensions/doc-search/cache.ts +415 -0
- package/extensions/doc-search/config.example.json +7 -0
- package/extensions/doc-search/config.ts +52 -0
- package/extensions/doc-search/curation.ts +192 -0
- package/extensions/doc-search/index.ts +6 -0
- package/extensions/doc-search/tools.ts +615 -0
- package/extensions/doc-search/types.ts +142 -0
- package/package.json +50 -0
- package/release-please-config.json +9 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
export interface DocSearchConfigFile {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
cache?: {
|
|
4
|
+
resolveTtlHours?: number;
|
|
5
|
+
docsTtlHours?: number;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface DocSearchSettings {
|
|
10
|
+
extensionDir: string;
|
|
11
|
+
configPath: string;
|
|
12
|
+
cacheDir: string;
|
|
13
|
+
apiKey?: string;
|
|
14
|
+
resolveTtlMs: number;
|
|
15
|
+
docsTtlMs: number;
|
|
16
|
+
configError?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface SearchResult {
|
|
20
|
+
id: string;
|
|
21
|
+
title: string;
|
|
22
|
+
description: string;
|
|
23
|
+
totalSnippets?: number;
|
|
24
|
+
trustScore?: number;
|
|
25
|
+
benchmarkScore?: number;
|
|
26
|
+
versions?: string[];
|
|
27
|
+
source?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface SearchResponse {
|
|
31
|
+
results: SearchResult[];
|
|
32
|
+
searchFilterApplied?: boolean;
|
|
33
|
+
error?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface Context7ApiError {
|
|
37
|
+
kind: 'auth' | 'rate_limit' | 'not_found' | 'network' | 'invalid_response' | 'unknown';
|
|
38
|
+
status?: number;
|
|
39
|
+
message: string;
|
|
40
|
+
upstreamMessage?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type Context7ApiResult<T> = { ok: true; data: T } | { ok: false; error: Context7ApiError };
|
|
44
|
+
|
|
45
|
+
export interface ResolveCacheEntry {
|
|
46
|
+
kind: 'resolve';
|
|
47
|
+
cacheKey: string;
|
|
48
|
+
objectKey: string;
|
|
49
|
+
libraryName: string;
|
|
50
|
+
normalizedLibraryName: string;
|
|
51
|
+
query: string;
|
|
52
|
+
createdAt: string;
|
|
53
|
+
expiresAt: string;
|
|
54
|
+
results: SearchResult[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface ResolveCacheIndexEntry {
|
|
58
|
+
kind: 'resolve';
|
|
59
|
+
cacheKey: string;
|
|
60
|
+
objectKey: string;
|
|
61
|
+
libraryName: string;
|
|
62
|
+
normalizedLibraryName: string;
|
|
63
|
+
query: string;
|
|
64
|
+
createdAt: string;
|
|
65
|
+
expiresAt: string;
|
|
66
|
+
resultCount: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface DocCacheEntry {
|
|
70
|
+
kind: 'docs';
|
|
71
|
+
docRef: string;
|
|
72
|
+
objectKey: string;
|
|
73
|
+
libraryId: string;
|
|
74
|
+
libraryName: string;
|
|
75
|
+
normalizedLibraryName: string;
|
|
76
|
+
libraryVersion?: string;
|
|
77
|
+
libraryVersionRaw?: string;
|
|
78
|
+
query: string;
|
|
79
|
+
topic?: string;
|
|
80
|
+
effectiveQuery: string;
|
|
81
|
+
page: number;
|
|
82
|
+
createdAt: string;
|
|
83
|
+
expiresAt: string;
|
|
84
|
+
rawText: string;
|
|
85
|
+
curatedText: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface DocCacheIndexEntry {
|
|
89
|
+
kind: 'docs';
|
|
90
|
+
docRef: string;
|
|
91
|
+
objectKey: string;
|
|
92
|
+
libraryId: string;
|
|
93
|
+
libraryName: string;
|
|
94
|
+
normalizedLibraryName: string;
|
|
95
|
+
libraryVersion?: string;
|
|
96
|
+
libraryVersionRaw?: string;
|
|
97
|
+
query: string;
|
|
98
|
+
topic?: string;
|
|
99
|
+
effectiveQuery: string;
|
|
100
|
+
page: number;
|
|
101
|
+
createdAt: string;
|
|
102
|
+
expiresAt: string;
|
|
103
|
+
rawLength: number;
|
|
104
|
+
curatedLength: number;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface CacheLookup<T> {
|
|
108
|
+
entry?: T;
|
|
109
|
+
fresh: boolean;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface CacheSearchSelector {
|
|
113
|
+
docRef?: string;
|
|
114
|
+
libraryId?: string;
|
|
115
|
+
libraryName?: string;
|
|
116
|
+
libraryVersion?: string;
|
|
117
|
+
query?: string;
|
|
118
|
+
topic?: string;
|
|
119
|
+
page?: number;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface CuratedDocResult {
|
|
123
|
+
text: string;
|
|
124
|
+
truncated: boolean;
|
|
125
|
+
selectedSectionCount: number;
|
|
126
|
+
rawLength: number;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface ResolveLibraryParams {
|
|
130
|
+
libraryName: string;
|
|
131
|
+
query?: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface GetLibraryDocsParams {
|
|
135
|
+
libraryId?: string;
|
|
136
|
+
libraryName?: string;
|
|
137
|
+
query?: string;
|
|
138
|
+
topic?: string;
|
|
139
|
+
page?: number;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface GetCachedDocRawParams extends CacheSearchSelector {}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dreki-gg/pi-doc-search",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Library doc-search tools for pi, powered by Context7 \u2014 direct HTTP, persistent cache, no MCP dependency",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package",
|
|
7
|
+
"pi",
|
|
8
|
+
"docs",
|
|
9
|
+
"documentation",
|
|
10
|
+
"context7"
|
|
11
|
+
],
|
|
12
|
+
"author": "Juan Albarran <jalbarrandev@gmail.com>",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/jalbarrang/pi-doc-search.git"
|
|
17
|
+
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"scripts": {
|
|
20
|
+
"typecheck": "tsc --noEmit",
|
|
21
|
+
"lint": "oxlint extensions",
|
|
22
|
+
"format": "oxfmt --write extensions",
|
|
23
|
+
"format:check": "oxfmt --check extensions"
|
|
24
|
+
},
|
|
25
|
+
"pi": {
|
|
26
|
+
"extensions": [
|
|
27
|
+
"./extensions/doc-search"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "24",
|
|
32
|
+
"oxfmt": "^0.43.0",
|
|
33
|
+
"oxlint": "^1.58.0",
|
|
34
|
+
"typescript": "^6.0.0",
|
|
35
|
+
"@earendil-works/pi-coding-agent": "^0.75.4",
|
|
36
|
+
"typebox": "^1.0.55"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
40
|
+
"typebox": "*"
|
|
41
|
+
},
|
|
42
|
+
"peerDependenciesMeta": {
|
|
43
|
+
"@earendil-works/pi-coding-agent": {
|
|
44
|
+
"optional": true
|
|
45
|
+
},
|
|
46
|
+
"typebox": {
|
|
47
|
+
"optional": true
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"incremental": true,
|
|
13
|
+
"tsBuildInfoFile": "./node_modules/.cache/doc-search.tsbuildinfo",
|
|
14
|
+
"rootDir": "."
|
|
15
|
+
},
|
|
16
|
+
"include": ["extensions/**/*.ts"]
|
|
17
|
+
}
|