Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "CMU 313 OpenCode",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",

"postCreateCommand": "sudo apt-get update && sudo apt-get install -y python3 python3-pip build-essential && curl -fsSL https://bun.com/install | bash && curl -sSL https://qlty.sh | bash && cd /workspaces/opencode && bun install",

"remoteEnv": {
"BUN_INSTALL": "/home/vscode/.bun",
"PATH": "/home/vscode/.bun/bin:/home/vscode/.qlty/bin:${containerEnv:PATH}"
}
}
36 changes: 0 additions & 36 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

94 changes: 45 additions & 49 deletions packages/opencode/src/cli/cmd/run/scrollback.shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,57 +18,53 @@ export function entryFailed(commit: StreamCommit): boolean {
return commit.kind === "tool" && (commit.toolState === "error" || commit.part?.state.status === "error")
}

export function entryLook(commit: StreamCommit, theme: RunEntryTheme): { fg: ColorInput; attrs?: number } {
if (commit.kind === "user") {
return {
fg: theme.user.body,
//attrs: TextAttributes.BOLD,
}
}

if (entryFailed(commit)) {
return {
fg: theme.error.body,
attrs: TextAttributes.BOLD,
}
}

if (commit.phase === "final") {
return {
fg: theme.system.body,
attrs: TextAttributes.DIM,
}
}

if (commit.kind === "tool" && commit.phase === "start") {
return {
fg: theme.tool.start ?? theme.tool.body,
}
}

if (commit.kind === "assistant") {
return { fg: theme.assistant.body }
}

if (commit.kind === "reasoning") {
return {
fg: theme.reasoning.body,
attrs: TextAttributes.DIM,
}
}

if (commit.kind === "error") {
return {
fg: theme.error.body,
attrs: TextAttributes.BOLD,
}
}
type EntryLookRule = {
matches: (commit: StreamCommit) => boolean
result: (theme: RunEntryTheme) => { fg: ColorInput; attrs?: number }
}

if (commit.kind === "tool") {
return { fg: theme.tool.body }
}
const entryLookRules: EntryLookRule[] = [
{
matches: (commit) => commit.kind === "user",
result: (theme) => ({ fg: theme.user.body }),
},
{
matches: (commit) => entryFailed(commit),
result: (theme) => ({ fg: theme.error.body, attrs: TextAttributes.BOLD }),
},
{
matches: (commit) => commit.phase === "final",
result: (theme) => ({ fg: theme.system.body, attrs: TextAttributes.DIM }),
},
{
matches: (commit) => commit.kind === "tool" && commit.phase === "start",
result: (theme) => ({ fg: theme.tool.start ?? theme.tool.body }),
},
{
matches: (commit) => commit.kind === "assistant",
result: (theme) => ({ fg: theme.assistant.body }),
},
{
matches: (commit) => commit.kind === "reasoning",
result: (theme) => ({ fg: theme.reasoning.body, attrs: TextAttributes.DIM }),
},
{
matches: (commit) => commit.kind === "error",
result: (theme) => ({ fg: theme.error.body, attrs: TextAttributes.BOLD }),
},
{
matches: (commit) => commit.kind === "tool",
result: (theme) => ({ fg: theme.tool.body }),
},
{
matches: () => true,
result: (theme) => ({ fg: theme.system.body }),
},
]

return { fg: theme.system.body }
export function entryLook(commit: StreamCommit, theme: RunEntryTheme): { fg: ColorInput; attrs?: number } {
const rule = entryLookRules.find((r) => r.matches(commit))!
return rule.result(theme)
}

export function entryColor(commit: StreamCommit, theme: RunTheme): ColorInput {
Expand Down
12 changes: 12 additions & 0 deletions packages/opencode/src/command/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { MCP } from "../mcp"
import { Skill } from "../skill"
import PROMPT_INITIALIZE from "./template/initialize.txt"
import PROMPT_REVIEW from "./template/review.txt"
import PROMPT_SCOTTY from "./template/scotty.txt"
import { LegacyEvent } from "@opencode-ai/schema/legacy-event"

type State = {
Expand Down Expand Up @@ -46,6 +47,7 @@ export function hints(template: string) {
export const Default = {
INIT: "init",
REVIEW: "review",
SCOTTY: "scotty",
} as const

export interface Interface {
Expand Down Expand Up @@ -87,6 +89,16 @@ const layer = Layer.effect(
hints: hints(PROMPT_REVIEW),
}

commands[Default.SCOTTY] = {
name: Default.SCOTTY,
description: "show ascii art of a dog",
source: "command",
get template() {
return PROMPT_SCOTTY
},
hints: hints(PROMPT_SCOTTY),
}

for (const [name, command] of Object.entries(cfg.command ?? {})) {
commands[name] = {
name,
Expand Down
11 changes: 11 additions & 0 deletions packages/opencode/src/command/template/scotty.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Output this ASCII art of a dog:

```
/ \__
( @\___
/ O
/ (_____/
/_____/ U
```

Just output the ASCII art as shown above, nothing else.
Loading
Loading