@agimon-ai/doompi-ui 0.0.1-alpha.13 → 0.0.1-alpha.14
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/dist/adapters/pi/extension.cjs +1 -1
- package/dist/adapters/pi/extension.cjs.map +1 -1
- package/dist/adapters/pi/extension.mjs +1 -1
- package/dist/adapters/pi/extension.mjs.map +1 -1
- package/dist/adapters/pi/toolOverrides.cjs +1 -1
- package/dist/adapters/pi/toolOverrides.cjs.map +1 -1
- package/dist/adapters/pi/toolOverrides.mjs +1 -1
- package/dist/adapters/pi/toolOverrides.mjs.map +1 -1
- package/dist/components/doomOverlay.cjs +1 -1
- package/dist/components/doomOverlay.d.cts +2 -2
- package/dist/components/doomOverlay.d.mts +2 -2
- package/dist/components/doomOverlay.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/services/state/uiState.cjs +1 -1
- package/dist/services/state/uiState.cjs.map +1 -1
- package/dist/services/state/uiState.d.cts +13 -12
- package/dist/services/state/uiState.d.cts.map +1 -1
- package/dist/services/state/uiState.d.mts +13 -12
- package/dist/services/state/uiState.d.mts.map +1 -1
- package/dist/services/state/uiState.mjs +1 -1
- package/dist/services/state/uiState.mjs.map +1 -1
- package/dist/tui/builtinToolRender.cjs +10 -9
- package/dist/tui/builtinToolRender.cjs.map +1 -1
- package/dist/tui/builtinToolRender.mjs +10 -9
- package/dist/tui/builtinToolRender.mjs.map +1 -1
- package/dist/tui/codeGutter.cjs +2 -0
- package/dist/tui/codeGutter.cjs.map +1 -0
- package/dist/tui/codeGutter.mjs +2 -0
- package/dist/tui/codeGutter.mjs.map +1 -0
- package/dist/tui/diffRender.cjs +4 -0
- package/dist/tui/diffRender.cjs.map +1 -0
- package/dist/tui/diffRender.mjs +4 -0
- package/dist/tui/diffRender.mjs.map +1 -0
- package/dist/tui/doomEditor.cjs +1 -1
- package/dist/tui/doomEditor.cjs.map +1 -1
- package/dist/tui/doomEditor.d.cts +1 -0
- package/dist/tui/doomEditor.d.cts.map +1 -1
- package/dist/tui/doomEditor.d.mts +1 -0
- package/dist/tui/doomEditor.d.mts.map +1 -1
- package/dist/tui/doomEditor.mjs +1 -1
- package/dist/tui/doomEditor.mjs.map +1 -1
- package/dist/tui/doomOverlay.cjs +1 -1
- package/dist/tui/doomOverlay.cjs.map +1 -1
- package/dist/tui/doomOverlay.d.cts +6 -1
- package/dist/tui/doomOverlay.d.cts.map +1 -1
- package/dist/tui/doomOverlay.d.mts +6 -1
- package/dist/tui/doomOverlay.d.mts.map +1 -1
- package/dist/tui/doomOverlay.mjs +1 -1
- package/dist/tui/doomOverlay.mjs.map +1 -1
- package/dist/tui/leaderHints.cjs.map +1 -1
- package/dist/tui/leaderHints.d.cts +2 -3
- package/dist/tui/leaderHints.d.cts.map +1 -1
- package/dist/tui/leaderHints.d.mts +2 -3
- package/dist/tui/leaderHints.d.mts.map +1 -1
- package/dist/tui/leaderHints.mjs.map +1 -1
- package/dist/tui/theme.cjs +1 -1
- package/dist/tui/theme.cjs.map +1 -1
- package/dist/tui/theme.d.cts +4 -2
- package/dist/tui/theme.d.cts.map +1 -1
- package/dist/tui/theme.d.mts +4 -2
- package/dist/tui/theme.d.mts.map +1 -1
- package/dist/tui/theme.mjs +1 -1
- package/dist/tui/theme.mjs.map +1 -1
- package/dist/uiState.cjs +1 -1
- package/dist/uiState.d.cts +2 -2
- package/dist/uiState.d.mts +2 -2
- package/dist/uiState.mjs +1 -1
- package/package.json +3 -8
- package/themes/doom-pi-dark.json +5 -3
- package/dist/mode.cjs +0 -2
- package/dist/mode.cjs.map +0 -1
- package/dist/mode.d.cts +0 -5
- package/dist/mode.d.cts.map +0 -1
- package/dist/mode.d.mts +0 -5
- package/dist/mode.d.mts.map +0 -1
- package/dist/mode.mjs +0 -2
- package/dist/mode.mjs.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../telemetry/logSinkTelemetry.cjs"),n=require("../../config.cjs"),r=require("../../footer.cjs"),i=require("../../services/state/uiState.cjs"),a=require("../../services/leader/leaderRegistry.cjs"),o=require("../../tui/doomEditor.cjs"),s=require("../../tui/doomFooter.cjs"),c=require("../../tui/doomHeader.cjs"),l=require("../../tui/leaderHints.cjs");require("../../tui/theme.cjs");const u=require("../../tui/configOverlay.cjs"),d=require("../../tui/toolsOverlay.cjs"),f=require("../../
|
|
1
|
+
const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../telemetry/logSinkTelemetry.cjs"),n=require("../../config.cjs"),r=require("../../footer.cjs"),i=require("../../services/state/uiState.cjs"),a=require("../../services/leader/leaderRegistry.cjs"),o=require("../../tui/doomEditor.cjs"),s=require("../../tui/doomFooter.cjs"),c=require("../../tui/doomHeader.cjs"),l=require("../../tui/leaderHints.cjs");require("../../tui/theme.cjs");const u=require("../../tui/configOverlay.cjs"),d=require("../../tui/toolsOverlay.cjs"),f=require("../../services/tools/toolInventory.cjs"),p=require("./toolOverrides.cjs");let m=require("@agimon-ai/doompi-extension-contracts/leader"),h=require("node:path");h=e.__toESM(h,1);let g=require("@agimon-ai/doompi-extension-contracts/mcp-status"),_=require("@agimon-ai/doompi-extension-contracts/mode"),v=require("@agimon-ai/doompi-extension-contracts/protocol");const y=`doom-pi-leader`,b=`belowEditor`,x=`warning`,S=`doom-pi`,C=new Set([`hotkeys`]);function w(e,t){let n=e.trim().replace(/\s+/g,` `);if(!n)return;let r=n.slice(0,64).trimEnd();return`${S} · ${r} · ${h.default.basename(t)||t}`}function T(e,T=t.createUiTelemetry()){p.registerBuiltinToolUi(e,process.cwd());let E=new i.DoomUiState,D=new r.footer_exports.DoomFooterStatusRegistry,O=(0,_.createMinorModeCatalogClient)(),k=new n.config_exports.DoomConfigRegistry,A=new a.DoomLeaderRegistry,j=new Set,M=new Map,N,P,F,I,L,R,z,B,V=new Map,H=0,U=0,W=!1,G,K,q=async()=>{if(G)try{return(await G.request(g.McpStatusQueryProtocol,{},{timeoutMs:250})).servers}catch{return}};e.registerCommand(`tools`,{description:`Browse the tools available in this session`,handler:async(t,n)=>{let r=await q(),i=f.buildToolSources({tools:e.getAllTools(),activeTools:e.getActiveTools(),...r?{mcpServers:r}:{}});await d.openToolsOverlay(n,i)}}),e.registerCommand(`config`,{description:`Browse and change the settings extensions contribute`,handler:async(e,t)=>{await u.openConfigOverlay(t,k)}});let J=e=>{for(let n of e){let e=n.bindingId?` (${n.bindingId})`:``,r=`Leader contribution from ${n.source}${e}: ${n.message}`;j.has(r)||(j.add(r),T.recordWarning(t.UI_EVENT.leaderContributionRejected,n.message,{"leader.source":n.source,...n.bindingId?{"leader.binding.id":n.bindingId}:{}}),P?.mode===`tui`&&P.ui.notify(r,x))}},Y=(e,t)=>{let n=Symbol(e.source),r=t?e=>A.registerDeferred(e):e=>A.register(e),i=r(e);if(J(i.diagnostics),!i.accepted)return{update:()=>void 0,dispose:()=>void 0};M.set(e.source,n);let a=!1;return{update(t){a||M.get(e.source)!==n||J(r({source:e.source,bindings:t}).diagnostics)},dispose(){a||(a=!0,M.get(e.source)===n&&(M.delete(e.source),r({source:e.source,bindings:[]})))}}},X=Object.freeze({register(e){let t=Y(e,!1);return()=>t.dispose()}});K=(0,m.installDoomLeaderBootstrapHost)({register:e=>Y(e,!0)}),e.on(`session_start`,(n,r)=>{P=r;let a=++U,u=(0,v.createProtocolRuntime)({bus:e.events,source:`@agimon-ai/doompi-ui`,sessionId:r.sessionManager.getSessionId()});if(G=u,J(A.flush()),F?.(),D.reset(),F=D.bind(u),I?.(),I=O.bind(u),R?.(),k.reset(),R=k.bind(u),z?.(),B?.(),z=u.provide(m.LeaderRegistrationProtocol,({contribution:e,generation:t},n)=>{if(n.source!==e.source)throw Error(`Leader contribution source does not match the registration envelope source.`);let r=`${n.source}:${t}:${++H}`,i={source:e.source,bindings:e.bindings.map(e=>{let[t,...n]=e.path;if(!t)throw Error(`Leader binding '${e.id}' has no path.`);return{...e,path:[t,...n]}})};return V.set(r,X.register(i)),{handleId:r}}),B=u.provide(m.LeaderUnregistrationProtocol,({handleId:e})=>{let t=V.get(e);return t?(V.delete(e),t(),{removed:!0}):{removed:!1}}),W=r.sessionManager.getEntries().some(e=>e.type===`message`),r.mode!==`tui`)return;for(let e of j)r.ui.notify(e,x);let d=process.env.DOOMPI_THEME||`doom-pi-dark`,f=r.ui.setTheme(d);f.success||(r.ui.notify(`Could not apply Doom Pi theme: ${f.error}`,x),T.recordWarning(t.UI_EVENT.themeApplyFailed,f.error??`Unknown theme error`,{"ui.theme":d})),L?.(),L=O.subscribe(()=>E.setModes(i.projectMinorModeRecords(O.list()))),E.setModes(i.projectMinorModeRecords(O.list())),r.ui.setTitle(`${S} · ${h.default.basename(r.cwd)||r.cwd} · pi/coding`),r.ui.setHeader((e,t)=>new c.DoomHeader(t,r.cwd,void 0,r,()=>e.terminal.rows)),r.ui.setFooter((e,t,n)=>(N=n,new s.DoomFooter(e,t,r,n,D,E))),r.ui.setEditorComponent((n,i,s)=>new o.DoomEditor(n,i,s,E,e=>{if(!e.active){r.ui.setWidget(y,void 0,{placement:b});return}r.ui.setWidget(y,(t,n)=>new l.LeaderHints(n,e,r,N,E.getModes()),{placement:b})},void 0,r.ui.theme,{registry:A,isCommandAvailable:t=>C.has(t)||e.getCommands().some(e=>e.name===t),onLeaderAction:(e,t)=>{if(P!==r||U!==a){r.ui.notify(`Leader action ${t} is unavailable.`,x);return}u.notify(m.LeaderActionInvoked,{source:e,action:t})},onUnavailableCommand:e=>{T.recordWarning(t.UI_EVENT.leaderCommandUnavailable,`Leader command /${e} is unavailable.`,{"ui.kind":`command`}),r.ui.notify(`Leader command /${e} is unavailable.`,x)},onUnavailableAction:e=>{T.recordWarning(t.UI_EVENT.leaderActionUnavailable,`Leader action ${e} is unavailable.`,{"ui.kind":`action`}),r.ui.notify(`Leader action ${e} is unavailable.`,x)}})),T.recordEvent(t.UI_EVENT.shellInstalled,{"ui.theme":d,"ui.theme.applied":f.success,"ui.leader.group.count":A.getGroup([])?.options.length??0})}),e.on(`input`,(e,t)=>{if(t.mode!==`tui`||e.source!==`interactive`||W)return;W=!0;let n=w(e.text,t.cwd);n&&t.ui.setTitle(n)}),e.on(`session_shutdown`,async(e,t)=>{++U,K?.(),K=void 0;for(let e of V.values())e();V.clear(),P=void 0,N=void 0,F?.(),F=void 0,D.reset(),I?.(),I=void 0,L?.(),L=void 0,O.reset(),R?.(),R=void 0,z?.(),z=void 0,B?.(),B=void 0,k.reset(),E.reset(),G=void 0,t.mode===`tui`&&t.ui.setWidget(y,void 0,{placement:b}),await T.shutdown()})}exports.doomPiUiExtension=T;
|
|
2
2
|
//# sourceMappingURL=extension.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.cjs","names":["path","createUiTelemetry","DoomUiState","DoomLeaderRegistry","McpStatusQueryProtocol","buildToolSources","openToolsOverlay","openConfigOverlay","UI_EVENT","installDoomLeaderBootstrapHost","createProtocolRuntime","LeaderRegistrationProtocol","LeaderUnregistrationProtocol","DoomHeader","DoomFooter","DoomEditor","LeaderHints","LeaderActionInvoked"],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import path from 'node:path';\nimport {\n installDoomLeaderBootstrapHost,\n LeaderActionInvoked,\n type LeaderContribution,\n LeaderRegistrationProtocol,\n LeaderUnregistrationProtocol,\n} from '@agimon-ai/doompi-extension-contracts/leader';\nimport { McpStatusQueryProtocol } from '@agimon-ai/doompi-extension-contracts/mcp-status';\nimport { createProtocolRuntime, type ProtocolRuntime } from '@agimon-ai/doompi-extension-contracts/protocol';\nimport type { ExtensionAPI, ExtensionContext, ReadonlyFooterDataProvider } from '@earendil-works/pi-coding-agent';\nimport { DoomConfigRegistry } from '../../config.ts';\nimport { DoomFooterStatusRegistry } from '../../footer.ts';\nimport { DoomModeStatusRegistry } from '../../mode.ts';\nimport { type DoomLeaderDiagnostic, DoomLeaderRegistry } from '../../services/leader/leaderRegistry.ts';\nimport { DoomUiState, type LeaderSnapshot } from '../../services/state/uiState.ts';\nimport { buildToolSources, type McpServerStatus } from '../../services/tools/toolInventory.ts';\nimport { openConfigOverlay } from '../../tui/configOverlay.ts';\nimport { DoomEditor } from '../../tui/doomEditor.ts';\nimport { DoomFooter } from '../../tui/doomFooter.ts';\nimport { DoomHeader } from '../../tui/doomHeader.ts';\nimport { LeaderHints } from '../../tui/leaderHints.ts';\nimport { DEFAULT_THEME_NAME } from '../../tui/theme.ts';\nimport { openToolsOverlay } from '../../tui/toolsOverlay.ts';\nimport { createUiTelemetry, UI_EVENT, type UiTelemetry } from '../telemetry/logSinkTelemetry.ts';\nimport { registerBuiltinToolUi } from './toolOverrides.ts';\n\nconst LEADER_WIDGET_KEY = 'doom-pi-leader';\nconst TUI_MODE = 'tui';\nconst WIDGET_PLACEMENT = 'belowEditor';\nconst WARNING_STYLE = 'warning';\nconst THEME_ENVIRONMENT_KEY = 'DOOMPI_THEME';\nconst HOTKEYS_COMMAND = 'hotkeys';\nconst TOOLS_COMMAND = 'tools';\nconst CONFIG_COMMAND = 'config';\n/** Short: `/tools` must open promptly whether or not an MCP extension answers. */\nconst MCP_STATUS_TIMEOUT_MS = 250;\nconst SESSION_START_EVENT = 'session_start';\nconst SESSION_MESSAGE_ENTRY = 'message';\nconst INPUT_EVENT = 'input';\nconst INTERACTIVE_INPUT_SOURCE = 'interactive';\nconst SESSION_SHUTDOWN_EVENT = 'session_shutdown';\nconst TITLE_MESSAGE_MAX_LENGTH = 64;\nconst TITLE_PREFIX = 'doom-pi';\nconst BUILTIN_LEADER_COMMANDS = new Set([HOTKEYS_COMMAND]);\n\nfunction createMessageTitle(message: string, cwd: string): string | undefined {\n const normalizedMessage = message.trim().replace(/\\s+/g, ' ');\n if (!normalizedMessage) return undefined;\n const messageTitle = normalizedMessage.slice(0, TITLE_MESSAGE_MAX_LENGTH).trimEnd();\n return `${TITLE_PREFIX} · ${messageTitle} · ${path.basename(cwd) || cwd}`;\n}\n\nexport function doomPiUiExtension(pi: ExtensionAPI, telemetry: UiTelemetry = createUiTelemetry()): void {\n registerBuiltinToolUi(pi, process.cwd());\n const uiState = new DoomUiState();\n const footerStatusRegistry = new DoomFooterStatusRegistry();\n const modeStatusRegistry = new DoomModeStatusRegistry();\n const configRegistry = new DoomConfigRegistry();\n const leaderRegistry = new DoomLeaderRegistry();\n const pendingDiagnostics = new Set<string>();\n const contributionGenerations = new Map<string, symbol>();\n let footerData: ReadonlyFooterDataProvider | undefined;\n let activeContext: ExtensionContext | undefined;\n let disposeFooterStatuses: (() => void) | undefined;\n let disposeModeStatuses: (() => void) | undefined;\n let disposeModeSubscription: (() => void) | undefined;\n let disposeConfigContributions: (() => void) | undefined;\n let disposeLeaderRegistration: (() => void) | undefined;\n let disposeLeaderUnregistration: (() => void) | undefined;\n const protocolContributions = new Map<string, () => void>();\n let nextProtocolHandle = 0;\n let sessionGeneration = 0;\n let hasSessionMessage = false;\n let sessionProtocol: ProtocolRuntime | undefined;\n let disposeLeaderBootstrap: (() => void) | undefined;\n\n /**\n * Asks the MCP extension what it is currently connected to.\n *\n * No answer is a normal session: `--no-mcp` leaves nobody providing the query,\n * and the panel simply lists MCP tools under the extension that registered them.\n */\n const readMcpServers = async (): Promise<readonly McpServerStatus[] | undefined> => {\n if (!sessionProtocol) return undefined;\n try {\n const snapshot = await sessionProtocol.request(McpStatusQueryProtocol, {}, { timeoutMs: MCP_STATUS_TIMEOUT_MS });\n return snapshot.servers;\n } catch {\n return undefined;\n }\n };\n\n pi.registerCommand(TOOLS_COMMAND, {\n description: 'Browse the tools available in this session',\n handler: async (_args, ctx) => {\n // Read at open time so a reconnected server or a plan-mode tool swap shows\n // up without restarting the session.\n const mcpServers = await readMcpServers();\n const sources = buildToolSources({\n tools: pi.getAllTools(),\n activeTools: pi.getActiveTools(),\n ...(mcpServers ? { mcpServers } : {}),\n });\n await openToolsOverlay(ctx, sources);\n },\n });\n\n pi.registerCommand(CONFIG_COMMAND, {\n description: 'Browse and change the settings extensions contribute',\n handler: async (_args, ctx) => {\n // The registry is passed live rather than snapshotted: a contributor can be\n // fetching or installing something while the panel is open, and that\n // progress is meant to land in it.\n await openConfigOverlay(ctx, configRegistry);\n },\n });\n\n const reportDiagnostics = (diagnostics: readonly DoomLeaderDiagnostic[]): void => {\n for (const diagnostic of diagnostics) {\n const binding = diagnostic.bindingId ? ` (${diagnostic.bindingId})` : '';\n const message = `Leader contribution from ${diagnostic.source}${binding}: ${diagnostic.message}`;\n if (pendingDiagnostics.has(message)) continue;\n pendingDiagnostics.add(message);\n // A rejected contribution silently drops another extension's keybindings,\n // and the notice below only reaches a run that has a TUI attached.\n void telemetry.recordWarning(UI_EVENT.leaderContributionRejected, diagnostic.message, {\n 'leader.source': diagnostic.source,\n ...(diagnostic.bindingId ? { 'leader.binding.id': diagnostic.bindingId } : {}),\n });\n if (activeContext?.mode === TUI_MODE) activeContext.ui.notify(message, WARNING_STYLE);\n }\n };\n\n const registerLeaderContribution = (contribution: LeaderContribution, deferred: boolean) => {\n const generation = Symbol(contribution.source);\n const register = deferred\n ? (value: LeaderContribution) => leaderRegistry.registerDeferred(value)\n : (value: LeaderContribution) => leaderRegistry.register(value);\n const result = register(contribution);\n reportDiagnostics(result.diagnostics);\n if (!result.accepted) return { update: () => undefined, dispose: () => undefined };\n contributionGenerations.set(contribution.source, generation);\n let disposed = false;\n return {\n update(bindings: LeaderContribution['bindings']) {\n if (disposed || contributionGenerations.get(contribution.source) !== generation) return;\n reportDiagnostics(register({ source: contribution.source, bindings }).diagnostics);\n },\n dispose() {\n if (disposed) return;\n disposed = true;\n if (contributionGenerations.get(contribution.source) !== generation) return;\n contributionGenerations.delete(contribution.source);\n register({ source: contribution.source, bindings: [] });\n },\n };\n };\n\n const leaderContext = Object.freeze({\n register(contribution: LeaderContribution) {\n const handle = registerLeaderContribution(contribution, false);\n return () => handle.dispose();\n },\n });\n // Installed during the UI factory, before the remaining Doom factories run.\n // Their registrations are validated immediately and rebuilt as one batch at\n // session_start, so the first editor always receives the complete keyspace.\n disposeLeaderBootstrap = installDoomLeaderBootstrapHost({\n register: (contribution) => registerLeaderContribution(contribution, true),\n });\n pi.on(SESSION_START_EVENT, (_event, ctx) => {\n activeContext = ctx;\n const activeGeneration = ++sessionGeneration;\n const protocol = createProtocolRuntime({\n bus: pi.events,\n source: '@agimon-ai/doompi-ui',\n sessionId: ctx.sessionManager.getSessionId(),\n });\n sessionProtocol = protocol;\n reportDiagnostics(leaderRegistry.flush());\n disposeFooterStatuses?.();\n footerStatusRegistry.reset();\n disposeFooterStatuses = footerStatusRegistry.bind(protocol);\n disposeModeStatuses?.();\n modeStatusRegistry.reset();\n disposeModeStatuses = modeStatusRegistry.bind(protocol);\n // Bound above the TUI-mode guard below, like footer and mode: a headless run\n // still accepts contributions, it just never draws them.\n disposeConfigContributions?.();\n configRegistry.reset();\n disposeConfigContributions = configRegistry.bind(protocol);\n disposeLeaderRegistration?.();\n disposeLeaderUnregistration?.();\n disposeLeaderRegistration = protocol.provide(\n LeaderRegistrationProtocol,\n ({ contribution, generation }, identity) => {\n if (identity.source !== contribution.source) {\n throw new Error('Leader contribution source does not match the registration envelope source.');\n }\n const handleId = `${identity.source}:${generation}:${++nextProtocolHandle}`;\n const typedContribution: LeaderContribution = {\n source: contribution.source,\n bindings: contribution.bindings.map((binding) => {\n const [first, ...rest] = binding.path;\n if (!first) throw new Error(`Leader binding '${binding.id}' has no path.`);\n return { ...binding, path: [first, ...rest] };\n }),\n };\n protocolContributions.set(handleId, leaderContext.register(typedContribution));\n return { handleId };\n },\n );\n disposeLeaderUnregistration = protocol.provide(LeaderUnregistrationProtocol, ({ handleId }) => {\n const dispose = protocolContributions.get(handleId);\n if (!dispose) return { removed: false };\n protocolContributions.delete(handleId);\n dispose();\n return { removed: true };\n });\n hasSessionMessage = ctx.sessionManager.getEntries().some((entry) => entry.type === SESSION_MESSAGE_ENTRY);\n if (ctx.mode !== TUI_MODE) return;\n for (const message of pendingDiagnostics) ctx.ui.notify(message, WARNING_STYLE);\n\n const themeName = process.env[THEME_ENVIRONMENT_KEY] || DEFAULT_THEME_NAME;\n const themeResult = ctx.ui.setTheme(themeName);\n if (!themeResult.success) {\n ctx.ui.notify(`Could not apply Doom Pi theme: ${themeResult.error}`, WARNING_STYLE);\n void telemetry.recordWarning(UI_EVENT.themeApplyFailed, themeResult.error ?? 'Unknown theme error', {\n 'ui.theme': themeName,\n });\n }\n\n // The modes go into shared state rather than a widget of their own: the\n // editor prints their names beside its badge and the leader panel prints\n // them with their detail, so there is no third surface to paint.\n disposeModeSubscription?.();\n disposeModeSubscription = modeStatusRegistry.subscribe(() => uiState.setModes(modeStatusRegistry.getStatuses()));\n uiState.setModes(modeStatusRegistry.getStatuses());\n\n ctx.ui.setTitle(`${TITLE_PREFIX} · ${path.basename(ctx.cwd) || ctx.cwd} · pi/coding`);\n ctx.ui.setHeader((tui, theme) => new DoomHeader(theme, ctx.cwd, undefined, ctx, () => tui.terminal.rows));\n ctx.ui.setFooter((tui, theme, data) => {\n footerData = data;\n return new DoomFooter(tui, theme, ctx, data, footerStatusRegistry, uiState);\n });\n ctx.ui.setEditorComponent(\n (tui, editorTheme, keybindings) =>\n new DoomEditor(\n tui,\n editorTheme,\n keybindings,\n uiState,\n (snapshot: LeaderSnapshot) => {\n if (!snapshot.active) {\n ctx.ui.setWidget(LEADER_WIDGET_KEY, undefined, { placement: WIDGET_PLACEMENT });\n return;\n }\n ctx.ui.setWidget(\n LEADER_WIDGET_KEY,\n (_widgetTui, widgetTheme) => new LeaderHints(widgetTheme, snapshot, ctx, footerData, uiState.getModes()),\n { placement: WIDGET_PLACEMENT },\n );\n },\n undefined,\n ctx.ui.theme,\n {\n registry: leaderRegistry,\n isCommandAvailable: (commandName) =>\n BUILTIN_LEADER_COMMANDS.has(commandName) ||\n pi.getCommands().some((command) => command.name === commandName),\n onLeaderAction: (source, action) => {\n if (activeContext !== ctx || sessionGeneration !== activeGeneration) {\n ctx.ui.notify(`Leader action ${action} is unavailable.`, WARNING_STYLE);\n return;\n }\n protocol.notify(LeaderActionInvoked, { source, action });\n },\n onUnavailableCommand: (commandName) => {\n void telemetry.recordWarning(\n UI_EVENT.leaderCommandUnavailable,\n `Leader command /${commandName} is unavailable.`,\n { 'ui.kind': 'command' },\n );\n ctx.ui.notify(`Leader command /${commandName} is unavailable.`, WARNING_STYLE);\n },\n onUnavailableAction: (action) => {\n void telemetry.recordWarning(\n UI_EVENT.leaderActionUnavailable,\n `Leader action ${action} is unavailable.`,\n {\n 'ui.kind': 'action',\n },\n );\n ctx.ui.notify(`Leader action ${action} is unavailable.`, WARNING_STYLE);\n },\n },\n ),\n );\n\n void telemetry.recordEvent(UI_EVENT.shellInstalled, {\n 'ui.theme': themeName,\n 'ui.theme.applied': themeResult.success,\n 'ui.leader.group.count': leaderRegistry.getGroup([])?.options.length ?? 0,\n });\n });\n\n pi.on(INPUT_EVENT, (event, ctx) => {\n if (ctx.mode !== TUI_MODE || event.source !== INTERACTIVE_INPUT_SOURCE || hasSessionMessage) return;\n hasSessionMessage = true;\n const title = createMessageTitle(event.text, ctx.cwd);\n if (title) ctx.ui.setTitle(title);\n });\n\n pi.on(SESSION_SHUTDOWN_EVENT, async (_event, ctx) => {\n ++sessionGeneration;\n disposeLeaderBootstrap?.();\n disposeLeaderBootstrap = undefined;\n for (const dispose of protocolContributions.values()) dispose();\n protocolContributions.clear();\n activeContext = undefined;\n footerData = undefined;\n disposeFooterStatuses?.();\n disposeFooterStatuses = undefined;\n footerStatusRegistry.reset();\n disposeModeStatuses?.();\n disposeModeStatuses = undefined;\n disposeModeSubscription?.();\n disposeModeSubscription = undefined;\n modeStatusRegistry.reset();\n disposeConfigContributions?.();\n disposeConfigContributions = undefined;\n disposeLeaderRegistration?.();\n disposeLeaderRegistration = undefined;\n disposeLeaderUnregistration?.();\n disposeLeaderUnregistration = undefined;\n configRegistry.reset();\n uiState.reset();\n sessionProtocol = undefined;\n if (ctx.mode === TUI_MOD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AChD,GAAO,EAAI,GAAG,SAAS,CAAK,CAClC,CAAC,EAED,EAAG,GAAG,mBAAwB,MAAO,EAAQ,IAAQ,CACnD,EAAE,EACF,IAAyB,EACzB,EAAyB,IAAA,GACzB,IAAK,IAAM,KAAW,EAAsB,OAAO,EAAG,EAAQ,EAC9D,EAAsB,MAAM,EAC5B,EAAgB,IAAA,GAChB,EAAa,IAAA,GACb,IAAwB,EACxB,EAAwB,IAAA,GACxB,EAAqB,MAAM,EAC3B,IAAsB,EACtB,EAAsB,IAAA,GACtB,IAA0B,EAC1B,EAA0B,IAAA,GAC1B,EAAmB,MAAM,EACzB,IAA6B,EAC7B,EAA6B,IAAA,GAC7B,IAA4B,EAC5B,EAA4B,IAAA,GAC5B,IAA8B,EAC9B,EAA8B,IAAA,GAC9B,EAAe,MAAM,EACrB,EAAQ,MAAM,EACd,EAAkB,IAAA,GACd,EAAI,OAAS,OAAU,EAAI,GAAG,UAAU,EAAmB,IAAA,GAAW,CAAE,UAAW,CAAiB,CAAC,EACzG,MAAM,EAAU,SAAS,CAC3B,CAAC,CACH"}
|
|
1
|
+
{"version":3,"file":"extension.cjs","names":["path","createUiTelemetry","DoomUiState","createMinorModeCatalogClient","DoomLeaderRegistry","McpStatusQueryProtocol","buildToolSources","openToolsOverlay","openConfigOverlay","UI_EVENT","installDoomLeaderBootstrapHost","createProtocolRuntime","LeaderRegistrationProtocol","LeaderUnregistrationProtocol","projectMinorModeRecords","DoomHeader","DoomFooter","DoomEditor","LeaderHints","LeaderActionInvoked"],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import path from 'node:path';\nimport {\n installDoomLeaderBootstrapHost,\n LeaderActionInvoked,\n type LeaderContribution,\n LeaderRegistrationProtocol,\n LeaderUnregistrationProtocol,\n} from '@agimon-ai/doompi-extension-contracts/leader';\nimport { McpStatusQueryProtocol } from '@agimon-ai/doompi-extension-contracts/mcp-status';\nimport { createMinorModeCatalogClient } from '@agimon-ai/doompi-extension-contracts/mode';\nimport { createProtocolRuntime, type ProtocolRuntime } from '@agimon-ai/doompi-extension-contracts/protocol';\nimport type { ExtensionAPI, ExtensionContext, ReadonlyFooterDataProvider } from '@earendil-works/pi-coding-agent';\nimport { DoomConfigRegistry } from '../../config.ts';\nimport { DoomFooterStatusRegistry } from '../../footer.ts';\nimport { type DoomLeaderDiagnostic, DoomLeaderRegistry } from '../../services/leader/leaderRegistry.ts';\nimport { DoomUiState, type LeaderSnapshot, projectMinorModeRecords } from '../../services/state/uiState.ts';\nimport { buildToolSources, type McpServerStatus } from '../../services/tools/toolInventory.ts';\nimport { openConfigOverlay } from '../../tui/configOverlay.ts';\nimport { DoomEditor } from '../../tui/doomEditor.ts';\nimport { DoomFooter } from '../../tui/doomFooter.ts';\nimport { DoomHeader } from '../../tui/doomHeader.ts';\nimport { LeaderHints } from '../../tui/leaderHints.ts';\nimport { DEFAULT_THEME_NAME } from '../../tui/theme.ts';\nimport { openToolsOverlay } from '../../tui/toolsOverlay.ts';\nimport { createUiTelemetry, UI_EVENT, type UiTelemetry } from '../telemetry/logSinkTelemetry.ts';\nimport { registerBuiltinToolUi } from './toolOverrides.ts';\n\nconst LEADER_WIDGET_KEY = 'doom-pi-leader';\nconst TUI_MODE = 'tui';\nconst WIDGET_PLACEMENT = 'belowEditor';\nconst WARNING_STYLE = 'warning';\nconst THEME_ENVIRONMENT_KEY = 'DOOMPI_THEME';\nconst HOTKEYS_COMMAND = 'hotkeys';\nconst TOOLS_COMMAND = 'tools';\nconst CONFIG_COMMAND = 'config';\n/** Short: `/tools` must open promptly whether or not an MCP extension answers. */\nconst MCP_STATUS_TIMEOUT_MS = 250;\nconst SESSION_START_EVENT = 'session_start';\nconst SESSION_MESSAGE_ENTRY = 'message';\nconst INPUT_EVENT = 'input';\nconst INTERACTIVE_INPUT_SOURCE = 'interactive';\nconst SESSION_SHUTDOWN_EVENT = 'session_shutdown';\nconst TITLE_MESSAGE_MAX_LENGTH = 64;\nconst TITLE_PREFIX = 'doom-pi';\nconst BUILTIN_LEADER_COMMANDS = new Set([HOTKEYS_COMMAND]);\n\nfunction createMessageTitle(message: string, cwd: string): string | undefined {\n const normalizedMessage = message.trim().replace(/\\s+/g, ' ');\n if (!normalizedMessage) return undefined;\n const messageTitle = normalizedMessage.slice(0, TITLE_MESSAGE_MAX_LENGTH).trimEnd();\n return `${TITLE_PREFIX} · ${messageTitle} · ${path.basename(cwd) || cwd}`;\n}\n\nexport function doomPiUiExtension(pi: ExtensionAPI, telemetry: UiTelemetry = createUiTelemetry()): void {\n registerBuiltinToolUi(pi, process.cwd());\n const uiState = new DoomUiState();\n const footerStatusRegistry = new DoomFooterStatusRegistry();\n const modeCatalog = createMinorModeCatalogClient();\n const configRegistry = new DoomConfigRegistry();\n const leaderRegistry = new DoomLeaderRegistry();\n const pendingDiagnostics = new Set<string>();\n const contributionGenerations = new Map<string, symbol>();\n let footerData: ReadonlyFooterDataProvider | undefined;\n let activeContext: ExtensionContext | undefined;\n let disposeFooterStatuses: (() => void) | undefined;\n let disposeModeCatalogBinding: (() => void) | undefined;\n let disposeModeSubscription: (() => void) | undefined;\n let disposeConfigContributions: (() => void) | undefined;\n let disposeLeaderRegistration: (() => void) | undefined;\n let disposeLeaderUnregistration: (() => void) | undefined;\n const protocolContributions = new Map<string, () => void>();\n let nextProtocolHandle = 0;\n let sessionGeneration = 0;\n let hasSessionMessage = false;\n let sessionProtocol: ProtocolRuntime | undefined;\n let disposeLeaderBootstrap: (() => void) | undefined;\n\n /**\n * Asks the MCP extension what it is currently connected to.\n *\n * No answer is a normal session: `--no-mcp` leaves nobody providing the query,\n * and the panel simply lists MCP tools under the extension that registered them.\n */\n const readMcpServers = async (): Promise<readonly McpServerStatus[] | undefined> => {\n if (!sessionProtocol) return undefined;\n try {\n const snapshot = await sessionProtocol.request(McpStatusQueryProtocol, {}, { timeoutMs: MCP_STATUS_TIMEOUT_MS });\n return snapshot.servers;\n } catch {\n return undefined;\n }\n };\n\n pi.registerCommand(TOOLS_COMMAND, {\n description: 'Browse the tools available in this session',\n handler: async (_args, ctx) => {\n // Read at open time so a reconnected server or a plan-mode tool swap shows\n // up without restarting the session.\n const mcpServers = await readMcpServers();\n const sources = buildToolSources({\n tools: pi.getAllTools(),\n activeTools: pi.getActiveTools(),\n ...(mcpServers ? { mcpServers } : {}),\n });\n await openToolsOverlay(ctx, sources);\n },\n });\n\n pi.registerCommand(CONFIG_COMMAND, {\n description: 'Browse and change the settings extensions contribute',\n handler: async (_args, ctx) => {\n // The registry is passed live rather than snapshotted: a contributor can be\n // fetching or installing something while the panel is open, and that\n // progress is meant to land in it.\n await openConfigOverlay(ctx, configRegistry);\n },\n });\n\n const reportDiagnostics = (diagnostics: readonly DoomLeaderDiagnostic[]): void => {\n for (const diagnostic of diagnostics) {\n const binding = diagnostic.bindingId ? ` (${diagnostic.bindingId})` : '';\n const message = `Leader contribution from ${diagnostic.source}${binding}: ${diagnostic.message}`;\n if (pendingDiagnostics.has(message)) continue;\n pendingDiagnostics.add(message);\n // A rejected contribution silently drops another extension's keybindings,\n // and the notice below only reaches a run that has a TUI attached.\n void telemetry.recordWarning(UI_EVENT.leaderContributionRejected, diagnostic.message, {\n 'leader.source': diagnostic.source,\n ...(diagnostic.bindingId ? { 'leader.binding.id': diagnostic.bindingId } : {}),\n });\n if (activeContext?.mode === TUI_MODE) activeContext.ui.notify(message, WARNING_STYLE);\n }\n };\n\n const registerLeaderContribution = (contribution: LeaderContribution, deferred: boolean) => {\n const generation = Symbol(contribution.source);\n const register = deferred\n ? (value: LeaderContribution) => leaderRegistry.registerDeferred(value)\n : (value: LeaderContribution) => leaderRegistry.register(value);\n const result = register(contribution);\n reportDiagnostics(result.diagnostics);\n if (!result.accepted) return { update: () => undefined, dispose: () => undefined };\n contributionGenerations.set(contribution.source, generation);\n let disposed = false;\n return {\n update(bindings: LeaderContribution['bindings']) {\n if (disposed || contributionGenerations.get(contribution.source) !== generation) return;\n reportDiagnostics(register({ source: contribution.source, bindings }).diagnostics);\n },\n dispose() {\n if (disposed) return;\n disposed = true;\n if (contributionGenerations.get(contribution.source) !== generation) return;\n contributionGenerations.delete(contribution.source);\n register({ source: contribution.source, bindings: [] });\n },\n };\n };\n\n const leaderContext = Object.freeze({\n register(contribution: LeaderContribution) {\n const handle = registerLeaderContribution(contribution, false);\n return () => handle.dispose();\n },\n });\n // Installed during the UI factory, before the remaining Doom factories run.\n // Their registrations are validated immediately and rebuilt as one batch at\n // session_start, so the first editor always receives the complete keyspace.\n disposeLeaderBootstrap = installDoomLeaderBootstrapHost({\n register: (contribution) => registerLeaderContribution(contribution, true),\n });\n pi.on(SESSION_START_EVENT, (_event, ctx) => {\n activeContext = ctx;\n const activeGeneration = ++sessionGeneration;\n const protocol = createProtocolRuntime({\n bus: pi.events,\n source: '@agimon-ai/doompi-ui',\n sessionId: ctx.sessionManager.getSessionId(),\n });\n sessionProtocol = protocol;\n reportDiagnostics(leaderRegistry.flush());\n disposeFooterStatuses?.();\n footerStatusRegistry.reset();\n disposeFooterStatuses = footerStatusRegistry.bind(protocol);\n disposeModeCatalogBinding?.();\n disposeModeCatalogBinding = modeCatalog.bind(protocol);\n // Bound above the TUI-mode guard below, like footer and mode: a headless run\n // still accepts contributions, it just never draws them.\n disposeConfigContributions?.();\n configRegistry.reset();\n disposeConfigContributions = configRegistry.bind(protocol);\n disposeLeaderRegistration?.();\n disposeLeaderUnregistration?.();\n disposeLeaderRegistration = protocol.provide(\n LeaderRegistrationProtocol,\n ({ contribution, generation }, identity) => {\n if (identity.source !== contribution.source) {\n throw new Error('Leader contribution source does not match the registration envelope source.');\n }\n const handleId = `${identity.source}:${generation}:${++nextProtocolHandle}`;\n const typedContribution: LeaderContribution = {\n source: contribution.source,\n bindings: contribution.bindings.map((binding) => {\n const [first, ...rest] = binding.path;\n if (!first) throw new Error(`Leader binding '${binding.id}' has no path.`);\n return { ...binding, path: [first, ...rest] };\n }),\n };\n protocolContributions.set(handleId, leaderContext.register(typedContribution));\n return { handleId };\n },\n );\n disposeLeaderUnregistration = protocol.provide(LeaderUnregistrationProtocol, ({ handleId }) => {\n const dispose = protocolContributions.get(handleId);\n if (!dispose) return { removed: false };\n protocolContributions.delete(handleId);\n dispose();\n return { removed: true };\n });\n hasSessionMessage = ctx.sessionManager.getEntries().some((entry) => entry.type === SESSION_MESSAGE_ENTRY);\n if (ctx.mode !== TUI_MODE) return;\n for (const message of pendingDiagnostics) ctx.ui.notify(message, WARNING_STYLE);\n\n const themeName = process.env[THEME_ENVIRONMENT_KEY] || DEFAULT_THEME_NAME;\n const themeResult = ctx.ui.setTheme(themeName);\n if (!themeResult.success) {\n ctx.ui.notify(`Could not apply Doom Pi theme: ${themeResult.error}`, WARNING_STYLE);\n void telemetry.recordWarning(UI_EVENT.themeApplyFailed, themeResult.error ?? 'Unknown theme error', {\n 'ui.theme': themeName,\n });\n }\n\n // The modes go into shared state rather than a widget of their own: the\n // editor prints their names beside its badge and the leader panel prints\n // them with their detail, so there is no third surface to paint.\n disposeModeSubscription?.();\n disposeModeSubscription = modeCatalog.subscribe(() =>\n uiState.setModes(projectMinorModeRecords(modeCatalog.list())),\n );\n uiState.setModes(projectMinorModeRecords(modeCatalog.list()));\n\n ctx.ui.setTitle(`${TITLE_PREFIX} · ${path.basename(ctx.cwd) || ctx.cwd} · pi/coding`);\n ctx.ui.setHeader((tui, theme) => new DoomHeader(theme, ctx.cwd, undefined, ctx, () => tui.terminal.rows));\n ctx.ui.setFooter((tui, theme, data) => {\n footerData = data;\n return new DoomFooter(tui, theme, ctx, data, footerStatusRegistry, uiState);\n });\n ctx.ui.setEditorComponent(\n (tui, editorTheme, keybindings) =>\n new DoomEditor(\n tui,\n editorTheme,\n keybindings,\n uiState,\n (snapshot: LeaderSnapshot) => {\n if (!snapshot.active) {\n ctx.ui.setWidget(LEADER_WIDGET_KEY, undefined, { placement: WIDGET_PLACEMENT });\n return;\n }\n ctx.ui.setWidget(\n LEADER_WIDGET_KEY,\n (_widgetTui, widgetTheme) => new LeaderHints(widgetTheme, snapshot, ctx, footerData, uiState.getModes()),\n { placement: WIDGET_PLACEMENT },\n );\n },\n undefined,\n ctx.ui.theme,\n {\n registry: leaderRegistry,\n isCommandAvailable: (commandName) =>\n BUILTIN_LEADER_COMMANDS.has(commandName) ||\n pi.getCommands().some((command) => command.name === commandName),\n onLeaderAction: (source, action) => {\n if (activeContext !== ctx || sessionGeneration !== activeGeneration) {\n ctx.ui.notify(`Leader action ${action} is unavailable.`, WARNING_STYLE);\n return;\n }\n protocol.notify(LeaderActionInvoked, { source, action });\n },\n onUnavailableCommand: (commandName) => {\n void telemetry.recordWarning(\n UI_EVENT.leaderCommandUnavailable,\n `Leader command /${commandName} is unavailable.`,\n { 'ui.kind': 'command' },\n );\n ctx.ui.notify(`Leader command /${commandName} is unavailable.`, WARNING_STYLE);\n },\n onUnavailableAction: (action) => {\n void telemetry.recordWarning(\n UI_EVENT.leaderActionUnavailable,\n `Leader action ${action} is unavailable.`,\n {\n 'ui.kind': 'action',\n },\n );\n ctx.ui.notify(`Leader action ${action} is unavailable.`, WARNING_STYLE);\n },\n },\n ),\n );\n\n void telemetry.recordEvent(UI_EVENT.shellInstalled, {\n 'ui.theme': themeName,\n 'ui.theme.applied': themeResult.success,\n 'ui.leader.group.count': leaderRegistry.getGroup([])?.options.length ?? 0,\n });\n });\n\n pi.on(INPUT_EVENT, (event, ctx) => {\n if (ctx.mode !== TUI_MODE || event.source !== INTERACTIVE_INPUT_SOURCE || hasSessionMessage) return;\n hasSessionMessage = true;\n const title = createMessageTitle(event.text, ctx.cwd);\n if (title) ctx.ui.setTitle(title);\n });\n\n pi.on(SESSION_SHUTDOWN_EVENT, async (_event, ctx) => {\n ++sessionGeneration;\n disposeLeaderBootstrap?.();\n disposeLeaderBootstrap = undefined;\n for (const dispose of protocolContributions.values()) dispose();\n protocolContributions.clear();\n activeContext = undefined;\n footerData = undefined;\n disposeFooterStatuses?.();\n disposeFooterStatuses = undefined;\n footerStatusRegistry.reset();\n disposeModeCatalogBinding?.();\n disposeModeCatalogBinding = undefined;\n disposeModeSubscription?.();\n disposeModeSubscription = undefined;\n modeCatalog.reset();\n disposeConfigContributions?.();\n disposeConfigContributions = undefined;\n disposeLeaderRegistration?.();\n disposeLeaderRegistration = undefined;\n disposeLeaderUnregistration?.();\n disposeLeaderUnregistration = undefined;\n configRegistry.reset();\n uiState.reset();\n sessionProtocol = undefined;\n if (ctx.mode === TUI_MODE) ctx.ui.setWidget(LEADER_WIDGET_KEY, undefined, { placement: WIDGET_PLACEMENT });\n await telemetry.shutdown();\n });\n}\n"],"mappings":"u4BA2BA,MAAM,EAAoB,iBAEpB,EAAmB,cACnB,EAAgB,UAahB,EAAe,UACf,EAA0B,IAAI,IAAI,CAAC,SAAe,CAAC,EAEzD,SAAS,EAAmB,EAAiB,EAAiC,CAC5E,IAAM,EAAoB,EAAQ,KAAK,CAAC,CAAC,QAAQ,OAAQ,GAAG,EAC5D,GAAI,CAAC,EAAmB,OACxB,IAAM,EAAe,EAAkB,MAAM,EAAG,EAAwB,CAAC,CAAC,QAAQ,EAClF,MAAO,GAAG,EAAa,KAAK,EAAa,KAAKA,EAAAA,QAAK,SAAS,CAAG,GAAK,GACtE,CAEA,SAAgB,EAAkB,EAAkB,EAAyBC,EAAAA,kBAAkB,EAAS,CACtG,EAAA,sBAAsB,EAAI,QAAQ,IAAI,CAAC,EACvC,IAAM,EAAU,IAAIC,EAAAA,YACd,EAAuB,IAAA,EAAA,eAAI,yBAC3B,GAAA,EAAcC,EAAAA,6BAAAA,CAA6B,EAC3C,EAAiB,IAAA,EAAA,eAAI,mBACrB,EAAiB,IAAIC,EAAAA,mBACrB,EAAqB,IAAI,IACzB,EAA0B,IAAI,IAChC,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACE,EAAwB,IAAI,IAC9B,EAAqB,EACrB,EAAoB,EACpB,EAAoB,GACpB,EACA,EAQE,EAAiB,SAA6D,CAC7E,KACL,GAAI,CAEF,OAAO,MADgB,EAAgB,QAAQC,EAAAA,uBAAwB,CAAC,EAAG,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,EACZ,mBAAoB,EAAY,QAChC,wBAAyB,EAAe,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,QAAU,CAC1E,CAAC,CACH,CAAC,EAED,EAAG,GAAG,SAAc,EAAO,IAAQ,CACjC,GAAI,EAAI,OAAS,OAAY,EAAM,SAAW,eAA4B,EAAmB,OAC7F,EAAoB,GACpB,IAAM,EAAQ,EAAmB,EAAM,KAAM,EAAI,GAAG,EAChD,GAAO,EAAI,GAAG,SAAS,CAAK,CAClC,CAAC,EAED,EAAG,GAAG,mBAAwB,MAAO,EAAQ,IAAQ,CACnD,EAAE,EACF,IAAyB,EACzB,EAAyB,IAAA,GACzB,IAAK,IAAM,KAAW,EAAsB,OAAO,EAAG,EAAQ,EAC9D,EAAsB,MAAM,EAC5B,EAAgB,IAAA,GAChB,EAAa,IAAA,GACb,IAAwB,EACxB,EAAwB,IAAA,GACxB,EAAqB,MAAM,EAC3B,IAA4B,EAC5B,EAA4B,IAAA,GAC5B,IAA0B,EAC1B,EAA0B,IAAA,GAC1B,EAAY,MAAM,EAClB,IAA6B,EAC7B,EAA6B,IAAA,GAC7B,IAA4B,EAC5B,EAA4B,IAAA,GAC5B,IAA8B,EAC9B,EAA8B,IAAA,GAC9B,EAAe,MAAM,EACrB,EAAQ,MAAM,EACd,EAAkB,IAAA,GACd,EAAI,OAAS,OAAU,EAAI,GAAG,UAAU,EAAmB,IAAA,GAAW,CAAE,UAAW,CAAiB,CAAC,EACzG,MAAM,EAAU,SAAS,CAC3B,CAAC,CACH"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{UI_EVENT as e,createUiTelemetry as t}from"../telemetry/logSinkTelemetry.mjs";import{config_exports as n}from"../../config.mjs";import{footer_exports as r}from"../../footer.mjs";import{DoomUiState as i}from"../../services/state/uiState.mjs";import{DoomLeaderRegistry as
|
|
1
|
+
import{UI_EVENT as e,createUiTelemetry as t}from"../telemetry/logSinkTelemetry.mjs";import{config_exports as n}from"../../config.mjs";import{footer_exports as r}from"../../footer.mjs";import{DoomUiState as i,projectMinorModeRecords as a}from"../../services/state/uiState.mjs";import{DoomLeaderRegistry as o}from"../../services/leader/leaderRegistry.mjs";import{DoomEditor as s}from"../../tui/doomEditor.mjs";import{DoomFooter as c}from"../../tui/doomFooter.mjs";import{DoomHeader as l}from"../../tui/doomHeader.mjs";import{LeaderHints as u}from"../../tui/leaderHints.mjs";import"../../tui/theme.mjs";import{openConfigOverlay as d}from"../../tui/configOverlay.mjs";import{openToolsOverlay as f}from"../../tui/toolsOverlay.mjs";import{buildToolSources as p}from"../../services/tools/toolInventory.mjs";import{registerBuiltinToolUi as m}from"./toolOverrides.mjs";import{LeaderActionInvoked as h,LeaderRegistrationProtocol as g,LeaderUnregistrationProtocol as _,installDoomLeaderBootstrapHost as v}from"@agimon-ai/doompi-extension-contracts/leader";import y from"node:path";import{McpStatusQueryProtocol as b}from"@agimon-ai/doompi-extension-contracts/mcp-status";import{createMinorModeCatalogClient as x}from"@agimon-ai/doompi-extension-contracts/mode";import{createProtocolRuntime as S}from"@agimon-ai/doompi-extension-contracts/protocol";const C=`doom-pi-leader`,w=`belowEditor`,T=`warning`,E=`doom-pi`,D=new Set([`hotkeys`]);function O(e,t){let n=e.trim().replace(/\s+/g,` `);if(!n)return;let r=n.slice(0,64).trimEnd();return`${E} · ${r} · ${y.basename(t)||t}`}function k(k,A=t()){m(k,process.cwd());let j=new i,M=new r.DoomFooterStatusRegistry,N=x(),P=new n.DoomConfigRegistry,F=new o,I=new Set,L=new Map,R,z,B,V,H,U,W,G,K=new Map,q=0,J=0,Y=!1,X,Z,ee=async()=>{if(X)try{return(await X.request(b,{},{timeoutMs:250})).servers}catch{return}};k.registerCommand(`tools`,{description:`Browse the tools available in this session`,handler:async(e,t)=>{let n=await ee(),r=p({tools:k.getAllTools(),activeTools:k.getActiveTools(),...n?{mcpServers:n}:{}});await f(t,r)}}),k.registerCommand(`config`,{description:`Browse and change the settings extensions contribute`,handler:async(e,t)=>{await d(t,P)}});let Q=t=>{for(let n of t){let t=n.bindingId?` (${n.bindingId})`:``,r=`Leader contribution from ${n.source}${t}: ${n.message}`;I.has(r)||(I.add(r),A.recordWarning(e.leaderContributionRejected,n.message,{"leader.source":n.source,...n.bindingId?{"leader.binding.id":n.bindingId}:{}}),z?.mode===`tui`&&z.ui.notify(r,T))}},$=(e,t)=>{let n=Symbol(e.source),r=t?e=>F.registerDeferred(e):e=>F.register(e),i=r(e);if(Q(i.diagnostics),!i.accepted)return{update:()=>void 0,dispose:()=>void 0};L.set(e.source,n);let a=!1;return{update(t){a||L.get(e.source)!==n||Q(r({source:e.source,bindings:t}).diagnostics)},dispose(){a||(a=!0,L.get(e.source)===n&&(L.delete(e.source),r({source:e.source,bindings:[]})))}}},te=Object.freeze({register(e){let t=$(e,!1);return()=>t.dispose()}});Z=v({register:e=>$(e,!0)}),k.on(`session_start`,(t,n)=>{z=n;let r=++J,i=S({bus:k.events,source:`@agimon-ai/doompi-ui`,sessionId:n.sessionManager.getSessionId()});if(X=i,Q(F.flush()),B?.(),M.reset(),B=M.bind(i),V?.(),V=N.bind(i),U?.(),P.reset(),U=P.bind(i),W?.(),G?.(),W=i.provide(g,({contribution:e,generation:t},n)=>{if(n.source!==e.source)throw Error(`Leader contribution source does not match the registration envelope source.`);let r=`${n.source}:${t}:${++q}`,i={source:e.source,bindings:e.bindings.map(e=>{let[t,...n]=e.path;if(!t)throw Error(`Leader binding '${e.id}' has no path.`);return{...e,path:[t,...n]}})};return K.set(r,te.register(i)),{handleId:r}}),G=i.provide(_,({handleId:e})=>{let t=K.get(e);return t?(K.delete(e),t(),{removed:!0}):{removed:!1}}),Y=n.sessionManager.getEntries().some(e=>e.type===`message`),n.mode!==`tui`)return;for(let e of I)n.ui.notify(e,T);let o=process.env.DOOMPI_THEME||`doom-pi-dark`,d=n.ui.setTheme(o);d.success||(n.ui.notify(`Could not apply Doom Pi theme: ${d.error}`,T),A.recordWarning(e.themeApplyFailed,d.error??`Unknown theme error`,{"ui.theme":o})),H?.(),H=N.subscribe(()=>j.setModes(a(N.list()))),j.setModes(a(N.list())),n.ui.setTitle(`${E} · ${y.basename(n.cwd)||n.cwd} · pi/coding`),n.ui.setHeader((e,t)=>new l(t,n.cwd,void 0,n,()=>e.terminal.rows)),n.ui.setFooter((e,t,r)=>(R=r,new c(e,t,n,r,M,j))),n.ui.setEditorComponent((t,a,o)=>new s(t,a,o,j,e=>{if(!e.active){n.ui.setWidget(C,void 0,{placement:w});return}n.ui.setWidget(C,(t,r)=>new u(r,e,n,R,j.getModes()),{placement:w})},void 0,n.ui.theme,{registry:F,isCommandAvailable:e=>D.has(e)||k.getCommands().some(t=>t.name===e),onLeaderAction:(e,t)=>{if(z!==n||J!==r){n.ui.notify(`Leader action ${t} is unavailable.`,T);return}i.notify(h,{source:e,action:t})},onUnavailableCommand:t=>{A.recordWarning(e.leaderCommandUnavailable,`Leader command /${t} is unavailable.`,{"ui.kind":`command`}),n.ui.notify(`Leader command /${t} is unavailable.`,T)},onUnavailableAction:t=>{A.recordWarning(e.leaderActionUnavailable,`Leader action ${t} is unavailable.`,{"ui.kind":`action`}),n.ui.notify(`Leader action ${t} is unavailable.`,T)}})),A.recordEvent(e.shellInstalled,{"ui.theme":o,"ui.theme.applied":d.success,"ui.leader.group.count":F.getGroup([])?.options.length??0})}),k.on(`input`,(e,t)=>{if(t.mode!==`tui`||e.source!==`interactive`||Y)return;Y=!0;let n=O(e.text,t.cwd);n&&t.ui.setTitle(n)}),k.on(`session_shutdown`,async(e,t)=>{++J,Z?.(),Z=void 0;for(let e of K.values())e();K.clear(),z=void 0,R=void 0,B?.(),B=void 0,M.reset(),V?.(),V=void 0,H?.(),H=void 0,N.reset(),U?.(),U=void 0,W?.(),W=void 0,G?.(),G=void 0,P.reset(),j.reset(),X=void 0,t.mode===`tui`&&t.ui.setWidget(C,void 0,{placement:w}),await A.shutdown()})}export{k as doomPiUiExtension};
|
|
2
2
|
//# sourceMappingURL=extension.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.mjs","names":["DoomFooterStatusRegistry","DoomModeStatusRegistry","DoomConfigRegistry"],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import path from 'node:path';\nimport {\n installDoomLeaderBootstrapHost,\n LeaderActionInvoked,\n type LeaderContribution,\n LeaderRegistrationProtocol,\n LeaderUnregistrationProtocol,\n} from '@agimon-ai/doompi-extension-contracts/leader';\nimport { McpStatusQueryProtocol } from '@agimon-ai/doompi-extension-contracts/mcp-status';\nimport { createProtocolRuntime, type ProtocolRuntime } from '@agimon-ai/doompi-extension-contracts/protocol';\nimport type { ExtensionAPI, ExtensionContext, ReadonlyFooterDataProvider } from '@earendil-works/pi-coding-agent';\nimport { DoomConfigRegistry } from '../../config.ts';\nimport { DoomFooterStatusRegistry } from '../../footer.ts';\nimport { DoomModeStatusRegistry } from '../../mode.ts';\nimport { type DoomLeaderDiagnostic, DoomLeaderRegistry } from '../../services/leader/leaderRegistry.ts';\nimport { DoomUiState, type LeaderSnapshot } from '../../services/state/uiState.ts';\nimport { buildToolSources, type McpServerStatus } from '../../services/tools/toolInventory.ts';\nimport { openConfigOverlay } from '../../tui/configOverlay.ts';\nimport { DoomEditor } from '../../tui/doomEditor.ts';\nimport { DoomFooter } from '../../tui/doomFooter.ts';\nimport { DoomHeader } from '../../tui/doomHeader.ts';\nimport { LeaderHints } from '../../tui/leaderHints.ts';\nimport { DEFAULT_THEME_NAME } from '../../tui/theme.ts';\nimport { openToolsOverlay } from '../../tui/toolsOverlay.ts';\nimport { createUiTelemetry, UI_EVENT, type UiTelemetry } from '../telemetry/logSinkTelemetry.ts';\nimport { registerBuiltinToolUi } from './toolOverrides.ts';\n\nconst LEADER_WIDGET_KEY = 'doom-pi-leader';\nconst TUI_MODE = 'tui';\nconst WIDGET_PLACEMENT = 'belowEditor';\nconst WARNING_STYLE = 'warning';\nconst THEME_ENVIRONMENT_KEY = 'DOOMPI_THEME';\nconst HOTKEYS_COMMAND = 'hotkeys';\nconst TOOLS_COMMAND = 'tools';\nconst CONFIG_COMMAND = 'config';\n/** Short: `/tools` must open promptly whether or not an MCP extension answers. */\nconst MCP_STATUS_TIMEOUT_MS = 250;\nconst SESSION_START_EVENT = 'session_start';\nconst SESSION_MESSAGE_ENTRY = 'message';\nconst INPUT_EVENT = 'input';\nconst INTERACTIVE_INPUT_SOURCE = 'interactive';\nconst SESSION_SHUTDOWN_EVENT = 'session_shutdown';\nconst TITLE_MESSAGE_MAX_LENGTH = 64;\nconst TITLE_PREFIX = 'doom-pi';\nconst BUILTIN_LEADER_COMMANDS = new Set([HOTKEYS_COMMAND]);\n\nfunction createMessageTitle(message: string, cwd: string): string | undefined {\n const normalizedMessage = message.trim().replace(/\\s+/g, ' ');\n if (!normalizedMessage) return undefined;\n const messageTitle = normalizedMessage.slice(0, TITLE_MESSAGE_MAX_LENGTH).trimEnd();\n return `${TITLE_PREFIX} · ${messageTitle} · ${path.basename(cwd) || cwd}`;\n}\n\nexport function doomPiUiExtension(pi: ExtensionAPI, telemetry: UiTelemetry = createUiTelemetry()): void {\n registerBuiltinToolUi(pi, process.cwd());\n const uiState = new DoomUiState();\n const footerStatusRegistry = new DoomFooterStatusRegistry();\n const modeStatusRegistry = new DoomModeStatusRegistry();\n const configRegistry = new DoomConfigRegistry();\n const leaderRegistry = new DoomLeaderRegistry();\n const pendingDiagnostics = new Set<string>();\n const contributionGenerations = new Map<string, symbol>();\n let footerData: ReadonlyFooterDataProvider | undefined;\n let activeContext: ExtensionContext | undefined;\n let disposeFooterStatuses: (() => void) | undefined;\n let disposeModeStatuses: (() => void) | undefined;\n let disposeModeSubscription: (() => void) | undefined;\n let disposeConfigContributions: (() => void) | undefined;\n let disposeLeaderRegistration: (() => void) | undefined;\n let disposeLeaderUnregistration: (() => void) | undefined;\n const protocolContributions = new Map<string, () => void>();\n let nextProtocolHandle = 0;\n let sessionGeneration = 0;\n let hasSessionMessage = false;\n let sessionProtocol: ProtocolRuntime | undefined;\n let disposeLeaderBootstrap: (() => void) | undefined;\n\n /**\n * Asks the MCP extension what it is currently connected to.\n *\n * No answer is a normal session: `--no-mcp` leaves nobody providing the query,\n * and the panel simply lists MCP tools under the extension that registered them.\n */\n const readMcpServers = async (): Promise<readonly McpServerStatus[] | undefined> => {\n if (!sessionProtocol) return undefined;\n try {\n const snapshot = await sessionProtocol.request(McpStatusQueryProtocol, {}, { timeoutMs: MCP_STATUS_TIMEOUT_MS });\n return snapshot.servers;\n } catch {\n return undefined;\n }\n };\n\n pi.registerCommand(TOOLS_COMMAND, {\n description: 'Browse the tools available in this session',\n handler: async (_args, ctx) => {\n // Read at open time so a reconnected server or a plan-mode tool swap shows\n // up without restarting the session.\n const mcpServers = await readMcpServers();\n const sources = buildToolSources({\n tools: pi.getAllTools(),\n activeTools: pi.getActiveTools(),\n ...(mcpServers ? { mcpServers } : {}),\n });\n await openToolsOverlay(ctx, sources);\n },\n });\n\n pi.registerCommand(CONFIG_COMMAND, {\n description: 'Browse and change the settings extensions contribute',\n handler: async (_args, ctx) => {\n // The registry is passed live rather than snapshotted: a contributor can be\n // fetching or installing something while the panel is open, and that\n // progress is meant to land in it.\n await openConfigOverlay(ctx, configRegistry);\n },\n });\n\n const reportDiagnostics = (diagnostics: readonly DoomLeaderDiagnostic[]): void => {\n for (const diagnostic of diagnostics) {\n const binding = diagnostic.bindingId ? ` (${diagnostic.bindingId})` : '';\n const message = `Leader contribution from ${diagnostic.source}${binding}: ${diagnostic.message}`;\n if (pendingDiagnostics.has(message)) continue;\n pendingDiagnostics.add(message);\n // A rejected contribution silently drops another extension's keybindings,\n // and the notice below only reaches a run that has a TUI attached.\n void telemetry.recordWarning(UI_EVENT.leaderContributionRejected, diagnostic.message, {\n 'leader.source': diagnostic.source,\n ...(diagnostic.bindingId ? { 'leader.binding.id': diagnostic.bindingId } : {}),\n });\n if (activeContext?.mode === TUI_MODE) activeContext.ui.notify(message, WARNING_STYLE);\n }\n };\n\n const registerLeaderContribution = (contribution: LeaderContribution, deferred: boolean) => {\n const generation = Symbol(contribution.source);\n const register = deferred\n ? (value: LeaderContribution) => leaderRegistry.registerDeferred(value)\n : (value: LeaderContribution) => leaderRegistry.register(value);\n const result = register(contribution);\n reportDiagnostics(result.diagnostics);\n if (!result.accepted) return { update: () => undefined, dispose: () => undefined };\n contributionGenerations.set(contribution.source, generation);\n let disposed = false;\n return {\n update(bindings: LeaderContribution['bindings']) {\n if (disposed || contributionGenerations.get(contribution.source) !== generation) return;\n reportDiagnostics(register({ source: contribution.source, bindings }).diagnostics);\n },\n dispose() {\n if (disposed) return;\n disposed = true;\n if (contributionGenerations.get(contribution.source) !== generation) return;\n contributionGenerations.delete(contribution.source);\n register({ source: contribution.source, bindings: [] });\n },\n };\n };\n\n const leaderContext = Object.freeze({\n register(contribution: LeaderContribution) {\n const handle = registerLeaderContribution(contribution, false);\n return () => handle.dispose();\n },\n });\n // Installed during the UI factory, before the remaining Doom factories run.\n // Their registrations are validated immediately and rebuilt as one batch at\n // session_start, so the first editor always receives the complete keyspace.\n disposeLeaderBootstrap = installDoomLeaderBootstrapHost({\n register: (contribution) => registerLeaderContribution(contribution, true),\n });\n pi.on(SESSION_START_EVENT, (_event, ctx) => {\n activeContext = ctx;\n const activeGeneration = ++sessionGeneration;\n const protocol = createProtocolRuntime({\n bus: pi.events,\n source: '@agimon-ai/doompi-ui',\n sessionId: ctx.sessionManager.getSessionId(),\n });\n sessionProtocol = protocol;\n reportDiagnostics(leaderRegistry.flush());\n disposeFooterStatuses?.();\n footerStatusRegistry.reset();\n disposeFooterStatuses = footerStatusRegistry.bind(protocol);\n disposeModeStatuses?.();\n modeStatusRegistry.reset();\n disposeModeStatuses = modeStatusRegistry.bind(protocol);\n // Bound above the TUI-mode guard below, like footer and mode: a headless run\n // still accepts contributions, it just never draws them.\n disposeConfigContributions?.();\n configRegistry.reset();\n disposeConfigContributions = configRegistry.bind(protocol);\n disposeLeaderRegistration?.();\n disposeLeaderUnregistration?.();\n disposeLeaderRegistration = protocol.provide(\n LeaderRegistrationProtocol,\n ({ contribution, generation }, identity) => {\n if (identity.source !== contribution.source) {\n throw new Error('Leader contribution source does not match the registration envelope source.');\n }\n const handleId = `${identity.source}:${generation}:${++nextProtocolHandle}`;\n const typedContribution: LeaderContribution = {\n source: contribution.source,\n bindings: contribution.bindings.map((binding) => {\n const [first, ...rest] = binding.path;\n if (!first) throw new Error(`Leader binding '${binding.id}' has no path.`);\n return { ...binding, path: [first, ...rest] };\n }),\n };\n protocolContributions.set(handleId, leaderContext.register(typedContribution));\n return { handleId };\n },\n );\n disposeLeaderUnregistration = protocol.provide(LeaderUnregistrationProtocol, ({ handleId }) => {\n const dispose = protocolContributions.get(handleId);\n if (!dispose) return { removed: false };\n protocolContributions.delete(handleId);\n dispose();\n return { removed: true };\n });\n hasSessionMessage = ctx.sessionManager.getEntries().some((entry) => entry.type === SESSION_MESSAGE_ENTRY);\n if (ctx.mode !== TUI_MODE) return;\n for (const message of pendingDiagnostics) ctx.ui.notify(message, WARNING_STYLE);\n\n const themeName = process.env[THEME_ENVIRONMENT_KEY] || DEFAULT_THEME_NAME;\n const themeResult = ctx.ui.setTheme(themeName);\n if (!themeResult.success) {\n ctx.ui.notify(`Could not apply Doom Pi theme: ${themeResult.error}`, WARNING_STYLE);\n void telemetry.recordWarning(UI_EVENT.themeApplyFailed, themeResult.error ?? 'Unknown theme error', {\n 'ui.theme': themeName,\n });\n }\n\n // The modes go into shared state rather than a widget of their own: the\n // editor prints their names beside its badge and the leader panel prints\n // them with their detail, so there is no third surface to paint.\n disposeModeSubscription?.();\n disposeModeSubscription = modeStatusRegistry.subscribe(() => uiState.setModes(modeStatusRegistry.getStatuses()));\n uiState.setModes(modeStatusRegistry.getStatuses());\n\n ctx.ui.setTitle(`${TITLE_PREFIX} · ${path.basename(ctx.cwd) || ctx.cwd} · pi/coding`);\n ctx.ui.setHeader((tui, theme) => new DoomHeader(theme, ctx.cwd, undefined, ctx, () => tui.terminal.rows));\n ctx.ui.setFooter((tui, theme, data) => {\n footerData = data;\n return new DoomFooter(tui, theme, ctx, data, footerStatusRegistry, uiState);\n });\n ctx.ui.setEditorComponent(\n (tui, editorTheme, keybindings) =>\n new DoomEditor(\n tui,\n editorTheme,\n keybindings,\n uiState,\n (snapshot: LeaderSnapshot) => {\n if (!snapshot.active) {\n ctx.ui.setWidget(LEADER_WIDGET_KEY, undefined, { placement: WIDGET_PLACEMENT });\n return;\n }\n ctx.ui.setWidget(\n LEADER_WIDGET_KEY,\n (_widgetTui, widgetTheme) => new LeaderHints(widgetTheme, snapshot, ctx, footerData, uiState.getModes()),\n { placement: WIDGET_PLACEMENT },\n );\n },\n undefined,\n ctx.ui.theme,\n {\n registry: leaderRegistry,\n isCommandAvailable: (commandName) =>\n BUILTIN_LEADER_COMMANDS.has(commandName) ||\n pi.getCommands().some((command) => command.name === commandName),\n onLeaderAction: (source, action) => {\n if (activeContext !== ctx || sessionGeneration !== activeGeneration) {\n ctx.ui.notify(`Leader action ${action} is unavailable.`, WARNING_STYLE);\n return;\n }\n protocol.notify(LeaderActionInvoked, { source, action });\n },\n onUnavailableCommand: (commandName) => {\n void telemetry.recordWarning(\n UI_EVENT.leaderCommandUnavailable,\n `Leader command /${commandName} is unavailable.`,\n { 'ui.kind': 'command' },\n );\n ctx.ui.notify(`Leader command /${commandName} is unavailable.`, WARNING_STYLE);\n },\n onUnavailableAction: (action) => {\n void telemetry.recordWarning(\n UI_EVENT.leaderActionUnavailable,\n `Leader action ${action} is unavailable.`,\n {\n 'ui.kind': 'action',\n },\n );\n ctx.ui.notify(`Leader action ${action} is unavailable.`, WARNING_STYLE);\n },\n },\n ),\n );\n\n void telemetry.recordEvent(UI_EVENT.shellInstalled, {\n 'ui.theme': themeName,\n 'ui.theme.applied': themeResult.success,\n 'ui.leader.group.count': leaderRegistry.getGroup([])?.options.length ?? 0,\n });\n });\n\n pi.on(INPUT_EVENT, (event, ctx) => {\n if (ctx.mode !== TUI_MODE || event.source !== INTERACTIVE_INPUT_SOURCE || hasSessionMessage) return;\n hasSessionMessage = true;\n const title = createMessageTitle(event.text, ctx.cwd);\n if (title) ctx.ui.setTitle(title);\n });\n\n pi.on(SESSION_SHUTDOWN_EVENT, async (_event, ctx) => {\n ++sessionGeneration;\n disposeLeaderBootstrap?.();\n disposeLeaderBootstrap = undefined;\n for (const dispose of protocolContributions.values()) dispose();\n protocolContributions.clear();\n activeContext = undefined;\n footerData = undefined;\n disposeFooterStatuses?.();\n disposeFooterStatuses = undefined;\n footerStatusRegistry.reset();\n disposeModeStatuses?.();\n disposeModeStatuses = undefined;\n disposeModeSubscription?.();\n disposeModeSubscription = undefined;\n modeStatusRegistry.reset();\n disposeConfigContributions?.();\n disposeConfigContributions = undefined;\n disposeLeaderRegistration?.();\n disposeLeaderRegistration = undefined;\n disposeLeaderUnregistration?.();\n disposeLeaderUnregistration = undefined;\n configRegistry.reset();\n uiState.reset();\n sessionProtocol = undefined;\n if (ctx.mode === TUI_MODE) ctx.ui.setWidget(LEADER_WIDGET_KEY, undefined, { placement: WIDGET_PLACEMENT });\n await telemetry.shutdown();\n });\n}\n"],"mappings":"gvCA2BA,MAAM,EAAoB,iBAEpB,EAAmB,cACnB,EAAgB,UAahB,EAAe,UACf,EAA0B,IAAI,IAAI,CAAC,SAAe,CAAC,EAEzD,SAAS,EAAmB,EAAiB,EAAiC,CAC5E,IAAM,EAAoB,EAAQ,KAAK,CAAC,CAAC,QAAQ,OAAQ,GAAG,EAC5D,GAAI,CAAC,EAAmB,OACxB,IAAM,EAAe,EAAkB,MAAM,EAAG,EAAwB,CAAC,CAAC,QAAQ,EAClF,MAAO,GAAG,EAAa,KAAK,EAAa,KAAK,EAAK,SAAS,CAAG,GAAK,GACtE,CAEA,SAAgB,EAAkB,EAAkB,EAAyB,EAAkB,EAAS,CACtG,EAAsB,EAAI,QAAQ,IAAI,CAAC,EACvC,IAAM,EAAU,IAAI,EACd,EAAuB,IAAIA,EAAAA,yBAC3B,EAAqB,IAAIC,EAAAA,uBACzB,EAAiB,IAAIC,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E,CACF,CACF,CACJ,EAEA,EAAe,YAAY,EAAS,eAAgB,CAClD,WAAY,EACZ,mBAAoB,EAAY,QAChC,wBAAyB,EAAe,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,QAAU,CAC1E,CAAC,CACH,CAAC,EAED,EAAG,GAAG,SAAc,EAAO,IAAQ,CACjC,GAAI,EAAI,OAAS,OAAY,EAAM,SAAW,eAA4B,EAAmB,OAC7F,EAAoB,GACpB,IAAM,EAAQ,EAAmB,EAAM,KAAM,EAAI,GAAG,EAChD,GAAO,EAAI,GAAG,SAAS,CAAK,CAClC,CAAC,EAED,EAAG,GAAG,mBAAwB,MAAO,EAAQ,IAAQ,CACnD,EAAE,EACF,IAAyB,EACzB,EAAyB,IAAA,GACzB,IAAK,IAAM,KAAW,EAAsB,OAAO,EAAG,EAAQ,EAC9D,EAAsB,MAAM,EAC5B,EAAgB,IAAA,GAChB,EAAa,IAAA,GACb,IAAwB,EACxB,EAAwB,IAAA,GACxB,EAAqB,MAAM,EAC3B,IAAsB,EACtB,EAAsB,IAAA,GACtB,IAA0B,EAC1B,EAA0B,IAAA,GAC1B,EAAmB,MAAM,EACzB,IAA6B,EAC7B,EAA6B,IAAA,GAC7B,IAA4B,EAC5B,EAA4B,IAAA,GAC5B,IAA8B,EAC9B,EAA8B,IAAA,GAC9B,EAAe,MAAM,EACrB,EAAQ,MAAM,EACd,EAAkB,IAAA,GACd,EAAI,OAAS,OAAU,EAAI,GAAG,UAAU,EAAmB,IAAA,GAAW,CAAE,UAAW,CAAiB,CAAC,EACzG,MAAM,EAAU,SAAS,CAC3B,CAAC,CACH"}
|
|
1
|
+
{"version":3,"file":"extension.mjs","names":["DoomFooterStatusRegistry","DoomConfigRegistry"],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import path from 'node:path';\nimport {\n installDoomLeaderBootstrapHost,\n LeaderActionInvoked,\n type LeaderContribution,\n LeaderRegistrationProtocol,\n LeaderUnregistrationProtocol,\n} from '@agimon-ai/doompi-extension-contracts/leader';\nimport { McpStatusQueryProtocol } from '@agimon-ai/doompi-extension-contracts/mcp-status';\nimport { createMinorModeCatalogClient } from '@agimon-ai/doompi-extension-contracts/mode';\nimport { createProtocolRuntime, type ProtocolRuntime } from '@agimon-ai/doompi-extension-contracts/protocol';\nimport type { ExtensionAPI, ExtensionContext, ReadonlyFooterDataProvider } from '@earendil-works/pi-coding-agent';\nimport { DoomConfigRegistry } from '../../config.ts';\nimport { DoomFooterStatusRegistry } from '../../footer.ts';\nimport { type DoomLeaderDiagnostic, DoomLeaderRegistry } from '../../services/leader/leaderRegistry.ts';\nimport { DoomUiState, type LeaderSnapshot, projectMinorModeRecords } from '../../services/state/uiState.ts';\nimport { buildToolSources, type McpServerStatus } from '../../services/tools/toolInventory.ts';\nimport { openConfigOverlay } from '../../tui/configOverlay.ts';\nimport { DoomEditor } from '../../tui/doomEditor.ts';\nimport { DoomFooter } from '../../tui/doomFooter.ts';\nimport { DoomHeader } from '../../tui/doomHeader.ts';\nimport { LeaderHints } from '../../tui/leaderHints.ts';\nimport { DEFAULT_THEME_NAME } from '../../tui/theme.ts';\nimport { openToolsOverlay } from '../../tui/toolsOverlay.ts';\nimport { createUiTelemetry, UI_EVENT, type UiTelemetry } from '../telemetry/logSinkTelemetry.ts';\nimport { registerBuiltinToolUi } from './toolOverrides.ts';\n\nconst LEADER_WIDGET_KEY = 'doom-pi-leader';\nconst TUI_MODE = 'tui';\nconst WIDGET_PLACEMENT = 'belowEditor';\nconst WARNING_STYLE = 'warning';\nconst THEME_ENVIRONMENT_KEY = 'DOOMPI_THEME';\nconst HOTKEYS_COMMAND = 'hotkeys';\nconst TOOLS_COMMAND = 'tools';\nconst CONFIG_COMMAND = 'config';\n/** Short: `/tools` must open promptly whether or not an MCP extension answers. */\nconst MCP_STATUS_TIMEOUT_MS = 250;\nconst SESSION_START_EVENT = 'session_start';\nconst SESSION_MESSAGE_ENTRY = 'message';\nconst INPUT_EVENT = 'input';\nconst INTERACTIVE_INPUT_SOURCE = 'interactive';\nconst SESSION_SHUTDOWN_EVENT = 'session_shutdown';\nconst TITLE_MESSAGE_MAX_LENGTH = 64;\nconst TITLE_PREFIX = 'doom-pi';\nconst BUILTIN_LEADER_COMMANDS = new Set([HOTKEYS_COMMAND]);\n\nfunction createMessageTitle(message: string, cwd: string): string | undefined {\n const normalizedMessage = message.trim().replace(/\\s+/g, ' ');\n if (!normalizedMessage) return undefined;\n const messageTitle = normalizedMessage.slice(0, TITLE_MESSAGE_MAX_LENGTH).trimEnd();\n return `${TITLE_PREFIX} · ${messageTitle} · ${path.basename(cwd) || cwd}`;\n}\n\nexport function doomPiUiExtension(pi: ExtensionAPI, telemetry: UiTelemetry = createUiTelemetry()): void {\n registerBuiltinToolUi(pi, process.cwd());\n const uiState = new DoomUiState();\n const footerStatusRegistry = new DoomFooterStatusRegistry();\n const modeCatalog = createMinorModeCatalogClient();\n const configRegistry = new DoomConfigRegistry();\n const leaderRegistry = new DoomLeaderRegistry();\n const pendingDiagnostics = new Set<string>();\n const contributionGenerations = new Map<string, symbol>();\n let footerData: ReadonlyFooterDataProvider | undefined;\n let activeContext: ExtensionContext | undefined;\n let disposeFooterStatuses: (() => void) | undefined;\n let disposeModeCatalogBinding: (() => void) | undefined;\n let disposeModeSubscription: (() => void) | undefined;\n let disposeConfigContributions: (() => void) | undefined;\n let disposeLeaderRegistration: (() => void) | undefined;\n let disposeLeaderUnregistration: (() => void) | undefined;\n const protocolContributions = new Map<string, () => void>();\n let nextProtocolHandle = 0;\n let sessionGeneration = 0;\n let hasSessionMessage = false;\n let sessionProtocol: ProtocolRuntime | undefined;\n let disposeLeaderBootstrap: (() => void) | undefined;\n\n /**\n * Asks the MCP extension what it is currently connected to.\n *\n * No answer is a normal session: `--no-mcp` leaves nobody providing the query,\n * and the panel simply lists MCP tools under the extension that registered them.\n */\n const readMcpServers = async (): Promise<readonly McpServerStatus[] | undefined> => {\n if (!sessionProtocol) return undefined;\n try {\n const snapshot = await sessionProtocol.request(McpStatusQueryProtocol, {}, { timeoutMs: MCP_STATUS_TIMEOUT_MS });\n return snapshot.servers;\n } catch {\n return undefined;\n }\n };\n\n pi.registerCommand(TOOLS_COMMAND, {\n description: 'Browse the tools available in this session',\n handler: async (_args, ctx) => {\n // Read at open time so a reconnected server or a plan-mode tool swap shows\n // up without restarting the session.\n const mcpServers = await readMcpServers();\n const sources = buildToolSources({\n tools: pi.getAllTools(),\n activeTools: pi.getActiveTools(),\n ...(mcpServers ? { mcpServers } : {}),\n });\n await openToolsOverlay(ctx, sources);\n },\n });\n\n pi.registerCommand(CONFIG_COMMAND, {\n description: 'Browse and change the settings extensions contribute',\n handler: async (_args, ctx) => {\n // The registry is passed live rather than snapshotted: a contributor can be\n // fetching or installing something while the panel is open, and that\n // progress is meant to land in it.\n await openConfigOverlay(ctx, configRegistry);\n },\n });\n\n const reportDiagnostics = (diagnostics: readonly DoomLeaderDiagnostic[]): void => {\n for (const diagnostic of diagnostics) {\n const binding = diagnostic.bindingId ? ` (${diagnostic.bindingId})` : '';\n const message = `Leader contribution from ${diagnostic.source}${binding}: ${diagnostic.message}`;\n if (pendingDiagnostics.has(message)) continue;\n pendingDiagnostics.add(message);\n // A rejected contribution silently drops another extension's keybindings,\n // and the notice below only reaches a run that has a TUI attached.\n void telemetry.recordWarning(UI_EVENT.leaderContributionRejected, diagnostic.message, {\n 'leader.source': diagnostic.source,\n ...(diagnostic.bindingId ? { 'leader.binding.id': diagnostic.bindingId } : {}),\n });\n if (activeContext?.mode === TUI_MODE) activeContext.ui.notify(message, WARNING_STYLE);\n }\n };\n\n const registerLeaderContribution = (contribution: LeaderContribution, deferred: boolean) => {\n const generation = Symbol(contribution.source);\n const register = deferred\n ? (value: LeaderContribution) => leaderRegistry.registerDeferred(value)\n : (value: LeaderContribution) => leaderRegistry.register(value);\n const result = register(contribution);\n reportDiagnostics(result.diagnostics);\n if (!result.accepted) return { update: () => undefined, dispose: () => undefined };\n contributionGenerations.set(contribution.source, generation);\n let disposed = false;\n return {\n update(bindings: LeaderContribution['bindings']) {\n if (disposed || contributionGenerations.get(contribution.source) !== generation) return;\n reportDiagnostics(register({ source: contribution.source, bindings }).diagnostics);\n },\n dispose() {\n if (disposed) return;\n disposed = true;\n if (contributionGenerations.get(contribution.source) !== generation) return;\n contributionGenerations.delete(contribution.source);\n register({ source: contribution.source, bindings: [] });\n },\n };\n };\n\n const leaderContext = Object.freeze({\n register(contribution: LeaderContribution) {\n const handle = registerLeaderContribution(contribution, false);\n return () => handle.dispose();\n },\n });\n // Installed during the UI factory, before the remaining Doom factories run.\n // Their registrations are validated immediately and rebuilt as one batch at\n // session_start, so the first editor always receives the complete keyspace.\n disposeLeaderBootstrap = installDoomLeaderBootstrapHost({\n register: (contribution) => registerLeaderContribution(contribution, true),\n });\n pi.on(SESSION_START_EVENT, (_event, ctx) => {\n activeContext = ctx;\n const activeGeneration = ++sessionGeneration;\n const protocol = createProtocolRuntime({\n bus: pi.events,\n source: '@agimon-ai/doompi-ui',\n sessionId: ctx.sessionManager.getSessionId(),\n });\n sessionProtocol = protocol;\n reportDiagnostics(leaderRegistry.flush());\n disposeFooterStatuses?.();\n footerStatusRegistry.reset();\n disposeFooterStatuses = footerStatusRegistry.bind(protocol);\n disposeModeCatalogBinding?.();\n disposeModeCatalogBinding = modeCatalog.bind(protocol);\n // Bound above the TUI-mode guard below, like footer and mode: a headless run\n // still accepts contributions, it just never draws them.\n disposeConfigContributions?.();\n configRegistry.reset();\n disposeConfigContributions = configRegistry.bind(protocol);\n disposeLeaderRegistration?.();\n disposeLeaderUnregistration?.();\n disposeLeaderRegistration = protocol.provide(\n LeaderRegistrationProtocol,\n ({ contribution, generation }, identity) => {\n if (identity.source !== contribution.source) {\n throw new Error('Leader contribution source does not match the registration envelope source.');\n }\n const handleId = `${identity.source}:${generation}:${++nextProtocolHandle}`;\n const typedContribution: LeaderContribution = {\n source: contribution.source,\n bindings: contribution.bindings.map((binding) => {\n const [first, ...rest] = binding.path;\n if (!first) throw new Error(`Leader binding '${binding.id}' has no path.`);\n return { ...binding, path: [first, ...rest] };\n }),\n };\n protocolContributions.set(handleId, leaderContext.register(typedContribution));\n return { handleId };\n },\n );\n disposeLeaderUnregistration = protocol.provide(LeaderUnregistrationProtocol, ({ handleId }) => {\n const dispose = protocolContributions.get(handleId);\n if (!dispose) return { removed: false };\n protocolContributions.delete(handleId);\n dispose();\n return { removed: true };\n });\n hasSessionMessage = ctx.sessionManager.getEntries().some((entry) => entry.type === SESSION_MESSAGE_ENTRY);\n if (ctx.mode !== TUI_MODE) return;\n for (const message of pendingDiagnostics) ctx.ui.notify(message, WARNING_STYLE);\n\n const themeName = process.env[THEME_ENVIRONMENT_KEY] || DEFAULT_THEME_NAME;\n const themeResult = ctx.ui.setTheme(themeName);\n if (!themeResult.success) {\n ctx.ui.notify(`Could not apply Doom Pi theme: ${themeResult.error}`, WARNING_STYLE);\n void telemetry.recordWarning(UI_EVENT.themeApplyFailed, themeResult.error ?? 'Unknown theme error', {\n 'ui.theme': themeName,\n });\n }\n\n // The modes go into shared state rather than a widget of their own: the\n // editor prints their names beside its badge and the leader panel prints\n // them with their detail, so there is no third surface to paint.\n disposeModeSubscription?.();\n disposeModeSubscription = modeCatalog.subscribe(() =>\n uiState.setModes(projectMinorModeRecords(modeCatalog.list())),\n );\n uiState.setModes(projectMinorModeRecords(modeCatalog.list()));\n\n ctx.ui.setTitle(`${TITLE_PREFIX} · ${path.basename(ctx.cwd) || ctx.cwd} · pi/coding`);\n ctx.ui.setHeader((tui, theme) => new DoomHeader(theme, ctx.cwd, undefined, ctx, () => tui.terminal.rows));\n ctx.ui.setFooter((tui, theme, data) => {\n footerData = data;\n return new DoomFooter(tui, theme, ctx, data, footerStatusRegistry, uiState);\n });\n ctx.ui.setEditorComponent(\n (tui, editorTheme, keybindings) =>\n new DoomEditor(\n tui,\n editorTheme,\n keybindings,\n uiState,\n (snapshot: LeaderSnapshot) => {\n if (!snapshot.active) {\n ctx.ui.setWidget(LEADER_WIDGET_KEY, undefined, { placement: WIDGET_PLACEMENT });\n return;\n }\n ctx.ui.setWidget(\n LEADER_WIDGET_KEY,\n (_widgetTui, widgetTheme) => new LeaderHints(widgetTheme, snapshot, ctx, footerData, uiState.getModes()),\n { placement: WIDGET_PLACEMENT },\n );\n },\n undefined,\n ctx.ui.theme,\n {\n registry: leaderRegistry,\n isCommandAvailable: (commandName) =>\n BUILTIN_LEADER_COMMANDS.has(commandName) ||\n pi.getCommands().some((command) => command.name === commandName),\n onLeaderAction: (source, action) => {\n if (activeContext !== ctx || sessionGeneration !== activeGeneration) {\n ctx.ui.notify(`Leader action ${action} is unavailable.`, WARNING_STYLE);\n return;\n }\n protocol.notify(LeaderActionInvoked, { source, action });\n },\n onUnavailableCommand: (commandName) => {\n void telemetry.recordWarning(\n UI_EVENT.leaderCommandUnavailable,\n `Leader command /${commandName} is unavailable.`,\n { 'ui.kind': 'command' },\n );\n ctx.ui.notify(`Leader command /${commandName} is unavailable.`, WARNING_STYLE);\n },\n onUnavailableAction: (action) => {\n void telemetry.recordWarning(\n UI_EVENT.leaderActionUnavailable,\n `Leader action ${action} is unavailable.`,\n {\n 'ui.kind': 'action',\n },\n );\n ctx.ui.notify(`Leader action ${action} is unavailable.`, WARNING_STYLE);\n },\n },\n ),\n );\n\n void telemetry.recordEvent(UI_EVENT.shellInstalled, {\n 'ui.theme': themeName,\n 'ui.theme.applied': themeResult.success,\n 'ui.leader.group.count': leaderRegistry.getGroup([])?.options.length ?? 0,\n });\n });\n\n pi.on(INPUT_EVENT, (event, ctx) => {\n if (ctx.mode !== TUI_MODE || event.source !== INTERACTIVE_INPUT_SOURCE || hasSessionMessage) return;\n hasSessionMessage = true;\n const title = createMessageTitle(event.text, ctx.cwd);\n if (title) ctx.ui.setTitle(title);\n });\n\n pi.on(SESSION_SHUTDOWN_EVENT, async (_event, ctx) => {\n ++sessionGeneration;\n disposeLeaderBootstrap?.();\n disposeLeaderBootstrap = undefined;\n for (const dispose of protocolContributions.values()) dispose();\n protocolContributions.clear();\n activeContext = undefined;\n footerData = undefined;\n disposeFooterStatuses?.();\n disposeFooterStatuses = undefined;\n footerStatusRegistry.reset();\n disposeModeCatalogBinding?.();\n disposeModeCatalogBinding = undefined;\n disposeModeSubscription?.();\n disposeModeSubscription = undefined;\n modeCatalog.reset();\n disposeConfigContributions?.();\n disposeConfigContributions = undefined;\n disposeLeaderRegistration?.();\n disposeLeaderRegistration = undefined;\n disposeLeaderUnregistration?.();\n disposeLeaderUnregistration = undefined;\n configRegistry.reset();\n uiState.reset();\n sessionProtocol = undefined;\n if (ctx.mode === TUI_MODE) ctx.ui.setWidget(LEADER_WIDGET_KEY, undefined, { placement: WIDGET_PLACEMENT });\n await telemetry.shutdown();\n });\n}\n"],"mappings":"yzCA2BA,MAAM,EAAoB,iBAEpB,EAAmB,cACnB,EAAgB,UAahB,EAAe,UACf,EAA0B,IAAI,IAAI,CAAC,SAAe,CAAC,EAEzD,SAAS,EAAmB,EAAiB,EAAiC,CAC5E,IAAM,EAAoB,EAAQ,KAAK,CAAC,CAAC,QAAQ,OAAQ,GAAG,EAC5D,GAAI,CAAC,EAAmB,OACxB,IAAM,EAAe,EAAkB,MAAM,EAAG,EAAwB,CAAC,CAAC,QAAQ,EAClF,MAAO,GAAG,EAAa,KAAK,EAAa,KAAK,EAAK,SAAS,CAAG,GAAK,GACtE,CAEA,SAAgB,EAAkB,EAAkB,EAAyB,EAAkB,EAAS,CACtG,EAAsB,EAAI,QAAQ,IAAI,CAAC,EACvC,IAAM,EAAU,IAAI,EACd,EAAuB,IAAIA,EAAAA,yBAC3B,EAAc,EAA6B,EAC3C,EAAiB,IAAIC,EAAAA,mBACrB,EAAiB,IAAI,EACrB,EAAqB,IAAI,IACzB,EAA0B,IAAI,IAChC,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACE,EAAwB,IAAI,IAC9B,EAAqB,EACrB,EAAoB,EACpB,EAAoB,GACpB,EACA,EAQE,GAAiB,SAA6D,CAC7E,KACL,GAAI,CAEF,OA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I,OAAS,OAAY,EAAM,SAAW,eAA4B,EAAmB,OAC7F,EAAoB,GACpB,IAAM,EAAQ,EAAmB,EAAM,KAAM,EAAI,GAAG,EAChD,GAAO,EAAI,GAAG,SAAS,CAAK,CAClC,CAAC,EAED,EAAG,GAAG,mBAAwB,MAAO,EAAQ,IAAQ,CACnD,EAAE,EACF,IAAyB,EACzB,EAAyB,IAAA,GACzB,IAAK,IAAM,KAAW,EAAsB,OAAO,EAAG,EAAQ,EAC9D,EAAsB,MAAM,EAC5B,EAAgB,IAAA,GAChB,EAAa,IAAA,GACb,IAAwB,EACxB,EAAwB,IAAA,GACxB,EAAqB,MAAM,EAC3B,IAA4B,EAC5B,EAA4B,IAAA,GAC5B,IAA0B,EAC1B,EAA0B,IAAA,GAC1B,EAAY,MAAM,EAClB,IAA6B,EAC7B,EAA6B,IAAA,GAC7B,IAA4B,EAC5B,EAA4B,IAAA,GAC5B,IAA8B,EAC9B,EAA8B,IAAA,GAC9B,EAAe,MAAM,EACrB,EAAQ,MAAM,EACd,EAAkB,IAAA,GACd,EAAI,OAAS,OAAU,EAAI,GAAG,UAAU,EAAmB,IAAA,GAAW,CAAE,UAAW,CAAiB,CAAC,EACzG,MAAM,EAAU,SAAS,CAC3B,CAAC,CACH"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../../tui/builtinToolRender.cjs");let t=require("@earendil-works/pi-coding-agent");function n(n,r){let i=(0,t.createReadToolDefinition)(r);n.registerTool({...i,renderShell:`self`,renderCall:(t,n)=>e.renderReadCall(t,n),renderResult:(t,n,r,i)=>{let a=e.renderReadResult(i.args,t,{expanded:n.expanded,isError:i.isError},r);return e.frameBuiltinResult(a,r,i.lastComponent)}});let a=(0,t.createEditToolDefinition)(r)
|
|
1
|
+
const e=require("../../tui/builtinToolRender.cjs");let t=require("@earendil-works/pi-coding-agent");function n(n,r){let i=(0,t.createReadToolDefinition)(r);n.registerTool({...i,renderShell:`self`,renderCall:(t,n)=>e.renderReadCall(t,n),renderResult:(t,n,r,i)=>{let a=e.renderReadResult(i.args,t,{expanded:n.expanded,isError:i.isError},r);return e.frameBuiltinResult(a,r,i.lastComponent)}});let a=(0,t.createEditToolDefinition)(r);n.registerTool({...a,renderShell:`self`,renderCall:(t,n)=>e.renderEditCall(t,n),renderResult:(t,n,r,i)=>{let a=e.renderEditResult(i.args,t,{expanded:n.expanded,isError:i.isError},r);return e.frameBuiltinResult(a,r,i.lastComponent)}});let o=(0,t.createWriteToolDefinition)(r),s=o.renderResult;n.registerTool({...o,renderShell:`self`,renderCall:(t,n,r)=>e.renderWriteCall(t,n,{expanded:r.expanded,argsStreaming:r.argsComplete===!1&&r.isPartial}),renderResult:(t,n,r,i)=>{let a=s(t,n,r,{...i,lastComponent:e.previousBuiltinResult(i.lastComponent)});return e.frameBuiltinResult(a,r,i.lastComponent)}});let c=(0,t.createGrepToolDefinition)(r),l=c.renderResult;n.registerTool({...c,renderShell:`self`,renderCall:(t,n)=>e.renderGrepCall(t,n),renderResult:(t,n,r,i)=>{let a=l(t,n,r,{...i,lastComponent:e.previousBuiltinResult(i.lastComponent)});return e.frameBuiltinResult(a,r,i.lastComponent)}});let u=(0,t.createFindToolDefinition)(r),d=u.renderResult;n.registerTool({...u,renderShell:`self`,renderCall:(t,n)=>e.renderFindCall(t,n),renderResult:(t,n,r,i)=>{let a=d(t,n,r,{...i,lastComponent:e.previousBuiltinResult(i.lastComponent)});return e.frameBuiltinResult(a,r,i.lastComponent)}});let f=(0,t.createLsToolDefinition)(r),p=f.renderResult;n.registerTool({...f,renderShell:`self`,renderCall:(t,n)=>e.renderLsCall(t,n),renderResult:(t,n,r,i)=>{let a=p(t,n,r,{...i,lastComponent:e.previousBuiltinResult(i.lastComponent)});return e.frameBuiltinResult(a,r,i.lastComponent)}})}exports.registerBuiltinToolUi=n;
|
|
2
2
|
//# sourceMappingURL=toolOverrides.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolOverrides.cjs","names":["createReadToolDefinition","renderReadCall","renderReadResult","frameBuiltinResult","createEditToolDefinition","renderEditCall","
|
|
1
|
+
{"version":3,"file":"toolOverrides.cjs","names":["createReadToolDefinition","renderReadCall","renderReadResult","frameBuiltinResult","createEditToolDefinition","renderEditCall","renderEditResult","createWriteToolDefinition","renderWriteCall","previousBuiltinResult","createGrepToolDefinition","renderGrepCall","createFindToolDefinition","renderFindCall","createLsToolDefinition","renderLsCall"],"sources":["../../../src/adapters/pi/toolOverrides.ts"],"sourcesContent":["import {\n createEditToolDefinition,\n createFindToolDefinition,\n createGrepToolDefinition,\n createLsToolDefinition,\n createReadToolDefinition,\n createWriteToolDefinition,\n type ExtensionAPI,\n} from '@earendil-works/pi-coding-agent';\nimport {\n frameBuiltinResult,\n previousBuiltinResult,\n renderEditCall,\n renderEditResult,\n renderFindCall,\n renderGrepCall,\n renderLsCall,\n renderReadCall,\n renderReadResult,\n renderWriteCall,\n} from '../../tui/builtinToolRender.ts';\n\n/**\n * Keep Pi's native schemas, prompt metadata, execution, and result formatting;\n * replace only the broad status-background shell and call heading.\n */\nexport function registerBuiltinToolUi(pi: ExtensionAPI, cwd: string): void {\n const read = createReadToolDefinition(cwd);\n pi.registerTool({\n ...read,\n renderShell: 'self',\n renderCall: (args, theme) => renderReadCall(args, theme),\n renderResult: (result, options, theme, context) => {\n const content = renderReadResult(\n context.args,\n result,\n { expanded: options.expanded, isError: context.isError },\n theme,\n );\n return frameBuiltinResult(content, theme, context.lastComponent);\n },\n });\n\n const edit = createEditToolDefinition(cwd);\n pi.registerTool({\n ...edit,\n renderShell: 'self',\n renderCall: (args, theme) => renderEditCall(args, theme),\n // Doom bands the diff on the background and keeps syntax highlighting on\n // the foreground, which Pi's foreground-only diff renderer cannot express.\n renderResult: (result, options, theme, context) => {\n const content = renderEditResult(\n context.args,\n result,\n { expanded: options.expanded, isError: context.isError },\n theme,\n );\n return frameBuiltinResult(content, theme, context.lastComponent);\n },\n });\n\n const write = createWriteToolDefinition(cwd);\n const writeResult = write.renderResult!;\n pi.registerTool({\n ...write,\n renderShell: 'self',\n renderCall: (args, theme, context) =>\n renderWriteCall(args, theme, {\n expanded: context.expanded,\n // Restored completed rows may not mark args complete, but their result is no longer partial.\n argsStreaming: context.argsComplete === false && context.isPartial,\n }),\n renderResult: (result, options, theme, context) => {\n const content = writeResult(result, options, theme, {\n ...context,\n lastComponent: previousBuiltinResult(context.lastComponent),\n });\n return frameBuiltinResult(content, theme, context.lastComponent);\n },\n });\n\n const grep = createGrepToolDefinition(cwd);\n const grepResult = grep.renderResult!;\n pi.registerTool({\n ...grep,\n renderShell: 'self',\n renderCall: (args, theme) => renderGrepCall(args, theme),\n renderResult: (result, options, theme, context) => {\n const content = grepResult(result, options, theme, {\n ...context,\n lastComponent: previousBuiltinResult(context.lastComponent),\n });\n return frameBuiltinResult(content, theme, context.lastComponent);\n },\n });\n\n const find = createFindToolDefinition(cwd);\n const findResult = find.renderResult!;\n pi.registerTool({\n ...find,\n renderShell: 'self',\n renderCall: (args, theme) => renderFindCall(args, theme),\n renderResult: (result, options, theme, context) => {\n const content = findResult(result, options, theme, {\n ...context,\n lastComponent: previousBuiltinResult(context.lastComponent),\n });\n return frameBuiltinResult(content, theme, context.lastComponent);\n },\n });\n\n const ls = createLsToolDefinition(cwd);\n const lsResult = ls.renderResult!;\n pi.registerTool({\n ...ls,\n renderShell: 'self',\n renderCall: (args, theme) => renderLsCall(args, theme),\n renderResult: (result, options, theme, context) => {\n const content = lsResult(result, options, theme, {\n ...context,\n lastComponent: previousBuiltinResult(context.lastComponent),\n });\n return frameBuiltinResult(content, theme, context.lastComponent);\n },\n });\n}\n"],"mappings":"oGA0BA,SAAgB,EAAsB,EAAkB,EAAmB,CACzE,IAAM,GAAA,EAAOA,EAAAA,yBAAAA,CAAyB,CAAG,EACzC,EAAG,aAAa,CACd,GAAG,EACH,YAAa,OACb,YAAa,EAAM,IAAUC,EAAAA,eAAe,EAAM,CAAK,EACvD,cAAe,EAAQ,EAAS,EAAO,I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O,CACjD,GAAG,EACH,cAAeF,EAAAA,sBAAsB,EAAQ,aAAa,CAC5D,CAAC,EACD,OAAON,EAAAA,mBAAmB,EAAS,EAAO,EAAQ,aAAa,CACjE,CACF,CAAC,EAED,IAAM,GAAA,EAAOS,EAAAA,yBAAAA,CAAyB,CAAG,EACnC,EAAa,EAAK,aACxB,EAAG,aAAa,CACd,GAAG,EACH,YAAa,OACb,YAAa,EAAM,IAAUC,EAAAA,eAAe,EAAM,CAAK,EACvD,cAAe,EAAQ,EAAS,EAAO,IAAY,CACjD,IAAM,EAAU,EAAW,EAAQ,EAAS,EAAO,CACjD,GAAG,EACH,cAAeJ,EAAAA,sBAAsB,EAAQ,aAAa,CAC5D,CAAC,EACD,OAAON,EAAAA,mBAAmB,EAAS,EAAO,EAAQ,aAAa,CACjE,CACF,CAAC,EAED,IAAM,GAAA,EAAKW,EAAAA,uBAAAA,CAAuB,CAAG,EAC/B,EAAW,EAAG,aACpB,EAAG,aAAa,CACd,GAAG,EACH,YAAa,OACb,YAAa,EAAM,IAAUC,EAAAA,aAAa,EAAM,CAAK,EACrD,cAAe,EAAQ,EAAS,EAAO,IAAY,CACjD,IAAM,EAAU,EAAS,EAAQ,EAAS,EAAO,CAC/C,GAAG,EACH,cAAeN,EAAAA,sBAAsB,EAAQ,aAAa,CAC5D,CAAC,EACD,OAAON,EAAAA,mBAAmB,EAAS,EAAO,EAAQ,aAAa,CACjE,CACF,CAAC,CACH"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{frameBuiltinResult as e,previousBuiltinResult as t,renderEditCall as n,
|
|
1
|
+
import{frameBuiltinResult as e,previousBuiltinResult as t,renderEditCall as n,renderEditResult as r,renderFindCall as i,renderGrepCall as a,renderLsCall as o,renderReadCall as s,renderReadResult as c,renderWriteCall as l}from"../../tui/builtinToolRender.mjs";import{createEditToolDefinition as u,createFindToolDefinition as d,createGrepToolDefinition as f,createLsToolDefinition as p,createReadToolDefinition as m,createWriteToolDefinition as h}from"@earendil-works/pi-coding-agent";function g(g,_){let v=m(_);g.registerTool({...v,renderShell:`self`,renderCall:(e,t)=>s(e,t),renderResult:(t,n,r,i)=>{let a=c(i.args,t,{expanded:n.expanded,isError:i.isError},r);return e(a,r,i.lastComponent)}});let y=u(_);g.registerTool({...y,renderShell:`self`,renderCall:(e,t)=>n(e,t),renderResult:(t,n,i,a)=>{let o=r(a.args,t,{expanded:n.expanded,isError:a.isError},i);return e(o,i,a.lastComponent)}});let b=h(_),x=b.renderResult;g.registerTool({...b,renderShell:`self`,renderCall:(e,t,n)=>l(e,t,{expanded:n.expanded,argsStreaming:n.argsComplete===!1&&n.isPartial}),renderResult:(n,r,i,a)=>{let o=x(n,r,i,{...a,lastComponent:t(a.lastComponent)});return e(o,i,a.lastComponent)}});let S=f(_),C=S.renderResult;g.registerTool({...S,renderShell:`self`,renderCall:(e,t)=>a(e,t),renderResult:(n,r,i,a)=>{let o=C(n,r,i,{...a,lastComponent:t(a.lastComponent)});return e(o,i,a.lastComponent)}});let w=d(_),T=w.renderResult;g.registerTool({...w,renderShell:`self`,renderCall:(e,t)=>i(e,t),renderResult:(n,r,i,a)=>{let o=T(n,r,i,{...a,lastComponent:t(a.lastComponent)});return e(o,i,a.lastComponent)}});let E=p(_),D=E.renderResult;g.registerTool({...E,renderShell:`self`,renderCall:(e,t)=>o(e,t),renderResult:(n,r,i,a)=>{let o=D(n,r,i,{...a,lastComponent:t(a.lastComponent)});return e(o,i,a.lastComponent)}})}export{g as registerBuiltinToolUi};
|
|
2
2
|
//# sourceMappingURL=toolOverrides.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolOverrides.mjs","names":[],"sources":["../../../src/adapters/pi/toolOverrides.ts"],"sourcesContent":["import {\n createEditToolDefinition,\n createFindToolDefinition,\n createGrepToolDefinition,\n createLsToolDefinition,\n createReadToolDefinition,\n createWriteToolDefinition,\n type ExtensionAPI,\n} from '@earendil-works/pi-coding-agent';\nimport {\n frameBuiltinResult,\n previousBuiltinResult,\n renderEditCall,\n renderFindCall,\n renderGrepCall,\n renderLsCall,\n renderReadCall,\n renderReadResult,\n renderWriteCall,\n} from '../../tui/builtinToolRender.ts';\n\n/**\n * Keep Pi's native schemas, prompt metadata, execution, and result formatting;\n * replace only the broad status-background shell and call heading.\n */\nexport function registerBuiltinToolUi(pi: ExtensionAPI, cwd: string): void {\n const read = createReadToolDefinition(cwd);\n pi.registerTool({\n ...read,\n renderShell: 'self',\n renderCall: (args, theme) => renderReadCall(args, theme),\n renderResult: (result, options, theme, context) => {\n const content = renderReadResult(\n context.args,\n result,\n { expanded: options.expanded, isError: context.isError },\n theme,\n );\n return frameBuiltinResult(content, theme, context.lastComponent);\n },\n });\n\n const edit = createEditToolDefinition(cwd);\n
|
|
1
|
+
{"version":3,"file":"toolOverrides.mjs","names":[],"sources":["../../../src/adapters/pi/toolOverrides.ts"],"sourcesContent":["import {\n createEditToolDefinition,\n createFindToolDefinition,\n createGrepToolDefinition,\n createLsToolDefinition,\n createReadToolDefinition,\n createWriteToolDefinition,\n type ExtensionAPI,\n} from '@earendil-works/pi-coding-agent';\nimport {\n frameBuiltinResult,\n previousBuiltinResult,\n renderEditCall,\n renderEditResult,\n renderFindCall,\n renderGrepCall,\n renderLsCall,\n renderReadCall,\n renderReadResult,\n renderWriteCall,\n} from '../../tui/builtinToolRender.ts';\n\n/**\n * Keep Pi's native schemas, prompt metadata, execution, and result formatting;\n * replace only the broad status-background shell and call heading.\n */\nexport function registerBuiltinToolUi(pi: ExtensionAPI, cwd: string): void {\n const read = createReadToolDefinition(cwd);\n pi.registerTool({\n ...read,\n renderShell: 'self',\n renderCall: (args, theme) => renderReadCall(args, theme),\n renderResult: (result, options, theme, context) => {\n const content = renderReadResult(\n context.args,\n result,\n { expanded: options.expanded, isError: context.isError },\n theme,\n );\n return frameBuiltinResult(content, theme, context.lastComponent);\n },\n });\n\n const edit = createEditToolDefinition(cwd);\n pi.registerTool({\n ...edit,\n renderShell: 'self',\n renderCall: (args, theme) => renderEditCall(args, theme),\n // Doom bands the diff on the background and keeps syntax highlighting on\n // the foreground, which Pi's foreground-only diff renderer cannot express.\n renderResult: (result, options, theme, context) => {\n const content = renderEditResult(\n context.args,\n result,\n { expanded: options.expanded, isError: context.isError },\n theme,\n );\n return frameBuiltinResult(content, theme, context.lastComponent);\n },\n });\n\n const write = createWriteToolDefinition(cwd);\n const writeResult = write.renderResult!;\n pi.registerTool({\n ...write,\n renderShell: 'self',\n renderCall: (args, theme, context) =>\n renderWriteCall(args, theme, {\n expanded: context.expanded,\n // Restored completed rows may not mark args complete, but their result is no longer partial.\n argsStreaming: context.argsComplete === false && context.isPartial,\n }),\n renderResult: (result, options, theme, context) => {\n const content = writeResult(result, options, theme, {\n ...context,\n lastComponent: previousBuiltinResult(context.lastComponent),\n });\n return frameBuiltinResult(content, theme, context.lastComponent);\n },\n });\n\n const grep = createGrepToolDefinition(cwd);\n const grepResult = grep.renderResult!;\n pi.registerTool({\n ...grep,\n renderShell: 'self',\n renderCall: (args, theme) => renderGrepCall(args, theme),\n renderResult: (result, options, theme, context) => {\n const content = grepResult(result, options, theme, {\n ...context,\n lastComponent: previousBuiltinResult(context.lastComponent),\n });\n return frameBuiltinResult(content, theme, context.lastComponent);\n },\n });\n\n const find = createFindToolDefinition(cwd);\n const findResult = find.renderResult!;\n pi.registerTool({\n ...find,\n renderShell: 'self',\n renderCall: (args, theme) => renderFindCall(args, theme),\n renderResult: (result, options, theme, context) => {\n const content = findResult(result, options, theme, {\n ...context,\n lastComponent: previousBuiltinResult(context.lastComponent),\n });\n return frameBuiltinResult(content, theme, context.lastComponent);\n },\n });\n\n const ls = createLsToolDefinition(cwd);\n const lsResult = ls.renderResult!;\n pi.registerTool({\n ...ls,\n renderShell: 'self',\n renderCall: (args, theme) => renderLsCall(args, theme),\n renderResult: (result, options, theme, context) => {\n const content = lsResult(result, options, theme, {\n ...context,\n lastComponent: previousBuiltinResult(context.lastComponent),\n });\n return frameBuiltinResult(content, theme, context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,EAAS,EAAO,IAAY,CACjD,IAAM,EAAU,EAAW,EAAQ,EAAS,EAAO,CACjD,GAAG,EACH,cAAe,EAAsB,EAAQ,aAAa,CAC5D,CAAC,EACD,OAAO,EAAmB,EAAS,EAAO,EAAQ,aAAa,CACjE,CACF,CAAC,EAED,IAAM,EAAO,EAAyB,CAAG,EACnC,EAAa,EAAK,aACxB,EAAG,aAAa,CACd,GAAG,EACH,YAAa,OACb,YAAa,EAAM,IAAU,EAAe,EAAM,CAAK,EACvD,cAAe,EAAQ,EAAS,EAAO,IAAY,CACjD,IAAM,EAAU,EAAW,EAAQ,EAAS,EAAO,CACjD,GAAG,EACH,cAAe,EAAsB,EAAQ,aAAa,CAC5D,CAAC,EACD,OAAO,EAAmB,EAAS,EAAO,EAAQ,aAAa,CACjE,CACF,CAAC,EAED,IAAM,EAAK,EAAuB,CAAG,EAC/B,EAAW,EAAG,aACpB,EAAG,aAAa,CACd,GAAG,EACH,YAAa,OACb,YAAa,EAAM,IAAU,EAAa,EAAM,CAAK,EACrD,cAAe,EAAQ,EAAS,EAAO,IAAY,CACjD,IAAM,EAAU,EAAS,EAAQ,EAAS,EAAO,CAC/C,GAAG,EACH,cAAe,EAAsB,EAAQ,aAAa,CAC5D,CAAC,EACD,OAAO,EAAmB,EAAS,EAAO,EAAQ,aAAa,CACjE,CACF,CAAC,CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../tui/doomOverlay.cjs");exports.DOOM_FULLSCREEN_UI_OPTIONS=e.DOOM_FULLSCREEN_UI_OPTIONS,exports.DOOM_OVERLAY_ACCENT=e.DOOM_OVERLAY_ACCENT,exports.DoomOverlay=e.DoomOverlay;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../tui/doomOverlay.cjs");exports.DOOM_FULLSCREEN_UI_OPTIONS=e.DOOM_FULLSCREEN_UI_OPTIONS,exports.DOOM_NAVIGATION_KEYS=e.DOOM_NAVIGATION_KEYS,exports.DOOM_OVERLAY_ACCENT=e.DOOM_OVERLAY_ACCENT,exports.DoomOverlay=e.DoomOverlay;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DOOM_FULLSCREEN_UI_OPTIONS, DOOM_OVERLAY_ACCENT, DoomOverlay, DoomOverlayChrome, DoomOverlayTui } from "../tui/doomOverlay.cjs";
|
|
2
|
-
export { DOOM_FULLSCREEN_UI_OPTIONS, DOOM_OVERLAY_ACCENT, DoomOverlay, DoomOverlayChrome, DoomOverlayTui };
|
|
1
|
+
import { DOOM_FULLSCREEN_UI_OPTIONS, DOOM_NAVIGATION_KEYS, DOOM_OVERLAY_ACCENT, DoomOverlay, DoomOverlayChrome, DoomOverlayTui } from "../tui/doomOverlay.cjs";
|
|
2
|
+
export { DOOM_FULLSCREEN_UI_OPTIONS, DOOM_NAVIGATION_KEYS, DOOM_OVERLAY_ACCENT, DoomOverlay, DoomOverlayChrome, DoomOverlayTui };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DOOM_FULLSCREEN_UI_OPTIONS, DOOM_OVERLAY_ACCENT, DoomOverlay, DoomOverlayChrome, DoomOverlayTui } from "../tui/doomOverlay.mjs";
|
|
2
|
-
export { DOOM_FULLSCREEN_UI_OPTIONS, DOOM_OVERLAY_ACCENT, DoomOverlay, DoomOverlayChrome, DoomOverlayTui };
|
|
1
|
+
import { DOOM_FULLSCREEN_UI_OPTIONS, DOOM_NAVIGATION_KEYS, DOOM_OVERLAY_ACCENT, DoomOverlay, DoomOverlayChrome, DoomOverlayTui } from "../tui/doomOverlay.mjs";
|
|
2
|
+
export { DOOM_FULLSCREEN_UI_OPTIONS, DOOM_NAVIGATION_KEYS, DOOM_OVERLAY_ACCENT, DoomOverlay, DoomOverlayChrome, DoomOverlayTui };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DOOM_FULLSCREEN_UI_OPTIONS as e,
|
|
1
|
+
import{DOOM_FULLSCREEN_UI_OPTIONS as e,DOOM_NAVIGATION_KEYS as t,DOOM_OVERLAY_ACCENT as n,DoomOverlay as r}from"../tui/doomOverlay.mjs";export{e as DOOM_FULLSCREEN_UI_OPTIONS,t as DOOM_NAVIGATION_KEYS,n as DOOM_OVERLAY_ACCENT,r as DoomOverlay};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./adapters/telemetry/logSinkTelemetry.cjs");require("./config.cjs"),require("./footer.cjs"),require("./leader.cjs");const t=require("./services/state/uiState.cjs"),n=require("./types/harnessMetadata.cjs"),r=require("./tui/doomEditor.cjs"),i=require("./tui/doomFooter.cjs"),a=require("./tui/doomHeader.cjs"),o=require("./tui/doomOverlay.cjs"),s=require("./tui/leaderHints.cjs"),c=require("./tui/theme.cjs"),l=require("./tui/toolChrome.cjs");let u=require("@agimon-ai/doompi-extension-contracts/leader");exports.DEFAULT_THEME=c.DEFAULT_THEME,exports.DEFAULT_THEME_NAME=c.DEFAULT_THEME_NAME,exports.DOOM_FULLSCREEN_UI_OPTIONS=o.DOOM_FULLSCREEN_UI_OPTIONS,exports.DoomEditor=r.DoomEditor,exports.DoomFooter=i.DoomFooter,exports.DoomHeader=a.DoomHeader,exports.DoomOverlay=o.DoomOverlay,exports.DoomToolCall=l.DoomToolCall,exports.DoomToolResult=l.DoomToolResult,exports.DoomUiState=t.DoomUiState,exports.LeaderHints=s.LeaderHints,exports.UI_EVENT=e.UI_EVENT,Object.defineProperty(exports,"createDoomLeaderContribution",{enumerable:!0,get:function(){return u.createDoomLeaderContribution}}),exports.createUiTelemetry=e.createUiTelemetry,exports.readDoomHarnessMetadata=n.readDoomHarnessMetadata,Object.defineProperty(exports,"registerDoomConfigContribution",{enumerable:!0,get:function(){return config_exports.registerDoomConfigContribution}}),Object.defineProperty(exports,"registerDoomFooterContribution",{enumerable:!0,get:function(){return footer_exports.registerDoomFooterContribution}}),Object.defineProperty(exports,"registerDoomLeaderContribution",{enumerable:!0,get:function(){return u.registerDoomLeaderContribution}}),exports.renderToolBadge=l.renderToolBadge,exports.renderToolHeading=l.renderToolHeading,exports.writeDefaultTheme=c.writeDefaultTheme;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./adapters/telemetry/logSinkTelemetry.cjs");require("./config.cjs"),require("./footer.cjs"),require("./leader.cjs");const t=require("./services/state/uiState.cjs"),n=require("./types/harnessMetadata.cjs"),r=require("./tui/doomEditor.cjs"),i=require("./tui/doomFooter.cjs"),a=require("./tui/doomHeader.cjs"),o=require("./tui/doomOverlay.cjs"),s=require("./tui/leaderHints.cjs"),c=require("./tui/theme.cjs"),l=require("./tui/toolChrome.cjs");let u=require("@agimon-ai/doompi-extension-contracts/leader");exports.DEFAULT_THEME=c.DEFAULT_THEME,exports.DEFAULT_THEME_NAME=c.DEFAULT_THEME_NAME,exports.DOOM_FULLSCREEN_UI_OPTIONS=o.DOOM_FULLSCREEN_UI_OPTIONS,exports.DOOM_NAVIGATION_KEYS=o.DOOM_NAVIGATION_KEYS,exports.DoomEditor=r.DoomEditor,exports.DoomFooter=i.DoomFooter,exports.DoomHeader=a.DoomHeader,exports.DoomOverlay=o.DoomOverlay,exports.DoomToolCall=l.DoomToolCall,exports.DoomToolResult=l.DoomToolResult,exports.DoomUiState=t.DoomUiState,exports.LeaderHints=s.LeaderHints,exports.UI_EVENT=e.UI_EVENT,Object.defineProperty(exports,"createDoomLeaderContribution",{enumerable:!0,get:function(){return u.createDoomLeaderContribution}}),exports.createUiTelemetry=e.createUiTelemetry,exports.readDoomHarnessMetadata=n.readDoomHarnessMetadata,Object.defineProperty(exports,"registerDoomConfigContribution",{enumerable:!0,get:function(){return config_exports.registerDoomConfigContribution}}),Object.defineProperty(exports,"registerDoomFooterContribution",{enumerable:!0,get:function(){return footer_exports.registerDoomFooterContribution}}),Object.defineProperty(exports,"registerDoomLeaderContribution",{enumerable:!0,get:function(){return u.registerDoomLeaderContribution}}),exports.renderToolBadge=l.renderToolBadge,exports.renderToolHeading=l.renderToolHeading,exports.writeDefaultTheme=c.writeDefaultTheme;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { config_d_exports } from "./config.cjs";
|
|
2
|
-
import { DOOM_FULLSCREEN_UI_OPTIONS, DoomOverlay, DoomOverlayChrome, DoomOverlayTui } from "./tui/doomOverlay.cjs";
|
|
2
|
+
import { DOOM_FULLSCREEN_UI_OPTIONS, DOOM_NAVIGATION_KEYS, DoomOverlay, DoomOverlayChrome, DoomOverlayTui } from "./tui/doomOverlay.cjs";
|
|
3
3
|
import { DoomLeaderBinding, DoomLeaderCommand, DoomLeaderContribution, DoomLeaderContributionHandle, DoomLeaderSegment, createDoomLeaderContribution, registerDoomLeaderContribution } from "./leader.cjs";
|
|
4
4
|
import { DoomUiState, LeaderOption, LeaderSnapshot } from "./services/state/uiState.cjs";
|
|
5
5
|
import { DoomEditor } from "./tui/doomEditor.cjs";
|
|
@@ -23,4 +23,4 @@ type DoomFooterContributionHandle = footer_d_exports.DoomFooterContributionHandl
|
|
|
23
23
|
type DoomFooterContributionValue = footer_d_exports.DoomFooterContributionValue;
|
|
24
24
|
type registerDoomConfigContribution = config_d_exports.registerDoomConfigContribution;
|
|
25
25
|
type registerDoomFooterContribution = footer_d_exports.registerDoomFooterContribution;
|
|
26
|
-
export { type ConfigChoice, type ConfigField, type ConfigSection, type ConfigStep, DEFAULT_THEME, DEFAULT_THEME_NAME, DOOM_FULLSCREEN_UI_OPTIONS, type DoomConfigActionInput, type DoomConfigContributionHandle, type DoomConfigContributionOptions, DoomEditor, DoomFooter, type DoomFooterContributionDefinition, type DoomFooterContributionHandle, type DoomFooterContributionValue, type DoomHarnessMetadata, DoomHeader, type DoomLeaderBinding, type DoomLeaderCommand, type DoomLeaderContribution, type DoomLeaderContributionHandle, type DoomLeaderSegment, DoomOverlay, type DoomOverlayChrome, type DoomOverlayTui, DoomToolCall, DoomToolResult, type DoomToolResultOptions, DoomUiState, LeaderHints, type LeaderOption, type LeaderSnapshot, UI_EVENT, type UiEventAttributes, type UiEventName, type UiTelemetry, type UiTelemetryOptions, createDoomLeaderContribution, createUiTelemetry, readDoomHarnessMetadata, registerDoomConfigContribution, registerDoomFooterContribution, registerDoomLeaderContribution, renderToolBadge, renderToolHeading, writeDefaultTheme };
|
|
26
|
+
export { type ConfigChoice, type ConfigField, type ConfigSection, type ConfigStep, DEFAULT_THEME, DEFAULT_THEME_NAME, DOOM_FULLSCREEN_UI_OPTIONS, DOOM_NAVIGATION_KEYS, type DoomConfigActionInput, type DoomConfigContributionHandle, type DoomConfigContributionOptions, DoomEditor, DoomFooter, type DoomFooterContributionDefinition, type DoomFooterContributionHandle, type DoomFooterContributionValue, type DoomHarnessMetadata, DoomHeader, type DoomLeaderBinding, type DoomLeaderCommand, type DoomLeaderContribution, type DoomLeaderContributionHandle, type DoomLeaderSegment, DoomOverlay, type DoomOverlayChrome, type DoomOverlayTui, DoomToolCall, DoomToolResult, type DoomToolResultOptions, DoomUiState, LeaderHints, type LeaderOption, type LeaderSnapshot, UI_EVENT, type UiEventAttributes, type UiEventName, type UiTelemetry, type UiTelemetryOptions, createDoomLeaderContribution, createUiTelemetry, readDoomHarnessMetadata, registerDoomConfigContribution, registerDoomFooterContribution, registerDoomLeaderContribution, renderToolBadge, renderToolHeading, writeDefaultTheme };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { config_d_exports } from "./config.mjs";
|
|
2
|
-
import { DOOM_FULLSCREEN_UI_OPTIONS, DoomOverlay, DoomOverlayChrome, DoomOverlayTui } from "./tui/doomOverlay.mjs";
|
|
2
|
+
import { DOOM_FULLSCREEN_UI_OPTIONS, DOOM_NAVIGATION_KEYS, DoomOverlay, DoomOverlayChrome, DoomOverlayTui } from "./tui/doomOverlay.mjs";
|
|
3
3
|
import { DoomLeaderBinding, DoomLeaderCommand, DoomLeaderContribution, DoomLeaderContributionHandle, DoomLeaderSegment, createDoomLeaderContribution, registerDoomLeaderContribution } from "./leader.mjs";
|
|
4
4
|
import { DoomUiState, LeaderOption, LeaderSnapshot } from "./services/state/uiState.mjs";
|
|
5
5
|
import { DoomEditor } from "./tui/doomEditor.mjs";
|
|
@@ -23,4 +23,4 @@ type DoomFooterContributionHandle = footer_d_exports.DoomFooterContributionHandl
|
|
|
23
23
|
type DoomFooterContributionValue = footer_d_exports.DoomFooterContributionValue;
|
|
24
24
|
type registerDoomConfigContribution = config_d_exports.registerDoomConfigContribution;
|
|
25
25
|
type registerDoomFooterContribution = footer_d_exports.registerDoomFooterContribution;
|
|
26
|
-
export { type ConfigChoice, type ConfigField, type ConfigSection, type ConfigStep, DEFAULT_THEME, DEFAULT_THEME_NAME, DOOM_FULLSCREEN_UI_OPTIONS, type DoomConfigActionInput, type DoomConfigContributionHandle, type DoomConfigContributionOptions, DoomEditor, DoomFooter, type DoomFooterContributionDefinition, type DoomFooterContributionHandle, type DoomFooterContributionValue, type DoomHarnessMetadata, DoomHeader, type DoomLeaderBinding, type DoomLeaderCommand, type DoomLeaderContribution, type DoomLeaderContributionHandle, type DoomLeaderSegment, DoomOverlay, type DoomOverlayChrome, type DoomOverlayTui, DoomToolCall, DoomToolResult, type DoomToolResultOptions, DoomUiState, LeaderHints, type LeaderOption, type LeaderSnapshot, UI_EVENT, type UiEventAttributes, type UiEventName, type UiTelemetry, type UiTelemetryOptions, createDoomLeaderContribution, createUiTelemetry, readDoomHarnessMetadata, registerDoomConfigContribution, registerDoomFooterContribution, registerDoomLeaderContribution, renderToolBadge, renderToolHeading, writeDefaultTheme };
|
|
26
|
+
export { type ConfigChoice, type ConfigField, type ConfigSection, type ConfigStep, DEFAULT_THEME, DEFAULT_THEME_NAME, DOOM_FULLSCREEN_UI_OPTIONS, DOOM_NAVIGATION_KEYS, type DoomConfigActionInput, type DoomConfigContributionHandle, type DoomConfigContributionOptions, DoomEditor, DoomFooter, type DoomFooterContributionDefinition, type DoomFooterContributionHandle, type DoomFooterContributionValue, type DoomHarnessMetadata, DoomHeader, type DoomLeaderBinding, type DoomLeaderCommand, type DoomLeaderContribution, type DoomLeaderContributionHandle, type DoomLeaderSegment, DoomOverlay, type DoomOverlayChrome, type DoomOverlayTui, DoomToolCall, DoomToolResult, type DoomToolResultOptions, DoomUiState, LeaderHints, type LeaderOption, type LeaderSnapshot, UI_EVENT, type UiEventAttributes, type UiEventName, type UiTelemetry, type UiTelemetryOptions, createDoomLeaderContribution, createUiTelemetry, readDoomHarnessMetadata, registerDoomConfigContribution, registerDoomFooterContribution, registerDoomLeaderContribution, renderToolBadge, renderToolHeading, writeDefaultTheme };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UI_EVENT as e,createUiTelemetry as t}from"./adapters/telemetry/logSinkTelemetry.mjs";import{config_exports as n}from"./config.mjs";import{footer_exports as r}from"./footer.mjs";import{createDoomLeaderContribution as i,registerDoomLeaderContribution as a}from"./leader.mjs";import{DoomUiState as o}from"./services/state/uiState.mjs";import{readDoomHarnessMetadata as s}from"./types/harnessMetadata.mjs";import{DoomEditor as c}from"./tui/doomEditor.mjs";import{DoomFooter as l}from"./tui/doomFooter.mjs";import{DoomHeader as u}from"./tui/doomHeader.mjs";import{DOOM_FULLSCREEN_UI_OPTIONS as d,DoomOverlay as
|
|
1
|
+
import{UI_EVENT as e,createUiTelemetry as t}from"./adapters/telemetry/logSinkTelemetry.mjs";import{config_exports as n}from"./config.mjs";import{footer_exports as r}from"./footer.mjs";import{createDoomLeaderContribution as i,registerDoomLeaderContribution as a}from"./leader.mjs";import{DoomUiState as o}from"./services/state/uiState.mjs";import{readDoomHarnessMetadata as s}from"./types/harnessMetadata.mjs";import{DoomEditor as c}from"./tui/doomEditor.mjs";import{DoomFooter as l}from"./tui/doomFooter.mjs";import{DoomHeader as u}from"./tui/doomHeader.mjs";import{DOOM_FULLSCREEN_UI_OPTIONS as d,DOOM_NAVIGATION_KEYS as f,DoomOverlay as p}from"./tui/doomOverlay.mjs";import{LeaderHints as m}from"./tui/leaderHints.mjs";import{DEFAULT_THEME as h,DEFAULT_THEME_NAME as g,writeDefaultTheme as _}from"./tui/theme.mjs";import{DoomToolCall as v,DoomToolResult as y,renderToolBadge as b,renderToolHeading as x}from"./tui/toolChrome.mjs";var S=n.registerDoomConfigContribution,C=r.registerDoomFooterContribution;export{h as DEFAULT_THEME,g as DEFAULT_THEME_NAME,d as DOOM_FULLSCREEN_UI_OPTIONS,f as DOOM_NAVIGATION_KEYS,c as DoomEditor,l as DoomFooter,u as DoomHeader,p as DoomOverlay,v as DoomToolCall,y as DoomToolResult,o as DoomUiState,m as LeaderHints,e as UI_EVENT,i as createDoomLeaderContribution,t as createUiTelemetry,s as readDoomHarnessMetadata,S as registerDoomConfigContribution,C as registerDoomFooterContribution,a as registerDoomLeaderContribution,b as renderToolBadge,x as renderToolHeading,_ as writeDefaultTheme};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={active:!1,prefix:[],label:``,options:[]};function t(e){return{active:e.active,prefix:[...e.prefix],label:e.label,options:e.options.map(e=>({...e})),...e.rootOptions?{rootOptions:e.rootOptions.map(e=>({...e}))}:{}}}var
|
|
1
|
+
const e={active:!1,prefix:[],label:``,options:[]};function t(e){return{active:e.active,prefix:[...e.prefix],label:e.label,options:e.options.map(e=>({...e})),...e.rootOptions?{rootOptions:e.rootOptions.map(e=>({...e}))}:{}}}function n(e){return e.filter(({state:e})=>e.activation!==`inactive`).map(({descriptor:e,state:t})=>({source:e.source,id:e.id,label:e.label,order:e.order,...t.detail?{detail:t.detail}:{},...t.color?{color:t.color}:{}})).sort((e,t)=>e.order-t.order||e.source.localeCompare(t.source)||e.id.localeCompare(t.id))}var r=class{snapshot=e;modes=[];listeners=new Set;getSnapshot(){return t(this.snapshot)}getModes(){return this.modes}setModes(e){this.modes=e.map(e=>({...e}));for(let e of this.listeners)e(this.getSnapshot())}setLeader(e){this.snapshot=t(e);for(let e of this.listeners)e(this.getSnapshot())}reset(){this.modes=[],this.setLeader(e)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}};exports.DoomUiState=r,exports.projectMinorModeRecords=n;
|
|
2
2
|
//# sourceMappingURL=uiState.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uiState.cjs","names":[],"sources":["../../../src/services/state/uiState.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"uiState.cjs","names":[],"sources":["../../../src/services/state/uiState.ts"],"sourcesContent":["import type { MinorModeRecord, ModeTextColor } from '@agimon-ai/doompi-extension-contracts/mode';\n\nexport interface LeaderOption {\n key: string;\n label: string;\n detail?: string;\n}\n\nexport interface LeaderSnapshot {\n active: boolean;\n prefix: string[];\n label: string;\n options: LeaderOption[];\n rootOptions?: LeaderOption[];\n}\n\nexport interface UiMinorModeStatus {\n source: string;\n id: string;\n label: string;\n detail?: string;\n color?: ModeTextColor;\n order: number;\n}\n\ntype StateListener = (snapshot: LeaderSnapshot) => void;\n\nconst INACTIVE_SNAPSHOT: LeaderSnapshot = {\n active: false,\n prefix: [],\n label: '',\n options: [],\n};\n\nfunction cloneSnapshot(snapshot: LeaderSnapshot): LeaderSnapshot {\n return {\n active: snapshot.active,\n prefix: [...snapshot.prefix],\n label: snapshot.label,\n options: snapshot.options.map((option) => ({ ...option })),\n ...(snapshot.rootOptions ? { rootOptions: snapshot.rootOptions.map((option) => ({ ...option })) } : {}),\n };\n}\n\nexport function projectMinorModeRecords(records: readonly MinorModeRecord[]): UiMinorModeStatus[] {\n return records\n .filter(({ state }) => state.activation !== 'inactive')\n .map(({ descriptor, state }) => ({\n source: descriptor.source,\n id: descriptor.id,\n label: descriptor.label,\n order: descriptor.order,\n ...(state.detail ? { detail: state.detail } : {}),\n ...(state.color ? { color: state.color } : {}),\n }))\n .sort(\n (left, right) =>\n left.order - right.order || left.source.localeCompare(right.source) || left.id.localeCompare(right.id),\n );\n}\n\nexport class DoomUiState {\n private snapshot = INACTIVE_SNAPSHOT;\n private modes: readonly UiMinorModeStatus[] = [];\n private readonly listeners = new Set<StateListener>();\n\n getSnapshot(): LeaderSnapshot {\n return cloneSnapshot(this.snapshot);\n }\n\n getModes(): readonly UiMinorModeStatus[] {\n return this.modes;\n }\n\n setModes(modes: readonly UiMinorModeStatus[]): void {\n this.modes = modes.map((mode) => ({ ...mode }));\n for (const listener of this.listeners) listener(this.getSnapshot());\n }\n\n setLeader(snapshot: LeaderSnapshot): void {\n this.snapshot = cloneSnapshot(snapshot);\n for (const listener of this.listeners) listener(this.getSnapshot());\n }\n\n reset(): void {\n this.modes = [];\n this.setLeader(INACTIVE_SNAPSHOT);\n }\n\n subscribe(listener: StateListener): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n}\n"],"mappings":"AA2BA,MAAM,EAAoC,CACxC,OAAQ,GACR,OAAQ,CAAC,EACT,MAAO,GACP,QAAS,CAAC,CACZ,EAEA,SAAS,EAAc,EAA0C,CAC/D,MAAO,CACL,OAAQ,EAAS,OACjB,OAAQ,CAAC,GAAG,EAAS,MAAM,EAC3B,MAAO,EAAS,MAChB,QAAS,EAAS,QAAQ,IAAK,IAAY,CAAE,GAAG,CAAO,EAAE,EACzD,GAAI,EAAS,YAAc,CAAE,YAAa,EAAS,YAAY,IAAK,IAAY,CAAE,GAAG,CAAO,EAAE,CAAE,EAAI,CAAC,CACvG,CACF,CAEA,SAAgB,EAAwB,EAA0D,CAChG,OAAO,EACJ,QAAQ,CAAE,WAAY,EAAM,aAAe,UAAU,CAAC,CACtD,KAAK,CAAE,aAAY,YAAa,CAC/B,OAAQ,EAAW,OACnB,GAAI,EAAW,GACf,MAAO,EAAW,MAClB,MAAO,EAAW,MAClB,GAAI,EAAM,OAAS,CAAE,OAAQ,EAAM,MAAO,EAAI,CAAC,EAC/C,GAAI,EAAM,MAAQ,CAAE,MAAO,EAAM,KAAM,EAAI,CAAC,CAC9C,EAAE,CAAC,CACF,MACE,EAAM,IACL,EAAK,MAAQ,EAAM,OAAS,EAAK,OAAO,cAAc,EAAM,MAAM,GAAK,EAAK,GAAG,cAAc,EAAM,EAAE,CACzG,CACJ,CAEA,IAAa,EAAb,KAAyB,CACvB,SAAmB,EACnB,MAA8C,CAAC,EAC/C,UAA6B,IAAI,IAEjC,aAA8B,CAC5B,OAAO,EAAc,KAAK,QAAQ,CACpC,CAEA,UAAyC,CACvC,OAAO,KAAK,KACd,CAEA,SAAS,EAA2C,CAClD,KAAK,MAAQ,EAAM,IAAK,IAAU,CAAE,GAAG,CAAK,EAAE,EAC9C,IAAK,IAAM,KAAY,KAAK,UAAW,EAAS,KAAK,YAAY,CAAC,CACpE,CAEA,UAAU,EAAgC,CACxC,KAAK,SAAW,EAAc,CAAQ,EACtC,IAAK,IAAM,KAAY,KAAK,UAAW,EAAS,KAAK,YAAY,CAAC,CACpE,CAEA,OAAc,CACZ,KAAK,MAAQ,CAAC,EACd,KAAK,UAAU,CAAiB,CAClC,CAEA,UAAU,EAAqC,CAE7C,OADA,KAAK,UAAU,IAAI,CAAQ,MACd,KAAK,UAAU,OAAO,CAAQ,CAC7C,CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MinorModeRecord, ModeTextColor } from "@agimon-ai/doompi-extension-contracts/mode";
|
|
2
2
|
//#region src/services/state/uiState.d.ts
|
|
3
3
|
interface LeaderOption {
|
|
4
4
|
key: string;
|
|
@@ -12,26 +12,27 @@ interface LeaderSnapshot {
|
|
|
12
12
|
options: LeaderOption[];
|
|
13
13
|
rootOptions?: LeaderOption[];
|
|
14
14
|
}
|
|
15
|
+
interface UiMinorModeStatus {
|
|
16
|
+
source: string;
|
|
17
|
+
id: string;
|
|
18
|
+
label: string;
|
|
19
|
+
detail?: string;
|
|
20
|
+
color?: ModeTextColor;
|
|
21
|
+
order: number;
|
|
22
|
+
}
|
|
15
23
|
type StateListener = (snapshot: LeaderSnapshot) => void;
|
|
24
|
+
declare function projectMinorModeRecords(records: readonly MinorModeRecord[]): UiMinorModeStatus[];
|
|
16
25
|
declare class DoomUiState {
|
|
17
26
|
private snapshot;
|
|
18
|
-
/**
|
|
19
|
-
* The enabled modes, shown in two places at two levels of detail.
|
|
20
|
-
*
|
|
21
|
-
* Held here rather than read from the mode registry by each surface because
|
|
22
|
-
* both readers already take this state: the editor prints the names beside
|
|
23
|
-
* its mode badge, and the leader panel prints them with their detail. One
|
|
24
|
-
* source, so the two can never disagree about what is on.
|
|
25
|
-
*/
|
|
26
27
|
private modes;
|
|
27
28
|
private readonly listeners;
|
|
28
29
|
getSnapshot(): LeaderSnapshot;
|
|
29
|
-
getModes(): readonly
|
|
30
|
-
setModes(modes: readonly
|
|
30
|
+
getModes(): readonly UiMinorModeStatus[];
|
|
31
|
+
setModes(modes: readonly UiMinorModeStatus[]): void;
|
|
31
32
|
setLeader(snapshot: LeaderSnapshot): void;
|
|
32
33
|
reset(): void;
|
|
33
34
|
subscribe(listener: StateListener): () => void;
|
|
34
35
|
}
|
|
35
36
|
//#endregion
|
|
36
|
-
export { DoomUiState, LeaderOption, LeaderSnapshot };
|
|
37
|
+
export { DoomUiState, LeaderOption, LeaderSnapshot, UiMinorModeStatus, projectMinorModeRecords };
|
|
37
38
|
//# sourceMappingURL=uiState.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uiState.d.cts","names":[],"sources":["../../../src/services/state/uiState.ts"],"mappings":";;UAEiB;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA,SAAS;EACT,cAAc;;
|
|
1
|
+
{"version":3,"file":"uiState.d.cts","names":[],"sources":["../../../src/services/state/uiState.ts"],"mappings":";;UAEiB;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA,SAAS;EACT,cAAc;;UAGC;EACf;EACA;EACA;EACA;EACA,QAAQ;EACR;;KAGG,iBAAiB,UAAU;iBAmBhB,wBAAwB,kBAAkB,oBAAoB;cAiBjE;UACH;UACA;mBACS;EAEjB,eAAe;EAIf,qBAAqB;EAIrB,SAAS,gBAAgB;EAKzB,UAAU,UAAU;EAKpB;EAKA,UAAU,UAAU"}
|