modscode JA

modscode / Gallery / forge

forge

Forge's board and machine views inside Claude Code.

Code you can checkTerminal + desktopPaneBandToastBox

What it does

  • Draws a pane, a band above the prompt, toasts
  • Adds /forge
  • Hooks session.end, session.start, turn.complete, turn.start
  • Keeps its own state between turns
  • Starts processes

Good points

  • No network calls
  • Written in TypeScript
  • Has a desktop-specific branch
  • Handles errors

Code to start from

Two kinds: a starter modscode writes from the design above, and the lines of the mod's own code that draw it.

Starter (register.tsx)

register.tsx
import type { Register } from 'claude-code'

// Drawn like forge by knacklabs (pane, band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/knacklabs-forge/
// Written by modscode from that reading, not copied from the mod: use it as you like.
// Each value below stands for one the mod works out at run time; put in your own.
export const register: Register = on => {
  // the pane: open it with $.ui.open({ id: 'my-pane', title: "Forge" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box } = $.ui.resolve(e)
    return (
      <Box flexDirection="column" gap={1} />
    )
  })

  // the band above the prompt; what else goes there is drawn under it
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const { Box } = $.ui.resolve(e)
    return (
      <Box flexDirection="column">

        {await next(e)}
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const message = '…'
    const drop = '…'
    await $.ui.toast(`Couldn't check the next step: ${message}`)
    await $.ui.toast(`Couldn't run the next step: ${drop}`)
    return next(e)
  })
}

The mod's own code

Shown under the mod's licence (MIT); its text is below. Keep the notice if you copy these lines.

src/forge/mod/hooks/pane.ts lines 43–70 · Pane
  on('ui.render', { component: 'Pane' }, async ($, e, next) => {
    if (e.requestId !== 'forge' || (e.surface !== 'terminal' && e.surface !== 'desktop')) return next(e)
    const t = $.ui.resolve(e)
    const now = await $.clock.now()
    const children: RenderNode[] = []
    if (tabs.size) children.push(t.Box({ flexDirection: 'row', gap: 1, children: ['Board', ...tabs.keys()].map(name => t.Button({ key: `tab-${name}`, label: name, onPress: () => { selected = name; $.ui.invalidate('ui.render') } })) }))
    const tab = tabs.get(selected)
    if (tab) children.push(tab(e))
    else if (data.error === TOO_OLD) children.push(t.Text({ children: TOO_OLD }))
    else {
      if (!data.board) children.push(t.Text({ dimColor: true, children: 'Loading Forge…' }))
      if (data.board && !data.board.items.length) children.push(t.Text({ children: 'Nothing in progress.' }))
      for (const item of rows(data.board?.items ?? [])) {
        const [state, detail] = itemLines(item, now)
        if (e.surface === 'desktop') {
          const desktop = $.ui.resolve(e)
          children.push(desktop.Markdown({ text: `| Item and status |\n| --- |\n| ${tableCell(state)} |\n| ${tableCell(detail)} |` }))
          children.push(desktop.Svg({ source: timeline(item, now), alt: stages(item).map(s => stageText(s, now)).join(' → '), isInteractive: true }))
        } else {
          children.push(t.Text({ bold: true, wrap: 'wrap', children: state }))
          children.push(t.Text({ wrap: 'wrap', children: detail }))
        }
        for (const render of actions.get(item.kind ?? '') ?? []) children.push(render(item, e))
      }
    }
    if (data.error && data.error !== TOO_OLD) children.push(t.Text({ dimColor: true, children: `Couldn't refresh: ${data.error}` }))
    return t.Box({ flexDirection: 'column', gap: 1, children })
  })
src/forge/mod/hooks/pane.ts lines 71–167 · Band
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    working = e.props.isWorking
    if (e.props.hasSurvey || e.props.maxRows < 1) return next(e)
    const t = $.ui.resolve(e), now = await $.clock.now()
    const command = data.error === TOO_OLD || working ? null : data.next?.next.command
    const narrow = e.props.bodyColumns < 80 || e.props.maxRows === 1
    let lines = summary(data, now, working)
    let compact: { title: string, counts: string, timing: string, tail: string } | undefined
    if (narrow && !data.lanes) lines = lines.slice(0, 1)
    else if (narrow && data.error !== TOO_OLD) {
      const n = laneCounts(data), first = activeRows(data)[0]
      const stage = first && stages(first).find(s => s.status === 'running')
      const counts = data.lanes ? `${n.agentsRunning + (n.test ? 1 : 0)} running, ${n.agentsWaiting}+${n.testsWaiting} waiting · ` : ''
      const step = record(first?.worker).step
      lines = [`${counts}${command ? `1: ${command}` : data.next?.next.line ?? 'Loading Forge…'}${typeof step === 'string' ? ` · ${step}` : ''}`]
      compact = { title: first?.title ?? '', counts, timing: first ? `: ${stage ? stageText(stage, now) : first.stage ?? 'unknown'} (${total(first, now)}) · ` : '', tail: `${data.next?.next.line ?? 'Loading Forge…'}${typeof step === 'string' ? ` · ${step}` : ''}` }
    }
    if ((e.viewport?.columns ?? e.props.bodyColumns) < 144 && data.error !== TOO_OLD) {
      lines[0] += ' · /forge for the board'
      if (compact) compact.tail += ' · /forge for the board'
    }
    const children: RenderNode[] = []
    const firstChildren: RenderNode[] = []
    const first = lines[0] ?? ''
    const lanes = laneCounts(data)
    const counts = !narrow && data.lanes && data.error !== TOO_OLD ? `Agents ${lanes.agentsRunning}/${lanes.size} (${lanes.agentsWaiting} waiting) · Tests: ${lanes.test ? 1 : 0} running (${lanes.testsWaiting} waiting) · ` : ''
    const testTitle = `${lanes.testTitle ?? lanes.test?.item ?? 'idle'} · `
    const titleWidth = Math.min(testTitle.length, Math.max(0, e.props.bodyColumns - counts.length - MIN_TITLE_COLUMNS))
    const nextWidth = Math.max(0, e.props.bodyColumns - counts.length - titleWidth)
    let tailColumns = compact?.tail.length ?? 0
    if (command) {
      const [prefix, suffix = ''] = first.split(`1: ${command}`)
      tailColumns = command.length + 3 + suffix.length
      firstChildren.push(
        t.Text({ children: prefix ?? '', wrap: 'truncate-end' }),
        t.Button({ key: 'next-step', hotkey: '1', plain: true, label: counts && command.length + 3 > nextWidth ? `${Array.from(command).slice(0, Math.max(0, nextWidth - 4)).join('')}…` : command, onPress: async () => {
          if (working) return
          let updated: Next
          try {
            const result = await $.process.run(['forge', 'next', '--json'], { cwd: cwd || data.board?.repo_root, timeoutMs: 20000 })
            if (result.exitCode !== 0) throw new Error((result.stderr || result.stdout || 'Forge did not answer').split(/\r?\n/)[0])
            const value: unknown = JSON.parse(result.stdout)
            const root = record(value), following = record(root.next)
            if (typeof root.version !== 'string' || typeof root.repo_root !== 'string' || typeof following.line !== 'string' || !(following.command === null || typeof following.command === 'string')) throw new Error('Malformed forge next output')
            updated = value as Next
          } catch (error) {
            $.ui.toast(`Couldn't check the next step: ${error instanceof Error ? error.message : String(error)}`)
            return
          }
          data.next = updated
          $.ui.invalidate('ui.render')
          if (updated.next.command !== command || working) return
          try {
            // The published declarations lag the documented asUser option.
            const submission = { text: command, asUser: true }
            const result = await $.prompt.submit(submission)
            if (result.drop !== undefined) $.ui.toast(`Couldn't run the next step: ${result.drop || 'Prompt unavailable'}`)
          } catch (error) {
            $.ui.toast(`Couldn't run the next step: ${error instanceof Error ? error.message : String(error)}`)
          }
        } }),
        t.Text({ children: suffix, wrap: 'truncate-end' }),
      )
    } else firstChildren.push(t.Text({ wrap: 'truncate-end', children: first }))
    if (compact) {
      const fixed = compact.counts.length + compact.timing.length
      const tailWidth = Math.min(tailColumns, Math.max(0, e.props.bodyColumns - fixed - MIN_TITLE_COLUMNS))
      children.push(t.Box({ flexDirection: 'row', width: e.props.bodyColumns, children: [
        t.Box({ width: compact.counts.length, flexShrink: 0, children: t.Text({ children: compact.counts }) }),
        t.Box({ width: Math.max(0, e.props.bodyColumns - fixed - tailWidth), minWidth: 0, children: t.Text({ wrap: 'truncate-end', children: compact.title }) }),
        t.Box({ width: compact.timing.length, flexShrink: 0, children: t.Text({ children: compact.timing }) }),
        t.Box({ width: tailWidth, flexShrink: 0, overflow: 'hidden', flexDirection: 'row', children: command ? firstChildren.slice(1) : t.Text({ wrap: 'truncate-end', children: compact.tail }) }),
      ] }))
    } else if (counts) {
      const step = record(activeRows(data).find(i => typeof record(i.worker).step === 'string')?.worker).step
      const tail = `${data.next?.next.line ?? 'Loading Forge…'}${step ? ` · ${step}` : ''}${(e.viewport?.columns ?? e.props.bodyColumns) < 144 ? ' · /forge for the board' : ''}`
      children.push(t.Box({ flexDirection: 'row', width: e.props.bodyColumns, children: [
        t.Box({ width: counts.length, flexShrink: 0, children: t.Text({ children: counts }) }),
        t.Box({ width: titleWidth, minWidth: 0, children: t.Text({ wrap: 'truncate-end', children: testTitle }) }),
        t.Box({ width: nextWidth, flexShrink: 0, overflow: 'hidden', flexDirection: 'row', children: command ? firstChildren.slice(1) : t.Text({ wrap: 'truncate-end', children: tail }) }),
      ] }))
    } else children.push(command ? t.Box({ flexDirection: 'row', children: firstChildren }) : firstChildren[0]!)
    const active = activeRows(data)
    for (const [n, line] of lines.slice(1, Math.min(3, e.props.maxRows)).entries()) {
      const item = active.length > 2 && n === 1 ? undefined : active[n]
      const timing = item ? itemTime(item, now).slice(item.title.length + 2) : undefined
      let status = timing ?? line
      // Reserve the timing cells; the native surface truncates only the title.
      if (timing && status.length >= e.props.bodyColumns) status = status.replaceAll(' ', '')
      const text = t.Text({ wrap: 'truncate-end', children: status.split('✗').flatMap((part, n) => n ? [t.Text({ color: 'red', children: '✗' }), part] : [part]) })
      children.push(item && timing ? t.Box({ flexDirection: 'row', width: e.props.bodyColumns, children: [
        t.Box({ width: Math.max(0, e.props.bodyColumns - status.length), minWidth: 0, children: t.Text({ wrap: 'truncate-end', children: `${item.title}: ` }) }),
        t.Box({ width: status.length, flexShrink: 0, children: text }),
      ] }) : text)
    }
    return t.Box({ flexDirection: 'column', children })
  })
Licence text (MIT)
MIT License

Copyright (c) 2024 Symphony Forge Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

What its code calls

runs programsenv varsdrives Clauderemembers

The design, read from code

Drawn from the mod's source at the commit read, not from a run: a list is drawn three times, a condition takes its first branch that draws in the desktop app, and a value only the run time knows is shown as a made-up sample (dotted underline) or left out. Colours and type are this site's.

What its code shows

Read from the source at commit 186ef9c83585 on 2026-10-06. The first group decides whether a mod is listed; the rest is for you to weigh. A later commit is not read until the next crawl.

Decides the listing: code you can check
Entry readEvery module hooks/hooks.json names was read.src/forge/mod/hooks/register.ts
ParsesEvery file parses as TypeScript or JavaScript.7 files parsed
All its code is in the modEvery import is a file of the mod or the engine's own module; no packages, no require.all its code is in the mod
ReadableNo minified lines, no eval or new Function, no import of a computed path, no encoded blobs.no minified code, no eval, no encoded blobs
Calls in the openNetwork and programs are reached as $.http.fetch and $.process.run in place, never passed around.every call outside goes through $ in the open
For you to weigh before installing
Where it drawsThe terminal, the desktop app, both, or nothing (hooks only: a guard or a prompt rewriter), as its code says. Shown, never a reason to leave a mod out.draws in the terminal and the desktop app, with its own branch for the desktop
Install lineWhether its repository's own .claude-plugin/marketplace.json lists it, so it installs from that marketplace with the lines on its page.its repository's .claude-plugin/marketplace.json does not list it: no install line to give
Programs on WindowsWhether every program it starts through $.process exists on Windows (tail, date, open, osascript, /usr/… do not).runs no program a Windows PC lacks
NetworkWhether every fetch names its https host in the code.no network
ProgramsWhether every program it starts is named in the code and is not a shell, an interpreter or a network tool.forge
Reads and sendsWhether it both reads files or environment variables and reaches the network.reaches no network
Keys in the sourceWhether the source holds what looks like an API key or a private key.no keys in the source
LicenceAn open licence (MIT, Apache-2.0, BSD, ISC, Unlicense, 0BSD, CC0) with its text lets modscode show its code; otherwise the code is linked.MIT

This is a reading of the code text, not a security review: it does not run the mod, and it cannot see what a program the mod starts does. The check before installing is yours. How mods are chosen

Install it

Check it yourself before you install it. Mods run unsandboxed, with your permissions, and modscode does not vouch for what this code does. Read the code below (or run claude plugin validate . in its folder), weigh what it reaches, and install the commit you read.

Its repository's .claude-plugin/marketplace.json does not list it, so there is no install line to give. Read it as code, or follow its author's README.

Ask Claude about it

With the modscode connector added, Claude can read this design, what its code reaches and its code, and build on them. Ask it like this:

Read the modscode design "knacklabs-forge" with its code and make me a pane like it

Search them from Claude: the MCP connector

Similar designs