@ashx-j/lunr 0.1.6 → 0.1.7

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.
Files changed (59) hide show
  1. package/dist/builtin-extensions/index.d.ts.map +1 -1
  2. package/dist/builtin-extensions/index.js +3 -6
  3. package/dist/builtin-extensions/index.js.map +1 -1
  4. package/dist/bun/cli.d.ts.map +1 -1
  5. package/dist/bun/cli.js +1 -0
  6. package/dist/bun/cli.js.map +1 -1
  7. package/dist/catalog/models.json +1 -1
  8. package/dist/catalog/providers/cerebras.json +1 -1
  9. package/dist/catalog/providers/cloudflare-ai-gateway.json +1 -1
  10. package/dist/catalog/providers/openrouter.json +1 -1
  11. package/dist/catalog/providers/vercel-ai-gateway.json +1 -1
  12. package/dist/catalog/publication.json +3 -3
  13. package/dist/cli.d.ts.map +1 -1
  14. package/dist/cli.js +4 -1
  15. package/dist/cli.js.map +1 -1
  16. package/dist/core/extensions/host-static.d.ts +2 -0
  17. package/dist/core/extensions/host-static.d.ts.map +1 -0
  18. package/dist/core/extensions/host-static.js +15 -0
  19. package/dist/core/extensions/host-static.js.map +1 -0
  20. package/dist/core/extensions/loader.d.ts +10 -0
  21. package/dist/core/extensions/loader.d.ts.map +1 -1
  22. package/dist/core/extensions/loader.js +75 -34
  23. package/dist/core/extensions/loader.js.map +1 -1
  24. package/dist/core/official-catalog.d.ts.map +1 -1
  25. package/dist/core/official-catalog.js +11 -4
  26. package/dist/core/official-catalog.js.map +1 -1
  27. package/dist/core/package-manager.d.ts +3 -0
  28. package/dist/core/package-manager.d.ts.map +1 -1
  29. package/dist/core/package-manager.js +11 -5
  30. package/dist/core/package-manager.js.map +1 -1
  31. package/dist/core/resource-loader.d.ts +4 -1
  32. package/dist/core/resource-loader.d.ts.map +1 -1
  33. package/dist/core/resource-loader.js +13 -5
  34. package/dist/core/resource-loader.js.map +1 -1
  35. package/dist/core/timings.d.ts +1 -0
  36. package/dist/core/timings.d.ts.map +1 -1
  37. package/dist/core/timings.js +6 -1
  38. package/dist/core/timings.js.map +1 -1
  39. package/dist/main.d.ts +8 -0
  40. package/dist/main.d.ts.map +1 -1
  41. package/dist/main.js +63 -16
  42. package/dist/main.js.map +1 -1
  43. package/dist/migrations.d.ts.map +1 -1
  44. package/dist/migrations.js +3 -0
  45. package/dist/migrations.js.map +1 -1
  46. package/dist/modes/interactive/interactive-mode.d.ts +6 -0
  47. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  48. package/dist/modes/interactive/interactive-mode.js +71 -34
  49. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  50. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  51. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  52. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  53. package/examples/extensions/gondolin/package-lock.json +2 -2
  54. package/examples/extensions/gondolin/package.json +1 -1
  55. package/examples/extensions/sandbox/package-lock.json +2 -2
  56. package/examples/extensions/sandbox/package.json +1 -1
  57. package/examples/extensions/with-deps/package-lock.json +2 -2
  58. package/examples/extensions/with-deps/package.json +1 -1
  59. package/package.json +4 -4
@@ -321,6 +321,7 @@ export class InteractiveMode {
321
321
  autoTrustOnReloadCwd;
322
322
  themeController;
323
323
  deferredBuiltinsAttached = false;
324
+ deferredBuiltinAttachPromise;
324
325
  // Convenience accessors
325
326
  get session() {
326
327
  return this.runtimeHost.session;
@@ -626,13 +627,15 @@ export class InteractiveMode {
626
627
  this.headerContainer.addChild(this.builtInHeader);
627
628
  }
628
629
  this.ui.requestRender();
629
- // Initialize extensions first so resources are shown before messages
630
+ // Light extensions first so resources are shown before messages. Deferred
631
+ // MCP/LSP/web/intercom attach in the background so the editor is usable.
630
632
  await this.rebindCurrentSession();
631
633
  time("rebindCurrentSession");
632
- await this.attachDeferredBuiltinExtensions();
633
- time("attachDeferredBuiltins");
634
- // Render initial messages AFTER showing loaded resources
635
634
  this.renderInitialMessages();
635
+ this.deferredBuiltinAttachPromise = this.attachDeferredBuiltinExtensions();
636
+ void this.deferredBuiltinAttachPromise.then(() => {
637
+ time("attachDeferredBuiltins");
638
+ });
636
639
  // Set up theme file watcher
637
640
  onThemeChange(() => {
638
641
  this.ui.invalidate();
@@ -643,9 +646,16 @@ export class InteractiveMode {
643
646
  this.footerDataProvider.onBranchChange(() => {
644
647
  this.ui.requestRender();
645
648
  });
646
- // Initialize available provider count for footer display
647
- await this.updateAvailableProviderCount();
648
- time("updateAvailableProviderCount");
649
+ // Cache-only footer snapshot. Do not hold time-to-type on it.
650
+ void this.updateAvailableProviderCount().then(() => {
651
+ time("updateAvailableProviderCount");
652
+ });
653
+ }
654
+ /** Wait until deferred builtins have attached (or were skipped). */
655
+ async waitForDeferredBuiltins() {
656
+ if (this.deferredBuiltinAttachPromise) {
657
+ await this.deferredBuiltinAttachPromise;
658
+ }
649
659
  }
650
660
  /**
651
661
  * Update terminal title with session name and cwd.
@@ -665,7 +675,9 @@ export class InteractiveMode {
665
675
  * Initializes the UI, shows warnings, processes initial messages, and starts the interactive loop.
666
676
  */
667
677
  async run() {
668
- await this.init();
678
+ if (!this.isInitialized) {
679
+ await this.init();
680
+ }
669
681
  // Check tmux keyboard setup asynchronously
670
682
  this.checkTmuxKeyboardSetup().then((warning) => {
671
683
  if (warning) {
@@ -688,7 +700,7 @@ export class InteractiveMode {
688
700
  // Process initial messages
689
701
  if (initialMessage) {
690
702
  try {
691
- await this.session.prompt(initialMessage, { images: initialImages });
703
+ await this.promptAfterDeferredBuiltins(initialMessage, { images: initialImages });
692
704
  }
693
705
  catch (error) {
694
706
  const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
@@ -698,7 +710,7 @@ export class InteractiveMode {
698
710
  if (initialMessages) {
699
711
  for (const message of initialMessages) {
700
712
  try {
701
- await this.session.prompt(message);
713
+ await this.promptAfterDeferredBuiltins(message);
702
714
  }
703
715
  catch (error) {
704
716
  const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
@@ -710,7 +722,7 @@ export class InteractiveMode {
710
722
  while (true) {
711
723
  const userInput = await this.getUserInput();
712
724
  try {
713
- await this.session.prompt(userInput);
725
+ await this.promptAfterDeferredBuiltins(userInput);
714
726
  }
715
727
  catch (error) {
716
728
  const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
@@ -1203,19 +1215,41 @@ export class InteractiveMode {
1203
1215
  /**
1204
1216
  * Initialize the extension system with TUI-based UI context.
1205
1217
  */
1218
+ async awaitDeferredBuiltinsForPrompt() {
1219
+ await this.waitForDeferredBuiltins();
1220
+ }
1221
+ async promptAfterDeferredBuiltins(text, options) {
1222
+ await this.awaitDeferredBuiltinsForPrompt();
1223
+ await this.session.prompt(text, options);
1224
+ }
1225
+ async sendUserMessageAfterDeferredBuiltins(text) {
1226
+ await this.awaitDeferredBuiltinsForPrompt();
1227
+ await this.session.sendUserMessage(text);
1228
+ }
1206
1229
  async attachDeferredBuiltinExtensions() {
1207
1230
  if (this.deferredBuiltinsAttached || !this.options.deferredBuiltinFactories) {
1208
1231
  return;
1209
1232
  }
1210
- this.deferredBuiltinsAttached = true;
1211
- const factories = await this.options.deferredBuiltinFactories();
1212
- if (factories.length === 0)
1213
- return;
1214
- this.options.onDeferredBuiltinsAttached?.(factories);
1215
- await this.session.attachInlineExtensions(factories);
1216
- this.setupAutocompleteProvider();
1217
- this.setupExtensionShortcuts(this.session.extensionRunner);
1218
- this.showLoadedResources({ force: false, showDiagnosticsWhenQuiet: true });
1233
+ this.setExtensionStatus("deferred-builtins", "loading tools…");
1234
+ try {
1235
+ const factories = await this.options.deferredBuiltinFactories();
1236
+ this.deferredBuiltinsAttached = true;
1237
+ if (factories.length === 0)
1238
+ return;
1239
+ this.options.onDeferredBuiltinsAttached?.(factories);
1240
+ await this.session.attachInlineExtensions(factories);
1241
+ this.setupAutocompleteProvider();
1242
+ this.setupExtensionShortcuts(this.session.extensionRunner);
1243
+ this.showLoadedResources({ force: false, showDiagnosticsWhenQuiet: true });
1244
+ }
1245
+ catch (error) {
1246
+ this.deferredBuiltinsAttached = false;
1247
+ const message = error instanceof Error ? error.message : String(error);
1248
+ this.showError(`Failed to load deferred extensions: ${message}`);
1249
+ }
1250
+ finally {
1251
+ this.setExtensionStatus("deferred-builtins", undefined);
1252
+ }
1219
1253
  }
1220
1254
  async bindCurrentSessionExtensions() {
1221
1255
  const uiContext = this.createExtensionUIContext();
@@ -1329,6 +1363,7 @@ export class InteractiveMode {
1329
1363
  return bootRows;
1330
1364
  }
1331
1365
  async rebindCurrentSession(options = {}) {
1366
+ await this.waitForDeferredBuiltins();
1332
1367
  this.unsubscribe?.();
1333
1368
  this.unsubscribe = undefined;
1334
1369
  this.applyRuntimeSettings();
@@ -1345,7 +1380,7 @@ export class InteractiveMode {
1345
1380
  await this.bindCurrentSessionExtensions();
1346
1381
  this.subscribeToAgent();
1347
1382
  }
1348
- await this.updateAvailableProviderCount();
1383
+ void this.updateAvailableProviderCount();
1349
1384
  this.updateEditorBorderColor();
1350
1385
  this.updateTerminalTitle();
1351
1386
  }
@@ -2376,7 +2411,7 @@ export class InteractiveMode {
2376
2411
  if (this.isExtensionCommand(text)) {
2377
2412
  this.editor.addToHistory?.(text);
2378
2413
  this.editor.setText("");
2379
- await this.session.prompt(text);
2414
+ await this.promptAfterDeferredBuiltins(text);
2380
2415
  }
2381
2416
  else {
2382
2417
  this.queueCompactionMessage(text, "steer");
@@ -2388,7 +2423,7 @@ export class InteractiveMode {
2388
2423
  if (this.session.isStreaming) {
2389
2424
  this.editor.addToHistory?.(text);
2390
2425
  this.editor.setText("");
2391
- await this.session.prompt(text, { streamingBehavior: "steer" });
2426
+ await this.promptAfterDeferredBuiltins(text, { streamingBehavior: "steer" });
2392
2427
  this.updatePendingMessagesDisplay();
2393
2428
  this.ui.requestRender();
2394
2429
  return;
@@ -3272,7 +3307,7 @@ export class InteractiveMode {
3272
3307
  if (this.isExtensionCommand(text)) {
3273
3308
  this.editor.addToHistory?.(text);
3274
3309
  this.editor.setText("");
3275
- await this.session.prompt(text);
3310
+ await this.promptAfterDeferredBuiltins(text);
3276
3311
  }
3277
3312
  else {
3278
3313
  this.queueCompactionMessage(text, "followUp");
@@ -3284,7 +3319,7 @@ export class InteractiveMode {
3284
3319
  if (this.session.isStreaming) {
3285
3320
  this.editor.addToHistory?.(text);
3286
3321
  this.editor.setText("");
3287
- await this.session.prompt(text, { streamingBehavior: "followUp" });
3322
+ await this.promptAfterDeferredBuiltins(text, { streamingBehavior: "followUp" });
3288
3323
  this.updatePendingMessagesDisplay();
3289
3324
  this.ui.requestRender();
3290
3325
  }
@@ -3561,7 +3596,7 @@ export class InteractiveMode {
3561
3596
  // When retry is pending, queue messages for the retry turn
3562
3597
  for (const message of queuedMessages) {
3563
3598
  if (this.isExtensionCommand(message.text)) {
3564
- await this.session.prompt(message.text);
3599
+ await this.promptAfterDeferredBuiltins(message.text);
3565
3600
  }
3566
3601
  else if (message.mode === "followUp") {
3567
3602
  await this.session.followUp(message.text);
@@ -3578,7 +3613,7 @@ export class InteractiveMode {
3578
3613
  if (firstPromptIndex === -1) {
3579
3614
  // All extension commands - execute them all
3580
3615
  for (const message of queuedMessages) {
3581
- await this.session.prompt(message.text);
3616
+ await this.promptAfterDeferredBuiltins(message.text);
3582
3617
  }
3583
3618
  return;
3584
3619
  }
@@ -3587,16 +3622,16 @@ export class InteractiveMode {
3587
3622
  const firstPrompt = queuedMessages[firstPromptIndex];
3588
3623
  const rest = queuedMessages.slice(firstPromptIndex + 1);
3589
3624
  for (const message of preCommands) {
3590
- await this.session.prompt(message.text);
3625
+ await this.promptAfterDeferredBuiltins(message.text);
3591
3626
  }
3592
3627
  // Send first prompt (starts streaming)
3593
- const promptPromise = this.session.prompt(firstPrompt.text).catch((error) => {
3628
+ const promptPromise = this.promptAfterDeferredBuiltins(firstPrompt.text).catch((error) => {
3594
3629
  restoreQueue(error);
3595
3630
  });
3596
3631
  // Queue remaining messages
3597
3632
  for (const message of rest) {
3598
3633
  if (this.isExtensionCommand(message.text)) {
3599
- await this.session.prompt(message.text);
3634
+ await this.promptAfterDeferredBuiltins(message.text);
3600
3635
  }
3601
3636
  else if (message.mode === "followUp") {
3602
3637
  await this.session.followUp(message.text);
@@ -5282,7 +5317,7 @@ export class InteractiveMode {
5282
5317
  return;
5283
5318
  }
5284
5319
  }
5285
- await this.session.sendUserMessage(prompt);
5320
+ await this.sendUserMessageAfterDeferredBuiltins(prompt);
5286
5321
  this.showStatus("AGENTS.md is being generated — run /reload when it finishes to load it into context.");
5287
5322
  }
5288
5323
  async handleSwarmCommand(task) {
@@ -5301,7 +5336,7 @@ export class InteractiveMode {
5301
5336
  }
5302
5337
  this.swarmMode = true;
5303
5338
  this.setExtensionStatus("swarm", "swarm ● active");
5304
- await this.session.sendUserMessage(buildSwarmPrompt(task));
5339
+ await this.sendUserMessageAfterDeferredBuiltins(buildSwarmPrompt(task));
5305
5340
  }
5306
5341
  async handleResearchCommand(args) {
5307
5342
  const usage = "Usage: /research [--depth N] [--breadth N] <question> — deep research with cited sources. depth: reflection rounds (1-4, default 2); breadth: subtopics per round (1-8, default 4).";
@@ -5349,7 +5384,7 @@ export class InteractiveMode {
5349
5384
  }
5350
5385
  this.researchMode = true;
5351
5386
  this.setExtensionStatus("research", "research ● active");
5352
- await this.session.sendUserMessage(buildResearchPrompt(question, depth, breadth));
5387
+ await this.sendUserMessageAfterDeferredBuiltins(buildResearchPrompt(question, depth, breadth));
5353
5388
  }
5354
5389
  // lunr: /undo persists the rewind by forking the session to just before the
5355
5390
  // last user message (same fork mechanism /rollback uses, but WITHOUT touching files).
@@ -5982,7 +6017,7 @@ export class InteractiveMode {
5982
6017
  else {
5983
6018
  this.applyPermissionMode("plan");
5984
6019
  }
5985
- await this.session.sendUserMessage(args);
6020
+ await this.sendUserMessageAfterDeferredBuiltins(args);
5986
6021
  return;
5987
6022
  }
5988
6023
  const next = sub === "" ? !inPlan : sub === "on";
@@ -6383,6 +6418,8 @@ ${cycleThinkingLevel ? `| \`${cycleThinkingLevel}\` | Cycle thinking level |\n`
6383
6418
  async handleClearCommand() {
6384
6419
  this.clearStatusIndicator();
6385
6420
  this.ui.setChatScroll(0);
6421
+ // Deferred factories must be on builtinRoster before /new rebuilds the runtime.
6422
+ await this.waitForDeferredBuiltins();
6386
6423
  // lunr: preserve the in-flight model across /new so a /model switch survives.
6387
6424
  const previousModel = this.session.model;
6388
6425
  try {