yzcode-cli 1.0.2 → 1.0.3
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/assistant/sessionHistory.ts +87 -0
- package/bootstrap/state.ts +1769 -0
- package/bridge/bridgeApi.ts +539 -0
- package/bridge/bridgeConfig.ts +48 -0
- package/bridge/bridgeDebug.ts +135 -0
- package/bridge/bridgeEnabled.ts +202 -0
- package/bridge/bridgeMain.ts +2999 -0
- package/bridge/bridgeMessaging.ts +461 -0
- package/bridge/bridgePermissionCallbacks.ts +43 -0
- package/bridge/bridgePointer.ts +210 -0
- package/bridge/bridgeStatusUtil.ts +163 -0
- package/bridge/bridgeUI.ts +530 -0
- package/bridge/capacityWake.ts +56 -0
- package/bridge/codeSessionApi.ts +168 -0
- package/bridge/createSession.ts +384 -0
- package/bridge/debugUtils.ts +141 -0
- package/bridge/envLessBridgeConfig.ts +165 -0
- package/bridge/flushGate.ts +71 -0
- package/bridge/inboundAttachments.ts +175 -0
- package/bridge/inboundMessages.ts +80 -0
- package/bridge/initReplBridge.ts +569 -0
- package/bridge/jwtUtils.ts +256 -0
- package/bridge/pollConfig.ts +110 -0
- package/bridge/pollConfigDefaults.ts +82 -0
- package/bridge/remoteBridgeCore.ts +1008 -0
- package/bridge/replBridge.ts +2406 -0
- package/bridge/replBridgeHandle.ts +36 -0
- package/bridge/replBridgeTransport.ts +370 -0
- package/bridge/sessionIdCompat.ts +57 -0
- package/bridge/sessionRunner.ts +550 -0
- package/bridge/trustedDevice.ts +210 -0
- package/bridge/types.ts +262 -0
- package/bridge/workSecret.ts +127 -0
- package/buddy/CompanionSprite.tsx +371 -0
- package/buddy/companion.ts +133 -0
- package/buddy/prompt.ts +36 -0
- package/buddy/sprites.ts +514 -0
- package/buddy/types.ts +148 -0
- package/buddy/useBuddyNotification.tsx +98 -0
- package/coordinator/coordinatorMode.ts +369 -0
- package/memdir/findRelevantMemories.ts +141 -0
- package/memdir/memdir.ts +507 -0
- package/memdir/memoryAge.ts +53 -0
- package/memdir/memoryScan.ts +94 -0
- package/memdir/memoryTypes.ts +271 -0
- package/memdir/paths.ts +278 -0
- package/memdir/teamMemPaths.ts +292 -0
- package/memdir/teamMemPrompts.ts +100 -0
- package/migrations/migrateAutoUpdatesToSettings.ts +61 -0
- package/migrations/migrateBypassPermissionsAcceptedToSettings.ts +40 -0
- package/migrations/migrateEnableAllProjectMcpServersToSettings.ts +118 -0
- package/migrations/migrateFennecToOpus.ts +45 -0
- package/migrations/migrateLegacyOpusToCurrent.ts +57 -0
- package/migrations/migrateOpusToOpus1m.ts +43 -0
- package/migrations/migrateReplBridgeEnabledToRemoteControlAtStartup.ts +22 -0
- package/migrations/migrateSonnet1mToSonnet45.ts +48 -0
- package/migrations/migrateSonnet45ToSonnet46.ts +67 -0
- package/migrations/resetAutoModeOptInForDefaultOffer.ts +51 -0
- package/migrations/resetProToOpusDefault.ts +51 -0
- package/native-ts/color-diff/index.ts +999 -0
- package/native-ts/file-index/index.ts +370 -0
- package/native-ts/yoga-layout/enums.ts +134 -0
- package/native-ts/yoga-layout/index.ts +2578 -0
- package/outputStyles/loadOutputStylesDir.ts +98 -0
- package/package.json +19 -2
- package/plugins/builtinPlugins.ts +159 -0
- package/plugins/bundled/index.ts +23 -0
- package/schemas/hooks.ts +222 -0
- package/screens/Doctor.tsx +575 -0
- package/screens/REPL.tsx +5006 -0
- package/screens/ResumeConversation.tsx +399 -0
- package/server/createDirectConnectSession.ts +88 -0
- package/server/directConnectManager.ts +213 -0
- package/server/types.ts +57 -0
- package/skills/bundled/batch.ts +124 -0
- package/skills/bundled/claudeApi.ts +196 -0
- package/skills/bundled/claudeApiContent.ts +75 -0
- package/skills/bundled/claudeInChrome.ts +34 -0
- package/skills/bundled/debug.ts +103 -0
- package/skills/bundled/index.ts +79 -0
- package/skills/bundled/keybindings.ts +339 -0
- package/skills/bundled/loop.ts +92 -0
- package/skills/bundled/loremIpsum.ts +282 -0
- package/skills/bundled/remember.ts +82 -0
- package/skills/bundled/scheduleRemoteAgents.ts +447 -0
- package/skills/bundled/simplify.ts +69 -0
- package/skills/bundled/skillify.ts +197 -0
- package/skills/bundled/stuck.ts +79 -0
- package/skills/bundled/updateConfig.ts +475 -0
- package/skills/bundled/verify/SKILL.md +3 -0
- package/skills/bundled/verify/examples/cli.md +3 -0
- package/skills/bundled/verify/examples/server.md +3 -0
- package/skills/bundled/verify.ts +30 -0
- package/skills/bundled/verifyContent.ts +13 -0
- package/skills/bundledSkills.ts +220 -0
- package/skills/loadSkillsDir.ts +1086 -0
- package/skills/mcpSkillBuilders.ts +44 -0
- package/tasks/DreamTask/DreamTask.ts +157 -0
- package/tasks/InProcessTeammateTask/InProcessTeammateTask.tsx +126 -0
- package/tasks/InProcessTeammateTask/types.ts +121 -0
- package/tasks/LocalAgentTask/LocalAgentTask.tsx +683 -0
- package/tasks/LocalMainSessionTask.ts +479 -0
- package/tasks/LocalShellTask/LocalShellTask.tsx +523 -0
- package/tasks/LocalShellTask/guards.ts +41 -0
- package/tasks/LocalShellTask/killShellTasks.ts +76 -0
- package/tasks/RemoteAgentTask/RemoteAgentTask.tsx +856 -0
- package/tasks/pillLabel.ts +82 -0
- package/tasks/stopTask.ts +100 -0
- package/tasks/types.ts +46 -0
- package/upstreamproxy/relay.ts +455 -0
- package/upstreamproxy/upstreamproxy.ts +285 -0
- package/vim/motions.ts +82 -0
- package/vim/operators.ts +556 -0
- package/vim/textObjects.ts +186 -0
- package/vim/transitions.ts +490 -0
- package/vim/types.ts +199 -0
- package/voice/voiceModeEnabled.ts +54 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure-TypeScript port of vendor/file-index-src (Rust NAPI module).
|
|
3
|
+
*
|
|
4
|
+
* The native module wraps nucleo (https://github.com/helix-editor/nucleo) for
|
|
5
|
+
* high-performance fuzzy file searching. This port reimplements the same API
|
|
6
|
+
* and scoring behavior without native dependencies.
|
|
7
|
+
*
|
|
8
|
+
* Key API:
|
|
9
|
+
* new FileIndex()
|
|
10
|
+
* .loadFromFileList(fileList: string[]): void — dedupe + index paths
|
|
11
|
+
* .search(query: string, limit: number): SearchResult[]
|
|
12
|
+
*
|
|
13
|
+
* Score semantics: lower = better. Score is position-in-results / result-count,
|
|
14
|
+
* so the best match is 0.0. Paths containing "test" get a 1.05× penalty (capped
|
|
15
|
+
* at 1.0) so non-test files rank slightly higher.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export type SearchResult = {
|
|
19
|
+
path: string
|
|
20
|
+
score: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// nucleo-style scoring constants (approximating fzf-v2 / nucleo bonuses)
|
|
24
|
+
const SCORE_MATCH = 16
|
|
25
|
+
const BONUS_BOUNDARY = 8
|
|
26
|
+
const BONUS_CAMEL = 6
|
|
27
|
+
const BONUS_CONSECUTIVE = 4
|
|
28
|
+
const BONUS_FIRST_CHAR = 8
|
|
29
|
+
const PENALTY_GAP_START = 3
|
|
30
|
+
const PENALTY_GAP_EXTENSION = 1
|
|
31
|
+
|
|
32
|
+
const TOP_LEVEL_CACHE_LIMIT = 100
|
|
33
|
+
const MAX_QUERY_LEN = 64
|
|
34
|
+
// Yield to event loop after this many ms of sync work. Chunk sizes are
|
|
35
|
+
// time-based (not count-based) so slow machines get smaller chunks and
|
|
36
|
+
// stay responsive — 5k paths is ~2ms on M-series but could be 15ms+ on
|
|
37
|
+
// older Windows hardware.
|
|
38
|
+
const CHUNK_MS = 4
|
|
39
|
+
|
|
40
|
+
// Reusable buffer: records where each needle char matched during the indexOf scan
|
|
41
|
+
const posBuf = new Int32Array(MAX_QUERY_LEN)
|
|
42
|
+
|
|
43
|
+
export class FileIndex {
|
|
44
|
+
private paths: string[] = []
|
|
45
|
+
private lowerPaths: string[] = []
|
|
46
|
+
private charBits: Int32Array = new Int32Array(0)
|
|
47
|
+
private pathLens: Uint16Array = new Uint16Array(0)
|
|
48
|
+
private topLevelCache: SearchResult[] | null = null
|
|
49
|
+
// During async build, tracks how many paths have bitmap/lowerPath filled.
|
|
50
|
+
// search() uses this to search the ready prefix while build continues.
|
|
51
|
+
private readyCount = 0
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Load paths from an array of strings.
|
|
55
|
+
* This is the main way to populate the index — ripgrep collects files, we just search them.
|
|
56
|
+
* Automatically deduplicates paths.
|
|
57
|
+
*/
|
|
58
|
+
loadFromFileList(fileList: string[]): void {
|
|
59
|
+
// Deduplicate and filter empty strings (matches Rust HashSet behavior)
|
|
60
|
+
const seen = new Set<string>()
|
|
61
|
+
const paths: string[] = []
|
|
62
|
+
for (const line of fileList) {
|
|
63
|
+
if (line.length > 0 && !seen.has(line)) {
|
|
64
|
+
seen.add(line)
|
|
65
|
+
paths.push(line)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
this.buildIndex(paths)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Async variant: yields to the event loop every ~8–12k paths so large
|
|
74
|
+
* indexes (270k+ files) don't block the main thread for >10ms at a time.
|
|
75
|
+
* Identical result to loadFromFileList.
|
|
76
|
+
*
|
|
77
|
+
* Returns { queryable, done }:
|
|
78
|
+
* - queryable: resolves as soon as the first chunk is indexed (search
|
|
79
|
+
* returns partial results). For a 270k-path list this is ~5–10ms of
|
|
80
|
+
* sync work after the paths array is available.
|
|
81
|
+
* - done: resolves when the entire index is built.
|
|
82
|
+
*/
|
|
83
|
+
loadFromFileListAsync(fileList: string[]): {
|
|
84
|
+
queryable: Promise<void>
|
|
85
|
+
done: Promise<void>
|
|
86
|
+
} {
|
|
87
|
+
let markQueryable: () => void = () => {}
|
|
88
|
+
const queryable = new Promise<void>(resolve => {
|
|
89
|
+
markQueryable = resolve
|
|
90
|
+
})
|
|
91
|
+
const done = this.buildAsync(fileList, markQueryable)
|
|
92
|
+
return { queryable, done }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private async buildAsync(
|
|
96
|
+
fileList: string[],
|
|
97
|
+
markQueryable: () => void,
|
|
98
|
+
): Promise<void> {
|
|
99
|
+
const seen = new Set<string>()
|
|
100
|
+
const paths: string[] = []
|
|
101
|
+
let chunkStart = performance.now()
|
|
102
|
+
for (let i = 0; i < fileList.length; i++) {
|
|
103
|
+
const line = fileList[i]!
|
|
104
|
+
if (line.length > 0 && !seen.has(line)) {
|
|
105
|
+
seen.add(line)
|
|
106
|
+
paths.push(line)
|
|
107
|
+
}
|
|
108
|
+
// Check every 256 iterations to amortize performance.now() overhead
|
|
109
|
+
if ((i & 0xff) === 0xff && performance.now() - chunkStart > CHUNK_MS) {
|
|
110
|
+
await yieldToEventLoop()
|
|
111
|
+
chunkStart = performance.now()
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
this.resetArrays(paths)
|
|
116
|
+
|
|
117
|
+
chunkStart = performance.now()
|
|
118
|
+
let firstChunk = true
|
|
119
|
+
for (let i = 0; i < paths.length; i++) {
|
|
120
|
+
this.indexPath(i)
|
|
121
|
+
if ((i & 0xff) === 0xff && performance.now() - chunkStart > CHUNK_MS) {
|
|
122
|
+
this.readyCount = i + 1
|
|
123
|
+
if (firstChunk) {
|
|
124
|
+
markQueryable()
|
|
125
|
+
firstChunk = false
|
|
126
|
+
}
|
|
127
|
+
await yieldToEventLoop()
|
|
128
|
+
chunkStart = performance.now()
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
this.readyCount = paths.length
|
|
132
|
+
markQueryable()
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private buildIndex(paths: string[]): void {
|
|
136
|
+
this.resetArrays(paths)
|
|
137
|
+
for (let i = 0; i < paths.length; i++) {
|
|
138
|
+
this.indexPath(i)
|
|
139
|
+
}
|
|
140
|
+
this.readyCount = paths.length
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private resetArrays(paths: string[]): void {
|
|
144
|
+
const n = paths.length
|
|
145
|
+
this.paths = paths
|
|
146
|
+
this.lowerPaths = new Array(n)
|
|
147
|
+
this.charBits = new Int32Array(n)
|
|
148
|
+
this.pathLens = new Uint16Array(n)
|
|
149
|
+
this.readyCount = 0
|
|
150
|
+
this.topLevelCache = computeTopLevelEntries(paths, TOP_LEVEL_CACHE_LIMIT)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Precompute: lowercase, a–z bitmap, length. Bitmap gives O(1) rejection
|
|
154
|
+
// of paths missing any needle letter (89% survival for broad queries like
|
|
155
|
+
// "test" → still a 10%+ free win; 90%+ rejection for rare chars).
|
|
156
|
+
private indexPath(i: number): void {
|
|
157
|
+
const lp = this.paths[i]!.toLowerCase()
|
|
158
|
+
this.lowerPaths[i] = lp
|
|
159
|
+
const len = lp.length
|
|
160
|
+
this.pathLens[i] = len
|
|
161
|
+
let bits = 0
|
|
162
|
+
for (let j = 0; j < len; j++) {
|
|
163
|
+
const c = lp.charCodeAt(j)
|
|
164
|
+
if (c >= 97 && c <= 122) bits |= 1 << (c - 97)
|
|
165
|
+
}
|
|
166
|
+
this.charBits[i] = bits
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Search for files matching the query using fuzzy matching.
|
|
171
|
+
* Returns top N results sorted by match score.
|
|
172
|
+
*/
|
|
173
|
+
search(query: string, limit: number): SearchResult[] {
|
|
174
|
+
if (limit <= 0) return []
|
|
175
|
+
if (query.length === 0) {
|
|
176
|
+
if (this.topLevelCache) {
|
|
177
|
+
return this.topLevelCache.slice(0, limit)
|
|
178
|
+
}
|
|
179
|
+
return []
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Smart case: lowercase query → case-insensitive; any uppercase → case-sensitive
|
|
183
|
+
const caseSensitive = query !== query.toLowerCase()
|
|
184
|
+
const needle = caseSensitive ? query : query.toLowerCase()
|
|
185
|
+
const nLen = Math.min(needle.length, MAX_QUERY_LEN)
|
|
186
|
+
const needleChars: string[] = new Array(nLen)
|
|
187
|
+
let needleBitmap = 0
|
|
188
|
+
for (let j = 0; j < nLen; j++) {
|
|
189
|
+
const ch = needle.charAt(j)
|
|
190
|
+
needleChars[j] = ch
|
|
191
|
+
const cc = ch.charCodeAt(0)
|
|
192
|
+
if (cc >= 97 && cc <= 122) needleBitmap |= 1 << (cc - 97)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Upper bound on score assuming every match gets the max boundary bonus.
|
|
196
|
+
// Used to reject paths whose gap penalties alone make them unable to beat
|
|
197
|
+
// the current top-k threshold, before the charCodeAt-heavy boundary pass.
|
|
198
|
+
const scoreCeiling =
|
|
199
|
+
nLen * (SCORE_MATCH + BONUS_BOUNDARY) + BONUS_FIRST_CHAR + 32
|
|
200
|
+
|
|
201
|
+
// Top-k: maintain a sorted-ascending array of the best `limit` matches.
|
|
202
|
+
// Avoids O(n log n) sort of all matches when we only need `limit` of them.
|
|
203
|
+
const topK: { path: string; fuzzScore: number }[] = []
|
|
204
|
+
let threshold = -Infinity
|
|
205
|
+
|
|
206
|
+
const { paths, lowerPaths, charBits, pathLens, readyCount } = this
|
|
207
|
+
|
|
208
|
+
outer: for (let i = 0; i < readyCount; i++) {
|
|
209
|
+
// O(1) bitmap reject: path must contain every letter in the needle
|
|
210
|
+
if ((charBits[i]! & needleBitmap) !== needleBitmap) continue
|
|
211
|
+
|
|
212
|
+
const haystack = caseSensitive ? paths[i]! : lowerPaths[i]!
|
|
213
|
+
|
|
214
|
+
// Fused indexOf scan: find positions (SIMD-accelerated in JSC/V8) AND
|
|
215
|
+
// accumulate gap/consecutive terms inline. The greedy-earliest positions
|
|
216
|
+
// found here are identical to what the charCodeAt scorer would find, so
|
|
217
|
+
// we score directly from them — no second scan.
|
|
218
|
+
let pos = haystack.indexOf(needleChars[0]!)
|
|
219
|
+
if (pos === -1) continue
|
|
220
|
+
posBuf[0] = pos
|
|
221
|
+
let gapPenalty = 0
|
|
222
|
+
let consecBonus = 0
|
|
223
|
+
let prev = pos
|
|
224
|
+
for (let j = 1; j < nLen; j++) {
|
|
225
|
+
pos = haystack.indexOf(needleChars[j]!, prev + 1)
|
|
226
|
+
if (pos === -1) continue outer
|
|
227
|
+
posBuf[j] = pos
|
|
228
|
+
const gap = pos - prev - 1
|
|
229
|
+
if (gap === 0) consecBonus += BONUS_CONSECUTIVE
|
|
230
|
+
else gapPenalty += PENALTY_GAP_START + gap * PENALTY_GAP_EXTENSION
|
|
231
|
+
prev = pos
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Gap-bound reject: if the best-case score (all boundary bonuses) minus
|
|
235
|
+
// known gap penalties can't beat threshold, skip the boundary pass.
|
|
236
|
+
if (
|
|
237
|
+
topK.length === limit &&
|
|
238
|
+
scoreCeiling + consecBonus - gapPenalty <= threshold
|
|
239
|
+
) {
|
|
240
|
+
continue
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Boundary/camelCase scoring: check the char before each match position.
|
|
244
|
+
const path = paths[i]!
|
|
245
|
+
const hLen = pathLens[i]!
|
|
246
|
+
let score = nLen * SCORE_MATCH + consecBonus - gapPenalty
|
|
247
|
+
score += scoreBonusAt(path, posBuf[0]!, true)
|
|
248
|
+
for (let j = 1; j < nLen; j++) {
|
|
249
|
+
score += scoreBonusAt(path, posBuf[j]!, false)
|
|
250
|
+
}
|
|
251
|
+
score += Math.max(0, 32 - (hLen >> 2))
|
|
252
|
+
|
|
253
|
+
if (topK.length < limit) {
|
|
254
|
+
topK.push({ path, fuzzScore: score })
|
|
255
|
+
if (topK.length === limit) {
|
|
256
|
+
topK.sort((a, b) => a.fuzzScore - b.fuzzScore)
|
|
257
|
+
threshold = topK[0]!.fuzzScore
|
|
258
|
+
}
|
|
259
|
+
} else if (score > threshold) {
|
|
260
|
+
let lo = 0
|
|
261
|
+
let hi = topK.length
|
|
262
|
+
while (lo < hi) {
|
|
263
|
+
const mid = (lo + hi) >> 1
|
|
264
|
+
if (topK[mid]!.fuzzScore < score) lo = mid + 1
|
|
265
|
+
else hi = mid
|
|
266
|
+
}
|
|
267
|
+
topK.splice(lo, 0, { path, fuzzScore: score })
|
|
268
|
+
topK.shift()
|
|
269
|
+
threshold = topK[0]!.fuzzScore
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// topK is ascending; reverse to descending (best first)
|
|
274
|
+
topK.sort((a, b) => b.fuzzScore - a.fuzzScore)
|
|
275
|
+
|
|
276
|
+
const matchCount = topK.length
|
|
277
|
+
const denom = Math.max(matchCount, 1)
|
|
278
|
+
const results: SearchResult[] = new Array(matchCount)
|
|
279
|
+
|
|
280
|
+
for (let i = 0; i < matchCount; i++) {
|
|
281
|
+
const path = topK[i]!.path
|
|
282
|
+
const positionScore = i / denom
|
|
283
|
+
const finalScore = path.includes('test')
|
|
284
|
+
? Math.min(positionScore * 1.05, 1.0)
|
|
285
|
+
: positionScore
|
|
286
|
+
results[i] = { path, score: finalScore }
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return results
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Boundary/camelCase bonus for a match at position `pos` in the original-case
|
|
295
|
+
* path. `first` enables the start-of-string bonus (only for needle[0]).
|
|
296
|
+
*/
|
|
297
|
+
function scoreBonusAt(path: string, pos: number, first: boolean): number {
|
|
298
|
+
if (pos === 0) return first ? BONUS_FIRST_CHAR : 0
|
|
299
|
+
const prevCh = path.charCodeAt(pos - 1)
|
|
300
|
+
if (isBoundary(prevCh)) return BONUS_BOUNDARY
|
|
301
|
+
if (isLower(prevCh) && isUpper(path.charCodeAt(pos))) return BONUS_CAMEL
|
|
302
|
+
return 0
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function isBoundary(code: number): boolean {
|
|
306
|
+
// / \ - _ . space
|
|
307
|
+
return (
|
|
308
|
+
code === 47 || // /
|
|
309
|
+
code === 92 || // \
|
|
310
|
+
code === 45 || // -
|
|
311
|
+
code === 95 || // _
|
|
312
|
+
code === 46 || // .
|
|
313
|
+
code === 32 // space
|
|
314
|
+
)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function isLower(code: number): boolean {
|
|
318
|
+
return code >= 97 && code <= 122
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function isUpper(code: number): boolean {
|
|
322
|
+
return code >= 65 && code <= 90
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export function yieldToEventLoop(): Promise<void> {
|
|
326
|
+
return new Promise(resolve => setImmediate(resolve))
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export { CHUNK_MS }
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Extract unique top-level path segments, sorted by (length asc, then alpha asc).
|
|
333
|
+
* Handles both Unix (/) and Windows (\) path separators.
|
|
334
|
+
* Mirrors FileIndex::compute_top_level_entries in lib.rs.
|
|
335
|
+
*/
|
|
336
|
+
function computeTopLevelEntries(
|
|
337
|
+
paths: string[],
|
|
338
|
+
limit: number,
|
|
339
|
+
): SearchResult[] {
|
|
340
|
+
const topLevel = new Set<string>()
|
|
341
|
+
|
|
342
|
+
for (const p of paths) {
|
|
343
|
+
// Split on first / or \ separator
|
|
344
|
+
let end = p.length
|
|
345
|
+
for (let i = 0; i < p.length; i++) {
|
|
346
|
+
const c = p.charCodeAt(i)
|
|
347
|
+
if (c === 47 || c === 92) {
|
|
348
|
+
end = i
|
|
349
|
+
break
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
const segment = p.slice(0, end)
|
|
353
|
+
if (segment.length > 0) {
|
|
354
|
+
topLevel.add(segment)
|
|
355
|
+
if (topLevel.size >= limit) break
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const sorted = Array.from(topLevel)
|
|
360
|
+
sorted.sort((a, b) => {
|
|
361
|
+
const lenDiff = a.length - b.length
|
|
362
|
+
if (lenDiff !== 0) return lenDiff
|
|
363
|
+
return a < b ? -1 : a > b ? 1 : 0
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
return sorted.slice(0, limit).map(path => ({ path, score: 0.0 }))
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export default FileIndex
|
|
370
|
+
export type { FileIndex as FileIndexType }
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Yoga enums — ported from yoga-layout/src/generated/YGEnums.ts
|
|
3
|
+
* Kept as `const` objects (not TS enums) per repo convention.
|
|
4
|
+
* Values match upstream exactly so callers don't change.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const Align = {
|
|
8
|
+
Auto: 0,
|
|
9
|
+
FlexStart: 1,
|
|
10
|
+
Center: 2,
|
|
11
|
+
FlexEnd: 3,
|
|
12
|
+
Stretch: 4,
|
|
13
|
+
Baseline: 5,
|
|
14
|
+
SpaceBetween: 6,
|
|
15
|
+
SpaceAround: 7,
|
|
16
|
+
SpaceEvenly: 8,
|
|
17
|
+
} as const
|
|
18
|
+
export type Align = (typeof Align)[keyof typeof Align]
|
|
19
|
+
|
|
20
|
+
export const BoxSizing = {
|
|
21
|
+
BorderBox: 0,
|
|
22
|
+
ContentBox: 1,
|
|
23
|
+
} as const
|
|
24
|
+
export type BoxSizing = (typeof BoxSizing)[keyof typeof BoxSizing]
|
|
25
|
+
|
|
26
|
+
export const Dimension = {
|
|
27
|
+
Width: 0,
|
|
28
|
+
Height: 1,
|
|
29
|
+
} as const
|
|
30
|
+
export type Dimension = (typeof Dimension)[keyof typeof Dimension]
|
|
31
|
+
|
|
32
|
+
export const Direction = {
|
|
33
|
+
Inherit: 0,
|
|
34
|
+
LTR: 1,
|
|
35
|
+
RTL: 2,
|
|
36
|
+
} as const
|
|
37
|
+
export type Direction = (typeof Direction)[keyof typeof Direction]
|
|
38
|
+
|
|
39
|
+
export const Display = {
|
|
40
|
+
Flex: 0,
|
|
41
|
+
None: 1,
|
|
42
|
+
Contents: 2,
|
|
43
|
+
} as const
|
|
44
|
+
export type Display = (typeof Display)[keyof typeof Display]
|
|
45
|
+
|
|
46
|
+
export const Edge = {
|
|
47
|
+
Left: 0,
|
|
48
|
+
Top: 1,
|
|
49
|
+
Right: 2,
|
|
50
|
+
Bottom: 3,
|
|
51
|
+
Start: 4,
|
|
52
|
+
End: 5,
|
|
53
|
+
Horizontal: 6,
|
|
54
|
+
Vertical: 7,
|
|
55
|
+
All: 8,
|
|
56
|
+
} as const
|
|
57
|
+
export type Edge = (typeof Edge)[keyof typeof Edge]
|
|
58
|
+
|
|
59
|
+
export const Errata = {
|
|
60
|
+
None: 0,
|
|
61
|
+
StretchFlexBasis: 1,
|
|
62
|
+
AbsolutePositionWithoutInsetsExcludesPadding: 2,
|
|
63
|
+
AbsolutePercentAgainstInnerSize: 4,
|
|
64
|
+
All: 2147483647,
|
|
65
|
+
Classic: 2147483646,
|
|
66
|
+
} as const
|
|
67
|
+
export type Errata = (typeof Errata)[keyof typeof Errata]
|
|
68
|
+
|
|
69
|
+
export const ExperimentalFeature = {
|
|
70
|
+
WebFlexBasis: 0,
|
|
71
|
+
} as const
|
|
72
|
+
export type ExperimentalFeature =
|
|
73
|
+
(typeof ExperimentalFeature)[keyof typeof ExperimentalFeature]
|
|
74
|
+
|
|
75
|
+
export const FlexDirection = {
|
|
76
|
+
Column: 0,
|
|
77
|
+
ColumnReverse: 1,
|
|
78
|
+
Row: 2,
|
|
79
|
+
RowReverse: 3,
|
|
80
|
+
} as const
|
|
81
|
+
export type FlexDirection = (typeof FlexDirection)[keyof typeof FlexDirection]
|
|
82
|
+
|
|
83
|
+
export const Gutter = {
|
|
84
|
+
Column: 0,
|
|
85
|
+
Row: 1,
|
|
86
|
+
All: 2,
|
|
87
|
+
} as const
|
|
88
|
+
export type Gutter = (typeof Gutter)[keyof typeof Gutter]
|
|
89
|
+
|
|
90
|
+
export const Justify = {
|
|
91
|
+
FlexStart: 0,
|
|
92
|
+
Center: 1,
|
|
93
|
+
FlexEnd: 2,
|
|
94
|
+
SpaceBetween: 3,
|
|
95
|
+
SpaceAround: 4,
|
|
96
|
+
SpaceEvenly: 5,
|
|
97
|
+
} as const
|
|
98
|
+
export type Justify = (typeof Justify)[keyof typeof Justify]
|
|
99
|
+
|
|
100
|
+
export const MeasureMode = {
|
|
101
|
+
Undefined: 0,
|
|
102
|
+
Exactly: 1,
|
|
103
|
+
AtMost: 2,
|
|
104
|
+
} as const
|
|
105
|
+
export type MeasureMode = (typeof MeasureMode)[keyof typeof MeasureMode]
|
|
106
|
+
|
|
107
|
+
export const Overflow = {
|
|
108
|
+
Visible: 0,
|
|
109
|
+
Hidden: 1,
|
|
110
|
+
Scroll: 2,
|
|
111
|
+
} as const
|
|
112
|
+
export type Overflow = (typeof Overflow)[keyof typeof Overflow]
|
|
113
|
+
|
|
114
|
+
export const PositionType = {
|
|
115
|
+
Static: 0,
|
|
116
|
+
Relative: 1,
|
|
117
|
+
Absolute: 2,
|
|
118
|
+
} as const
|
|
119
|
+
export type PositionType = (typeof PositionType)[keyof typeof PositionType]
|
|
120
|
+
|
|
121
|
+
export const Unit = {
|
|
122
|
+
Undefined: 0,
|
|
123
|
+
Point: 1,
|
|
124
|
+
Percent: 2,
|
|
125
|
+
Auto: 3,
|
|
126
|
+
} as const
|
|
127
|
+
export type Unit = (typeof Unit)[keyof typeof Unit]
|
|
128
|
+
|
|
129
|
+
export const Wrap = {
|
|
130
|
+
NoWrap: 0,
|
|
131
|
+
Wrap: 1,
|
|
132
|
+
WrapReverse: 2,
|
|
133
|
+
} as const
|
|
134
|
+
export type Wrap = (typeof Wrap)[keyof typeof Wrap]
|