Optional PREVIEW console for Claude Code that observes Skill Heaven summons and never changes them: a status entry, a Lens band above the prompt, and a /heaven…

An optional console for Skill Heaven in Claude Code. It shows what a summon returned, whether the skill body actually entered context, and what you are trusting. It observes; it never changes a summon, refuses a tool call, or runs one on its own. Skill Heaven works exactly the same without it.
Status: preview. It is built on Claude Code's early-access Mods API (function hooks, first available in 2.1.293), which may change between releases. It has passed
claude plugin validateand the engine's own test kit on both the terminal and desktop surfaces, and a live probe in a logged-in terminal session on 2.1.294 (below). How it paints in the desktop app has not been probed — treat the desktop look as unconfirmed.
| Surface | What you see |
|---|---|
| Status entry | ◇ entropy ‹‹ [NATIVE] ›› · 2 skills beside your own status line. It is appended; your statusLine setting is never touched. |
| Lens band | Empty by default. Only an explicit /lens opens it. Ordinary summon/read observations update compact status and receipt state, never open an unsolicited band. The requested band shows one short notice plus deliberate controls; Dismiss clears intent. |
/lens <intent> | Previews which skill would be summoned, with preview: true. Nothing is materialized; the summon engine still logs the query in its own session directory. The preview and its detail appear in the band, not in the conversation. For a single candidate the band offers Summon, which only fills your prompt with /skill-heaven:summon <name> — you press Enter. If a summon tool ignores preview and materializes a skill, the band shows that real summon and the count includes it. |
/heaven | A concise pane with Session, Scope, Flow and Trust. Inspect section or /heaven inspect <section> deliberately reveals evidence/diagnostics/controls. Section changes return to summary. Close/Escape or /heaven dismiss closes it; opening requests 12 rows through the supported host API. |
Selecting a rung (/skill-heaven:skill-heaven low, /skill-heaven:skill-hell high, /skill-heaven:skill-ultra, /skill-heaven:skill-zero) changes the bracketed reading in the status entry. That reading is a preference you expressed and the console saw; Skill Heaven does not enforce it. /skill-ultra reads [ULTRA]; the Ultra controller is provisioned, not built. The compact status entry shows only [ULTRA] and the skill count — controller unavailable is disclosed in inspected Scope and shared summaries, never an invented working controller.
Add the marketplace once, then install:
/plugin marketplace add gaia-research/gaia-skill-heaven
/plugin install skill-heaven-console@gaia-skill-heaven
It needs the skill-heaven plugin (or the claude-zero launcher) to have anything to observe; without a summon tool the pane says summon tool: not connected.
A mod installed this way is a terminal action: a local session started from the desktop app loads a user-scope install, but the install command itself is typed in a terminal session.
/skill-* commands you submit, and Read and Agent tool calls — only to observe them./lens preview.)/lens calls the bundled summon tool, which fetches the skill source./lens and /heaven is a row the model can see. It is fixed text and carries nothing a skill source, a tool error or a refusal supplied; all detail stays in the band and the pane.~/.claude. Buttons pre-fill a command for you to submit. All text that came from a skill source or a model is sanitized before it is drawn.status (Settings, or pluginConfigs in settings.json): off, compact (default) or full. off removes the status entry; the band and pane stay available. The persistent contribution is always one compact line maximum, including when the legacy full statusline option is selected; details belong in the deliberately opened pane.
Core + Console is a Skill Heaven terminal installation profile. It does not install or claim the optional cross-product Gaia Ecosystem Desktop Mod / Living Tree B.
/plugin disable skill-heaven-console
/plugin uninstall skill-heaven-console@gaia-skill-heaven
The status entry, band and pane disappear. Skill Heaven is unchanged.
PR #187, macOS, a logged-in session in a visible Herdr pane, both plugins loaded from the checkout with --plugin-dir and a session-only --settings that supplied a user statusLine:
statusLine; neither replaces the other. The host draws it as ⚠ skill-heaven-console: ◇ entropy ‹‹ [NATIVE] ›› · 0 skills; the ⚠ <plugin>: prefix is the host's./lens shows the band and leaves the count at 0 skills. /skill-heaven:summon takes it to 1 skill. A Read of the materialized SKILL.md moves the band from card returned · body not read to in context · body read by main agent.tool.call and $.tool.call as { ref, result, text }, with result the server's JSON text as a string. structuredContent appears nowhere; the console reads the JSON text.$.tool.list() names deferred MCP tools (the summon tool is behind ToolSearch and is listed), but only once MCP has connected: at session.start it lists no MCP tool at all, so /lens re-checks for a few seconds before saying "not connected".tool.call and turn.complete inside a subagent carry its agentId, and the Agent tool's result carries the same id. Flow attributes the subagent's summons to it.command.run fires before prompt.submit, and prompt.submit.text is the raw typed text (/skill-heaven:skill-hell high), not the expanded body. A subagent's hand-back arrives as prompt.submit with origin.kind: "peer"; the console ignores it./skill-zero or /skill-hell high resolves to the plugin's portable skill and the host says it "can only be invoked by Claude". Every console pre-fill uses /skill-heaven:<surface>.~/.claude/settings.json, settings.local.json and installed_plugins.json were byte-identical. claude plugin validate resolves the console's calls to $.state, $.ui.*, $.prompt.fill, $.tool.list/call (the /lens preview) and $.command.register: no file system, settings or process calls.Still unconfirmed:
node scripts/build-status.mjs # regenerate hooks/status-model.mjs from packages/status
claude plugin validate plugins/skill-heaven-console
claude plugin test plugins/skill-heaven-console
hooks/status-model.mjs is generated and committed; CI checks it against a fresh build. Do not edit it.
hooks/register.tsx 451 lines1// Skill Heaven console (preview) — a Claude Code mod.
2//
3// It projects the one status model (status-model.mjs) into the desktop and the
4// terminal: a status entry, the Lens band above the prompt, and the /heaven
5// pane. It OBSERVES summons; it never rewrites, refuses or issues one. Every
6// tool.call hook below calls `next`, records what came back, and returns the
7// result untouched. A button pre-fills a command for the person to submit; the
8// UI is not an authority channel. Nothing is written to disk or to settings.
9//
10// The engine reads this file's source: every helper that is handed `$` is a
11// function declared at the top level of this file.
12
13import { atom, read, update } from 'claude-code'
14import type { EngineInterface, PluginOptions, Register, RenderSurface } from 'claude-code'
15
16import {
17 eventFromSummonResult,
18 renderStatusSegments,
19 sanitizeDisplay,
20 selectionFromCommand,
21 toPlain,
22} from './status-model.mjs'
23import type { StatusMode, SummonEvent } from './status-model.mjs'
24import { PANE_ID } from './meta.ts'
25import {
26 LAUNCHER_SUMMON_TOOL,
27 MARKETPLACE_SUMMON_TOOL,
28 SUMMON_TOOL,
29 agentCallLabel,
30 agentLabelFor,
31 agentReturned,
32 dropAgentCall,
33 finishAgentCall,
34 fromData,
35 initialState,
36 noteAgentId,
37 qualifyCommand,
38 recordEvent,
39 recordRead,
40 recordSelection,
41 startAgentCall,
42 structuredOf,
43 toData,
44} from './model.ts'
45import type { ConsoleSection, ConsoleState } from './model.ts'
46import { renderBand, renderPane } from './views.tsx'
47import type { BandActions, PaneActions } from './views.tsx'
48
49// The shape tag: a reload whose code names another tag starts from a clean state
50// instead of reading a value an older layout wrote.
51const stateAtom = atom({ plugin: 'skill-heaven-console', key: 'state' } as const, toData(initialState()), {
52 shape: 'skill-heaven-console/state@2',
53})
54
55const SECTIONS: readonly ConsoleSection[] = ['session', 'scope', 'flow', 'trust']
56
57// True while this console's own /lens preview is in flight, so the summon
58// observer does not record the same call twice.
59let lensInFlight = false
60
61function modeOf(options: PluginOptions): StatusMode {
62 const v = options.status
63 return v === 'off' || v === 'full' ? v : 'compact'
64}
65
66const isoOf = (ms: number): string => new Date(ms).toISOString()
67
68/** Re-set the status entry from state. `off` removes it; it never touches statusLine. */
69function paintStatus($: EngineInterface, mode: StatusMode, state: ConsoleState): void {
70 $.ui.status(mode === 'off' ? undefined : toPlain(renderStatusSegments(state.status, 'compact')))
71}
72
73async function load($: EngineInterface): Promise<ConsoleState> {
74 return fromData(await read($, stateAtom))
75}
76
77/** Change state, then re-set the status entry. */
78async function change($: EngineInterface, mode: StatusMode, fn: (s: ConsoleState) => ConsoleState): Promise<ConsoleState> {
79 const next = fromData(await update($, stateAtom, (data) => toData(fn(fromData(data)))))
80 paintStatus($, mode, next)
81 return next
82}
83
84async function openPane($: EngineInterface): Promise<void> {
85 await $.ui.open({ id: PANE_ID, title: 'Skill Heaven', focus: true, closeOnEscape: true, rows: 12 })
86}
87
88/** Fire and forget, but never leave a rejection unhandled. */
89function later(work: Promise<unknown>): void {
90 work.catch(() => {})
91}
92
93/** Pre-fill the prompt without wiping a draft; say so when the box could not take it.
94 * Skill Heaven commands are filled in the spelling the session accepts. */
95async function fillPrompt($: EngineInterface, command: string): Promise<void> {
96 const text = qualifyCommand(command)
97 try {
98 const filled = await $.prompt.fill({ text, mode: 'insert' })
99 if (!filled.isFilled) $.ui.toast(`Type this: ${text}`)
100 } catch {
101 $.ui.toast(`Type this: ${text}`)
102 }
103}
104
105async function copyText($: EngineInterface, text: string, surface: RenderSurface): Promise<void> {
106 try {
107 const copied = await $.ui.copy({ text, surface })
108 if (!copied.isCopied) $.ui.toast(`Copy this: ${text}`)
109 } catch {
110 $.ui.toast(`Copy this: ${text}`)
111 }
112}
113
114type Preview = { event: SummonEvent; reached: boolean } | { notConnected: true }
115
116/**
117 * Ask the summon tool what it would summon, with `preview: true`.
118 *
119 * A tool is absent only when it is not in the session's tool list. A call to a
120 * tool the list names that is rejected was aborted or failed: that is an error
121 * event, and says nothing about whether the tool is connected.
122 */
123/** MCP servers connect in the background after session.start: observed on
124 * 2.1.294, `$.tool.list()` names no MCP tool at session.start and a /lens typed in
125 * the first seconds found no summon tool. An absent tool is checked again, a few
126 * times, before the band says "not connected". */
127const CONNECT_CHECKS = 4
128const CONNECT_WAIT_MS = 1500
129
130async function previewSummon($: EngineInterface, query: string): Promise<Preview> {
131 for (let check = 1; ; check++) {
132 const outcome = await previewOnce($, query)
133 if (!('notConnected' in outcome) || check >= CONNECT_CHECKS) return outcome
134 try {
135 await $.clock.sleep(CONNECT_WAIT_MS)
136 } catch {
137 return outcome
138 }
139 }
140}
141
142async function previewOnce($: EngineInterface, query: string): Promise<Preview> {
143 const listed: string[] = []
144 try {
145 for (const t of await $.tool.list()) if (SUMMON_TOOL.test(t.name)) listed.push(t.name)
146 } catch {
147 // listing is a convenience; the two known spellings are tried next
148 }
149 const names = [...listed]
150 for (const known of [MARKETPLACE_SUMMON_TOOL, LAUNCHER_SUMMON_TOOL]) if (!names.includes(known)) names.push(known)
151 const at = isoOf(await $.clock.now())
152 const failed = (text: string): Preview => ({
153 event: eventFromSummonResult(undefined, { at, agent: null, preview: true, query }, { isError: true, text }),
154 reached: false,
155 })
156 for (const name of names) {
157 let result
158 try {
159 result = await $.tool.call({
160 tool: name as typeof MARKETPLACE_SUMMON_TOOL | typeof LAUNCHER_SUMMON_TOOL,
161 query,
162 surface: 'any',
163 preview: true,
164 })
165 } catch {
166 if (listed.includes(name)) return failed('preview aborted or failed')
167 continue // not in this session
168 }
169 if (result.deny !== undefined) return failed(`preview refused: ${result.deny}`)
170 const failure = result.isError === true ? ({ isError: true, text: result.text ?? null } as const) : undefined
171 return {
172 event: eventFromSummonResult(failure ? undefined : structuredOf(result), { at, agent: null, preview: true, query }, failure),
173 reached: true,
174 }
175 }
176 return { notConnected: true }
177}
178
179/** The one-line result of /lens. The model reads it, so it is fixed text: nothing a
180 * skill source, a tool error or a refusal supplied ever goes in it. The detail is in the band. */
181function lensResultText(event: SummonEvent): string {
182 if (event.kind === 'summoned' && event.delta > 0) {
183 return 'Lens: this summon tool ignored preview; a skill was materialized. See the band.'
184 }
185 if (event.kind === 'previewed') return 'Lens preview shown in the band. Nothing was summoned.'
186 if (event.kind === 'no-match') return 'Lens: no match. Nothing was summoned.'
187 return 'Lens: the preview failed; see the band.'
188}
189
190export const register: Register = (on, options) => {
191 const mode = modeOf(options)
192
193 /* ----------------------------------------------------------------------- *
194 * Session
195 * ----------------------------------------------------------------------- */
196
197 on('session.start', async ($, e, next) => {
198 await $.command.register({ name: 'heaven', description: 'Open the Skill Heaven console', argumentHint: '[inspect] [session|scope|flow|trust] | dismiss' })
199 await $.command.register({
200 name: 'lens',
201 description: 'Preview which skill would be summoned — nothing is materialized',
202 argumentHint: '<intent>',
203 })
204 let hostVersion: string | null = null
205 try {
206 hostVersion = (await $.session.version()).version
207 } catch {
208 hostVersion = null
209 }
210 await change($, mode, (s) => ({ ...s, hostVersion }))
211 return next(e)
212 })
213
214 // A /clear ends the conversation without a new session.start: what the console
215 // counted belongs to the conversation that is gone.
216 on('session.end', async ($, e, next) => {
217 if (e.reason === 'clear') {
218 try {
219 await change($, mode, (s) => ({ ...initialState(), hostVersion: s.hostVersion }))
220 } catch {
221 // leave the old state rather than break the session
222 }
223 }
224 return next(e)
225 })
226
227 /* ----------------------------------------------------------------------- *
228 * Commands
229 * ----------------------------------------------------------------------- */
230
231 on('command.run', { command: 'heaven' }, async ($, e) => {
232 const args = e.args.trim().toLowerCase().split(/\s+/)
233 if (args[0] === 'dismiss') {
234 await $.ui.close({ id: PANE_ID })
235 await change($, mode, (s) => ({ ...s, band: null, bandRequested: false }))
236 return { text: 'Skill Heaven console dismissed.' }
237 }
238 const inspectSection = args[0] === 'inspect'
239 const section = SECTIONS.find((s) => s === args[inspectSection ? 1 : 0])
240 await change($, mode, (s) => ({ ...s, section: section ?? s.section, inspectSection, openEntry: null }))
241 await openPane($)
242 // The model reads this row: fixed text only.
243 return { text: 'Skill Heaven console opened.' }
244 })
245
246 on('command.run', { command: 'lens' }, async ($, e) => {
247 const query = sanitizeDisplay(e.args, 200)
248 if (query === '') return { text: 'Usage: /lens <intent>. Nothing was summoned.' }
249 await change($, mode, (s) => ({ ...s, band: { kind: 'looking', query }, bandRequested: true }))
250 lensInFlight = true
251 try {
252 let outcome: Preview
253 try {
254 outcome = await previewSummon($, query)
255 } finally {
256 lensInFlight = false
257 }
258 if ('notConnected' in outcome) {
259 await change($, mode, (s) => ({
260 ...s,
261 band: { kind: 'not-connected' },
262 status: { ...s.status, summonTool: 'not-connected' },
263 }))
264 return { text: 'Lens: the summon tool is not connected.' }
265 }
266 const { event, reached } = outcome
267 await change($, mode, (s) => recordEvent(s, event, null, 'lens', reached))
268 return { text: lensResultText(event) }
269 } finally {
270 // however it ended, the in-flight band does not stay up
271 try {
272 await change($, mode, (s) => (s.band !== null && s.band.kind === 'looking' ? { ...s, band: null } : s))
273 } catch {
274 // nothing more to do
275 }
276 }
277 })
278
279 /* ----------------------------------------------------------------------- *
280 * Observing (never changing) tool calls
281 * ----------------------------------------------------------------------- */
282
283 // Agents: the host reports an agent id on calls made inside a subagent, and the
284 // Agent tool starts one. Both only add rows to Flow.
285 on('tool.call', async ($, e, next) => {
286 const args = e as unknown as Record<string, unknown>
287 const isAgentCall = String(e.tool) === 'Agent' || String(e.tool) === 'Task'
288 const key = typeof e.tool_use_id === 'string' ? e.tool_use_id : ''
289 const background = args.run_in_background !== false
290 try {
291 const reported = typeof e.agentId === 'string' ? e.agentId : null
292 if (reported !== null) {
293 const seen = await load($)
294 if (!seen.agentIdsSeen || !seen.agents.some((a) => a.id === reported)) {
295 await change($, mode, (s) => noteAgentId(s, reported))
296 }
297 }
298 if (isAgentCall && key) {
299 const label = agentCallLabel(args.subagent_type, args.description)
300 await change($, mode, (s) => startAgentCall(s, key, label, background))
301 }
302 } catch {
303 // observing must never get in the way of the call
304 }
305 let r
306 try {
307 r = await next(e)
308 } catch (error) {
309 // aborted: the call started nothing
310 if (isAgentCall && key) later(change($, mode, (s) => dropAgentCall(s, key)))
311 throw error
312 }
313 try {
314 if (isAgentCall && key) {
315 if (r.deny !== undefined || r.isError === true) {
316 // refused or failed: no agent was started, so no row is left
317 await change($, mode, (s) => dropAgentCall(s, key))
318 } else {
319 const record = (r as { result?: unknown }).result
320 const rec = typeof record === 'object' && record !== null ? (record as Record<string, unknown>) : {}
321 const id = typeof rec.agentId === 'string' ? rec.agentId : typeof rec.agent_id === 'string' ? rec.agent_id : null
322 await change($, mode, (s) => finishAgentCall(s, key, id, background))
323 }
324 }
325 } catch {
326 // see above
327 }
328 return r
329 }).catch(($, e, next) => next(e))
330
331 // Summons: record what came back. The result is returned exactly as received.
332 on('tool.call', { tool: /^mcp__(?:plugin_skill-heaven_)?skill-summon__summon$/ }, async ($, e, next) => {
333 const r = await next(e)
334 try {
335 const args = e as unknown as Record<string, unknown>
336 const preview = args.preview === true
337 if (r.deny === undefined && !(lensInFlight && preview)) {
338 const at = isoOf(await $.clock.now())
339 const agent = typeof e.agentId === 'string' ? e.agentId : null
340 const failure = r.isError === true ? ({ isError: true, text: r.text ?? null } as const) : undefined
341 const event = eventFromSummonResult(
342 failure ? undefined : structuredOf(r),
343 { at, agent, preview, query: typeof args.query === 'string' ? args.query : undefined },
344 failure,
345 )
346 await change($, mode, (s) => recordEvent(s, event, agent, 'tool'))
347 }
348 } catch {
349 // see above
350 }
351 return r
352 }).catch(($, e, next) => next(e))
353
354 // Body reads: a Read of a summoned skill's materialized SKILL.md is what puts
355 // it in context. The result is returned exactly as received.
356 on('tool.call', { tool: 'Read' }, async ($, e, next) => {
357 const r = await next(e)
358 try {
359 const args = e as unknown as Record<string, unknown>
360 // a partial read (an offset or a limit) is not the body read
361 const isWhole = (args.offset === undefined || args.offset === null) && (args.limit === undefined || args.limit === null)
362 if (isWhole && r.deny === undefined && r.isError !== true && typeof e.file_path === 'string') {
363 const path = e.file_path
364 const current = await load($)
365 const reader = agentLabelFor(current, typeof e.agentId === 'string' ? e.agentId : null)
366 if (recordRead(current, path, reader) !== current) {
367 await change($, mode, (s) => recordRead(s, path, reader))
368 }
369 }
370 } catch {
371 // see above
372 }
373 return r
374 }).catch(($, e, next) => next(e))
375
376 on('turn.complete', async ($, e, next) => {
377 try {
378 if (typeof e.agentId === 'string') {
379 const id = e.agentId
380 await change($, mode, (s) => agentReturned(s, id))
381 }
382 } catch {
383 // see above
384 }
385 return next(e)
386 })
387
388 // Rung selection: the person typed /skill-heaven, /skill-hell, /skill-ultra or
389 // /skill-zero. The console reads it; the prompt goes on unchanged.
390 on('prompt.submit', async ($, e, next) => {
391 // A subagent's hand-back arrives as a prompt too (origin `peer`, observed on
392 // 2.1.294): it is not the person's next prompt and selects no rung.
393 if ((e as { origin?: { kind?: string } }).origin?.kind === 'peer') return next(e)
394 try {
395 const reading = selectionFromCommand(e.text)
396 await change($, mode, (s) => {
397 const seen = reading ? recordSelection(s, reading, e.text.trim()) : s
398 // The band hides on the next prompt (a /lens in flight keeps its own).
399 return seen.band !== null && seen.band.kind !== 'looking' ? { ...seen, band: null } : seen
400 })
401 } catch {
402 // see above
403 }
404 return next(e)
405 }).catch(($, e, next) => next(e))
406
407 /* ----------------------------------------------------------------------- *
408 * Drawing
409 * ----------------------------------------------------------------------- */
410
411 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
412 if (e.props.hasSurvey) return next(e)
413 const state = await load($)
414 if (state.band === null || !state.bandRequested) return next(e)
415 const actions: BandActions = {
416 inspect: (id) => {
417 later(change($, mode, (s) => ({ ...s, section: 'session', openEntry: id, inspectSection: true })).then(() => openPane($)))
418 },
419 dismiss: () => {
420 later(change($, mode, (s) => ({ ...s, band: null, bandRequested: false })))
421 },
422 summon: (name) => {
423 later(fillPrompt($, `/summon ${name}`))
424 },
425 }
426 const tree = renderBand($.ui.resolve(e), state, actions, e.props.bodyColumns)
427 return tree ?? next(e)
428 })
429
430 on('ui.render', { component: 'Pane', requestId: 'skill-heaven' }, async ($, e) => {
431 const state = await load($)
432 const actions: PaneActions = {
433 inspect: () => { later(change($, mode, (s) => ({ ...s, inspectSection: !s.inspectSection, openEntry: null }))) },
434 close: () => { later($.ui.close({ id: PANE_ID })) },
435 section: (section) => {
436 later(change($, mode, (s) => ({ ...s, section, inspectSection: false, openEntry: null })))
437 },
438 toggle: (id) => {
439 later(change($, mode, (s) => ({ ...s, openEntry: s.openEntry === id ? null : id })))
440 },
441 fill: (text) => {
442 later(fillPrompt($, text))
443 },
444 copy: (text) => {
445 later(copyText($, text, e.surface))
446 },
447 }
448 return renderPane($.ui.resolve(e), state, actions, e.props.bodyColumns)
449 })
450}
451hooks/status-model.mjs 1883 lines1// GENERATED by scripts/build-status.mjs from packages/status/src — do not edit.
2// One status model for every projection (docs/CONTROL-PLANE.md).
3// packages/status/src/model.ts
4var RUNGS = ["zero", "low", "med", "high", "xhigh", "max", "ultra"];
5var RUNG_BAND = Object.freeze({
6 zero: "zero",
7 low: "heaven",
8 med: "heaven",
9 high: "hell",
10 xhigh: "hell",
11 max: "hell",
12 ultra: "ultra"
13});
14function bandOf(rung) {
15 return RUNG_BAND[rung];
16}
17function readingRung(reading) {
18 if (reading.kind === "selected") return reading.rung;
19 if (reading.kind === "boot" && reading.posture === "product-floor") return "zero";
20 return null;
21}
22function isRung(value) {
23 return typeof value === "string" && RUNGS.includes(value);
24}
25function emptyStatus() {
26 return {
27 reading: { kind: "unknown" },
28 skills: null,
29 summons: null,
30 lastArrival: null,
31 controller: { kind: "not-selected" },
32 summonTool: "unknown"
33 };
34}
35
36// packages/status/src/sanitize.ts
37var ANSI = /\u001b(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007\u001b]*(?:\u0007|\u001b\\)|[@-Z\\-_])/g;
38var CONTROLS = /[\u0000-\u001f\u007f-\u009f]/g;
39var BIDI = /[--]/g;
40var RESERVED = /* @__PURE__ */ new Map([
41 ["\u25C7", "*"],
42 ["\u25C6", "*"],
43 ["\u2039", "<"],
44 ["\u203A", ">"],
45 ["\xD7", "x"]
46]);
47var DEFAULT_FIELD_LIMIT = 48;
48function sanitizeDisplay(value, limit = DEFAULT_FIELD_LIMIT) {
49 if (value === null || value === void 0) return "";
50 let text = String(value).replace(ANSI, "").replace(BIDI, "").replace(CONTROLS, " ");
51 let out = "";
52 for (const ch of text) out += RESERVED.get(ch) ?? ch;
53 text = out.replace(/\s+/g, " ").trim();
54 const chars = Array.from(text);
55 if (limit > 0 && chars.length > limit) return chars.slice(0, Math.max(1, limit - 1)).join("") + "\u2026";
56 return text;
57}
58function cellWidth(text) {
59 let width = 0;
60 for (const ch of text) {
61 const code = ch.codePointAt(0) ?? 0;
62 width += isWide(code) ? 2 : 1;
63 }
64 return width;
65}
66function isWide(code) {
67 return code >= 4352 && code <= 4447 || code >= 11904 && code <= 42191 || code >= 44032 && code <= 55203 || code >= 63744 && code <= 64255 || code >= 65072 && code <= 65103 || code >= 65280 && code <= 65376 || code >= 65504 && code <= 65510 || code >= 127744 && code <= 129791 || code >= 131072 && code <= 262141;
68}
69
70// packages/status/src/tokens.ts
71var ROLE_COLORS = Object.freeze({
72 umbrella: { hex: "#a58ae0", ansi256: 141, ansi16: 35, cssVar: "--sh-violet" },
73 ultra: { hex: "#d9b25c", ansi256: 179, ansi16: 33, cssVar: "--sh-ultra" },
74 zero: { hex: "#5fc2d6", ansi256: 80, ansi16: 36, cssVar: "--sh-zero" },
75 heaven: { hex: "#6f96d8", ansi256: 68, ansi16: 34, cssVar: "--sh-heaven" },
76 hell: { hex: "#e094c8", ansi256: 175, ansi16: 95, cssVar: "--sh-hell" },
77 ink: { hex: "#eeebe6", ansi256: 255, ansi16: 39, cssVar: "--sh-bone" },
78 dim: { hex: "#9a9691", ansi256: 246, ansi16: 90, cssVar: "--sh-dim" },
79 arbor: { hex: "#55c878", ansi256: 77, ansi16: 32, cssVar: "--sh-arbor" },
80 stop: { hex: "#c81e1e", ansi256: 160, ansi16: 31, cssVar: "--sh-stop" },
81 amber: { hex: "#e0b45c", ansi256: 179, ansi16: 33, cssVar: "--sh-amber" }
82});
83var GROUND_HEX = "#1b1a1c";
84
85// packages/status/src/render.ts
86var SEP = { text: " \xB7 ", role: "dim" };
87var seg = (text, role) => ({ text, role });
88function readingToken(reading) {
89 switch (reading.kind) {
90 case "selected":
91 return reading.rung.toUpperCase();
92 case "boot":
93 return reading.posture === "product-floor" ? "ZERO" : reading.posture === "curated" ? "CURATED" : "NATIVE";
94 case "native":
95 return "NATIVE";
96 case "unknown":
97 return "?";
98 }
99}
100function readingRole(reading) {
101 const rung = readingRung(reading);
102 if (!rung) return "ink";
103 const band = RUNG_BAND[rung];
104 return band === "zero" ? "zero" : band === "heaven" ? "heaven" : band === "hell" ? "hell" : "ultra";
105}
106function isUltra(status) {
107 return readingRung(status.reading) === "ultra";
108}
109function skillsText(n, short) {
110 if (n === null) return short ? "?" : "? skills";
111 if (short) return String(n);
112 return `${n} ${n === 1 ? "skill" : "skills"}`;
113}
114function readingSegments(status) {
115 return [
116 seg("\u2039\u2039", "heaven"),
117 seg(" ", "dim"),
118 seg(`[${readingToken(status.reading)}]`, readingRole(status.reading)),
119 seg(" ", "dim"),
120 seg("\u203A\u203A", "hell")
121 ];
122}
123function headSegments(status, withWord) {
124 const ultra = isUltra(status);
125 const out = [];
126 if (status.fixture || status.controller.kind === "fixture") out.push(seg("FIXTURE", "amber"), seg(" ", "dim"));
127 out.push(seg(ultra ? "\u25C6" : "\u25C7", ultra ? "ultra" : "umbrella"));
128 if (withWord) out.push(seg(" entropy", "umbrella"));
129 out.push(seg(" ", "dim"), ...readingSegments(status));
130 return out;
131}
132function controllerSegments(controller, opts = { progress: true }) {
133 switch (controller.kind) {
134 case "not-selected":
135 return [];
136 case "unavailable":
137 return [SEP, seg("controller unavailable", "dim")];
138 case "reported":
139 case "fixture": {
140 const out = [SEP, seg(sanitizeDisplay(controller.state, 24).toUpperCase(), "ultra")];
141 if (controller.effective) {
142 const band = RUNG_BAND[controller.effective];
143 const role = band === "heaven" ? "heaven" : "hell";
144 out.push(SEP, seg("now ", "dim"), seg(controller.effective.toUpperCase(), role), seg(band === "heaven" ? " \u2039" : " \u203A", role));
145 }
146 if (opts.progress && controller.progress) {
147 out.push(SEP, seg(`${controller.progress.completed}/${controller.progress.total}`, "ink"));
148 }
149 return out;
150 }
151 }
152}
153function statusLevels(status, mode) {
154 if (mode === "off") return [];
155 const ultra = isUltra(status);
156 const controller = ultra ? status.controller : { kind: "not-selected" };
157 const skills = [SEP, seg(skillsText(status.skills, false), "ink")];
158 const summons = status.summons === null ? [] : [seg(" / ", "dim"), seg(`${status.summons} ${status.summons === 1 ? "summon" : "summons"}`, "dim")];
159 const arrival = status.lastArrival ? [SEP, seg(`+${sanitizeDisplay(status.lastArrival, 32)}`, "ink")] : [];
160 const full = [
161 [...headSegments(status, true), ...skills, ...summons, ...controllerSegments(controller), ...arrival],
162 [...headSegments(status, true), ...skills, ...summons, ...controllerSegments(controller)],
163 [...headSegments(status, true), ...skills, ...controllerSegments(controller)],
164 [...headSegments(status, true), ...skills, ...controllerSegments(controller, { progress: false })]
165 ];
166 const compact = [
167 [...headSegments(status, true), ...skills],
168 [...headSegments(status, false), SEP, seg(skillsText(status.skills, true), "ink")],
169 [...headSegments(status, false)]
170 ];
171 const bare = [];
172 if (status.fixture || status.controller.kind === "fixture") bare.push(seg("FIXTURE", "amber"), seg(" ", "dim"));
173 bare.push(seg(`[${readingToken(status.reading)}]`, readingRole(status.reading)));
174 return mode === "full" ? [...full, ...compact, bare] : [...compact, bare];
175}
176function segmentsWidth(segments) {
177 return segments.reduce((sum, s) => sum + cellWidth(s.text), 0);
178}
179function renderStatusSegments(status, mode, width) {
180 const levels = statusLevels(status, mode);
181 if (levels.length === 0) return [];
182 if (width === void 0 || !Number.isFinite(width)) return levels[0];
183 return levels.find((level) => segmentsWidth(level) <= width) ?? levels[levels.length - 1];
184}
185function directionGlyph(direction) {
186 if (direction === "converge") return seg("\u2039", "heaven");
187 if (direction === "explore") return seg("\u203A", "hell");
188 return seg("\u25C7", "umbrella");
189}
190function formatScore(value) {
191 if (value === null || !Number.isFinite(value)) return null;
192 const clamped = Math.max(0, Math.min(1, value));
193 return clamped >= 1 ? "1.00" : clamped.toFixed(2).replace(/^0/, "");
194}
195function formatMs(ms) {
196 if (ms === null || !Number.isFinite(ms) || ms < 0) return null;
197 return ms < 1e3 ? `${Math.round(ms)}ms` : `${(ms / 1e3).toFixed(2)}s`;
198}
199var CLOSE_CALL_MARGIN = 0.1;
200function receiptDetail(skill, delta) {
201 const parts = [];
202 if (skill.matchKind !== "unknown") parts.push(skill.matchKind);
203 const score = formatScore(skill.score);
204 if (score) parts.push(score);
205 const margin = formatScore(skill.margin);
206 if (margin) parts.push(`\u0394 ${margin}`);
207 if (skill.cache !== "unknown") parts.push(skill.cache);
208 const ms = formatMs(skill.ms);
209 if (ms) parts.push(ms);
210 if (delta !== null) parts.push(`+${delta}`);
211 return [seg(" ", "dim"), seg(parts.join(" \xB7 ") || "no ranking disclosure", "dim")];
212}
213function eventLines(event) {
214 const lines = eventLinesInner(event);
215 if (event.evidence === "fixture" && lines[0]) lines[0] = [seg("FIXTURE", "amber"), seg(" ", "dim"), ...lines[0]];
216 return lines;
217}
218function eventLinesInner(event) {
219 switch (event.kind) {
220 case "summoned": {
221 const [first, ...rest] = event.skills;
222 const line1 = [directionGlyph(event.direction), seg(" summoned ", "dim")];
223 line1.push(seg(first ? sanitizeDisplay(first.name, 40) : "nothing", "ink"));
224 if (rest.length > 0) line1.push(seg(` +${rest.length} more`, "dim"));
225 const line2 = first ? receiptDetail(first, event.delta) : [seg(" ", "dim"), seg("no skill in result", "dim")];
226 if (event.sourceHealth.kind === "stale") line2.push(SEP, seg("? index stale", "amber"));
227 return [line1, line2];
228 }
229 case "previewed": {
230 const [first] = event.skills;
231 const line1 = [seg("\u25C7", "umbrella"), seg(" lens ", "dim")];
232 if (event.skills.length === 1 && first) line1.push(seg(sanitizeDisplay(first.name, 40), "ink"));
233 else line1.push(seg(`${event.skills.length} candidates`, "ink"));
234 const parts = [seg(" ", "dim"), seg("nothing materialized", "dim")];
235 if (first && event.skills.length > 1) parts.push(SEP, seg(`top ${sanitizeDisplay(first.name, 32)}`, "dim"));
236 if (first?.margin !== null && first?.margin !== void 0 && first.margin < CLOSE_CALL_MARGIN && event.skills.length > 1) {
237 parts.push(SEP, seg(`\u0394 ${formatScore(first.margin)} close call (retrieval)`, "dim"));
238 }
239 return [line1, parts];
240 }
241 case "no-match": {
242 const detail = event.considered === null ? "0 admitted" : `${event.considered} considered \xB7 0 admitted`;
243 const reason = event.reason ? ` \xB7 ${sanitizeDisplay(event.reason, 60)}` : "";
244 const tail = event.preview ? " \xB7 nothing materialized" : "";
245 return [
246 [seg("\u25C7", "umbrella"), seg(event.preview ? " lens " : " summon ", "dim"), seg("\xD7", "ink"), seg(" no match", "ink")],
247 [seg(" ", "dim"), seg(detail + reason + tail, "dim")]
248 ];
249 }
250 case "unavailable":
251 return [
252 [seg("\u25C7", "umbrella"), seg(" summon ", "dim"), seg("?", "amber"), seg(" unavailable", "ink")],
253 [seg(" ", "dim"), seg(sanitizeDisplay(event.reason, 72), "dim")]
254 ];
255 case "error":
256 return [
257 [seg("\u25C7", "umbrella"), seg(" summon ", "dim"), seg("!", "stop"), seg(" failed", "ink")],
258 [seg(" ", "dim"), seg(sanitizeDisplay(event.reason, 72), "dim")]
259 ];
260 }
261}
262function noticeLines(notice) {
263 if (notice.kind === "looking") {
264 return [
265 [seg("\u25C7", "umbrella"), seg(" lens ", "dim"), seg("looking\u2026", "ink")],
266 [seg(" ", "dim"), seg(`${sanitizeDisplay(notice.query, 48)} \xB7 nothing materialized`, "dim")]
267 ];
268 }
269 return [
270 [seg("\u25C7", "umbrella"), seg(" summon ", "dim"), seg("?", "amber"), seg(" not connected", "ink")],
271 [seg(" ", "dim"), seg("the summon tool is not available in this session", "dim")]
272 ];
273}
274function describeReading(reading) {
275 switch (reading.kind) {
276 case "selected":
277 return `${reading.rung}, the rung you selected (not enforced)`;
278 case "boot":
279 return reading.posture === "product-floor" ? "zero, the Skill Zero floor set at launch" : reading.posture === "curated" ? "curated, set at launch" : "native, your harness's own skills";
280 case "native":
281 return "native, your harness's own skills";
282 case "unknown":
283 return "unknown";
284 }
285}
286function describeStatus(status) {
287 const parts = [`Skill entropy reading: ${describeReading(status.reading)}.`];
288 parts.push(
289 status.skills === null ? "Skills in this session: unknown." : `${status.skills} ${status.skills === 1 ? "skill" : "skills"} materialized in this session.`
290 );
291 if (isUltra(status)) {
292 const c = status.controller;
293 if (c.kind === "unavailable") parts.push("Ultra controller: unavailable; nothing is choosing for you yet.");
294 else if (c.kind === "reported" || c.kind === "fixture") {
295 parts.push(`Ultra controller: ${sanitizeDisplay(c.state, 24).toLowerCase()}${c.effective ? `, working at ${c.effective}` : ""}.`);
296 }
297 }
298 if (status.fixture || status.controller.kind === "fixture") parts.unshift("Fixture, design state only.");
299 return parts.join(" ");
300}
301function describeEvent(event) {
302 const text = describeEventInner(event);
303 return event.evidence === "fixture" ? `Fixture, design state only. ${text}` : text;
304}
305function describeEventInner(event) {
306 const how = event.direction === "converge" ? "converging" : event.direction === "explore" ? "exploring" : event.direction === "manual" ? "by hand" : "";
307 switch (event.kind) {
308 case "summoned": {
309 const names = event.skills.map((s) => sanitizeDisplay(s.name, 40)).join(", ") || "nothing";
310 return `Summoned ${names}${how ? `, ${how}` : ""}. A card was returned; ${event.delta} added to the session.`;
311 }
312 case "previewed":
313 return `Lens preview: ${event.skills.length} candidate${event.skills.length === 1 ? "" : "s"}; nothing materialized.`;
314 case "no-match":
315 return event.preview ? "Lens preview found no match. Nothing was materialized." : "Summon found no match. Nothing was added to the session.";
316 case "unavailable":
317 return `Summon unavailable: ${sanitizeDisplay(event.reason, 72)}.`;
318 case "error":
319 return `Summon failed: ${sanitizeDisplay(event.reason, 72)}.`;
320 }
321}
322function resolveColorDepth(env, isTTY = true) {
323 if (env.NO_COLOR !== void 0 && env.NO_COLOR !== "") return "none";
324 if (!isTTY && env.FORCE_COLOR === void 0) return "none";
325 const term = env.TERM ?? "";
326 if (term === "dumb") return "none";
327 const colorterm = (env.COLORTERM ?? "").toLowerCase();
328 if (colorterm === "truecolor" || colorterm === "24bit") return "truecolor";
329 if (term.includes("256")) return "256";
330 return "16";
331}
332function sgr(role, depth) {
333 const c = ROLE_COLORS[role];
334 if (depth === "truecolor") {
335 const n = parseInt(c.hex.slice(1), 16);
336 return `\x1B[38;2;${n >> 16 & 255};${n >> 8 & 255};${n & 255}m`;
337 }
338 if (depth === "256") return `\x1B[38;5;${c.ansi256}m`;
339 return `\x1B[${c.ansi16}m`;
340}
341function paintAnsi(segments, depth) {
342 if (depth === "none") return toPlain(segments);
343 return segments.map((s) => s.role === "dim" && s.text.trim() === "" ? s.text : `${sgr(s.role, depth)}${s.text}\x1B[39m`).join("");
344}
345function toPlain(segments) {
346 return segments.map((s) => s.text).join("");
347}
348
349// packages/status/src/adapters.ts
350var isRec = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
351var str = (v) => typeof v === "string" && v.length > 0 ? v : null;
352var num = (v) => typeof v === "number" && Number.isFinite(v) ? v : null;
353function readingFromProfileManifest(manifest) {
354 if (!isRec(manifest) || manifest.schema !== "claude-zero/profile@1") return { kind: "unknown" };
355 const posture = manifest.posture;
356 if (posture === "product-floor" || posture === "curated" || posture === "native") {
357 return { kind: "boot", posture, source: "launcher-manifest" };
358 }
359 return { kind: "unknown" };
360}
361var BAND_COMMANDS = [
362 { command: "skill-zero", rungs: ["zero"], fallback: "zero" },
363 { command: "skill-heaven", rungs: ["low", "med"], fallback: "low" },
364 { command: "skill-hell", rungs: ["high", "xhigh", "max"], fallback: "high" },
365 { command: "skill-ultra", rungs: ["ultra"], fallback: "ultra" }
366];
367function selectionFromCommand(text) {
368 const match = /^\s*\/(?:[a-z0-9-]+:)?(skill-zero|skill-heaven|skill-hell|skill-ultra)(?:\s+(\S+))?\s*$/i.exec(text);
369 if (!match) return null;
370 const entry = BAND_COMMANDS.find((b) => b.command === match[1].toLowerCase());
371 const arg = match[2]?.toLowerCase();
372 if (!arg) return { kind: "selected", rung: entry.fallback, source: "observed-command" };
373 if (entry.command === "skill-zero") return arg === "all" ? { kind: "selected", rung: "zero", source: "observed-command" } : null;
374 if (isRung(arg) && entry.rungs.includes(arg)) return { kind: "selected", rung: arg, source: "observed-command" };
375 return null;
376}
377function withReading(status, reading) {
378 const ultra = reading.kind === "selected" && reading.rung === "ultra";
379 const boot = status.boot ?? (status.reading.kind === "selected" || status.reading.kind === "unknown" ? void 0 : status.reading);
380 const controller = ultra ? status.controller.kind === "reported" ? status.controller : { kind: "unavailable" } : { kind: "not-selected" };
381 return { ...status, reading, controller, ...boot ? { boot } : {} };
382}
383function skillsFromSessionManifest(manifest) {
384 if (!isRec(manifest) || !Array.isArray(manifest.skills)) return { skills: null, last: null };
385 const entries = manifest.skills.filter((s) => isRec(s) && typeof s.id === "string");
386 if (entries.length !== manifest.skills.length) return { skills: null, last: null };
387 const last = entries.length > 0 ? entries[entries.length - 1] : null;
388 return { skills: entries.length, last: last ? str(last.name) ?? str(last.id) : null };
389}
390function directionFromSurface(surface) {
391 if (surface === "any") return "manual";
392 if (surface === "heaven") return "converge";
393 if (surface === "hell") return "explore";
394 return "unspecified";
395}
396function laneOf(skill) {
397 if (skill.invocation === "human") return "human-led";
398 if (skill.invocation === "model") return "model-led";
399 if (skill.invocation === "any") return "unspecified";
400 return "unknown";
401}
402function receiptFrom(skill, stage, agent) {
403 const retrieval = isRec(skill.retrieval) ? skill.retrieval : {};
404 const matchKind = retrieval.matchKind === "exact" || retrieval.matchKind === "ranked" ? retrieval.matchKind : "unknown";
405 const cacheRaw = skill.cacheState ?? skill.cache;
406 const totalSeconds = num(skill.totalSeconds);
407 const installability = isRec(skill.installability) ? str(skill.installability.state) ?? "unknown" : "unknown";
408 return {
409 id: str(skill.id) ?? "unknown",
410 name: str(skill.name) ?? str(skill.id) ?? "unknown",
411 stage,
412 matchKind,
413 score: num(retrieval.score) ?? num(skill.score),
414 margin: num(retrieval.margin) ?? num(skill.margin),
415 cache: cacheRaw === "cold" || cacheRaw === "warm" ? cacheRaw : "unknown",
416 ms: totalSeconds === null ? null : Math.round(totalSeconds * 1e3),
417 lane: laneOf(skill),
418 source: str(skill.source),
419 repoUrl: str(skill.repoUrl),
420 ref: str(skill.branch),
421 sourceUrl: str(skill.sourceUrl),
422 subpath: str(skill.subpath),
423 sha256: str(skill.sha256),
424 path: str(skill.path),
425 installability,
426 agent
427 };
428}
429function sourceHealthOf(result) {
430 const ranking = isRec(result.ranking) ? result.ranking : null;
431 if (!ranking || typeof ranking.stale !== "boolean") return { kind: "unknown" };
432 const age = num(ranking.indexAgeDays);
433 const indexAgeDays = age === null ? null : Math.floor(age);
434 return ranking.stale ? { kind: "stale", indexAgeDays } : { kind: "fresh", indexAgeDays };
435}
436function arborOf(result, summoned) {
437 const arbor = isRec(result.arbor) ? result.arbor : null;
438 if (!arbor) return "unknown";
439 if (arbor.publicationState === "unavailable" || arbor.publicationState === "unreadable") return "unavailable";
440 if (arbor.publicationState !== "loaded") return "unknown";
441 return summoned.some((s) => isRec(s.arbor) && s.arbor.join === "content-pinned") ? "governed-record" : "no-record";
442}
443var NO_MATCH_REASON = {
444 no_candidates: "no candidates in the source",
445 below_floor: "nothing cleared the relevance floor",
446 all_filtered: "every candidate was outside this lane"
447};
448function eventFromSummonResult(structured, call = {}, failure) {
449 const at = call.at ?? null;
450 const agent = call.agent ?? null;
451 if (failure?.isError) {
452 const text = failure.text ?? "the summon tool reported an error";
453 const unavailable = /unresolvable|unreachable|ENOTFOUND|EAI_AGAIN|fetch failed|network|offline/i.test(text);
454 return {
455 kind: unavailable ? "unavailable" : "error",
456 direction: "unspecified",
457 query: call.query ?? "",
458 preview: call.preview === true,
459 reason: text,
460 at,
461 evidence: "observed"
462 };
463 }
464 if (!isRec(structured)) {
465 return {
466 kind: "error",
467 direction: "unspecified",
468 query: call.query ?? "",
469 preview: call.preview === true,
470 reason: "the summon result had no structured content",
471 at,
472 evidence: "observed"
473 };
474 }
475 const direction = directionFromSurface(structured.surface);
476 const query = str(structured.query) ?? call.query ?? "";
477 const sourceHealth = sourceHealthOf(structured);
478 if (structured.noMatch !== null && structured.noMatch !== void 0) {
479 const noMatch = isRec(structured.noMatch) ? structured.noMatch : {};
480 const reason = typeof noMatch.reason === "string" ? NO_MATCH_REASON[noMatch.reason] ?? null : null;
481 return { kind: "no-match", direction, query, preview: call.preview === true, considered: null, reason, at, evidence: "reported", sourceHealth };
482 }
483 const summoned = Array.isArray(structured.summoned) ? structured.summoned.filter(isRec) : [];
484 const previewed = Array.isArray(structured.previewed) ? structured.previewed.filter(isRec) : [];
485 if (summoned.length === 0 && (previewed.length > 0 || call.preview === true)) {
486 return {
487 kind: "previewed",
488 direction,
489 query,
490 skills: previewed.map((s) => receiptFrom(s, "previewed", agent)),
491 delta: 0,
492 preview: true,
493 at,
494 evidence: "reported",
495 sourceHealth
496 };
497 }
498 const skipped = Array.isArray(structured.skipped) ? structured.skipped : [];
499 if (summoned.length === 0 && skipped.length > 0) {
500 const first = skipped[0];
501 const why = isRec(first) ? str(first.why) ?? str(first.reason) ?? str(first.error) : str(first);
502 return {
503 kind: "error",
504 direction,
505 query,
506 preview: call.preview === true,
507 reason: why ? `nothing materialized: ${why}` : "nothing materialized: every candidate was skipped",
508 at,
509 evidence: "reported"
510 };
511 }
512 const composition = isRec(structured.composition) && structured.composition.mode === "relevance-only" ? "relevance-only" : "unknown";
513 return {
514 kind: "summoned",
515 direction,
516 query,
517 skills: summoned.map((s) => receiptFrom(s, "materialized", agent)),
518 delta: summoned.length,
519 preview: false,
520 at,
521 evidence: "reported",
522 composition,
523 arbor: arborOf(structured, summoned),
524 sourceHealth
525 };
526}
527function reduceStatus(status, event) {
528 if (event.kind === "previewed" || event.kind !== "summoned" && event.preview) return status;
529 const summons = status.summons === null ? null : status.summons + 1;
530 if (event.kind !== "summoned") return { ...status, summons };
531 const skills = status.skills === null ? null : status.skills + event.delta;
532 const last = event.skills[event.skills.length - 1];
533 return { ...status, skills, summons, lastArrival: last ? last.name : status.lastArrival };
534}
535function markRead(event, readPath, stage = "in-context") {
536 if (event.kind !== "summoned") return event;
537 const norm = readPath.replace(/\\/g, "/");
538 let changed = false;
539 const skills = event.skills.map((s) => {
540 if (!s.path || s.stage === "in-context" || s.stage === stage) return s;
541 let root = s.path.replace(/\\/g, "/");
542 while (root.endsWith("/")) root = root.slice(0, -1);
543 if (norm === `${root}/SKILL.md`) {
544 changed = true;
545 return { ...s, stage };
546 }
547 return s;
548 });
549 return changed ? { ...event, skills } : event;
550}
551function eventsFromLedger(manifest, logLines) {
552 const records = /* @__PURE__ */ new Map();
553 if (isRec(manifest) && Array.isArray(manifest.skills)) {
554 for (const s of manifest.skills) if (isRec(s) && typeof s.id === "string") records.set(s.id, s);
555 }
556 const events = [];
557 for (const line of logLines) {
558 if (!isRec(line)) continue;
559 const at = str(line.at);
560 const query = str(line.query) ?? "";
561 const direction = directionFromSurface(line.surface);
562 const preview = line.preview === true;
563 const noMatch = str(line.noMatch);
564 const sourceHealth = { kind: "unknown" };
565 if (noMatch !== null) {
566 events.push({
567 kind: "no-match",
568 direction,
569 query,
570 preview,
571 considered: null,
572 reason: NO_MATCH_REASON[noMatch] ?? null,
573 at,
574 evidence: "reported",
575 sourceHealth
576 });
577 continue;
578 }
579 const chosen = Array.isArray(line.chosen) ? line.chosen.filter(isRec) : [];
580 if (preview) {
581 events.push({
582 kind: "previewed",
583 direction,
584 query,
585 skills: chosen.map(
586 (c) => receiptFrom(
587 { id: c.id, name: c.id, retrieval: { matchKind: c.matchKind, score: c.score, margin: c.margin } },
588 "previewed",
589 null
590 )
591 ),
592 delta: 0,
593 preview: true,
594 at,
595 evidence: "reported",
596 sourceHealth
597 });
598 continue;
599 }
600 const skills = chosen.map((c) => {
601 const record = typeof c.id === "string" ? records.get(c.id) : void 0;
602 return receiptFrom(
603 record ?? { id: c.id, name: c.id, retrieval: { matchKind: c.matchKind, score: c.score, margin: c.margin } },
604 "read-unobserved",
605 null
606 );
607 });
608 events.push({
609 kind: "summoned",
610 direction,
611 query,
612 skills,
613 delta: skills.length,
614 preview: false,
615 at,
616 evidence: "reported",
617 composition: "unknown",
618 arbor: "unknown",
619 sourceHealth
620 });
621 }
622 return events;
623}
624var STEERING_DECISIONS = {
625 hold: "HOLD",
626 explore: "EXPLORE",
627 recover: "RECOVER",
628 reopen: "REOPEN",
629 checkpoint: "CHECKPOINT",
630 close: "CLOSE",
631 stop: "STOP"
632};
633function controllerFromSteeringEntry(entry) {
634 if (!isRec(entry) || typeof entry.decision !== "string") return null;
635 const state = STEERING_DECISIONS[entry.decision];
636 if (!state) return null;
637 const to = isRec(entry.to) ? entry.to : null;
638 const rung = to && isRung(to.rung) && to.rung !== "zero" && to.rung !== "ultra" ? to.rung : void 0;
639 const from = isRec(entry.from) && typeof entry.from.rung === "string" ? entry.from.rung : null;
640 const explanation = str(entry.explanation);
641 return {
642 kind: "reported",
643 source: "steering-trace",
644 state,
645 ...rung ? { effective: rung } : {},
646 ...from && explanation && entry.changed === true ? { transition: { from: from.toUpperCase(), to: state, reason: explanation } } : {}
647 };
648}
649var PROPOSED_CONTROLLER_SCHEMA = "skill-heaven/controller-status@0";
650function controllerFromCampaignStatus(value) {
651 if (!isRec(value) || value.schema !== PROPOSED_CONTROLLER_SCHEMA) return null;
652 const allowed = /* @__PURE__ */ new Set(["schema", "state", "effective", "progress", "transition"]);
653 if (Object.keys(value).some((k) => !allowed.has(k))) return null;
654 if (typeof value.state !== "string" || !/^[A-Z][A-Z0-9 ·_-]{0,31}$/.test(value.state)) return null;
655 const out = { kind: "reported", source: "campaign", state: value.state };
656 if (value.effective !== void 0) {
657 if (!isRung(value.effective) || value.effective === "zero" || value.effective === "ultra") return null;
658 out.effective = value.effective;
659 }
660 if (value.progress !== void 0) {
661 const p = value.progress;
662 if (!isRec(p) || !Number.isInteger(p.completed) || !Number.isInteger(p.total)) return null;
663 const completed = p.completed;
664 const total = p.total;
665 if (completed < 0 || total < 1 || completed > total) return null;
666 out.progress = { completed, total };
667 }
668 if (value.transition !== void 0) {
669 const t = value.transition;
670 if (!isRec(t) || typeof t.from !== "string" || typeof t.to !== "string" || typeof t.reason !== "string") return null;
671 out.transition = { from: t.from, to: t.to, reason: t.reason };
672 }
673 return out;
674}
675
676// packages/status/src/compat-console.ts
677var step = (argv, run, effect) => ({ where: "shell", argv, run, effect });
678var piece = (register, update, remove) => ({ register, update, remove });
679var degraded = (via, note) => ({ level: "degraded", via, note });
680var ROOT = "https://github.com/gaia-research/gaia-skill-heaven/blob/main";
681function adapterPath(id) {
682 const pi = id === "pi";
683 const hermes = id === "hermes";
684 const agy = id === "agy";
685 const versions = { pi: "1.1.0", codex: "0.161.0", hermes: "0.20.0", grok: "1.0.46", agy: "1.3.1" };
686 const register = (console2) => {
687 const dir = console2 ? "{{CONSOLE_DIR}}" : "{{PLUGIN_DIR}}";
688 const name = console2 ? "skill-heaven-console" : "skill-heaven";
689 if (pi) return [step(["pi", "install", dir, "--approve"], `pi install "${dir}" --approve`, `registers only ${name} as a Pi package`)];
690 if (id === "codex") return [
691 ...console2 ? [] : [step(["codex", "plugin", "marketplace", "add", "{{MARKETPLACE_DIR}}"], 'codex plugin marketplace add "{{MARKETPLACE_DIR}}"', "registers the staged marketplace")],
692 step(["codex", "plugin", "add", `${name}@gaia-skill-heaven`], `codex plugin add ${name}@gaia-skill-heaven`, `registers only ${name}`)
693 ];
694 if (hermes) return [step(["hermes", "plugins", "install", `file://${dir}`, "--enable"], `hermes plugins install "file://${dir}" --enable`, `registers ${name}; staging MUST supply an independent Git root (Hermes clones Git sources)`)];
695 if (id === "grok") return [step(["grok", "plugin", "install", dir, "--trust"], `grok plugin install "${dir}" --trust`, `registers only ${name}`)];
696 return [step(["agy", "plugin", "install", dir], `agy plugin install "${dir}"`, `registers only ${name}; real HOME required`)];
697 };
698 const remove = (console2) => {
699 const name = console2 ? "skill-heaven-console" : "skill-heaven";
700 const dir = console2 ? "{{CONSOLE_DIR}}" : "{{PLUGIN_DIR}}";
701 if (pi) return [step(["pi", "remove", dir], `pi remove "${dir}"`, `removes only ${name}`)];
702 if (id === "codex") return [step(["codex", "plugin", "remove", `${name}@gaia-skill-heaven`], `codex plugin remove ${name}@gaia-skill-heaven`, `removes only ${name}`)];
703 if (hermes) return [
704 step(["hermes", "plugins", "disable", name], `hermes plugins disable ${name}`, `disables only ${name}; preserves the host-owned deny-list`),
705 step(["hermes", "plugins", "remove", name], `hermes plugins remove ${name}`, `removes only ${name}'s cached plugin directory`)
706 ];
707 if (agy) return [{ ...step(["agy", "plugin", "uninstall", name], `agy plugin uninstall ${name}`, `uninstalls only ${name}; real HOME preserved`), stdin: "y\n" }];
708 return [step(["grok", "plugin", "uninstall", name], `grok plugin uninstall ${name}`, `removes only ${name}`)];
709 };
710 const update = (console2) => {
711 if (pi) return [];
712 if (hermes) {
713 const steps = register(console2);
714 return steps.map((s) => ({ ...s, argv: [...s.argv, "--force"], run: s.run + " --force", effect: s.effect + "; replaces this cached copy" }));
715 }
716 if (agy) return register(console2);
717 if (id === "codex") return [...remove(console2), ...register(console2)];
718 return [...remove(console2), ...register(console2)];
719 };
720 const command = agy ? "/skill-heaven-console:heaven" : "/heaven";
721 const report = pi ? "ctx.ui.custom explicit pane (Pi 1.1+); compact owned status" : hermes ? "native register_command /heaven report" : "explicit console skill/command (model-mediated)";
722 const console = {
723 kind: pi ? "extension-ui" : "command-backed",
724 mechanism: pi ? "Separate Pi 1.1+ extension: one compact owned status line and explicit, bounded ctx.ui.custom pane; Escape/q dismiss. Diagnostics require inspect. /lens drafts a preview handoff; /heaven fill prefills only, a human submits through normal tool approval." : `${agy ? "Provisional Console runtime: installed-carrier invocation and native Core preview/session binding are unverified (#206). " : ""}${report}; one canonical renderConsoleText report, no fake HUD or status configuration rewrite.`,
725 command,
726 commandPrefix: agy ? "skill-heaven:" : "",
727 surfaces: {
728 status: pi ? { level: "native", via: "ctx.ui.setStatus(skill-heaven-console)", note: "Appends an owned entry; does not replace the footer." } : degraded(report, "Report only, not a persistent status contribution."),
729 lens: degraded(pi ? "/lens + /heaven fill" : hermes ? "/lens (printed draft)" : `${command} lens`, pi || hermes ? "Draft only: no tool call, retrieval or materialization until a human submits the handoff through normal host tool approval. Observed preview results use the same shared model." : "Explicit model-mediated preview:true on the existing Core tool; printed handoff, no automatic tool call."),
730 session: degraded(report, "Bounded receipt window. Exact session binding required; no newest-directory guess."),
731 scope: degraded(report, "Printed controls, not enforcement. Ultra controller remains unavailable."),
732 flow: { level: "unsupported", via: report, note: "No implemented, empirically pinned agent-id attribution. Summons attributed to main; no invented agents." },
733 trust: degraded(report, "Lists capabilities and limits; does not rate them.")
734 },
735 observes: { summon: pi ? "observed" : "reported", read: pi ? "observed" : "unavailable", agents: "unavailable", rung: pi ? "observed" : "unavailable" },
736 summonTools: pi ? ["summon"] : agy ? ["skill-heaven_skill-summon/summon"] : id === "codex" ? ["mcp__skill-summon__summon"] : [],
737 trust: [
738 { id: "skill-heaven", profile: "core", kind: "harness runtime package", version: "0.1.2", summary: "Five entropy surfaces and the bundled summon engine.", reads: ["configured skill source"], writes: ["disposable engine session directory"], network: "Core fetches the configured skill source", disable: remove(false)[0].run },
739 { id: "skill-heaven-console", profile: "full", kind: pi ? "Pi extension package" : hermes ? "Hermes native Python plugin + Node painter" : "command/skill plugin + Node report", version: "0.1.0", summary: "Read-only projection of the shared console model; independently removable.", reads: pi ? ["exact Core summon results", "successful read events", "active session branch"] : hermes ? ["caller-supplied exact Core sessionRoot ledger"] : ["caller-supplied exact Core sessionRoot ledger", ...agy ? ["optional exact conversation transcript and confined result files"] : []], writes: [], network: pi || hermes ? "none; Lens only drafts a handoff, normal Core calls remain subject to host approval" : "none of its own; explicit model-mediated Lens requests use the existing Core tool", disable: remove(true)[0].run, notes: ["No hidden submission, automatic materialization, daemon, global configuration rewrite or independent summon server.", ...pi ? ["Active-branch paired historical reads lack execution-time tool provenance and restore as unknown; current complete-read credit requires the pinned builtin contract. Partial, missing or truncated reads cannot establish full context. Rung selection is not restored from guessed prompt text."] : ["Without an exact binding, counts are unknown. Command/skill output may pass through the model."]] }
740 ],
741 probe: { version: agy ? "1.3.2" : id === "codex" ? "0.162.0" : hermes ? "vgit.8ac5c74 (2026.9.24)" : id === "grok" ? "1.0.50" : versions[id], summary: agy ? "PROVISIONAL \u2014 Agy 1.3.2 Core/Full registration succeeded and installed Console assets exist; installed-carrier invocation, native Core preview and exact sessionRoot binding remain unverified (#206). Repository-report execution is not installed-carrier acceptance. Five other hosts are runtime accepted under the founder-approved 5+1 boundary." : pi ? "Pi 1.1.0 native status/pane, dismissal/paging, loaded preview schema, policy denial, preview without materialization and successful body read observed. Branch restoration/rung decoding additionally have deterministic tests; remaining acceptance is tracked separately." : id === "codex" ? "Accepted \u2014 Codex 0.162.0 installed console skill/report, once-approved Core preview and populated bound report observed; gpt-6-luna medium. No body-read/use or native HUD claim." : hermes ? "Accepted \u2014 Hermes vgit.8ac5c74 native command report, Core preview and exact sessionRoot binding/inspection observed with openai-codex / gpt-6-luna minimal; fresh reset stayed unknown. No read/use or HUD claim." : "Accepted \u2014 Grok 1.0.50 actual report, Core preview and bound report observed on grok-4.7 under default permissions. Limited-time free access and model-mediated reflow, not a permanent free tier or native HUD/read/use claim.", href: `${ROOT}/plugins/skill-heaven-console-${id}/README.md` }
742 };
743 return { console, core: piece(register(false), update(false), remove(false)), consolePiece: piece(register(true), update(true), remove(true)), fullBlocked: null };
744}
745
746// packages/status/src/compat.ts
747var AGENT_PLUGIN_INSTALL = {
748 posix: "curl -fsSL https://gaia-research.github.io/gaia-skill-heaven/install-agent-plugin.sh | sh",
749 windows: "irm https://gaia-research.github.io/gaia-skill-heaven/install-agent-plugin.ps1 | iex",
750 root: "$HOME/.local/share/gaia-skill-heaven-agent-plugin",
751 marketplace: "$HOME/.local/share/gaia-skill-heaven-agent-plugin/marketplace",
752 plugin: "$HOME/.local/share/gaia-skill-heaven-agent-plugin/marketplace/plugins/skill-heaven",
753 uninstall: "$HOME/.local/share/gaia-skill-heaven-agent-plugin/uninstall.sh"
754};
755var LAUNCHER_INSTALL = {
756 posix: "curl -fsSL https://gaia-research.github.io/gaia-skill-heaven/install.sh | sh",
757 windows: "irm https://gaia-research.github.io/gaia-skill-heaven/install.ps1 | iex",
758 uninstall: "$HOME/.local/share/gaia-skill-heaven/uninstall.sh"
759};
760var PROFILES = ["core", "full"];
761var PROFILE_PITCH = {
762 core: { name: "Core", line: "The Skill Heaven runtime. Summon and the entropy controls. No extra console UI." },
763 full: {
764 name: "Core + Console",
765 line: "Core plus the supported Skill Heaven console \u2014 compact statusline, receipts and intentionally opened terminal views where the harness supports them."
766 }
767};
768var PENDING = (name) => ({
769 console: {
770 kind: "command-backed",
771 mechanism: `pending recon for ${name}`,
772 command: null,
773 commandPrefix: "",
774 surfaces: {
775 status: { level: "unsupported", via: "pending", note: "pending" },
776 lens: { level: "unsupported", via: "pending", note: "pending" },
777 session: { level: "unsupported", via: "pending", note: "pending" },
778 scope: { level: "unsupported", via: "pending", note: "pending" },
779 flow: { level: "unsupported", via: "pending", note: "pending" },
780 trust: { level: "unsupported", via: "pending", note: "pending" }
781 },
782 observes: { summon: "unavailable", read: "unavailable", agents: "unavailable", rung: "unavailable" },
783 summonTools: [],
784 trust: [],
785 probe: { version: null, summary: "pending", href: null }
786 },
787 core: { register: [], update: [], remove: [] },
788 consolePiece: null,
789 fullBlocked: "pending recon"
790});
791var REPO = "https://github.com/gaia-research/gaia-skill-heaven/blob/main";
792var HARNESS_PATHS = [
793 {
794 id: "claude",
795 name: "Claude Code",
796 bin: "claude",
797 chip: "verified",
798 probedVersion: "2.1.288",
799 evidence: "Fresh-install receipt, 76/76 checks, GitHub main @ fdfd94e.",
800 evidenceHref: `${REPO}/docs/RELEASE-ACCEPTANCE.md`,
801 needsInstaller: false,
802 commands: [
803 "/plugin marketplace add gaia-research/gaia-skill-heaven",
804 "/plugin install skill-heaven@gaia-skill-heaven"
805 ],
806 inHarness: true,
807 blocked: null,
808 update: "claude plugin marketplace update gaia-skill-heaven && claude plugin update skill-heaven@gaia-skill-heaven",
809 remove: ["claude plugin uninstall skill-heaven@gaia-skill-heaven"],
810 statusIntegration: "APPEND",
811 statusNote: "The optional console (preview) adds a status entry beside yours \u2014 it never replaces your statusLine. Probed live in the terminal on 2.1.294; its desktop paint is not probed.",
812 launcher: "claude-zero",
813 // 2.1.294 refuses a bare /summon: it resolves to the portable skill, which is user-invocable: false.
814 firstRun: "/skill-heaven:summon <what you need>",
815 console: {
816 kind: "pane",
817 mechanism: "Claude Code's Mods API (function hooks, early access since 2.1.293): $.ui.status appends a status entry beside your own, an AbovePrompt band carries Lens, and /heaven opens a pane with Session, Scope, Flow and Trust.",
818 command: "/heaven",
819 commandPrefix: "skill-heaven:",
820 surfaces: {
821 status: { level: "native", via: "$.ui.status (APPEND \u2014 never touches statusLine)", note: "Probed live in the terminal on 2.1.294; desktop paint is not probed." },
822 lens: { level: "native", via: "AbovePrompt band + $.prompt.fill", note: "A button only pre-fills the prompt; you press Enter." },
823 session: { level: "native", via: "the /heaven pane", note: "Every field carries an evidence class." },
824 scope: { level: "native", via: "the /heaven pane", note: "Rung controls pre-fill commands; nothing runs until you submit." },
825 flow: { level: "native", via: "agentId on tool.call and turn.complete", note: "Only agents the host reported appear." },
826 trust: { level: "native", via: "the /heaven pane", note: "Lists what the console reads and writes; it does not rate it." }
827 },
828 observes: { summon: "observed", read: "observed", agents: "observed", rung: "observed" },
829 summonTools: ["mcp__plugin_skill-heaven_skill-summon__summon", "mcp__skill-summon__summon"],
830 trust: [
831 {
832 id: "skill-heaven",
833 profile: "core",
834 kind: "Claude Code plugin",
835 version: "0.1.2",
836 summary: "The runtime: five commands and one bundled MCP server (skill-summon).",
837 reads: ["the skill source you configure (network, by the summon tool)"],
838 writes: ["a disposable session directory under your temp dir"],
839 network: "the summon tool fetches the skill source",
840 disable: "claude plugin uninstall skill-heaven@gaia-skill-heaven"
841 },
842 {
843 id: "skill-heaven-console",
844 profile: "full",
845 kind: "Claude Code plugin (Mods, preview)",
846 version: "0.1.0",
847 summary: "The console: a status entry, the Lens band and the /heaven pane. Runs inside Claude Code as local code.",
848 notes: ["/lens and /heaven print a one-line result that the model can read. It is fixed text and carries nothing a skill source supplied."],
849 reads: ["summon tool results", "your /skill-* commands", "Read and Agent tool calls \u2014 to observe, never to change"],
850 writes: ["nothing to disk", "session-only $.state"],
851 network: "none of its own; /lens calls the bundled summon tool, which fetches the skill source",
852 disable: "claude plugin uninstall skill-heaven-console@gaia-skill-heaven"
853 }
854 ],
855 probe: {
856 version: "2.1.294",
857 summary: "the console was probed live in the terminal on 2.1.294; desktop paint is not probed",
858 href: `${REPO}/plugins/skill-heaven-console/README.md`
859 }
860 },
861 core: {
862 register: [
863 { where: "shell", run: 'claude plugin marketplace add "{{MARKETPLACE_DIR}}"', argv: ["claude", "plugin", "marketplace", "add", "{{MARKETPLACE_DIR}}"], effect: "adds the reviewed staged local marketplace to Claude Code's plugin registry" },
864 { where: "harness", run: "/plugin install skill-heaven@gaia-skill-heaven", shell: "claude plugin install skill-heaven@gaia-skill-heaven", argv: ["claude", "plugin", "install", "skill-heaven@gaia-skill-heaven"], effect: "installs the skill-heaven plugin (runtime only)" }
865 ],
866 update: [
867 { where: "shell", run: "claude plugin marketplace update gaia-skill-heaven", argv: ["claude", "plugin", "marketplace", "update", "gaia-skill-heaven"], effect: "refreshes the marketplace listing" },
868 { where: "shell", run: "claude plugin uninstall skill-heaven@gaia-skill-heaven", argv: ["claude", "plugin", "uninstall", "skill-heaven@gaia-skill-heaven"], effect: "removes only the old cached runtime registration before reinstall" },
869 { where: "shell", run: "claude plugin install skill-heaven@gaia-skill-heaven", argv: ["claude", "plugin", "install", "skill-heaven@gaia-skill-heaven"], effect: "installs the staged candidate even when the version string is unchanged" }
870 ],
871 remove: [{ where: "shell", run: "claude plugin uninstall skill-heaven@gaia-skill-heaven", argv: ["claude", "plugin", "uninstall", "skill-heaven@gaia-skill-heaven"], effect: "removes the plugin" }]
872 },
873 consolePiece: {
874 register: [
875 { where: "harness", run: "/plugin install skill-heaven-console@gaia-skill-heaven", shell: "claude plugin install skill-heaven-console@gaia-skill-heaven", argv: ["claude", "plugin", "install", "skill-heaven-console@gaia-skill-heaven"], effect: "installs the console plugin beside skill-heaven" }
876 ],
877 update: [
878 { where: "shell", run: "claude plugin marketplace update gaia-skill-heaven", argv: ["claude", "plugin", "marketplace", "update", "gaia-skill-heaven"], effect: "refreshes the registered local marketplace" },
879 { where: "shell", run: "claude plugin uninstall skill-heaven-console@gaia-skill-heaven", argv: ["claude", "plugin", "uninstall", "skill-heaven-console@gaia-skill-heaven"], effect: "removes only the old cached console before reinstall" },
880 { where: "shell", run: "claude plugin install skill-heaven-console@gaia-skill-heaven", argv: ["claude", "plugin", "install", "skill-heaven-console@gaia-skill-heaven"], effect: "installs the staged console even when its version string is unchanged" }
881 ],
882 remove: [{ where: "shell", run: "claude plugin uninstall skill-heaven-console@gaia-skill-heaven", argv: ["claude", "plugin", "uninstall", "skill-heaven-console@gaia-skill-heaven"], effect: "removes only the console; skill-heaven is unchanged" }]
883 },
884 fullBlocked: null
885 },
886 {
887 id: "codex",
888 ...adapterPath("codex"),
889 name: "Codex",
890 bin: "codex",
891 chip: "compatible",
892 probedVersion: "0.161.0",
893 evidence: "Live smoke on 0.161.0: plugin added, codex mcp list resolves skill-summon, a summon call completed. Headless codex exec asks approval for MCP calls. Surfaces last probed on 0.146.0.",
894 evidenceHref: `${REPO}/plugins/skill-heaven/PROBE.md`,
895 needsInstaller: true,
896 commands: [
897 `codex plugin marketplace add "${AGENT_PLUGIN_INSTALL.marketplace}"`,
898 "codex plugin add skill-heaven@gaia-skill-heaven"
899 ],
900 inHarness: false,
901 blocked: null,
902 update: "Re-run the installer, then reinstall in Codex \u2014 Codex keeps its own cached copy.",
903 remove: ["codex plugin remove skill-heaven@gaia-skill-heaven", AGENT_PLUGIN_INSTALL.uninstall],
904 statusIntegration: "UNSUPPORTED",
905 statusNote: "Codex has no public status contribution API. Summon receipts still print in the transcript.",
906 launcher: "codex-zero",
907 firstRun: "/summon <what you need>"
908 },
909 {
910 id: "pi",
911 ...adapterPath("pi"),
912 name: "Pi",
913 bin: "pi",
914 chip: "compatible",
915 probedVersion: "1.1.0",
916 evidence: "Pi 1.1.0: native profile lifecycle, registered active summon schema with optional boolean preview, normal policy-hook denial, approved preview without materialization, materialization and body read observed. Five package-owned namespaced resources load without shadowing user skills. The adapter keeps its own summon tool rather than an optional MCP replacement extension.",
917 evidenceHref: `${REPO}/plugins/skill-heaven/dev.skill-heaven.pi/PROBE.md`,
918 needsInstaller: true,
919 commands: [`pi install "${AGENT_PLUGIN_INSTALL.plugin}" --approve`],
920 inHarness: false,
921 blocked: null,
922 update: "Re-run the installer, then pi update.",
923 remove: [`pi remove "${AGENT_PLUGIN_INSTALL.plugin}"`, AGENT_PLUGIN_INSTALL.uninstall],
924 statusIntegration: "NATIVE SLOT",
925 statusNote: "Core + Console requires Pi 1.1+ and adds one compact owned status line plus an explicitly opened bounded terminal pane (Escape/q dismiss; inspect for details). Native 1.1.0 height, paging and editor restoration observed. Core registers no console.",
926 launcher: "pi-zero",
927 firstRun: "/summon <what you need>"
928 },
929 {
930 id: "grok",
931 ...adapterPath("grok"),
932 name: "Grok",
933 bin: "grok",
934 chip: "compatible",
935 probedVersion: "1.0.5",
936 evidence: "Live probe on 1.0.5. On 1.0.46, grok plugin install and details find the skills, commands and MCP server (static: no signed-in session to run a summon).",
937 evidenceHref: `${REPO}/plugins/skill-heaven/PROBE.md`,
938 needsInstaller: true,
939 commands: [`grok plugin install "${AGENT_PLUGIN_INSTALL.plugin}" --trust`],
940 inHarness: false,
941 blocked: null,
942 update: "Re-run the installer, then grok plugin update.",
943 remove: ["grok plugin uninstall skill-heaven", AGENT_PLUGIN_INSTALL.uninstall],
944 statusIntegration: "UNSUPPORTED",
945 statusNote: "Core + Console carries Status in an explicit command-backed report, not a persistent HUD.",
946 launcher: "grok-zero",
947 firstRun: "/summon <what you need>"
948 },
949 {
950 id: "hermes",
951 ...adapterPath("hermes"),
952 name: "Hermes",
953 bin: "hermes",
954 chip: "compatible",
955 probedVersion: "0.20.0",
956 evidence: "Live probe, repeated on 0.20.0 (2026-10-08): plugin installed and enabled, a summon call completed.",
957 evidenceHref: `${REPO}/plugins/skill-heaven/PROBE.md`,
958 needsInstaller: true,
959 commands: [`hermes plugins install "file://${AGENT_PLUGIN_INSTALL.plugin}" --enable`],
960 inHarness: false,
961 blocked: null,
962 update: "Re-run the installer, then reinstall in Hermes. Remove the Hermes registration with Hermes's own plugin manager.",
963 // Hermes's own removal command was not verified on the machine that wrote
964 // this table (its `--help` could not run), so none is printed.
965 remove: [AGENT_PLUGIN_INSTALL.uninstall],
966 statusIntegration: "UNSUPPORTED",
967 statusNote: "Hermes has no stable public status contribution. Receipts print in the transcript.",
968 launcher: "hermes-zero",
969 firstRun: "/summon <what you need>"
970 },
971 {
972 id: "agy",
973 ...adapterPath("agy"),
974 name: "Antigravity",
975 bin: "agy",
976 chip: "compatible",
977 probedVersion: "1.3.1",
978 evidence: "Live probe on 1.3.1 with your real HOME: agy plugin install loads the skills, commands and the summon server; /skill-heaven:summon and the four surfaces ran.",
979 evidenceHref: `${REPO}/packages/agy-zero/PROBE.md`,
980 needsInstaller: true,
981 commands: [`agy plugin install "${AGENT_PLUGIN_INSTALL.plugin}"`],
982 inHarness: false,
983 blocked: null,
984 update: "Re-run the installer, then agy plugin uninstall skill-heaven and install it again \u2014 Antigravity keeps its own copy.",
985 remove: ["agy plugin uninstall skill-heaven", AGENT_PLUGIN_INSTALL.uninstall],
986 statusIntegration: "UNSUPPORTED",
987 statusNote: "Console runtime is provisional: installed-carrier invocation and native Core preview/session binding are unverified (#206). Registration succeeded; no user statusLine is installed or rewritten.",
988 launcher: "agy-zero",
989 // Antigravity namespaces plugin skills: its / menu lists /skill-heaven:summon, and a bare /summon is not a command.
990 firstRun: "/skill-heaven:summon <what you need>"
991 },
992 {
993 id: "other",
994 ...PENDING("Another"),
995 name: "Another Agent Plugins client",
996 bin: null,
997 chip: "unverified",
998 probedVersion: null,
999 evidence: "The package follows Agent Plugins 1.0.0. Your client owns registration; it has not been probed here.",
1000 evidenceHref: "https://agent-plugins.org/specification",
1001 needsInstaller: true,
1002 commands: [],
1003 inHarness: false,
1004 blocked: `Point your client's own plugin install at ${AGENT_PLUGIN_INSTALL.plugin}. There is no universal registration command.`,
1005 update: "Re-run the installer; your client may keep its own cached copy.",
1006 remove: [AGENT_PLUGIN_INSTALL.uninstall],
1007 statusIntegration: "UNSUPPORTED",
1008 statusNote: "Depends on your client.",
1009 launcher: null,
1010 firstRun: "/summon <what you need>, or the spelling your client lists for the skill-heaven plugin"
1011 }
1012];
1013var CHIP_LABEL = {
1014 verified: "Verified",
1015 compatible: "Compatible",
1016 partial: "Partial",
1017 unverified: "Unverified",
1018 "needs-local-probe": "Needs local probe"
1019};
1020var CHIP_MEANING = {
1021 verified: "A fresh install was verified end to end on the pinned version.",
1022 compatible: "A live probe passed on the pinned version. Yours may differ.",
1023 partial: "Part of the plugin loads; something is proven missing.",
1024 unverified: "Not probed. The package is portable; this client is untested.",
1025 "needs-local-probe": "Could not be established without a logged-in session."
1026};
1027function harnessById(id) {
1028 const found = HARNESS_PATHS.find((h) => h.id === id);
1029 if (!found) throw new Error(`unknown harness ${id}`);
1030 return found;
1031}
1032
1033// packages/status/src/console-host.ts
1034var CONSOLE_SURFACES = ["status", "lens", "session", "scope", "flow", "trust"];
1035var SURFACE_LABEL = Object.freeze({
1036 status: "Status",
1037 lens: "Lens",
1038 session: "Session",
1039 scope: "Scope",
1040 flow: "Flow",
1041 trust: "Trust"
1042});
1043var SURFACE_QUESTION = Object.freeze({
1044 status: "Where am I on the line, and how many skills entered this session?",
1045 lens: "What would a summon return \u2014 and hand it to me to submit.",
1046 session: "What happened, and what is the evidence for each step?",
1047 scope: "What can Skill Heaven see, what is active, which rung did I pick?",
1048 flow: "Which agents ran, and which skills did each summon?",
1049 trust: "What is installed, what can it read and write, what is degraded here?"
1050});
1051
1052// packages/status/src/console-state.ts
1053var MAX_ENTRIES = 50;
1054var MAX_AGENTS = 100;
1055var MAX_SKILLS_PER_ENTRY = 20;
1056function initialConsoleState() {
1057 return {
1058 status: {
1059 ...emptyStatus(),
1060 reading: { kind: "native", source: "no-launcher" },
1061 skills: 0,
1062 summons: 0,
1063 summonTool: "unknown"
1064 },
1065 entries: [],
1066 band: null,
1067 agents: [],
1068 agentIdsSeen: false,
1069 selectedFrom: null,
1070 hostVersion: null,
1071 seq: 0
1072 };
1073}
1074var isRec2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
1075var looksLikeSummon = (v) => isRec2(v) && ("summoned" in v || "previewed" in v || "noMatch" in v);
1076function structuredOf(r) {
1077 if (typeof r === "string") {
1078 const parsed = parseJson(r);
1079 if (looksLikeSummon(parsed)) return parsed;
1080 const embedded = firstJsonObject(r);
1081 return looksLikeSummon(embedded) ? embedded : void 0;
1082 }
1083 if (!isRec2(r)) return void 0;
1084 if (looksLikeSummon(r)) return r;
1085 const result = r.result;
1086 if (isRec2(result)) {
1087 if (looksLikeSummon(result.structuredContent)) return result.structuredContent;
1088 if (looksLikeSummon(result)) return result;
1089 }
1090 if (looksLikeSummon(r.structuredContent)) return r.structuredContent;
1091 const texts = [];
1092 if (typeof r.text === "string") texts.push(r.text);
1093 if (typeof result === "string" && result !== r.text) texts.push(result);
1094 for (const holder of [result, r]) {
1095 if (isRec2(holder) && Array.isArray(holder.content)) {
1096 for (const block of holder.content) {
1097 if (isRec2(block) && typeof block.text === "string") texts.push(block.text);
1098 }
1099 }
1100 }
1101 for (const text of texts) {
1102 const parsed = parseJson(text);
1103 if (looksLikeSummon(parsed)) return parsed;
1104 const embedded = firstJsonObject(text);
1105 if (looksLikeSummon(embedded)) return embedded;
1106 }
1107 return void 0;
1108}
1109function parseJson(text) {
1110 try {
1111 return JSON.parse(text);
1112 } catch {
1113 return void 0;
1114 }
1115}
1116function firstJsonObject(text) {
1117 for (let start = text.indexOf("{"); start !== -1; start = text.indexOf("{", start + 1)) {
1118 let depth = 0;
1119 let inString = false;
1120 for (let i = start; i < text.length; i++) {
1121 const ch = text[i];
1122 if (inString) {
1123 if (ch === "\\") i++;
1124 else if (ch === '"') inString = false;
1125 } else if (ch === '"') inString = true;
1126 else if (ch === "{") depth++;
1127 else if (ch === "}" && --depth === 0) {
1128 try {
1129 return JSON.parse(text.slice(start, i + 1));
1130 } catch {
1131 break;
1132 }
1133 }
1134 }
1135 }
1136 return void 0;
1137}
1138function isSummonTool(projection, name) {
1139 return projection.summonTools.includes(name);
1140}
1141var shortId = (id) => sanitizeDisplay(id, 12);
1142function agentLabelFor(state, id) {
1143 if (id === null || id === void 0) return "main agent";
1144 const row = state.agents.find((a) => a.id === id);
1145 return row ? row.label : `agent ${shortId(id)}`;
1146}
1147function agentCallLabel(subagentType, description) {
1148 const type = typeof subagentType === "string" && subagentType ? sanitizeDisplay(subagentType, 24) : "agent";
1149 const desc = typeof description === "string" && description ? sanitizeDisplay(description, 48) : "";
1150 return desc ? `${type} "${desc}"` : type;
1151}
1152function noteAgentId(state, id) {
1153 if (state.agents.some((a) => a.id === id)) return state.agentIdsSeen ? state : { ...state, agentIdsSeen: true };
1154 const agents = [
1155 ...state.agents,
1156 { key: id, id, label: `agent ${shortId(id)}`, state: "running" }
1157 ].slice(-MAX_AGENTS);
1158 return { ...state, agentIdsSeen: true, agents };
1159}
1160function startAgentCall(state, key, label, background) {
1161 if (state.agents.some((a) => a.key === key)) return state;
1162 return {
1163 ...state,
1164 agents: [...state.agents, { key, id: null, label, state: background ? "started" : "running" }].slice(-MAX_AGENTS)
1165 };
1166}
1167function dropAgentCall(state, key) {
1168 return state.agents.some((a) => a.key === key) ? { ...state, agents: state.agents.filter((a) => a.key !== key) } : state;
1169}
1170function finishAgentCall(state, key, agentId, background) {
1171 const agents = state.agents.filter((a) => agentId === null || a.key !== agentId || a.key === key).map(
1172 (a) => a.key === key ? { ...a, id: agentId ?? a.id, state: background ? "started" : "returned" } : a
1173 );
1174 return { ...state, agents, agentIdsSeen: state.agentIdsSeen || agentId !== null };
1175}
1176function agentReturned(state, agentId) {
1177 if (!state.agents.some((a) => a.id === agentId && a.state !== "returned")) return state;
1178 return { ...state, agents: state.agents.map((a) => a.id === agentId ? { ...a, state: "returned" } : a) };
1179}
1180function bounded(event) {
1181 if ((event.kind === "summoned" || event.kind === "previewed") && event.skills.length > MAX_SKILLS_PER_ENTRY) {
1182 return { event: { ...event, skills: event.skills.slice(0, MAX_SKILLS_PER_ENTRY) }, omitted: event.skills.length - MAX_SKILLS_PER_ENTRY };
1183 }
1184 return { event, omitted: 0 };
1185}
1186function withReadObservability(event, readObservable) {
1187 if (readObservable || event.kind !== "summoned") return event;
1188 return {
1189 ...event,
1190 skills: event.skills.map((s) => s.stage === "materialized" ? { ...s, stage: "read-unobserved" } : s)
1191 };
1192}
1193function recordEvent(state, event, agent, via, opts = {}) {
1194 const reached = opts.reached ?? true;
1195 const shaped = withReadObservability(event, opts.readObservable ?? true);
1196 const id = state.seq + 1;
1197 const kept = bounded(shaped);
1198 const entry = {
1199 id,
1200 event: kept.event,hooks/meta.ts 16 lines1// What the Trust section states about the installed code. A mod cannot read its
2// own manifest, so these are written here and a repository test holds each to
3// the version in its plugin.json.
4
5/** plugins/skill-heaven/.claude-plugin/plugin.json `version`. */
6export const SKILL_HEAVEN_VERSION = '0.1.2'
7
8/** plugins/skill-heaven-console/.claude-plugin/plugin.json `version`. */
9export const CONSOLE_VERSION = '0.1.0'
10
11/** The pane's id, the status values' plugin name. */
12export const PANE_ID = 'skill-heaven'
13
14/** What a logged-in probe established about this console (PR #187), for Trust. */
15export const CONSOLE_PROBE = 'the console was probed live in the terminal on 2.1.294; desktop paint is not probed'
16hooks/model.ts 99 lines1// The console's pure logic for Claude Code: how observed facts fold into session state.
2//
3// The folding itself is shared by every host — `packages/status/src/console-state.ts`,
4// reached here through the committed bundle (`status-model.mjs`) — so Claude Code,
5// Pi, Codex, Hermes, Grok and Antigravity all treat an observation the same way.
6// This file only adds what is Claude-specific: the pane's own UI state (`section`,
7// `openEntry`), the exact tool names the host spells, and the `reached` shorthand
8// the hooks use.
9//
10// No `$`, no engine, no I/O here.
11
12import {
13 agentCallLabel,
14 agentLabelFor,
15 agentReturned,
16 dropAgentCall,
17 entryById,
18 finishAgentCall,
19 initialConsoleState,
20 noteAgentId,
21 qualifyCommand as qualifyShared,
22 recordEvent as recordShared,
23 recordRead,
24 recordSelection,
25 startAgentCall,
26 stageText,
27 structuredOf,
28 summonSuggestion,
29 summonableName,
30 timeLabel,
31} from './status-model.mjs'
32import type { SkillHeavenStatus, SummonEvent } from './status-model.mjs'
33import type { ConsoleAgent, ConsoleBand, ConsoleEntryData, ConsoleSection, ConsoleStateData } from '../types'
34
35export type { ConsoleAgent, ConsoleBand, ConsoleSection }
36
37/** The state contract (types/index.d.ts) keeps `status` and `event` opaque because
38 * the engine wants that file self-contained; these are their real types, and
39 * `fromData` / `toData` are the only place the two meet. */
40export type ConsoleEntry = Omit<ConsoleEntryData, 'event'> & { event: SummonEvent }
41export type ConsoleState = Omit<ConsoleStateData, 'status' | 'entries'> & {
42 status: SkillHeavenStatus
43 entries: ConsoleEntry[]
44}
45export const fromData = (data: ConsoleStateData): ConsoleState => data as unknown as ConsoleState
46export const toData = (state: ConsoleState): ConsoleStateData => state as unknown as ConsoleStateData
47
48export { MAX_ENTRIES, MAX_AGENTS, MAX_SKILLS_PER_ENTRY } from './status-model.mjs'
49
50/** The summon tool, however the session spells it:
51 * `mcp__plugin_skill-heaven_skill-summon__summon` (marketplace install) or
52 * `mcp__skill-summon__summon` (launcher). Anchored at both ends: a server that
53 * merely ends in "skill-summon" (`mcp__evil-skill-summon__summon`) is not it.
54 * register.tsx spells the same pattern as a literal in its tool.call matcher;
55 * a repository test holds the two equal. */
56export const SUMMON_TOOL = /^mcp__(?:plugin_skill-heaven_)?skill-summon__summon$/
57export const MARKETPLACE_SUMMON_TOOL = 'mcp__plugin_skill-heaven_skill-summon__summon'
58export const LAUNCHER_SUMMON_TOOL = 'mcp__skill-summon__summon'
59
60/** The console watches the whole session, so zero is honest at the start. */
61export function initialState(): ConsoleState {
62 return { ...initialConsoleState(), section: 'session', openEntry: null, inspectSection: false, bandRequested: false } as unknown as ConsoleState
63}
64
65/** Fold one observed summon-tool call into state. `reached` is false when the call
66 * never got an answer from the tool (a /lens preview that was aborted or refused):
67 * that says nothing about whether the tool is connected. Claude Code shows every
68 * Read, so a materialized skill whose body was not read is *inferred* "not read". */
69export function recordEvent(
70 state: ConsoleState,
71 event: SummonEvent,
72 agent: string | null,
73 via: ConsoleEntry['via'],
74 reached = true,
75): ConsoleState {
76 return recordShared(state, event, agent, via, { reached, readObservable: true })
77}
78
79/** The spelling of a Skill Heaven command this session accepts (Claude Code 2.1.294 refuses the bare ones). */
80export const qualifyCommand = (text: string): string => qualifyShared(text, 'skill-heaven:')
81
82export {
83 agentCallLabel,
84 agentLabelFor,
85 agentReturned,
86 dropAgentCall,
87 entryById,
88 finishAgentCall,
89 noteAgentId,
90 recordRead,
91 recordSelection,
92 startAgentCall,
93 stageText,
94 structuredOf,
95 summonSuggestion,
96 summonableName,
97 timeLabel,
98}
99hooks/views.tsx 337 lines1// Drawing: the Lens band and the /heaven pane, as trees of the surface's own
2// elements. Pure functions of state — no `$`, no writes. A press is handed back
3// to the hook that drew the tree through the `actions` objects below, so this
4// file cannot change anything by itself.
5//
6// Every string that came from the network or from a model (skill names, queries,
7// sources, reasons, agent labels) reaches the screen through the status model's
8// sanitizer or its renderers. Colour is never the only carrier of meaning: each
9// state keeps its glyph and its word.
10
11import type { Elements, RenderElement } from 'claude-code'
12
13import {
14 ROLE_COLORS,
15 buildConsoleView,
16 renderConsoleText,
17 flowView,
18 harnessById,
19 lensView,
20 renderStatusSegments,
21 scopeView,
22 sessionView,
23 trustView,
24 evidenceWord,
25} from './status-model.mjs'
26import type { Role, Row, Segment } from './status-model.mjs'
27import { qualifyCommand, summonSuggestion, entryById } from './model.ts'
28import type { ConsoleSection, ConsoleState } from './model.ts'
29
30const CLAUDE = harnessById('claude')
31
32/** The elements every surface that draws a band or a pane has in common. */
33export type UI = Pick<Elements['desktop'], 'Box' | 'Text' | 'Button'>
34
35export interface BandActions {
36 inspect: (id: number) => void
37 dismiss: () => void
38 /** Pre-fills `/summon <name>` into the prompt. The person submits it. */
39 summon: (name: string) => void
40}
41
42export interface PaneActions {
43 inspect: () => void
44 close: () => void
45 section: (section: ConsoleSection) => void
46 toggle: (id: number) => void
47 /** Pre-fills a command into the prompt. The person submits it. */
48 fill: (text: string) => void
49 copy: (text: string) => void
50}
51
52/* ------------------------------------------------------------------------- *
53 * Colour: roles from the one palette. `ink` is the theme's own text colour,
54 * `dim` is the theme's dim; every other role is its palette hex.
55 * ------------------------------------------------------------------------- */
56
57type StyleProps = { color?: string; dimColor?: boolean; italic?: boolean; bold?: boolean }
58
59function styleOf(role: Role): StyleProps {
60 if (role === 'ink') return {}
61 if (role === 'dim') return { dimColor: true }
62 return { color: ROLE_COLORS[role].hex }
63}
64
65function runs(ui: UI, segments: readonly Segment[], extra: StyleProps = {}): RenderElement {
66 const { Text } = ui
67 return (
68 <Text>
69 {segments.map((s) => (
70 <Text {...styleOf(s.role)} {...extra}>
71 {s.text}
72 </Text>
73 ))}
74 </Text>
75 )
76}
77
78/* ------------------------------------------------------------------------- *
79 * The Lens band — empty by default (the hook returns next(e) for null).
80 * ------------------------------------------------------------------------- */
81
82export function renderBand(ui: UI, state: ConsoleState, actions: BandActions, columns: number): RenderElement | null {
83 const { Box, Text, Button } = ui
84 const view = lensView(state, CLAUDE.console)
85 if (view === null || !state.bandRequested) return null
86 const width = Math.max(20, columns)
87 const [first] = view.lines
88
89 if (view.entryId === null) {
90 return (
91 <Box flexDirection="column" width={width}>
92 {first ? runs(ui, first) : null}
93 <Button key="dismiss" label="Dismiss" role="dismiss" onPress={() => actions.dismiss()} />
94 </Box>
95 )
96 }
97
98 const entry = entryById(state, view.entryId)
99 if (!entry) return null
100 const name = summonSuggestion(entry)
101 return (
102 <Box flexDirection="column" width={width}>
103 {first ? runs(ui, first) : null}
104 {/* a preview's second line already says "nothing materialized" (seen twice live on 2.1.294) */}
105 {view.stage === null ? null : (
106 <Text key="stage" dimColor italic={view.stage.inferred}>
107 {' '}
108 {view.stage.text}
109 {view.stage.inferred ? ' (inferred)' : ''}
110 </Text>
111 )}
112 <Box flexDirection="row" gap={1}>
113 {name !== null ? <Button key="summon" label="Summon" variant="primary" onPress={() => actions.summon(name)} /> : null}
114 <Button key="inspect" label="Inspect" onPress={() => actions.inspect(entry.id)} />
115 <Button key="dismiss" label="Dismiss" role="dismiss" onPress={() => actions.dismiss()} />
116 </Box>
117 </Box>
118 )
119}
120
121/* ------------------------------------------------------------------------- *
122 * The /heaven pane
123 * ------------------------------------------------------------------------- */
124
125const SECTIONS: ReadonlyArray<{ id: ConsoleSection; label: string; hotkey: string }> = [
126 { id: 'session', label: 'Session', hotkey: '1' },
127 { id: 'scope', label: 'Scope', hotkey: '2' },
128 { id: 'flow', label: 'Flow', hotkey: '3' },
129 { id: 'trust', label: 'Trust', hotkey: '4' },
130]
131
132export function renderPane(ui: UI, state: ConsoleState, actions: PaneActions, columns: number): RenderElement {
133 const { Box, Text, Button } = ui
134 const width = Math.max(24, columns)
135 return (
136 <Box flexDirection="column" width={width} gap={1}>
137 <Box flexDirection="column">
138 <Text>
139 <Text bold>Skill Heaven</Text>
140 <Text color={ROLE_COLORS.amber.hex}>{' PREVIEW'}</Text>
141 <Text dimColor>{' console · observes, never changes'}</Text>
142 </Text>
143 {runs(ui, renderStatusSegments(state.status, 'full'))}
144 </Box>
145 <Box flexDirection="row" gap={1} flexWrap="wrap">
146 {SECTIONS.map((s) => (
147 <Button
148 key={`section-${s.id}`}
149 label={s.label}
150 hotkey={s.hotkey}
151 variant={state.section === s.id ? 'primary' : 'secondary'}
152 onPress={() => actions.section(s.id)}
153 />
154 ))}
155 </Box>
156 <Box flexDirection="row" gap={1}>
157 <Button key="inspect-section" label={state.inspectSection ? 'Back to summary' : 'Inspect section'} onPress={() => actions.inspect()} />
158 <Button key="close-pane" label="Close" role="dismiss" onPress={() => actions.close()} />
159 </Box>
160 {!state.inspectSection ? <Text>{renderConsoleText(buildConsoleView(state, CLAUDE), { surface: state.section }).split('\n').slice(1, -1).join('\n')}</Text> : null}
161 {state.inspectSection && state.section === 'session' ? sessionSection(ui, state, actions) : null}
162 {state.inspectSection && state.section === 'scope' ? scopeSection(ui, state, actions) : null}
163 {state.inspectSection && state.section === 'flow' ? flowSection(ui, state) : null}
164 {state.inspectSection && state.section === 'trust' ? trustSection(ui, state) : null}
165 </Box>
166 )
167}
168
169/* -- evidence-labelled rows ------------------------------------------------ */
170
171const FIELD_WIDTH = 16
172
173function fieldRow(ui: UI, f: Row, key: string): RenderElement {
174 const { Box, Text } = ui
175 const known = f.value !== null && f.value !== '' && f.evidence !== 'unknown'
176 return (
177 <Box key={key} flexDirection="row" flexWrap="wrap">
178 <Text dimColor>{f.label.padEnd(FIELD_WIDTH)}</Text>
179 <Text italic={f.evidence === 'inferred'}>{known ? f.value : '—'}</Text>
180 <Text dimColor>{` ${evidenceWord(f)}`}</Text>
181 </Box>
182 )
183}
184
185/* -- Session ----------------------------------------------------------------- */
186
187function sessionSection(ui: UI, state: ConsoleState, actions: PaneActions): RenderElement {
188 const { Box, Text, Button } = ui
189 const view = sessionView(state, CLAUDE.console)
190 return (
191 <Box flexDirection="column" gap={1}>
192 {view.notConnected ? (
193 <Text>
194 <Text color={ROLE_COLORS.amber.hex}>{'? '}</Text>
195 <Text>{'summon tool: not connected'}</Text>
196 <Text dimColor>{` /summon and /lens cannot reach the Skill Heaven plugin. ${CLAUDE.core.register[1]?.run ?? ''}`}</Text>
197 </Text>
198 ) : null}
199 {view.empty !== null ? (
200 <Text>
201 {'Nothing summoned yet. Try '}
202 <Text bold>{`${qualifyCommand('/summon')} <need>`}</Text>
203 {' or '}
204 <Text bold>{'/lens <need>'}</Text>
205 {'.'}
206 </Text>
207 ) : null}
208 {view.entries.map((entry) => {
209 const open = state.openEntry === entry.id
210 const [line1, line2] = entry.lines
211 return (
212 <Box key={`entry-${entry.id}`} flexDirection="column">
213 {line1 ? runs(ui, [...line1, { text: entry.meta ? ` ${entry.meta}` : '', role: 'dim' }]) : null}
214 {line2 ? runs(ui, line2) : null}
215 <Button
216 key={`toggle-${entry.id}`}
217 label={open ? 'Hide receipt' : 'Receipt'}
218 plain
219 dimColor
220 onPress={() => actions.toggle(entry.id)}
221 />
222 {open
223 ? (
224 <Box flexDirection="column" marginLeft={2} gap={1}>
225 {entry.groups.map((group, gi) => (
226 <Box key={`group-${gi}`} flexDirection="column">
227 {group.map((f, fi) => fieldRow(ui, f, `f-${gi}-${fi}`))}
228 </Box>
229 ))}
230 </Box>
231 )
232 : null}
233 </Box>
234 )
235 })}
236 <Text dimColor>{view.legend}</Text>
237 </Box>
238 )
239}
240
241/* -- Scope ------------------------------------------------------------------- */
242
243const RUNG_KEYS = ['fill-heaven', 'fill-hell', 'fill-ultra'] as const
244const KEEP_KEYS = ['fill-zero', 'fill-zero-all', 'copy-clean'] as const
245
246function scopeSection(ui: UI, state: ConsoleState, actions: PaneActions): RenderElement {
247 const { Box, Text, Button } = ui
248 const view = scopeView(state, CLAUDE)
249 return (
250 <Box flexDirection="column" gap={1}>
251 <Box flexDirection="column">{view.rows.map((f, i) => fieldRow(ui, f, `scope-${i}`))}</Box>
252 {view.note !== null ? <Text dimColor>{view.note}</Text> : null}
253 {view.ultra !== null ? <Text color={ROLE_COLORS.ultra.hex}>{view.ultra}</Text> : null}
254 <Box flexDirection="column">
255 <Text bold>Choose a rung</Text>
256 <Text dimColor>These fill your prompt. You press Enter; nothing runs until you do.</Text>
257 <Box flexDirection="row" gap={1} flexWrap="wrap">
258 {view.rungControls.map((c, i) => (
259 <Button key={RUNG_KEYS[i] ?? `rung-${i}`} label={c.label} onPress={() => actions.fill(c.text)} />
260 ))}
261 </Box>
262 <Text dimColor>{view.otherRungs}</Text>
263 </Box>
264 <Box flexDirection="column">
265 <Text bold>Keep context small</Text>
266 <Box flexDirection="row" gap={1} flexWrap="wrap">
267 {view.keepSmall.map((c, i) => (
268 <Button
269 key={KEEP_KEYS[i] ?? `keep-${i}`}
270 label={c.label}
271 onPress={() => (c.kind === 'copy' ? actions.copy(c.text) : actions.fill(c.text))}
272 />
273 ))}
274 </Box>
275 {view.keepSmallNote !== null ? <Text dimColor>{view.keepSmallNote}</Text> : null}
276 </Box>
277 </Box>
278 )
279}
280
281/* -- Flow -------------------------------------------------------------------- */
282
283function flowSection(ui: UI, state: ConsoleState): RenderElement {
284 const { Box, Text } = ui
285 const view = flowView(state, CLAUDE.console)
286 return (
287 <Box flexDirection="column" gap={1}>
288 <Box flexDirection="column">
289 <Text>
290 <Text bold>main</Text>
291 <Text dimColor>{` ${view.main.line}`}</Text>
292 </Text>
293 {view.agents.map((agent) => (
294 <Text>
295 <Text dimColor>{agent.last ? '└─ ' : '├─ '}</Text>
296 <Text>{agent.label}</Text>
297 <Text dimColor>{` ${agent.line}`}</Text>
298 </Text>
299 ))}
300 {view.more > 0 ? <Text dimColor>{`└─ +${view.more} more`}</Text> : null}
301 </Box>
302 {view.telemetryNote !== null ? <Text dimColor>{view.telemetryNote}</Text> : null}
303 {view.windowNote !== null ? <Text dimColor>{view.windowNote}</Text> : null}
304 <Text dimColor>{view.footer}</Text>
305 </Box>
306 )
307}
308
309/* -- Trust ------------------------------------------------------------------- */
310
311function trustSection(ui: UI, state: ConsoleState): RenderElement {
312 const { Box, Text } = ui
313 const view = trustView(state, CLAUDE)
314 const row = (r: Row, key: string) => fieldRow(ui, { ...r, label: r.label }, key)
315 return (
316 <Box flexDirection="column" gap={1}>
317 {view.components.map((c) => (
318 <Box key={`c-${c.id}`} flexDirection="column">
319 <Text>
320 <Text bold>{c.id}</Text>
321 <Text dimColor>{` ${c.version} · ${c.profile === 'full' ? 'Full only' : 'Core'} · ${c.kind}`}</Text>
322 </Text>
323 <Text dimColor>{c.summary}</Text>
324 <Box flexDirection="column" marginLeft={2}>
325 {c.rows.map((r, i) => row(r, `c-${c.id}-${i}`))}
326 {c.notes.map((n, i) => (
327 <Text key={`c-${c.id}-n-${i}`} dimColor>{n}</Text>
328 ))}
329 </Box>
330 </Box>
331 ))}
332 <Box flexDirection="column">{view.rows.map((r, i) => row(r, `t-${i}`))}</Box>
333 <Text dimColor>{view.footer}</Text>
334 </Box>
335 )
336}
337types/index.d.ts 80 lines1// The console's session state contract: the one `$.state` value its drawings read.
2//
3// The engine requires this file to be self-contained (no import), so the status
4// model's own types cannot be named here. `status` and each entry's `event` are
5// therefore opaque plain data (`ConsoleData`) at this seam; hooks/model.ts gives
6// them their real types — SkillHeavenStatus and SummonEvent from the one status
7// model — in exactly one place, and nothing else casts.
8
9/** Plain, JSON-shaped data. */
10export type ConsoleData = string | number | boolean | null | ConsoleData[] | { [key: string]: ConsoleData }
11
12export type ConsoleSection = 'session' | 'scope' | 'flow' | 'trust'
13
14/** One summon-tool call the console observed (a real summon, or a /lens preview). */
15export type ConsoleEntryData = {
16 id: number
17 /** A SummonEvent (status model). */
18 event: ConsoleData
19 /** Which agent the host reported for the call; null = the main conversation. */
20 agent: string | null
21 /** How the console came to know: a tool call it watched, or its own /lens preview. */
22 via: 'tool' | 'lens'
23 /** One slot per stored skill: who read its materialized SKILL.md (a label, never a path), or null. */
24 readBy: (string | null)[]
25 /** Skills the result named beyond the bounded number stored here. */
26 omitted: number
27}
28
29/** What the Lens band shows. null = nothing (the default). */
30export type ConsoleBand =
31 | { kind: 'event'; id: number }
32 | { kind: 'looking'; query: string }
33 | { kind: 'not-connected' }
34 | null
35
36/** An agent the host reported (an `agentId` on a tool call, or an Agent call). */
37export type ConsoleAgent = {
38 /** The Agent call's tool_use_id until the host names the agent, then its agentId. */
39 key: string
40 /** The host's agent id, when it has been reported. */
41 id: string | null
42 /** Sanitized: subagent type and the call's own description. */
43 label: string
44 /** running = a foreground call is open; started = launched in the background, end not observed; returned = observed to finish. */
45 state: 'running' | 'started' | 'returned'
46}
47
48export type ConsoleStateData = {
49 /** A SkillHeavenStatus (status model). */
50 status: ConsoleData
51 /** Newest last, at most 50. */
52 entries: ConsoleEntryData[]
53 band: ConsoleBand
54 agents: ConsoleAgent[]
55 /** True once the host reported any agent id this session. */
56 agentIdsSeen: boolean
57 section: ConsoleSection
58 /** UI only: opened intentionally, never by a tool observation. */
59 inspectSection?: boolean
60 bandRequested?: boolean
61 /** The receipt row that is expanded in the Session section. */
62 openEntry: number | null
63 /** The rung command the person typed, sanitized, for the Scope section. */
64 selectedFrom: string | null
65 /** Claude Code's version string, when the host reported it. */
66 hostVersion: string | null
67 seq: number
68}
69
70declare module 'claude-code' {
71 // The optional launcher uses the same bundled server/schema under this
72 // second exact spelling. Generated marketplace tables know only the first.
73 interface McpToolInputs {
74 'mcp__skill-summon__summon': { query: string; limit?: number; surface?: 'any' | 'heaven' | 'hell'; source?: string; preview?: boolean }
75 }
76 interface PluginState {
77 'skill-heaven-console': { state: Shaped<ConsoleStateData> }
78 }
79}
80