apex-code 0.0.1-alpha.4 → 0.0.1-alpha.6
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/CHANGELOG.md +78 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +10 -1
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +2 -2
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +20 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +91 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +17 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +28 -4
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/lsp/client.d.ts +76 -0
- package/dist/core/lsp/client.d.ts.map +1 -0
- package/dist/core/lsp/client.js +469 -0
- package/dist/core/lsp/client.js.map +1 -0
- package/dist/core/lsp/diagnostics.d.ts +47 -0
- package/dist/core/lsp/diagnostics.d.ts.map +1 -0
- package/dist/core/lsp/diagnostics.js +224 -0
- package/dist/core/lsp/diagnostics.js.map +1 -0
- package/dist/core/lsp/pool.d.ts +48 -0
- package/dist/core/lsp/pool.d.ts.map +1 -0
- package/dist/core/lsp/pool.js +150 -0
- package/dist/core/lsp/pool.js.map +1 -0
- package/dist/core/lsp/registry.d.ts +49 -0
- package/dist/core/lsp/registry.d.ts.map +1 -0
- package/dist/core/lsp/registry.js +215 -0
- package/dist/core/lsp/registry.js.map +1 -0
- package/dist/core/lsp/status.d.ts +23 -0
- package/dist/core/lsp/status.d.ts.map +1 -0
- package/dist/core/lsp/status.js +35 -0
- package/dist/core/lsp/status.js.map +1 -0
- package/dist/core/lsp/sync.d.ts +13 -0
- package/dist/core/lsp/sync.d.ts.map +1 -0
- package/dist/core/lsp/sync.js +71 -0
- package/dist/core/lsp/sync.js.map +1 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +15 -0
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/project-trust.d.ts.map +1 -1
- package/dist/core/project-trust.js +1 -1
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/sandbox/cli-launch.d.ts +43 -0
- package/dist/core/sandbox/cli-launch.d.ts.map +1 -1
- package/dist/core/sandbox/cli-launch.js +70 -3
- package/dist/core/sandbox/cli-launch.js.map +1 -1
- package/dist/core/sandbox/cli-supervisor.d.ts +2 -0
- package/dist/core/sandbox/cli-supervisor.d.ts.map +1 -1
- package/dist/core/sandbox/cli-supervisor.js +1 -0
- package/dist/core/sandbox/cli-supervisor.js.map +1 -1
- package/dist/core/sdk.d.ts +4 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +10 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager.d.ts +3 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +3 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +19 -7
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +77 -19
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +3 -3
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/contract.d.ts +29 -2
- package/dist/core/tools/contract.d.ts.map +1 -1
- package/dist/core/tools/contract.js.map +1 -1
- package/dist/core/tools/diagnostics.d.ts +39 -0
- package/dist/core/tools/diagnostics.d.ts.map +1 -0
- package/dist/core/tools/diagnostics.js +62 -0
- package/dist/core/tools/diagnostics.js.map +1 -0
- package/dist/core/tools/edit.d.ts +10 -0
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +17 -8
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/index.d.ts +20 -3
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +18 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/lsp.d.ts +62 -0
- package/dist/core/tools/lsp.d.ts.map +1 -0
- package/dist/core/tools/lsp.js +216 -0
- package/dist/core/tools/lsp.js.map +1 -0
- package/dist/core/tools/skill-search.d.ts +32 -0
- package/dist/core/tools/skill-search.d.ts.map +1 -0
- package/dist/core/tools/skill-search.js +56 -0
- package/dist/core/tools/skill-search.js.map +1 -0
- package/dist/core/tools/write.d.ts +10 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +16 -3
- package/dist/core/tools/write.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +49 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +235 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +2 -1
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +19 -6
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +172 -89
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/splash-header.d.ts +41 -0
- package/dist/modes/interactive/components/splash-header.d.ts.map +1 -0
- package/dist/modes/interactive/components/splash-header.js +145 -0
- package/dist/modes/interactive/components/splash-header.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +19 -15
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/apex.json +94 -0
- package/dist/modes/interactive/theme/light.json +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +6 -1
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +2 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/themes/apex-logo.d.ts +21 -0
- package/dist/themes/apex-logo.d.ts.map +1 -0
- package/dist/themes/apex-logo.js +31 -0
- package/dist/themes/apex-logo.js.map +1 -0
- package/dist/utils/changelog.d.ts +7 -2
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js +82 -13
- package/dist/utils/changelog.js.map +1 -1
- package/docs/skills.md +54 -4
- package/npm-shrinkwrap.json +5 -5
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-selector.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/model-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EACN,SAAS,EAET,WAAW,EACX,cAAc,EACd,KAAK,EACL,MAAM,EACN,IAAI,GAEJ,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAehD;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,SAAS;IAC5C,WAAW,CAAQ;IAE3B,iFAAiF;IACzE,QAAQ,G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n\tgetKeybindings,\n\tInput,\n\tSpacer,\n\tText,\n\ttype TUI,\n} from \"@earendil-works/pi-tui\";\nimport type { ModelRuntime } from \"../../../core/model-runtime.ts\";\nimport type { SettingsManager } from \"../../../core/settings-manager.ts\";\nimport { getModelSelectorSearchText } from \"../model-search.ts\";\nimport { theme } from \"../theme/theme.ts\";\nimport { DynamicBorder } from \"./dynamic-border.ts\";\nimport { keyHint } from \"./keybinding-hints.ts\";\n\ninterface ModelItem {\n\tprovider: string;\n\tid: string;\n\tmodel: Model<any>;\n}\n\ninterface ScopedModelItem {\n\tmodel: Model<any>;\n\tthinkingLevel?: string;\n}\n\ntype ModelScope = \"all\" | \"scoped\";\n\n/**\n * Component that renders a model selector with search\n */\nexport class ModelSelectorComponent extends Container implements Focusable {\n\tprivate searchInput: Input;\n\n\t// Focusable implementation - propagate to searchInput for IME cursor positioning\n\tprivate _focused = false;\n\tget focused(): boolean {\n\t\treturn this._focused;\n\t}\n\tset focused(value: boolean) {\n\t\tthis._focused = value;\n\t\tthis.searchInput.focused = value;\n\t}\n\tprivate listContainer: Container;\n\tprivate allModels: ModelItem[] = [];\n\tprivate scopedModelItems: ModelItem[] = [];\n\tprivate activeModels: ModelItem[] = [];\n\tprivate filteredModels: ModelItem[] = [];\n\tprivate selectedIndex: number = 0;\n\tprivate currentModel?: Model<any>;\n\tprivate settingsManager: SettingsManager;\n\tprivate modelRuntime: ModelRuntime;\n\tprivate onSelectCallback: (model: Model<any>) => void;\n\tprivate onCancelCallback: () => void;\n\tprivate errorMessage?: string;\n\tprivate refreshStatusMessage = \"Refreshing model catalogs…\";\n\tprivate refreshStatusSuccess = false;\n\tprivate tui: TUI;\n\tprivate scopedModels: ReadonlyArray<ScopedModelItem>;\n\tprivate scope: ModelScope = \"all\";\n\tprivate scopeText?: Text;\n\tprivate scopeHintText?: Text;\n\tprivate readonly refreshAbortController = new AbortController();\n\tprivate refreshTimeout?: ReturnType<typeof setTimeout>;\n\tprivate closed = false;\n\n\tconstructor(\n\t\ttui: TUI,\n\t\tcurrentModel: Model<any> | undefined,\n\t\tsettingsManager: SettingsManager,\n\t\tmodelRuntime: ModelRuntime,\n\t\tscopedModels: ReadonlyArray<ScopedModelItem>,\n\t\tonSelect: (model: Model<any>) => void,\n\t\tonCancel: () => void,\n\t\tinitialSearchInput?: string,\n\t) {\n\t\tsuper();\n\n\t\tthis.tui = tui;\n\t\tthis.currentModel = currentModel;\n\t\tthis.settingsManager = settingsManager;\n\t\tthis.modelRuntime = modelRuntime;\n\t\tthis.scopedModels = scopedModels;\n\t\tthis.scope = scopedModels.length > 0 ? \"scoped\" : \"all\";\n\t\tthis.onSelectCallback = onSelect;\n\t\tthis.onCancelCallback = onCancel;\n\n\t\t// Add top border\n\t\tthis.addChild(new DynamicBorder());\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Add hint about model filtering\n\t\tif (scopedModels.length > 0) {\n\t\t\tthis.scopeText = new Text(this.getScopeText(), 0, 0);\n\t\t\tthis.addChild(this.scopeText);\n\t\t\tthis.scopeHintText = new Text(this.getScopeHintText(), 0, 0);\n\t\t\tthis.addChild(this.scopeHintText);\n\t\t} else {\n\t\t\tconst hintText = \"Only showing models from configured providers. Use /login to add providers.\";\n\t\t\tthis.addChild(new Text(theme.fg(\"warning\", hintText), 0, 0));\n\t\t}\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Create search input\n\t\tthis.searchInput = new Input();\n\t\tif (initialSearchInput) {\n\t\t\tthis.searchInput.setValue(initialSearchInput);\n\t\t}\n\t\tthis.searchInput.onSubmit = () => {\n\t\t\t// Enter on search input selects the first filtered item\n\t\t\tif (this.filteredModels[this.selectedIndex]) {\n\t\t\t\tthis.handleSelect(this.filteredModels[this.selectedIndex].model);\n\t\t\t}\n\t\t};\n\t\tthis.addChild(this.searchInput);\n\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Create list container\n\t\tthis.listContainer = new Container();\n\t\tthis.addChild(this.listContainer);\n\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Add bottom border\n\t\tthis.addChild(new DynamicBorder());\n\n\t\t// Render the current snapshot immediately, then refresh in the background.\n\t\tthis.loadModelsFromSnapshot();\n\t\tif (initialSearchInput) this.filterModels(initialSearchInput);\n\t\telse this.updateList();\n\t\tthis.tui.requestRender();\n\t\tvoid this.refreshModels();\n\t}\n\n\tprivate loadModelsFromSnapshot(): void {\n\t\tconst models = this.modelRuntime.getAvailableSnapshot().map((model: Model<any>) => ({\n\t\t\tprovider: model.provider,\n\t\t\tid: model.id,\n\t\t\tmodel,\n\t\t}));\n\t\tthis.allModels = this.sortModels(models);\n\t\tthis.scopedModels = this.scopedModels.map((scoped) => {\n\t\t\tconst refreshed = this.modelRuntime.getModel(scoped.model.provider, scoped.model.id);\n\t\t\treturn refreshed ? { ...scoped, model: refreshed } : scoped;\n\t\t});\n\t\tthis.scopedModelItems = this.scopedModels.map((scoped) => ({\n\t\t\tprovider: scoped.model.provider,\n\t\t\tid: scoped.model.id,\n\t\t\tmodel: scoped.model,\n\t\t}));\n\t\tthis.activeModels = this.scope === \"scoped\" ? this.scopedModelItems : this.allModels;\n\t\tthis.filteredModels = this.activeModels;\n\t\tconst currentIndex = this.filteredModels.findIndex((item) => modelsAreEqual(this.currentModel, item.model));\n\t\tthis.selectedIndex =\n\t\t\tcurrentIndex >= 0 ? currentIndex : Math.min(this.selectedIndex, Math.max(0, this.filteredModels.length - 1));\n\t}\n\n\tprivate async refreshModels(): Promise<void> {\n\t\tconst timeoutMs = 15_000;\n\t\tlet timedOut = false;\n\t\tthis.refreshTimeout = setTimeout(() => {\n\t\t\ttimedOut = true;\n\t\t\tthis.refreshAbortController.abort();\n\t\t}, timeoutMs);\n\t\ttry {\n\t\t\tconst result = await this.modelRuntime.refresh({ signal: this.refreshAbortController.signal });\n\t\t\tif (this.closed) return;\n\t\t\tthis.refreshStatusMessage = \"\";\n\t\t\tif (result.aborted && timedOut) {\n\t\t\t\tthis.errorMessage = \"Model refresh timed out; showing cached models.\";\n\t\t\t} else if (result.errors.size === 1) {\n\t\t\t\tthis.errorMessage = `Could not refresh ${result.errors.keys().next().value}; showing cached models.`;\n\t\t\t} else if (result.errors.size > 1) {\n\t\t\t\tthis.errorMessage = `Could not refresh ${result.errors.size} model catalogs (${[...result.errors.keys()].join(\", \")}); showing cached models.`;\n\t\t\t} else {\n\t\t\t\tthis.errorMessage = this.modelRuntime.getError();\n\t\t\t\tif (!this.errorMessage) {\n\t\t\t\t\tthis.refreshStatusMessage = \"Model catalogs refreshed.\";\n\t\t\t\t\tthis.refreshStatusSuccess = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.loadModelsFromSnapshot();\n\t\t\tthis.filterModels(this.searchInput.getValue());\n\t\t\tthis.tui.requestRender();\n\t\t} catch (error) {\n\t\t\tif (this.closed) return;\n\t\t\tthis.refreshStatusMessage = \"\";\n\t\t\tthis.errorMessage = timedOut\n\t\t\t\t? \"Model refresh timed out; showing cached models.\"\n\t\t\t\t: `Could not refresh model catalogs: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\tthis.updateList();\n\t\t\tthis.tui.requestRender();\n\t\t} finally {\n\t\t\tif (this.refreshTimeout) clearTimeout(this.refreshTimeout);\n\t\t}\n\t}\n\n\tdispose(): void {\n\t\tif (this.closed) return;\n\t\tthis.closed = true;\n\t\tif (this.refreshTimeout) clearTimeout(this.refreshTimeout);\n\t\tthis.refreshAbortController.abort();\n\t}\n\n\tprivate sortModels(models: ModelItem[]): ModelItem[] {\n\t\tconst sorted = [...models];\n\t\t// Sort: current model first, then by provider\n\t\tsorted.sort((a, b) => {\n\t\t\tconst aIsCurrent = modelsAreEqual(this.currentModel, a.model);\n\t\t\tconst bIsCurrent = modelsAreEqual(this.currentModel, b.model);\n\t\t\tif (aIsCurrent && !bIsCurrent) return -1;\n\t\t\tif (!aIsCurrent && bIsCurrent) return 1;\n\t\t\treturn a.provider.localeCompare(b.provider);\n\t\t});\n\t\treturn sorted;\n\t}\n\n\tprivate getScopeText(): string {\n\t\tconst allText = this.scope === \"all\" ? theme.fg(\"accent\", \"all\") : theme.fg(\"muted\", \"all\");\n\t\tconst scopedText = this.scope === \"scoped\" ? theme.fg(\"accent\", \"scoped\") : theme.fg(\"muted\", \"scoped\");\n\t\treturn `${theme.fg(\"muted\", \"Scope: \")}${allText}${theme.fg(\"muted\", \" | \")}${scopedText}`;\n\t}\n\n\tprivate getScopeHintText(): string {\n\t\treturn keyHint(\"tui.input.tab\", \"scope\") + theme.fg(\"muted\", \" (all/scoped)\");\n\t}\n\n\tprivate setScope(scope: ModelScope): void {\n\t\tif (this.scope === scope) return;\n\t\tthis.scope = scope;\n\t\tthis.activeModels = this.scope === \"scoped\" ? this.scopedModelItems : this.allModels;\n\t\tconst currentIndex = this.activeModels.findIndex((item) => modelsAreEqual(this.currentModel, item.model));\n\t\tthis.selectedIndex = currentIndex >= 0 ? currentIndex : 0;\n\t\tthis.filterModels(this.searchInput.getValue());\n\t\tif (this.scopeText) {\n\t\t\tthis.scopeText.setText(this.getScopeText());\n\t\t}\n\t}\n\n\tprivate filterModels(query: string): void {\n\t\tthis.filteredModels = query\n\t\t\t? fuzzyFilter(this.activeModels, query, ({ id, provider, model }) =>\n\t\t\t\t\tgetModelSelectorSearchText({ id, provider, name: model.name }),\n\t\t\t\t)\n\t\t\t: this.activeModels;\n\t\t// When filtering by a query, move the selector to the top row so the best\n\t\t// match is highlighted. When the query is cleared, keep the current position\n\t\t// clamped to the (restored) list length.\n\t\tthis.selectedIndex = query ? 0 : Math.min(this.selectedIndex, Math.max(0, this.filteredModels.length - 1));\n\t\tthis.updateList();\n\t}\n\n\tprivate updateList(): void {\n\t\tthis.listContainer.clear();\n\n\t\tconst maxVisible = 10;\n\t\tconst startIndex = Math.max(\n\t\t\t0,\n\t\t\tMath.min(this.selectedIndex - Math.floor(maxVisible / 2), this.filteredModels.length - maxVisible),\n\t\t);\n\t\tconst endIndex = Math.min(startIndex + maxVisible, this.filteredModels.length);\n\n\t\t// Show visible slice of filtered models\n\t\tfor (let i = startIndex; i < endIndex; i++) {\n\t\t\tconst item = this.filteredModels[i];\n\t\t\tif (!item) continue;\n\n\t\t\tconst isSelected = i === this.selectedIndex;\n\t\t\tconst isCurrent = modelsAreEqual(this.currentModel, item.model);\n\n\t\t\tlet line = \"\";\n\t\t\tif (isSelected) {\n\t\t\t\tconst prefix = theme.fg(\"accent\", \"→ \");\n\t\t\t\tconst modelText = `${item.id}`;\n\t\t\t\tconst providerBadge = theme.fg(\"muted\", `[${item.provider}]`);\n\t\t\t\tconst checkmark = isCurrent ? theme.fg(\"success\", \" ✓\") : \"\";\n\t\t\t\tline = `${prefix + theme.fg(\"accent\", modelText)} ${providerBadge}${checkmark}`;\n\t\t\t} else {\n\t\t\t\tconst modelText = ` ${item.id}`;\n\t\t\t\tconst providerBadge = theme.fg(\"muted\", `[${item.provider}]`);\n\t\t\t\tconst checkmark = isCurrent ? theme.fg(\"success\", \" ✓\") : \"\";\n\t\t\t\tline = `${modelText} ${providerBadge}${checkmark}`;\n\t\t\t}\n\n\t\t\tthis.listContainer.addChild(new Text(line, 0, 0));\n\t\t}\n\n\t\t// Add scroll indicator if needed\n\t\tif (startIndex > 0 || endIndex < this.filteredModels.length) {\n\t\t\tconst scrollInfo = theme.fg(\"muted\", ` (${this.selectedIndex + 1}/${this.filteredModels.length})`);\n\t\t\tthis.listContainer.addChild(new Text(scrollInfo, 0, 0));\n\t\t}\n\n\t\t// Show error message or \"no results\" if empty\n\t\tif (this.errorMessage) {\n\t\t\t// Show error in red\n\t\t\tconst errorLines = this.errorMessage.split(\"\\n\");\n\t\t\tfor (const line of errorLines) {\n\t\t\t\tthis.listContainer.addChild(new Text(theme.fg(\"error\", line), 0, 0));\n\t\t\t}\n\t\t} else if (this.filteredModels.length === 0) {\n\t\t\tthis.listContainer.addChild(new Text(theme.fg(\"muted\", \" No matching models\"), 0, 0));\n\t\t} else {\n\t\t\tconst selected = this.filteredModels[this.selectedIndex];\n\t\t\tthis.listContainer.addChild(new Spacer(1));\n\t\t\tthis.listContainer.addChild(new Text(theme.fg(\"muted\", ` Model Name: ${selected.model.name}`), 0, 0));\n\t\t}\n\t\tif (this.refreshStatusMessage) {\n\t\t\tthis.listContainer.addChild(new Spacer(1));\n\t\t\tthis.listContainer.addChild(\n\t\t\t\tnew Text(theme.fg(this.refreshStatusSuccess ? \"success\" : \"muted\", ` ${this.refreshStatusMessage}`), 0, 0),\n\t\t\t);\n\t\t}\n\t}\n\n\thandleInput(keyData: string): void {\n\t\tconst kb = getKeybindings();\n\t\tif (kb.matches(keyData, \"tui.input.tab\")) {\n\t\t\tif (this.scopedModelItems.length > 0) {\n\t\t\t\tconst nextScope: ModelScope = this.scope === \"all\" ? \"scoped\" : \"all\";\n\t\t\t\tthis.setScope(nextScope);\n\t\t\t\tif (this.scopeHintText) {\n\t\t\t\t\tthis.scopeHintText.setText(this.getScopeHintText());\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\t// Up arrow - wrap to bottom when at top\n\t\tif (kb.matches(keyData, \"tui.select.up\")) {\n\t\t\tif (this.filteredModels.length === 0) return;\n\t\t\tthis.selectedIndex = this.selectedIndex === 0 ? this.filteredModels.length - 1 : this.selectedIndex - 1;\n\t\t\tthis.updateList();\n\t\t}\n\t\t// Down arrow - wrap to top when at bottom\n\t\telse if (kb.matches(keyData, \"tui.select.down\")) {\n\t\t\tif (this.filteredModels.length === 0) return;\n\t\t\tthis.selectedIndex = this.selectedIndex === this.filteredModels.length - 1 ? 0 : this.selectedIndex + 1;\n\t\t\tthis.updateList();\n\t\t}\n\t\t// Enter\n\t\telse if (kb.matches(keyData, \"tui.select.confirm\")) {\n\t\t\tconst selectedModel = this.filteredModels[this.selectedIndex];\n\t\t\tif (selectedModel) {\n\t\t\t\tthis.handleSelect(selectedModel.model);\n\t\t\t}\n\t\t}\n\t\t// Escape or Ctrl+C\n\t\telse if (kb.matches(keyData, \"tui.select.cancel\")) {\n\t\t\tthis.dispose();\n\t\t\tthis.onCancelCallback();\n\t\t}\n\t\t// Pass everything else to search input\n\t\telse {\n\t\t\tthis.searchInput.handleInput(keyData);\n\t\t\tthis.filterModels(this.searchInput.getValue());\n\t\t}\n\t}\n\n\tprivate handleSelect(model: Model<any>): void {\n\t\tthis.dispose();\n\t\t// Save as new default\n\t\tthis.settingsManager.setDefaultModelAndProvider(model.provider, model.id);\n\t\tthis.onSelectCallback(model);\n\t}\n\n\tgetSearchInput(): Input {\n\t\treturn this.searchInput;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model-selector.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/model-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EACN,SAAS,EAET,WAAW,EACX,cAAc,EACd,KAAK,EACL,GAAG,EACH,UAAU,EACV,MAAM,EACN,IAAI,GAEJ,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAyB5D,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,SAAS;IAC5C,WAAW,CAAQ;IAE3B,iFAAiF;IACzE,QAAQ,GAAG,KAAK,CAAC;IACzB,IAAI,OAAO,GAAY;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC;IAAA,CACrB;IACD,IAAI,OAAO,CAAC,KAAc,EAAE;QAC3B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;IAAA,CACjC;IACO,eAAe,CAAY;IAC3B,aAAa,CAAY;IACzB,SAAS,GAAgB,EAA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-ai\";\nimport {\n\tContainer,\n\ttype Focusable,\n\tfuzzyFilter,\n\tgetKeybindings,\n\tInput,\n\tKey,\n\tmatchesKey,\n\tSpacer,\n\tText,\n\ttype TUI,\n} from \"@earendil-works/pi-tui\";\nimport type { ModelRuntime } from \"../../../core/model-runtime.ts\";\nimport type { SettingsManager } from \"../../../core/settings-manager.ts\";\nimport { getModelSelectorSearchText } from \"../model-search.ts\";\nimport { theme } from \"../theme/theme.ts\";\nimport { DynamicBorder } from \"./dynamic-border.ts\";\nimport { keyHint, rawKeyHint } from \"./keybinding-hints.ts\";\n\ninterface ModelItem {\n\tprovider: string;\n\tid: string;\n\tmodel: Model<any>;\n}\n\ninterface ScopedModelItem {\n\tmodel: Model<any>;\n\tthinkingLevel?: string;\n}\n\ntype ModelScope = \"all\" | \"scoped\";\n\n/**\n * Which of the two steps the selector is on. `provider: null` lists every provider's models at once,\n * which is how a `/model <search>` invocation and a single-provider setup both open.\n */\ntype Step = { kind: \"providers\" } | { kind: \"models\"; provider: string | null };\n\ntype Row =\n\t| { kind: \"provider\"; provider: string; count: number; hasCurrent: boolean }\n\t| { kind: \"model\"; item: ModelItem };\n\nconst MAX_VISIBLE_ROWS = 10;\n\n/**\n * Component that renders a two-step model selector: provider first, then that provider's models.\n */\nexport class ModelSelectorComponent extends Container implements Focusable {\n\tprivate searchInput: Input;\n\n\t// Focusable implementation - propagate to searchInput for IME cursor positioning\n\tprivate _focused = false;\n\tget focused(): boolean {\n\t\treturn this._focused;\n\t}\n\tset focused(value: boolean) {\n\t\tthis._focused = value;\n\t\tthis.searchInput.focused = value;\n\t}\n\tprivate headerContainer: Container;\n\tprivate listContainer: Container;\n\tprivate allModels: ModelItem[] = [];\n\tprivate scopedModelItems: ModelItem[] = [];\n\tprivate activeModels: ModelItem[] = [];\n\tprivate rows: Row[] = [];\n\tprivate filteredRows: Row[] = [];\n\tprivate selectedIndex: number = 0;\n\tprivate currentModel?: Model<any>;\n\tprivate settingsManager: SettingsManager;\n\tprivate modelRuntime: ModelRuntime;\n\tprivate onSelectCallback: (model: Model<any>) => void;\n\tprivate onCancelCallback: () => void;\n\tprivate errorMessage?: string;\n\tprivate refreshStatusMessage = \"Refreshing model catalogs…\";\n\tprivate refreshStatusSuccess = false;\n\tprivate tui: TUI;\n\tprivate scopedModels: ReadonlyArray<ScopedModelItem>;\n\tprivate scope: ModelScope = \"all\";\n\tprivate step: Step = { kind: \"providers\" };\n\tprivate readonly refreshAbortController = new AbortController();\n\tprivate refreshTimeout?: ReturnType<typeof setTimeout>;\n\tprivate closed = false;\n\n\tconstructor(\n\t\ttui: TUI,\n\t\tcurrentModel: Model<any> | undefined,\n\t\tsettingsManager: SettingsManager,\n\t\tmodelRuntime: ModelRuntime,\n\t\tscopedModels: ReadonlyArray<ScopedModelItem>,\n\t\tonSelect: (model: Model<any>) => void,\n\t\tonCancel: () => void,\n\t\tinitialSearchInput?: string,\n\t) {\n\t\tsuper();\n\n\t\tthis.tui = tui;\n\t\tthis.currentModel = currentModel;\n\t\tthis.settingsManager = settingsManager;\n\t\tthis.modelRuntime = modelRuntime;\n\t\tthis.scopedModels = scopedModels;\n\t\tthis.scope = scopedModels.length > 0 ? \"scoped\" : \"all\";\n\t\tthis.onSelectCallback = onSelect;\n\t\tthis.onCancelCallback = onCancel;\n\n\t\t// Add top border\n\t\tthis.addChild(new DynamicBorder());\n\t\tthis.addChild(new Spacer(1));\n\n\t\tthis.headerContainer = new Container();\n\t\tthis.addChild(this.headerContainer);\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Create search input\n\t\tthis.searchInput = new Input();\n\t\tif (initialSearchInput) {\n\t\t\tthis.searchInput.setValue(initialSearchInput);\n\t\t}\n\t\tthis.searchInput.onSubmit = () => this.confirmSelection();\n\t\tthis.addChild(this.searchInput);\n\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Create list container\n\t\tthis.listContainer = new Container();\n\t\tthis.addChild(this.listContainer);\n\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Add bottom border\n\t\tthis.addChild(new DynamicBorder());\n\n\t\t// Render the current snapshot immediately, then refresh in the background.\n\t\tthis.loadModelsFromSnapshot();\n\t\tthis.step = this.initialStep(initialSearchInput);\n\t\tthis.rebuildRows();\n\t\tthis.selectedIndex = this.defaultSelectedIndex();\n\t\tthis.renderHeader();\n\t\tthis.filterRows(this.searchInput.getValue());\n\t\tthis.tui.requestRender();\n\t\tvoid this.refreshModels();\n\t}\n\n\tprivate initialStep(initialSearchInput: string | undefined): Step {\n\t\tconst providers = this.activeProviders();\n\t\tif (initialSearchInput) return { kind: \"models\", provider: null };\n\t\tif (providers.length <= 1) return { kind: \"models\", provider: providers[0] ?? null };\n\t\treturn { kind: \"providers\" };\n\t}\n\n\tprivate activeProviders(): string[] {\n\t\treturn [...new Set(this.activeModels.map((item) => item.provider))];\n\t}\n\n\tprivate loadModelsFromSnapshot(): void {\n\t\tconst models = this.modelRuntime.getAvailableSnapshot().map((model: Model<any>) => ({\n\t\t\tprovider: model.provider,\n\t\t\tid: model.id,\n\t\t\tmodel,\n\t\t}));\n\t\tthis.allModels = this.sortModels(models);\n\t\tthis.scopedModels = this.scopedModels.map((scoped) => {\n\t\t\tconst refreshed = this.modelRuntime.getModel(scoped.model.provider, scoped.model.id);\n\t\t\treturn refreshed ? { ...scoped, model: refreshed } : scoped;\n\t\t});\n\t\tthis.scopedModelItems = this.scopedModels.map((scoped) => ({\n\t\t\tprovider: scoped.model.provider,\n\t\t\tid: scoped.model.id,\n\t\t\tmodel: scoped.model,\n\t\t}));\n\t\tthis.activeModels = this.scope === \"scoped\" ? this.scopedModelItems : this.allModels;\n\t}\n\n\tprivate async refreshModels(): Promise<void> {\n\t\tconst timeoutMs = 15_000;\n\t\tlet timedOut = false;\n\t\tthis.refreshTimeout = setTimeout(() => {\n\t\t\ttimedOut = true;\n\t\t\tthis.refreshAbortController.abort();\n\t\t}, timeoutMs);\n\t\ttry {\n\t\t\tconst result = await this.modelRuntime.refresh({ signal: this.refreshAbortController.signal });\n\t\t\tif (this.closed) return;\n\t\t\tthis.refreshStatusMessage = \"\";\n\t\t\tif (result.aborted && timedOut) {\n\t\t\t\tthis.errorMessage = \"Model refresh timed out; showing cached models.\";\n\t\t\t} else if (result.errors.size === 1) {\n\t\t\t\tthis.errorMessage = `Could not refresh ${result.errors.keys().next().value}; showing cached models.`;\n\t\t\t} else if (result.errors.size > 1) {\n\t\t\t\tthis.errorMessage = `Could not refresh ${result.errors.size} model catalogs (${[...result.errors.keys()].join(\", \")}); showing cached models.`;\n\t\t\t} else {\n\t\t\t\tthis.errorMessage = this.modelRuntime.getError();\n\t\t\t\tif (!this.errorMessage) {\n\t\t\t\t\tthis.refreshStatusMessage = \"Model catalogs refreshed.\";\n\t\t\t\t\tthis.refreshStatusSuccess = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.loadModelsFromSnapshot();\n\t\t\tthis.rebuildRows();\n\t\t\tthis.renderHeader();\n\t\t\tthis.filterRows(this.searchInput.getValue());\n\t\t\tthis.tui.requestRender();\n\t\t} catch (error) {\n\t\t\tif (this.closed) return;\n\t\t\tthis.refreshStatusMessage = \"\";\n\t\t\tthis.errorMessage = timedOut\n\t\t\t\t? \"Model refresh timed out; showing cached models.\"\n\t\t\t\t: `Could not refresh model catalogs: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\tthis.updateList();\n\t\t\tthis.tui.requestRender();\n\t\t} finally {\n\t\t\tif (this.refreshTimeout) clearTimeout(this.refreshTimeout);\n\t\t}\n\t}\n\n\tdispose(): void {\n\t\tif (this.closed) return;\n\t\tthis.closed = true;\n\t\tif (this.refreshTimeout) clearTimeout(this.refreshTimeout);\n\t\tthis.refreshAbortController.abort();\n\t}\n\n\tprivate sortModels(models: ModelItem[]): ModelItem[] {\n\t\tconst sorted = [...models];\n\t\t// Sort: current model first, then by provider\n\t\tsorted.sort((a, b) => {\n\t\t\tconst aIsCurrent = modelsAreEqual(this.currentModel, a.model);\n\t\t\tconst bIsCurrent = modelsAreEqual(this.currentModel, b.model);\n\t\t\tif (aIsCurrent && !bIsCurrent) return -1;\n\t\t\tif (!aIsCurrent && bIsCurrent) return 1;\n\t\t\treturn a.provider.localeCompare(b.provider);\n\t\t});\n\t\treturn sorted;\n\t}\n\n\tprivate rebuildRows(): void {\n\t\tif (this.step.kind === \"providers\") {\n\t\t\tconst byProvider = new Map<string, ModelItem[]>();\n\t\t\tfor (const item of this.activeModels) {\n\t\t\t\tconst existing = byProvider.get(item.provider);\n\t\t\t\tif (existing) existing.push(item);\n\t\t\t\telse byProvider.set(item.provider, [item]);\n\t\t\t}\n\t\t\tconst providerRows: Row[] = [...byProvider].map(([provider, items]) => ({\n\t\t\t\tkind: \"provider\",\n\t\t\t\tprovider,\n\t\t\t\tcount: items.length,\n\t\t\t\thasCurrent: items.some((item) => modelsAreEqual(this.currentModel, item.model)),\n\t\t\t}));\n\t\t\tproviderRows.sort((a, b) => {\n\t\t\t\tif (a.kind !== \"provider\" || b.kind !== \"provider\") return 0;\n\t\t\t\tif (a.hasCurrent !== b.hasCurrent) return a.hasCurrent ? -1 : 1;\n\t\t\t\treturn a.provider.localeCompare(b.provider);\n\t\t\t});\n\t\t\tthis.rows = providerRows;\n\t\t\treturn;\n\t\t}\n\t\tconst provider = this.step.provider;\n\t\tconst models = provider === null ? this.activeModels : this.activeModels.filter((m) => m.provider === provider);\n\t\tthis.rows = models.map((item) => ({ kind: \"model\", item }));\n\t}\n\n\tprivate defaultSelectedIndex(): number {\n\t\tconst index = this.rows.findIndex((row) =>\n\t\t\trow.kind === \"provider\" ? row.hasCurrent : modelsAreEqual(this.currentModel, row.item.model),\n\t\t);\n\t\treturn index >= 0 ? index : 0;\n\t}\n\n\tprivate setStep(step: Step): void {\n\t\tthis.step = step;\n\t\tthis.searchInput.setValue(\"\");\n\t\tthis.rebuildRows();\n\t\tthis.selectedIndex = this.defaultSelectedIndex();\n\t\tthis.renderHeader();\n\t\tthis.filterRows(\"\");\n\t\tthis.tui.requestRender();\n\t}\n\n\tprivate isDrilledIn(): boolean {\n\t\treturn this.step.kind === \"models\" && this.step.provider !== null;\n\t}\n\n\t/** Escape returns to the provider list whenever there is a provider list worth returning to. */\n\tprivate canGoBack(): boolean {\n\t\treturn this.step.kind === \"models\" && this.activeProviders().length > 1;\n\t}\n\n\tprivate renderHeader(): void {\n\t\tthis.headerContainer.clear();\n\n\t\tif (this.step.kind === \"providers\") {\n\t\t\tthis.headerContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"Select a provider\")), 0, 0));\n\t\t} else {\n\t\t\tconst label = this.step.provider ?? \"All providers\";\n\t\t\tconst crumb = `${theme.bold(theme.fg(\"accent\", label))}${theme.fg(\"muted\", \" › select a model\")}`;\n\t\t\tthis.headerContainer.addChild(new Text(crumb, 0, 0));\n\t\t}\n\n\t\tif (this.scopedModelItems.length > 0) {\n\t\t\tthis.headerContainer.addChild(new Text(this.getScopeText(), 0, 0));\n\t\t} else if (!this.isDrilledIn()) {\n\t\t\tconst hintText = \"Only showing models from configured providers. Use /login to add providers.\";\n\t\t\tthis.headerContainer.addChild(new Text(theme.fg(\"warning\", hintText), 0, 0));\n\t\t}\n\n\t\tthis.headerContainer.addChild(new Text(this.getHintText(), 0, 0));\n\t}\n\n\tprivate getScopeText(): string {\n\t\tconst allText = this.scope === \"all\" ? theme.fg(\"accent\", \"all\") : theme.fg(\"muted\", \"all\");\n\t\tconst scopedText = this.scope === \"scoped\" ? theme.fg(\"accent\", \"scoped\") : theme.fg(\"muted\", \"scoped\");\n\t\treturn `${theme.fg(\"muted\", \"Scope: \")}${allText}${theme.fg(\"muted\", \" | \")}${scopedText}`;\n\t}\n\n\tprivate getHintText(): string {\n\t\tconst hints: string[] = [];\n\t\tif (this.scopedModelItems.length > 0) {\n\t\t\thints.push(keyHint(\"tui.input.tab\", \"scope\") + theme.fg(\"muted\", \" (all/scoped)\"));\n\t\t}\n\t\tif (this.canGoBack()) hints.push(rawKeyHint(\"escape\", \"providers\"), rawKeyHint(\"ctrl+c\", \"close\"));\n\t\telse hints.push(keyHint(\"tui.select.cancel\", \"close\"));\n\t\treturn hints.join(theme.fg(\"muted\", \" · \"));\n\t}\n\n\tprivate setScope(scope: ModelScope): void {\n\t\tif (this.scope === scope) return;\n\t\tthis.scope = scope;\n\t\tthis.activeModels = this.scope === \"scoped\" ? this.scopedModelItems : this.allModels;\n\t\tthis.rebuildRows();\n\t\tthis.selectedIndex = this.defaultSelectedIndex();\n\t\tthis.renderHeader();\n\t\tthis.filterRows(this.searchInput.getValue());\n\t}\n\n\tprivate rowSearchText(row: Row): string {\n\t\tif (row.kind === \"provider\") return row.provider;\n\t\treturn getModelSelectorSearchText({ id: row.item.id, provider: row.item.provider, name: row.item.model.name });\n\t}\n\n\tprivate filterRows(query: string): void {\n\t\tthis.filteredRows = query ? fuzzyFilter(this.rows, query, (row) => this.rowSearchText(row)) : this.rows;\n\t\t// When filtering by a query, move the selector to the top row so the best\n\t\t// match is highlighted. When the query is cleared, keep the current position\n\t\t// clamped to the (restored) list length.\n\t\tthis.selectedIndex = query ? 0 : Math.min(this.selectedIndex, Math.max(0, this.filteredRows.length - 1));\n\t\tthis.updateList();\n\t}\n\n\tprivate renderRow(row: Row, isSelected: boolean): string {\n\t\tconst prefix = isSelected ? theme.fg(\"accent\", \"→ \") : \" \";\n\t\tif (row.kind === \"provider\") {\n\t\t\tconst label = isSelected ? theme.fg(\"accent\", row.provider) : row.provider;\n\t\t\tconst count = theme.fg(\"muted\", ` (${row.count} model${row.count === 1 ? \"\" : \"s\"})`);\n\t\t\tconst checkmark = row.hasCurrent ? theme.fg(\"success\", \" ✓\") : \"\";\n\t\t\treturn `${prefix}${label}${count}${checkmark}`;\n\t\t}\n\t\tconst label = isSelected ? theme.fg(\"accent\", row.item.id) : row.item.id;\n\t\tconst showProvider = this.step.kind === \"models\" && this.step.provider === null;\n\t\tconst badge = showProvider ? ` ${theme.fg(\"muted\", `[${row.item.provider}]`)}` : \"\";\n\t\tconst checkmark = modelsAreEqual(this.currentModel, row.item.model) ? theme.fg(\"success\", \" ✓\") : \"\";\n\t\treturn `${prefix}${label}${badge}${checkmark}`;\n\t}\n\n\tprivate updateList(): void {\n\t\tthis.listContainer.clear();\n\n\t\tconst startIndex = Math.max(\n\t\t\t0,\n\t\t\tMath.min(this.selectedIndex - Math.floor(MAX_VISIBLE_ROWS / 2), this.filteredRows.length - MAX_VISIBLE_ROWS),\n\t\t);\n\t\tconst endIndex = Math.min(startIndex + MAX_VISIBLE_ROWS, this.filteredRows.length);\n\n\t\tfor (let i = startIndex; i < endIndex; i++) {\n\t\t\tconst row = this.filteredRows[i];\n\t\t\tif (!row) continue;\n\t\t\tthis.listContainer.addChild(new Text(this.renderRow(row, i === this.selectedIndex), 0, 0));\n\t\t}\n\n\t\t// Add scroll indicator if needed\n\t\tif (startIndex > 0 || endIndex < this.filteredRows.length) {\n\t\t\tconst scrollInfo = theme.fg(\"muted\", ` (${this.selectedIndex + 1}/${this.filteredRows.length})`);\n\t\t\tthis.listContainer.addChild(new Text(scrollInfo, 0, 0));\n\t\t}\n\n\t\t// Show error message or \"no results\" if empty\n\t\tif (this.errorMessage) {\n\t\t\t// Show error in red\n\t\t\tconst errorLines = this.errorMessage.split(\"\\n\");\n\t\t\tfor (const line of errorLines) {\n\t\t\t\tthis.listContainer.addChild(new Text(theme.fg(\"error\", line), 0, 0));\n\t\t\t}\n\t\t} else if (this.filteredRows.length === 0) {\n\t\t\tconst empty = this.step.kind === \"providers\" ? \" No matching providers\" : \" No matching models\";\n\t\t\tthis.listContainer.addChild(new Text(theme.fg(\"muted\", empty), 0, 0));\n\t\t} else {\n\t\t\tconst selected = this.filteredRows[this.selectedIndex];\n\t\t\tif (selected?.kind === \"model\") {\n\t\t\t\tthis.listContainer.addChild(new Spacer(1));\n\t\t\t\tthis.listContainer.addChild(new Text(theme.fg(\"muted\", ` Model Name: ${selected.item.model.name}`), 0, 0));\n\t\t\t}\n\t\t}\n\t\tif (this.refreshStatusMessage) {\n\t\t\tthis.listContainer.addChild(new Spacer(1));\n\t\t\tthis.listContainer.addChild(\n\t\t\t\tnew Text(theme.fg(this.refreshStatusSuccess ? \"success\" : \"muted\", ` ${this.refreshStatusMessage}`), 0, 0),\n\t\t\t);\n\t\t}\n\t}\n\n\thandleInput(keyData: string): void {\n\t\tconst kb = getKeybindings();\n\t\tif (kb.matches(keyData, \"tui.input.tab\")) {\n\t\t\tif (this.scopedModelItems.length > 0) {\n\t\t\t\tthis.setScope(this.scope === \"all\" ? \"scoped\" : \"all\");\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\t// Up arrow - wrap to bottom when at top\n\t\tif (kb.matches(keyData, \"tui.select.up\")) {\n\t\t\tif (this.filteredRows.length === 0) return;\n\t\t\tthis.selectedIndex = this.selectedIndex === 0 ? this.filteredRows.length - 1 : this.selectedIndex - 1;\n\t\t\tthis.updateList();\n\t\t}\n\t\t// Down arrow - wrap to top when at bottom\n\t\telse if (kb.matches(keyData, \"tui.select.down\")) {\n\t\t\tif (this.filteredRows.length === 0) return;\n\t\t\tthis.selectedIndex = this.selectedIndex === this.filteredRows.length - 1 ? 0 : this.selectedIndex + 1;\n\t\t\tthis.updateList();\n\t\t}\n\t\t// Enter\n\t\telse if (kb.matches(keyData, \"tui.select.confirm\")) {\n\t\t\tthis.confirmSelection();\n\t\t}\n\t\t// Escape or Ctrl+C\n\t\telse if (kb.matches(keyData, \"tui.select.cancel\")) {\n\t\t\t// Escape steps back through the two levels; Ctrl+C always closes.\n\t\t\tif (matchesKey(keyData, Key.escape) && this.canGoBack()) {\n\t\t\t\tthis.setStep({ kind: \"providers\" });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.dispose();\n\t\t\tthis.onCancelCallback();\n\t\t}\n\t\t// Pass everything else to search input\n\t\telse {\n\t\t\tthis.searchInput.handleInput(keyData);\n\t\t\tthis.filterRows(this.searchInput.getValue());\n\t\t}\n\t}\n\n\tprivate confirmSelection(): void {\n\t\tconst row = this.filteredRows[this.selectedIndex];\n\t\tif (!row) return;\n\t\tif (row.kind === \"provider\") {\n\t\t\tthis.setStep({ kind: \"models\", provider: row.provider });\n\t\t\treturn;\n\t\t}\n\t\tthis.handleSelect(row.item.model);\n\t}\n\n\tprivate handleSelect(model: Model<any>): void {\n\t\tthis.dispose();\n\t\t// Save as new default\n\t\tthis.settingsManager.setDefaultModelAndProvider(model.provider, model.id);\n\t\tthis.onSelectCallback(model);\n\t}\n\n\tgetSearchInput(): Input {\n\t\treturn this.searchInput;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type Component } from "@earendil-works/pi-tui";
|
|
2
|
+
/** One `label value` row in the metadata column. */
|
|
3
|
+
export interface SplashHeaderMetadataLine {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ApexSplashHeaderOptions {
|
|
8
|
+
/** Rows appended after `cwd`, for extensions that want to contribute context. */
|
|
9
|
+
getExtraMetadata?: () => readonly SplashHeaderMetadataLine[];
|
|
10
|
+
/** Hint rendered under the metadata block. Return undefined for none. */
|
|
11
|
+
getHint?: () => string | undefined;
|
|
12
|
+
/** Resolves `terminal.symbolPreset`. Defaults to unicode. */
|
|
13
|
+
getSymbolPreset?: () => "unicode" | "ascii";
|
|
14
|
+
/** Emit a leading blank line above the mark. */
|
|
15
|
+
topPadding?: boolean;
|
|
16
|
+
/** Override the mark. Used by tests and by extensions that rebrand. */
|
|
17
|
+
logo?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Startup header: brand mark on the left, runtime metadata on the right.
|
|
21
|
+
*
|
|
22
|
+
* Values are read through getters rather than captured at construction, so the
|
|
23
|
+
* model fills in once the session binds without an explicit refresh.
|
|
24
|
+
*
|
|
25
|
+
* The metadata column is dropped when the terminal cannot hold it, and the mark
|
|
26
|
+
* falls back to a compact variant rather than being truncated mid-glyph.
|
|
27
|
+
*/
|
|
28
|
+
export declare class ApexSplashHeader implements Component {
|
|
29
|
+
private readonly version;
|
|
30
|
+
private readonly getModelId;
|
|
31
|
+
private readonly getCwd;
|
|
32
|
+
private readonly verboseInstructions;
|
|
33
|
+
private readonly options;
|
|
34
|
+
constructor(version: string, getModelId: () => string | undefined, getCwd: () => string, verboseInstructions?: string, options?: ApexSplashHeaderOptions);
|
|
35
|
+
invalidate(): void;
|
|
36
|
+
render(width: number): string[];
|
|
37
|
+
private selectLogo;
|
|
38
|
+
private buildMetadata;
|
|
39
|
+
private padLine;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=splash-header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splash-header.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/splash-header.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAiC,MAAM,wBAAwB,CAAC;AAKvF,qDAAqD;AACrD,MAAM,WAAW,wBAAwB;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,uBAAuB;IACvC,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,MAAM,SAAS,wBAAwB,EAAE,CAAC;IAC7D,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACnC,6DAA6D;IAC7D,eAAe,CAAC,EAAE,MAAM,SAAS,GAAG,OAAO,CAAC;IAC5C,gDAAgD;IAChD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AA8DD;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,YAAW,SAAS;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA2B;IACtD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAqB;IACzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;IAElD,YACC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,MAAM,GAAG,SAAS,EACpC,MAAM,EAAE,MAAM,MAAM,EACpB,mBAAmB,CAAC,EAAE,MAAM,EAC5B,OAAO,GAAE,uBAA4B,EAOrC;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAwC9B;IAED,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,OAAO;CAIf","sourcesContent":["import { type Component, truncateToWidth, visibleWidth } from \"@earendil-works/pi-tui\";\nimport { APEX_PEAK_LOGO, APEX_PEAK_LOGO_ASCII, APEX_PEAK_LOGO_COMPACT } from \"../../../themes/apex-logo.ts\";\nimport { theme } from \"../theme/theme.ts\";\nimport { formatCwdForFooter } from \"./footer.ts\";\n\n/** One `label value` row in the metadata column. */\nexport interface SplashHeaderMetadataLine {\n\tlabel: string;\n\tvalue: string;\n}\n\nexport interface ApexSplashHeaderOptions {\n\t/** Rows appended after `cwd`, for extensions that want to contribute context. */\n\tgetExtraMetadata?: () => readonly SplashHeaderMetadataLine[];\n\t/** Hint rendered under the metadata block. Return undefined for none. */\n\tgetHint?: () => string | undefined;\n\t/** Resolves `terminal.symbolPreset`. Defaults to unicode. */\n\tgetSymbolPreset?: () => \"unicode\" | \"ascii\";\n\t/** Emit a leading blank line above the mark. */\n\ttopPadding?: boolean;\n\t/** Override the mark. Used by tests and by extensions that rebrand. */\n\tlogo?: string;\n}\n\nconst GUTTER = 4;\nconst LABEL_WIDTH = 9;\n/** Smallest value column worth rendering; below this the metadata column is dropped. */\nconst MIN_VALUE_WIDTH = 8;\n\n/**\n * Keep the rightmost path segments that fit, so the leaf directory stays visible.\n *\n * `truncateToWidth` clips the tail, which for a path hides the part that\n * identifies the session. This clips the head instead.\n */\nfunction truncatePathTail(path: string, maxWidth: number): string {\n\tif (maxWidth <= 0) {\n\t\treturn \"\";\n\t}\n\tif (visibleWidth(path) <= maxWidth) {\n\t\treturn path;\n\t}\n\tconst ellipsis = \"…/\";\n\tconst budget = Math.max(0, maxWidth - visibleWidth(ellipsis));\n\tconst segments = path.split(\"/\");\n\tlet tail = \"\";\n\tfor (let index = segments.length - 1; index >= 0; index--) {\n\t\tconst candidate = tail ? `${segments[index]}/${tail}` : segments[index];\n\t\tif (visibleWidth(candidate) > budget) {\n\t\t\tbreak;\n\t\t}\n\t\ttail = candidate;\n\t}\n\t// A single segment longer than the whole budget: clip it from the left.\n\treturn tail ? ellipsis + tail : ellipsis + trailingByWidth(path, budget);\n}\n\n/**\n * The widest suffix of `text` that fits `maxWidth` terminal columns.\n *\n * Walks grapheme clusters from the right rather than using `String.slice`, whose\n * UTF-16 offsets would cut an astral character in half — emitting a lone\n * surrogate — and would miscount every double-width character on the way.\n */\nfunction trailingByWidth(text: string, maxWidth: number): string {\n\tif (maxWidth <= 0) {\n\t\treturn \"\";\n\t}\n\tconst graphemes = [...new Intl.Segmenter(undefined, { granularity: \"grapheme\" }).segment(text)].map(\n\t\t(entry) => entry.segment,\n\t);\n\tlet width = 0;\n\tlet index = graphemes.length;\n\twhile (index > 0) {\n\t\tconst next = width + visibleWidth(graphemes[index - 1]);\n\t\tif (next > maxWidth) {\n\t\t\tbreak;\n\t\t}\n\t\twidth = next;\n\t\tindex -= 1;\n\t}\n\treturn graphemes.slice(index).join(\"\");\n}\n\n/**\n * Startup header: brand mark on the left, runtime metadata on the right.\n *\n * Values are read through getters rather than captured at construction, so the\n * model fills in once the session binds without an explicit refresh.\n *\n * The metadata column is dropped when the terminal cannot hold it, and the mark\n * falls back to a compact variant rather than being truncated mid-glyph.\n */\nexport class ApexSplashHeader implements Component {\n\tprivate readonly version: string;\n\tprivate readonly getModelId: () => string | undefined;\n\tprivate readonly getCwd: () => string;\n\tprivate readonly verboseInstructions: string | undefined;\n\tprivate readonly options: ApexSplashHeaderOptions;\n\n\tconstructor(\n\t\tversion: string,\n\t\tgetModelId: () => string | undefined,\n\t\tgetCwd: () => string,\n\t\tverboseInstructions?: string,\n\t\toptions: ApexSplashHeaderOptions = {},\n\t) {\n\t\tthis.version = version;\n\t\tthis.getModelId = getModelId;\n\t\tthis.getCwd = getCwd;\n\t\tthis.verboseInstructions = verboseInstructions;\n\t\tthis.options = options;\n\t}\n\n\tinvalidate(): void {\n\t\t// Render output is derived from current theme and session state.\n\t}\n\n\trender(width: number): string[] {\n\t\tconst safeWidth = Math.max(1, width);\n\t\tconst paddingX = safeWidth > 1 ? 1 : 0;\n\t\tconst contentWidth = Math.max(1, safeWidth - paddingX * 2);\n\n\t\tconst logoLines = this.selectLogo(contentWidth);\n\t\tconst logoWidth = logoLines.reduce((max, line) => Math.max(max, visibleWidth(line)), 0);\n\n\t\tconst metaWidth = contentWidth - logoWidth - GUTTER;\n\t\tconst showMeta = metaWidth >= LABEL_WIDTH + MIN_VALUE_WIDTH;\n\t\tconst valueWidth = Math.max(1, metaWidth - LABEL_WIDTH);\n\t\tconst metaLines = showMeta ? this.buildMetadata(valueWidth) : [];\n\t\tconst metaStart = Math.max(0, Math.floor((logoLines.length - metaLines.length) / 2));\n\n\t\tconst lines = this.options.topPadding ? [this.padLine(\"\", safeWidth, paddingX)] : [];\n\n\t\tlogoLines.forEach((line, index) => {\n\t\t\tconst meta = index >= metaStart && index < metaStart + metaLines.length ? metaLines[index - metaStart] : \"\";\n\t\t\tconst gap = showMeta ? \" \".repeat(Math.max(0, logoWidth - visibleWidth(line) + GUTTER)) : \"\";\n\t\t\tconst content = truncateToWidth(theme.fg(\"text\", line) + gap + meta, contentWidth, \"\");\n\t\t\tlines.push(this.padLine(content, safeWidth, paddingX));\n\t\t});\n\n\t\t// The hint is product copy rather than a runtime fact, so it sits under the\n\t\t// whole block at full width instead of inside the narrow metadata column,\n\t\t// where it would truncate even on a wide terminal.\n\t\tconst hint = this.options.getHint?.();\n\t\tif (hint) {\n\t\t\tlines.push(this.padLine(\"\", safeWidth, paddingX));\n\t\t\tlines.push(this.padLine(theme.fg(\"dim\", truncateToWidth(hint, contentWidth)), safeWidth, paddingX));\n\t\t}\n\n\t\tif (this.verboseInstructions) {\n\t\t\tlines.push(this.padLine(\"\", safeWidth, paddingX));\n\t\t\tfor (const instruction of this.verboseInstructions.split(\"\\n\")) {\n\t\t\t\tlines.push(this.padLine(truncateToWidth(instruction, contentWidth), safeWidth, paddingX));\n\t\t\t}\n\t\t}\n\n\t\treturn lines;\n\t}\n\n\tprivate selectLogo(contentWidth: number): string[] {\n\t\tif (this.options.logo) {\n\t\t\treturn this.options.logo.split(\"\\n\");\n\t\t}\n\t\tif (this.options.getSymbolPreset?.() === \"ascii\") {\n\t\t\treturn APEX_PEAK_LOGO_ASCII.split(\"\\n\");\n\t\t}\n\t\tconst full = APEX_PEAK_LOGO.split(\"\\n\");\n\t\tconst fullWidth = full.reduce((max, line) => Math.max(max, visibleWidth(line)), 0);\n\t\treturn contentWidth >= fullWidth ? full : APEX_PEAK_LOGO_COMPACT.split(\"\\n\");\n\t}\n\n\tprivate buildMetadata(valueWidth: number): string[] {\n\t\tconst labelled = (label: string, value: string) =>\n\t\t\ttheme.fg(\"dim\", label.padEnd(LABEL_WIDTH)) + theme.fg(\"muted\", truncateToWidth(value, valueWidth));\n\n\t\tconst cwd = formatCwdForFooter(this.getCwd(), process.env.HOME || process.env.USERPROFILE);\n\t\treturn [\n\t\t\tlabelled(\"version\", `v${this.version}`),\n\t\t\tlabelled(\"model\", this.getModelId() ?? \"—\"),\n\t\t\ttheme.fg(\"dim\", \"cwd\".padEnd(LABEL_WIDTH)) + theme.fg(\"muted\", truncatePathTail(cwd, valueWidth)),\n\t\t\t...(this.options.getExtraMetadata?.() ?? []).map((line) => labelled(line.label, line.value)),\n\t\t];\n\t}\n\n\tprivate padLine(content: string, safeWidth: number, paddingX: number): string {\n\t\tconst trailing = Math.max(0, safeWidth - paddingX - visibleWidth(content));\n\t\treturn \" \".repeat(paddingX) + content + \" \".repeat(trailing);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
2
|
+
import { APEX_PEAK_LOGO, APEX_PEAK_LOGO_ASCII, APEX_PEAK_LOGO_COMPACT } from "../../../themes/apex-logo.js";
|
|
3
|
+
import { theme } from "../theme/theme.js";
|
|
4
|
+
import { formatCwdForFooter } from "./footer.js";
|
|
5
|
+
const GUTTER = 4;
|
|
6
|
+
const LABEL_WIDTH = 9;
|
|
7
|
+
/** Smallest value column worth rendering; below this the metadata column is dropped. */
|
|
8
|
+
const MIN_VALUE_WIDTH = 8;
|
|
9
|
+
/**
|
|
10
|
+
* Keep the rightmost path segments that fit, so the leaf directory stays visible.
|
|
11
|
+
*
|
|
12
|
+
* `truncateToWidth` clips the tail, which for a path hides the part that
|
|
13
|
+
* identifies the session. This clips the head instead.
|
|
14
|
+
*/
|
|
15
|
+
function truncatePathTail(path, maxWidth) {
|
|
16
|
+
if (maxWidth <= 0) {
|
|
17
|
+
return "";
|
|
18
|
+
}
|
|
19
|
+
if (visibleWidth(path) <= maxWidth) {
|
|
20
|
+
return path;
|
|
21
|
+
}
|
|
22
|
+
const ellipsis = "…/";
|
|
23
|
+
const budget = Math.max(0, maxWidth - visibleWidth(ellipsis));
|
|
24
|
+
const segments = path.split("/");
|
|
25
|
+
let tail = "";
|
|
26
|
+
for (let index = segments.length - 1; index >= 0; index--) {
|
|
27
|
+
const candidate = tail ? `${segments[index]}/${tail}` : segments[index];
|
|
28
|
+
if (visibleWidth(candidate) > budget) {
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
tail = candidate;
|
|
32
|
+
}
|
|
33
|
+
// A single segment longer than the whole budget: clip it from the left.
|
|
34
|
+
return tail ? ellipsis + tail : ellipsis + trailingByWidth(path, budget);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The widest suffix of `text` that fits `maxWidth` terminal columns.
|
|
38
|
+
*
|
|
39
|
+
* Walks grapheme clusters from the right rather than using `String.slice`, whose
|
|
40
|
+
* UTF-16 offsets would cut an astral character in half — emitting a lone
|
|
41
|
+
* surrogate — and would miscount every double-width character on the way.
|
|
42
|
+
*/
|
|
43
|
+
function trailingByWidth(text, maxWidth) {
|
|
44
|
+
if (maxWidth <= 0) {
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
const graphemes = [...new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(text)].map((entry) => entry.segment);
|
|
48
|
+
let width = 0;
|
|
49
|
+
let index = graphemes.length;
|
|
50
|
+
while (index > 0) {
|
|
51
|
+
const next = width + visibleWidth(graphemes[index - 1]);
|
|
52
|
+
if (next > maxWidth) {
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
width = next;
|
|
56
|
+
index -= 1;
|
|
57
|
+
}
|
|
58
|
+
return graphemes.slice(index).join("");
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Startup header: brand mark on the left, runtime metadata on the right.
|
|
62
|
+
*
|
|
63
|
+
* Values are read through getters rather than captured at construction, so the
|
|
64
|
+
* model fills in once the session binds without an explicit refresh.
|
|
65
|
+
*
|
|
66
|
+
* The metadata column is dropped when the terminal cannot hold it, and the mark
|
|
67
|
+
* falls back to a compact variant rather than being truncated mid-glyph.
|
|
68
|
+
*/
|
|
69
|
+
export class ApexSplashHeader {
|
|
70
|
+
version;
|
|
71
|
+
getModelId;
|
|
72
|
+
getCwd;
|
|
73
|
+
verboseInstructions;
|
|
74
|
+
options;
|
|
75
|
+
constructor(version, getModelId, getCwd, verboseInstructions, options = {}) {
|
|
76
|
+
this.version = version;
|
|
77
|
+
this.getModelId = getModelId;
|
|
78
|
+
this.getCwd = getCwd;
|
|
79
|
+
this.verboseInstructions = verboseInstructions;
|
|
80
|
+
this.options = options;
|
|
81
|
+
}
|
|
82
|
+
invalidate() {
|
|
83
|
+
// Render output is derived from current theme and session state.
|
|
84
|
+
}
|
|
85
|
+
render(width) {
|
|
86
|
+
const safeWidth = Math.max(1, width);
|
|
87
|
+
const paddingX = safeWidth > 1 ? 1 : 0;
|
|
88
|
+
const contentWidth = Math.max(1, safeWidth - paddingX * 2);
|
|
89
|
+
const logoLines = this.selectLogo(contentWidth);
|
|
90
|
+
const logoWidth = logoLines.reduce((max, line) => Math.max(max, visibleWidth(line)), 0);
|
|
91
|
+
const metaWidth = contentWidth - logoWidth - GUTTER;
|
|
92
|
+
const showMeta = metaWidth >= LABEL_WIDTH + MIN_VALUE_WIDTH;
|
|
93
|
+
const valueWidth = Math.max(1, metaWidth - LABEL_WIDTH);
|
|
94
|
+
const metaLines = showMeta ? this.buildMetadata(valueWidth) : [];
|
|
95
|
+
const metaStart = Math.max(0, Math.floor((logoLines.length - metaLines.length) / 2));
|
|
96
|
+
const lines = this.options.topPadding ? [this.padLine("", safeWidth, paddingX)] : [];
|
|
97
|
+
logoLines.forEach((line, index) => {
|
|
98
|
+
const meta = index >= metaStart && index < metaStart + metaLines.length ? metaLines[index - metaStart] : "";
|
|
99
|
+
const gap = showMeta ? " ".repeat(Math.max(0, logoWidth - visibleWidth(line) + GUTTER)) : "";
|
|
100
|
+
const content = truncateToWidth(theme.fg("text", line) + gap + meta, contentWidth, "");
|
|
101
|
+
lines.push(this.padLine(content, safeWidth, paddingX));
|
|
102
|
+
});
|
|
103
|
+
// The hint is product copy rather than a runtime fact, so it sits under the
|
|
104
|
+
// whole block at full width instead of inside the narrow metadata column,
|
|
105
|
+
// where it would truncate even on a wide terminal.
|
|
106
|
+
const hint = this.options.getHint?.();
|
|
107
|
+
if (hint) {
|
|
108
|
+
lines.push(this.padLine("", safeWidth, paddingX));
|
|
109
|
+
lines.push(this.padLine(theme.fg("dim", truncateToWidth(hint, contentWidth)), safeWidth, paddingX));
|
|
110
|
+
}
|
|
111
|
+
if (this.verboseInstructions) {
|
|
112
|
+
lines.push(this.padLine("", safeWidth, paddingX));
|
|
113
|
+
for (const instruction of this.verboseInstructions.split("\n")) {
|
|
114
|
+
lines.push(this.padLine(truncateToWidth(instruction, contentWidth), safeWidth, paddingX));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return lines;
|
|
118
|
+
}
|
|
119
|
+
selectLogo(contentWidth) {
|
|
120
|
+
if (this.options.logo) {
|
|
121
|
+
return this.options.logo.split("\n");
|
|
122
|
+
}
|
|
123
|
+
if (this.options.getSymbolPreset?.() === "ascii") {
|
|
124
|
+
return APEX_PEAK_LOGO_ASCII.split("\n");
|
|
125
|
+
}
|
|
126
|
+
const full = APEX_PEAK_LOGO.split("\n");
|
|
127
|
+
const fullWidth = full.reduce((max, line) => Math.max(max, visibleWidth(line)), 0);
|
|
128
|
+
return contentWidth >= fullWidth ? full : APEX_PEAK_LOGO_COMPACT.split("\n");
|
|
129
|
+
}
|
|
130
|
+
buildMetadata(valueWidth) {
|
|
131
|
+
const labelled = (label, value) => theme.fg("dim", label.padEnd(LABEL_WIDTH)) + theme.fg("muted", truncateToWidth(value, valueWidth));
|
|
132
|
+
const cwd = formatCwdForFooter(this.getCwd(), process.env.HOME || process.env.USERPROFILE);
|
|
133
|
+
return [
|
|
134
|
+
labelled("version", `v${this.version}`),
|
|
135
|
+
labelled("model", this.getModelId() ?? "—"),
|
|
136
|
+
theme.fg("dim", "cwd".padEnd(LABEL_WIDTH)) + theme.fg("muted", truncatePathTail(cwd, valueWidth)),
|
|
137
|
+
...(this.options.getExtraMetadata?.() ?? []).map((line) => labelled(line.label, line.value)),
|
|
138
|
+
];
|
|
139
|
+
}
|
|
140
|
+
padLine(content, safeWidth, paddingX) {
|
|
141
|
+
const trailing = Math.max(0, safeWidth - paddingX - visibleWidth(content));
|
|
142
|
+
return " ".repeat(paddingX) + content + " ".repeat(trailing);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=splash-header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splash-header.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/splash-header.ts"],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AAC,CAAC;QAC3E,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAAA,CAC7D;CACD","sourcesContent":["import { type Component, truncateToWidth, visibleWidth } from \"@earendil-works/pi-tui\";\nimport { APEX_PEAK_LOGO, APEX_PEAK_LOGO_ASCII, APEX_PEAK_LOGO_COMPACT } from \"../../../themes/apex-logo.ts\";\nimport { theme } from \"../theme/theme.ts\";\nimport { formatCwdForFooter } from \"./footer.ts\";\n\n/** One `label value` row in the metadata column. */\nexport interface SplashHeaderMetadataLine {\n\tlabel: string;\n\tvalue: string;\n}\n\nexport interface ApexSplashHeaderOptions {\n\t/** Rows appended after `cwd`, for extensions that want to contribute context. */\n\tgetExtraMetadata?: () => readonly SplashHeaderMetadataLine[];\n\t/** Hint rendered under the metadata block. Return undefined for none. */\n\tgetHint?: () => string | undefined;\n\t/** Resolves `terminal.symbolPreset`. Defaults to unicode. */\n\tgetSymbolPreset?: () => \"unicode\" | \"ascii\";\n\t/** Emit a leading blank line above the mark. */\n\ttopPadding?: boolean;\n\t/** Override the mark. Used by tests and by extensions that rebrand. */\n\tlogo?: string;\n}\n\nconst GUTTER = 4;\nconst LABEL_WIDTH = 9;\n/** Smallest value column worth rendering; below this the metadata column is dropped. */\nconst MIN_VALUE_WIDTH = 8;\n\n/**\n * Keep the rightmost path segments that fit, so the leaf directory stays visible.\n *\n * `truncateToWidth` clips the tail, which for a path hides the part that\n * identifies the session. This clips the head instead.\n */\nfunction truncatePathTail(path: string, maxWidth: number): string {\n\tif (maxWidth <= 0) {\n\t\treturn \"\";\n\t}\n\tif (visibleWidth(path) <= maxWidth) {\n\t\treturn path;\n\t}\n\tconst ellipsis = \"…/\";\n\tconst budget = Math.max(0, maxWidth - visibleWidth(ellipsis));\n\tconst segments = path.split(\"/\");\n\tlet tail = \"\";\n\tfor (let index = segments.length - 1; index >= 0; index--) {\n\t\tconst candidate = tail ? `${segments[index]}/${tail}` : segments[index];\n\t\tif (visibleWidth(candidate) > budget) {\n\t\t\tbreak;\n\t\t}\n\t\ttail = candidate;\n\t}\n\t// A single segment longer than the whole budget: clip it from the left.\n\treturn tail ? ellipsis + tail : ellipsis + trailingByWidth(path, budget);\n}\n\n/**\n * The widest suffix of `text` that fits `maxWidth` terminal columns.\n *\n * Walks grapheme clusters from the right rather than using `String.slice`, whose\n * UTF-16 offsets would cut an astral character in half — emitting a lone\n * surrogate — and would miscount every double-width character on the way.\n */\nfunction trailingByWidth(text: string, maxWidth: number): string {\n\tif (maxWidth <= 0) {\n\t\treturn \"\";\n\t}\n\tconst graphemes = [...new Intl.Segmenter(undefined, { granularity: \"grapheme\" }).segment(text)].map(\n\t\t(entry) => entry.segment,\n\t);\n\tlet width = 0;\n\tlet index = graphemes.length;\n\twhile (index > 0) {\n\t\tconst next = width + visibleWidth(graphemes[index - 1]);\n\t\tif (next > maxWidth) {\n\t\t\tbreak;\n\t\t}\n\t\twidth = next;\n\t\tindex -= 1;\n\t}\n\treturn graphemes.slice(index).join(\"\");\n}\n\n/**\n * Startup header: brand mark on the left, runtime metadata on the right.\n *\n * Values are read through getters rather than captured at construction, so the\n * model fills in once the session binds without an explicit refresh.\n *\n * The metadata column is dropped when the terminal cannot hold it, and the mark\n * falls back to a compact variant rather than being truncated mid-glyph.\n */\nexport class ApexSplashHeader implements Component {\n\tprivate readonly version: string;\n\tprivate readonly getModelId: () => string | undefined;\n\tprivate readonly getCwd: () => string;\n\tprivate readonly verboseInstructions: string | undefined;\n\tprivate readonly options: ApexSplashHeaderOptions;\n\n\tconstructor(\n\t\tversion: string,\n\t\tgetModelId: () => string | undefined,\n\t\tgetCwd: () => string,\n\t\tverboseInstructions?: string,\n\t\toptions: ApexSplashHeaderOptions = {},\n\t) {\n\t\tthis.version = version;\n\t\tthis.getModelId = getModelId;\n\t\tthis.getCwd = getCwd;\n\t\tthis.verboseInstructions = verboseInstructions;\n\t\tthis.options = options;\n\t}\n\n\tinvalidate(): void {\n\t\t// Render output is derived from current theme and session state.\n\t}\n\n\trender(width: number): string[] {\n\t\tconst safeWidth = Math.max(1, width);\n\t\tconst paddingX = safeWidth > 1 ? 1 : 0;\n\t\tconst contentWidth = Math.max(1, safeWidth - paddingX * 2);\n\n\t\tconst logoLines = this.selectLogo(contentWidth);\n\t\tconst logoWidth = logoLines.reduce((max, line) => Math.max(max, visibleWidth(line)), 0);\n\n\t\tconst metaWidth = contentWidth - logoWidth - GUTTER;\n\t\tconst showMeta = metaWidth >= LABEL_WIDTH + MIN_VALUE_WIDTH;\n\t\tconst valueWidth = Math.max(1, metaWidth - LABEL_WIDTH);\n\t\tconst metaLines = showMeta ? this.buildMetadata(valueWidth) : [];\n\t\tconst metaStart = Math.max(0, Math.floor((logoLines.length - metaLines.length) / 2));\n\n\t\tconst lines = this.options.topPadding ? [this.padLine(\"\", safeWidth, paddingX)] : [];\n\n\t\tlogoLines.forEach((line, index) => {\n\t\t\tconst meta = index >= metaStart && index < metaStart + metaLines.length ? metaLines[index - metaStart] : \"\";\n\t\t\tconst gap = showMeta ? \" \".repeat(Math.max(0, logoWidth - visibleWidth(line) + GUTTER)) : \"\";\n\t\t\tconst content = truncateToWidth(theme.fg(\"text\", line) + gap + meta, contentWidth, \"\");\n\t\t\tlines.push(this.padLine(content, safeWidth, paddingX));\n\t\t});\n\n\t\t// The hint is product copy rather than a runtime fact, so it sits under the\n\t\t// whole block at full width instead of inside the narrow metadata column,\n\t\t// where it would truncate even on a wide terminal.\n\t\tconst hint = this.options.getHint?.();\n\t\tif (hint) {\n\t\t\tlines.push(this.padLine(\"\", safeWidth, paddingX));\n\t\t\tlines.push(this.padLine(theme.fg(\"dim\", truncateToWidth(hint, contentWidth)), safeWidth, paddingX));\n\t\t}\n\n\t\tif (this.verboseInstructions) {\n\t\t\tlines.push(this.padLine(\"\", safeWidth, paddingX));\n\t\t\tfor (const instruction of this.verboseInstructions.split(\"\\n\")) {\n\t\t\t\tlines.push(this.padLine(truncateToWidth(instruction, contentWidth), safeWidth, paddingX));\n\t\t\t}\n\t\t}\n\n\t\treturn lines;\n\t}\n\n\tprivate selectLogo(contentWidth: number): string[] {\n\t\tif (this.options.logo) {\n\t\t\treturn this.options.logo.split(\"\\n\");\n\t\t}\n\t\tif (this.options.getSymbolPreset?.() === \"ascii\") {\n\t\t\treturn APEX_PEAK_LOGO_ASCII.split(\"\\n\");\n\t\t}\n\t\tconst full = APEX_PEAK_LOGO.split(\"\\n\");\n\t\tconst fullWidth = full.reduce((max, line) => Math.max(max, visibleWidth(line)), 0);\n\t\treturn contentWidth >= fullWidth ? full : APEX_PEAK_LOGO_COMPACT.split(\"\\n\");\n\t}\n\n\tprivate buildMetadata(valueWidth: number): string[] {\n\t\tconst labelled = (label: string, value: string) =>\n\t\t\ttheme.fg(\"dim\", label.padEnd(LABEL_WIDTH)) + theme.fg(\"muted\", truncateToWidth(value, valueWidth));\n\n\t\tconst cwd = formatCwdForFooter(this.getCwd(), process.env.HOME || process.env.USERPROFILE);\n\t\treturn [\n\t\t\tlabelled(\"version\", `v${this.version}`),\n\t\t\tlabelled(\"model\", this.getModelId() ?? \"—\"),\n\t\t\ttheme.fg(\"dim\", \"cwd\".padEnd(LABEL_WIDTH)) + theme.fg(\"muted\", truncatePathTail(cwd, valueWidth)),\n\t\t\t...(this.options.getExtraMetadata?.() ?? []).map((line) => labelled(line.label, line.value)),\n\t\t];\n\t}\n\n\tprivate padLine(content: string, safeWidth: number, paddingX: number): string {\n\t\tconst trailing = Math.max(0, safeWidth - paddingX - visibleWidth(content));\n\t\treturn \" \".repeat(paddingX) + content + \" \".repeat(trailing);\n\t}\n}\n"]}
|