@teammates/recall 0.1.0 → 0.1.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/README.md +12 -0
- package/dist/cli.js +19 -19
- package/dist/embeddings.js +4 -1
- package/dist/indexer.d.ts +3 -2
- package/dist/indexer.js +7 -6
- package/dist/search.js +3 -13
- package/package.json +34 -34
- package/src/cli.ts +275 -275
- package/src/embeddings.ts +46 -43
- package/src/index.ts +3 -3
- package/src/indexer.ts +204 -203
- package/src/search.ts +99 -107
- package/tsconfig.json +18 -18
package/src/indexer.ts
CHANGED
|
@@ -1,203 +1,204 @@
|
|
|
1
|
-
import { LocalDocumentIndex } from "vectra";
|
|
2
|
-
import { LocalEmbeddings } from "./embeddings.js";
|
|
3
|
-
import * as fs from "node:fs/promises";
|
|
4
|
-
import * as path from "node:path";
|
|
5
|
-
|
|
6
|
-
export interface IndexerConfig {
|
|
7
|
-
/** Path to the .teammates directory */
|
|
8
|
-
teammatesDir: string;
|
|
9
|
-
/** Embedding model name (default: Xenova/all-MiniLM-L6-v2) */
|
|
10
|
-
model?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface TeammateFiles {
|
|
14
|
-
teammate: string;
|
|
15
|
-
files: { uri: string; absolutePath: string }[];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Indexes teammate memory files (MEMORIES.md + memory/*.md) into Vectra.
|
|
20
|
-
* One index per teammate, stored at .teammates
|
|
21
|
-
*/
|
|
22
|
-
export class Indexer {
|
|
23
|
-
private _config: IndexerConfig;
|
|
24
|
-
private _embeddings: LocalEmbeddings;
|
|
25
|
-
|
|
26
|
-
constructor(config: IndexerConfig) {
|
|
27
|
-
this._config = config;
|
|
28
|
-
this._embeddings = new LocalEmbeddings(config.model);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
*
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
*
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
1
|
+
import { LocalDocumentIndex } from "vectra";
|
|
2
|
+
import { LocalEmbeddings } from "./embeddings.js";
|
|
3
|
+
import * as fs from "node:fs/promises";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
|
|
6
|
+
export interface IndexerConfig {
|
|
7
|
+
/** Path to the .teammates directory */
|
|
8
|
+
teammatesDir: string;
|
|
9
|
+
/** Embedding model name (default: Xenova/all-MiniLM-L6-v2) */
|
|
10
|
+
model?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface TeammateFiles {
|
|
14
|
+
teammate: string;
|
|
15
|
+
files: { uri: string; absolutePath: string }[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Indexes teammate memory files (MEMORIES.md + memory/*.md) into Vectra.
|
|
20
|
+
* One index per teammate, stored at .teammates/<name>/.index/
|
|
21
|
+
*/
|
|
22
|
+
export class Indexer {
|
|
23
|
+
private _config: IndexerConfig;
|
|
24
|
+
private _embeddings: LocalEmbeddings;
|
|
25
|
+
|
|
26
|
+
constructor(config: IndexerConfig) {
|
|
27
|
+
this._config = config;
|
|
28
|
+
this._embeddings = new LocalEmbeddings(config.model);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Get the index path for a specific teammate */
|
|
32
|
+
indexPath(teammate: string): string {
|
|
33
|
+
return path.join(this._config.teammatesDir, teammate, ".index");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Discover all teammate directories (folders containing SOUL.md).
|
|
38
|
+
*/
|
|
39
|
+
async discoverTeammates(): Promise<string[]> {
|
|
40
|
+
const entries = await fs.readdir(this._config.teammatesDir, {
|
|
41
|
+
withFileTypes: true,
|
|
42
|
+
});
|
|
43
|
+
const teammates: string[] = [];
|
|
44
|
+
for (const entry of entries) {
|
|
45
|
+
if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
|
|
46
|
+
const soulPath = path.join(
|
|
47
|
+
this._config.teammatesDir,
|
|
48
|
+
entry.name,
|
|
49
|
+
"SOUL.md"
|
|
50
|
+
);
|
|
51
|
+
try {
|
|
52
|
+
await fs.access(soulPath);
|
|
53
|
+
teammates.push(entry.name);
|
|
54
|
+
} catch {
|
|
55
|
+
// Not a teammate folder
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return teammates;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Collect all indexable memory files for a teammate.
|
|
63
|
+
*/
|
|
64
|
+
async collectFiles(teammate: string): Promise<TeammateFiles> {
|
|
65
|
+
const teammateDir = path.join(this._config.teammatesDir, teammate);
|
|
66
|
+
const files: TeammateFiles["files"] = [];
|
|
67
|
+
|
|
68
|
+
// MEMORIES.md
|
|
69
|
+
const memoriesPath = path.join(teammateDir, "MEMORIES.md");
|
|
70
|
+
try {
|
|
71
|
+
await fs.access(memoriesPath);
|
|
72
|
+
files.push({ uri: `${teammate}/MEMORIES.md`, absolutePath: memoriesPath });
|
|
73
|
+
} catch {
|
|
74
|
+
// No MEMORIES.md
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// memory/*.md (daily logs)
|
|
78
|
+
const memoryDir = path.join(teammateDir, "memory");
|
|
79
|
+
try {
|
|
80
|
+
const memoryEntries = await fs.readdir(memoryDir);
|
|
81
|
+
for (const entry of memoryEntries) {
|
|
82
|
+
if (!entry.endsWith(".md")) continue;
|
|
83
|
+
files.push({
|
|
84
|
+
uri: `${teammate}/memory/${entry}`,
|
|
85
|
+
absolutePath: path.join(memoryDir, entry),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
} catch {
|
|
89
|
+
// No memory/ directory
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return { teammate, files };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Build or rebuild the index for a single teammate.
|
|
97
|
+
*/
|
|
98
|
+
async indexTeammate(teammate: string): Promise<number> {
|
|
99
|
+
const { files } = await this.collectFiles(teammate);
|
|
100
|
+
if (files.length === 0) return 0;
|
|
101
|
+
|
|
102
|
+
const indexPath = this.indexPath(teammate);
|
|
103
|
+
const index = new LocalDocumentIndex({
|
|
104
|
+
folderPath: indexPath,
|
|
105
|
+
embeddings: this._embeddings,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Recreate index from scratch
|
|
109
|
+
await index.createIndex({ version: 1, deleteIfExists: true });
|
|
110
|
+
|
|
111
|
+
let count = 0;
|
|
112
|
+
for (const file of files) {
|
|
113
|
+
const text = await fs.readFile(file.absolutePath, "utf-8");
|
|
114
|
+
if (text.trim().length === 0) continue;
|
|
115
|
+
await index.upsertDocument(file.uri, text, "md");
|
|
116
|
+
count++;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return count;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Build or rebuild indexes for all teammates.
|
|
124
|
+
*/
|
|
125
|
+
async indexAll(): Promise<Map<string, number>> {
|
|
126
|
+
const teammates = await this.discoverTeammates();
|
|
127
|
+
const results = new Map<string, number>();
|
|
128
|
+
for (const teammate of teammates) {
|
|
129
|
+
const count = await this.indexTeammate(teammate);
|
|
130
|
+
results.set(teammate, count);
|
|
131
|
+
}
|
|
132
|
+
return results;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Upsert a single file into an existing teammate index.
|
|
137
|
+
* Creates the index if it doesn't exist yet.
|
|
138
|
+
*/
|
|
139
|
+
async upsertFile(teammate: string, filePath: string): Promise<void> {
|
|
140
|
+
const teammateDir = path.join(this._config.teammatesDir, teammate);
|
|
141
|
+
const absolutePath = path.resolve(filePath);
|
|
142
|
+
const relativePath = path.relative(teammateDir, absolutePath);
|
|
143
|
+
const uri = `${teammate}/${relativePath.replace(/\\/g, "/")}`;
|
|
144
|
+
|
|
145
|
+
const text = await fs.readFile(absolutePath, "utf-8");
|
|
146
|
+
if (text.trim().length === 0) return;
|
|
147
|
+
|
|
148
|
+
const indexPath = this.indexPath(teammate);
|
|
149
|
+
const index = new LocalDocumentIndex({
|
|
150
|
+
folderPath: indexPath,
|
|
151
|
+
embeddings: this._embeddings,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
if (!(await index.isIndexCreated())) {
|
|
155
|
+
await index.createIndex({ version: 1 });
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
await index.upsertDocument(uri, text, "md");
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Sync a teammate's index with their current memory files.
|
|
163
|
+
* Upserts new/changed files without a full rebuild.
|
|
164
|
+
*/
|
|
165
|
+
async syncTeammate(teammate: string): Promise<number> {
|
|
166
|
+
const { files } = await this.collectFiles(teammate);
|
|
167
|
+
if (files.length === 0) return 0;
|
|
168
|
+
|
|
169
|
+
const indexPath = this.indexPath(teammate);
|
|
170
|
+
const index = new LocalDocumentIndex({
|
|
171
|
+
folderPath: indexPath,
|
|
172
|
+
embeddings: this._embeddings,
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
if (!(await index.isIndexCreated())) {
|
|
176
|
+
// No index yet — do a full build
|
|
177
|
+
return this.indexTeammate(teammate);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Upsert all files (Vectra handles dedup internally via URI)
|
|
181
|
+
let count = 0;
|
|
182
|
+
for (const file of files) {
|
|
183
|
+
const text = await fs.readFile(file.absolutePath, "utf-8");
|
|
184
|
+
if (text.trim().length === 0) continue;
|
|
185
|
+
await index.upsertDocument(file.uri, text, "md");
|
|
186
|
+
count++;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return count;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Sync indexes for all teammates.
|
|
194
|
+
*/
|
|
195
|
+
async syncAll(): Promise<Map<string, number>> {
|
|
196
|
+
const teammates = await this.discoverTeammates();
|
|
197
|
+
const results = new Map<string, number>();
|
|
198
|
+
for (const teammate of teammates) {
|
|
199
|
+
const count = await this.syncTeammate(teammate);
|
|
200
|
+
results.set(teammate, count);
|
|
201
|
+
}
|
|
202
|
+
return results;
|
|
203
|
+
}
|
|
204
|
+
}
|
package/src/search.ts
CHANGED
|
@@ -1,107 +1,99 @@
|
|
|
1
|
-
import { LocalDocumentIndex } from "vectra";
|
|
2
|
-
import { LocalEmbeddings } from "./embeddings.js";
|
|
3
|
-
import { Indexer } from "./indexer.js";
|
|
4
|
-
import * as path from "node:path";
|
|
5
|
-
import * as fs from "node:fs/promises";
|
|
6
|
-
|
|
7
|
-
export interface SearchOptions {
|
|
8
|
-
/** Path to the .teammates directory */
|
|
9
|
-
teammatesDir: string;
|
|
10
|
-
/** Teammate name to search (searches all if omitted) */
|
|
11
|
-
teammate?: string;
|
|
12
|
-
/** Max results per teammate (default: 5) */
|
|
13
|
-
maxResults?: number;
|
|
14
|
-
/** Max chunks per document (default: 3) */
|
|
15
|
-
maxChunks?: number;
|
|
16
|
-
/** Max tokens per section (default: 500) */
|
|
17
|
-
maxTokens?: number;
|
|
18
|
-
/** Embedding model name */
|
|
19
|
-
model?: string;
|
|
20
|
-
/** Skip auto-sync before searching (default: false) */
|
|
21
|
-
skipSync?: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface SearchResult {
|
|
25
|
-
teammate: string;
|
|
26
|
-
uri: string;
|
|
27
|
-
text: string;
|
|
28
|
-
score: number;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Search teammate memories using semantic + keyword search.
|
|
33
|
-
*/
|
|
34
|
-
export async function search(
|
|
35
|
-
query: string,
|
|
36
|
-
options: SearchOptions
|
|
37
|
-
): Promise<SearchResult[]> {
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const maxResults = options.maxResults ?? 5;
|
|
41
|
-
const maxChunks = options.maxChunks ?? 3;
|
|
42
|
-
const maxTokens = options.maxTokens ?? 500;
|
|
43
|
-
|
|
44
|
-
// Auto-sync: upsert any new/changed files before searching
|
|
45
|
-
if (!options.skipSync) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Sort by score descending, return top results
|
|
105
|
-
allResults.sort((a, b) => b.score - a.score);
|
|
106
|
-
return allResults.slice(0, maxResults);
|
|
107
|
-
}
|
|
1
|
+
import { LocalDocumentIndex } from "vectra";
|
|
2
|
+
import { LocalEmbeddings } from "./embeddings.js";
|
|
3
|
+
import { Indexer } from "./indexer.js";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
import * as fs from "node:fs/promises";
|
|
6
|
+
|
|
7
|
+
export interface SearchOptions {
|
|
8
|
+
/** Path to the .teammates directory */
|
|
9
|
+
teammatesDir: string;
|
|
10
|
+
/** Teammate name to search (searches all if omitted) */
|
|
11
|
+
teammate?: string;
|
|
12
|
+
/** Max results per teammate (default: 5) */
|
|
13
|
+
maxResults?: number;
|
|
14
|
+
/** Max chunks per document (default: 3) */
|
|
15
|
+
maxChunks?: number;
|
|
16
|
+
/** Max tokens per section (default: 500) */
|
|
17
|
+
maxTokens?: number;
|
|
18
|
+
/** Embedding model name */
|
|
19
|
+
model?: string;
|
|
20
|
+
/** Skip auto-sync before searching (default: false) */
|
|
21
|
+
skipSync?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface SearchResult {
|
|
25
|
+
teammate: string;
|
|
26
|
+
uri: string;
|
|
27
|
+
text: string;
|
|
28
|
+
score: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Search teammate memories using semantic + keyword search.
|
|
33
|
+
*/
|
|
34
|
+
export async function search(
|
|
35
|
+
query: string,
|
|
36
|
+
options: SearchOptions
|
|
37
|
+
): Promise<SearchResult[]> {
|
|
38
|
+
const embeddings = new LocalEmbeddings(options.model);
|
|
39
|
+
const indexer = new Indexer({ teammatesDir: options.teammatesDir, model: options.model });
|
|
40
|
+
const maxResults = options.maxResults ?? 5;
|
|
41
|
+
const maxChunks = options.maxChunks ?? 3;
|
|
42
|
+
const maxTokens = options.maxTokens ?? 500;
|
|
43
|
+
|
|
44
|
+
// Auto-sync: upsert any new/changed files before searching
|
|
45
|
+
if (!options.skipSync) {
|
|
46
|
+
if (options.teammate) {
|
|
47
|
+
await indexer.syncTeammate(options.teammate);
|
|
48
|
+
} else {
|
|
49
|
+
await indexer.syncAll();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Determine which teammates to search
|
|
54
|
+
let teammates: string[];
|
|
55
|
+
if (options.teammate) {
|
|
56
|
+
teammates = [options.teammate];
|
|
57
|
+
} else {
|
|
58
|
+
teammates = await indexer.discoverTeammates();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const allResults: SearchResult[] = [];
|
|
62
|
+
|
|
63
|
+
for (const teammate of teammates) {
|
|
64
|
+
const indexPath = indexer.indexPath(teammate);
|
|
65
|
+
try {
|
|
66
|
+
await fs.access(indexPath);
|
|
67
|
+
} catch {
|
|
68
|
+
continue; // No index for this teammate
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const index = new LocalDocumentIndex({
|
|
72
|
+
folderPath: indexPath,
|
|
73
|
+
embeddings,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
if (!(await index.isIndexCreated())) continue;
|
|
77
|
+
|
|
78
|
+
const docs = await index.queryDocuments(query, {
|
|
79
|
+
maxDocuments: maxResults,
|
|
80
|
+
maxChunks,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
for (const doc of docs) {
|
|
84
|
+
const sections = await doc.renderSections(maxTokens, 1);
|
|
85
|
+
for (const section of sections) {
|
|
86
|
+
allResults.push({
|
|
87
|
+
teammate,
|
|
88
|
+
uri: doc.uri,
|
|
89
|
+
text: section.text,
|
|
90
|
+
score: section.score,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Sort by score descending, return top results
|
|
97
|
+
allResults.sort((a, b) => b.score - a.score);
|
|
98
|
+
return allResults.slice(0, maxResults);
|
|
99
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "Node16",
|
|
5
|
-
"moduleResolution": "Node16",
|
|
6
|
-
"lib": ["ES2022"],
|
|
7
|
-
"outDir": "dist",
|
|
8
|
-
"rootDir": "src",
|
|
9
|
-
"strict": true,
|
|
10
|
-
"declaration": true,
|
|
11
|
-
"esModuleInterop": true,
|
|
12
|
-
"skipLibCheck": true,
|
|
13
|
-
"forceConsistentCasingInFileNames": true,
|
|
14
|
-
"resolveJsonModule": true
|
|
15
|
-
},
|
|
16
|
-
"include": ["src"],
|
|
17
|
-
"exclude": ["node_modules", "dist"]
|
|
18
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "Node16",
|
|
5
|
+
"moduleResolution": "Node16",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"rootDir": "src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
|
+
"resolveJsonModule": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["src"],
|
|
17
|
+
"exclude": ["node_modules", "dist"]
|
|
18
|
+
}
|