pi-ext bugabingas pi extensions
owned by bugabinga
README Source History Refs Reviews Compare Notes Search Review guide CI runs lint: remove non-null assertions
3e40400713f946a8db7655811568fc8d71383b25
Oliver Jan Krylow <oliver@bugabinga.net > · 6 Jun 2026
unsigned
Browse files Compare with HEAD
Changed files (26) Diff layout Auto Unified Split
extensions/ctx/__tests__/harness.test.ts Modified +4 / −3 text lines
50 50 it ("registers no tools and no commands" , () => { it ("registers no tools and no commands" , () => {51 - const [extension] = t! .session.extensionRunner.extensions;52 - expect ([... extension.tools.keys ()]).toEqual ([]);53 - expect ([... extension.commands.keys ()]).toEqual ([]);51 + const [extension] = t? .session.extensionRunner.extensions ?? [ ] ;52 + expect (extension).toBeDefined ();53 + expect ([... ( extension? .tools.keys () ?? [ ])] ) .toEqual ([]);54 + expect ([... ( extension? .commands.keys () ?? [ ])] ) .toEqual ([]);56 57 it ("compacts huge read output before it reaches the transcript" , async () => { it ("compacts huge read output before it reaches the transcript" , async () => {extensions/devil/index.ts Modified +2 / −1 text lines
967 967 ctx.ui?.notify (`No API key for ${model.provider}` , "error" ); ctx.ui?.notify (`No API key for ${model.provider}` , "error" );
970 + const apiKey = auth.apiKey;970 971 const defenderAuth = const defenderAuth = 971 972 await ctx.modelRegistry.getApiKeyAndHeaders (defenderModel); await ctx.modelRegistry.getApiKeyAndHeaders (defenderModel);972 973 if (! defenderAuth.ok || ! defenderAuth.apiKey) { if (! defenderAuth.ok || ! defenderAuth.apiKey) {1052 1053 defenderModel, defenderModel,1054 - apiKey : auth.apiKey! ,1055 1056 headers : auth.headers , headers : auth.headers ,1056 1057 devilThinkingLevel, devilThinkingLevel,1057 1058 defenderThinkingLevel, defenderThinkingLevel,extensions/diff-review/__e2e__/e2e.spec.ts Modified +3 / −1 text lines
221 221 expect (submittedResults.length ).toBe (prevSubmissions + 1 ); expect (submittedResults.length ).toBe (prevSubmissions + 1 );222 - const last = submittedResults[ submittedResults .length - 1 ] ! ;222 + const last = submittedResults.at ( - 1 ) ;223 + expect (last).toBeDefined ();224 + if (! last) throw new Error ("expected submitted result" );223 225 expect (last.type ).toBe ("submit" ); expect (last.type ).toBe ("submit" );224 226 expect (last.notes).toBe ("e2e notes" ); expect (last.notes).toBe ("e2e notes" );225 227 expect (last.findings.length ).toBeGreaterThanOrEqual (1 ); expect (last.findings.length ).toBeGreaterThanOrEqual (1 );extensions/diff-review/git.ts Modified +5 / −4 text lines
234 234 .map ((line) => { .map ((line) => {235 235 const quotedDiff = const quotedDiff = 236 236 / ^ diff --git ("(?:[ ^ "\\] | \\.) + ") ("(?:[ ^ "\\] | \\.) + ") $ / .exec (line); / ^ diff --git ("(?:[ ^ "\\] | \\.) + ") ("(?:[ ^ "\\] | \\.) + ") $ / .exec (line);238 - return `diff --git ${ gitPathToken (quotedDiff [ 1 ] ! )} ${ gitPathToken (quotedDiff [ 2 ] ! )}` ;237 + const [, oldPath, newPath] = quotedDiff ?? [];238 + if (oldPath && newPath)239 + return `diff --git ${ gitPathToken (oldPath )} ${ gitPathToken (newPath )}` ;239 240 const quotedHeader = / ^ (--- | \+\+\+) ("(?:[ ^ "\\] | \\.) + ") $ / .exec (line); const quotedHeader = / ^ (--- | \+\+\+) ("(?:[ ^ "\\] | \\.) + ") $ / .exec (line);241 - return `${quotedHeader[1]} ${ gitPathToken (quotedHeader[2] ! )}` ;241 + const [, marker, path] = quotedHeader ?? [];242 + if (marker && path) return `${marker} ${ gitPathToken (path)}` ;242 243 return line; return line;244 245 .join ("\n" ); .join ("\n" );extensions/footer/index.ts Modified +3 / −3 text lines
230 230 let line1Width = 0 ; let line1Width = 0 ;231 231 let overflowIndex = - 1 ; let overflowIndex = - 1 ;233 - for (let i = 0 ; i < rendered.length ; i++ ) {234 - const segWidth = visibleWidth (rendered [ i ] ! );233 + for (const [i, segment] of rendered.entries ()) {234 + const segWidth = visibleWidth (segment );235 235 const prefixWidth = line1Width > 0 ? visibleWidth (sep) : 0 ; const prefixWidth = line1Width > 0 ? visibleWidth (sep) : 0 ;237 237 if (line1Width + prefixWidth + segWidth <= width) { if (line1Width + prefixWidth + segWidth <= width) {238 - line1 += (line1Width > 0 ? sep : "" ) + rendered [ i ] ;238 + line1 += (line1Width > 0 ? sep : "" ) + segment ;239 239 line1Width += prefixWidth + segWidth; line1Width += prefixWidth + segWidth;241 241 overflowIndex = i; overflowIndex = i;extensions/git-safe/index.ts Modified +3 / −2 text lines
119 119 if (! content || ! Array .isArray (content)) return ; if (! content || ! Array .isArray (content)) return ;121 121 const allText = content const allText = content122 - . filter ( ( c ) => c.type === "text" && typeof c.text === "string" ) 123 - .map ((c) => c.text ! )123 + c.type === "text" && typeof c.text === "string" ? [ c . text ] : [ ] , 124 125 .join ("\n" ); .join ("\n" );126 127 if (! allText) return ; if (! allText) return ;extensions/goal/index.ts Modified +4 / −3 text lines
795 795 (_tui, theme) => ({ (_tui, theme) => ({796 796 invalidate () {}, invalidate () {},797 797 render (width: number ): string [] { render (width: number ): string [] {798 - const s = liveGoalState! ;798 + const state = liveGoalState;799 + if (! state) return [];799 800 const m = liveGoalMode; const m = liveGoalMode;800 - const tone = goalTone (s , m);801 - const lines = goalWidgetLines (s , m, width);801 + const tone = goalTone (state , m);802 + const lines = goalWidgetLines (state , m, width);802 803 return lines.map ((rawLine) => theme.fg (tone, rawLine)); return lines.map ((rawLine) => theme.fg (tone, rawLine));extensions/llmiterate/__tests__/core.test.ts Modified +5 / −3 text lines
29 29 const tempDirs: string [] = [];const tempDirs: string [] = [];31 31 afterEach (() => {afterEach (() => {32 - while (tempDirs.length )33 - rmSync (tempDirs . pop ( ) ! , { recursive: true , force: true });32 + for (const dir of tempDirs.splice (0 ))33 + rmSync (dir , { recursive: true , force: true });36 36 function tempDir (): string {function tempDir (): string {342 342 describe ("llmiterate output snapshots" , () => {describe ("llmiterate output snapshots" , () => {343 343 test ("agent prompt snapshot" , () => { test ("agent prompt snapshot" , () => {344 344 const [block] = parseMarkerPrompts ("a.rs" , "// llmiterate: implement foo" ); const [block] = parseMarkerPrompts ("a.rs" , "// llmiterate: implement foo" );345 - expect (buildAgentPrompt (block! )).toMatchSnapshot ();345 + expect (block).toBeDefined ();346 + if (! block) throw new Error ("expected llmiterate block" );347 + expect (buildAgentPrompt (block)).toMatchSnapshot ();extensions/llmiterate/__tests__/harness.ts Modified +2 / −2 text lines
19 19 export function cleanupHarness (): void {export function cleanupHarness (): void {20 20 process .env .XDG_STATE_HOME = oldXdg; process .env .XDG_STATE_HOME = oldXdg;21 - while (tempDirs.length )22 - rmSync (tempDirs . pop ( ) ! , { recursive: true , force: true });21 + for (const dir of tempDirs.splice (0 ))22 + rmSync (dir , { recursive: true , force: true });25 25 export class FakeWorker {export class FakeWorker {extensions/llmiterate/__tests__/lock.test.ts Modified +2 / −2 text lines
13 13 const tempDirs: string [] = [];const tempDirs: string [] = [];15 15 afterEach (() => {afterEach (() => {16 - while (tempDirs.length )17 - rmSync (tempDirs . pop ( ) ! , { recursive: true , force: true });16 + for (const dir of tempDirs.splice (0 ))17 + rmSync (dir , { recursive: true , force: true });20 20 function tempDir (): string {function tempDir (): string {extensions/llmiterate/__tests__/log.test.ts Modified +2 / −2 text lines
19 19 const tempDirs: string [] = [];const tempDirs: string [] = [];21 21 afterEach (() => {afterEach (() => {22 - while (tempDirs.length )23 - rmSync (tempDirs . pop ( ) ! , { recursive: true , force: true });22 + for (const dir of tempDirs.splice (0 ))23 + rmSync (dir , { recursive: true , force: true });26 26 describe ("editor command parsing" , () => {describe ("editor command parsing" , () => {extensions/llmiterate/__tests__/rpc.test.ts Modified +2 / −2 text lines
14 14 afterEach (() => {afterEach (() => {15 15 while (workers.length ) workers.pop ()?.dispose (); while (workers.length ) workers.pop ()?.dispose ();16 - while (tempDirs.length )17 - rmSync (tempDirs . pop ( ) ! , { recursive: true , force: true });16 + for (const dir of tempDirs.splice (0 ))17 + rmSync (dir , { recursive: true , force: true });20 20 describe ("PiRpcWorker args" , () => {describe ("PiRpcWorker args" , () => {extensions/llmiterate/__tests__/ui.test.ts Modified +2 / −1 text lines
88 88 "src/main.ts" , "src/main.ts" ,89 89 "// llmiterate: implement foo and bar" , "// llmiterate: implement foo and bar" ,
91 + if (! block) throw new Error ("expected llmiterate block" );94 95 projectFile: "src/main.ts" , projectFile: "src/main.ts" ,95 96 absoluteFile: "/tmp/project/src/main.ts" , absoluteFile: "/tmp/project/src/main.ts" ,96 97 fullPrompt: "prompt" , fullPrompt: "prompt" ,extensions/llmiterate/__tests__/watcher.test.ts Modified +2 / −2 text lines
17 17 afterEach (() => {afterEach (() => {18 18 while (watchers.length ) watchers.pop ()?.stop (); while (watchers.length ) watchers.pop ()?.stop ();19 - while (tempDirs.length )20 - rmSync (tempDirs . pop ( ) ! , { recursive: true , force: true });19 + for (const dir of tempDirs.splice (0 ))20 + rmSync (dir , { recursive: true , force: true });23 23 function tempDir (): string {function tempDir (): string {extensions/llmiterate/path-filter.ts Modified +5 / −2 text lines
181 181 } else if (patternIndex >= pattern.length ) { } else if (patternIndex >= pattern.length ) {182 182 result = false ; result = false ;184 - const segment = pattern[patternIndex]! ;184 + const segment = pattern[patternIndex];185 + const dirSegment = dir[dirIndex];186 187 segment === "**" segment === "**" 187 188 ? visit (patternIndex + 1 , dirIndex) || ? visit (patternIndex + 1 , dirIndex) || 188 189 visit (patternIndex, dirIndex + 1 ) visit (patternIndex, dirIndex + 1 )189 - : segment.test (dir[dirIndex]! ) && 192 + segment.test (dirSegment) && 190 193 visit (patternIndex + 1 , dirIndex + 1 ); visit (patternIndex + 1 , dirIndex + 1 );extensions/neko/__tests__/lifecycle.test.ts Modified +6 / −4 text lines
225 225 await h.emit ("session_before_compact" ); await h.emit ("session_before_compact" );226 226 const compactionTimer = timers.find ( const compactionTimer = timers.find (227 227 (timer) => timer.kind === "timeout" && timer.ms === 180_000 , (timer) => timer.kind === "timeout" && timer.ms === 180_000 ,229 + expect (compactionTimer).toBeDefined ();229 230 expect (stripAnsi (editor.render (40 )[0 ])).toContain ("[" ); expect (stripAnsi (editor.render (40 )[0 ])).toContain ("[" );231 - compactionTimer.fn ();232 + compactionTimer? .fn ();232 233 expect (stripAnsi (editor.render (40 )[0 ])).toContain ("(=^" ); expect (stripAnsi (editor.render (40 )[0 ])).toContain ("(=^" );239 240 await h.emit ("session_before_compact" ); await h.emit ("session_before_compact" );240 241 const first = timers.find ( const first = timers.find (241 242 (timer) => timer.kind === "timeout" && timer.ms === 180_000 , (timer) => timer.kind === "timeout" && timer.ms === 180_000 ,244 + expect (first).toBeDefined ();243 245 await h.emit ("session_before_compact" ); await h.emit ("session_before_compact" );244 246 const compactionTimers = timers.filter ( const compactionTimers = timers.filter (245 247 (timer) => timer.kind === "timeout" && timer.ms === 180_000 , (timer) => timer.kind === "timeout" && timer.ms === 180_000 ,248 250 expect (compactionTimers).toHaveLength (2 ); expect (compactionTimers).toHaveLength (2 );249 - expect (first.cleared).toBe (true );251 + expect (first? .cleared).toBe (true );250 252 expect (compactionTimers[1 ]?.cleared).toBe (false ); expect (compactionTimers[1 ]?.cleared).toBe (false );extensions/neko/index.ts Modified +3 / −1 text lines
289 289 const motion: Motion = const motion: Motion =290 290 Math .abs (this.targetNoseX - this.noseX) > MOVE_STEP ? "walking" : "idle" ; Math .abs (this.targetNoseX - this.noseX) > MOVE_STEP ? "walking" : "idle" ;291 291 const frames = this.framesFor (motion); const frames = this.framesFor (motion);292 - return frames[this.frame % frames.length ]! ;292 + const frame = frames[this.frame % frames.length ];293 + if (! frame) throw new Error (`missing neko sprite frame: ${motion}` );295 297 override setPaddingX (padding: number): void { override setPaddingX (padding: number): void {extensions/nu-bang/__tests__/real-world.test.ts Modified +4 / −3 text lines
413 413 expect (result.output).toContain ("truncated" ); expect (result.output).toContain ("truncated" );414 414 expect (result.output).toContain ("line-2500" ); expect (result.output).toContain ("line-2500" );415 415 expect (typeof result.fullOutputPath).toBe ("string" ); expect (typeof result.fullOutputPath).toBe ("string" );
416 + if (! result.fullOutputPath) throw new Error ("expected full output path" );418 - const fullOutputStat = await stat (result.fullOutputPath! );419 + const fullOutputStat = await stat (result.fullOutputPath);419 420 expect (fullOutputStat.mode & 0o777 ).toBe (0o600 ); expect (fullOutputStat.mode & 0o777 ).toBe (0o600 );420 - const fullOutput = await readFile (result.fullOutputPath! , "utf8" );421 + const fullOutput = await readFile (result.fullOutputPath, "utf8" );421 422 expect (fullOutput).toContain ("line-1" ); expect (fullOutput).toContain ("line-1" );422 423 expect (fullOutput).toContain ("line-2500" ); expect (fullOutput).toContain ("line-2500" );423 424 expect (fullOutput.length ).toBeGreaterThan (result.output.length ); expect (fullOutput.length ).toBeGreaterThan (result.output.length );424 425 } finally { } finally {425 - await rm (result.fullOutputPath! , { force: true });426 + await rm (result.fullOutputPath, { force: true });extensions/pulse/__tests__/harness.test.ts Modified +2 / −2 text lines
20 20 function pulseCommand () {function pulseCommand () {21 - const [extension] = t! .session.extensionRunner.extensions;22 - return extension.commands.get ("pulse" );21 + const [extension] = t? .session.extensionRunner.extensions ?? [ ] ;22 + return extension? .commands.get ("pulse" );25 25 function ctx (): any {function ctx (): any {extensions/session-rename/index.ts Modified +3 / −2 text lines
66 66 if (typeof content === "string" ) return content; if (typeof content === "string" ) return content;67 67 if (! Array .isArray (content)) return "" ; if (! Array .isArray (content)) return "" ;68 68 return (content as ContentBlock []) return (content as ContentBlock [])69 - . filter ( ( p ) => p?.type === "text" && typeof p.text === "string" ) 70 + p?.type === "text" && typeof p.text === "string" ? [ p . text ] : [ ] , 71 72 .join ("\n" ); .join ("\n" );extensions/ssh-tools/index.ts Modified +7 / −6 text lines
226 226 function makeHelpers (pi: ExtensionAPI ) {function makeHelpers (pi: ExtensionAPI ) {227 - function assertTarget (): asserts target is Target {227 + function assertTarget (): Target {228 228 if (! target) throw new Error ("SSH mode off. Use /ssh <host> first." ); if (! target) throw new Error ("SSH mode off. Use /ssh <host> first." );230 231 function enableTools () { function enableTools () {231 232 const next = new Set (pi.getActiveTools ()); const next = new Set (pi.getActiveTools ());300 301 ? { prepareArguments: editBase.prepareArguments } ? { prepareArguments: editBase.prepareArguments }302 303 execute (id, params, signal, onUpdate) { execute (id, params, signal, onUpdate) {304 - return mkDef (target ? .cwd, { operations: ops (target ! ) }).execute (304 + const active = assertTarget ();305 + return mkDef (active .cwd, { operations: ops (active ) }).execute (321 322 promptSnippet : "Run bash on remote SSH host" , promptSnippet : "Run bash on remote SSH host" ,322 323 parameters : bashBase.parameters, parameters : bashBase.parameters,323 324 execute (id, params, signal, onUpdate) { execute (id, params, signal, onUpdate) {325 - return createBashToolDefinition (target ? .cwd, {326 - operations: remoteBash (target ! ),325 + const active = assertTarget ();326 + return createBashToolDefinition (active .cwd, {327 + operations: remoteBash (active ),327 328 }).execute (id, params, signal, onUpdate); }).execute (id, params, signal, onUpdate);329 330 renderCall (args, theme, ctx) { renderCall (args, theme, ctx) {extensions/superpowers/__tests__/harness.test.ts Modified +14 / −5 text lines
16 16 const extPath = () => path.resolve (import .meta .dirname, "../index.ts" );const extPath = () => path.resolve (import .meta .dirname, "../index.ts" );18 - t! .session.extensionRunner.extensions[0 ].commands.get ("superpowers" )! ;19 - const ctx = () => t! .session.extensionRunner.createCommandContext ();19 + t?.session.extensionRunner.extensions[0 ]?.commands.get ("superpowers" );20 + if (! cmd) throw new Error ("superpowers command not registered" );24 + if (! t) throw new Error ("test session not initialized" );25 + return t.session.extensionRunner.createCommandContext ();20 27 const notices = () => const notices = () => 21 28 t?.events.uiCallsFor ("notify" ).map ((c) => String (c.args[0 ])); t?.events.uiCallsFor ("notify" ).map ((c) => String (c.args[0 ]));22 29 const tasksPath = () => __test.tasksFile (t?.cwd);const tasksPath = () => __test.tasksFile (t?.cwd);292 299 await waitFor (() => await waitFor (() => 293 300 t?.events.messages.some ((m: any ) => m.customType === "superpowers" ), t?.events.messages.some ((m: any ) => m.customType === "superpowers" ),295 - const firstNotice = notices ().at (- 1 )! ;302 + const firstNotice = notices ().at (- 1 );303 + expect (firstNotice).toBeDefined ();296 304 expect (firstNotice).toContain ("visual live: http://127.0.0.1:" ); expect (firstNotice).toContain ("visual live: http://127.0.0.1:" );297 305 expect (firstNotice).toContain ("content:" ); expect (firstNotice).toContain ("content:" );298 306 expect (firstNotice).toContain ("events file:" ); expect (firstNotice).toContain ("events file:" );517 525 execSync ([_cmd, ... _args].join (" " ), { cwd: t.cwd }); execSync ([_cmd, ... _args].join (" " ), { cwd: t.cwd });519 527 } as any ; } as any ;520 - const isolate = await __test.createIsolate (t.cwd, "sp-test" , repo! , piMock);528 + if (! repo) throw new Error ("expected git repo" );529 + const isolate = await __test.createIsolate (t.cwd, "sp-test" , repo, piMock);521 530 expect (isolate.type ).toBe ("git-standard" ); expect (isolate.type ).toBe ("git-standard" );522 531 expect (existsSync (isolate.path)).toBe (true ); expect (existsSync (isolate.path)).toBe (true );523 532 const task = { isolate, log: [] as string [] } as any ; const task = { isolate, log: [] as string [] } as any ;extensions/superpowers/index.ts Modified +9 / −5 text lines
704 704 const { isolate } = task; const { isolate } = task;706 706 if (isolate.type === "jj" ) { if (isolate.type === "jj" ) {707 - await pi.exec ("jj" , ["workspace" , "forget" , isolate.workspaceName! ]);707 + if (isolate.workspaceName)708 + await pi.exec ("jj" , ["workspace" , "forget" , isolate.workspaceName]);708 709 rmdirSync (isolate.path, { recursive: true }); rmdirSync (isolate.path, { recursive: true });709 710 } else if (isolate.type === "git-bare" ) { } else if (isolate.type === "git-bare" ) {
711 + if (! isolate.gitDir || ! isolate.branch)712 + throw new Error ("git-bare isolate missing cleanup metadata" );710 713 await pi.exec ("git" , [ await pi.exec ("git" , [713 716 "worktree" , "worktree" ,714 717 "remove" , "remove" ,715 718 "--force" , "--force" ,718 721 await pi.exec ("git" , [ await pi.exec ("git" , [721 724 "branch" , "branch" ,
729 + if (! isolate.branch) throw new Error ("git isolate missing branch" );726 730 await pi.exec ("git" , ["worktree" , "remove" , "--force" , isolate.path]); await pi.exec ("git" , ["worktree" , "remove" , "--force" , isolate.path]);727 - await pi.exec ("git" , ["branch" , "-D" , isolate.branch! ]);731 + await pi.exec ("git" , ["branch" , "-D" , isolate.branch]);729 733 } catch { } catch {extensions/usage/index.ts Modified +13 / −9 text lines
203 203 compact : !! c.compact , compact : !! c.compact ,206 - const fallback = layouts[ layouts .length - 1 ] ! ;206 + const fallback = layouts.at ( - 1 ) ;207 + if (! fallback) throw new Error ("usage layouts must not be empty" );207 208 const fw = fallback.columns.reduce ((s, col) => s + col.width , 0 ); const fw = fallback.columns.reduce ((s, col) => s + col.width , 0 );209 210 columns: fallback.columns, columns: fallback.columns,253 254 if (i % YIELD_EVERY_N_LINES === 0 ) if (i % YIELD_EVERY_N_LINES === 0 )254 255 await new Promise <void >((r) => setImmediate (r)); await new Promise <void >((r) => setImmediate (r));256 - const line = lines[i]! ;257 - if (! line.trim ()) continue ;257 + const line = lines[i];258 + if (! line? .trim ()) continue ;259 260 const entry = parseJsonLine (line); const entry = parseJsonLine (line);260 261 if (! entry) continue ; if (! entry) continue ;520 521 left = 0 , left = 0 ,521 522 right = 0 , right = 0 ,522 523 parallelCost = 0 ; parallelCost = 0 ;523 - for (let i = 0 ; i < sorted.length ; i++ ) {524 - const cur = sorted[ i ] ! ; 524 + for ( const cur of sorted) { 526 526 right < sorted.length && right < sorted.length && 527 527 sorted[right]?.timestamp <= cur.timestamp + PARALLEL_WINDOW_MS sorted[right]?.timestamp <= cur.timestamp + PARALLEL_WINDOW_MS714 714 if (matchesKey (data, "tab" ) || matchesKey (data, "right" )) { if (matchesKey (data, "tab" ) || matchesKey (data, "right" )) {715 715 const idx = TAB_ORDER.indexOf (this.activeTab); const idx = TAB_ORDER.indexOf (this.activeTab);716 - this . activeTab = TAB_ORDER[(idx + 1 ) % TAB_ORDER.length ]! ;717 + TAB_ORDER[(idx + 1 ) % TAB_ORDER.length ] ?? this . activeTab ;717 718 this.updateProviderOrder (); this.updateProviderOrder ();718 719 this.requestRender (); this.requestRender ();719 720 } else if (matchesKey (data, "shift+tab" ) || matchesKey (data, "left" )) { } else if (matchesKey (data, "shift+tab" ) || matchesKey (data, "left" )) {720 721 const idx = TAB_ORDER.indexOf (this.activeTab); const idx = TAB_ORDER.indexOf (this.activeTab);721 722 this.activeTab = this.activeTab = 722 - TAB_ORDER[(idx - 1 + TAB_ORDER.length ) % TAB_ORDER.length ]! ; 723 + TAB_ORDER[(idx - 1 + TAB_ORDER.length ) % TAB_ORDER.length ] ?? 723 725 this.updateProviderOrder (); this.updateProviderOrder ();724 726 this.requestRender (); this.requestRender ();725 727 } else if (this.viewMode === "table" && matchesKey (data, "up" )) { } else if (this.viewMode === "table" && matchesKey (data, "up" )) {834 836 lines.push (th.fg ("dim" , " No usage data" )); lines.push (th.fg ("dim" , " No usage data" ));836 838 for (let i = 0 ; i < this.providerOrder.length ; i++ ) { for (let i = 0 ; i < this.providerOrder.length ; i++ ) {837 - const name = this.providerOrder[i]! ;838 - const prov = stats.providers.get (name)! ;839 + const name = this.providerOrder[i];840 + if (! name) continue ;841 + const prov = stats.providers.get (name);842 + if (! prov) continue ;839 843 const sel = i === this.selectedIndex ; const sel = i === this.selectedIndex ;840 844 const exp = this.expanded.has (name); const exp = this.expanded.has (name);841 845 const arrow = sel const arrow = selextensions/web/extract.ts Modified +2 / −1 text lines
112 112 const openMatch = html.match (openRe); const openMatch = html.match (openRe);113 113 if (! openMatch) return null ; if (! openMatch) return null ;115 - const startIdx = openMatch.index ! + openMatch[0 ].length ;115 + if (openMatch.index === undefined ) return null ;116 + const startIdx = openMatch.index + openMatch[0 ].length ;116 117 return extractBalanced (html, startIdx, tag); return extractBalanced (html, startIdx, tag);extensions/web/search.ts Modified +5 / −4 text lines
58 58 ): Promise < SearchProvider[]> {): Promise < SearchProvider[]> {59 59 const providers: SearchProvider[] = []; const providers: SearchProvider[] = [];61 - if (options . ctx && (await isCodexAvailable (options . ctx))) {61 + const ctx = options.ctx;62 + if (ctx && (await isCodexAvailable (ctx))) {62 63 providers.push({ providers.push({63 64 source: "codex" , source: "codex" ,64 65 label: "Codex" , label: "Codex" ,65 66 search : () => search : () => 66 - codexSearch (options.query, options . ctx! , options.signal, options.count),67 + codexSearch (options.query, ctx, options.signal, options.count),82 - if (options . ctx && (await isMinimaxAvailable (options . ctx))) {83 + if (ctx && (await isMinimaxAvailable (ctx))) {83 84 providers.push ({ providers.push ({84 85 source: "minimax" , source: "minimax" ,85 86 label: "MiniMax" , label: "MiniMax" ,86 - search : () => searchMinimax (options.query, options . ctx! , options.signal),87 + search : () => searchMinimax (options.query, ctx, options.signal),