@agimon-ai/doompi-ui 0.0.1-alpha.0 → 0.0.1-alpha.10
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 +2 -0
- package/dist/adapters/pi/extension.cjs.map +1 -0
- package/dist/adapters/pi/extension.d.cts +7 -0
- package/dist/adapters/pi/extension.d.cts.map +1 -0
- package/dist/adapters/pi/extension.d.mts +7 -0
- package/dist/adapters/pi/extension.d.mts.map +1 -0
- package/dist/adapters/pi/extension.mjs +2 -0
- package/dist/adapters/pi/extension.mjs.map +1 -0
- package/dist/adapters/pi/extensionName.cjs +2 -0
- package/dist/adapters/pi/extensionName.cjs.map +1 -0
- package/dist/adapters/pi/extensionName.d.cts +16 -0
- package/dist/adapters/pi/extensionName.d.cts.map +1 -0
- package/dist/adapters/pi/extensionName.d.mts +16 -0
- package/dist/adapters/pi/extensionName.d.mts.map +1 -0
- package/dist/adapters/pi/extensionName.mjs +2 -0
- package/dist/adapters/pi/extensionName.mjs.map +1 -0
- package/dist/adapters/telemetry/logSinkTelemetry.cjs +2 -0
- package/dist/adapters/telemetry/logSinkTelemetry.cjs.map +1 -0
- package/dist/adapters/telemetry/logSinkTelemetry.d.cts +29 -0
- package/dist/adapters/telemetry/logSinkTelemetry.d.cts.map +1 -0
- package/dist/adapters/telemetry/logSinkTelemetry.d.mts +29 -0
- package/dist/adapters/telemetry/logSinkTelemetry.d.mts.map +1 -0
- package/dist/adapters/telemetry/logSinkTelemetry.mjs +2 -0
- package/dist/adapters/telemetry/logSinkTelemetry.mjs.map +1 -0
- package/dist/components/configOverlay.cjs +0 -0
- package/dist/components/configOverlay.d.cts +0 -0
- package/dist/components/configOverlay.d.mts +0 -0
- package/dist/components/configOverlay.mjs +0 -0
- package/dist/components/doomEditor.cjs +1 -2
- package/dist/components/doomEditor.d.cts +2 -59
- package/dist/components/doomEditor.d.mts +2 -59
- package/dist/components/doomEditor.mjs +1 -2
- package/dist/components/doomFooter.cjs +1 -2
- package/dist/components/doomFooter.d.cts +2 -32
- package/dist/components/doomFooter.d.mts +2 -32
- package/dist/components/doomFooter.mjs +1 -2
- package/dist/components/doomHeader.cjs +1 -2
- package/dist/components/doomHeader.d.cts +2 -34
- package/dist/components/doomHeader.d.mts +2 -34
- package/dist/components/doomHeader.mjs +1 -2
- package/dist/components/doomOverlay.cjs +1 -2
- package/dist/components/doomOverlay.d.cts +2 -79
- package/dist/components/doomOverlay.d.mts +2 -79
- package/dist/components/doomOverlay.mjs +1 -2
- package/dist/components/leaderHints.cjs +1 -2
- package/dist/components/leaderHints.d.cts +2 -37
- package/dist/components/leaderHints.d.mts +2 -37
- package/dist/components/leaderHints.mjs +1 -2
- package/dist/components/toolsOverlay.cjs +1 -2
- package/dist/components/toolsOverlay.d.cts +2 -29
- package/dist/components/toolsOverlay.d.mts +2 -29
- package/dist/components/toolsOverlay.mjs +1 -2
- package/dist/extension.cjs +1 -2
- package/dist/extension.d.cts +2 -7
- package/dist/extension.d.mts +2 -7
- package/dist/extension.mjs +1 -2
- package/dist/extensionName.cjs +1 -2
- package/dist/extensionName.d.cts +2 -5
- package/dist/extensionName.d.mts +2 -5
- package/dist/extensionName.mjs +1 -2
- package/dist/extensions/pi.cjs +1 -1
- package/dist/extensions/pi.cjs.map +1 -1
- package/dist/extensions/pi.d.cts +1 -1
- package/dist/extensions/pi.d.mts +1 -1
- package/dist/extensions/pi.mjs +1 -1
- package/dist/extensions/pi.mjs.map +1 -1
- package/dist/harnessMetadata.cjs +1 -2
- package/dist/harnessMetadata.d.cts +2 -21
- package/dist/harnessMetadata.d.mts +2 -21
- package/dist/harnessMetadata.mjs +1 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9 -9
- package/dist/index.d.mts +9 -9
- package/dist/index.mjs +1 -1
- package/dist/leader.cjs +1 -1
- package/dist/leader.d.cts +2 -2
- package/dist/leader.d.mts +2 -2
- package/dist/leader.mjs +1 -1
- package/dist/leaderRegistry.cjs +1 -2
- package/dist/leaderRegistry.d.cts +2 -52
- package/dist/leaderRegistry.d.mts +2 -52
- package/dist/leaderRegistry.mjs +1 -2
- package/dist/logSinkTelemetry.cjs +1 -2
- package/dist/logSinkTelemetry.d.cts +2 -29
- package/dist/logSinkTelemetry.d.mts +2 -29
- package/dist/logSinkTelemetry.mjs +1 -2
- package/dist/rendering.cjs +1 -2
- package/dist/rendering.d.cts +2 -11
- package/dist/rendering.d.mts +2 -11
- package/dist/rendering.mjs +1 -2
- package/dist/services/leader/leaderRegistry.cjs +2 -0
- package/dist/services/leader/leaderRegistry.cjs.map +1 -0
- package/dist/services/leader/leaderRegistry.d.cts +58 -0
- package/dist/services/leader/leaderRegistry.d.cts.map +1 -0
- package/dist/services/leader/leaderRegistry.d.mts +58 -0
- package/dist/services/leader/leaderRegistry.d.mts.map +1 -0
- package/dist/services/leader/leaderRegistry.mjs +2 -0
- package/dist/services/leader/leaderRegistry.mjs.map +1 -0
- package/dist/services/state/uiState.cjs +2 -0
- package/dist/services/state/uiState.cjs.map +1 -0
- package/dist/services/state/uiState.d.cts +37 -0
- package/dist/services/state/uiState.d.cts.map +1 -0
- package/dist/services/state/uiState.d.mts +37 -0
- package/dist/services/state/uiState.d.mts.map +1 -0
- package/dist/services/state/uiState.mjs +2 -0
- package/dist/services/state/uiState.mjs.map +1 -0
- package/dist/services/tools/toolInventory.cjs +2 -0
- package/dist/services/tools/toolInventory.cjs.map +1 -0
- package/dist/services/tools/toolInventory.d.cts +40 -0
- package/dist/services/tools/toolInventory.d.cts.map +1 -0
- package/dist/services/tools/toolInventory.d.mts +40 -0
- package/dist/services/tools/toolInventory.d.mts.map +1 -0
- package/dist/services/tools/toolInventory.mjs +2 -0
- package/dist/services/tools/toolInventory.mjs.map +1 -0
- package/dist/theme.cjs +1 -2
- package/dist/theme.d.cts +2 -95
- package/dist/theme.d.mts +2 -95
- package/dist/theme.mjs +1 -2
- package/dist/toolInventory.cjs +1 -2
- package/dist/toolInventory.d.cts +2 -40
- package/dist/toolInventory.d.mts +2 -40
- package/dist/toolInventory.mjs +1 -2
- package/dist/tui/configOverlay.cjs +0 -0
- package/dist/tui/configOverlay.cjs.map +1 -0
- package/dist/tui/configOverlay.d.cts +0 -0
- package/dist/tui/configOverlay.d.cts.map +1 -0
- package/dist/tui/configOverlay.d.mts +0 -0
- package/dist/tui/configOverlay.d.mts.map +1 -0
- package/dist/tui/configOverlay.mjs +0 -0
- package/dist/tui/configOverlay.mjs.map +1 -0
- package/dist/tui/doomEditor.cjs +2 -0
- package/dist/tui/doomEditor.cjs.map +1 -0
- package/dist/tui/doomEditor.d.cts +62 -0
- package/dist/tui/doomEditor.d.cts.map +1 -0
- package/dist/tui/doomEditor.d.mts +62 -0
- package/dist/tui/doomEditor.d.mts.map +1 -0
- package/dist/tui/doomEditor.mjs +2 -0
- package/dist/tui/doomEditor.mjs.map +1 -0
- package/dist/tui/doomFooter.cjs +2 -0
- package/dist/tui/doomFooter.cjs.map +1 -0
- package/dist/tui/doomFooter.d.cts +32 -0
- package/dist/tui/doomFooter.d.cts.map +1 -0
- package/dist/tui/doomFooter.d.mts +32 -0
- package/dist/tui/doomFooter.d.mts.map +1 -0
- package/dist/tui/doomFooter.mjs +2 -0
- package/dist/tui/doomFooter.mjs.map +1 -0
- package/dist/tui/doomHeader.cjs +2 -0
- package/dist/tui/doomHeader.cjs.map +1 -0
- package/dist/tui/doomHeader.d.cts +34 -0
- package/dist/tui/doomHeader.d.cts.map +1 -0
- package/dist/tui/doomHeader.d.mts +34 -0
- package/dist/tui/doomHeader.d.mts.map +1 -0
- package/dist/tui/doomHeader.mjs +2 -0
- package/dist/tui/doomHeader.mjs.map +1 -0
- package/dist/tui/doomOverlay.cjs +2 -0
- package/dist/tui/doomOverlay.cjs.map +1 -0
- package/dist/tui/doomOverlay.d.cts +79 -0
- package/dist/tui/doomOverlay.d.cts.map +1 -0
- package/dist/tui/doomOverlay.d.mts +79 -0
- package/dist/tui/doomOverlay.d.mts.map +1 -0
- package/dist/tui/doomOverlay.mjs +2 -0
- package/dist/tui/doomOverlay.mjs.map +1 -0
- package/dist/tui/leaderHints.cjs +2 -0
- package/dist/tui/leaderHints.cjs.map +1 -0
- package/dist/tui/leaderHints.d.cts +37 -0
- package/dist/tui/leaderHints.d.cts.map +1 -0
- package/dist/tui/leaderHints.d.mts +37 -0
- package/dist/tui/leaderHints.d.mts.map +1 -0
- package/dist/tui/leaderHints.mjs +2 -0
- package/dist/tui/leaderHints.mjs.map +1 -0
- package/dist/tui/rendering.cjs +2 -0
- package/dist/tui/rendering.cjs.map +1 -0
- package/dist/tui/rendering.d.cts +11 -0
- package/dist/tui/rendering.d.cts.map +1 -0
- package/dist/tui/rendering.d.mts +11 -0
- package/dist/tui/rendering.d.mts.map +1 -0
- package/dist/tui/rendering.mjs +2 -0
- package/dist/tui/rendering.mjs.map +1 -0
- package/dist/tui/theme.cjs +2 -0
- package/dist/tui/theme.cjs.map +1 -0
- package/dist/tui/theme.d.cts +101 -0
- package/dist/tui/theme.d.cts.map +1 -0
- package/dist/tui/theme.d.mts +101 -0
- package/dist/tui/theme.d.mts.map +1 -0
- package/dist/tui/theme.mjs +2 -0
- package/dist/tui/theme.mjs.map +1 -0
- package/dist/tui/toolsOverlay.cjs +2 -0
- package/dist/tui/toolsOverlay.cjs.map +1 -0
- package/dist/tui/toolsOverlay.d.cts +29 -0
- package/dist/tui/toolsOverlay.d.cts.map +1 -0
- package/dist/tui/toolsOverlay.d.mts +29 -0
- package/dist/tui/toolsOverlay.d.mts.map +1 -0
- package/dist/tui/toolsOverlay.mjs +2 -0
- package/dist/tui/toolsOverlay.mjs.map +1 -0
- package/dist/types/harnessMetadata.cjs +2 -0
- package/dist/types/harnessMetadata.cjs.map +1 -0
- package/dist/types/harnessMetadata.d.cts +21 -0
- package/dist/types/harnessMetadata.d.cts.map +1 -0
- package/dist/types/harnessMetadata.d.mts +21 -0
- package/dist/types/harnessMetadata.d.mts.map +1 -0
- package/dist/types/harnessMetadata.mjs +2 -0
- package/dist/types/harnessMetadata.mjs.map +1 -0
- package/dist/uiState.cjs +1 -2
- package/dist/uiState.d.cts +2 -37
- package/dist/uiState.d.mts +2 -37
- package/dist/uiState.mjs +1 -2
- package/package.json +3 -3
- package/dist/components/configOverlay.cjs.map +0 -1
- package/dist/components/configOverlay.d.cts.map +0 -1
- package/dist/components/configOverlay.d.mts.map +0 -1
- package/dist/components/configOverlay.mjs.map +0 -1
- package/dist/components/doomEditor.cjs.map +0 -1
- package/dist/components/doomEditor.d.cts.map +0 -1
- package/dist/components/doomEditor.d.mts.map +0 -1
- package/dist/components/doomEditor.mjs.map +0 -1
- package/dist/components/doomFooter.cjs.map +0 -1
- package/dist/components/doomFooter.d.cts.map +0 -1
- package/dist/components/doomFooter.d.mts.map +0 -1
- package/dist/components/doomFooter.mjs.map +0 -1
- package/dist/components/doomHeader.cjs.map +0 -1
- package/dist/components/doomHeader.d.cts.map +0 -1
- package/dist/components/doomHeader.d.mts.map +0 -1
- package/dist/components/doomHeader.mjs.map +0 -1
- package/dist/components/doomOverlay.cjs.map +0 -1
- package/dist/components/doomOverlay.d.cts.map +0 -1
- package/dist/components/doomOverlay.d.mts.map +0 -1
- package/dist/components/doomOverlay.mjs.map +0 -1
- package/dist/components/leaderHints.cjs.map +0 -1
- package/dist/components/leaderHints.d.cts.map +0 -1
- package/dist/components/leaderHints.d.mts.map +0 -1
- package/dist/components/leaderHints.mjs.map +0 -1
- package/dist/components/toolsOverlay.cjs.map +0 -1
- package/dist/components/toolsOverlay.d.cts.map +0 -1
- package/dist/components/toolsOverlay.d.mts.map +0 -1
- package/dist/components/toolsOverlay.mjs.map +0 -1
- package/dist/extension.cjs.map +0 -1
- package/dist/extension.d.cts.map +0 -1
- package/dist/extension.d.mts.map +0 -1
- package/dist/extension.mjs.map +0 -1
- package/dist/extensionName.cjs.map +0 -1
- package/dist/extensionName.d.cts.map +0 -1
- package/dist/extensionName.d.mts.map +0 -1
- package/dist/extensionName.mjs.map +0 -1
- package/dist/harnessMetadata.cjs.map +0 -1
- package/dist/harnessMetadata.d.cts.map +0 -1
- package/dist/harnessMetadata.d.mts.map +0 -1
- package/dist/harnessMetadata.mjs.map +0 -1
- package/dist/leaderRegistry.cjs.map +0 -1
- package/dist/leaderRegistry.d.cts.map +0 -1
- package/dist/leaderRegistry.d.mts.map +0 -1
- package/dist/leaderRegistry.mjs.map +0 -1
- package/dist/logSinkTelemetry.cjs.map +0 -1
- package/dist/logSinkTelemetry.d.cts.map +0 -1
- package/dist/logSinkTelemetry.d.mts.map +0 -1
- package/dist/logSinkTelemetry.mjs.map +0 -1
- package/dist/rendering.cjs.map +0 -1
- package/dist/rendering.d.cts.map +0 -1
- package/dist/rendering.d.mts.map +0 -1
- package/dist/rendering.mjs.map +0 -1
- package/dist/theme.cjs.map +0 -1
- package/dist/theme.d.cts.map +0 -1
- package/dist/theme.d.mts.map +0 -1
- package/dist/theme.mjs.map +0 -1
- package/dist/toolInventory.cjs.map +0 -1
- package/dist/toolInventory.d.cts.map +0 -1
- package/dist/toolInventory.d.mts.map +0 -1
- package/dist/toolInventory.mjs.map +0 -1
- package/dist/uiState.cjs.map +0 -1
- package/dist/uiState.d.cts.map +0 -1
- package/dist/uiState.d.mts.map +0 -1
- package/dist/uiState.mjs.map +0 -1
|
@@ -0,0 +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("../../mode.cjs"),p=require("../../services/tools/toolInventory.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/protocol");const v=`doom-pi-leader`,y=`belowEditor`,b=`warning`,x=`doom-pi`,S=new Set([`hotkeys`]);function C(e,t){let n=e.trim().replace(/\s+/g,` `);if(!n)return;let r=n.slice(0,64).trimEnd();return`${x} · ${r} · ${h.default.basename(t)||t}`}function w(e,w=t.createUiTelemetry()){let T=new i.DoomUiState,E=new r.footer_exports.DoomFooterStatusRegistry,D=new f.mode_exports.DoomModeStatusRegistry,O=new n.config_exports.DoomConfigRegistry,k=new a.DoomLeaderRegistry,A=new Set,j=new Map,M,N,P,F,I,L,R,z,B=new Map,V=0,H=0,U=!1,W,G,K=async()=>{if(W)try{return(await W.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 K(),i=p.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,O)}});let q=e=>{for(let n of e){let e=n.bindingId?` (${n.bindingId})`:``,r=`Leader contribution from ${n.source}${e}: ${n.message}`;A.has(r)||(A.add(r),w.recordWarning(t.UI_EVENT.leaderContributionRejected,n.message,{"leader.source":n.source,...n.bindingId?{"leader.binding.id":n.bindingId}:{}}),N?.mode===`tui`&&N.ui.notify(r,b))}},J=(e,t)=>{let n=Symbol(e.source),r=t?e=>k.registerDeferred(e):e=>k.register(e),i=r(e);if(q(i.diagnostics),!i.accepted)return{update:()=>void 0,dispose:()=>void 0};j.set(e.source,n);let a=!1;return{update(t){a||j.get(e.source)!==n||q(r({source:e.source,bindings:t}).diagnostics)},dispose(){a||(a=!0,j.get(e.source)===n&&(j.delete(e.source),r({source:e.source,bindings:[]})))}}},Y=Object.freeze({register(e){let t=J(e,!1);return()=>t.dispose()}});G=(0,m.installDoomLeaderBootstrapHost)({register:e=>J(e,!0)}),e.on(`session_start`,(n,r)=>{N=r;let i=++H,a=(0,_.createProtocolRuntime)({bus:e.events,source:`@agimon-ai/doompi-ui`,sessionId:r.sessionManager.getSessionId()});if(W=a,q(k.flush()),P?.(),E.reset(),P=E.bind(a),F?.(),D.reset(),F=D.bind(a),L?.(),O.reset(),L=O.bind(a),R?.(),z?.(),R=a.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}:${++V}`,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 B.set(r,Y.register(i)),{handleId:r}}),z=a.provide(m.LeaderUnregistrationProtocol,({handleId:e})=>{let t=B.get(e);return t?(B.delete(e),t(),{removed:!0}):{removed:!1}}),U=r.sessionManager.getEntries().some(e=>e.type===`message`),r.mode!==`tui`)return;for(let e of A)r.ui.notify(e,b);let u=process.env.DOOMPI_THEME||`doom-pi-dark`,d=r.ui.setTheme(u);d.success||(r.ui.notify(`Could not apply Doom Pi theme: ${d.error}`,b),w.recordWarning(t.UI_EVENT.themeApplyFailed,d.error??`Unknown theme error`,{"ui.theme":u})),I?.(),I=D.subscribe(()=>T.setModes(D.getStatuses())),T.setModes(D.getStatuses()),r.ui.setTitle(`${x} · ${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)=>(M=n,new s.DoomFooter(e,t,r,n,E,T))),r.ui.setEditorComponent((n,s,c)=>new o.DoomEditor(n,s,c,T,e=>{if(!e.active){r.ui.setWidget(v,void 0,{placement:y});return}r.ui.setWidget(v,(t,n)=>new l.LeaderHints(n,e,r,M,T.getModes()),{placement:y})},void 0,r.ui.theme,{registry:k,isCommandAvailable:t=>S.has(t)||e.getCommands().some(e=>e.name===t),onLeaderAction:(e,t)=>{if(N!==r||H!==i){r.ui.notify(`Leader action ${t} is unavailable.`,b);return}a.notify(m.LeaderActionInvoked,{source:e,action:t})},onUnavailableCommand:e=>{w.recordWarning(t.UI_EVENT.leaderCommandUnavailable,`Leader command /${e} is unavailable.`,{"ui.kind":`command`}),r.ui.notify(`Leader command /${e} is unavailable.`,b)},onUnavailableAction:e=>{w.recordWarning(t.UI_EVENT.leaderActionUnavailable,`Leader action ${e} is unavailable.`,{"ui.kind":`action`}),r.ui.notify(`Leader action ${e} is unavailable.`,b)}})),w.recordEvent(t.UI_EVENT.shellInstalled,{"ui.theme":u,"ui.theme.applied":d.success,"ui.leader.group.count":k.getGroup([])?.options.length??0})}),e.on(`input`,(e,t)=>{if(t.mode!==`tui`||e.source!==`interactive`||U)return;U=!0;let n=C(e.text,t.cwd);n&&t.ui.setTitle(n)}),e.on(`session_shutdown`,async(e,t)=>{++H,G?.(),G=void 0;for(let e of B.values())e();B.clear(),N=void 0,M=void 0,P?.(),P=void 0,E.reset(),F?.(),F=void 0,I?.(),I=void 0,D.reset(),L?.(),L=void 0,R?.(),R=void 0,z?.(),z=void 0,O.reset(),T.reset(),W=void 0,t.mode===`tui`&&t.ui.setWidget(v,void 0,{placement:y}),await w.shutdown()})}exports.doomPiUiExtension=w;
|
|
2
|
+
//# sourceMappingURL=extension.cjs.map
|
|
@@ -0,0 +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';\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 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":"00BA0BA,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,IAAM,EAAU,IAAIC,EAAAA,YACd,EAAuB,IAAA,EAAA,eAAI,yBAC3B,EAAqB,IAAA,EAAA,aAAI,uBACzB,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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AAe,YAAYA,EAAAA,SAAS,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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UiTelemetry } from "../telemetry/logSinkTelemetry.cjs";
|
|
2
|
+
import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
//#region src/adapters/pi/extension.d.ts
|
|
4
|
+
declare function doomPiUiExtension(pi: ExtensionAPI, telemetry?: UiTelemetry): void;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { doomPiUiExtension };
|
|
7
|
+
//# sourceMappingURL=extension.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.d.cts","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"mappings":";;;iBAoDgB,kBAAkB,IAAI,cAAc,YAAW"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UiTelemetry } from "../telemetry/logSinkTelemetry.mjs";
|
|
2
|
+
import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
//#region src/adapters/pi/extension.d.ts
|
|
4
|
+
declare function doomPiUiExtension(pi: ExtensionAPI, telemetry?: UiTelemetry): void;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { doomPiUiExtension };
|
|
7
|
+
//# sourceMappingURL=extension.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.d.mts","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"mappings":";;;iBAoDgB,kBAAkB,IAAI,cAAc,YAAW"}
|
|
@@ -0,0 +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 a}from"../../services/leader/leaderRegistry.mjs";import{DoomEditor as o}from"../../tui/doomEditor.mjs";import{DoomFooter as s}from"../../tui/doomFooter.mjs";import{DoomHeader as c}from"../../tui/doomHeader.mjs";import{LeaderHints as l}from"../../tui/leaderHints.mjs";import"../../tui/theme.mjs";import{openConfigOverlay as u}from"../../tui/configOverlay.mjs";import{openToolsOverlay as d}from"../../tui/toolsOverlay.mjs";import{mode_exports as f}from"../../mode.mjs";import{buildToolSources as p}from"../../services/tools/toolInventory.mjs";import{LeaderActionInvoked as m,LeaderRegistrationProtocol as h,LeaderUnregistrationProtocol as g,installDoomLeaderBootstrapHost as _}from"@agimon-ai/doompi-extension-contracts/leader";import v from"node:path";import{McpStatusQueryProtocol as y}from"@agimon-ai/doompi-extension-contracts/mcp-status";import{createProtocolRuntime as b}from"@agimon-ai/doompi-extension-contracts/protocol";const x=`doom-pi-leader`,S=`belowEditor`,C=`warning`,w=`doom-pi`,T=new Set([`hotkeys`]);function E(e,t){let n=e.trim().replace(/\s+/g,` `);if(!n)return;let r=n.slice(0,64).trimEnd();return`${w} · ${r} · ${v.basename(t)||t}`}function D(D,O=t()){let k=new i,A=new r.DoomFooterStatusRegistry,j=new f.DoomModeStatusRegistry,M=new n.DoomConfigRegistry,N=new a,P=new Set,F=new Map,I,L,R,z,B,V,H,U,W=new Map,G=0,K=0,q=!1,J,Y,X=async()=>{if(J)try{return(await J.request(y,{},{timeoutMs:250})).servers}catch{return}};D.registerCommand(`tools`,{description:`Browse the tools available in this session`,handler:async(e,t)=>{let n=await X(),r=p({tools:D.getAllTools(),activeTools:D.getActiveTools(),...n?{mcpServers:n}:{}});await d(t,r)}}),D.registerCommand(`config`,{description:`Browse and change the settings extensions contribute`,handler:async(e,t)=>{await u(t,M)}});let Z=t=>{for(let n of t){let t=n.bindingId?` (${n.bindingId})`:``,r=`Leader contribution from ${n.source}${t}: ${n.message}`;P.has(r)||(P.add(r),O.recordWarning(e.leaderContributionRejected,n.message,{"leader.source":n.source,...n.bindingId?{"leader.binding.id":n.bindingId}:{}}),L?.mode===`tui`&&L.ui.notify(r,C))}},Q=(e,t)=>{let n=Symbol(e.source),r=t?e=>N.registerDeferred(e):e=>N.register(e),i=r(e);if(Z(i.diagnostics),!i.accepted)return{update:()=>void 0,dispose:()=>void 0};F.set(e.source,n);let a=!1;return{update(t){a||F.get(e.source)!==n||Z(r({source:e.source,bindings:t}).diagnostics)},dispose(){a||(a=!0,F.get(e.source)===n&&(F.delete(e.source),r({source:e.source,bindings:[]})))}}},$=Object.freeze({register(e){let t=Q(e,!1);return()=>t.dispose()}});Y=_({register:e=>Q(e,!0)}),D.on(`session_start`,(t,n)=>{L=n;let r=++K,i=b({bus:D.events,source:`@agimon-ai/doompi-ui`,sessionId:n.sessionManager.getSessionId()});if(J=i,Z(N.flush()),R?.(),A.reset(),R=A.bind(i),z?.(),j.reset(),z=j.bind(i),V?.(),M.reset(),V=M.bind(i),H?.(),U?.(),H=i.provide(h,({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}:${++G}`,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 W.set(r,$.register(i)),{handleId:r}}),U=i.provide(g,({handleId:e})=>{let t=W.get(e);return t?(W.delete(e),t(),{removed:!0}):{removed:!1}}),q=n.sessionManager.getEntries().some(e=>e.type===`message`),n.mode!==`tui`)return;for(let e of P)n.ui.notify(e,C);let a=process.env.DOOMPI_THEME||`doom-pi-dark`,u=n.ui.setTheme(a);u.success||(n.ui.notify(`Could not apply Doom Pi theme: ${u.error}`,C),O.recordWarning(e.themeApplyFailed,u.error??`Unknown theme error`,{"ui.theme":a})),B?.(),B=j.subscribe(()=>k.setModes(j.getStatuses())),k.setModes(j.getStatuses()),n.ui.setTitle(`${w} · ${v.basename(n.cwd)||n.cwd} · pi/coding`),n.ui.setHeader((e,t)=>new c(t,n.cwd,void 0,n,()=>e.terminal.rows)),n.ui.setFooter((e,t,r)=>(I=r,new s(e,t,n,r,A,k))),n.ui.setEditorComponent((t,a,s)=>new o(t,a,s,k,e=>{if(!e.active){n.ui.setWidget(x,void 0,{placement:S});return}n.ui.setWidget(x,(t,r)=>new l(r,e,n,I,k.getModes()),{placement:S})},void 0,n.ui.theme,{registry:N,isCommandAvailable:e=>T.has(e)||D.getCommands().some(t=>t.name===e),onLeaderAction:(e,t)=>{if(L!==n||K!==r){n.ui.notify(`Leader action ${t} is unavailable.`,C);return}i.notify(m,{source:e,action:t})},onUnavailableCommand:t=>{O.recordWarning(e.leaderCommandUnavailable,`Leader command /${t} is unavailable.`,{"ui.kind":`command`}),n.ui.notify(`Leader command /${t} is unavailable.`,C)},onUnavailableAction:t=>{O.recordWarning(e.leaderActionUnavailable,`Leader action ${t} is unavailable.`,{"ui.kind":`action`}),n.ui.notify(`Leader action ${t} is unavailable.`,C)}})),O.recordEvent(e.shellInstalled,{"ui.theme":a,"ui.theme.applied":u.success,"ui.leader.group.count":N.getGroup([])?.options.length??0})}),D.on(`input`,(e,t)=>{if(t.mode!==`tui`||e.source!==`interactive`||q)return;q=!0;let n=E(e.text,t.cwd);n&&t.ui.setTitle(n)}),D.on(`session_shutdown`,async(e,t)=>{++K,Y?.(),Y=void 0;for(let e of W.values())e();W.clear(),L=void 0,I=void 0,R?.(),R=void 0,A.reset(),z?.(),z=void 0,B?.(),B=void 0,j.reset(),V?.(),V=void 0,H?.(),H=void 0,U?.(),U=void 0,M.reset(),k.reset(),J=void 0,t.mode===`tui`&&t.ui.setWidget(x,void 0,{placement:S}),await O.shutdown()})}export{D as doomPiUiExtension};
|
|
2
|
+
//# sourceMappingURL=extension.mjs.map
|
|
@@ -0,0 +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';\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 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) ct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M,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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../_virtual/_rolldown/runtime.cjs");let t=require("node:path");t=e.__toESM(t,1);let n=require("node:fs");n=e.__toESM(n,1);const r=new Map,i=`__doompiExtensionToolSources__`;function a(){let e=globalThis,t=e[i];if(t)return t;let n=new Map;return e[i]=n,n}function o(e,t){let n=Reflect.get(e,t,e);return typeof n==`function`?n.bind(e):n}function s(e,t){return new Proxy(e,{get(e,n){return n===`registerTool`?n=>{e.registerTool(n),a().set(n.name,t)}:o(e,n)}})}function c(e){return a().get(e)}function l(e){let r=e;for(;;){try{let e=JSON.parse(n.default.readFileSync(t.default.join(r,`package.json`),`utf8`));if(typeof e.name==`string`&&e.name.length>0)return e.name}catch{}let e=t.default.dirname(r);if(e===r)return;r=e}}function u(e){let n=r.get(e);if(n!==void 0)return n;let i=l(t.default.dirname(e)),a=i?i.split(`/`).pop()??i:t.default.basename(e,t.default.extname(e));return r.set(e,a),a}exports.extensionName=u,exports.extensionToolSource=c,exports.withExtensionSource=s;
|
|
2
|
+
//# sourceMappingURL=extensionName.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensionName.cjs","names":["fs","path"],"sources":["../../../src/adapters/pi/extensionName.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\n\n/**\n * Display name for an extension that Pi could not attribute to a package.\n *\n * Pi stamps every `--extension <path>` argument with the literal source `cli`,\n * and doom-pi launches all of its extensions that way, so the only surviving\n * identity is the entry path. The nearest `package.json` above it names the\n * package that registered the tools.\n */\n\n/** Results are stable for the life of a session, and every source hits the same few dirs. */\nconst cache = new Map<string, string>();\nconst TOOL_SOURCE_REGISTRY_KEY = '__doompiExtensionToolSources__' as const;\n\ntype RegisteredTool = Parameters<ExtensionAPI['registerTool']>[0];\ntype RegistryHost = typeof globalThis & { [TOOL_SOURCE_REGISTRY_KEY]?: Map<string, string> };\n\n/** Shared through `globalThis` so compiled and separately loaded modules see one registry. */\nfunction toolSourceRegistry(): Map<string, string> {\n const host = globalThis as RegistryHost;\n const existing = host[TOOL_SOURCE_REGISTRY_KEY];\n if (existing) return existing;\n const registry = new Map<string, string>();\n host[TOOL_SOURCE_REGISTRY_KEY] = registry;\n return registry;\n}\n\nfunction boundValue(target: object, property: PropertyKey): unknown {\n const value = Reflect.get(target, property, target);\n return typeof value === 'function' ? value.bind(target) : value;\n}\n\n/**\n * Gives one composed extension a Pi API that remembers which tools it registers.\n *\n * Pi attributes every factory inside a compiled Doom bundle to the outer bundle.\n * The compiler still knows each original entry path, so it calls factories through\n * this boundary and preserves that identity before the information is lost.\n */\nexport function withExtensionSource(pi: ExtensionAPI, entryPath: string): ExtensionAPI {\n return new Proxy(pi, {\n get(target, property) {\n if (property !== 'registerTool') return boundValue(target, property);\n return (tool: RegisteredTool): void => {\n target.registerTool(tool);\n toolSourceRegistry().set(tool.name, entryPath);\n };\n },\n });\n}\n\n/** Original extension entry that registered a tool inside a composed bundle. */\nexport function extensionToolSource(toolName: string): string | undefined {\n return toolSourceRegistry().get(toolName);\n}\n\nfunction packageName(directory: string): string | undefined {\n let current = directory;\n for (;;) {\n try {\n const manifest = JSON.parse(fs.readFileSync(path.join(current, 'package.json'), 'utf8')) as { name?: unknown };\n if (typeof manifest.name === 'string' && manifest.name.length > 0) return manifest.name;\n } catch {\n // No manifest here, or an unreadable one; keep walking up.\n }\n const parent = path.dirname(current);\n if (parent === current) return undefined;\n current = parent;\n }\n}\n\nexport function extensionName(entryPath: string): string {\n const cached = cache.get(entryPath);\n if (cached !== undefined) return cached;\n const name = packageName(path.dirname(entryPath));\n // `@agimon-ai/doompi-task` reads as `doom-task`; the scope is noise in a tree.\n const resolved = name ? (name.split('/').pop() ?? name) : path.basename(entryPath, path.extname(entryPath));\n cache.set(entryPath, resolved);\n return resolved;\n}\n"],"mappings":"8IAcA,MAAM,EAAQ,IAAI,IACZ,EAA2B,iCAMjC,SAAS,GAA0C,CACjD,IAAM,EAAO,WACP,EAAW,EAAK,GACtB,GAAI,EAAU,OAAO,EACrB,IAAM,EAAW,IAAI,IAErB,MADA,GAAK,GAA4B,EAC1B,CACT,CAEA,SAAS,EAAW,EAAgB,EAAgC,CAClE,IAAM,EAAQ,QAAQ,IAAI,EAAQ,EAAU,CAAM,EAClD,OAAO,OAAO,GAAU,WAAa,EAAM,KAAK,CAAM,EAAI,CAC5D,CASA,SAAgB,EAAoB,EAAkB,EAAiC,CACrF,OAAO,IAAI,MAAM,EAAI,CACnB,IAAI,EAAQ,EAAU,CAEpB,OADI,IAAa,eACT,GAA+B,CACrC,EAAO,aAAa,CAAI,EACxB,EAAmB,CAAC,CAAC,IAAI,EAAK,KAAM,CAAS,CAC/C,EAJwC,EAAW,EAAQ,CAAQ,CAKrE,CACF,CAAC,CACH,CAGA,SAAgB,EAAoB,EAAsC,CACxE,OAAO,EAAmB,CAAC,CAAC,IAAI,CAAQ,CAC1C,CAEA,SAAS,EAAY,EAAuC,CAC1D,IAAI,EAAU,EACd,OAAS,CACP,GAAI,CACF,IAAM,EAAW,KAAK,MAAMA,EAAAA,QAAG,aAAaC,EAAAA,QAAK,KAAK,EAAS,cAAc,EAAG,MAAM,CAAC,EACvF,GAAI,OAAO,EAAS,MAAS,UAAY,EAAS,KAAK,OAAS,EAAG,OAAO,EAAS,IACrF,MAAQ,CAER,CACA,IAAM,EAASA,EAAAA,QAAK,QAAQ,CAAO,EACnC,GAAI,IAAW,EAAS,OACxB,EAAU,CACZ,CACF,CAEA,SAAgB,EAAc,EAA2B,CACvD,IAAM,EAAS,EAAM,IAAI,CAAS,EAClC,GAAI,IAAW,IAAA,GAAW,OAAO,EACjC,IAAM,EAAO,EAAYA,EAAAA,QAAK,QAAQ,CAAS,CAAC,EAE1C,EAAW,EAAQ,EAAK,MAAM,GAAG,CAAC,CAAC,IAAI,GAAK,EAAQA,EAAAA,QAAK,SAAS,EAAWA,EAAAA,QAAK,QAAQ,CAAS,CAAC,EAE1G,OADA,EAAM,IAAI,EAAW,CAAQ,EACtB,CACT"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
//#region src/adapters/pi/extensionName.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Gives one composed extension a Pi API that remembers which tools it registers.
|
|
5
|
+
*
|
|
6
|
+
* Pi attributes every factory inside a compiled Doom bundle to the outer bundle.
|
|
7
|
+
* The compiler still knows each original entry path, so it calls factories through
|
|
8
|
+
* this boundary and preserves that identity before the information is lost.
|
|
9
|
+
*/
|
|
10
|
+
declare function withExtensionSource(pi: ExtensionAPI, entryPath: string): ExtensionAPI;
|
|
11
|
+
/** Original extension entry that registered a tool inside a composed bundle. */
|
|
12
|
+
declare function extensionToolSource(toolName: string): string | undefined;
|
|
13
|
+
declare function extensionName(entryPath: string): string;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { extensionName, extensionToolSource, withExtensionSource };
|
|
16
|
+
//# sourceMappingURL=extensionName.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensionName.d.cts","names":[],"sources":["../../../src/adapters/pi/extensionName.ts"],"mappings":";;;;;;;;;iBA0CgB,oBAAoB,IAAI,cAAc,oBAAoB;;iBAa1D,oBAAoB;iBAmBpB,cAAc"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
//#region src/adapters/pi/extensionName.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Gives one composed extension a Pi API that remembers which tools it registers.
|
|
5
|
+
*
|
|
6
|
+
* Pi attributes every factory inside a compiled Doom bundle to the outer bundle.
|
|
7
|
+
* The compiler still knows each original entry path, so it calls factories through
|
|
8
|
+
* this boundary and preserves that identity before the information is lost.
|
|
9
|
+
*/
|
|
10
|
+
declare function withExtensionSource(pi: ExtensionAPI, entryPath: string): ExtensionAPI;
|
|
11
|
+
/** Original extension entry that registered a tool inside a composed bundle. */
|
|
12
|
+
declare function extensionToolSource(toolName: string): string | undefined;
|
|
13
|
+
declare function extensionName(entryPath: string): string;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { extensionName, extensionToolSource, withExtensionSource };
|
|
16
|
+
//# sourceMappingURL=extensionName.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensionName.d.mts","names":[],"sources":["../../../src/adapters/pi/extensionName.ts"],"mappings":";;;;;;;;;iBA0CgB,oBAAoB,IAAI,cAAc,oBAAoB;;iBAa1D,oBAAoB;iBAmBpB,cAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import e from"node:path";import t from"node:fs";const n=new Map,r=`__doompiExtensionToolSources__`;function i(){let e=globalThis,t=e[r];if(t)return t;let n=new Map;return e[r]=n,n}function a(e,t){let n=Reflect.get(e,t,e);return typeof n==`function`?n.bind(e):n}function o(e,t){return new Proxy(e,{get(e,n){return n===`registerTool`?n=>{e.registerTool(n),i().set(n.name,t)}:a(e,n)}})}function s(e){return i().get(e)}function c(n){let r=n;for(;;){try{let n=JSON.parse(t.readFileSync(e.join(r,`package.json`),`utf8`));if(typeof n.name==`string`&&n.name.length>0)return n.name}catch{}let n=e.dirname(r);if(n===r)return;r=n}}function l(t){let r=n.get(t);if(r!==void 0)return r;let i=c(e.dirname(t)),a=i?i.split(`/`).pop()??i:e.basename(t,e.extname(t));return n.set(t,a),a}export{l as extensionName,s as extensionToolSource,o as withExtensionSource};
|
|
2
|
+
//# sourceMappingURL=extensionName.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensionName.mjs","names":[],"sources":["../../../src/adapters/pi/extensionName.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\n\n/**\n * Display name for an extension that Pi could not attribute to a package.\n *\n * Pi stamps every `--extension <path>` argument with the literal source `cli`,\n * and doom-pi launches all of its extensions that way, so the only surviving\n * identity is the entry path. The nearest `package.json` above it names the\n * package that registered the tools.\n */\n\n/** Results are stable for the life of a session, and every source hits the same few dirs. */\nconst cache = new Map<string, string>();\nconst TOOL_SOURCE_REGISTRY_KEY = '__doompiExtensionToolSources__' as const;\n\ntype RegisteredTool = Parameters<ExtensionAPI['registerTool']>[0];\ntype RegistryHost = typeof globalThis & { [TOOL_SOURCE_REGISTRY_KEY]?: Map<string, string> };\n\n/** Shared through `globalThis` so compiled and separately loaded modules see one registry. */\nfunction toolSourceRegistry(): Map<string, string> {\n const host = globalThis as RegistryHost;\n const existing = host[TOOL_SOURCE_REGISTRY_KEY];\n if (existing) return existing;\n const registry = new Map<string, string>();\n host[TOOL_SOURCE_REGISTRY_KEY] = registry;\n return registry;\n}\n\nfunction boundValue(target: object, property: PropertyKey): unknown {\n const value = Reflect.get(target, property, target);\n return typeof value === 'function' ? value.bind(target) : value;\n}\n\n/**\n * Gives one composed extension a Pi API that remembers which tools it registers.\n *\n * Pi attributes every factory inside a compiled Doom bundle to the outer bundle.\n * The compiler still knows each original entry path, so it calls factories through\n * this boundary and preserves that identity before the information is lost.\n */\nexport function withExtensionSource(pi: ExtensionAPI, entryPath: string): ExtensionAPI {\n return new Proxy(pi, {\n get(target, property) {\n if (property !== 'registerTool') return boundValue(target, property);\n return (tool: RegisteredTool): void => {\n target.registerTool(tool);\n toolSourceRegistry().set(tool.name, entryPath);\n };\n },\n });\n}\n\n/** Original extension entry that registered a tool inside a composed bundle. */\nexport function extensionToolSource(toolName: string): string | undefined {\n return toolSourceRegistry().get(toolName);\n}\n\nfunction packageName(directory: string): string | undefined {\n let current = directory;\n for (;;) {\n try {\n const manifest = JSON.parse(fs.readFileSync(path.join(current, 'package.json'), 'utf8')) as { name?: unknown };\n if (typeof manifest.name === 'string' && manifest.name.length > 0) return manifest.name;\n } catch {\n // No manifest here, or an unreadable one; keep walking up.\n }\n const parent = path.dirname(current);\n if (parent === current) return undefined;\n current = parent;\n }\n}\n\nexport function extensionName(entryPath: string): string {\n const cached = cache.get(entryPath);\n if (cached !== undefined) return cached;\n const name = packageName(path.dirname(entryPath));\n // `@agimon-ai/doompi-task` reads as `doom-task`; the scope is noise in a tree.\n const resolved = name ? (name.split('/').pop() ?? name) : path.basename(entryPath, path.extname(entryPath));\n cache.set(entryPath, resolved);\n return resolved;\n}\n"],"mappings":"gDAcA,MAAM,EAAQ,IAAI,IACZ,EAA2B,iCAMjC,SAAS,GAA0C,CACjD,IAAM,EAAO,WACP,EAAW,EAAK,GACtB,GAAI,EAAU,OAAO,EACrB,IAAM,EAAW,IAAI,IAErB,MADA,GAAK,GAA4B,EAC1B,CACT,CAEA,SAAS,EAAW,EAAgB,EAAgC,CAClE,IAAM,EAAQ,QAAQ,IAAI,EAAQ,EAAU,CAAM,EAClD,OAAO,OAAO,GAAU,WAAa,EAAM,KAAK,CAAM,EAAI,CAC5D,CASA,SAAgB,EAAoB,EAAkB,EAAiC,CACrF,OAAO,IAAI,MAAM,EAAI,CACnB,IAAI,EAAQ,EAAU,CAEpB,OADI,IAAa,eACT,GAA+B,CACrC,EAAO,aAAa,CAAI,EACxB,EAAmB,CAAC,CAAC,IAAI,EAAK,KAAM,CAAS,CAC/C,EAJwC,EAAW,EAAQ,CAAQ,CAKrE,CACF,CAAC,CACH,CAGA,SAAgB,EAAoB,EAAsC,CACxE,OAAO,EAAmB,CAAC,CAAC,IAAI,CAAQ,CAC1C,CAEA,SAAS,EAAY,EAAuC,CAC1D,IAAI,EAAU,EACd,OAAS,CACP,GAAI,CACF,IAAM,EAAW,KAAK,MAAM,EAAG,aAAa,EAAK,KAAK,EAAS,cAAc,EAAG,MAAM,CAAC,EACvF,GAAI,OAAO,EAAS,MAAS,UAAY,EAAS,KAAK,OAAS,EAAG,OAAO,EAAS,IACrF,MAAQ,CAER,CACA,IAAM,EAAS,EAAK,QAAQ,CAAO,EACnC,GAAI,IAAW,EAAS,OACxB,EAAU,CACZ,CACF,CAEA,SAAgB,EAAc,EAA2B,CACvD,IAAM,EAAS,EAAM,IAAI,CAAS,EAClC,GAAI,IAAW,IAAA,GAAW,OAAO,EACjC,IAAM,EAAO,EAAY,EAAK,QAAQ,CAAS,CAAC,EAE1C,EAAW,EAAQ,EAAK,MAAM,GAAG,CAAC,CAAC,IAAI,GAAK,EAAQ,EAAK,SAAS,EAAW,EAAK,QAAQ,CAAS,CAAC,EAE1G,OADA,EAAM,IAAI,EAAW,CAAQ,EACtB,CACT"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
let e=require("@agimon-ai/doompi-telemetry");const t={leaderContributionRejected:`doom_pi_ui.leader_contribution_rejected`,leaderCommandUnavailable:`doom_pi_ui.leader_command_unavailable`,leaderActionUnavailable:`doom_pi_ui.leader_action_unavailable`,themeApplyFailed:`doom_pi_ui.theme_apply_failed`,shellInstalled:`doom_pi_ui.shell_installed`};function n(t={}){let n=(0,e.createDoomTelemetry)({serviceName:`doom-pi-ui`,packageName:`@agimon-ai/doompi-ui`,cwd:t.cwd,workspaceRoot:t.workspaceRoot,env:t.env,telemetryFactory:t.telemetryFactory,warn:t.warn,enableLogs:!0,enableTraces:!0});return{recordError:(e,t,r)=>n.recordError(e,t,r),recordWarning:(e,t,r)=>n.recordWarning(e,t,r),recordEvent:(e,t)=>n.recordEvent(e,t),flush:()=>n.flush(),shutdown:()=>n.shutdown()}}exports.UI_EVENT=t,exports.createUiTelemetry=n;
|
|
2
|
+
//# sourceMappingURL=logSinkTelemetry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logSinkTelemetry.cjs","names":["createDoomTelemetry"],"sources":["../../../src/adapters/telemetry/logSinkTelemetry.ts"],"sourcesContent":["import { createDoomTelemetry, type DoomTelemetry, type DoomTelemetryOptions } from '@agimon-ai/doompi-telemetry';\n\nconst SERVICE_NAME = 'doom-pi-ui';\nconst PACKAGE_NAME = '@agimon-ai/doompi-ui';\n\nexport const UI_EVENT = {\n leaderContributionRejected: 'doom_pi_ui.leader_contribution_rejected',\n leaderCommandUnavailable: 'doom_pi_ui.leader_command_unavailable',\n leaderActionUnavailable: 'doom_pi_ui.leader_action_unavailable',\n themeApplyFailed: 'doom_pi_ui.theme_apply_failed',\n shellInstalled: 'doom_pi_ui.shell_installed',\n} as const;\n\nexport type UiEventName = (typeof UI_EVENT)[keyof typeof UI_EVENT];\nexport type UiEventAttributes = Record<string, string | number | boolean>;\n\nexport interface UiTelemetryOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport interface UiTelemetry {\n recordError(event: UiEventName, error: unknown, attributes?: UiEventAttributes): Promise<void>;\n recordWarning(event: UiEventName, error: unknown, attributes?: UiEventAttributes): Promise<void>;\n recordEvent(event: UiEventName, attributes?: UiEventAttributes): Promise<void>;\n flush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\nexport function createUiTelemetry(options: UiTelemetryOptions = {}): UiTelemetry {\n const telemetry: DoomTelemetry = createDoomTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n flush: () => telemetry.flush(),\n shutdown: () => telemetry.shutdown(),\n };\n}\n"],"mappings":"6CAEA,MAGa,EAAW,CACtB,2BAA4B,0CAC5B,yBAA0B,wCAC1B,wBAAyB,uCACzB,iBAAkB,gCAClB,eAAgB,4BAClB,EAqBA,SAAgB,EAAkB,EAA8B,CAAC,EAAgB,CAC/E,IAAM,GAAA,EAA2BA,EAAAA,oBAAAA,CAAoB,CACnD,YAAa,aACb,YAAa,uBACb,IAAK,EAAQ,IACb,cAAe,EAAQ,cACvB,IAAK,EAAQ,IACb,iBAAkB,EAAQ,iBAC1B,KAAM,EAAQ,KACd,WAAY,GACZ,aAAc,EAChB,CAAC,EACD,MAAO,CACL,aAAc,EAAO,EAAO,IAAe,EAAU,YAAY,EAAO,EAAO,CAAU,EACzF,eAAgB,EAAO,EAAO,IAAe,EAAU,cAAc,EAAO,EAAO,CAAU,EAC7F,aAAc,EAAO,IAAe,EAAU,YAAY,EAAO,CAAU,EAC3E,UAAa,EAAU,MAAM,EAC7B,aAAgB,EAAU,SAAS,CACrC,CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DoomTelemetryOptions } from "@agimon-ai/doompi-telemetry";
|
|
2
|
+
//#region src/adapters/telemetry/logSinkTelemetry.d.ts
|
|
3
|
+
declare const UI_EVENT: {
|
|
4
|
+
readonly leaderContributionRejected: "doom_pi_ui.leader_contribution_rejected";
|
|
5
|
+
readonly leaderCommandUnavailable: "doom_pi_ui.leader_command_unavailable";
|
|
6
|
+
readonly leaderActionUnavailable: "doom_pi_ui.leader_action_unavailable";
|
|
7
|
+
readonly themeApplyFailed: "doom_pi_ui.theme_apply_failed";
|
|
8
|
+
readonly shellInstalled: "doom_pi_ui.shell_installed";
|
|
9
|
+
};
|
|
10
|
+
type UiEventName = (typeof UI_EVENT)[keyof typeof UI_EVENT];
|
|
11
|
+
type UiEventAttributes = Record<string, string | number | boolean>;
|
|
12
|
+
interface UiTelemetryOptions {
|
|
13
|
+
cwd?: string;
|
|
14
|
+
workspaceRoot?: string;
|
|
15
|
+
env?: NodeJS.ProcessEnv;
|
|
16
|
+
telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;
|
|
17
|
+
warn?: (message: string) => void;
|
|
18
|
+
}
|
|
19
|
+
interface UiTelemetry {
|
|
20
|
+
recordError(event: UiEventName, error: unknown, attributes?: UiEventAttributes): Promise<void>;
|
|
21
|
+
recordWarning(event: UiEventName, error: unknown, attributes?: UiEventAttributes): Promise<void>;
|
|
22
|
+
recordEvent(event: UiEventName, attributes?: UiEventAttributes): Promise<void>;
|
|
23
|
+
flush(): Promise<void>;
|
|
24
|
+
shutdown(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
declare function createUiTelemetry(options?: UiTelemetryOptions): UiTelemetry;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { UI_EVENT, UiEventAttributes, UiEventName, UiTelemetry, UiTelemetryOptions, createUiTelemetry };
|
|
29
|
+
//# sourceMappingURL=logSinkTelemetry.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logSinkTelemetry.d.cts","names":[],"sources":["../../../src/adapters/telemetry/logSinkTelemetry.ts"],"mappings":";;cAKa;;;;;;;KAQD,sBAAsB,uBAAuB;KAC7C,oBAAoB;UAEf;EACf;EACA;EACA,MAAM,OAAO;EACb,mBAAmB,YAAY;EAC/B,QAAQ;;UAGO;EACf,YAAY,OAAO,aAAa,gBAAgB,aAAa,oBAAoB;EACjF,cAAc,OAAO,aAAa,gBAAgB,aAAa,oBAAoB;EACnF,YAAY,OAAO,aAAa,aAAa,oBAAoB;EACjE,SAAS;EACT,YAAY;;iBAGE,kBAAkB,UAAS,qBAA0B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DoomTelemetryOptions } from "@agimon-ai/doompi-telemetry";
|
|
2
|
+
//#region src/adapters/telemetry/logSinkTelemetry.d.ts
|
|
3
|
+
declare const UI_EVENT: {
|
|
4
|
+
readonly leaderContributionRejected: "doom_pi_ui.leader_contribution_rejected";
|
|
5
|
+
readonly leaderCommandUnavailable: "doom_pi_ui.leader_command_unavailable";
|
|
6
|
+
readonly leaderActionUnavailable: "doom_pi_ui.leader_action_unavailable";
|
|
7
|
+
readonly themeApplyFailed: "doom_pi_ui.theme_apply_failed";
|
|
8
|
+
readonly shellInstalled: "doom_pi_ui.shell_installed";
|
|
9
|
+
};
|
|
10
|
+
type UiEventName = (typeof UI_EVENT)[keyof typeof UI_EVENT];
|
|
11
|
+
type UiEventAttributes = Record<string, string | number | boolean>;
|
|
12
|
+
interface UiTelemetryOptions {
|
|
13
|
+
cwd?: string;
|
|
14
|
+
workspaceRoot?: string;
|
|
15
|
+
env?: NodeJS.ProcessEnv;
|
|
16
|
+
telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;
|
|
17
|
+
warn?: (message: string) => void;
|
|
18
|
+
}
|
|
19
|
+
interface UiTelemetry {
|
|
20
|
+
recordError(event: UiEventName, error: unknown, attributes?: UiEventAttributes): Promise<void>;
|
|
21
|
+
recordWarning(event: UiEventName, error: unknown, attributes?: UiEventAttributes): Promise<void>;
|
|
22
|
+
recordEvent(event: UiEventName, attributes?: UiEventAttributes): Promise<void>;
|
|
23
|
+
flush(): Promise<void>;
|
|
24
|
+
shutdown(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
declare function createUiTelemetry(options?: UiTelemetryOptions): UiTelemetry;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { UI_EVENT, UiEventAttributes, UiEventName, UiTelemetry, UiTelemetryOptions, createUiTelemetry };
|
|
29
|
+
//# sourceMappingURL=logSinkTelemetry.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logSinkTelemetry.d.mts","names":[],"sources":["../../../src/adapters/telemetry/logSinkTelemetry.ts"],"mappings":";;cAKa;;;;;;;KAQD,sBAAsB,uBAAuB;KAC7C,oBAAoB;UAEf;EACf;EACA;EACA,MAAM,OAAO;EACb,mBAAmB,YAAY;EAC/B,QAAQ;;UAGO;EACf,YAAY,OAAO,aAAa,gBAAgB,aAAa,oBAAoB;EACjF,cAAc,OAAO,aAAa,gBAAgB,aAAa,oBAAoB;EACnF,YAAY,OAAO,aAAa,aAAa,oBAAoB;EACjE,SAAS;EACT,YAAY;;iBAGE,kBAAkB,UAAS,qBAA0B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createDoomTelemetry as e}from"@agimon-ai/doompi-telemetry";const t={leaderContributionRejected:`doom_pi_ui.leader_contribution_rejected`,leaderCommandUnavailable:`doom_pi_ui.leader_command_unavailable`,leaderActionUnavailable:`doom_pi_ui.leader_action_unavailable`,themeApplyFailed:`doom_pi_ui.theme_apply_failed`,shellInstalled:`doom_pi_ui.shell_installed`};function n(t={}){let n=e({serviceName:`doom-pi-ui`,packageName:`@agimon-ai/doompi-ui`,cwd:t.cwd,workspaceRoot:t.workspaceRoot,env:t.env,telemetryFactory:t.telemetryFactory,warn:t.warn,enableLogs:!0,enableTraces:!0});return{recordError:(e,t,r)=>n.recordError(e,t,r),recordWarning:(e,t,r)=>n.recordWarning(e,t,r),recordEvent:(e,t)=>n.recordEvent(e,t),flush:()=>n.flush(),shutdown:()=>n.shutdown()}}export{t as UI_EVENT,n as createUiTelemetry};
|
|
2
|
+
//# sourceMappingURL=logSinkTelemetry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logSinkTelemetry.mjs","names":[],"sources":["../../../src/adapters/telemetry/logSinkTelemetry.ts"],"sourcesContent":["import { createDoomTelemetry, type DoomTelemetry, type DoomTelemetryOptions } from '@agimon-ai/doompi-telemetry';\n\nconst SERVICE_NAME = 'doom-pi-ui';\nconst PACKAGE_NAME = '@agimon-ai/doompi-ui';\n\nexport const UI_EVENT = {\n leaderContributionRejected: 'doom_pi_ui.leader_contribution_rejected',\n leaderCommandUnavailable: 'doom_pi_ui.leader_command_unavailable',\n leaderActionUnavailable: 'doom_pi_ui.leader_action_unavailable',\n themeApplyFailed: 'doom_pi_ui.theme_apply_failed',\n shellInstalled: 'doom_pi_ui.shell_installed',\n} as const;\n\nexport type UiEventName = (typeof UI_EVENT)[keyof typeof UI_EVENT];\nexport type UiEventAttributes = Record<string, string | number | boolean>;\n\nexport interface UiTelemetryOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport interface UiTelemetry {\n recordError(event: UiEventName, error: unknown, attributes?: UiEventAttributes): Promise<void>;\n recordWarning(event: UiEventName, error: unknown, attributes?: UiEventAttributes): Promise<void>;\n recordEvent(event: UiEventName, attributes?: UiEventAttributes): Promise<void>;\n flush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\nexport function createUiTelemetry(options: UiTelemetryOptions = {}): UiTelemetry {\n const telemetry: DoomTelemetry = createDoomTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n flush: () => telemetry.flush(),\n shutdown: () => telemetry.shutdown(),\n };\n}\n"],"mappings":"kEAEA,MAGa,EAAW,CACtB,2BAA4B,0CAC5B,yBAA0B,wCAC1B,wBAAyB,uCACzB,iBAAkB,gCAClB,eAAgB,4BAClB,EAqBA,SAAgB,EAAkB,EAA8B,CAAC,EAAgB,CAC/E,IAAM,EAA2B,EAAoB,CACnD,YAAa,aACb,YAAa,uBACb,IAAK,EAAQ,IACb,cAAe,EAAQ,cACvB,IAAK,EAAQ,IACb,iBAAkB,EAAQ,iBAC1B,KAAM,EAAQ,KACd,WAAY,GACZ,aAAc,EAChB,CAAC,EACD,MAAO,CACL,aAAc,EAAO,EAAO,IAAe,EAAU,YAAY,EAAO,EAAO,CAAU,EACzF,eAAgB,EAAO,EAAO,IAAe,EAAU,cAAc,EAAO,EAAO,CAAU,EAC7F,aAAc,EAAO,IAAe,EAAU,YAAY,EAAO,CAAU,EAC3E,UAAa,EAAU,MAAM,EAC7B,aAAgB,EAAU,SAAS,CACrC,CACF"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../
|
|
2
|
-
//# sourceMappingURL=doomEditor.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../tui/doomEditor.cjs");exports.DoomEditor=e.DoomEditor;
|
|
@@ -1,59 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { CustomEditor, KeybindingsManager, Theme } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
import { EditorOptions, EditorTheme, TUI } from "@earendil-works/pi-tui";
|
|
5
|
-
//#region src/components/doomEditor.d.ts
|
|
6
|
-
interface DoomEditorLeaderOptions {
|
|
7
|
-
registry?: DoomLeaderRegistry;
|
|
8
|
-
isCommandAvailable?: (commandName: string) => boolean;
|
|
9
|
-
onUnavailableCommand?: (commandName: string) => void;
|
|
10
|
-
onUnavailableAction?: (action: string) => void;
|
|
11
|
-
onLeaderAction?: (source: string, actionName: string) => void;
|
|
12
|
-
}
|
|
13
|
-
type SnapshotHandler = (snapshot: LeaderSnapshot) => void;
|
|
14
|
-
type ChromeTheme = Pick<Theme, 'bg' | 'bold' | 'fg' | 'inverse'>;
|
|
15
|
-
declare class DoomEditor extends CustomEditor {
|
|
16
|
-
private readonly uiState;
|
|
17
|
-
private readonly onSnapshot;
|
|
18
|
-
private readonly chromeTheme;
|
|
19
|
-
private readonly leaderRegistry;
|
|
20
|
-
private readonly isCommandAvailable;
|
|
21
|
-
private readonly onUnavailableCommand;
|
|
22
|
-
private readonly onUnavailableAction;
|
|
23
|
-
private readonly onLeaderAction;
|
|
24
|
-
private readonly unsubscribeLeaderRegistry;
|
|
25
|
-
private readonly unsubscribeUiState;
|
|
26
|
-
private leaderActive;
|
|
27
|
-
private leaderPath;
|
|
28
|
-
constructor(tui: TUI, editorTheme: EditorTheme, keybindings: KeybindingsManager, uiState: DoomUiState, onSnapshot: SnapshotHandler, options?: EditorOptions, chromeTheme?: ChromeTheme, leaderOptions?: DoomEditorLeaderOptions);
|
|
29
|
-
handleInput(data: string): void;
|
|
30
|
-
render(width: number): string[];
|
|
31
|
-
dispose(): void;
|
|
32
|
-
private startLeader;
|
|
33
|
-
private cancelLeader;
|
|
34
|
-
private handleLeaderInput;
|
|
35
|
-
private currentGroup;
|
|
36
|
-
private publishLeader;
|
|
37
|
-
private publish;
|
|
38
|
-
private execute;
|
|
39
|
-
private submitCommand;
|
|
40
|
-
private modeLabel;
|
|
41
|
-
private modeBadge;
|
|
42
|
-
/**
|
|
43
|
-
* The enabled modes, names only, beside the editor's own mode badge.
|
|
44
|
-
*
|
|
45
|
-
* Names only because this row is glanced at, not read: which modes are on is
|
|
46
|
-
* the whole question here, and their sub-state belongs where there is room to
|
|
47
|
-
* explain it. The leader panel carries that longer form.
|
|
48
|
-
*
|
|
49
|
-
* Empty when nothing is on, so an ordinary session pays no columns for a
|
|
50
|
-
* feature it is not using.
|
|
51
|
-
*/
|
|
52
|
-
private modeNames;
|
|
53
|
-
private editorStatus;
|
|
54
|
-
private editorLine;
|
|
55
|
-
private findBottomBorder;
|
|
56
|
-
}
|
|
57
|
-
//#endregion
|
|
58
|
-
export { DoomEditor, DoomEditorLeaderOptions };
|
|
59
|
-
//# sourceMappingURL=doomEditor.d.cts.map
|
|
1
|
+
import { DoomEditor, DoomEditorLeaderOptions } from "../tui/doomEditor.cjs";
|
|
2
|
+
export { DoomEditor, DoomEditorLeaderOptions };
|
|
@@ -1,59 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { CustomEditor, KeybindingsManager, Theme } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
import { EditorOptions, EditorTheme, TUI } from "@earendil-works/pi-tui";
|
|
5
|
-
//#region src/components/doomEditor.d.ts
|
|
6
|
-
interface DoomEditorLeaderOptions {
|
|
7
|
-
registry?: DoomLeaderRegistry;
|
|
8
|
-
isCommandAvailable?: (commandName: string) => boolean;
|
|
9
|
-
onUnavailableCommand?: (commandName: string) => void;
|
|
10
|
-
onUnavailableAction?: (action: string) => void;
|
|
11
|
-
onLeaderAction?: (source: string, actionName: string) => void;
|
|
12
|
-
}
|
|
13
|
-
type SnapshotHandler = (snapshot: LeaderSnapshot) => void;
|
|
14
|
-
type ChromeTheme = Pick<Theme, 'bg' | 'bold' | 'fg' | 'inverse'>;
|
|
15
|
-
declare class DoomEditor extends CustomEditor {
|
|
16
|
-
private readonly uiState;
|
|
17
|
-
private readonly onSnapshot;
|
|
18
|
-
private readonly chromeTheme;
|
|
19
|
-
private readonly leaderRegistry;
|
|
20
|
-
private readonly isCommandAvailable;
|
|
21
|
-
private readonly onUnavailableCommand;
|
|
22
|
-
private readonly onUnavailableAction;
|
|
23
|
-
private readonly onLeaderAction;
|
|
24
|
-
private readonly unsubscribeLeaderRegistry;
|
|
25
|
-
private readonly unsubscribeUiState;
|
|
26
|
-
private leaderActive;
|
|
27
|
-
private leaderPath;
|
|
28
|
-
constructor(tui: TUI, editorTheme: EditorTheme, keybindings: KeybindingsManager, uiState: DoomUiState, onSnapshot: SnapshotHandler, options?: EditorOptions, chromeTheme?: ChromeTheme, leaderOptions?: DoomEditorLeaderOptions);
|
|
29
|
-
handleInput(data: string): void;
|
|
30
|
-
render(width: number): string[];
|
|
31
|
-
dispose(): void;
|
|
32
|
-
private startLeader;
|
|
33
|
-
private cancelLeader;
|
|
34
|
-
private handleLeaderInput;
|
|
35
|
-
private currentGroup;
|
|
36
|
-
private publishLeader;
|
|
37
|
-
private publish;
|
|
38
|
-
private execute;
|
|
39
|
-
private submitCommand;
|
|
40
|
-
private modeLabel;
|
|
41
|
-
private modeBadge;
|
|
42
|
-
/**
|
|
43
|
-
* The enabled modes, names only, beside the editor's own mode badge.
|
|
44
|
-
*
|
|
45
|
-
* Names only because this row is glanced at, not read: which modes are on is
|
|
46
|
-
* the whole question here, and their sub-state belongs where there is room to
|
|
47
|
-
* explain it. The leader panel carries that longer form.
|
|
48
|
-
*
|
|
49
|
-
* Empty when nothing is on, so an ordinary session pays no columns for a
|
|
50
|
-
* feature it is not using.
|
|
51
|
-
*/
|
|
52
|
-
private modeNames;
|
|
53
|
-
private editorStatus;
|
|
54
|
-
private editorLine;
|
|
55
|
-
private findBottomBorder;
|
|
56
|
-
}
|
|
57
|
-
//#endregion
|
|
58
|
-
export { DoomEditor, DoomEditorLeaderOptions };
|
|
59
|
-
//# sourceMappingURL=doomEditor.d.mts.map
|
|
1
|
+
import { DoomEditor, DoomEditorLeaderOptions } from "../tui/doomEditor.mjs";
|
|
2
|
+
export { DoomEditor, DoomEditorLeaderOptions };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=doomEditor.mjs.map
|
|
1
|
+
import{DoomEditor as e}from"../tui/doomEditor.mjs";export{e as DoomEditor};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../
|
|
2
|
-
//# sourceMappingURL=doomFooter.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../tui/doomFooter.cjs");exports.DoomFooter=e.DoomFooter;
|
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { ExtensionContext, ReadonlyFooterDataProvider, Theme } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
import { Component, TUI } from "@earendil-works/pi-tui";
|
|
5
|
-
//#region src/components/doomFooter.d.ts
|
|
6
|
-
declare class DoomFooter implements Component {
|
|
7
|
-
private readonly theme;
|
|
8
|
-
private readonly context;
|
|
9
|
-
private readonly footerData;
|
|
10
|
-
private readonly footerStatuses;
|
|
11
|
-
private readonly uiState;
|
|
12
|
-
private readonly unsubscribeBranch;
|
|
13
|
-
private readonly unsubscribeFooterStatuses;
|
|
14
|
-
private readonly unsubscribeState;
|
|
15
|
-
constructor(tui: TUI, theme: Theme, context: ExtensionContext, footerData: ReadonlyFooterDataProvider, footerStatuses: footer_d_exports.DoomFooterStatusRegistry, uiState: DoomUiState);
|
|
16
|
-
dispose(): void;
|
|
17
|
-
invalidate(): void;
|
|
18
|
-
render(width: number): string[];
|
|
19
|
-
private locationSegment;
|
|
20
|
-
private runtimeSegment;
|
|
21
|
-
/** Effort rides the theme's rising ramp, from grey at off to red at max. */
|
|
22
|
-
private thinkingColor;
|
|
23
|
-
/** Context usage warms as the window fills, so pressure is visible at a glance. */
|
|
24
|
-
private contextColor;
|
|
25
|
-
private modelineSummary;
|
|
26
|
-
private footerStatusSummary;
|
|
27
|
-
private renderFooterSegments;
|
|
28
|
-
private compactModel;
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
export { DoomFooter };
|
|
32
|
-
//# sourceMappingURL=doomFooter.d.cts.map
|
|
1
|
+
import { DoomFooter } from "../tui/doomFooter.cjs";
|
|
2
|
+
export { DoomFooter };
|
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { ExtensionContext, ReadonlyFooterDataProvider, Theme } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
import { Component, TUI } from "@earendil-works/pi-tui";
|
|
5
|
-
//#region src/components/doomFooter.d.ts
|
|
6
|
-
declare class DoomFooter implements Component {
|
|
7
|
-
private readonly theme;
|
|
8
|
-
private readonly context;
|
|
9
|
-
private readonly footerData;
|
|
10
|
-
private readonly footerStatuses;
|
|
11
|
-
private readonly uiState;
|
|
12
|
-
private readonly unsubscribeBranch;
|
|
13
|
-
private readonly unsubscribeFooterStatuses;
|
|
14
|
-
private readonly unsubscribeState;
|
|
15
|
-
constructor(tui: TUI, theme: Theme, context: ExtensionContext, footerData: ReadonlyFooterDataProvider, footerStatuses: footer_d_exports.DoomFooterStatusRegistry, uiState: DoomUiState);
|
|
16
|
-
dispose(): void;
|
|
17
|
-
invalidate(): void;
|
|
18
|
-
render(width: number): string[];
|
|
19
|
-
private locationSegment;
|
|
20
|
-
private runtimeSegment;
|
|
21
|
-
/** Effort rides the theme's rising ramp, from grey at off to red at max. */
|
|
22
|
-
private thinkingColor;
|
|
23
|
-
/** Context usage warms as the window fills, so pressure is visible at a glance. */
|
|
24
|
-
private contextColor;
|
|
25
|
-
private modelineSummary;
|
|
26
|
-
private footerStatusSummary;
|
|
27
|
-
private renderFooterSegments;
|
|
28
|
-
private compactModel;
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
export { DoomFooter };
|
|
32
|
-
//# sourceMappingURL=doomFooter.d.mts.map
|
|
1
|
+
import { DoomFooter } from "../tui/doomFooter.mjs";
|
|
2
|
+
export { DoomFooter };
|