@vibecontrols/vibe-plugin-tunnel 2026.509.2 → 2026.509.3
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/index.js +3 -3
- package/package.json +1 -1
- package/dist/utils/multimode.d.ts +0 -66
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var __require=import.meta.require;import{Elysia}from"elysia";function createLifecycleHooks(spec){let{name,onInit,onShutdown,telemetryEventName,skipPlatforms}=spec;return{onServerStart:async(_app,hostServices)=>{if(skipPlatforms&&skipPlatforms.includes(process.platform)){process.stderr.write(`[${name}] skipping init on unsupported platform '${process.platform}'
|
|
3
|
-
`);return}if(onInit)await onInit(hostServices);if(telemetryEventName)hostServices.telemetry?.emit(telemetryEventName,{plugin:name})},onServerStop:async(hostServices)=>{if(onShutdown)await onShutdown(hostServices)}}}
|
|
4
|
-
`);return}if(mode==="plain"){await opts.plain(data);return}if((mode==="interactive"||
|
|
5
|
-
`),!0}async function loadCore(){return await import("@opentui/core")}async function interactiveTable(opts){if(opts.rows.length===0)return null;let core=await loadCore(),{createCliRenderer,BoxRenderable,TextRenderable,SelectRenderable,SelectRenderableEvents}=core,renderer=await createCliRenderer({exitOnCtrlC:!0,targetFps:30}),ctx=renderer.root.ctx,root=new BoxRenderable(ctx,{width:"100%",height:"100%",flexDirection:"column",backgroundColor:"#0b0d12"}),title=new TextRenderable(ctx,{content:` ${opts.title}`,fg:"#8be9fd",height:1}),footer=new TextRenderable(ctx,{content:` ${opts.footer??"\u2191/\u2193 navigate \xB7 Enter select \xB7 q quit"}`,fg:"#6c7086",height:1}),body=new BoxRenderable(ctx,{width:"100%",flexGrow:1,flexDirection:"row"}),list=new SelectRenderable(ctx,{width:opts.listWidth??28,height:"100%",options:opts.rows.map((r)=>({name:r.label,description:r.hint??"",value:r.id})),selectedIndex:0,showDescription:!0,backgroundColor:"#0b0d12",textColor:"#cdd6f4",focusedBackgroundColor:"#0b0d12",focusedTextColor:"#cdd6f4",selectedBackgroundColor:"#1f2335",selectedTextColor:"#a6e3a1",descriptionColor:"#6c7086",selectedDescriptionColor:"#9399b2",showScrollIndicator:!0,wrapSelection:!0}),detailPane=new BoxRenderable(ctx,{flexGrow:1,height:"100%",flexDirection:"column",paddingLeft:2,paddingRight:2,backgroundColor:"#11141c"}),detailText=new TextRenderable(ctx,{content:"",fg:"#cdd6f4"});detailPane.add(detailText),body.add(list),body.add(detailPane),root.add(title),root.add(body),root.add(footer),renderer.root.add(root),list.focus();let renderDetail=(idx)=>{let row=opts.rows[idx];if(!row)return;detailText.content=`
|
|
3
|
+
`);return}if(onInit)await onInit(hostServices);if(telemetryEventName)hostServices.telemetry?.emit(telemetryEventName,{plugin:name})},onServerStop:async(hostServices)=>{if(onShutdown)await onShutdown(hostServices)}}}function pickOutputMode(flags){if(flags.json)return"json";if(flags.plain)return"plain";if(flags.interactive)return"interactive";return"auto"}function isCi(){return!!process.env.CI||!!process.env.NO_COLOR||process.env.TERM==="dumb"}function stdoutIsTty(){return Boolean(process.stdout.isTTY)}async function runMultimode(opts){let data=await opts.fetchData(),mode=opts.mode??"auto";if(mode==="json"){let shaped=opts.json?opts.json(data):data;process.stdout.write(`${JSON.stringify(shaped,null,2)}
|
|
4
|
+
`);return}if(mode==="plain"){await opts.plain(data);return}if((mode==="interactive"||stdoutIsTty()&&!isCi())&&!!opts.interactive&&opts.interactive)try{await opts.interactive(data);return}catch{}await opts.plain(data)}function maybePrintJson(flags,data){if(!flags.json)return!1;return process.stdout.write(`${JSON.stringify(data,null,2)}
|
|
5
|
+
`),!0}var TelemetryEmitter=class{constructor(pluginName,pluginVersion,hostServices){this.pluginName=pluginName,this.pluginVersion=pluginVersion,this.hostServices=hostServices}pluginName;pluginVersion;hostServices;emit(eventName,payload){let target=this.hostServices?.telemetry;if(!target)return;target.emit(eventName,{plugin:this.pluginName,version:this.pluginVersion,timestamp:new Date().toISOString(),...payload??{}})}emitReady(context){this.emit(`${this.pluginName}.ready`,context)}emitError(error,context){this.emit(`${this.pluginName}.error`,{message:error.message,...context??{}})}emitEvent(type,payload){this.emit(type,payload)}},BoundLogger=class{constructor(logger,source){this.logger=logger,this.source=source}logger;source;info(message,meta){this.logger?.info?.(this.source,message,meta)}warn(message,meta){this.logger?.warn?.(this.source,message,meta)}error(message,meta){this.logger?.error?.(this.source,message,meta)}debug(message,meta){this.logger?.debug?.(this.source,message,meta)}};var ProviderRegistry=class{constructor(hostServices){this.hostServices=hostServices}hostServices;getServiceRegistry(){return this.hostServices?.serviceRegistry}registerProvider(type,name,provider){this.hostServices?.serviceRegistry?.registerService(type,name,provider)}getProvider(type,name){return this.hostServices?.serviceRegistry?.getService(type,name)}listProviders(type){return this.hostServices?.serviceRegistry?.listProvidersForType?.(type)??[]}withCliContribution(contribution){let contributors=this.hostServices?.cliContributors;if(!contributors)return;for(let section of contribution.statusSections??[])contributors.addStatusSection?.(section);for(let check of contribution.doctorChecks??[])contributors.addDoctorCheck?.(check)}};import{existsSync,readFileSync}from"fs";import{join,resolve}from"path";async function loadCore(){return await import("@opentui/core")}async function interactiveTable(opts){if(opts.rows.length===0)return null;let core=await loadCore(),{createCliRenderer,BoxRenderable,TextRenderable,SelectRenderable,SelectRenderableEvents}=core,renderer=await createCliRenderer({exitOnCtrlC:!0,targetFps:30}),ctx=renderer.root.ctx,root=new BoxRenderable(ctx,{width:"100%",height:"100%",flexDirection:"column",backgroundColor:"#0b0d12"}),title=new TextRenderable(ctx,{content:` ${opts.title}`,fg:"#8be9fd",height:1}),footer=new TextRenderable(ctx,{content:` ${opts.footer??"\u2191/\u2193 navigate \xB7 Enter select \xB7 q quit"}`,fg:"#6c7086",height:1}),body=new BoxRenderable(ctx,{width:"100%",flexGrow:1,flexDirection:"row"}),list=new SelectRenderable(ctx,{width:opts.listWidth??28,height:"100%",options:opts.rows.map((r)=>({name:r.label,description:r.hint??"",value:r.id})),selectedIndex:0,showDescription:!0,backgroundColor:"#0b0d12",textColor:"#cdd6f4",focusedBackgroundColor:"#0b0d12",focusedTextColor:"#cdd6f4",selectedBackgroundColor:"#1f2335",selectedTextColor:"#a6e3a1",descriptionColor:"#6c7086",selectedDescriptionColor:"#9399b2",showScrollIndicator:!0,wrapSelection:!0}),detailPane=new BoxRenderable(ctx,{flexGrow:1,height:"100%",flexDirection:"column",paddingLeft:2,paddingRight:2,backgroundColor:"#11141c"}),detailText=new TextRenderable(ctx,{content:"",fg:"#cdd6f4"});detailPane.add(detailText),body.add(list),body.add(detailPane),root.add(title),root.add(body),root.add(footer),renderer.root.add(root),list.focus();let renderDetail=(idx)=>{let row=opts.rows[idx];if(!row)return;detailText.content=`
|
|
6
6
|
${row.detail}
|
|
7
7
|
`};return renderDetail(0),list.on(SelectRenderableEvents.SELECTION_CHANGED,(idx)=>{renderDetail(idx)}),await new Promise((resolve)=>{let cleanup=(chosen)=>{try{renderer.destroy()}catch{}resolve(chosen)};list.on(SelectRenderableEvents.ITEM_SELECTED,()=>{let row=opts.rows[list.getSelectedIndex()];cleanup(row??null)}),renderer.keyInput.on("keypress",(key)=>{if(key.name==="escape"||key.name==="q")cleanup(null)})}).then(async(chosen)=>{if(chosen&&opts.onSelect)await opts.onSelect(chosen);return chosen})}async function interactiveDetail(opts){let core=await loadCore(),{createCliRenderer,BoxRenderable,TextRenderable}=core,renderer=await createCliRenderer({exitOnCtrlC:!0,targetFps:30}),ctx=renderer.root.ctx,root=new BoxRenderable(ctx,{width:"100%",height:"100%",flexDirection:"column",backgroundColor:"#0b0d12"}),title=new TextRenderable(ctx,{content:` ${opts.title}`,fg:"#8be9fd",height:1}),bodyBox=new BoxRenderable(ctx,{width:"100%",flexGrow:1,paddingLeft:2,paddingRight:2,backgroundColor:"#11141c"}),bodyText=new TextRenderable(ctx,{content:`
|
|
8
8
|
${opts.body}
|
package/package.json
CHANGED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Multi-mode output dispatcher.
|
|
3
|
-
*
|
|
4
|
-
* Every read-style command (list/show/status/dashboard) should funnel its
|
|
5
|
-
* output through `runMultimode`. The data is fetched ONCE by `fetchData`,
|
|
6
|
-
* then handed to one of three renderers:
|
|
7
|
-
*
|
|
8
|
-
* • interactive — opentui UI (default in TTY when an interactive renderer
|
|
9
|
-
* is provided AND @opentui/core imports cleanly)
|
|
10
|
-
* • plain — ANSI text written to stdout (the legacy / pipe-friendly
|
|
11
|
-
* output)
|
|
12
|
-
* • json — `JSON.stringify(data, null, 2)` to stdout (or a
|
|
13
|
-
* custom shaper) — friendly for jq/scripting
|
|
14
|
-
*
|
|
15
|
-
* Mutating commands (start/stop/install/...) typically don't need this —
|
|
16
|
-
* they print progress and exit. They MAY still call `runMultimode` to emit
|
|
17
|
-
* a result object in JSON when `--json` is set; see `pickOutputMode`.
|
|
18
|
-
*
|
|
19
|
-
* The selection rules:
|
|
20
|
-
*
|
|
21
|
-
* ┌─────────────────────┬──────────────────────────────────────────────┐
|
|
22
|
-
* │ explicit --json │ json renderer (or default JSON.stringify) │
|
|
23
|
-
* │ explicit --plain │ plain renderer │
|
|
24
|
-
* │ stdout is not a TTY │ plain renderer │
|
|
25
|
-
* │ NO_COLOR, CI=true │ plain renderer │
|
|
26
|
-
* │ no interactive fn │ plain renderer │
|
|
27
|
-
* │ otherwise │ interactive renderer (falls back to plain │
|
|
28
|
-
* │ │ if @opentui/core fails to import) │
|
|
29
|
-
* └─────────────────────┴──────────────────────────────────────────────┘
|
|
30
|
-
*/
|
|
31
|
-
export type OutputMode = "auto" | "interactive" | "plain" | "json";
|
|
32
|
-
export interface OutputFlags {
|
|
33
|
-
json?: boolean;
|
|
34
|
-
plain?: boolean;
|
|
35
|
-
interactive?: boolean;
|
|
36
|
-
}
|
|
37
|
-
export interface MultimodeOptions<T> {
|
|
38
|
-
/** Pure data fetcher. Called once. */
|
|
39
|
-
fetchData: () => Promise<T> | T;
|
|
40
|
-
/** Plain-text renderer. Required — every command needs a pipe-friendly fallback. */
|
|
41
|
-
plain: (data: T) => void | Promise<void>;
|
|
42
|
-
/**
|
|
43
|
-
* Optional opentui renderer. Only used when stdout is a TTY and opentui
|
|
44
|
-
* imports cleanly. If omitted or it fails, we fall back to `plain`.
|
|
45
|
-
*/
|
|
46
|
-
interactive?: (data: T) => Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* Optional JSON shaper. Defaults to `JSON.stringify(data, null, 2)`.
|
|
49
|
-
* Override when you need to redact secrets or reshape for scripting.
|
|
50
|
-
*/
|
|
51
|
-
json?: (data: T) => unknown;
|
|
52
|
-
/** Output mode (resolved from CLI flags by `pickOutputMode`). */
|
|
53
|
-
mode?: OutputMode;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Resolve the desired output mode from CLI flags. The caller should pass the
|
|
57
|
-
* merged opts of the local command + the global program (since `--json`
|
|
58
|
-
* lives on the program level too).
|
|
59
|
-
*/
|
|
60
|
-
export declare function pickOutputMode(flags: OutputFlags): OutputMode;
|
|
61
|
-
export declare function runMultimode<T>(opts: MultimodeOptions<T>): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Convenience: emit the data shape as JSON (used by mutating commands that
|
|
64
|
-
* still want a `--json` opt-in for scripting). Returns true if it printed.
|
|
65
|
-
*/
|
|
66
|
-
export declare function maybePrintJson(flags: OutputFlags, data: unknown): boolean;
|