MCPcopy Create free account
hub / github.com/anomalyco/opencode / scrollBashProgress

Function scrollBashProgress

packages/opencode/src/cli/cmd/run/tool.ts:640–671  ·  view source on GitHub ↗
(p: ToolProps<typeof BashTool>)

Source from the content-addressed store, hash-verified

638}
639
640function scrollBashProgress(p: ToolProps<typeof BashTool>): string {
641 const out = stripAnsi(p.frame.raw)
642 const cmd = (p.input.command ?? "").trim()
643 const fmt = (text: string) => {
644 const body = text.replace(/^\n+/, "").replace(/\n+$/, "")
645 return body ? `\n${body}` : ""
646 }
647
648 if (!cmd) {
649 return out.replace(/\n+$/, "")
650 }
651
652 const wdRaw = (p.input.workdir ?? "").trim()
653 const wd = wdRaw ? toolPath(wdRaw) : ""
654 const lines = out.split("\n")
655 const first = (lines[0] || "").trim()
656 const second = (lines[1] || "").trim()
657
658 if (wd && (first === wd || first === wdRaw) && second === cmd) {
659 return fmt(lines.slice(2).join("\n"))
660 }
661
662 if (first === cmd || first === `$ ${cmd}`) {
663 return fmt(lines.slice(1).join("\n"))
664 }
665
666 if (wd && (first === `${wd} ${cmd}` || first === `${wdRaw} ${cmd}`)) {
667 return fmt(lines.slice(1).join("\n"))
668 }
669
670 return fmt(out)
671}
672
673function scrollBashFinal(p: ToolProps<typeof BashTool>): string {
674 const code = p.metadata.exit ?? num(p.frame.meta.exitCode) ?? num(p.frame.meta.exit_code)

Callers

nothing calls this directly

Calls 2

toolPathFunction · 0.85
fmtFunction · 0.70

Tested by

no test coverage detected